TestSphere for triangles
This commit is contained in:
parent
cd4afc58b0
commit
69e2cd4c56
@ -41,6 +41,8 @@ public:
|
||||
|
||||
bool TestSphere(b3TestSphereOutput* output, const b3Sphere& sphere, const b3Transform& xf) const;
|
||||
|
||||
bool TestSphere(b3TestSphereOutput* output, const b3Sphere& sphere, const b3Transform& xf, u32 childIndex) const;
|
||||
|
||||
bool RayCast(b3RayCastOutput* output, const b3RayCastInput& input, const b3Transform& xf) const;
|
||||
|
||||
bool RayCast(b3RayCastOutput* output, const b3RayCastInput& input, const b3Transform& xf, u32 childIndex) const;
|
||||
|
@ -153,6 +153,7 @@ protected:
|
||||
friend class b3Body;
|
||||
friend class b3Contact;
|
||||
friend class b3ContactManager;
|
||||
friend class b3MeshShape;
|
||||
friend class b3MeshContact;
|
||||
friend class b3ContactSolver;
|
||||
friend class b3List1<b3Shape>;
|
||||
|
@ -17,7 +17,9 @@
|
||||
*/
|
||||
|
||||
#include <bounce/dynamics/shapes/mesh_shape.h>
|
||||
#include <bounce/dynamics/shapes/hull_shape.h>
|
||||
#include <bounce/collision/shapes/mesh.h>
|
||||
#include <bounce/collision/shapes/triangle_hull.h>
|
||||
|
||||
b3MeshShape::b3MeshShape()
|
||||
{
|
||||
@ -88,6 +90,24 @@ bool b3MeshShape::TestSphere(b3TestSphereOutput* output, const b3Sphere& sphere,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool b3MeshShape::TestSphere(b3TestSphereOutput* output, const b3Sphere& sphere, const b3Transform& xf, u32 index) const
|
||||
{
|
||||
B3_ASSERT(index < m_mesh->triangleCount);
|
||||
b3Triangle* triangle = m_mesh->triangles + index;
|
||||
b3Vec3 v1 = m_mesh->vertices[triangle->v1];
|
||||
b3Vec3 v2 = m_mesh->vertices[triangle->v2];
|
||||
b3Vec3 v3 = m_mesh->vertices[triangle->v3];
|
||||
|
||||
b3TriangleHull hull(v1, v2, v3);
|
||||
|
||||
b3HullShape hullShape;
|
||||
hullShape.m_body = m_body;
|
||||
hullShape.m_hull = &hull;
|
||||
hullShape.m_radius = B3_HULL_RADIUS;
|
||||
|
||||
return hullShape.TestSphere(output, sphere, xf);
|
||||
}
|
||||
|
||||
bool b3MeshShape::RayCast(b3RayCastOutput* output, const b3RayCastInput& input, const b3Transform& xf, u32 index) const
|
||||
{
|
||||
B3_ASSERT(index < m_mesh->triangleCount);
|
||||
|
Loading…
x
Reference in New Issue
Block a user