integration/gwnavruntimeglue/bulletcollisioninterface/bulletcollisioninterface.h Source File

bulletcollisioninterface.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 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 #pragma once
8 
11 
12 namespace Kaim
13 {
14 class IndexedMesh;
15 class CollisionData;
16 class World;
17 class HeightField;
18 }
19 
20 class btCollisionWorld;
21 class btDispatcher;
22 class btBroadphaseInterface;
23 class btCollisionConfiguration;
24 class CollisionInterfaceDebugDraw;
25 class btTriangleIndexVertexArray;
26 class btBvhTriangleMeshShape;
27 class btCollisionObject;
28 
29 namespace KyGlue
30 {
31 
34 {
35 public:
36  explicit BulletCollisionInterface(Kaim::World* world = nullptr);
37 
38  virtual ~BulletCollisionInterface();
39 
40  // The data within collisionData will be added to the world.
41  virtual KyResult AddCollisionData(Kaim::Ptr<Kaim::CollisionData> collisionData);
42 
43  // The data within collisionData will be removed from the world.
44  virtual KyResult RemoveCollisionData(Kaim::Ptr<Kaim::CollisionData> collisionData);
45 
46  // Perform any processing that may be necessary.
47  virtual KyResult Update();
48 
49  // Perform RayCast from a to b, return true if no hit.
50  virtual Kaim::CollisionRayCastResult RayCast(const Kaim::Vec3f& a, const Kaim::Vec3f& b);
51 
53  // Functions that are not derived.
55  // The data referenced by inputMesh will be stored in collisionData in a format understood by the CollisionInterface.
56  KyResult ConvertIndexedMeshToCollisionData(const Kaim::IndexedMesh& inputMesh, Kaim::Ptr<Kaim::CollisionData> collisionData);
57 
59  // The data in the CollisionWorld will be transformed into a heightfield with the given tilesize.
60  KyResult SaveToHeightField(Kaim::HeightField& heightField, KyFloat32 tileSize);
61 
62 private:
63  struct StaticMesh
64  {
65  btTriangleIndexVertexArray* m_indexVertexArray;
66  btBvhTriangleMeshShape* m_bvhTriMeshShape;
67  btCollisionObject* m_collisionObject;
68  };
69 
70  void Init();
71 
72  Kaim::World* m_navigationWorld;
73  Kaim::Hash<Kaim::CollisionData*, StaticMesh> m_staticMeshes;
74  btCollisionWorld* m_world;
75  btDispatcher* m_dispatcher;
76  btBroadphaseInterface* m_broadphase;
77  btCollisionConfiguration* m_config;
78  CollisionInterfaceDebugDraw* m_debugDraw;
79 };
80 
81 }
82 
Wraps a IndexedMeshBlob either as IndexedMeshBlob* or as Ptr< />> Also adds ...
Definition: indexedmesh.h:18
Definition: defaultgeneratorglue.h:14
An abstract interface for an object that can perform collision queries.
Definition: icollisioninterface.h:25
This class is a runtime container for Autodesk Navigation WorldElements such as NavData, Bots, BoxObstacles, TagVolumes...
Definition: world.h:52
Navigation return code class.
Definition: types.h:108
Heightfield with a uniform grid of sampled altitudes.
Definition: heightfield.h:47
CollisionRayCastResult
CollisionRayCastResult.
Definition: collisiontypes.h:15
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
Implementation of ICollisionInterface that uses Bullet.
Definition: bulletcollisioninterface.h:33
float KyFloat32
float
Definition: types.h:32
3d vector using 32bits floating points.
Definition: vec3f.h:16