integration/gwnavruntimeglue/bulletcollisioninterface/bulletcollisioninterface.h Source File

bulletcollisioninterface.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 #ifndef KyRuntimeGlue_CollisionInterface_H
9 #define KyRuntimeGlue_CollisionInterface_H
10 
13 
14 namespace Kaim
15 {
16  class IndexedMesh;
17  class CollisionData;
18  class World;
19  class HeightField;
20 }
21 
22 class btCollisionWorld;
23 class btDispatcher;
24 class btBroadphaseInterface;
25 class btCollisionConfiguration;
26 class CollisionInterfaceDebugDraw;
27 class btTriangleIndexVertexArray;
28 class btBvhTriangleMeshShape;
29 class btCollisionObject;
30 
33 {
34 public:
35  explicit CollisionInterface(Kaim::World* world = KY_NULL);
36 
37  virtual ~CollisionInterface();
38 
39  // The data within collisionData will be added to the world.
40  virtual KyResult AddCollisionData(Kaim::Ptr<Kaim::CollisionData> collisionData);
41 
42  // The data within collisionData will be removed from the world.
43  virtual KyResult RemoveCollisionData(Kaim::Ptr<Kaim::CollisionData> collisionData);
44 
45  // Perform any processing that may be necessary.
46  virtual KyResult Update();
47 
48  // Perform RayCast from a to b, return true if no hit.
49  virtual Kaim::CollisionRayCastResult RayCast(const Kaim::Vec3f& a, const Kaim::Vec3f& b);
50 
52  // Functions that are not derived.
54  // The data referenced by inputMesh will be stored in collisionData in a format understood by the CollisionInterface.
55  KyResult ConvertIndexedMeshToCollisionData(const Kaim::IndexedMesh& inputMesh, Kaim::Ptr<Kaim::CollisionData> collisionData);
56 
58  // The data in the CollisionWorld will be transformed into a heightfield with the given tilesize.
59  KyResult SaveToHeightField(Kaim::HeightField& heightField, KyFloat32 tileSize);
60 
61 private:
62  struct StaticMesh
63  {
64  btTriangleIndexVertexArray* m_indexVertexArray;
65  btBvhTriangleMeshShape* m_bvhTriMeshShape;
66  btCollisionObject* m_collisionObject;
67  };
68 
69  void Init();
70 
71  Kaim::World* m_navigationWorld;
72  Kaim::Hash<Kaim::CollisionData*, StaticMesh> m_staticMeshes;
73  btCollisionWorld* m_world;
74  btDispatcher* m_dispatcher;
75  btBroadphaseInterface* m_broadphase;
76  btCollisionConfiguration* m_config;
77  CollisionInterfaceDebugDraw* m_debugDraw;
78 };
79 
80 #endif
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
The IndexedMesh class represents a 3D Triangle Mesh with Indexing.
Definition: indexedmesh.h:24
#define KY_NULL
Null value.
Definition: types.h:247
Implementation of ICollisionInterface that uses Bullet.
Definition: bulletcollisioninterface.h:32
An abstract interface for an object that can perform collision queries.
Definition: icollisioninterface.h:26
This class is a runtime container for Gameware Navigation WorldElements such as NavData, Bots, BoxObstacles, TagVolumes...
Definition: world.h:54
Heightfield with a uniform grid of sampled altitudes.
Definition: heightfield.h:51
Definition: gamekitcrowddispersion.h:20
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23