Bullet Collision Detection & Physics Library
btCollisionWorldImporter.cpp
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2014 Erwin Coumans http://bulletphysics.org
4 
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10 
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15 
18 #include "LinearMath/btSerializer.h" //for btBulletSerializedArrays definition
19 
20 #ifdef SUPPORT_GIMPACT_SHAPE_IMPORT
22 #endif //SUPPORT_GIMPACT_SHAPE_IMPORT
23 
25 :m_collisionWorld(world),
26 m_verboseMode(0)
27 {
28 
29 }
30 
32 {
33 }
34 
35 
36 
37 
38 
40 {
41 
42  m_shapeMap.clear();
43  m_bodyMap.clear();
44 
45  int i;
46 
47  for (i=0;i<arrays->m_bvhsDouble.size();i++)
48  {
50  btQuantizedBvhDoubleData* bvhData = arrays->m_bvhsDouble[i];
51  bvh->deSerializeDouble(*bvhData);
52  m_bvhMap.insert(arrays->m_bvhsDouble[i],bvh);
53  }
54  for (i=0;i<arrays->m_bvhsFloat.size();i++)
55  {
57  btQuantizedBvhFloatData* bvhData = arrays->m_bvhsFloat[i];
58  bvh->deSerializeFloat(*bvhData);
59  m_bvhMap.insert(arrays->m_bvhsFloat[i],bvh);
60  }
61 
62 
63 
64 
65 
66  for (i=0;i<arrays->m_colShapeData.size();i++)
67  {
68  btCollisionShapeData* shapeData = arrays->m_colShapeData[i];
69  btCollisionShape* shape = convertCollisionShape(shapeData);
70  if (shape)
71  {
72  // printf("shapeMap.insert(%x,%x)\n",shapeData,shape);
73  m_shapeMap.insert(shapeData,shape);
74  }
75 
76  if (shape&& shapeData->m_name)
77  {
78  char* newname = duplicateName(shapeData->m_name);
79  m_objectNameMap.insert(shape,newname);
80  m_nameShapeMap.insert(newname,shape);
81  }
82  }
83 
84 
85  for (i=0;i<arrays->m_collisionObjectDataDouble.size();i++)
86  {
88  btCollisionShape** shapePtr = m_shapeMap.find(colObjData->m_collisionShape);
89  if (shapePtr && *shapePtr)
90  {
91  btTransform startTransform;
92  colObjData->m_worldTransform.m_origin.m_floats[3] = 0.f;
93  startTransform.deSerializeDouble(colObjData->m_worldTransform);
94 
95  btCollisionShape* shape = (btCollisionShape*)*shapePtr;
96  btCollisionObject* body = createCollisionObject(startTransform,shape,colObjData->m_name);
97  body->setFriction(btScalar(colObjData->m_friction));
98  body->setRestitution(btScalar(colObjData->m_restitution));
99 
100 #ifdef USE_INTERNAL_EDGE_UTILITY
102  {
104  if (trimesh->getTriangleInfoMap())
105  {
107  }
108  }
109 #endif //USE_INTERNAL_EDGE_UTILITY
110  m_bodyMap.insert(colObjData,body);
111  } else
112  {
113  printf("error: no shape found\n");
114  }
115  }
116  for (i=0;i<arrays->m_collisionObjectDataFloat.size();i++)
117  {
119  btCollisionShape** shapePtr = m_shapeMap.find(colObjData->m_collisionShape);
120  if (shapePtr && *shapePtr)
121  {
122  btTransform startTransform;
123  colObjData->m_worldTransform.m_origin.m_floats[3] = 0.f;
124  startTransform.deSerializeFloat(colObjData->m_worldTransform);
125 
126  btCollisionShape* shape = (btCollisionShape*)*shapePtr;
127  btCollisionObject* body = createCollisionObject(startTransform,shape,colObjData->m_name);
128 
129 #ifdef USE_INTERNAL_EDGE_UTILITY
131  {
133  if (trimesh->getTriangleInfoMap())
134  {
136  }
137  }
138 #endif //USE_INTERNAL_EDGE_UTILITY
139  m_bodyMap.insert(colObjData,body);
140  } else
141  {
142  printf("error: no shape found\n");
143  }
144  }
145 
146  return true;
147 }
148 
149 
150 
152 {
153  int i;
154 
155  for (i=0;i<m_allocatedCollisionObjects.size();i++)
156  {
157  if(m_collisionWorld)
159  delete m_allocatedCollisionObjects[i];
160  }
161 
163 
164 
165  for (i=0;i<m_allocatedCollisionShapes.size();i++)
166  {
167  delete m_allocatedCollisionShapes[i];
168  }
170 
171 
172  for (i=0;i<m_allocatedBvhs.size();i++)
173  {
174  delete m_allocatedBvhs[i];
175  }
177 
178  for (i=0;i<m_allocatedTriangleInfoMaps.size();i++)
179  {
180  delete m_allocatedTriangleInfoMaps[i];
181  }
183  for (i=0;i<m_allocatedTriangleIndexArrays.size();i++)
184  {
186  }
188  for (i=0;i<m_allocatedNames.size();i++)
189  {
190  delete[] m_allocatedNames[i];
191  }
193 
195  {
197 
198  for(int a = 0;a < curData->m_numMeshParts;a++)
199  {
200  btMeshPartData* curPart = &curData->m_meshPartsPtr[a];
201  if(curPart->m_vertices3f)
202  delete [] curPart->m_vertices3f;
203 
204  if(curPart->m_vertices3d)
205  delete [] curPart->m_vertices3d;
206 
207  if(curPart->m_indices32)
208  delete [] curPart->m_indices32;
209 
210  if(curPart->m_3indices16)
211  delete [] curPart->m_3indices16;
212 
213  if(curPart->m_indices16)
214  delete [] curPart->m_indices16;
215 
216  if (curPart->m_3indices8)
217  delete [] curPart->m_3indices8;
218 
219  }
220  delete [] curData->m_meshPartsPtr;
221  delete curData;
222  }
224 
225  for (i=0;i<m_indexArrays.size();i++)
226  {
228  }
230 
231  for (i=0;i<m_shortIndexArrays.size();i++)
232  {
234  }
236 
237  for (i=0;i<m_charIndexArrays.size();i++)
238  {
240  }
242 
243  for (i=0;i<m_floatVertexArrays.size();i++)
244  {
246  }
248 
249  for (i=0;i<m_doubleVertexArrays.size();i++)
250  {
252  }
254 
255 
256 }
257 
258 
259 
261 {
262  btCollisionShape* shape = 0;
263 
264  switch (shapeData->m_shapeType)
265  {
267  {
268  btStaticPlaneShapeData* planeData = (btStaticPlaneShapeData*)shapeData;
269  btVector3 planeNormal,localScaling;
270  planeNormal.deSerializeFloat(planeData->m_planeNormal);
271  localScaling.deSerializeFloat(planeData->m_localScaling);
272  shape = createPlaneShape(planeNormal,planeData->m_planeConstant);
273  shape->setLocalScaling(localScaling);
274 
275  break;
276  }
278  {
280  btCollisionShapeData* colShapeData = (btCollisionShapeData*) &scaledMesh->m_trimeshShapeData;
282  btCollisionShape* childShape = convertCollisionShape(colShapeData);
283  btBvhTriangleMeshShape* meshShape = (btBvhTriangleMeshShape*)childShape;
284  btVector3 localScaling;
285  localScaling.deSerializeFloat(scaledMesh->m_localScaling);
286 
287  shape = createScaledTrangleMeshShape(meshShape, localScaling);
288  break;
289  }
290 #ifdef SUPPORT_GIMPACT_SHAPE_IMPORT
292  {
293  btGImpactMeshShapeData* gimpactData = (btGImpactMeshShapeData*) shapeData;
294  if (gimpactData->m_gimpactSubType == CONST_GIMPACT_TRIMESH_SHAPE)
295  {
297  btTriangleIndexVertexArray* meshInterface = createMeshInterface(*interfaceData);
298 
299 
300  btGImpactMeshShape* gimpactShape = createGimpactShape(meshInterface);
301  btVector3 localScaling;
302  localScaling.deSerializeFloat(gimpactData->m_localScaling);
303  gimpactShape->setLocalScaling(localScaling);
304  gimpactShape->setMargin(btScalar(gimpactData->m_collisionMargin));
305  gimpactShape->updateBound();
306  shape = gimpactShape;
307  } else
308  {
309  printf("unsupported gimpact sub type\n");
310  }
311  break;
312  }
313 #endif //SUPPORT_GIMPACT_SHAPE_IMPORT
314  //The btCapsuleShape* API has issue passing the margin/scaling/halfextents unmodified through the API
315  //so deal with this
317  {
318  btCapsuleShapeData* capData = (btCapsuleShapeData*)shapeData;
319 
320 
321  switch (capData->m_upAxis)
322  {
323  case 0:
324  {
325  shape = createCapsuleShapeX(1,1);
326  break;
327  }
328  case 1:
329  {
330  shape = createCapsuleShapeY(1,1);
331  break;
332  }
333  case 2:
334  {
335  shape = createCapsuleShapeZ(1,1);
336  break;
337  }
338  default:
339  {
340  printf("error: wrong up axis for btCapsuleShape\n");
341  }
342 
343 
344  };
345  if (shape)
346  {
347  btCapsuleShape* cap = (btCapsuleShape*) shape;
348  cap->deSerializeFloat(capData);
349  }
350  break;
351  }
354  case BOX_SHAPE_PROXYTYPE:
358  {
360  btVector3 implicitShapeDimensions;
361  implicitShapeDimensions.deSerializeFloat(bsd->m_implicitShapeDimensions);
362  btVector3 localScaling;
363  localScaling.deSerializeFloat(bsd->m_localScaling);
365  switch (shapeData->m_shapeType)
366  {
367  case BOX_SHAPE_PROXYTYPE:
368  {
369  btBoxShape* box= (btBoxShape*)createBoxShape(implicitShapeDimensions/localScaling+margin);
370  //box->initializePolyhedralFeatures();
371  shape = box;
372 
373  break;
374  }
376  {
377  shape = createSphereShape(implicitShapeDimensions.getX());
378  break;
379  }
380 
382  {
383  btCylinderShapeData* cylData = (btCylinderShapeData*) shapeData;
384  btVector3 halfExtents = implicitShapeDimensions+margin;
385  switch (cylData->m_upAxis)
386  {
387  case 0:
388  {
389  shape = createCylinderShapeX(halfExtents.getY(),halfExtents.getX());
390  break;
391  }
392  case 1:
393  {
394  shape = createCylinderShapeY(halfExtents.getX(),halfExtents.getY());
395  break;
396  }
397  case 2:
398  {
399  shape = createCylinderShapeZ(halfExtents.getX(),halfExtents.getZ());
400  break;
401  }
402  default:
403  {
404  printf("unknown Cylinder up axis\n");
405  }
406 
407  };
408 
409 
410 
411  break;
412  }
414  {
415  btConeShapeData* conData = (btConeShapeData*) shapeData;
416  btVector3 halfExtents = implicitShapeDimensions;//+margin;
417  switch (conData->m_upIndex)
418  {
419  case 0:
420  {
421  shape = createConeShapeX(halfExtents.getY(),halfExtents.getX());
422  break;
423  }
424  case 1:
425  {
426  shape = createConeShapeY(halfExtents.getX(),halfExtents.getY());
427  break;
428  }
429  case 2:
430  {
431  shape = createConeShapeZ(halfExtents.getX(),halfExtents.getZ());
432  break;
433  }
434  default:
435  {
436  printf("unknown Cone up axis\n");
437  }
438 
439  };
440 
441 
442 
443  break;
444  }
446  {
448  int numSpheres = mss->m_localPositionArraySize;
449 
452  radii.resize(numSpheres);
453  tmpPos.resize(numSpheres);
454  int i;
455  for ( i=0;i<numSpheres;i++)
456  {
457  tmpPos[i].deSerializeFloat(mss->m_localPositionArrayPtr[i].m_pos);
458  radii[i] = mss->m_localPositionArrayPtr[i].m_radius;
459  }
460  shape = createMultiSphereShape(&tmpPos[0],&radii[0],numSpheres);
461  break;
462  }
464  {
465  // int sz = sizeof(btConvexHullShapeData);
466  // int sz2 = sizeof(btConvexInternalShapeData);
467  // int sz3 = sizeof(btCollisionShapeData);
468  btConvexHullShapeData* convexData = (btConvexHullShapeData*)bsd;
469  int numPoints = convexData->m_numUnscaledPoints;
470 
472  tmpPoints.resize(numPoints);
473  int i;
474  for ( i=0;i<numPoints;i++)
475  {
476 #ifdef BT_USE_DOUBLE_PRECISION
477  if (convexData->m_unscaledPointsDoublePtr)
478  tmpPoints[i].deSerialize(convexData->m_unscaledPointsDoublePtr[i]);
479  if (convexData->m_unscaledPointsFloatPtr)
480  tmpPoints[i].deSerializeFloat(convexData->m_unscaledPointsFloatPtr[i]);
481 #else
482  if (convexData->m_unscaledPointsFloatPtr)
483  tmpPoints[i].deSerialize(convexData->m_unscaledPointsFloatPtr[i]);
484  if (convexData->m_unscaledPointsDoublePtr)
485  tmpPoints[i].deSerializeDouble(convexData->m_unscaledPointsDoublePtr[i]);
486 #endif //BT_USE_DOUBLE_PRECISION
487  }
489  for (i=0;i<numPoints;i++)
490  {
491  hullShape->addPoint(tmpPoints[i]);
492  }
493  hullShape->setMargin(bsd->m_collisionMargin);
494  //hullShape->initializePolyhedralFeatures();
495  shape = hullShape;
496  break;
497  }
498  default:
499  {
500  printf("error: cannot create shape type (%d)\n",shapeData->m_shapeType);
501  }
502  }
503 
504  if (shape)
505  {
506  shape->setMargin(bsd->m_collisionMargin);
507 
508  btVector3 localScaling;
509  localScaling.deSerializeFloat(bsd->m_localScaling);
510  shape->setLocalScaling(localScaling);
511 
512  }
513  break;
514  }
516  {
517  btTriangleMeshShapeData* trimesh = (btTriangleMeshShapeData*)shapeData;
519  btTriangleIndexVertexArray* meshInterface = createMeshInterface(*interfaceData);
520  if (!meshInterface->getNumSubParts())
521  {
522  return 0;
523  }
524 
525  btVector3 scaling; scaling.deSerializeFloat(trimesh->m_meshInterface.m_scaling);
526  meshInterface->setScaling(scaling);
527 
528 
529  btOptimizedBvh* bvh = 0;
530 #if 1
531  if (trimesh->m_quantizedFloatBvh)
532  {
533  btOptimizedBvh** bvhPtr = m_bvhMap.find(trimesh->m_quantizedFloatBvh);
534  if (bvhPtr && *bvhPtr)
535  {
536  bvh = *bvhPtr;
537  } else
538  {
539  bvh = createOptimizedBvh();
540  bvh->deSerializeFloat(*trimesh->m_quantizedFloatBvh);
541  }
542  }
543  if (trimesh->m_quantizedDoubleBvh)
544  {
545  btOptimizedBvh** bvhPtr = m_bvhMap.find(trimesh->m_quantizedDoubleBvh);
546  if (bvhPtr && *bvhPtr)
547  {
548  bvh = *bvhPtr;
549  } else
550  {
551  bvh = createOptimizedBvh();
552  bvh->deSerializeDouble(*trimesh->m_quantizedDoubleBvh);
553  }
554  }
555 #endif
556 
557 
558  btBvhTriangleMeshShape* trimeshShape = createBvhTriangleMeshShape(meshInterface,bvh);
559  trimeshShape->setMargin(trimesh->m_collisionMargin);
560  shape = trimeshShape;
561 
562  if (trimesh->m_triangleInfoMap)
563  {
565  map->deSerialize(*trimesh->m_triangleInfoMap);
566  trimeshShape->setTriangleInfoMap(map);
567 
568 #ifdef USE_INTERNAL_EDGE_UTILITY
569  gContactAddedCallback = btAdjustInternalEdgeContactsCallback;
570 #endif //USE_INTERNAL_EDGE_UTILITY
571 
572  }
573 
574  //printf("trimesh->m_collisionMargin=%f\n",trimesh->m_collisionMargin);
575  break;
576  }
578  {
579  btCompoundShapeData* compoundData = (btCompoundShapeData*)shapeData;
580  btCompoundShape* compoundShape = createCompoundShape();
581 
582  //btCompoundShapeChildData* childShapeDataArray = &compoundData->m_childShapePtr[0];
583 
584 
586  for (int i=0;i<compoundData->m_numChildShapes;i++)
587  {
588  //btCompoundShapeChildData* ptr = &compoundData->m_childShapePtr[i];
589 
590  btCollisionShapeData* cd = compoundData->m_childShapePtr[i].m_childShape;
591 
592  btCollisionShape* childShape = convertCollisionShape(cd);
593  if (childShape)
594  {
595  btTransform localTransform;
596  localTransform.deSerializeFloat(compoundData->m_childShapePtr[i].m_transform);
597  compoundShape->addChildShape(localTransform,childShape);
598  } else
599  {
600 #ifdef _DEBUG
601  printf("error: couldn't create childShape for compoundShape\n");
602 #endif
603  }
604 
605  }
606  shape = compoundShape;
607 
608  break;
609  }
611  {
612  return 0;
613  }
614  default:
615  {
616 #ifdef _DEBUG
617  printf("unsupported shape type (%d)\n",shapeData->m_shapeType);
618 #endif
619  }
620  }
621 
622  return shape;
623 
624 }
625 
626 
627 
629 {
630  if (name)
631  {
632  int l = (int)strlen(name);
633  char* newName = new char[l+1];
634  memcpy(newName,name,l);
635  newName[l] = 0;
636  m_allocatedNames.push_back(newName);
637  return newName;
638  }
639  return 0;
640 }
641 
642 
643 
644 
645 
646 
647 
648 
649 
650 
651 
653 {
655 
656  for (int i=0;i<meshData.m_numMeshParts;i++)
657  {
658  btIndexedMesh meshPart;
659  meshPart.m_numTriangles = meshData.m_meshPartsPtr[i].m_numTriangles;
660  meshPart.m_numVertices = meshData.m_meshPartsPtr[i].m_numVertices;
661 
662 
663  if (meshData.m_meshPartsPtr[i].m_indices32)
664  {
665  meshPart.m_indexType = PHY_INTEGER;
666  meshPart.m_triangleIndexStride = 3*sizeof(int);
667  int* indexArray = (int*)btAlignedAlloc(sizeof(int)*3*meshPart.m_numTriangles,16);
668  m_indexArrays.push_back(indexArray);
669  for (int j=0;j<3*meshPart.m_numTriangles;j++)
670  {
671  indexArray[j] = meshData.m_meshPartsPtr[i].m_indices32[j].m_value;
672  }
673  meshPart.m_triangleIndexBase = (const unsigned char*)indexArray;
674  } else
675  {
676  if (meshData.m_meshPartsPtr[i].m_3indices16)
677  {
678  meshPart.m_indexType = PHY_SHORT;
679  meshPart.m_triangleIndexStride = sizeof(short int)*3;//sizeof(btShortIntIndexTripletData);
680 
681  short int* indexArray = (short int*)btAlignedAlloc(sizeof(short int)*3*meshPart.m_numTriangles,16);
682  m_shortIndexArrays.push_back(indexArray);
683 
684  for (int j=0;j<meshPart.m_numTriangles;j++)
685  {
686  indexArray[3*j] = meshData.m_meshPartsPtr[i].m_3indices16[j].m_values[0];
687  indexArray[3*j+1] = meshData.m_meshPartsPtr[i].m_3indices16[j].m_values[1];
688  indexArray[3*j+2] = meshData.m_meshPartsPtr[i].m_3indices16[j].m_values[2];
689  }
690 
691  meshPart.m_triangleIndexBase = (const unsigned char*)indexArray;
692  }
693  if (meshData.m_meshPartsPtr[i].m_indices16)
694  {
695  meshPart.m_indexType = PHY_SHORT;
696  meshPart.m_triangleIndexStride = 3*sizeof(short int);
697  short int* indexArray = (short int*)btAlignedAlloc(sizeof(short int)*3*meshPart.m_numTriangles,16);
698  m_shortIndexArrays.push_back(indexArray);
699  for (int j=0;j<3*meshPart.m_numTriangles;j++)
700  {
701  indexArray[j] = meshData.m_meshPartsPtr[i].m_indices16[j].m_value;
702  }
703 
704  meshPart.m_triangleIndexBase = (const unsigned char*)indexArray;
705  }
706 
707  if (meshData.m_meshPartsPtr[i].m_3indices8)
708  {
709  meshPart.m_indexType = PHY_UCHAR;
710  meshPart.m_triangleIndexStride = sizeof(unsigned char)*3;
711 
712  unsigned char* indexArray = (unsigned char*)btAlignedAlloc(sizeof(unsigned char)*3*meshPart.m_numTriangles,16);
713  m_charIndexArrays.push_back(indexArray);
714 
715  for (int j=0;j<meshPart.m_numTriangles;j++)
716  {
717  indexArray[3*j] = meshData.m_meshPartsPtr[i].m_3indices8[j].m_values[0];
718  indexArray[3*j+1] = meshData.m_meshPartsPtr[i].m_3indices8[j].m_values[1];
719  indexArray[3*j+2] = meshData.m_meshPartsPtr[i].m_3indices8[j].m_values[2];
720  }
721 
722  meshPart.m_triangleIndexBase = (const unsigned char*)indexArray;
723  }
724  }
725 
726  if (meshData.m_meshPartsPtr[i].m_vertices3f)
727  {
728  meshPart.m_vertexType = PHY_FLOAT;
729  meshPart.m_vertexStride = sizeof(btVector3FloatData);
731  m_floatVertexArrays.push_back(vertices);
732 
733  for (int j=0;j<meshPart.m_numVertices;j++)
734  {
735  vertices[j].m_floats[0] = meshData.m_meshPartsPtr[i].m_vertices3f[j].m_floats[0];
736  vertices[j].m_floats[1] = meshData.m_meshPartsPtr[i].m_vertices3f[j].m_floats[1];
737  vertices[j].m_floats[2] = meshData.m_meshPartsPtr[i].m_vertices3f[j].m_floats[2];
738  vertices[j].m_floats[3] = meshData.m_meshPartsPtr[i].m_vertices3f[j].m_floats[3];
739  }
740  meshPart.m_vertexBase = (const unsigned char*)vertices;
741  } else
742  {
743  meshPart.m_vertexType = PHY_DOUBLE;
744  meshPart.m_vertexStride = sizeof(btVector3DoubleData);
745 
746 
749 
750  for (int j=0;j<meshPart.m_numVertices;j++)
751  {
752  vertices[j].m_floats[0] = meshData.m_meshPartsPtr[i].m_vertices3d[j].m_floats[0];
753  vertices[j].m_floats[1] = meshData.m_meshPartsPtr[i].m_vertices3d[j].m_floats[1];
754  vertices[j].m_floats[2] = meshData.m_meshPartsPtr[i].m_vertices3d[j].m_floats[2];
755  vertices[j].m_floats[3] = meshData.m_meshPartsPtr[i].m_vertices3d[j].m_floats[3];
756  }
757  meshPart.m_vertexBase = (const unsigned char*)vertices;
758  }
759 
760  if (meshPart.m_triangleIndexBase && meshPart.m_vertexBase)
761  {
762  meshInterface->addIndexedMesh(meshPart,meshPart.m_indexType);
763  }
764  }
765 
766  return meshInterface;
767 }
768 
769 
771 {
772  //create a new btStridingMeshInterfaceData that is an exact copy of shapedata and store it in the WorldImporter
774 
775  newData->m_scaling = interfaceData->m_scaling;
776  newData->m_numMeshParts = interfaceData->m_numMeshParts;
777  newData->m_meshPartsPtr = new btMeshPartData[newData->m_numMeshParts];
778 
779  for(int i = 0;i < newData->m_numMeshParts;i++)
780  {
781  btMeshPartData* curPart = &interfaceData->m_meshPartsPtr[i];
782  btMeshPartData* curNewPart = &newData->m_meshPartsPtr[i];
783 
784  curNewPart->m_numTriangles = curPart->m_numTriangles;
785  curNewPart->m_numVertices = curPart->m_numVertices;
786 
787  if(curPart->m_vertices3f)
788  {
789  curNewPart->m_vertices3f = new btVector3FloatData[curNewPart->m_numVertices];
790  memcpy(curNewPart->m_vertices3f,curPart->m_vertices3f,sizeof(btVector3FloatData) * curNewPart->m_numVertices);
791  }
792  else
793  curNewPart->m_vertices3f = NULL;
794 
795  if(curPart->m_vertices3d)
796  {
797  curNewPart->m_vertices3d = new btVector3DoubleData[curNewPart->m_numVertices];
798  memcpy(curNewPart->m_vertices3d,curPart->m_vertices3d,sizeof(btVector3DoubleData) * curNewPart->m_numVertices);
799  }
800  else
801  curNewPart->m_vertices3d = NULL;
802 
803  int numIndices = curNewPart->m_numTriangles * 3;
806  bool uninitialized3indices8Workaround =false;
807 
808  if(curPart->m_indices32)
809  {
810  uninitialized3indices8Workaround=true;
811  curNewPart->m_indices32 = new btIntIndexData[numIndices];
812  memcpy(curNewPart->m_indices32,curPart->m_indices32,sizeof(btIntIndexData) * numIndices);
813  }
814  else
815  curNewPart->m_indices32 = NULL;
816 
817  if(curPart->m_3indices16)
818  {
819  uninitialized3indices8Workaround=true;
820  curNewPart->m_3indices16 = new btShortIntIndexTripletData[curNewPart->m_numTriangles];
821  memcpy(curNewPart->m_3indices16,curPart->m_3indices16,sizeof(btShortIntIndexTripletData) * curNewPart->m_numTriangles);
822  }
823  else
824  curNewPart->m_3indices16 = NULL;
825 
826  if(curPart->m_indices16)
827  {
828  uninitialized3indices8Workaround=true;
829  curNewPart->m_indices16 = new btShortIntIndexData[numIndices];
830  memcpy(curNewPart->m_indices16,curPart->m_indices16,sizeof(btShortIntIndexData) * numIndices);
831  }
832  else
833  curNewPart->m_indices16 = NULL;
834 
835  if(!uninitialized3indices8Workaround && curPart->m_3indices8)
836  {
837  curNewPart->m_3indices8 = new btCharIndexTripletData[curNewPart->m_numTriangles];
838  memcpy(curNewPart->m_3indices8,curPart->m_3indices8,sizeof(btCharIndexTripletData) * curNewPart->m_numTriangles);
839  }
840  else
841  curNewPart->m_3indices8 = NULL;
842 
843  }
844 
846 
847  return(newData);
848 }
849 
850 #ifdef USE_INTERNAL_EDGE_UTILITY
852 
853 static bool btAdjustInternalEdgeContactsCallback(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
854 {
855 
856  btAdjustInternalEdgeContacts(cp,colObj1,colObj0, partId1,index1);
857  //btAdjustInternalEdgeContacts(cp,colObj1,colObj0, partId1,index1, BT_TRIANGLE_CONVEX_BACKFACE_MODE);
858  //btAdjustInternalEdgeContacts(cp,colObj1,colObj0, partId1,index1, BT_TRIANGLE_CONVEX_DOUBLE_SIDED+BT_TRIANGLE_CONCAVE_DOUBLE_SIDED);
859  return true;
860 }
861 #endif //USE_INTERNAL_EDGE_UTILITY
862 
863 
864 /*
865 btRigidBody* btWorldImporter::createRigidBody(bool isDynamic, btScalar mass, const btTransform& startTransform,btCollisionShape* shape,const char* bodyName)
866 {
867  btVector3 localInertia;
868  localInertia.setZero();
869 
870  if (mass)
871  shape->calculateLocalInertia(mass,localInertia);
872 
873  btRigidBody* body = new btRigidBody(mass,0,shape,localInertia);
874  body->setWorldTransform(startTransform);
875 
876  if (m_dynamicsWorld)
877  m_dynamicsWorld->addRigidBody(body);
878 
879  if (bodyName)
880  {
881  char* newname = duplicateName(bodyName);
882  m_objectNameMap.insert(body,newname);
883  m_nameBodyMap.insert(newname,body);
884  }
885  m_allocatedRigidBodies.push_back(body);
886  return body;
887 
888 }
889 */
890 
892 {
893  btCollisionObject** bodyPtr = m_nameColObjMap.find(name);
894  if (bodyPtr && *bodyPtr)
895  {
896  return *bodyPtr;
897  }
898  return 0;
899 }
900 
902 {
903  btCollisionObject* colObj = new btCollisionObject();
904  colObj->setWorldTransform(startTransform);
905  colObj->setCollisionShape(shape);
906  m_collisionWorld->addCollisionObject(colObj);//todo: flags etc
907 
908  if (bodyName)
909  {
910  char* newname = duplicateName(bodyName);
911  m_objectNameMap.insert(colObj,newname);
912  m_nameColObjMap.insert(newname,colObj);
913  }
915 
916  return colObj;
917 }
918 
919 
920 
922 {
923  btStaticPlaneShape* shape = new btStaticPlaneShape(planeNormal,planeConstant);
925  return shape;
926 }
928 {
929  btBoxShape* shape = new btBoxShape(halfExtents);
931  return shape;
932 }
934 {
935  btSphereShape* shape = new btSphereShape(radius);
937  return shape;
938 }
939 
940 
942 {
943  btCapsuleShapeX* shape = new btCapsuleShapeX(radius,height);
945  return shape;
946 }
947 
949 {
950  btCapsuleShape* shape = new btCapsuleShape(radius,height);
952  return shape;
953 }
954 
956 {
957  btCapsuleShapeZ* shape = new btCapsuleShapeZ(radius,height);
959  return shape;
960 }
961 
963 {
964  btCylinderShapeX* shape = new btCylinderShapeX(btVector3(height,radius,radius));
966  return shape;
967 }
968 
970 {
971  btCylinderShape* shape = new btCylinderShape(btVector3(radius,height,radius));
973  return shape;
974 }
975 
977 {
978  btCylinderShapeZ* shape = new btCylinderShapeZ(btVector3(radius,radius,height));
980  return shape;
981 }
982 
984 {
985  btConeShapeX* shape = new btConeShapeX(radius,height);
987  return shape;
988 }
989 
991 {
992  btConeShape* shape = new btConeShape(radius,height);
994  return shape;
995 }
996 
998 {
999  btConeShapeZ* shape = new btConeShapeZ(radius,height);
1001  return shape;
1002 }
1003 
1005 {
1008  return in;
1009 }
1010 
1012 {
1013  btOptimizedBvh* bvh = new btOptimizedBvh();
1015  return bvh;
1016 }
1017 
1018 
1020 {
1021  btTriangleInfoMap* tim = new btTriangleInfoMap();
1023  return tim;
1024 }
1025 
1027 {
1028  if (bvh)
1029  {
1030  btBvhTriangleMeshShape* bvhTriMesh = new btBvhTriangleMeshShape(trimesh,bvh->isQuantized(), false);
1031  bvhTriMesh->setOptimizedBvh(bvh);
1033  return bvhTriMesh;
1034  }
1035 
1036  btBvhTriangleMeshShape* ts = new btBvhTriangleMeshShape(trimesh,true);
1038  return ts;
1039 
1040 }
1042 {
1043  return 0;
1044 }
1045 #ifdef SUPPORT_GIMPACT_SHAPE_IMPORT
1046 btGImpactMeshShape* btCollisionWorldImporter::createGimpactShape(btStridingMeshInterface* trimesh)
1047 {
1048  btGImpactMeshShape* shape = new btGImpactMeshShape(trimesh);
1050  return shape;
1051 
1052 }
1053 #endif //SUPPORT_GIMPACT_SHAPE_IMPORT
1054 
1056 {
1057  btConvexHullShape* shape = new btConvexHullShape();
1059  return shape;
1060 }
1061 
1063 {
1064  btCompoundShape* shape = new btCompoundShape();
1066  return shape;
1067 }
1068 
1069 
1071 {
1072  btScaledBvhTriangleMeshShape* shape = new btScaledBvhTriangleMeshShape(meshShape,localScaling);
1074  return shape;
1075 }
1076 
1078 {
1079  btMultiSphereShape* shape = new btMultiSphereShape(positions, radi, numSpheres);
1081  return shape;
1082 }
1083 
1084 
1085 
1086  // query for data
1088 {
1090 }
1091 
1093 {
1094  return m_allocatedCollisionShapes[index];
1095 }
1096 
1098 {
1099  btCollisionShape** shapePtr = m_nameShapeMap.find(name);
1100  if (shapePtr&& *shapePtr)
1101  {
1102  return *shapePtr;
1103  }
1104  return 0;
1105 }
1106 
1107 
1108 const char* btCollisionWorldImporter::getNameForPointer(const void* ptr) const
1109 {
1110  const char*const * namePtr = m_objectNameMap.find(ptr);
1111  if (namePtr && *namePtr)
1112  return *namePtr;
1113  return 0;
1114 }
1115 
1116 
1118 {
1119  return m_allocatedRigidBodies.size();
1120 }
1121 
1123 {
1124  return m_allocatedRigidBodies[index];
1125 }
1126 
1127 
1129 {
1130  return m_allocatedBvhs.size();
1131 }
1133 {
1134  return m_allocatedBvhs[index];
1135 }
1136 
1138 {
1140 }
1141 
1143 {
1144  return m_allocatedTriangleInfoMaps[index];
1145 }
1146 
1147 
btCollisionWorldImporter::duplicateName
char * duplicateName(const char *name)
Definition: btCollisionWorldImporter.cpp:628
btCollisionShapeData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition: btCollisionShape.h:155
btBulletSerializedArrays::m_bvhsDouble
btAlignedObjectArray< struct btQuantizedBvhDoubleData * > m_bvhsDouble
Definition: btSerializer.h:147
btMeshPartData::m_3indices16
btShortIntIndexTripletData * m_3indices16
Definition: btStridingMeshInterface.h:135
btCollisionObject
btCollisionObject can be used to manage collision detection objects.
Definition: btCollisionObject.h:49
btCollisionShapeData::m_shapeType
int m_shapeType
Definition: btCollisionShape.h:158
btCollisionWorldImporter::getBvhByIndex
btOptimizedBvh * getBvhByIndex(int index) const
Definition: btCollisionWorldImporter.cpp:1132
SOFTBODY_SHAPE_PROXYTYPE
@ SOFTBODY_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:73
btCollisionWorldImporter::deleteAllData
virtual void deleteAllData()
delete all memory collision shapes, rigid bodies, constraints etc.
Definition: btCollisionWorldImporter.cpp:151
btCompoundShapeChildData::m_childShape
btCollisionShapeData * m_childShape
Definition: btCompoundShape.h:182
btCollisionWorldImporter::getCollisionShapeByIndex
btCollisionShape * getCollisionShapeByIndex(int index)
Definition: btCollisionWorldImporter.cpp:1092
btAlignedFree
#define btAlignedFree(ptr)
Definition: btAlignedAllocator.h:48
btCollisionShape::getShapeType
int getShapeType() const
Definition: btCollisionShape.h:112
btCollisionWorldImporter::createBvhTriangleMeshShape
virtual btBvhTriangleMeshShape * createBvhTriangleMeshShape(btStridingMeshInterface *trimesh, btOptimizedBvh *bvh)
Definition: btCollisionWorldImporter.cpp:1026
CYLINDER_SHAPE_PROXYTYPE
@ CYLINDER_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:45
btCollisionWorldImporter::createMultiSphereShape
virtual class btMultiSphereShape * createMultiSphereShape(const btVector3 *positions, const btScalar *radi, int numSpheres)
Definition: btCollisionWorldImporter.cpp:1077
btOptimizedBvh
The btOptimizedBvh extends the btQuantizedBvh to create AABB tree for triangle meshes,...
Definition: btOptimizedBvh.h:27
btTransformDoubleData::m_origin
btVector3DoubleData m_origin
Definition: btTransform.h:262
btCollisionWorldImporter.h
btCollisionShapeData::m_name
char * m_name
Definition: btCollisionShape.h:157
btCollisionObjectFloatData::m_name
char * m_name
Definition: btCollisionObject.h:642
btCollisionWorldImporter::createCylinderShapeZ
virtual btCollisionShape * createCylinderShapeZ(btScalar radius, btScalar height)
Definition: btCollisionWorldImporter.cpp:976
btShortIntIndexTripletData::m_values
short m_values[3]
Definition: btStridingMeshInterface.h:117
btStaticPlaneShapeData::m_planeConstant
float m_planeConstant
Definition: btStaticPlaneShape.h:78
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:292
btBoxShape
The btBoxShape is a box primitive around the origin, its sides axis aligned with length specified by ...
Definition: btBoxShape.h:26
btConvexHullShapeData::m_unscaledPointsFloatPtr
btVector3FloatData * m_unscaledPointsFloatPtr
Definition: btConvexHullShape.h:105
btMeshPartData::m_vertices3f
btVector3FloatData * m_vertices3f
Definition: btStridingMeshInterface.h:131
btConeShapeData::m_upIndex
int m_upIndex
Definition: btConeShape.h:157
btScaledTriangleMeshShapeData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition: btScaledBvhTriangleMeshShape.h:70
btCylinderShapeData::m_upAxis
int m_upAxis
Definition: btCylinderShape.h:188
btCollisionWorldImporter::getCollisionShapeByName
btCollisionShape * getCollisionShapeByName(const char *name)
Definition: btCollisionWorldImporter.cpp:1097
btCollisionObjectDoubleData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition: btCollisionObject.h:602
btAdjustInternalEdgeContacts
void btAdjustInternalEdgeContacts(btManifoldPoint &cp, const btCollisionObjectWrapper *colObj0Wrap, const btCollisionObjectWrapper *colObj1Wrap, int partId0, int index0, int normalAdjustFlags)
Changes a btManifoldPoint collision normal to the normal from the mesh.
Definition: btInternalEdgeUtility.cpp:449
btTriangleMeshShapeData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition: btBvhTriangleMeshShape.h:124
btCollisionObjectFloatData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition: btCollisionObject.h:637
btBvhTriangleMeshShape
The btBvhTriangleMeshShape is a static-triangle mesh shape, it can only be used for fixed/non-moving ...
Definition: btBvhTriangleMeshShape.h:34
btCompoundShapeChildData::m_transform
btTransformFloatData m_transform
Definition: btCompoundShape.h:181
btCollisionWorldImporter::getTriangleInfoMapByIndex
btTriangleInfoMap * getTriangleInfoMapByIndex(int index) const
Definition: btCollisionWorldImporter.cpp:1142
btCollisionWorldImporter::createCylinderShapeX
virtual btCollisionShape * createCylinderShapeX(btScalar radius, btScalar height)
Definition: btCollisionWorldImporter.cpp:962
btIndexedMesh::m_vertexType
PHY_ScalarType m_vertexType
Definition: btTriangleIndexVertexArray.h:46
btBulletSerializedArrays::m_bvhsFloat
btAlignedObjectArray< struct btQuantizedBvhFloatData * > m_bvhsFloat
Definition: btSerializer.h:148
btStridingMeshInterface::setScaling
void setScaling(const btVector3 &scaling)
Definition: btStridingMeshInterface.h:91
btStaticPlaneShapeData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition: btStaticPlaneShape.h:72
btAlignedObjectArray::clear
void clear()
clear the array, deallocated memory. Generally it is better to use array.resize(0),...
Definition: btAlignedObjectArray.h:190
btMeshPartData::m_indices16
btShortIntIndexData * m_indices16
Definition: btStridingMeshInterface.h:138
gContactAddedCallback
ContactAddedCallback gContactAddedCallback
This is to allow MaterialCombiner/Custom Friction/Restitution values.
Definition: btManifoldResult.cpp:23
btCollisionWorldImporter::m_shapeMap
btHashMap< btHashPtr, btCollisionShape * > m_shapeMap
Definition: btCollisionWorldImporter.h:87
btCollisionWorldImporter::m_nameShapeMap
btHashMap< btHashString, btCollisionShape * > m_nameShapeMap
Definition: btCollisionWorldImporter.h:82
btCollisionWorldImporter::createTriangleMeshContainer
virtual class btTriangleIndexVertexArray * createTriangleMeshContainer()
Definition: btCollisionWorldImporter.cpp:1004
btMeshPartData::m_numVertices
int m_numVertices
Definition: btStridingMeshInterface.h:141
btCollisionWorldImporter::convertAllObjects
bool convertAllObjects(btBulletSerializedArrays *arrays)
Definition: btCollisionWorldImporter.cpp:39
btCollisionWorldImporter::createTriangleInfoMap
virtual btTriangleInfoMap * createTriangleInfoMap()
Definition: btCollisionWorldImporter.cpp:1019
btVector3DoubleData::m_floats
double m_floats[4]
Definition: btVector3.h:1319
btAlignedAlloc
#define btAlignedAlloc(size, alignment)
Definition: btAlignedAllocator.h:47
btStridingMeshInterfaceData::m_numMeshParts
int m_numMeshParts
Definition: btStridingMeshInterface.h:150
btCollisionWorldImporter::m_allocatedRigidBodies
btAlignedObjectArray< btCollisionObject * > m_allocatedRigidBodies
Definition: btCollisionWorldImporter.h:60
btCollisionObjectDoubleData::m_worldTransform
btTransformDoubleData m_worldTransform
Definition: btCollisionObject.h:609
btCollisionWorldImporter::m_nameColObjMap
btHashMap< btHashString, btCollisionObject * > m_nameColObjMap
Definition: btCollisionWorldImporter.h:83
btCollisionWorldImporter::m_indexArrays
btAlignedObjectArray< int * > m_indexArrays
Definition: btCollisionWorldImporter.h:71
btCollisionObjectDoubleData::m_collisionShape
void * m_collisionShape
Definition: btCollisionObject.h:605
btCollisionWorldImporter::m_bvhMap
btHashMap< btHashPtr, btOptimizedBvh * > m_bvhMap
Definition: btCollisionWorldImporter.h:79
btCollisionWorldImporter::createOptimizedBvh
virtual btOptimizedBvh * createOptimizedBvh()
acceleration and connectivity structures
Definition: btCollisionWorldImporter.cpp:1011
btGImpactMeshShape::setLocalScaling
virtual void setLocalScaling(const btVector3 &scaling)
Definition: btGImpactShape.h:964
btCollisionWorldImporter::createSphereShape
virtual btCollisionShape * createSphereShape(btScalar radius)
Definition: btCollisionWorldImporter.cpp:933
btGImpactMeshShape
This class manages a mesh supplied by the btStridingMeshInterface interface.
Definition: btGImpactShape.h:890
btPositionAndRadius::m_pos
btVector3FloatData m_pos
Definition: btMultiSphereShape.h:79
PHY_FLOAT
@ PHY_FLOAT
Definition: btConcaveShape.h:26
btTriangleInfoMap::deSerialize
void deSerialize(struct btTriangleInfoMapData &data)
fills the dataBuffer and returns the struct name (and 0 on failure)
Definition: btTriangleInfoMap.h:211
btCharIndexTripletData
Definition: btStridingMeshInterface.h:121
btIndexedMesh::m_triangleIndexBase
const unsigned char * m_triangleIndexBase
Definition: btTriangleIndexVertexArray.h:31
btMeshPartData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition: btStridingMeshInterface.h:129
btCollisionWorldImporter::createConvexHullShape
virtual class btConvexHullShape * createConvexHullShape()
Definition: btCollisionWorldImporter.cpp:1055
btHashMap::clear
void clear()
Definition: btHashMap.h:472
btMultiSphereShapeData::m_localPositionArraySize
int m_localPositionArraySize
Definition: btMultiSphereShape.h:88
btCollisionWorldImporter::m_allocatedbtStridingMeshInterfaceDatas
btAlignedObjectArray< btStridingMeshInterfaceData * > m_allocatedbtStridingMeshInterfaceDatas
Definition: btCollisionWorldImporter.h:65
btTriangleMeshShapeData::m_meshInterface
btStridingMeshInterfaceData m_meshInterface
Definition: btBvhTriangleMeshShape.h:128
btVector3FloatData
Definition: btVector3.h:1312
btCollisionWorldImporter::createConeShapeZ
virtual btCollisionShape * createConeShapeZ(btScalar radius, btScalar height)
Definition: btCollisionWorldImporter.cpp:997
btBulletSerializedArrays::m_colShapeData
btAlignedObjectArray< struct btCollisionShapeData * > m_colShapeData
Definition: btSerializer.h:149
btCollisionObjectDoubleData::m_restitution
double m_restitution
Definition: btCollisionObject.h:620
btCollisionWorldImporter::createMeshInterface
virtual btTriangleIndexVertexArray * createMeshInterface(btStridingMeshInterfaceData &meshData)
Definition: btCollisionWorldImporter.cpp:652
GIMPACT_SHAPE_PROXYTYPE
@ GIMPACT_SHAPE_PROXYTYPE
Used for GIMPACT Trimesh integration.
Definition: btBroadphaseProxy.h:62
btShortIntIndexData::m_value
short m_value
Definition: btStridingMeshInterface.h:111
btCapsuleShapeData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition: btCapsuleShape.h:149
btStridingMeshInterface
The btStridingMeshInterface is the interface class for high performance generic access to triangle me...
Definition: btStridingMeshInterface.h:30
btVector3::getX
const btScalar & getX() const
Return the x value.
Definition: btVector3.h:573
btBvhTriangleMeshShape::setOptimizedBvh
void setOptimizedBvh(btOptimizedBvh *bvh, const btVector3 &localScaling=btVector3(1, 1, 1))
Definition: btBvhTriangleMeshShape.cpp:356
btTriangleMeshShapeData::m_collisionMargin
float m_collisionMargin
Definition: btBvhTriangleMeshShape.h:135
btTriangleMeshShapeData::m_triangleInfoMap
btTriangleInfoMapData * m_triangleInfoMap
Definition: btBvhTriangleMeshShape.h:133
btCollisionObjectFloatData::m_collisionShape
void * m_collisionShape
Definition: btCollisionObject.h:640
btShortIntIndexTripletData
Definition: btStridingMeshInterface.h:115
btCollisionShape
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
Definition: btCollisionShape.h:27
MULTI_SPHERE_SHAPE_PROXYTYPE
@ MULTI_SPHERE_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:41
btCollisionWorldImporter::m_allocatedBvhs
btAlignedObjectArray< btOptimizedBvh * > m_allocatedBvhs
Definition: btCollisionWorldImporter.h:62
btConvexInternalShapeData::m_localScaling
btVector3FloatData m_localScaling
Definition: btConvexInternalShape.h:148
btCapsuleShapeX
btCapsuleShapeX represents a capsule around the Z axis the total height is height+2*radius,...
Definition: btCapsuleShape.h:116
btCollisionObject::setRestitution
void setRestitution(btScalar rest)
Definition: btCollisionObject.h:304
btConcaveShape::setMargin
virtual void setMargin(btScalar collisionMargin)
Definition: btConcaveShape.h:53
btGImpactMeshShapeData::m_gimpactSubType
int m_gimpactSubType
Definition: btGImpactShape.h:1155
PHY_DOUBLE
@ PHY_DOUBLE
Definition: btConcaveShape.h:27
btVector3DoubleData
Definition: btVector3.h:1317
CAPSULE_SHAPE_PROXYTYPE
@ CAPSULE_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:42
btCollisionObject::setCollisionShape
virtual void setCollisionShape(btCollisionShape *collisionShape)
Definition: btCollisionObject.h:221
btManifoldPoint
ManifoldContactPoint collects and maintains persistent contactpoints.
Definition: btManifoldPoint.h:49
btMultiSphereShapeData::m_localPositionArrayPtr
btPositionAndRadius * m_localPositionArrayPtr
Definition: btMultiSphereShape.h:87
btMultiSphereShape
The btMultiSphereShape represents the convex hull of a collection of spheres.
Definition: btMultiSphereShape.h:28
btGImpactMeshShapeData::m_collisionMargin
float m_collisionMargin
Definition: btGImpactShape.h:1153
btCollisionWorldImporter::m_collisionWorld
btCollisionWorld * m_collisionWorld
Definition: btCollisionWorldImporter.h:55
btCollisionWorldImporter::~btCollisionWorldImporter
virtual ~btCollisionWorldImporter()
Definition: btCollisionWorldImporter.cpp:31
btGImpactMeshShapeData::m_meshInterface
btStridingMeshInterfaceData m_meshInterface
Definition: btGImpactShape.h:1149
btCollisionWorldImporter::getCollisionObjectByName
btCollisionObject * getCollisionObjectByName(const char *name)
Definition: btCollisionWorldImporter.cpp:891
btAlignedObjectArray::resize
void resize(int newsize, const T &fillData=T())
Definition: btAlignedObjectArray.h:218
btIndexedMesh::m_numTriangles
int m_numTriangles
Definition: btTriangleIndexVertexArray.h:30
btMultiSphereShapeData
Definition: btMultiSphereShape.h:83
btCollisionWorldImporter::m_doubleVertexArrays
btAlignedObjectArray< btVector3DoubleData * > m_doubleVertexArrays
Definition: btCollisionWorldImporter.h:76
btCylinderShapeX
Definition: btCylinderShape.h:137
btTriangleInfoMap
The btTriangleInfoMap stores edge angle information for some triangles. You can compute this informat...
Definition: btTriangleInfoMap.h:58
btCollisionWorldImporter::createConvexTriangleMeshShape
virtual btCollisionShape * createConvexTriangleMeshShape(btStridingMeshInterface *trimesh)
Definition: btCollisionWorldImporter.cpp:1041
btGImpactMeshShape::setMargin
virtual void setMargin(btScalar margin)
Definition: btGImpactShape.h:978
btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK
@ CF_CUSTOM_MATERIAL_CALLBACK
Definition: btCollisionObject.h:136
btCollisionWorldImporter::createCylinderShapeY
virtual btCollisionShape * createCylinderShapeY(btScalar radius, btScalar height)
Definition: btCollisionWorldImporter.cpp:969
btCollisionObjectFloatData::m_worldTransform
btTransformFloatData m_worldTransform
Definition: btCollisionObject.h:644
SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE
@ SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:56
btBulletSerializedArrays::m_collisionObjectDataFloat
btAlignedObjectArray< struct btCollisionObjectFloatData * > m_collisionObjectDataFloat
Definition: btSerializer.h:155
btCompoundShapeData::m_childShapePtr
btCompoundShapeChildData * m_childShapePtr
Definition: btCompoundShape.h:192
btCollisionObject::setFriction
void setFriction(btScalar frict)
Definition: btCollisionObject.h:313
btQuantizedBvh::deSerializeDouble
virtual void deSerializeDouble(struct btQuantizedBvhDoubleData &quantizedBvhDoubleData)
Definition: btQuantizedBvh.cpp:1238
btBulletSerializedArrays::m_collisionObjectDataDouble
btAlignedObjectArray< struct btCollisionObjectDoubleData * > m_collisionObjectDataDouble
Definition: btSerializer.h:154
btCollisionObject::setWorldTransform
void setWorldTransform(const btTransform &worldTrans)
Definition: btCollisionObject.h:382
btSerializer.h
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:34
BOX_SHAPE_PROXYTYPE
@ BOX_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:31
btTriangleMeshShapeData::m_quantizedDoubleBvh
btQuantizedBvhDoubleData * m_quantizedDoubleBvh
Definition: btBvhTriangleMeshShape.h:131
btCollisionObject::getCollisionFlags
int getCollisionFlags() const
Definition: btCollisionObject.h:485
btCollisionWorldImporter::createConeShapeY
virtual btCollisionShape * createConeShapeY(btScalar radius, btScalar height)
Definition: btCollisionWorldImporter.cpp:990
ContactAddedCallback
bool(* ContactAddedCallback)(btManifoldPoint &cp, const btCollisionObjectWrapper *colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper *colObj1Wrap, int partId1, int index1)
Definition: btManifoldResult.h:32
btConvexHullShapeData::m_numUnscaledPoints
int m_numUnscaledPoints
Definition: btConvexHullShape.h:108
btIndexedMesh
The btIndexedMesh indexes a single vertex and index array.
Definition: btTriangleIndexVertexArray.h:26
btConeShapeZ
btConeShapeZ implements a Cone shape, around the Z axis
Definition: btConeShape.h:133
btCompoundShapeData::m_numChildShapes
int m_numChildShapes
Definition: btCompoundShape.h:194
btCapsuleShape
The btCapsuleShape represents a capsule around the Y axis, there is also the btCapsuleShapeX aligned ...
Definition: btCapsuleShape.h:26
btCollisionWorldImporter::createCapsuleShapeZ
virtual btCollisionShape * createCapsuleShapeZ(btScalar radius, btScalar height)
Definition: btCollisionWorldImporter.cpp:955
btSphereShape
The btSphereShape implements an implicit sphere, centered around a local origin with radius.
Definition: btSphereShape.h:22
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
btCollisionWorldImporter::createPlaneShape
virtual btCollisionShape * createPlaneShape(const btVector3 &planeNormal, btScalar planeConstant)
shapes
Definition: btCollisionWorldImporter.cpp:921
CONVEX_HULL_SHAPE_PROXYTYPE
@ CONVEX_HULL_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:35
btCylinderShapeData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition: btCylinderShape.h:184
btIndexedMesh::m_triangleIndexStride
int m_triangleIndexStride
Definition: btTriangleIndexVertexArray.h:33
btMeshPartData::m_vertices3d
btVector3DoubleData * m_vertices3d
Definition: btStridingMeshInterface.h:132
btCollisionWorldImporter::m_charIndexArrays
btAlignedObjectArray< unsigned char * > m_charIndexArrays
Definition: btCollisionWorldImporter.h:73
btCollisionWorldImporter::getNameForPointer
const char * getNameForPointer(const void *ptr) const
Definition: btCollisionWorldImporter.cpp:1108
btConvexInternalShapeData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition: btConvexInternalShape.h:144
btIndexedMesh::m_vertexStride
int m_vertexStride
Definition: btTriangleIndexVertexArray.h:37
btQuantizedBvh::deSerializeFloat
virtual void deSerializeFloat(struct btQuantizedBvhFloatData &quantizedBvhFloatData)
Definition: btQuantizedBvh.cpp:1167
btCharIndexTripletData::m_values
unsigned char m_values[3]
Definition: btStridingMeshInterface.h:123
btCollisionWorldImporter::createConeShapeX
virtual btCollisionShape * createConeShapeX(btScalar radius, btScalar height)
Definition: btCollisionWorldImporter.cpp:983
btConvexHullShapeData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition: btConvexHullShape.h:101
SPHERE_SHAPE_PROXYTYPE
@ SPHERE_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:40
btBvhTriangleMeshShape::setTriangleInfoMap
void setTriangleInfoMap(btTriangleInfoMap *triangleInfoMap)
Definition: btBvhTriangleMeshShape.h:97
btVector3::getZ
const btScalar & getZ() const
Return the z value.
Definition: btVector3.h:577
btMeshPartData::m_indices32
btIntIndexData * m_indices32
Definition: btStridingMeshInterface.h:134
btConvexInternalShapeData::m_collisionMargin
float m_collisionMargin
Definition: btConvexInternalShape.h:152
btCollisionWorldImporter::m_allocatedTriangleIndexArrays
btAlignedObjectArray< btTriangleIndexVertexArray * > m_allocatedTriangleIndexArrays
Definition: btCollisionWorldImporter.h:64
btCollisionWorldImporter::createCapsuleShapeY
virtual btCollisionShape * createCapsuleShapeY(btScalar radius, btScalar height)
Definition: btCollisionWorldImporter.cpp:948
btAlignedObjectArray< btVector3 >
btVector3::getY
const btScalar & getY() const
Return the y value.
Definition: btVector3.h:575
btCollisionWorldImporter::getNumCollisionShapes
int getNumCollisionShapes() const
Definition: btCollisionWorldImporter.cpp:1087
btHashMap::find
const Value * find(const Key &key) const
Definition: btHashMap.h:434
btCollisionWorldImporter::m_allocatedNames
btAlignedObjectArray< char * > m_allocatedNames
Definition: btCollisionWorldImporter.h:69
btTriangleMeshShapeData::m_quantizedFloatBvh
btQuantizedBvhFloatData * m_quantizedFloatBvh
Definition: btBvhTriangleMeshShape.h:130
btCompoundShape
The btCompoundShape allows to store multiple other btCollisionShapes This allows for moving concave c...
Definition: btCompoundShape.h:54
btConvexHullShape
The btConvexHullShape implements an implicit convex hull of an array of vertices.
Definition: btConvexHullShape.h:26
btBulletSerializedArrays
Definition: btSerializer.h:142
CONST_GIMPACT_TRIMESH_SHAPE
@ CONST_GIMPACT_TRIMESH_SHAPE
Definition: btGImpactShape.h:50
btCollisionWorld::removeCollisionObject
virtual void removeCollisionObject(btCollisionObject *collisionObject)
Definition: btCollisionWorld.cpp:237
btCollisionShape::setMargin
virtual void setMargin(btScalar margin)=0
btShortIntIndexData
Definition: btStridingMeshInterface.h:109
TRIANGLE_MESH_SHAPE_PROXYTYPE
@ TRIANGLE_MESH_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:55
btMeshPartData::m_numTriangles
int m_numTriangles
Definition: btStridingMeshInterface.h:140
btIntIndexData::m_value
int m_value
Definition: btStridingMeshInterface.h:106
btCollisionWorldImporter::getNumTriangleInfoMaps
int getNumTriangleInfoMaps() const
Definition: btCollisionWorldImporter.cpp:1137
btCollisionObject::setCollisionFlags
void setCollisionFlags(int flags)
Definition: btCollisionObject.h:490
btScaledTriangleMeshShapeData::m_localScaling
btVector3FloatData m_localScaling
Definition: btScaledBvhTriangleMeshShape.h:74
btCompoundShape::addChildShape
void addChildShape(const btTransform &localTransform, btCollisionShape *shape)
Definition: btCompoundShape.cpp:51
btStaticPlaneShapeData::m_planeNormal
btVector3FloatData m_planeNormal
Definition: btStaticPlaneShape.h:77
btConvexHullShapeData::m_unscaledPointsDoublePtr
btVector3DoubleData * m_unscaledPointsDoublePtr
Definition: btConvexHullShape.h:106
btHashMap::insert
void insert(const Key &key, const Value &value)
Definition: btHashMap.h:274
btGImpactMeshShapeData::m_localScaling
btVector3FloatData m_localScaling
Definition: btGImpactShape.h:1151
btStaticPlaneShape
The btStaticPlaneShape simulates an infinite non-moving (static) collision plane.
Definition: btStaticPlaneShape.h:23
btQuantizedBvhFloatData
Definition: btQuantizedBvh.h:539
btBulletCollisionCommon.h
btTriangleIndexVertexArray::getNumSubParts
virtual int getNumSubParts() const
getNumSubParts returns the number of seperate subparts each subpart has a continuous array of vertice...
Definition: btTriangleIndexVertexArray.h:109
btStridingMeshInterfaceData::m_meshPartsPtr
btMeshPartData * m_meshPartsPtr
Definition: btStridingMeshInterface.h:148
btTriangleIndexVertexArray::addIndexedMesh
void addIndexedMesh(const btIndexedMesh &mesh, PHY_ScalarType indexType=PHY_INTEGER)
Definition: btTriangleIndexVertexArray.h:90
btConeShape
The btConeShape implements a cone shape primitive, centered around the origin and aligned with the Y ...
Definition: btConeShape.h:23
btCollisionWorldImporter::m_allocatedTriangleInfoMaps
btAlignedObjectArray< btTriangleInfoMap * > m_allocatedTriangleInfoMaps
Definition: btCollisionWorldImporter.h:63
PHY_INTEGER
@ PHY_INTEGER
Definition: btConcaveShape.h:28
btCollisionWorldImporter::getRigidBodyByIndex
btCollisionObject * getRigidBodyByIndex(int index) const
Definition: btCollisionWorldImporter.cpp:1122
btQuantizedBvh::isQuantized
bool isQuantized()
Definition: btQuantizedBvh.h:488
btCapsuleShape::deSerializeFloat
void deSerializeFloat(struct btCapsuleShapeData *dataBuffer)
Definition: btCapsuleShape.h:181
btCollisionWorldImporter::createCapsuleShapeX
virtual btCollisionShape * createCapsuleShapeX(btScalar radius, btScalar height)
Definition: btCollisionWorldImporter.cpp:941
btCollisionWorldImporter::createStridingMeshInterfaceData
virtual btStridingMeshInterfaceData * createStridingMeshInterfaceData(btStridingMeshInterfaceData *interfaceData)
Definition: btCollisionWorldImporter.cpp:770
btCollisionObjectDoubleData::m_name
char * m_name
Definition: btCollisionObject.h:607
btConvexInternalShape::setMargin
virtual void setMargin(btScalar margin)
Definition: btConvexInternalShape.h:109
btStridingMeshInterfaceData::m_scaling
btVector3FloatData m_scaling
Definition: btStridingMeshInterface.h:149
btCylinderShape
The btCylinderShape class implements a cylinder shape primitive, centered around the origin....
Definition: btCylinderShape.h:24
btCollisionWorldImporter::createBoxShape
virtual btCollisionShape * createBoxShape(const btVector3 &halfExtents)
Definition: btCollisionWorldImporter.cpp:927
btTransformFloatData::m_origin
btVector3FloatData m_origin
Definition: btTransform.h:256
btIntIndexData
Definition: btStridingMeshInterface.h:104
btCollisionWorld
CollisionWorld is interface and container for the collision detection.
Definition: btCollisionWorld.h:88
btCollisionWorldImporter::createCompoundShape
virtual class btCompoundShape * createCompoundShape()
Definition: btCollisionWorldImporter.cpp:1062
btStaticPlaneShapeData::m_localScaling
btVector3FloatData m_localScaling
Definition: btStaticPlaneShape.h:76
PHY_UCHAR
@ PHY_UCHAR
Definition: btConcaveShape.h:31
btCollisionWorldImporter::getNumBvhs
int getNumBvhs() const
Definition: btCollisionWorldImporter.cpp:1128
btCollisionShape::setLocalScaling
virtual void setLocalScaling(const btVector3 &scaling)=0
btVector3::deSerializeFloat
void deSerializeFloat(const struct btVector3FloatData &dataIn)
Definition: btVector3.h:1330
btCollisionWorldImporter::m_shortIndexArrays
btAlignedObjectArray< short int * > m_shortIndexArrays
Definition: btCollisionWorldImporter.h:72
btCollisionWorldImporter::getNumRigidBodies
int getNumRigidBodies() const
Definition: btCollisionWorldImporter.cpp:1117
btConvexHullShape::addPoint
void addPoint(const btVector3 &point, bool recalculateLocalAabb=true)
Definition: btConvexHullShape.cpp:54
btBvhTriangleMeshShape::getTriangleInfoMap
const btTriangleInfoMap * getTriangleInfoMap() const
Definition: btBvhTriangleMeshShape.h:102
btStridingMeshInterfaceData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition: btStridingMeshInterface.h:146
CONE_SHAPE_PROXYTYPE
@ CONE_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:43
btTriangleIndexVertexArray
The btTriangleIndexVertexArray allows to access multiple triangle meshes, by indexing into existing t...
Definition: btTriangleIndexVertexArray.h:68
btCompoundShapeData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition: btCompoundShape.h:188
btCollisionWorld::addCollisionObject
virtual void addCollisionObject(btCollisionObject *collisionObject, int collisionFilterGroup=btBroadphaseProxy::DefaultFilter, int collisionFilterMask=btBroadphaseProxy::AllFilter)
Definition: btCollisionWorld.cpp:111
btCollisionWorldImporter::m_allocatedCollisionObjects
btAlignedObjectArray< btCollisionObject * > m_allocatedCollisionObjects
Definition: btCollisionWorldImporter.h:66
btPositionAndRadius::m_radius
float m_radius
Definition: btMultiSphereShape.h:80
btQuantizedBvhDoubleData
Definition: btQuantizedBvh.h:556
btAlignedObjectArray::push_back
void push_back(const T &_Val)
Definition: btAlignedObjectArray.h:274
btGImpactMeshShapeData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition: btGImpactShape.h:1145
btCollisionWorldImporter::m_objectNameMap
btHashMap< btHashPtr, const char * > m_objectNameMap
Definition: btCollisionWorldImporter.h:85
btGImpactShapeInterface::updateBound
void updateBound()
performs refit operation
Definition: btGImpactShape.h:123
btIndexedMesh::m_vertexBase
const unsigned char * m_vertexBase
Definition: btTriangleIndexVertexArray.h:35
btCylinderShapeZ
Definition: btCylinderShape.h:160
btCapsuleShapeData::m_upAxis
int m_upAxis
Definition: btCapsuleShape.h:153
STATIC_PLANE_PROXYTYPE
@ STATIC_PLANE_PROXYTYPE
Definition: btBroadphaseProxy.h:67
btTransform::deSerializeFloat
void deSerializeFloat(const struct btTransformFloatData &dataIn)
Definition: btTransform.h:286
btTransform::deSerializeDouble
void deSerializeDouble(const struct btTransformDoubleData &dataIn)
Definition: btTransform.h:292
btCollisionWorldImporter::convertCollisionShape
btCollisionShape * convertCollisionShape(btCollisionShapeData *shapeData)
Definition: btCollisionWorldImporter.cpp:260
btCollisionWorldImporter::btCollisionWorldImporter
btCollisionWorldImporter(btCollisionWorld *world)
Definition: btCollisionWorldImporter.cpp:24
btCollisionWorldImporter::m_floatVertexArrays
btAlignedObjectArray< btVector3FloatData * > m_floatVertexArrays
Definition: btCollisionWorldImporter.h:75
btIndexedMesh::m_numVertices
int m_numVertices
Definition: btTriangleIndexVertexArray.h:34
btConeShapeData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition: btConeShape.h:153
btScaledBvhTriangleMeshShape
The btScaledBvhTriangleMeshShape allows to instance a scaled version of an existing btBvhTriangleMesh...
Definition: btScaledBvhTriangleMeshShape.h:24
btVector3FloatData::m_floats
float m_floats[4]
Definition: btVector3.h:1314
btCollisionWorldImporter::createCollisionObject
virtual btCollisionObject * createCollisionObject(const btTransform &startTransform, btCollisionShape *shape, const char *bodyName)
those virtuals are called by load and can be overridden by the user
Definition: btCollisionWorldImporter.cpp:901
btCapsuleShapeZ
btCapsuleShapeZ represents a capsule around the Z axis the total height is height+2*radius,...
Definition: btCapsuleShape.h:134
btCollisionObjectDoubleData::m_friction
double m_friction
Definition: btCollisionObject.h:616
btIndexedMesh::m_indexType
PHY_ScalarType m_indexType
Definition: btTriangleIndexVertexArray.h:41
btScaledTriangleMeshShapeData::m_trimeshShapeData
btTriangleMeshShapeData m_trimeshShapeData
Definition: btScaledBvhTriangleMeshShape.h:72
btConvexInternalShapeData::m_implicitShapeDimensions
btVector3FloatData m_implicitShapeDimensions
Definition: btConvexInternalShape.h:150
btGImpactShape.h
btCollisionWorldImporter::m_bodyMap
btHashMap< btHashPtr, btCollisionObject * > m_bodyMap
Definition: btCollisionWorldImporter.h:88
btConeShapeX
btConeShape implements a Cone shape, around the X axis
Definition: btConeShape.h:113
btAlignedObjectArray::size
int size() const
return the number of elements in the array
Definition: btAlignedObjectArray.h:155
btMeshPartData::m_3indices8
btCharIndexTripletData * m_3indices8
Definition: btStridingMeshInterface.h:136
PHY_SHORT
@ PHY_SHORT
Definition: btConcaveShape.h:29
btCollisionWorldImporter::createScaledTrangleMeshShape
virtual class btScaledBvhTriangleMeshShape * createScaledTrangleMeshShape(btBvhTriangleMeshShape *meshShape, const btVector3 &localScalingbtBvhTriangleMeshShape)
Definition: btCollisionWorldImporter.cpp:1070
COMPOUND_SHAPE_PROXYTYPE
@ COMPOUND_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:71
btCollisionWorldImporter::m_allocatedCollisionShapes
btAlignedObjectArray< btCollisionShape * > m_allocatedCollisionShapes
Definition: btCollisionWorldImporter.h:59