Update test

This commit is contained in:
Irlan 2019-05-24 20:36:33 -03:00
parent 416157bccf
commit c696cb1a86

View File

@ -26,18 +26,11 @@ class SoftBody : public Test
public: public:
SoftBody() SoftBody()
{ {
m_mesh.SetAsSphere(5.0f, 1);
for (u32 i = 0; i < m_mesh.vertexCount; ++i)
{
m_mesh.vertices[i].y += 10.0f;
}
// Create soft body // Create soft body
b3SoftBodyDef def; b3SoftBodyDef def;
def.mesh = &m_mesh; def.mesh = &m_mesh;
def.density = 0.2f; def.density = 0.2f;
def.E = 100.0f; def.E = 1000.0f;
def.nu = 0.33f; def.nu = 0.33f;
m_body = new b3SoftBody(def); m_body = new b3SoftBody(def);
@ -54,23 +47,37 @@ public:
n->SetFriction(0.2f); n->SetFriction(0.2f);
} }
// Create ground // Create body
{ {
b3BodyDef bd; b3BodyDef bd;
bd.type = e_staticBody; bd.type = e_staticBody;
bd.position.x = -3.5f;
b3Body* b = m_world.CreateBody(bd); b3Body* b = m_world.CreateBody(bd);
m_groundHull.SetAsCylinder(20.0f, 2.0f); m_wallHull.Set(1.0f, 5.0f, 5.0f);
b3HullShape groundShape; b3HullShape wallShape;
groundShape.m_hull = &m_groundHull; wallShape.m_hull = &m_wallHull;
b3ShapeDef sd; b3ShapeDef sd;
sd.shape = &groundShape; sd.shape = &wallShape;
sd.friction = 0.3f;
b->CreateShape(sd); b3Shape* wall = b->CreateShape(sd);
}
b3AABB3 aabb;
aabb.m_lower.Set(-3.0f, -5.0f, -5.0f);
aabb.m_upper.Set(-2.0f, 5.0f, 5.0f);
for (u32 i = 0; i < m_mesh.vertexCount; ++i)
{
b3SoftBodyNode* n = m_body->GetVertexNode(i);
b3Vec3 p = n->GetPosition();
if (aabb.Contains(p))
{
n->SetType(e_staticSoftBodyNode);
}
} }
m_bodyDragger = new b3SoftBodyDragger(&m_ray, m_body); m_bodyDragger = new b3SoftBodyDragger(&m_ray, m_body);
@ -144,12 +151,12 @@ public:
return new SoftBody(); return new SoftBody();
} }
b3QSoftBodyMesh m_mesh; b3BlockSoftBodyMesh<5, 2, 2> m_mesh;
b3SoftBody* m_body; b3SoftBody* m_body;
b3SoftBodyDragger* m_bodyDragger; b3SoftBodyDragger* m_bodyDragger;
b3QHull m_groundHull; b3BoxHull m_wallHull;
}; };
#endif #endif