diff --git a/src/easymesh/easymesh.cpp b/src/easymesh/easymesh.cpp index 6eaf9c6f..70715873 100644 --- a/src/easymesh/easymesh.cpp +++ b/src/easymesh/easymesh.cpp @@ -304,7 +304,10 @@ void EasyMesh::AppendCylinder(int nsides, float h, float r1, float r2, vec3 p1(r1, -h * .5f, 0.f), p2(r2, h * .5f, 0.f), n; /* Construct normal */ - n = p2; + if (r2 != .0f) + n = vec3(r2, h * .5f, 0.f); + else + n = vec3(r1, h * .5f, 0.f); n.y = r1 * (r1 - r2) / h; if (!smooth) n = mat3::rotate(180.0f / nsides, 0.f, 1.f, 0.f) * n; diff --git a/test/PhysicObject.h b/test/PhysicObject.h index 5a2724cf..721c7189 100644 --- a/test/PhysicObject.h +++ b/test/PhysicObject.h @@ -53,13 +53,23 @@ public: MeshRand << "[sc#ada asph16 2 2 2]"; MeshRand << "[sc#aad asph16 2 2 2]"; + int ConeLimit = MeshRand.Count(); + + MeshRand << "[sc#add scb#add ad16 2 0 rx180 ty-1 ac16 2 2 0 0 0]"; + MeshRand << "[sc#dad scb#dad ad16 2 0 rx180 ty-1 ac16 2 2 0 0 0]"; + MeshRand << "[sc#dda scb#dda ad16 2 0 rx180 ty-1 ac16 2 2 0 0 0]"; + MeshRand << "[sc#daa scb#daa ad16 2 0 rx180 ty-1 ac16 2 2 0 0 0]"; + MeshRand << "[sc#ada scb#ada ad16 2 0 rx180 ty-1 ac16 2 2 0 0 0]"; + MeshRand << "[sc#aad scb#aad ad16 2 0 rx180 ty-1 ac16 2 2 0 0 0]"; int RandValue = (int)(lol::RandF() * (MeshRand.Count() - 1)); m_mesh.Compile(MeshRand[RandValue]); vec3 BoxSize = vec3(2.0f); - if (RandValue >= SphereLimit) + if (RandValue >= SphereLimit && RandValue < ConeLimit) m_physics.SetShapeToSphere(BoxSize.x); + else if (RandValue >= ConeLimit) + m_physics.SetShapeToCone(BoxSize.x, BoxSize.y); else m_physics.SetShapeToBox(BoxSize); m_physics.SetMass(base_mass); diff --git a/test/Physics/EasyPhysics.cpp b/test/Physics/EasyPhysics.cpp index 6d98970d..2cc5d2c2 100644 --- a/test/Physics/EasyPhysics.cpp +++ b/test/Physics/EasyPhysics.cpp @@ -73,6 +73,12 @@ void EasyPhysics::SetShapeToSphere(float radius) SetShapeTo(new btSphereShape(radius * LOL2BT_UNIT * LOL2BT_SIZE)); } +void EasyPhysics::SetShapeToCone(float radius, float height) +{ + SetShapeTo(new btConeShape( radius * LOL2BT_UNIT, + height * LOL2BT_UNIT)); +} + //------------------------------------------------------------------------- //Base Location/Rotation setup //-- diff --git a/test/Physics/EasyPhysics.h b/test/Physics/EasyPhysics.h index 6cc4f290..e8a3a27a 100644 --- a/test/Physics/EasyPhysics.h +++ b/test/Physics/EasyPhysics.h @@ -37,6 +37,7 @@ public: void SetShapeToBox(lol::vec3& box_size); void SetShapeToSphere(float radius); + void SetShapeToCone(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(); @@ -62,6 +63,7 @@ public: EasyPhysics() { } void SetShapeToBox(lol::vec3& BoxSize) { } + void SetShapeToSphere(float radius) { } void SetBaseTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f))) { } void SetMass(float mass) { } void InitBodyToRigid() { }