Bullet Collision Detection & Physics Library
btCompoundFromGimpact.h
Go to the documentation of this file.
1#ifndef BT_COMPOUND_FROM_GIMPACT
2#define BT_COMPOUND_FROM_GIMPACT
3
5#include "btGImpactShape.h"
7
10{
11public:
13
15 {
16 /*delete all the btBU_Simplex1to4 ChildShapes*/
17 for (int i = 0; i < m_children.size(); i++)
18 {
19 delete m_children[i].m_childShape;
20 }
21 }
22};
23
25{
28
33 {
34 }
36 {
38 {
40 return hitFraction;
41 }
42
43 return m_hitFraction;
44 }
45};
47{
51
56 {
57 }
58
60 {
62 btVector3 v0 = triangle[0] * scale;
63 btVector3 v1 = triangle[1] * scale;
64 btVector3 v2 = triangle[2] * scale;
65
66 btVector3 centroid = (v0 + v1 + v2) / 3;
67 btVector3 normal = (v1 - v0).cross(v2 - v0);
68 normal.normalize();
70 btVector3 rayTo = centroid - normal * m_depth;
71
73
75 if (cb.m_hitFraction < 1)
76 {
77 rayTo.setInterpolate3(cb.m_from, cb.m_to, cb.m_hitFraction);
78 //rayTo = cb.m_from;
79 //rayTo = rayTo.lerp(cb.m_to,cb.m_hitFraction);
80 //gDebugDraw.drawLine(tr(centroid),tr(centroid+normal),btVector3(1,0,0));
81 }
82
83 btBU_Simplex1to4* tet = new btBU_Simplex1to4(v0, v1, v2, rayTo);
87 }
88};
89
91{
93
96
99 gimpactMesh->getAabb(tr, aabbMin, aabbMax);
100 gimpactMesh->getMeshInterface()->InternalProcessAllTriangles(&cb, aabbMin, aabbMax);
101
102 return colShape;
103}
104
105#endif //BT_COMPOUND_FROM_GIMPACT
btCompoundShape * btCreateCompoundFromGimpactShape(const btGImpactMeshShape *gimpactMesh, btScalar depth)
const T & btMax(const T &a, const T &b)
Definition btMinMax.h:27
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition btScalar.h:314
#define ATTRIBUTE_ALIGNED16(a)
Definition btScalar.h:99
The btBU_Simplex1to4 implements tetrahedron, triangle, line, vertex collision shapes....
The btCompoundShape allows to store multiple other btCollisionShapes This allows for moving concave c...
void addChildShape(const btTransform &localTransform, btCollisionShape *shape)
This class manages a mesh supplied by the btStridingMeshInterface interface.
virtual void processAllTrianglesRay(btTriangleCallback *callback, const btVector3 &rayFrom, const btVector3 &rayTo) const
Function for retrieve triangles.
virtual const btVector3 & getLocalScaling() const
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition btTransform.h:30
void setIdentity()
Set this transformation to the identity.
btVector3 can be used to represent 3D points and vectors.
Definition btVector3.h:82
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
Definition btVector3.h:303
virtual btScalar reportHit(const btVector3 &hitNormalLocal, btScalar hitFraction, int partId, int triangleIndex)
MyCallback(const btVector3 &from, const btVector3 &to, int ignorePart, int ignoreTriangleIndex)
const btGImpactMeshShape * m_gimpactShape
MyInternalTriangleIndexCallback(btCompoundShape *colShape, const btGImpactMeshShape *meshShape, btScalar depth)
virtual void internalProcessTriangleIndex(btVector3 *triangle, int partId, int triangleIndex)