update tests
Allow dragging a spring cloth in all spring cloth tests related to the spring cloth Use gravity acceleration in Earth in all spring cloth tests
This commit is contained in:
@ -16,20 +16,18 @@
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef SPRING_CLOTH_COLLISION_TESH_H
|
||||
#define SPRING_CLOTH_COLLISION_TESH_H
|
||||
#ifndef SPRING_CLOTH_COLLISION_H
|
||||
#define SPRING_CLOTH_COLLISION_H
|
||||
|
||||
extern DebugDraw* g_debugDraw;
|
||||
extern Camera g_camera;
|
||||
extern Settings g_settings;
|
||||
|
||||
class SpringClothCollision : public Test
|
||||
class SpringClothCollision : public SpringClothTest
|
||||
{
|
||||
public:
|
||||
SpringClothCollision()
|
||||
{
|
||||
g_camera.m_zoom = 25.0f;
|
||||
|
||||
b3SpringClothDef def;
|
||||
def.allocator = &m_clothAllocator;
|
||||
def.mesh = &m_clothMesh;
|
||||
@ -47,57 +45,16 @@ public:
|
||||
|
||||
m_clothCapsule.SetFriction(1.0f);
|
||||
|
||||
|
||||
m_cloth.AddShape(&m_clothCapsule);
|
||||
}
|
||||
|
||||
void Step()
|
||||
{
|
||||
float32 dt = g_settings.hertz > 0.0f ? 1.0f / g_settings.hertz : 0.0f;
|
||||
|
||||
if (g_settings.pause)
|
||||
{
|
||||
if (g_settings.singleStep)
|
||||
{
|
||||
g_settings.singleStep = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
dt = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
m_cloth.Step(dt);
|
||||
|
||||
b3Shape** shapes = m_cloth.GetShapes();
|
||||
for (u32 i = 0; i < m_cloth.GetShapeCount(); ++i)
|
||||
{
|
||||
b3Shape* s = shapes[i];
|
||||
|
||||
b3Transform xf;
|
||||
xf.SetIdentity();
|
||||
|
||||
g_debugDraw->DrawShape(s, b3Color_white, xf);
|
||||
}
|
||||
|
||||
m_cloth.Draw(g_debugDraw);
|
||||
|
||||
b3SpringClothStep step = m_cloth.GetStep();
|
||||
|
||||
char text[256];
|
||||
sprintf(text, "Iterations = %u", step.iterations);
|
||||
g_debugDraw->DrawString(text, b3Color_white);
|
||||
}
|
||||
|
||||
static Test* Create()
|
||||
{
|
||||
return new SpringClothCollision();
|
||||
}
|
||||
|
||||
b3GridMesh<10, 10> m_clothMesh;
|
||||
b3StackAllocator m_clothAllocator;
|
||||
b3CapsuleShape m_clothCapsule;
|
||||
b3SpringCloth m_cloth;
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user