Bullet Collision Detection & Physics Library
btCollisionWorldImporter.cpp
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2014 Erwin Coumans http://bulletphysics.org
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. 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),
26m_verboseMode(0)
27{
28
29}
30
32{
33}
34
35
36
37
38
40{
41
44
45 int i;
46
47 for (i=0;i<arrays->m_bvhsDouble.size();i++)
48 {
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 {
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 {
70 if (shape)
71 {
72 // printf("shapeMap.insert(%x,%x)\n",shapeData,shape);
74 }
75
76 if (shape&& shapeData->m_name)
77 {
78 char* newname = duplicateName(shapeData->m_name);
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 {
92 colObjData->m_worldTransform.m_origin.m_floats[3] = 0.f;
93 startTransform.deSerializeDouble(colObjData->m_worldTransform);
94
97 body->setFriction(btScalar(colObjData->m_friction));
98 body->setRestitution(btScalar(colObjData->m_restitution));
99
100#ifdef USE_INTERNAL_EDGE_UTILITY
101 if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
102 {
104 if (trimesh->getTriangleInfoMap())
105 {
107 }
108 }
109#endif //USE_INTERNAL_EDGE_UTILITY
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 {
123 colObjData->m_worldTransform.m_origin.m_floats[3] = 0.f;
124 startTransform.deSerializeFloat(colObjData->m_worldTransform);
125
128
129#ifdef USE_INTERNAL_EDGE_UTILITY
130 if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
131 {
133 if (trimesh->getTriangleInfoMap())
134 {
136 }
137 }
138#endif //USE_INTERNAL_EDGE_UTILITY
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 {
160 }
161
163
164
165 for (i=0;i<m_allocatedCollisionShapes.size();i++)
166 {
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 {
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{
263
264 switch (shapeData->m_shapeType)
265 {
267 {
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 {
284 btVector3 localScaling;
285 localScaling.deSerializeFloat(scaledMesh->m_localScaling);
286
288 break;
289 }
290#ifdef SUPPORT_GIMPACT_SHAPE_IMPORT
292 {
294 if (gimpactData->m_gimpactSubType == CONST_GIMPACT_TRIMESH_SHAPE)
295 {
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();
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 {
319
320
321 switch (capData->m_upAxis)
322 {
323 case 0:
324 {
326 break;
327 }
328 case 1:
329 {
331 break;
332 }
333 case 2:
334 {
336 break;
337 }
338 default:
339 {
340 printf("error: wrong up axis for btCapsuleShape\n");
341 }
342
343
344 };
345 if (shape)
346 {
349 }
350 break;
351 }
358 {
361 implicitShapeDimensions.deSerializeFloat(bsd->m_implicitShapeDimensions);
362 btVector3 localScaling;
363 localScaling.deSerializeFloat(bsd->m_localScaling);
364 btVector3 margin(bsd->m_collisionMargin,bsd->m_collisionMargin,bsd->m_collisionMargin);
365 switch (shapeData->m_shapeType)
366 {
368 {
370 //box->initializePolyhedralFeatures();
371 shape = box;
372
373 break;
374 }
376 {
378 break;
379 }
380
382 {
385 switch (cylData->m_upAxis)
386 {
387 case 0:
388 {
390 break;
391 }
392 case 1:
393 {
395 break;
396 }
397 case 2:
398 {
400 break;
401 }
402 default:
403 {
404 printf("unknown Cylinder up axis\n");
405 }
406
407 };
408
409
410
411 break;
412 }
414 {
417 switch (conData->m_upIndex)
418 {
419 case 0:
420 {
422 break;
423 }
424 case 1:
425 {
427 break;
428 }
429 case 2:
430 {
432 break;
433 }
434 default:
435 {
436 printf("unknown Cone up axis\n");
437 }
438
439 };
440
441
442
443 break;
444 }
446 {
449
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 }
461 break;
462 }
464 {
465 // int sz = sizeof(btConvexHullShapeData);
466 // int sz2 = sizeof(btConvexInternalShapeData);
467 // int sz3 = sizeof(btCollisionShapeData);
470
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();
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 {
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 {
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 {
552 bvh->deSerializeDouble(*trimesh->m_quantizedDoubleBvh);
553 }
554 }
555#endif
556
557
559 trimeshShape->setMargin(trimesh->m_collisionMargin);
561
562 if (trimesh->m_triangleInfoMap)
563 {
565 map->deSerialize(*trimesh->m_triangleInfoMap);
566 trimeshShape->setTriangleInfoMap(map);
567
568#ifdef USE_INTERNAL_EDGE_UTILITY
570#endif //USE_INTERNAL_EDGE_UTILITY
571
572 }
573
574 //printf("trimesh->m_collisionMargin=%f\n",trimesh->m_collisionMargin);
575 break;
576 }
578 {
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
593 if (childShape)
594 {
596 localTransform.deSerializeFloat(compoundData->m_childShapePtr[i].m_transform);
598 } else
599 {
600#ifdef _DEBUG
601 printf("error: couldn't create childShape for compoundShape\n");
602#endif
603 }
604
605 }
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];
635 newName[l] = 0;
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 {
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);
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);
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);
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);
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);
730 btVector3FloatData* vertices = (btVector3FloatData*) btAlignedAlloc(sizeof(btVector3FloatData)*meshPart.m_numVertices,16);
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;
807
808 if(curPart->m_indices32)
809 {
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 {
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 {
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
854{
855
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/*
865btRigidBody* 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{
894 if (bodyPtr && *bodyPtr)
895 {
896 return *bodyPtr;
897 }
898 return 0;
899}
900
902{
904 colObj->setWorldTransform(startTransform);
905 colObj->setCollisionShape(shape);
906 m_collisionWorld->addCollisionObject(colObj);//todo: flags etc
907
908 if (bodyName)
909 {
913 }
915
916 return colObj;
917}
918
919
920
922{
925 return shape;
926}
928{
931 return shape;
932}
934{
937 return shape;
938}
939
940
942{
945 return shape;
946}
947
949{
952 return shape;
953}
954
956{
959 return shape;
960}
961
963{
966 return shape;
967}
968
970{
973 return shape;
974}
975
977{
980 return shape;
981}
982
984{
987 return shape;
988}
989
991{
994 return shape;
995}
996
998{
1001 return shape;
1002}
1003
1005{
1008 return in;
1009}
1010
1012{
1015 return bvh;
1016}
1017
1018
1020{
1023 return tim;
1024}
1025
1027{
1028 if (bvh)
1029 {
1031 bvhTriMesh->setOptimizedBvh(bvh);
1033 return bvhTriMesh;
1034 }
1035
1038 return ts;
1039
1040}
1042{
1043 return 0;
1044}
1045#ifdef SUPPORT_GIMPACT_SHAPE_IMPORT
1046btGImpactMeshShape* btCollisionWorldImporter::createGimpactShape(btStridingMeshInterface* trimesh)
1047{
1050 return shape;
1051
1052}
1053#endif //SUPPORT_GIMPACT_SHAPE_IMPORT
1054
1056{
1059 return shape;
1060}
1061
1063{
1066 return shape;
1067}
1068
1069
1071{
1074 return shape;
1075}
1076
1078{
1081 return shape;
1082}
1083
1084
1085
1086 // query for data
1088{
1090}
1091
1093{
1094 return m_allocatedCollisionShapes[index];
1095}
1096
1098{
1100 if (shapePtr&& *shapePtr)
1101 {
1102 return *shapePtr;
1103 }
1104 return 0;
1105}
1106
1107
1109{
1110 const char*const * namePtr = m_objectNameMap.find(ptr);
1111 if (namePtr && *namePtr)
1112 return *namePtr;
1113 return 0;
1114}
1115
1116
1118{
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
#define btAlignedFree(ptr)
#define btAlignedAlloc(size, alignment)
@ COMPOUND_SHAPE_PROXYTYPE
@ GIMPACT_SHAPE_PROXYTYPE
Used for GIMPACT Trimesh integration.
@ SOFTBODY_SHAPE_PROXYTYPE
@ SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE
@ TRIANGLE_MESH_SHAPE_PROXYTYPE
@ STATIC_PLANE_PROXYTYPE
@ SPHERE_SHAPE_PROXYTYPE
@ BOX_SHAPE_PROXYTYPE
@ MULTI_SPHERE_SHAPE_PROXYTYPE
@ CYLINDER_SHAPE_PROXYTYPE
@ CONE_SHAPE_PROXYTYPE
@ CAPSULE_SHAPE_PROXYTYPE
@ CONVEX_HULL_SHAPE_PROXYTYPE
@ PHY_FLOAT
@ PHY_UCHAR
@ PHY_DOUBLE
@ PHY_SHORT
@ PHY_INTEGER
@ CONST_GIMPACT_TRIMESH_SHAPE
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.
ContactAddedCallback gContactAddedCallback
This is to allow MaterialCombiner/Custom Friction/Restitution values.
bool(* ContactAddedCallback)(btManifoldPoint &cp, const btCollisionObjectWrapper *colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper *colObj1Wrap, int partId1, int index1)
const T & btMax(const T &a, const T &b)
Definition btMinMax.h:29
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition btScalar.h:292
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
int size() const
return the number of elements in the array
void resize(int newsize, const T &fillData=T())
void clear()
clear the array, deallocated memory. Generally it is better to use array.resize(0),...
void push_back(const T &_Val)
The btBoxShape is a box primitive around the origin, its sides axis aligned with length specified by ...
Definition btBoxShape.h:27
The btBvhTriangleMeshShape is a static-triangle mesh shape, it can only be used for fixed/non-moving ...
btCapsuleShapeX represents a capsule around the Z axis the total height is height+2*radius,...
btCapsuleShapeZ represents a capsule around the Z axis the total height is height+2*radius,...
The btCapsuleShape represents a capsule around the Y axis, there is also the btCapsuleShapeX aligned ...
void deSerializeFloat(struct btCapsuleShapeData *dataBuffer)
btCollisionObject can be used to manage collision detection objects.
void setRestitution(btScalar rest)
void setCollisionFlags(int flags)
void setFriction(btScalar frict)
int getCollisionFlags() const
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
btAlignedObjectArray< btOptimizedBvh * > m_allocatedBvhs
btHashMap< btHashPtr, btCollisionShape * > m_shapeMap
virtual void deleteAllData()
delete all memory collision shapes, rigid bodies, constraints etc.
virtual btStridingMeshInterfaceData * createStridingMeshInterfaceData(btStridingMeshInterfaceData *interfaceData)
virtual btOptimizedBvh * createOptimizedBvh()
acceleration and connectivity structures
btAlignedObjectArray< btTriangleIndexVertexArray * > m_allocatedTriangleIndexArrays
virtual btCollisionShape * createCylinderShapeX(btScalar radius, btScalar height)
btHashMap< btHashPtr, btCollisionObject * > m_bodyMap
bool convertAllObjects(btBulletSerializedArrays *arrays)
btCollisionShape * getCollisionShapeByName(const char *name)
virtual btCollisionShape * createPlaneShape(const btVector3 &planeNormal, btScalar planeConstant)
shapes
char * duplicateName(const char *name)
virtual class btTriangleIndexVertexArray * createTriangleMeshContainer()
btCollisionShape * convertCollisionShape(btCollisionShapeData *shapeData)
virtual btCollisionShape * createConeShapeZ(btScalar radius, btScalar height)
btTriangleInfoMap * getTriangleInfoMapByIndex(int index) const
btAlignedObjectArray< btCollisionObject * > m_allocatedRigidBodies
btHashMap< btHashPtr, const char * > m_objectNameMap
virtual class btCompoundShape * createCompoundShape()
virtual class btMultiSphereShape * createMultiSphereShape(const btVector3 *positions, const btScalar *radi, int numSpheres)
virtual btCollisionShape * createConeShapeY(btScalar radius, btScalar height)
virtual btCollisionShape * createSphereShape(btScalar radius)
btCollisionShape * getCollisionShapeByIndex(int index)
btHashMap< btHashString, btCollisionObject * > m_nameColObjMap
virtual btCollisionShape * createBoxShape(const btVector3 &halfExtents)
btAlignedObjectArray< btVector3DoubleData * > m_doubleVertexArrays
virtual btCollisionShape * createCylinderShapeZ(btScalar radius, btScalar height)
virtual class btConvexHullShape * createConvexHullShape()
btAlignedObjectArray< int * > m_indexArrays
const char * getNameForPointer(const void *ptr) const
virtual btTriangleInfoMap * createTriangleInfoMap()
virtual btCollisionShape * createConeShapeX(btScalar radius, btScalar height)
btCollisionObject * getCollisionObjectByName(const char *name)
btAlignedObjectArray< char * > m_allocatedNames
btHashMap< btHashPtr, btOptimizedBvh * > m_bvhMap
virtual btBvhTriangleMeshShape * createBvhTriangleMeshShape(btStridingMeshInterface *trimesh, btOptimizedBvh *bvh)
btAlignedObjectArray< short int * > m_shortIndexArrays
btAlignedObjectArray< btStridingMeshInterfaceData * > m_allocatedbtStridingMeshInterfaceDatas
btOptimizedBvh * getBvhByIndex(int index) const
btCollisionObject * getRigidBodyByIndex(int index) const
btAlignedObjectArray< btCollisionObject * > m_allocatedCollisionObjects
virtual btCollisionShape * createConvexTriangleMeshShape(btStridingMeshInterface *trimesh)
virtual class btScaledBvhTriangleMeshShape * createScaledTrangleMeshShape(btBvhTriangleMeshShape *meshShape, const btVector3 &localScalingbtBvhTriangleMeshShape)
virtual btCollisionShape * createCylinderShapeY(btScalar radius, btScalar height)
virtual btCollisionShape * createCapsuleShapeY(btScalar radius, btScalar height)
virtual btCollisionShape * createCapsuleShapeZ(btScalar radius, btScalar height)
btAlignedObjectArray< btVector3FloatData * > m_floatVertexArrays
btAlignedObjectArray< btTriangleInfoMap * > m_allocatedTriangleInfoMaps
virtual btCollisionObject * createCollisionObject(const btTransform &startTransform, btCollisionShape *shape, const char *bodyName)
those virtuals are called by load and can be overridden by the user
virtual btTriangleIndexVertexArray * createMeshInterface(btStridingMeshInterfaceData &meshData)
btHashMap< btHashString, btCollisionShape * > m_nameShapeMap
btCollisionWorldImporter(btCollisionWorld *world)
btAlignedObjectArray< unsigned char * > m_charIndexArrays
btAlignedObjectArray< btCollisionShape * > m_allocatedCollisionShapes
virtual btCollisionShape * createCapsuleShapeX(btScalar radius, btScalar height)
CollisionWorld is interface and container for the collision detection.
virtual void removeCollisionObject(btCollisionObject *collisionObject)
virtual void addCollisionObject(btCollisionObject *collisionObject, int collisionFilterGroup=btBroadphaseProxy::DefaultFilter, int collisionFilterMask=btBroadphaseProxy::AllFilter)
The btCompoundShape allows to store multiple other btCollisionShapes This allows for moving concave c...
btConeShape implements a Cone shape, around the X axis
btConeShapeZ implements a Cone shape, around the Z axis
The btConeShape implements a cone shape primitive, centered around the origin and aligned with the Y ...
Definition btConeShape.h:25
The btConvexHullShape implements an implicit convex hull of an array of vertices.
The btCylinderShape class implements a cylinder shape primitive, centered around the origin....
This class manages a mesh supplied by the btStridingMeshInterface interface.
void insert(const Key &key, const Value &value)
Definition btHashMap.h:274
void clear()
Definition btHashMap.h:472
const Value * find(const Key &key) const
Definition btHashMap.h:434
ManifoldContactPoint collects and maintains persistent contactpoints.
The btMultiSphereShape represents the convex hull of a collection of spheres.
The btOptimizedBvh extends the btQuantizedBvh to create AABB tree for triangle meshes,...
The btScaledBvhTriangleMeshShape allows to instance a scaled version of an existing btBvhTriangleMesh...
The btSphereShape implements an implicit sphere, centered around a local origin with radius.
The btStaticPlaneShape simulates an infinite non-moving (static) collision plane.
The btStridingMeshInterface is the interface class for high performance generic access to triangle me...
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition btTransform.h:34
void deSerializeFloat(const struct btTransformFloatData &dataIn)
btVector3 m_origin
Storage for the translation.
Definition btTransform.h:39
The btTriangleIndexVertexArray allows to access multiple triangle meshes, by indexing into existing t...
btVector3 can be used to represent 3D points and vectors.
Definition btVector3.h:84
void deSerializeFloat(const struct btVector3FloatData &dataIn)
Definition btVector3.h:1330
btScalar m_floats[4]
Definition btVector3.h:112
btAlignedObjectArray< struct btQuantizedBvhDoubleData * > m_bvhsDouble
btAlignedObjectArray< struct btCollisionObjectFloatData * > m_collisionObjectDataFloat
btAlignedObjectArray< struct btCollisionObjectDoubleData * > m_collisionObjectDataDouble
btAlignedObjectArray< struct btCollisionShapeData * > m_colShapeData
btAlignedObjectArray< struct btQuantizedBvhFloatData * > m_bvhsFloat
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
The btIndexedMesh indexes a single vertex and index array.
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
btVector3FloatData * m_vertices3f
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
The btTriangleInfoMap stores edge angle information for some triangles. You can compute this informat...
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64