This commit is contained in:
Irlan
2018-04-06 21:54:13 -03:00
parent f11ec48adc
commit 62e12d6205
10 changed files with 56 additions and 117 deletions

View File

@ -29,7 +29,7 @@ public:
b3Body* ground = m_world.CreateBody(bdef);
b3MeshShape ms;
ms.m_mesh = m_meshes + e_gridMesh;
ms.m_mesh = &m_groundMesh;
b3ShapeDef sd;
sd.shape = &ms;

View File

@ -314,7 +314,7 @@ public:
Ray3 m_clothRay;
b3StackAllocator m_clothAllocator;
b3GridMesh<5, 5> m_clothMesh;
b3GridMesh<10, 10> m_clothMesh;
b3SpringCloth m_cloth;
ClothDragger m_clothDragger;

View File

@ -31,7 +31,7 @@ public:
g_camera.m_zoom = 25.0f;
b3ClothDef def;
def.mesh = m_meshes + e_clothMesh;
def.mesh = &m_clothMesh;
def.density = 0.2f;
def.gravity.Set(2.5f, 5.0f, -10.0f);
def.k1 = 0.2f;
@ -81,6 +81,7 @@ public:
return new Cloth();
}
b3GridMesh<10, 10> m_clothMesh;
b3Cloth m_cloth;
b3AABB3 m_aabb;
};

View File

@ -24,12 +24,20 @@ class MeshContactTest : public Test
public:
MeshContactTest()
{
// Transform grid into a terrain
for (u32 i = 0; i < m_terrainMesh.vertexCount; ++i)
{
m_terrainMesh.vertices[i].y = RandomFloat(0.0f, 1.0f);
}
m_terrainMesh.BuildTree();
{
b3BodyDef bd;
m_ground = m_world.CreateBody(bd);
b3MeshShape ms;
ms.m_mesh = m_meshes + e_gridMesh;
ms.m_mesh = &m_groundMesh;
b3ShapeDef sd;
sd.shape = &ms;
@ -130,7 +138,7 @@ public:
if (key == GLFW_KEY_G)
{
b3MeshShape ms;
ms.m_mesh = m_meshes + e_gridMesh;
ms.m_mesh = &m_groundMesh;
b3ShapeDef sd;
sd.shape = &ms;
@ -141,7 +149,7 @@ public:
if (key == GLFW_KEY_T)
{
b3MeshShape ms;
ms.m_mesh = m_meshes + e_terrainMesh;
ms.m_mesh = &m_terrainMesh;
b3ShapeDef sd;
sd.shape = &ms;
@ -169,6 +177,8 @@ public:
return new MeshContactTest();
}
b3GridMesh<25, 25> m_terrainMesh;
b3Body* m_ground;
b3Body* m_body;
};

View File

@ -30,7 +30,7 @@ public:
b3Body* ground = m_world.CreateBody(bd);
b3MeshShape ms;
ms.m_mesh = m_meshes + e_gridMesh;
ms.m_mesh = &m_groundMesh;
b3ShapeDef sd;
sd.shape = &ms;

View File

@ -32,7 +32,7 @@ public:
b3SpringClothDef def;
def.allocator = &m_clothAllocator;
def.mesh = m_meshes + e_clothMesh;
def.mesh = &m_clothMesh;
def.density = 0.2f;
def.ks = 1000.0f;
def.kd = 0.0f;
@ -94,6 +94,7 @@ public:
return new SpringClothCollision();
}
b3GridMesh<10, 10> m_clothMesh;
b3StackAllocator m_clothAllocator;
b3CapsuleShape m_clothCapsule;
b3SpringCloth m_cloth;

View File

@ -32,7 +32,7 @@ public:
b3SpringClothDef def;
def.allocator = &m_clothAllocator;
def.mesh = m_meshes + e_clothMesh;
def.mesh = &m_clothMesh;
def.density = 0.2f;
def.ks = 100000.0f;
def.kb = 1000000.0f;
@ -84,6 +84,7 @@ public:
return new SpringCloth();
}
b3GridMesh<10, 10> m_clothMesh;
b3StackAllocator m_clothAllocator;
b3SpringCloth m_cloth;
b3AABB3 m_aabb;

View File

@ -119,14 +119,6 @@ public:
class Test : public b3ContactListener
{
public:
enum Meshes
{
e_gridMesh,
e_terrainMesh,
e_clothMesh,
e_maxMeshes,
};
Test();
virtual ~Test();
@ -146,12 +138,13 @@ public:
virtual void Dump() { }
b3World m_world;
b3RayCastSingleOutput m_rayHit; // ray hit local space
b3RayCastSingleOutput m_rayHit;
b3MouseJoint* m_mouseJoint;
b3BoxHull m_boxHull;
b3BoxHull m_groundHull;
b3BoxHull m_boxHull;
b3Mesh m_meshes[e_maxMeshes];
b3GridMesh<50, 50> m_groundMesh;
};
#endif
#endif