13 #ifndef hifi_MyCharacterController_h
14 #define hifi_MyCharacterController_h
16 #include <CharacterController.h>
18 #include <PhysicsEngine.h>
20 class btCollisionShape;
22 class DetailedMotionState;
24 class MyCharacterController :
public CharacterController {
26 explicit MyCharacterController(std::shared_ptr<MyAvatar> avatar,
const FollowTimePerType& followTimeRemainingPerType);
27 ~MyCharacterController ();
29 void addToWorld()
override;
30 void updateShapeIfNecessary()
override;
35 class RayShotgunResult {
38 float hitFraction { 1.0f };
39 bool walkable {
true };
43 bool testRayShotgun(
const glm::vec3& position,
const glm::vec3& step, RayShotgunResult& result);
45 void setDensity(btScalar density) { _density = density; }
47 const btCollisionShape* createDetailedCollisionShapeForJoint(int32_t jointIndex);
48 DetailedMotionState* createDetailedMotionStateForJoint(int32_t jointIndex);
49 std::vector<DetailedMotionState*>& getDetailedMotionStates() {
return _detailedMotionStates; }
50 void clearDetailedMotionStates();
52 void buildPhysicsTransaction(PhysicsEngine::Transaction& transaction);
54 struct RayAvatarResult {
55 bool _intersect {
false };
56 bool _isBound {
false };
57 QUuid _intersectWithAvatar;
58 int32_t _intersectWithJoint { -1 };
59 float _distance { 0.0f };
60 float _maxDistance { 0.0f };
61 QVariantMap _extraInfo;
62 glm::vec3 _intersectionPoint;
63 glm::vec3 _intersectionNormal;
64 std::vector<int32_t> _boundJoints;
66 std::vector<RayAvatarResult> rayTest(
const btVector3& origin,
const btVector3& direction,
const btScalar& length,
67 const QVector<uint>& jointsToExclude)
const;
69 int32_t computeCollisionMask()
const override;
70 void handleChangedCollisionMask()
override;
72 void setCollideWithOtherAvatars(
bool collideWithOtherAvatars) { _collideWithOtherAvatars = collideWithOtherAvatars; }
74 bool needsSafeLandingSupport()
const;
77 void initRayShotgun(
const btCollisionWorld* world);
78 void updateMassProperties()
override;
81 btConvexHullShape* computeShape()
const;
84 std::shared_ptr<MyAvatar> _avatar {
nullptr };
87 btAlignedObjectArray<btVector3> _topPoints;
88 btAlignedObjectArray<btVector3> _bottomPoints;
89 btScalar _density { 1.0f };
91 std::vector<DetailedMotionState*> _detailedMotionStates;
92 bool _collideWithOtherAvatars {
true };