consistency
This commit is contained in:
parent
db54750a87
commit
2af8cff389
@ -51,7 +51,7 @@ public:
|
|||||||
return 1.0f;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
b3ShapeRayCastSingleOutput hit;
|
b3RayCastSingleShapeOutput hit;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Test : public b3ContactListener
|
class Test : public b3ContactListener
|
||||||
|
@ -178,7 +178,7 @@ public:
|
|||||||
|
|
||||||
void CastRay(const b3Vec3 p1, const b3Vec3 p2) const
|
void CastRay(const b3Vec3 p1, const b3Vec3 p2) const
|
||||||
{
|
{
|
||||||
b3ShapeRayCastSingleOutput out;
|
b3RayCastSingleShapeOutput out;
|
||||||
if (m_world.RayCastSingleShape(&out, p1, p2))
|
if (m_world.RayCastSingleShape(&out, p1, p2))
|
||||||
{
|
{
|
||||||
g_draw->DrawSegment(p1, out.point, b3Color_green);
|
g_draw->DrawSegment(p1, out.point, b3Color_green);
|
||||||
|
@ -48,7 +48,7 @@ public:
|
|||||||
{
|
{
|
||||||
B3_ASSERT(m_mouseJoint == nullptr);
|
B3_ASSERT(m_mouseJoint == nullptr);
|
||||||
|
|
||||||
b3ShapeRayCastSingleOutput out;
|
b3RayCastSingleShapeOutput out;
|
||||||
if (m_world->RayCastSingleShape(&out, m_ray->A(), m_ray->B()) == false)
|
if (m_world->RayCastSingleShape(&out, m_ray->A(), m_ray->B()) == false)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -52,7 +52,7 @@ public:
|
|||||||
{
|
{
|
||||||
B3_ASSERT(IsDragging() == false);
|
B3_ASSERT(IsDragging() == false);
|
||||||
|
|
||||||
b3ClothRayCastSingleOutput rayOut;
|
b3RayCastSingleClothOutput rayOut;
|
||||||
if (m_world->RayCastSingleCloth(&rayOut, m_ray->A(), m_ray->B()) == false)
|
if (m_world->RayCastSingleCloth(&rayOut, m_ray->A(), m_ray->B()) == false)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -37,7 +37,7 @@ struct b3ClothMesh;
|
|||||||
class b3RayCastListener;
|
class b3RayCastListener;
|
||||||
|
|
||||||
struct b3RayCastInput;
|
struct b3RayCastInput;
|
||||||
struct b3ClothRayCastSingleOutput;
|
struct b3RayCastSingleClothOutput;
|
||||||
|
|
||||||
// Cloth definition
|
// Cloth definition
|
||||||
// This requires defining a cloth mesh which is typically bound to a render mesh
|
// This requires defining a cloth mesh which is typically bound to a render mesh
|
||||||
@ -90,13 +90,13 @@ public:
|
|||||||
void DestroyForce(b3Force* force);
|
void DestroyForce(b3Force* force);
|
||||||
|
|
||||||
// Perform a ray cast with a given cloth mesh triangle.
|
// Perform a ray cast with a given cloth mesh triangle.
|
||||||
bool RayCast(b3ClothRayCastSingleOutput* output, const b3RayCastInput* input, u32 triangleIndex) const;
|
bool RayCast(b3RayCastSingleClothOutput* output, const b3RayCastInput* input, u32 triangleIndex) const;
|
||||||
|
|
||||||
// Perform a ray cast with the cloth.
|
// Perform a ray cast with the cloth.
|
||||||
void RayCast(b3RayCastListener* listener, const b3RayCastInput* input) const;
|
void RayCast(b3RayCastListener* listener, const b3RayCastInput* input) const;
|
||||||
|
|
||||||
// Perform a ray cast with the cloth.
|
// Perform a ray cast with the cloth.
|
||||||
bool RayCastSingle(b3ClothRayCastSingleOutput* output, const b3Vec3& p1, const b3Vec3& p2) const;
|
bool RayCastSingle(b3RayCastSingleClothOutput* output, const b3Vec3& p1, const b3Vec3& p2) const;
|
||||||
|
|
||||||
// Return the cloth mesh proxy.
|
// Return the cloth mesh proxy.
|
||||||
b3ClothMesh* GetMesh() const;
|
b3ClothMesh* GetMesh() const;
|
||||||
|
@ -58,32 +58,24 @@ struct b3ParticleDef
|
|||||||
void* userData;
|
void* userData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//
|
||||||
class b3FrictionForce : public b3Force
|
class b3FrictionForce : public b3Force
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
b3FrictionForce() { }
|
b3FrictionForce() { }
|
||||||
|
|
||||||
~b3FrictionForce() { }
|
~b3FrictionForce() { }
|
||||||
|
|
||||||
void Apply(const b3ClothSolverData* data);
|
void Apply(const b3ClothSolverData* data);
|
||||||
|
|
||||||
b3Particle* m_p;
|
b3Particle* m_p;
|
||||||
float32 m_kd;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// A contact between a particle and a solid
|
// A contact between a particle and a solid
|
||||||
class b3BodyContact
|
class b3BodyContact
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
b3BodyContact()
|
b3BodyContact() { }
|
||||||
{
|
~b3BodyContact() { }
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
~b3BodyContact()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
b3Particle* p1;
|
b3Particle* p1;
|
||||||
b3Shape* s2;
|
b3Shape* s2;
|
||||||
|
@ -36,7 +36,7 @@ class b3RayCastListener;
|
|||||||
class b3ContactListener;
|
class b3ContactListener;
|
||||||
class b3ContactFilter;
|
class b3ContactFilter;
|
||||||
|
|
||||||
struct b3ShapeRayCastSingleOutput
|
struct b3RayCastSingleShapeOutput
|
||||||
{
|
{
|
||||||
b3Shape* shape; // shape
|
b3Shape* shape; // shape
|
||||||
b3Vec3 point; // intersection point on surface
|
b3Vec3 point; // intersection point on surface
|
||||||
@ -44,7 +44,7 @@ struct b3ShapeRayCastSingleOutput
|
|||||||
float32 fraction; // time of intersection on segment
|
float32 fraction; // time of intersection on segment
|
||||||
};
|
};
|
||||||
|
|
||||||
struct b3ClothRayCastSingleOutput
|
struct b3RayCastSingleClothOutput
|
||||||
{
|
{
|
||||||
b3Cloth* cloth; // cloth
|
b3Cloth* cloth; // cloth
|
||||||
u32 triangle; // triangle
|
u32 triangle; // triangle
|
||||||
@ -115,7 +115,7 @@ public:
|
|||||||
// The ray cast output is the intercepted shape, the intersection
|
// The ray cast output is the intercepted shape, the intersection
|
||||||
// point in world space, the face normal on the shape associated with the point,
|
// point in world space, the face normal on the shape associated with the point,
|
||||||
// and the intersection fraction.
|
// and the intersection fraction.
|
||||||
bool RayCastSingleShape(b3ShapeRayCastSingleOutput* output, const b3Vec3& p1, const b3Vec3& p2) const;
|
bool RayCastSingleShape(b3RayCastSingleShapeOutput* output, const b3Vec3& p1, const b3Vec3& p2) const;
|
||||||
|
|
||||||
// Perform a ray cast with the world.
|
// Perform a ray cast with the world.
|
||||||
// The given ray cast listener will be notified when a ray intersects a shape
|
// The given ray cast listener will be notified when a ray intersects a shape
|
||||||
@ -130,7 +130,7 @@ public:
|
|||||||
// The ray cast output is the intercepted cloth, the intersection
|
// The ray cast output is the intercepted cloth, the intersection
|
||||||
// point in world space, the face normal on the cloth associated with the point,
|
// point in world space, the face normal on the cloth associated with the point,
|
||||||
// and the intersection fraction.
|
// and the intersection fraction.
|
||||||
bool RayCastSingleCloth(b3ClothRayCastSingleOutput* output, const b3Vec3& p1, const b3Vec3& p2) const;
|
bool RayCastSingleCloth(b3RayCastSingleClothOutput* output, const b3Vec3& p1, const b3Vec3& p2) const;
|
||||||
|
|
||||||
// Perform a AABB query with the world.
|
// Perform a AABB query with the world.
|
||||||
// The query listener will be notified when two shape AABBs are overlapping.
|
// The query listener will be notified when two shape AABBs are overlapping.
|
||||||
|
@ -352,7 +352,7 @@ void b3Cloth::RayCast(b3RayCastListener* listener, const b3RayCastInput* input)
|
|||||||
{
|
{
|
||||||
for (u32 i = 0; i < m_mesh->triangleCount; ++i)
|
for (u32 i = 0; i < m_mesh->triangleCount; ++i)
|
||||||
{
|
{
|
||||||
b3ClothRayCastSingleOutput subOutput;
|
b3RayCastSingleClothOutput subOutput;
|
||||||
if (RayCast(&subOutput, input, i))
|
if (RayCast(&subOutput, input, i))
|
||||||
{
|
{
|
||||||
float32 newFraction = listener->ReportCloth(subOutput.cloth, subOutput.point, subOutput.normal, subOutput.fraction, subOutput.triangle);
|
float32 newFraction = listener->ReportCloth(subOutput.cloth, subOutput.point, subOutput.normal, subOutput.fraction, subOutput.triangle);
|
||||||
@ -366,7 +366,7 @@ void b3Cloth::RayCast(b3RayCastListener* listener, const b3RayCastInput* input)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool b3Cloth::RayCastSingle(b3ClothRayCastSingleOutput* output, const b3Vec3& p1, const b3Vec3& p2) const
|
bool b3Cloth::RayCastSingle(b3RayCastSingleClothOutput* output, const b3Vec3& p1, const b3Vec3& p2) const
|
||||||
{
|
{
|
||||||
b3RayCastInput input;
|
b3RayCastInput input;
|
||||||
input.p1 = p1;
|
input.p1 = p1;
|
||||||
@ -378,7 +378,7 @@ bool b3Cloth::RayCastSingle(b3ClothRayCastSingleOutput* output, const b3Vec3& p1
|
|||||||
|
|
||||||
for (u32 i = 0; i < m_mesh->triangleCount; ++i)
|
for (u32 i = 0; i < m_mesh->triangleCount; ++i)
|
||||||
{
|
{
|
||||||
b3ClothRayCastSingleOutput subOutput;
|
b3RayCastSingleClothOutput subOutput;
|
||||||
if (RayCast(&subOutput, &input, i))
|
if (RayCast(&subOutput, &input, i))
|
||||||
{
|
{
|
||||||
if (subOutput.fraction < output->fraction)
|
if (subOutput.fraction < output->fraction)
|
||||||
@ -396,7 +396,7 @@ bool b3Cloth::RayCastSingle(b3ClothRayCastSingleOutput* output, const b3Vec3& p1
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool b3Cloth::RayCast(b3ClothRayCastSingleOutput* output, const b3RayCastInput* input, u32 triangleIndex) const
|
bool b3Cloth::RayCast(b3RayCastSingleClothOutput* output, const b3RayCastInput* input, u32 triangleIndex) const
|
||||||
{
|
{
|
||||||
B3_ASSERT(triangleIndex < m_mesh->triangleCount);
|
B3_ASSERT(triangleIndex < m_mesh->triangleCount);
|
||||||
b3ClothMeshTriangle* triangle = m_mesh->triangles + triangleIndex;
|
b3ClothMeshTriangle* triangle = m_mesh->triangles + triangleIndex;
|
||||||
|
@ -426,7 +426,7 @@ void b3World::RayCastShape(b3RayCastListener* listener, const b3Vec3& p1, const
|
|||||||
m_contactMan.m_broadPhase.RayCast(&callback, input);
|
m_contactMan.m_broadPhase.RayCast(&callback, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct b3ShapeRayCastSingleCallback
|
struct b3RayCastSingleShapeCallback
|
||||||
{
|
{
|
||||||
float32 Report(const b3RayCastInput& input, u32 proxyId)
|
float32 Report(const b3RayCastInput& input, u32 proxyId)
|
||||||
{
|
{
|
||||||
@ -458,14 +458,14 @@ struct b3ShapeRayCastSingleCallback
|
|||||||
const b3BroadPhase* broadPhase;
|
const b3BroadPhase* broadPhase;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool b3World::RayCastSingleShape(b3ShapeRayCastSingleOutput* output, const b3Vec3& p1, const b3Vec3& p2) const
|
bool b3World::RayCastSingleShape(b3RayCastSingleShapeOutput* output, const b3Vec3& p1, const b3Vec3& p2) const
|
||||||
{
|
{
|
||||||
b3RayCastInput input;
|
b3RayCastInput input;
|
||||||
input.p1 = p1;
|
input.p1 = p1;
|
||||||
input.p2 = p2;
|
input.p2 = p2;
|
||||||
input.maxFraction = 1.0f;
|
input.maxFraction = 1.0f;
|
||||||
|
|
||||||
b3ShapeRayCastSingleCallback callback;
|
b3RayCastSingleShapeCallback callback;
|
||||||
callback.shape0 = NULL;
|
callback.shape0 = NULL;
|
||||||
callback.output0.fraction = B3_MAX_FLOAT;
|
callback.output0.fraction = B3_MAX_FLOAT;
|
||||||
callback.broadPhase = &m_contactMan.m_broadPhase;
|
callback.broadPhase = &m_contactMan.m_broadPhase;
|
||||||
@ -504,7 +504,7 @@ void b3World::RayCastCloth(b3RayCastListener* listener, const b3Vec3& p1, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool b3World::RayCastSingleCloth(b3ClothRayCastSingleOutput* output, const b3Vec3& p1, const b3Vec3& p2) const
|
bool b3World::RayCastSingleCloth(b3RayCastSingleClothOutput* output, const b3Vec3& p1, const b3Vec3& p2) const
|
||||||
{
|
{
|
||||||
output->cloth = NULL;
|
output->cloth = NULL;
|
||||||
output->triangle = ~0;
|
output->triangle = ~0;
|
||||||
@ -512,7 +512,7 @@ bool b3World::RayCastSingleCloth(b3ClothRayCastSingleOutput* output, const b3Vec
|
|||||||
|
|
||||||
for (b3Cloth* c = m_clothList.m_head; c; c = c->m_next)
|
for (b3Cloth* c = m_clothList.m_head; c; c = c->m_next)
|
||||||
{
|
{
|
||||||
b3ClothRayCastSingleOutput subOutput;
|
b3RayCastSingleClothOutput subOutput;
|
||||||
if (c->RayCastSingle(&subOutput, p1, p2))
|
if (c->RayCastSingle(&subOutput, p1, p2))
|
||||||
{
|
{
|
||||||
if (subOutput.fraction < output->fraction)
|
if (subOutput.fraction < output->fraction)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user