29 int numtotalphysicsverts = 0;
31 const unsigned char * vertexbase;
32 const unsigned char * indexbase;
36 int stride,numverts,numtriangles;
43 for (part=0;part<graphicssubparts ;part++)
46 numtotalphysicsverts+=numtriangles*3;
63 for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
65 unsigned int* tri_indices= (
unsigned int*)(indexbase+gfxindex*indexstride);
66 graphicsbase = (
float*)(vertexbase+tri_indices[0]*stride);
67 triangle[0].
setValue(graphicsbase[0]*meshScaling.
getX(),graphicsbase[1]*meshScaling.
getY(),graphicsbase[2]*meshScaling.
getZ());
68 graphicsbase = (
float*)(vertexbase+tri_indices[1]*stride);
69 triangle[1].
setValue(graphicsbase[0]*meshScaling.
getX(),graphicsbase[1]*meshScaling.
getY(), graphicsbase[2]*meshScaling.
getZ());
70 graphicsbase = (
float*)(vertexbase+tri_indices[2]*stride);
71 triangle[2].
setValue(graphicsbase[0]*meshScaling.
getX(),graphicsbase[1]*meshScaling.
getY(), graphicsbase[2]*meshScaling.
getZ());
78 for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
80 unsigned short int* tri_indices= (
unsigned short int*)(indexbase+gfxindex*indexstride);
81 graphicsbase = (
float*)(vertexbase+tri_indices[0]*stride);
82 triangle[0].
setValue(graphicsbase[0]*meshScaling.
getX(),graphicsbase[1]*meshScaling.
getY(),graphicsbase[2]*meshScaling.
getZ());
83 graphicsbase = (
float*)(vertexbase+tri_indices[1]*stride);
84 triangle[1].
setValue(graphicsbase[0]*meshScaling.
getX(),graphicsbase[1]*meshScaling.
getY(), graphicsbase[2]*meshScaling.
getZ());
85 graphicsbase = (
float*)(vertexbase+tri_indices[2]*stride);
86 triangle[2].
setValue(graphicsbase[0]*meshScaling.
getX(),graphicsbase[1]*meshScaling.
getY(), graphicsbase[2]*meshScaling.
getZ());
93 for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
95 unsigned char* tri_indices= (
unsigned char*)(indexbase+gfxindex*indexstride);
96 graphicsbase = (
float*)(vertexbase+tri_indices[0]*stride);
97 triangle[0].
setValue(graphicsbase[0]*meshScaling.
getX(),graphicsbase[1]*meshScaling.
getY(),graphicsbase[2]*meshScaling.
getZ());
98 graphicsbase = (
float*)(vertexbase+tri_indices[1]*stride);
99 triangle[1].
setValue(graphicsbase[0]*meshScaling.
getX(),graphicsbase[1]*meshScaling.
getY(), graphicsbase[2]*meshScaling.
getZ());
100 graphicsbase = (
float*)(vertexbase+tri_indices[2]*stride);
101 triangle[2].
setValue(graphicsbase[0]*meshScaling.
getX(),graphicsbase[1]*meshScaling.
getY(), graphicsbase[2]*meshScaling.
getZ());
114 double* graphicsbase;
116 switch (gfxindextype)
120 for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
122 unsigned int* tri_indices= (
unsigned int*)(indexbase+gfxindex*indexstride);
123 graphicsbase = (
double*)(vertexbase+tri_indices[0]*stride);
125 graphicsbase = (
double*)(vertexbase+tri_indices[1]*stride);
127 graphicsbase = (
double*)(vertexbase+tri_indices[2]*stride);
135 for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
137 unsigned short int* tri_indices= (
unsigned short int*)(indexbase+gfxindex*indexstride);
138 graphicsbase = (
double*)(vertexbase+tri_indices[0]*stride);
140 graphicsbase = (
double*)(vertexbase+tri_indices[1]*stride);
142 graphicsbase = (
double*)(vertexbase+tri_indices[2]*stride);
150 for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
152 unsigned char* tri_indices= (
unsigned char*)(indexbase+gfxindex*indexstride);
153 graphicsbase = (
double*)(vertexbase+tri_indices[0]*stride);
155 graphicsbase = (
double*)(vertexbase+tri_indices[1]*stride);
157 graphicsbase = (
double*)(vertexbase+tri_indices[2]*stride);
184 AabbCalculationCallback()
190 virtual void internalProcessTriangleIndex(
btVector3* triangle,
int partId,
int triangleIndex)
195 m_aabbMin.
setMin(triangle[0]);
196 m_aabbMax.
setMax(triangle[0]);
197 m_aabbMin.
setMin(triangle[1]);
198 m_aabbMax.
setMax(triangle[1]);
199 m_aabbMin.
setMin(triangle[2]);
200 m_aabbMax.
setMax(triangle[2]);
205 AabbCalculationCallback aabbCallback;
210 aabbMin = aabbCallback.m_aabbMin;
211 aabbMax = aabbCallback.m_aabbMax;
236 const unsigned char * vertexbase;
237 const unsigned char * indexbase;
241 int stride,numverts,numtriangles;
248 for (part=0;part<graphicssubparts ;part++,memPtr++)
261 switch (gfxindextype)
265 int numindices = numtriangles*3;
272 for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
274 unsigned int* tri_indices= (
unsigned int*)(indexbase+gfxindex*indexstride);
275 tmpIndices[gfxindex*3].
m_value = tri_indices[0];
276 tmpIndices[gfxindex*3+1].
m_value = tri_indices[1];
277 tmpIndices[gfxindex*3+2].
m_value = tri_indices[2];
290 for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
292 unsigned short int* tri_indices= (
unsigned short int*)(indexbase+gfxindex*indexstride);
293 tmpIndices[gfxindex].
m_values[0] = tri_indices[0];
294 tmpIndices[gfxindex].
m_values[1] = tri_indices[1];
295 tmpIndices[gfxindex].
m_values[2] = tri_indices[2];
297 tmpIndices[gfxindex].
m_pad[0] = 0;
298 tmpIndices[gfxindex].
m_pad[1] = 0;
311 for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
313 unsigned char* tri_indices= (
unsigned char*)(indexbase+gfxindex*indexstride);
314 tmpIndices[gfxindex].
m_values[0] = tri_indices[0];
315 tmpIndices[gfxindex].
m_values[1] = tri_indices[1];
316 tmpIndices[gfxindex].
m_values[2] = tri_indices[2];
318 tmpIndices[gfxindex].
m_pad = 0;
342 for (
int i=0;i<numverts;i++)
344 graphicsbase = (
float*)(vertexbase+i*stride);
345 tmpVertices[i].
m_floats[0] = graphicsbase[0];
346 tmpVertices[i].
m_floats[1] = graphicsbase[1];
347 tmpVertices[i].
m_floats[2] = graphicsbase[2];
361 for (
int i=0;i<numverts;i++)
363 double* graphicsbase = (
double*)(vertexbase+i*stride);
364 tmpVertices[i].
m_floats[0] = graphicsbase[0];
365 tmpVertices[i].
m_floats[1] = graphicsbase[1];
366 tmpVertices[i].
m_floats[2] = graphicsbase[2];
387 return "btStridingMeshInterfaceData";
btMeshPartData * m_meshPartsPtr
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
virtual void * getUniquePointer(void *oldPtr)=0
const btVector3 & getScaling() const
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
btVector3FloatData * m_vertices3f
const btScalar & getZ() const
Return the z value.
btShortIntIndexData * m_indices16
btCharIndexTripletData * m_3indices8
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
btShortIntIndexTripletData * m_3indices16
unsigned char m_values[3]
const btScalar & getY() const
Return the y value.
const btScalar & getX() const
Return the x value.
btVector3FloatData m_scaling
void serializeFloat(struct btVector3FloatData &dataOut) const
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 finalizeChunk(btChunk *chunk, const char *structType, int chunkCode, void *oldPtr)=0
virtual ~btStridingMeshInterface()
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 internalProcessTriangleIndex(btVector3 *triangle, int partId, int triangleIndex)=0
btIntIndexData * m_indices32
virtual void unLockReadOnlyVertexBase(int subpart) const =0
virtual const char * serialize(void *dataBuffer, btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
void setMax(const btVector3 &other)
Set each element to the max of the current values and the values of another btVector3.
virtual btChunk * allocate(size_t size, int numElements)=0
void setMin(const btVector3 &other)
Set each element to the min of the current values and the values of another btVector3.
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
PHY_ScalarType
PHY_ScalarType enumerates possible scalar types.
virtual void InternalProcessAllTriangles(btInternalTriangleIndexCallback *callback, const btVector3 &aabbMin, const btVector3 &aabbMax) const
void calculateAabbBruteForce(btVector3 &aabbMin, btVector3 &aabbMax)
brute force method to calculate aabb
btVector3DoubleData * m_vertices3d