consistency
This commit is contained in:
@ -35,16 +35,18 @@ void b3EndProfileScope()
|
||||
g_profiler->PopEvent();
|
||||
}
|
||||
|
||||
Test::Test() : m_bodyDragger(&m_bodyRay, &m_world)
|
||||
Test::Test() :
|
||||
m_bodyDragger(&m_ray, &m_world),
|
||||
m_clothDragger(&m_ray, &m_world)
|
||||
{
|
||||
b3Draw_draw = g_draw;
|
||||
b3_convexCache = g_testSettings->convexCache;
|
||||
|
||||
m_world.SetContactListener(this);
|
||||
|
||||
m_bodyRay.origin.SetZero();
|
||||
m_bodyRay.direction.Set(0.0f, 0.0f, -1.0f);
|
||||
m_bodyRay.fraction = g_camera->m_zFar;
|
||||
m_ray.origin.SetZero();
|
||||
m_ray.direction.Set(0.0f, 0.0f, -1.0f);
|
||||
m_ray.fraction = g_camera->m_zFar;
|
||||
|
||||
m_groundHull.Set(50.0f, 1.0f, 50.0f);
|
||||
m_groundMesh.BuildTree();
|
||||
@ -117,31 +119,51 @@ void Test::Step()
|
||||
|
||||
void Test::MouseMove(const b3Ray3& pw)
|
||||
{
|
||||
m_bodyRay = pw;
|
||||
m_ray = pw;
|
||||
|
||||
if (m_bodyDragger.IsSelected() == true)
|
||||
if (m_bodyDragger.IsDragging() == true)
|
||||
{
|
||||
m_bodyDragger.Drag();
|
||||
}
|
||||
|
||||
if (m_clothDragger.IsDragging() == true)
|
||||
{
|
||||
m_clothDragger.Drag();
|
||||
}
|
||||
}
|
||||
|
||||
void Test::MouseLeftDown(const b3Ray3& pw)
|
||||
{
|
||||
if (m_bodyDragger.IsSelected() == false)
|
||||
if (m_bodyDragger.IsDragging() == false)
|
||||
{
|
||||
if (m_bodyDragger.StartDragging() == true)
|
||||
{
|
||||
BeginDragging();
|
||||
}
|
||||
}
|
||||
|
||||
if (m_clothDragger.IsDragging() == false)
|
||||
{
|
||||
if (m_clothDragger.StartDragging() == true)
|
||||
{
|
||||
BeginDragging();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Test::MouseLeftUp(const b3Ray3& pw)
|
||||
{
|
||||
if (m_bodyDragger.IsSelected() == true)
|
||||
if (m_bodyDragger.IsDragging() == true)
|
||||
{
|
||||
m_bodyDragger.StopDragging();
|
||||
|
||||
EndDragging();
|
||||
}
|
||||
|
||||
if (m_clothDragger.IsDragging() == true)
|
||||
{
|
||||
m_clothDragger.StopDragging();
|
||||
|
||||
EndDragging();
|
||||
}
|
||||
}
|
@ -45,7 +45,13 @@ public:
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
b3RayCastSingleOutput hit;
|
||||
float32 ReportCloth(b3Shape* shape, const b3Vec3& point, const b3Vec3& normal, float32 fraction)
|
||||
{
|
||||
B3_ASSERT(false);
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
b3ShapeRayCastSingleOutput hit;
|
||||
};
|
||||
|
||||
class Test : public b3ContactListener
|
||||
@ -73,7 +79,8 @@ public:
|
||||
|
||||
b3World m_world;
|
||||
|
||||
b3Ray3 m_bodyRay;
|
||||
b3Ray3 m_ray;
|
||||
b3ClothDragger m_clothDragger;
|
||||
b3BodyDragger m_bodyDragger;
|
||||
|
||||
b3BoxHull m_groundHull;
|
||||
|
@ -22,14 +22,9 @@
|
||||
class ClothTest : public Test
|
||||
{
|
||||
public:
|
||||
ClothTest() : m_clothDragger(&m_clothRay, m_cloth)
|
||||
ClothTest()
|
||||
{
|
||||
m_world.SetGravity(b3Vec3(0.0f, -10.0f, 0.0f));
|
||||
|
||||
m_clothRay.origin.SetZero();
|
||||
m_clothRay.direction.Set(0.0f, 0.0f, -1.0f);
|
||||
m_clothRay.fraction = g_camera->m_zFar;
|
||||
|
||||
m_cloth = nullptr;
|
||||
}
|
||||
|
||||
@ -47,41 +42,13 @@ public:
|
||||
float32 E = m_cloth->GetEnergy();
|
||||
g_draw->DrawString(b3Color_white, "E = %f", E);
|
||||
|
||||
if (m_clothDragger.IsSelected() == true)
|
||||
if (m_clothDragger.IsDragging() == true)
|
||||
{
|
||||
g_draw->DrawSegment(m_clothDragger.GetPointA(), m_clothDragger.GetPointB(), b3Color_white);
|
||||
}
|
||||
}
|
||||
|
||||
void MouseMove(const b3Ray3& pw)
|
||||
{
|
||||
m_clothRay = pw;
|
||||
|
||||
if (m_clothDragger.IsSelected() == true)
|
||||
{
|
||||
m_clothDragger.Drag();
|
||||
}
|
||||
}
|
||||
|
||||
void MouseLeftDown(const b3Ray3& pw)
|
||||
{
|
||||
if (m_clothDragger.IsSelected() == false)
|
||||
{
|
||||
m_clothDragger.StartDragging();
|
||||
}
|
||||
}
|
||||
|
||||
void MouseLeftUp(const b3Ray3& pw)
|
||||
{
|
||||
if (m_clothDragger.IsSelected() == true)
|
||||
{
|
||||
m_clothDragger.StopDragging();
|
||||
}
|
||||
}
|
||||
|
||||
b3Ray3 m_clothRay;
|
||||
|
||||
b3Cloth* m_cloth;
|
||||
b3ClothDragger m_clothDragger;
|
||||
};
|
||||
|
||||
#endif
|
@ -69,7 +69,7 @@ public:
|
||||
|
||||
void Step()
|
||||
{
|
||||
if (m_bodyDragger.IsSelected())
|
||||
if (m_bodyDragger.IsDragging())
|
||||
{
|
||||
if (m_bodyDragger.GetBody() != m_character)
|
||||
{
|
||||
|
@ -178,8 +178,8 @@ public:
|
||||
|
||||
void CastRay(const b3Vec3 p1, const b3Vec3 p2) const
|
||||
{
|
||||
b3RayCastSingleOutput out;
|
||||
if (m_world.RayCastSingle(&out, p1, p2))
|
||||
b3ShapeRayCastSingleOutput out;
|
||||
if (m_world.RayCastSingleShape(&out, p1, p2))
|
||||
{
|
||||
g_draw->DrawSegment(p1, out.point, b3Color_green);
|
||||
|
||||
|
@ -156,7 +156,7 @@ public:
|
||||
g_draw->DrawSolidTriangle(n2, v1, v3, v2, color);
|
||||
}
|
||||
|
||||
if (m_clothDragger.IsSelected() == true)
|
||||
if (m_clothDragger.IsDragging() == true)
|
||||
{
|
||||
g_draw->DrawSegment(m_clothDragger.GetPointA(), m_clothDragger.GetPointB(), b3Color_white);
|
||||
}
|
||||
|
Reference in New Issue
Block a user