This commit is contained in:
Irlan 2018-04-06 22:07:35 -03:00
parent 8e615d3ca4
commit 5401e8aba2
4 changed files with 23 additions and 27 deletions

View File

@ -61,7 +61,7 @@
#include <testbed/tests/cloth_test.h>
#include <testbed/tests/spring_cloth_test.h>
#include <testbed/tests/spring_cloth_collision_test.h>
#include <testbed/tests/cloth_dragger.h>
#include <testbed/tests/spring_cloth_dragger.h>
#include <testbed/tests/rope_test.h>
#include <testbed/tests/mass_spring.h>
#include <testbed/tests/shift_center.h>
@ -111,7 +111,7 @@ TestEntry g_tests[] =
{ "Cloth", &Cloth::Create },
{ "Spring Cloth", &SpringCloth::Create },
{ "Spring Cloth Collision", &SpringClothCollision::Create },
{ "Spring Cloth Dragging", &ClothDraggerTest::Create },
{ "Spring Cloth Dragging", &SpringClothDraggerTest::Create },
{ "Rope", &Rope::Create },
{ "Mass-Spring System", &MassSpring::Create },
{ "Shift Center", &ShiftCenter::Create },

View File

@ -41,13 +41,14 @@ public:
m_cloth.Initialize(def);
m_aabb.m_lower.Set(-5.0f, -1.0f, -6.0f);
m_aabb.m_upper.Set(5.0f, 1.0f, -4.0f);
b3AABB3 aabb;
aabb.m_lower.Set(-5.0f, -1.0f, -6.0f);
aabb.m_upper.Set(5.0f, 1.0f, -4.0f);
b3Particle* vs = m_cloth.GetVertices();
for (u32 i = 0; i < m_cloth.GetVertexCount(); ++i)
{
if (m_aabb.Contains(vs[i].p))
if (aabb.Contains(vs[i].p))
{
vs[i].im = 0.0f;
}
@ -72,8 +73,6 @@ public:
m_cloth.Step(dt, g_settings.positionIterations);
m_cloth.Draw(g_debugDraw);
//g_debugDraw->DrawAABB(m_aabb, b3Color_black);
}
static Test* Create()
@ -83,7 +82,6 @@ public:
b3GridMesh<10, 10> m_clothMesh;
b3Cloth m_cloth;
b3AABB3 m_aabb;
};
#endif

View File

@ -16,8 +16,8 @@
* 3. This notice may not be removed or altered from any source distribution.
*/
#ifndef CLOTH_DRAGGER_TESH_H
#define CLOTH_DRAGGER_TESH_H
#ifndef SPRING_CLOTH_DRAGGER_TESH_H
#define SPRING_CLOTH_DRAGGER_TESH_H
extern DebugDraw* g_debugDraw;
extern Camera g_camera;
@ -203,10 +203,10 @@ private:
b3MassType m_t1, m_t2, m_t3;
};
class ClothDraggerTest : public Test
class SpringClothDraggerTest : public Test
{
public:
ClothDraggerTest() : m_clothDragger(&m_clothRay, &m_cloth)
SpringClothDraggerTest() : m_clothDragger(&m_clothRay, &m_cloth)
{
g_camera.m_zoom = 25.0f;
@ -214,18 +214,14 @@ public:
def.allocator = &m_clothAllocator;
def.mesh = &m_clothMesh;
def.density = 0.2f;
def.ks = 10000.0f;
def.gravity.Set(0.0f, -10.0f, 0.0f);
def.ks = 100000.0f;
def.gravity.Set(2.5f, 5.0f, -10.0f);
m_cloth.Initialize(def);
m_clothRay.origin.SetZero();
m_clothRay.direction.Set(0.0f, 0.0f, -1.0f);
m_clothRay.fraction = g_camera.m_zFar;
b3AABB3 aabb;
aabb.m_lower.Set(-5.0f, -1.0f, -4.0f);
aabb.m_upper.Set(5.0f, 1.0f, -2.0f);
aabb.m_lower.Set(-5.0f, -1.0f, -6.0f);
aabb.m_upper.Set(5.0f, 1.0f, -4.0f);
for (u32 i = 0; i < def.mesh->vertexCount; ++i)
{
@ -234,6 +230,10 @@ public:
m_cloth.SetType(i, b3MassType::e_staticMass);
}
}
m_clothRay.origin.SetZero();
m_clothRay.direction.Set(0.0f, 0.0f, -1.0f);
m_clothRay.fraction = g_camera.m_zFar;
}
void Step()
@ -308,7 +308,7 @@ public:
static Test* Create()
{
return new ClothDraggerTest();
return new SpringClothDraggerTest();
}
Ray3 m_clothRay;

View File

@ -35,18 +35,17 @@ public:
def.mesh = &m_clothMesh;
def.density = 0.2f;
def.ks = 100000.0f;
def.kb = 1000000.0f;
def.kd = 100.0f;
def.gravity.Set(2.5f, 5.0f, -10.0f);
m_cloth.Initialize(def);
m_aabb.m_lower.Set(-5.0f, -1.0f, -6.0f);
m_aabb.m_upper.Set(5.0f, 1.0f, -4.0f);
b3AABB3 aabb;
aabb.m_lower.Set(-5.0f, -1.0f, -6.0f);
aabb.m_upper.Set(5.0f, 1.0f, -4.0f);
for (u32 i = 0; i < def.mesh->vertexCount; ++i)
{
if (m_aabb.Contains(def.mesh->vertices[i]))
if (aabb.Contains(def.mesh->vertices[i]))
{
m_cloth.SetType(i, b3MassType::e_staticMass);
}
@ -87,7 +86,6 @@ public:
b3GridMesh<10, 10> m_clothMesh;
b3StackAllocator m_clothAllocator;
b3SpringCloth m_cloth;
b3AABB3 m_aabb;
};
#endif