diff --git a/test/PhysicObject.h b/test/PhysicObject.h index 0f3e7e92..22776126 100644 --- a/test/PhysicObject.h +++ b/test/PhysicObject.h @@ -71,6 +71,15 @@ public: MeshRand << "[sc#ada scb#ada ad16 2 0 rx180 ty-1 my ac16 2 2 2 0 0]"; MeshRand << "[sc#aad scb#aad ad16 2 0 rx180 ty-1 my ac16 2 2 2 0 0]"; + int CapsLimit = MeshRand.Count(); + + MeshRand << "[sc#add scb#add asph16 2 2 2 ty-1 my ac16 2 1 1 0 0]"; + MeshRand << "[sc#dad scb#dad asph16 2 2 2 ty-1 my ac16 2 1 1 0 0]"; + MeshRand << "[sc#dda scb#dda asph16 2 2 2 ty-1 my ac16 2 1 1 0 0]"; + MeshRand << "[sc#daa scb#daa asph16 2 2 2 ty-1 my ac16 2 1 1 0 0]"; + MeshRand << "[sc#ada scb#ada asph16 2 2 2 ty-1 my ac16 2 1 1 0 0]"; + MeshRand << "[sc#aad scb#aad asph16 2 2 2 ty-1 my ac16 2 1 1 0 0]"; + int RandValue = (int)(lol::RandF() * (MeshRand.Count() - 1)); m_mesh.Compile(MeshRand[RandValue]); @@ -81,8 +90,10 @@ public: m_physics.SetShapeToSphere(BoxSize.x); else if (RandValue < CylLimit) m_physics.SetShapeToCone(BoxSize.x, BoxSize.y); - else + else if (RandValue < CapsLimit) m_physics.SetShapeToCylinder(BoxSize); + else + m_physics.SetShapeToCapsule(BoxSize.x, BoxSize.y); m_physics.SetMass(base_mass); m_physics.SetBaseTransform(base_location); diff --git a/test/Physics/EasyPhysics.cpp b/test/Physics/EasyPhysics.cpp index 0191821c..50756db3 100644 --- a/test/Physics/EasyPhysics.cpp +++ b/test/Physics/EasyPhysics.cpp @@ -93,6 +93,12 @@ void EasyPhysics::SetShapeToCylinder(lol::vec3& cyl_size) SetShapeTo(new btCylinderShape(LOL2BT_VEC3(new_cyl_size))); } +void EasyPhysics::SetShapeToCapsule(float radius, float height) +{ + SetShapeTo(new btCapsuleShape( radius * LOL2BT_UNIT * LOL2BT_SIZE, + height * LOL2BT_UNIT * LOL2BT_SIZE)); +} + //------------------------------------------------------------------------- //Base Location/Rotation setup //-- diff --git a/test/Physics/EasyPhysics.h b/test/Physics/EasyPhysics.h index cb0b8f86..3f8b3984 100644 --- a/test/Physics/EasyPhysics.h +++ b/test/Physics/EasyPhysics.h @@ -40,6 +40,7 @@ public: void SetShapeToSphere(float radius); void SetShapeToCone(float radius, float height); void SetShapeToCylinder(lol::vec3& cyl_size); + void SetShapeToCapsule(float radius, float height); void SetBaseTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f))); void SetMass(float mass); @@ -67,6 +68,10 @@ public: void SetShapeToBox(lol::vec3& BoxSize) { } void SetShapeToSphere(float radius) { } + void SetShapeToCone(float radius, float height) { } + void SetShapeToCylinder(lol::vec3& cyl_size) { } + void SetShapeToCapsule(float radius, float height) { } + void SetBaseTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f))) { } void SetMass(float mass) { } void InitBodyToRigid() { }