Overte C++ Documentation
CharacterGhostObject.h
1 //
2 // CharacterGhostObject.h
3 // libraries/physics/src
4 //
5 // Created by Andrew Meadows 2016.08.26
6 // Copyright 2016 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_CharacterGhostObject_h
13 #define hifi_CharacterGhostObject_h
14 
15 #include <stdint.h>
16 
17 #include <btBulletDynamicsCommon.h>
18 #include <BulletCollision/CollisionDispatch/btGhostObject.h>
19 #include <stdint.h>
20 
21 #include "CharacterSweepResult.h"
22 #include "CharacterRayResult.h"
23 
24 class CharacterGhostShape;
25 
26 class CharacterGhostObject : public btGhostObject {
27 public:
28  CharacterGhostObject() { }
29  ~CharacterGhostObject();
30 
31  void setCollisionGroupAndMask(int32_t group, int32_t mask);
32  void getCollisionGroupAndMask(int32_t& group, int32_t& mask) const;
33 
34  void setRadiusAndHalfHeight(btScalar radius, btScalar halfHeight);
35  void setUpDirection(const btVector3& up);
36 
37  void setCharacterShape(btConvexHullShape* shape);
38 
39  void setCollisionWorld(btCollisionWorld* world);
40 
41  bool rayTest(const btVector3& start,
42  const btVector3& end,
43  CharacterRayResult& result) const;
44 
45  void refreshOverlappingPairCache();
46 
47 protected:
48  void removeFromWorld();
49  void addToWorld();
50 
51 protected:
52  btCollisionWorld* _world { nullptr }; // input, pointer to world
53  btScalar _halfHeight { 0.0f };
54  btScalar _radius { 0.0f };
55  btConvexHullShape* _characterShape { nullptr }; // input, shape of character
56  CharacterGhostShape* _ghostShape { nullptr }; // internal, shape whose Aabb is used for overlap cache
57  int32_t _collisionFilterGroup { 0 };
58  int32_t _collisionFilterMask { 0 };
59  bool _inWorld { false }; // internal, was added to world
60 };
61 
62 #endif // hifi_CharacterGhostObject_h