24 #ifndef GIMPACT_SHAPE_H 25 #define GIMPACT_SHAPE_H 104 m_needs_update =
true;
105 localScaling.
setValue(1.f, 1.f, 1.f);
117 if (!m_needs_update)
return;
119 m_needs_update =
false;
128 btAABB transformedbox = m_localAABB;
130 aabbMin = transformedbox.
m_min;
131 aabbMax = transformedbox.
m_max;
137 m_needs_update =
true;
156 localScaling = scaling;
168 int i = getNumChildShapes();
175 m_needs_update =
true;
201 virtual int getNumChildShapes()
const = 0;
204 virtual bool childrenHasTransform()
const = 0;
207 virtual bool needsRetrieveTriangles()
const = 0;
210 virtual bool needsRetrieveTetrahedrons()
const = 0;
212 virtual void getBulletTriangle(
int prim_index,
btTriangleShapeEx& triangle)
const = 0;
228 getPrimitiveManager()->get_primitive_triangle(index, triangle);
237 getPrimitiveManager()->get_primitive_box(child_index, child_aabb);
239 aabbMin = child_aabb.
m_min;
240 aabbMax = child_aabb.
m_max;
250 virtual btTransform getChildTransform(
int index)
const = 0;
256 virtual void setChildTransform(
int index,
const btTransform& transform) = 0;
265 (void)resultCallback;
312 m_compoundShape = compoundShape;
317 m_compoundShape = NULL;
361 (void)children_has_transform;
363 m_box_set.setPrimitiveManager(&m_primitive_manager);
373 if (m_childTransforms.
size() == 0)
return false;
380 return &m_primitive_manager;
386 return &m_primitive_manager;
392 return m_childShapes.
size();
399 m_childTransforms.
push_back(localTransform);
413 return m_childShapes[index];
419 return m_childShapes[index];
427 if (childrenHasTransform())
429 m_childShapes[child_index]->getAabb(t * m_childTransforms[child_index], aabbMin, aabbMax);
433 m_childShapes[child_index]->getAabb(t, aabbMin, aabbMax);
441 return m_childTransforms[index];
451 m_childTransforms[index] = transform;
486 return "GImpactCompound";
528 m_meshInterface = NULL;
560 m_meshInterface = meshInterface;
577 if (m_lock_count > 0)
583 &vertexbase, numverts,
584 type, stride, &indexbase, indexstride, numfaces, indicestype, m_part);
591 if (m_lock_count == 0)
return;
592 if (m_lock_count > 1)
609 return (
int)numfaces;
614 return (
int)numverts;
621 unsigned short* s_indices = (
unsigned short*)(indexbase + face_index * indexstride);
628 unsigned int* i_indices = (
unsigned int*)(indexbase + face_index * indexstride);
639 double* dvertices = (
double*)(vertexbase + vertex_index * stride);
640 vertex[0] =
btScalar(dvertices[0] * m_scale[0]);
641 vertex[1] =
btScalar(dvertices[1] * m_scale[1]);
642 vertex[2] =
btScalar(dvertices[2] * m_scale[2]);
646 float* svertices = (
float*)(vertexbase + vertex_index * stride);
647 vertex[0] = svertices[0] * m_scale[0];
648 vertex[1] = svertices[1] * m_scale[1];
649 vertex[2] = svertices[2] * m_scale[2];
656 get_primitive_triangle(prim_index, triangle);
664 unsigned int indices[3];
665 get_indices(prim_index, indices[0], indices[1], indices[2]);
666 get_vertex(indices[0], triangle.
m_vertices[0]);
667 get_vertex(indices[1], triangle.
m_vertices[1]);
668 get_vertex(indices[2], triangle.
m_vertices[2]);
674 unsigned int indices[3];
675 get_indices(prim_index, indices[0], indices[1], indices[2]);
689 m_box_set.setPrimitiveManager(&m_primitive_manager);
702 virtual void lockChildShapes()
const;
703 virtual void unlockChildShapes()
const;
749 return &m_primitive_manager;
754 return &m_primitive_manager;
761 return "GImpactMeshShapePart";
800 m_primitive_manager.
get_vertex(vertex_index, vertex);
805 m_primitive_manager.
m_margin = margin;
811 return m_primitive_manager.
m_margin;
816 m_primitive_manager.
m_scale = scaling;
822 return m_primitive_manager.
m_scale;
827 return (
int)m_primitive_manager.
m_part;
860 m_localAABB.invalidate();
861 int i = m_mesh_parts.
size();
864 m_mesh_parts[i]->updateBound();
865 m_localAABB.merge(m_mesh_parts[i]->getLocalBox());
872 m_meshInterface = meshInterface;
873 buildMeshParts(meshInterface);
878 int i = m_mesh_parts.
size();
884 m_mesh_parts.
clear();
889 return m_meshInterface;
894 return m_meshInterface;
899 return m_mesh_parts.
size();
904 return m_mesh_parts[index];
909 return m_mesh_parts[index];
914 localScaling = scaling;
916 int i = m_mesh_parts.
size();
923 m_needs_update =
true;
930 int i = m_mesh_parts.
size();
937 m_needs_update =
true;
943 int i = m_mesh_parts.
size();
950 m_needs_update =
true;
1069 return "GImpactMesh";
1107 #endif //GIMPACT_MESH_SHAPE_H virtual int get_primitive_count() const
int getMeshPartCount() const
virtual const btVector3 & getLocalScaling() const
virtual btTransform getChildTransform(int index) const
Gets the children transform.
void push_back(const T &_Val)
virtual const char * getName() const
virtual ~btGImpactMeshShape()
Helper class for colliding Bullet Triangle Shapes.
CompoundPrimitiveManager()
virtual eGIMPACT_SHAPE_TYPE getGImpactShapeType() const
Subshape member functions.
btScalar m_collisionMargin
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
virtual void setMargin(btScalar margin)
virtual void postUpdate()
Tells to this object that is needed to refit all the meshes.
virtual btTransform getChildTransform(int index) const
Gets the children transform.
void setVertices(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2, const btVector3 &v3)
virtual void lockChildShapes() const
call when reading child shapes
virtual bool childrenHasTransform() const
if true, then its children must get transforms.
virtual void setLocalScaling(const btVector3 &scaling)
virtual bool needsRetrieveTetrahedrons() const
Determines if this shape has tetrahedrons.
const btAABB & getLocalBox()
Obtains the local box, which is the global calculated box of the total of subshapes.
virtual bool needsRetrieveTriangles() const
Determines if this shape has triangles.
btGImpactShapeInterface()
btAABB getGlobalBox() const
virtual int getNumChildShapes() const
Gets the number of children.
virtual bool needsRetrieveTetrahedrons() const
Determines if this shape has tetrahedrons.
int getVertexCount() const
btScalar getMargin() const
TrimeshPrimitiveManager(btStridingMeshInterface *meshInterface, int part)
virtual void setLocalScaling(const btVector3 &scaling)
void setMargin(btScalar margin)
CompoundPrimitiveManager(const CompoundPrimitiveManager &compound)
void get_indices(int face_index, unsigned int &i0, unsigned int &i1, unsigned int &i2) const
virtual int calculateSerializeBufferSize() const
void addChildShape(const btTransform &localTransform, btCollisionShape *shape)
Use this method for adding children. Only Convex shapes are allowed.
virtual void calcLocalAABB()
use this function for perfofm refit in bounding boxes use this function for perfofm refit in bounding...
virtual bool childrenHasTransform() const
if true, then its children must get transforms.
virtual void rayTest(const btVector3 &rayFrom, const btVector3 &rayTo, btCollisionWorld::RayResultCallback &resultCallback) const
virtual method for ray collision
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
RayResultCallback is used to report new raycast results.
virtual const btVector3 & getLocalScaling() const
virtual void unlockChildShapes() const
#define SIMD_FORCE_INLINE
CompoundPrimitiveManager m_primitive_manager
void addChildShape(btCollisionShape *shape)
Use this method for adding children. Only Convex shapes are allowed.
virtual void lockChildShapes() const
call when reading child shapes
void get_bullet_triangle(int prim_index, btTriangleShapeEx &triangle) const
virtual int getNumChildShapes() const
Gets the number of children.
virtual bool is_trimesh() const
determines if this manager consist on only triangles, which special case will be optimized ...
const btGImpactBoxSet * getBoxSet() const
gets boxset
virtual bool is_trimesh() const
determines if this manager consist on only triangles, which special case will be optimized ...
void buildMeshParts(btStridingMeshInterface *meshInterface)
This class manages a mesh supplied by the btStridingMeshInterface interface.
Used for GIMPACT Trimesh integration.
virtual void getChildAabb(int child_index, const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
Retrieves the bound from a child.
const unsigned char * vertexbase
btGImpactBoxSet m_box_set
Prototype Base class for primitive classification.
virtual void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const =0
getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t...
CompoundPrimitiveManager(btGImpactCompoundShape *compoundShape)
virtual eGIMPACT_SHAPE_TYPE getGImpactShapeType() const
Subshape member functions.
void clear()
clear the array, deallocated memory. Generally it is better to use array.resize(0), to reduce performance overhead of run-time memory (de)allocations.
virtual void getBulletTriangle(int prim_index, btTriangleShapeEx &triangle) const
compound primitive manager
btGImpactCompoundShape(bool children_has_transform=true)
void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
If the Bounding box is not updated, then this class attemps to calculate it.
void getVertex(int vertex_index, btVector3 &vertex) const
btGImpactMeshShapePart * getMeshPart(int index)
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
virtual const btPrimitiveManagerBase * getPrimitiveManager() const
Obtains the primitive manager.
virtual const char * serialize(void *dataBuffer, btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
btStridingMeshInterface * getMeshInterface()
TrimeshPrimitiveManager * getTrimeshPrimitiveManager()
virtual void getChildAabb(int child_index, const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
Retrieves the bound from a child.
virtual void setMargin(btScalar margin)
btAlignedObjectArray< btTransform > m_childTransforms
Base class for gimpact shapes.
This class manages a sub part of a mesh supplied by the btStridingMeshInterface interface.
virtual void getBulletTetrahedron(int prim_index, btTetrahedronShapeEx &tetrahedron) const
virtual void getBulletTetrahedron(int prim_index, btTetrahedronShapeEx &tetrahedron) const
virtual void postUpdate()
Tells to this object that is needed to refit the box set.
virtual const btPrimitiveManagerBase * getPrimitiveManager() const
Obtains the primitive manager.
The btTriangleCallback provides a callback for each overlapping triangle when calling processAllTrian...
The btBU_Simplex1to4 implements tetrahedron, triangle, line, vertex collision shapes. In most cases it is better to use btConvexHullShape instead.
void update()
node manager prototype functions
btStridingMeshInterfaceData m_meshInterface
TrimeshPrimitiveManager m_primitive_manager
virtual ~TrimeshPrimitiveManager()
void calc_from_triangle_margin(const CLASS_POINT &V1, const CLASS_POINT &V2, const CLASS_POINT &V3, btScalar margin)
virtual const char * getName() const
virtual void setChildTransform(int index, const btTransform &transform)
Sets the children transform.
virtual void get_primitive_box(int prim_index, btAABB &primbox) const
virtual bool needsRetrieveTriangles() const
Determines if this shape has triangles.
int getNodeCount() const
node count
virtual void setMargin(btScalar margin)=0
Helper class for tetrahedrons.
virtual void get_primitive_box(int prim_index, btAABB &primbox) const
TrimeshPrimitiveManager(const TrimeshPrimitiveManager &manager)
void appy_transform(const btTransform &trans)
Apply a transform to an AABB.
virtual bool childrenHasTransform() const
if true, then its children must get transforms.
virtual void get_primitive_triangle(int prim_index, btPrimitiveTriangle &triangle) const
retrieves only the points of the triangle, and the collision margin
virtual int getNumChildShapes() const
Gets the number of children.
virtual void getChildAabb(int child_index, const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
Retrieves the bound from a child.
Trimesh primitive manager.
virtual void get_primitive_triangle(int prim_index, btPrimitiveTriangle &triangle) const
retrieves only the points of the triangle, and the collision margin
CompoundPrimitiveManager * getCompoundPrimitiveManager()
Obtains the compopund primitive manager.
btCollisionShapeData m_collisionShapeData
btVector3 can be used to represent 3D points and vectors.
virtual int getNumSubParts() const =0
getNumSubParts returns the number of seperate subparts each subpart has a continuous array of vertice...
virtual void getBulletTriangle(int prim_index, btTriangleShapeEx &triangle) const
virtual void calcLocalAABB()
use this function for perfofm refit in bounding boxes
int size() const
return the number of elements in the array
PHY_ScalarType indicestype
virtual btCollisionShape * getChildShape(int index)
Gets the children.
virtual const char * getName() const
The btStridingMeshInterface is the interface class for high performance generic access to triangle me...
virtual void getBulletTetrahedron(int prim_index, btTetrahedronShapeEx &tetrahedron) const
virtual void setLocalScaling(const btVector3 &scaling)
virtual btTransform getChildTransform(int index) const
Gets the children transform.
virtual int getShapeType() const
The btConcaveShape class provides an interface for non-moving (static) concave shapes.
const btVector3 & getScaling() const
virtual btCollisionShape * getChildShape(int index)
Gets the children.
virtual const btCollisionShape * getChildShape(int index) const
Gets the child.
virtual int get_primitive_count() const
const unsigned char * indexbase
virtual void getBulletTriangle(int prim_index, btTriangleShapeEx &triangle) const
virtual void setChildTransform(int index, const btTransform &transform)
Sets the children transform.
void get_vertex(unsigned int vertex_index, btVector3 &vertex) const
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
void getPrimitiveTriangle(int index, btPrimitiveTriangle &triangle) const
if this trimesh
bool hasBoxSet() const
Determines if this class has a hierarchy structure for sorting its primitives.
virtual eGIMPACT_SHAPE_TYPE getGImpactShapeType() const
Subshape member functions.
virtual const btCollisionShape * getChildShape(int index) const
Gets the children.
btStridingMeshInterface * m_meshInterface
virtual void getLockedReadOnlyVertexIndexBase(const unsigned char **vertexbase, int &numverts, PHY_ScalarType &type, int &stride, const unsigned char **indexbase, int &indexstride, int &numfaces, PHY_ScalarType &indicestype, int subpart=0) const =0
virtual void processAllTrianglesRay(btTriangleCallback *, const btVector3 &, const btVector3 &) const
Function for retrieve triangles.
virtual int calculateSerializeBufferSize() const
virtual ~CompoundPrimitiveManager()
const btGImpactMeshShapePart * getMeshPart(int index) const
virtual btCollisionShape * getChildShape(int index)
Gets the children.
virtual void unLockReadOnlyVertexBase(int subpart) const =0
void updateBound()
performs refit operation
virtual bool needsRetrieveTetrahedrons() const
Determines if this shape has tetrahedrons.
int get_vertex_count() const
virtual ~btGImpactCompoundShape()
virtual void unlockChildShapes() const
btAlignedObjectArray< btGImpactMeshShapePart * > m_mesh_parts
btVector3FloatData m_localScaling
Structure for containing Boxes.
btAlignedObjectArray< btCollisionShape * > m_childShapes
virtual const btCollisionShape * getChildShape(int index) const
Gets the child.
btGImpactCompoundShape * m_compoundShape
TrimeshPrimitiveManager()
const btStridingMeshInterface * getMeshInterface() const
virtual bool needsRetrieveTriangles() const
Determines if this shape has triangles.
virtual void setChildTransform(int index, const btTransform &transform)
Sets the children transform.
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
virtual void processAllTriangles(btTriangleCallback *callback, const btVector3 &aabbMin, const btVector3 &aabbMax) const
Function for retrieve triangles.
virtual const btPrimitiveManagerBase * getPrimitiveManager() const
Obtains the primitive manager.
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
virtual void calculateLocalInertia(btScalar mass, btVector3 &inertia) const
btGImpactCompoundShape allows to handle multiple btCollisionShape objects at once ...
PHY_ScalarType
PHY_ScalarType enumerates possible scalar types.
btGImpactMeshShape(btStridingMeshInterface *meshInterface)
btStridingMeshInterface * m_meshInterface
btGImpactQuantizedBvh btGImpactBoxSet
declare Quantized trees, (you can change to float based trees)
void buildSet()
this rebuild the entire set
virtual void setMargin(btScalar margin)