Bullet Collision Detection & Physics Library
btGImpactShape.h
Go to the documentation of this file.
1 
4 /*
5 This source file is part of GIMPACT Library.
6 
7 For the latest info, see http://gimpact.sourceforge.net/
8 
9 Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
10 email: projectileman@yahoo.com
11 
12 
13 This software is provided 'as-is', without any express or implied warranty.
14 In no event will the authors be held liable for any damages arising from the use of this software.
15 Permission is granted to anyone to use this software for any purpose,
16 including commercial applications, and to alter it and redistribute it freely,
17 subject to the following restrictions:
18 
19 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.
20 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
21 3. This notice may not be removed or altered from any source distribution.
22 */
23 
24 
25 #ifndef GIMPACT_SHAPE_H
26 #define GIMPACT_SHAPE_H
27 
35 #include "LinearMath/btVector3.h"
36 #include "LinearMath/btTransform.h"
37 #include "LinearMath/btMatrix3x3.h"
39 
40 #include "btGImpactQuantizedBvh.h" // box tree class
41 
42 
45 
47 {
51 };
52 
53 
54 
57 {
58 public:
60  {
61  m_numVertices = 4;
62  }
63 
64 
66  const btVector3 & v0,const btVector3 & v1,
67  const btVector3 & v2,const btVector3 & v3)
68  {
69  m_vertices[0] = v0;
70  m_vertices[1] = v1;
71  m_vertices[2] = v2;
72  m_vertices[3] = v3;
74  }
75 };
76 
77 
80 {
81 protected:
85  btGImpactBoxSet m_box_set;// optionally boxset
86 
89  virtual void calcLocalAABB()
90  {
91  lockChildShapes();
92  if(m_box_set.getNodeCount() == 0)
93  {
94  m_box_set.buildSet();
95  }
96  else
97  {
98  m_box_set.update();
99  }
100  unlockChildShapes();
101 
102  m_localAABB = m_box_set.getGlobalBox();
103  }
104 
105 
106 public:
108  {
110  m_localAABB.invalidate();
111  m_needs_update = true;
112  localScaling.setValue(1.f,1.f,1.f);
113  }
114 
115 
117 
124  {
125  if(!m_needs_update) return;
126  calcLocalAABB();
127  m_needs_update = false;
128  }
129 
131 
134  void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
135  {
136  btAABB transformedbox = m_localAABB;
137  transformedbox.appy_transform(t);
138  aabbMin = transformedbox.m_min;
139  aabbMax = transformedbox.m_max;
140  }
141 
143  virtual void postUpdate()
144  {
145  m_needs_update = true;
146  }
147 
150  {
151  return m_localAABB;
152  }
153 
154 
155  virtual int getShapeType() const
156  {
158  }
159 
163  virtual void setLocalScaling(const btVector3& scaling)
164  {
165  localScaling = scaling;
166  postUpdate();
167  }
168 
169  virtual const btVector3& getLocalScaling() const
170  {
171  return localScaling;
172  }
173 
174 
175  virtual void setMargin(btScalar margin)
176  {
177  m_collisionMargin = margin;
178  int i = getNumChildShapes();
179  while(i--)
180  {
181  btCollisionShape* child = getChildShape(i);
182  child->setMargin(margin);
183  }
184 
185  m_needs_update = true;
186  }
187 
188 
191 
193  virtual eGIMPACT_SHAPE_TYPE getGImpactShapeType() const = 0 ;
194 
197  {
198  return &m_box_set;
199  }
200 
203  {
204  if(m_box_set.getNodeCount() == 0) return false;
205  return true;
206  }
207 
209  virtual const btPrimitiveManagerBase * getPrimitiveManager() const = 0;
210 
211 
213  virtual int getNumChildShapes() const = 0;
214 
216  virtual bool childrenHasTransform() const = 0;
217 
219  virtual bool needsRetrieveTriangles() const = 0;
220 
222  virtual bool needsRetrieveTetrahedrons() const = 0;
223 
224  virtual void getBulletTriangle(int prim_index,btTriangleShapeEx & triangle) const = 0;
225 
226  virtual void getBulletTetrahedron(int prim_index,btTetrahedronShapeEx & tetrahedron) const = 0;
227 
228 
229 
231  virtual void lockChildShapes() const
232  {
233  }
234 
235  virtual void unlockChildShapes() const
236  {
237  }
238 
241  {
242  getPrimitiveManager()->get_primitive_triangle(index,triangle);
243  }
244 
245 
247 
249  virtual void getChildAabb(int child_index,const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
250  {
251  btAABB child_aabb;
252  getPrimitiveManager()->get_primitive_box(child_index,child_aabb);
253  child_aabb.appy_transform(t);
254  aabbMin = child_aabb.m_min;
255  aabbMax = child_aabb.m_max;
256  }
257 
259  virtual btCollisionShape* getChildShape(int index) = 0;
260 
261 
263  virtual const btCollisionShape* getChildShape(int index) const = 0;
264 
266  virtual btTransform getChildTransform(int index) const = 0;
267 
269 
272  virtual void setChildTransform(int index, const btTransform & transform) = 0;
273 
275 
276 
278  virtual void rayTest(const btVector3& rayFrom, const btVector3& rayTo, btCollisionWorld::RayResultCallback& resultCallback) const
279  {
280  (void) rayFrom; (void) rayTo; (void) resultCallback;
281  }
282 
284 
287  virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
288  {
289  (void) callback; (void) aabbMin; (void) aabbMax;
290  }
291 
293 
296  virtual void processAllTrianglesRay(btTriangleCallback* /*callback*/,const btVector3& /*rayFrom*/, const btVector3& /*rayTo*/) const
297  {
298 
299  }
300 
302 
303 };
304 
305 
307 
311 {
312 public:
315  {
316  public:
319 
320 
323  {
324  m_compoundShape = compound.m_compoundShape;
325  }
326 
328  {
329  m_compoundShape = compoundShape;
330  }
331 
333  {
334  m_compoundShape = NULL;
335  }
336 
337  virtual bool is_trimesh() const
338  {
339  return false;
340  }
341 
342  virtual int get_primitive_count() const
343  {
344  return (int )m_compoundShape->getNumChildShapes();
345  }
346 
347  virtual void get_primitive_box(int prim_index ,btAABB & primbox) const
348  {
349  btTransform prim_trans;
350  if(m_compoundShape->childrenHasTransform())
351  {
352  prim_trans = m_compoundShape->getChildTransform(prim_index);
353  }
354  else
355  {
356  prim_trans.setIdentity();
357  }
358  const btCollisionShape* shape = m_compoundShape->getChildShape(prim_index);
359  shape->getAabb(prim_trans,primbox.m_min,primbox.m_max);
360  }
361 
362  virtual void get_primitive_triangle(int prim_index,btPrimitiveTriangle & triangle) const
363  {
364  btAssert(0);
365  (void) prim_index; (void) triangle;
366  }
367 
368  };
369 
370 
371 
372 protected:
376 
377 
378 public:
379 
380  btGImpactCompoundShape(bool children_has_transform = true)
381  {
382  (void) children_has_transform;
383  m_primitive_manager.m_compoundShape = this;
384  m_box_set.setPrimitiveManager(&m_primitive_manager);
385  }
386 
388  {
389  }
390 
391 
393  virtual bool childrenHasTransform() const
394  {
395  if(m_childTransforms.size()==0) return false;
396  return true;
397  }
398 
399 
402  {
403  return &m_primitive_manager;
404  }
405 
408  {
409  return &m_primitive_manager;
410  }
411 
413  virtual int getNumChildShapes() const
414  {
415  return m_childShapes.size();
416  }
417 
418 
420  void addChildShape(const btTransform& localTransform,btCollisionShape* shape)
421  {
422  btAssert(shape->isConvex());
423  m_childTransforms.push_back(localTransform);
424  m_childShapes.push_back(shape);
425  }
426 
429  {
430  btAssert(shape->isConvex());
431  m_childShapes.push_back(shape);
432  }
433 
435  virtual btCollisionShape* getChildShape(int index)
436  {
437  return m_childShapes[index];
438  }
439 
441  virtual const btCollisionShape* getChildShape(int index) const
442  {
443  return m_childShapes[index];
444  }
445 
447 
449  virtual void getChildAabb(int child_index,const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
450  {
451 
452  if(childrenHasTransform())
453  {
454  m_childShapes[child_index]->getAabb(t*m_childTransforms[child_index],aabbMin,aabbMax);
455  }
456  else
457  {
458  m_childShapes[child_index]->getAabb(t,aabbMin,aabbMax);
459  }
460  }
461 
462 
464  virtual btTransform getChildTransform(int index) const
465  {
466  btAssert(m_childTransforms.size() == m_childShapes.size());
467  return m_childTransforms[index];
468  }
469 
471 
474  virtual void setChildTransform(int index, const btTransform & transform)
475  {
476  btAssert(m_childTransforms.size() == m_childShapes.size());
477  m_childTransforms[index] = transform;
478  postUpdate();
479  }
480 
482  virtual bool needsRetrieveTriangles() const
483  {
484  return false;
485  }
486 
488  virtual bool needsRetrieveTetrahedrons() const
489  {
490  return false;
491  }
492 
493 
494  virtual void getBulletTriangle(int prim_index,btTriangleShapeEx & triangle) const
495  {
496  (void) prim_index; (void) triangle;
497  btAssert(0);
498  }
499 
500  virtual void getBulletTetrahedron(int prim_index,btTetrahedronShapeEx & tetrahedron) const
501  {
502  (void) prim_index; (void) tetrahedron;
503  btAssert(0);
504  }
505 
506 
508  virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const;
509 
510  virtual const char* getName()const
511  {
512  return "GImpactCompound";
513  }
514 
516  {
518  }
519 
520 };
521 
522 
523 
525 
532 {
533 public:
535 
539  {
540  public:
544  int m_part;
546  const unsigned char *vertexbase;
547  int numverts;
549  int stride;
550  const unsigned char *indexbase;
552  int numfaces;
554 
556  {
557  m_meshInterface = NULL;
558  m_part = 0;
559  m_margin = 0.01f;
560  m_scale = btVector3(1.f,1.f,1.f);
561  m_lock_count = 0;
562  vertexbase = 0;
563  numverts = 0;
564  stride = 0;
565  indexbase = 0;
566  indexstride = 0;
567  numfaces = 0;
568  }
569 
572  {
573  m_meshInterface = manager.m_meshInterface;
574  m_part = manager.m_part;
575  m_margin = manager.m_margin;
576  m_scale = manager.m_scale;
577  m_lock_count = 0;
578  vertexbase = 0;
579  numverts = 0;
580  stride = 0;
581  indexbase = 0;
582  indexstride = 0;
583  numfaces = 0;
584 
585  }
586 
588  btStridingMeshInterface * meshInterface, int part)
589  {
590  m_meshInterface = meshInterface;
591  m_part = part;
592  m_scale = m_meshInterface->getScaling();
593  m_margin = 0.1f;
594  m_lock_count = 0;
595  vertexbase = 0;
596  numverts = 0;
597  stride = 0;
598  indexbase = 0;
599  indexstride = 0;
600  numfaces = 0;
601 
602  }
603 
605 
606  void lock()
607  {
608  if(m_lock_count>0)
609  {
610  m_lock_count++;
611  return;
612  }
613  m_meshInterface->getLockedReadOnlyVertexIndexBase(
614  &vertexbase,numverts,
615  type, stride,&indexbase, indexstride, numfaces,indicestype,m_part);
616 
617  m_lock_count = 1;
618  }
619 
620  void unlock()
621  {
622  if(m_lock_count == 0) return;
623  if(m_lock_count>1)
624  {
625  --m_lock_count;
626  return;
627  }
628  m_meshInterface->unLockReadOnlyVertexBase(m_part);
629  vertexbase = NULL;
630  m_lock_count = 0;
631  }
632 
633  virtual bool is_trimesh() const
634  {
635  return true;
636  }
637 
638  virtual int get_primitive_count() const
639  {
640  return (int )numfaces;
641  }
642 
644  {
645  return (int )numverts;
646  }
647 
648  SIMD_FORCE_INLINE void get_indices(int face_index,unsigned int &i0,unsigned int &i1,unsigned int &i2) const
649  {
650  if(indicestype == PHY_SHORT)
651  {
652  unsigned short* s_indices = (unsigned short *)(indexbase + face_index * indexstride);
653  i0 = s_indices[0];
654  i1 = s_indices[1];
655  i2 = s_indices[2];
656  }
657  else
658  {
659  unsigned int * i_indices = (unsigned int *)(indexbase + face_index*indexstride);
660  i0 = i_indices[0];
661  i1 = i_indices[1];
662  i2 = i_indices[2];
663  }
664  }
665 
666  SIMD_FORCE_INLINE void get_vertex(unsigned int vertex_index, btVector3 & vertex) const
667  {
668  if(type == PHY_DOUBLE)
669  {
670  double * dvertices = (double *)(vertexbase + vertex_index*stride);
671  vertex[0] = btScalar(dvertices[0]*m_scale[0]);
672  vertex[1] = btScalar(dvertices[1]*m_scale[1]);
673  vertex[2] = btScalar(dvertices[2]*m_scale[2]);
674  }
675  else
676  {
677  float * svertices = (float *)(vertexbase + vertex_index*stride);
678  vertex[0] = svertices[0]*m_scale[0];
679  vertex[1] = svertices[1]*m_scale[1];
680  vertex[2] = svertices[2]*m_scale[2];
681  }
682  }
683 
684  virtual void get_primitive_box(int prim_index ,btAABB & primbox) const
685  {
686  btPrimitiveTriangle triangle;
687  get_primitive_triangle(prim_index,triangle);
689  triangle.m_vertices[0],
690  triangle.m_vertices[1],triangle.m_vertices[2],triangle.m_margin);
691  }
692 
693  virtual void get_primitive_triangle(int prim_index,btPrimitiveTriangle & triangle) const
694  {
695  unsigned int indices[3];
696  get_indices(prim_index,indices[0],indices[1],indices[2]);
697  get_vertex(indices[0],triangle.m_vertices[0]);
698  get_vertex(indices[1],triangle.m_vertices[1]);
699  get_vertex(indices[2],triangle.m_vertices[2]);
700  triangle.m_margin = m_margin;
701  }
702 
703  SIMD_FORCE_INLINE void get_bullet_triangle(int prim_index,btTriangleShapeEx & triangle) const
704  {
705  unsigned int indices[3];
706  get_indices(prim_index,indices[0],indices[1],indices[2]);
707  get_vertex(indices[0],triangle.m_vertices1[0]);
708  get_vertex(indices[1],triangle.m_vertices1[1]);
709  get_vertex(indices[2],triangle.m_vertices1[2]);
710  triangle.setMargin(m_margin);
711  }
712 
713  };
714 
715 
716 protected:
718 public:
719 
721  {
722  m_box_set.setPrimitiveManager(&m_primitive_manager);
723  }
724 
725  btGImpactMeshShapePart( btStridingMeshInterface * meshInterface, int part );
726  virtual ~btGImpactMeshShapePart();
727 
729  virtual bool childrenHasTransform() const
730  {
731  return false;
732  }
733 
734 
736  virtual void lockChildShapes() const;
737  virtual void unlockChildShapes() const;
738 
740  virtual int getNumChildShapes() const
741  {
742  return m_primitive_manager.get_primitive_count();
743  }
744 
745 
747  virtual btCollisionShape* getChildShape(int index)
748  {
749  (void) index;
750  btAssert(0);
751  return NULL;
752  }
753 
754 
755 
757  virtual const btCollisionShape* getChildShape(int index) const
758  {
759  (void) index;
760  btAssert(0);
761  return NULL;
762  }
763 
765  virtual btTransform getChildTransform(int index) const
766  {
767  (void) index;
768  btAssert(0);
769  return btTransform();
770  }
771 
773 
776  virtual void setChildTransform(int index, const btTransform & transform)
777  {
778  (void) index;
779  (void) transform;
780  btAssert(0);
781  }
782 
783 
786  {
787  return &m_primitive_manager;
788  }
789 
791  {
792  return &m_primitive_manager;
793  }
794 
795 
796 
797 
798 
799  virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const;
800 
801 
802 
803 
804  virtual const char* getName()const
805  {
806  return "GImpactMeshShapePart";
807  }
808 
810  {
812  }
813 
815  virtual bool needsRetrieveTriangles() const
816  {
817  return true;
818  }
819 
821  virtual bool needsRetrieveTetrahedrons() const
822  {
823  return false;
824  }
825 
826  virtual void getBulletTriangle(int prim_index,btTriangleShapeEx & triangle) const
827  {
828  m_primitive_manager.get_bullet_triangle(prim_index,triangle);
829  }
830 
831  virtual void getBulletTetrahedron(int prim_index,btTetrahedronShapeEx & tetrahedron) const
832  {
833  (void) prim_index;
834  (void) tetrahedron;
835  btAssert(0);
836  }
837 
838 
839 
841  {
842  return m_primitive_manager.get_vertex_count();
843  }
844 
845  SIMD_FORCE_INLINE void getVertex(int vertex_index, btVector3 & vertex) const
846  {
847  m_primitive_manager.get_vertex(vertex_index,vertex);
848  }
849 
851  {
852  m_primitive_manager.m_margin = margin;
853  postUpdate();
854  }
855 
857  {
858  return m_primitive_manager.m_margin;
859  }
860 
861  virtual void setLocalScaling(const btVector3& scaling)
862  {
863  m_primitive_manager.m_scale = scaling;
864  postUpdate();
865  }
866 
867  virtual const btVector3& getLocalScaling() const
868  {
869  return m_primitive_manager.m_scale;
870  }
871 
873  {
874  return (int)m_primitive_manager.m_part;
875  }
876 
877  virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
878  virtual void processAllTrianglesRay(btTriangleCallback* callback,const btVector3& rayFrom,const btVector3& rayTo) const;
879 };
880 
881 
883 
891 {
893 
894 protected:
897  {
898  for (int i=0;i<meshInterface->getNumSubParts() ;++i )
899  {
900  btGImpactMeshShapePart * newpart = new btGImpactMeshShapePart(meshInterface,i);
901  m_mesh_parts.push_back(newpart);
902  }
903  }
904 
906  virtual void calcLocalAABB()
907  {
908  m_localAABB.invalidate();
909  int i = m_mesh_parts.size();
910  while(i--)
911  {
912  m_mesh_parts[i]->updateBound();
913  m_localAABB.merge(m_mesh_parts[i]->getLocalBox());
914  }
915  }
916 
917 public:
919  {
920  m_meshInterface = meshInterface;
921  buildMeshParts(meshInterface);
922  }
923 
925  {
926  int i = m_mesh_parts.size();
927  while(i--)
928  {
929  btGImpactMeshShapePart * part = m_mesh_parts[i];
930  delete part;
931  }
932  m_mesh_parts.clear();
933  }
934 
935 
937  {
938  return m_meshInterface;
939  }
940 
942  {
943  return m_meshInterface;
944  }
945 
946  int getMeshPartCount() const
947  {
948  return m_mesh_parts.size();
949  }
950 
952  {
953  return m_mesh_parts[index];
954  }
955 
956 
957 
958  const btGImpactMeshShapePart * getMeshPart(int index) const
959  {
960  return m_mesh_parts[index];
961  }
962 
963 
964  virtual void setLocalScaling(const btVector3& scaling)
965  {
966  localScaling = scaling;
967 
968  int i = m_mesh_parts.size();
969  while(i--)
970  {
971  btGImpactMeshShapePart * part = m_mesh_parts[i];
972  part->setLocalScaling(scaling);
973  }
974 
975  m_needs_update = true;
976  }
977 
978  virtual void setMargin(btScalar margin)
979  {
980  m_collisionMargin = margin;
981 
982  int i = m_mesh_parts.size();
983  while(i--)
984  {
985  btGImpactMeshShapePart * part = m_mesh_parts[i];
986  part->setMargin(margin);
987  }
988 
989  m_needs_update = true;
990  }
991 
993  virtual void postUpdate()
994  {
995  int i = m_mesh_parts.size();
996  while(i--)
997  {
998  btGImpactMeshShapePart * part = m_mesh_parts[i];
999  part->postUpdate();
1000  }
1001 
1002  m_needs_update = true;
1003  }
1004 
1005  virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const;
1006 
1007 
1010  {
1011  btAssert(0);
1012  return NULL;
1013  }
1014 
1015 
1017  virtual int getNumChildShapes() const
1018  {
1019  btAssert(0);
1020  return 0;
1021  }
1022 
1023 
1025  virtual bool childrenHasTransform() const
1026  {
1027  btAssert(0);
1028  return false;
1029  }
1030 
1032  virtual bool needsRetrieveTriangles() const
1033  {
1034  btAssert(0);
1035  return false;
1036  }
1037 
1039  virtual bool needsRetrieveTetrahedrons() const
1040  {
1041  btAssert(0);
1042  return false;
1043  }
1044 
1045  virtual void getBulletTriangle(int prim_index,btTriangleShapeEx & triangle) const
1046  {
1047  (void) prim_index; (void) triangle;
1048  btAssert(0);
1049  }
1050 
1051  virtual void getBulletTetrahedron(int prim_index,btTetrahedronShapeEx & tetrahedron) const
1052  {
1053  (void) prim_index; (void) tetrahedron;
1054  btAssert(0);
1055  }
1056 
1058  virtual void lockChildShapes() const
1059  {
1060  btAssert(0);
1061  }
1062 
1063  virtual void unlockChildShapes() const
1064  {
1065  btAssert(0);
1066  }
1067 
1068 
1069 
1070 
1072 
1074  virtual void getChildAabb(int child_index,const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
1075  {
1076  (void) child_index; (void) t; (void) aabbMin; (void) aabbMax;
1077  btAssert(0);
1078  }
1079 
1081  virtual btCollisionShape* getChildShape(int index)
1082  {
1083  (void) index;
1084  btAssert(0);
1085  return NULL;
1086  }
1087 
1088 
1090  virtual const btCollisionShape* getChildShape(int index) const
1091  {
1092  (void) index;
1093  btAssert(0);
1094  return NULL;
1095  }
1096 
1098  virtual btTransform getChildTransform(int index) const
1099  {
1100  (void) index;
1101  btAssert(0);
1102  return btTransform();
1103  }
1104 
1106 
1109  virtual void setChildTransform(int index, const btTransform & transform)
1110  {
1111  (void) index; (void) transform;
1112  btAssert(0);
1113  }
1114 
1115 
1117  {
1119  }
1120 
1121 
1122  virtual const char* getName()const
1123  {
1124  return "GImpactMesh";
1125  }
1126 
1127  virtual void rayTest(const btVector3& rayFrom, const btVector3& rayTo, btCollisionWorld::RayResultCallback& resultCallback) const;
1128 
1130 
1133  virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
1134 
1135  virtual void processAllTrianglesRay (btTriangleCallback* callback,const btVector3& rayFrom,const btVector3& rayTo) const;
1136 
1137  virtual int calculateSerializeBufferSize() const;
1138 
1140  virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
1141 
1142 };
1143 
1146 {
1148 
1150 
1152 
1154 
1156 };
1157 
1159 {
1160  return sizeof(btGImpactMeshShapeData);
1161 }
1162 
1163 
1164 #endif //GIMPACT_MESH_SHAPE_H
const btStridingMeshInterface * getMeshInterface() const
void get_bullet_triangle(int prim_index, btTriangleShapeEx &triangle) const
virtual bool needsRetrieveTetrahedrons() const
Determines if this shape has tetrahedrons.
void push_back(const T &_Val)
virtual void getChildAabb(int child_index, const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
Retrieves the bound from a child.
virtual ~btGImpactMeshShape()
Helper class for colliding Bullet Triangle Shapes.
virtual bool childrenHasTransform() const
if true, then its children must get transforms.
virtual bool is_trimesh() const
determines if this manager consist on only triangles, which special case will be optimized ...
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
Definition: btVector3.h:652
virtual void setMargin(btScalar margin)
virtual void postUpdate()
Tells to this object that is needed to refit all the meshes.
void setVertices(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2, const btVector3 &v3)
virtual int calculateSerializeBufferSize() const
virtual btTransform getChildTransform(int index) const
Gets the children transform.
virtual void lockChildShapes() const
call when reading child shapes
virtual void setLocalScaling(const btVector3 &scaling)
virtual bool is_trimesh() const
determines if this manager consist on only triangles, which special case will be optimized ...
eGIMPACT_SHAPE_TYPE
btVector3 m_max
const btAABB & getLocalBox()
Obtains the local box, which is the global calculated box of the total of subshapes.
void get_indices(int face_index, unsigned int &i0, unsigned int &i1, unsigned int &i2) const
virtual const btPrimitiveManagerBase * getPrimitiveManager() const
Obtains the primitive manager.
void getVertex(int vertex_index, btVector3 &vertex) const
virtual bool childrenHasTransform() const
if true, then its children must get transforms.
TrimeshPrimitiveManager(btStridingMeshInterface *meshInterface, int part)
virtual void setLocalScaling(const btVector3 &scaling)
void setMargin(btScalar margin)
virtual int calculateSerializeBufferSize() const
virtual const char * serialize(void *dataBuffer, btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
CompoundPrimitiveManager(const CompoundPrimitiveManager &compound)
void setIdentity()
Set this transformation to the identity.
Definition: btTransform.h:172
void addChildShape(const btTransform &localTransform, btCollisionShape *shape)
Use this method for adding children. Only Convex shapes are allowed.
#define btAssert(x)
Definition: btScalar.h:131
virtual void calcLocalAABB()
use this function for perfofm refit in bounding boxes
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
RayResultCallback is used to report new raycast results.
const btVector3 & getScaling() const
#define SIMD_FORCE_INLINE
Definition: btScalar.h:81
CompoundPrimitiveManager m_primitive_manager
void addChildShape(btCollisionShape *shape)
Use this method for adding children. Only Convex shapes are allowed.
btVector3 m_min
void buildMeshParts(btStridingMeshInterface *meshInterface)
virtual btTransform getChildTransform(int index) const
Gets the children transform.
virtual eGIMPACT_SHAPE_TYPE getGImpactShapeType() const
Subshape member functions.
This class manages a mesh supplied by the btStridingMeshInterface interface.
Used for GIMPACT Trimesh integration.
virtual bool needsRetrieveTetrahedrons() const
Determines if this shape has tetrahedrons.
virtual const char * getName() const
virtual void getBulletTetrahedron(int prim_index, btTetrahedronShapeEx &tetrahedron) const
btGImpactBoxSet m_box_set
virtual bool childrenHasTransform() const
if true, then its children must get transforms.
Prototype Base class for primitive classification.
Definition: btGImpactBvh.h:153
void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
If the Bounding box is not updated, then this class attemps to calculate it.
virtual void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const =0
getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t...
virtual void getBulletTriangle(int prim_index, btTriangleShapeEx &triangle) const
virtual const btPrimitiveManagerBase * getPrimitiveManager() const
Obtains the primitive manager.
CompoundPrimitiveManager(btGImpactCompoundShape *compoundShape)
void clear()
clear the array, deallocated memory. Generally it is better to use array.resize(0), to reduce performance overhead of run-time memory (de)allocations.
virtual eGIMPACT_SHAPE_TYPE getGImpactShapeType() const
Subshape member functions.
btGImpactCompoundShape(bool children_has_transform=true)
virtual void processAllTrianglesRay(btTriangleCallback *, const btVector3 &, const btVector3 &) const
Function for retrieve triangles.
bool hasBoxSet() const
Determines if this class has a hierarchy structure for sorting its primitives.
btGImpactMeshShapePart * getMeshPart(int index)
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
void get_vertex(unsigned int vertex_index, btVector3 &vertex) const
btStridingMeshInterface * getMeshInterface()
TrimeshPrimitiveManager * getTrimeshPrimitiveManager()
virtual void setMargin(btScalar margin)
btAlignedObjectArray< btTransform > m_childTransforms
Base class for gimpact shapes.
This class manages a sub part of a mesh supplied by the btStridingMeshInterface interface.
const btGImpactBoxSet * getBoxSet() const
gets boxset
virtual const btPrimitiveManagerBase * getPrimitiveManager() const
Obtains the primitive manager.
int size() const
return the number of elements in the array
virtual int getNumChildShapes() const
Gets the number of children.
virtual void postUpdate()
Tells to this object that is needed to refit the box set.
The btTriangleCallback provides a callback for each overlapping triangle when calling processAllTrian...
virtual int getNumChildShapes() const
Gets the number of children.
virtual void get_primitive_triangle(int prim_index, btPrimitiveTriangle &triangle) const
retrieves only the points of the triangle, and the collision margin
The btBU_Simplex1to4 implements tetrahedron, triangle, line, vertex collision shapes. In most cases it is better to use btConvexHullShape instead.
virtual void lockChildShapes() const
call when reading child shapes
void update()
node manager prototype functions
btStridingMeshInterfaceData m_meshInterface
TrimeshPrimitiveManager m_primitive_manager
virtual btTransform getChildTransform(int index) const
Gets the children transform.
virtual const btCollisionShape * getChildShape(int index) const
Gets the child.
void calc_from_triangle_margin(const CLASS_POINT &V1, const CLASS_POINT &V2, const CLASS_POINT &V3, btScalar margin)
virtual void get_primitive_triangle(int prim_index, btPrimitiveTriangle &triangle) const
retrieves only the points of the triangle, and the collision margin
int getNodeCount() const
node count
virtual void setChildTransform(int index, const btTransform &transform)
Sets the children transform.
Axis aligned box.
virtual void unlockChildShapes() const
virtual void getBulletTetrahedron(int prim_index, btTetrahedronShapeEx &tetrahedron) const
virtual bool needsRetrieveTriangles() const
Determines if this shape has triangles.
virtual void unlockChildShapes() const
virtual void setMargin(btScalar margin)=0
Helper class for tetrahedrons.
TrimeshPrimitiveManager(const TrimeshPrimitiveManager &manager)
void appy_transform(const btTransform &trans)
Apply a transform to an AABB.
virtual bool needsRetrieveTetrahedrons() const
Determines if this shape has tetrahedrons.
btScalar getMargin() const
virtual void get_primitive_box(int prim_index, btAABB &primbox) const
CompoundPrimitiveManager * getCompoundPrimitiveManager()
Obtains the compopund primitive manager.
virtual const char * getName() const
btCollisionShapeData m_collisionShapeData
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
virtual int getNumSubParts() const =0
getNumSubParts returns the number of seperate subparts each subpart has a continuous array of vertice...
virtual void calcLocalAABB()
use this function for perfofm refit in bounding boxes
virtual bool needsRetrieveTriangles() const
Determines if this shape has triangles.
virtual btCollisionShape * getChildShape(int index)
Gets the children.
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:34
The btStridingMeshInterface is the interface class for high performance generic access to triangle me...
bool isConvex() const
virtual bool needsRetrieveTriangles() const
Determines if this shape has triangles.
virtual void setLocalScaling(const btVector3 &scaling)
virtual void getBulletTriangle(int prim_index, btTriangleShapeEx &triangle) const
The btConcaveShape class provides an interface for non-moving (static) concave shapes.
virtual btCollisionShape * getChildShape(int index)
Gets the children.
virtual void getChildAabb(int child_index, const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
Retrieves the bound from a child.
virtual const btVector3 & getLocalScaling() const
virtual void setChildTransform(int index, const btTransform &transform)
Sets the children transform.
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
void invalidate()
const btGImpactMeshShapePart * getMeshPart(int index) const
virtual void calculateLocalInertia(btScalar mass, btVector3 &inertia) const
virtual void getBulletTriangle(int prim_index, btTriangleShapeEx &triangle) const
btStridingMeshInterface * m_meshInterface
virtual void getLockedReadOnlyVertexIndexBase(const unsigned char **vertexbase, int &numverts, PHY_ScalarType &type, int &stride, const unsigned char **indexbase, int &indexstride, int &numfaces, PHY_ScalarType &indicestype, int subpart=0) const =0
virtual void processAllTriangles(btTriangleCallback *callback, const btVector3 &aabbMin, const btVector3 &aabbMax) const
Function for retrieve triangles.
virtual void rayTest(const btVector3 &rayFrom, const btVector3 &rayTo, btCollisionWorld::RayResultCallback &resultCallback) const
virtual method for ray collision
virtual const btVector3 & getLocalScaling() const
virtual btCollisionShape * getChildShape(int index)
Gets the children.
virtual void unLockReadOnlyVertexBase(int subpart) const =0
void updateBound()
performs refit operation
btVector3 m_vertices[4]
virtual eGIMPACT_SHAPE_TYPE getGImpactShapeType() const
Subshape member functions.
virtual ~btGImpactCompoundShape()
void getPrimitiveTriangle(int index, btPrimitiveTriangle &triangle) const
if this trimesh
btAlignedObjectArray< btGImpactMeshShapePart * > m_mesh_parts
virtual void getBulletTetrahedron(int prim_index, btTetrahedronShapeEx &tetrahedron) const
btVector3FloatData m_localScaling
Structure for containing Boxes.
int getMeshPartCount() const
btAlignedObjectArray< btCollisionShape * > m_childShapes
virtual void get_primitive_box(int prim_index, btAABB &primbox) const
virtual void getChildAabb(int child_index, const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
Retrieves the bound from a child.
virtual void setChildTransform(int index, const btTransform &transform)
Sets the children transform.
virtual int getNumChildShapes() const
Gets the number of children.
btVector3 m_vertices1[3]
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
virtual const btCollisionShape * getChildShape(int index) const
Gets the children.
virtual const char * getName() const
virtual int getShapeType() const
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:292
btGImpactCompoundShape allows to handle multiple btCollisionShape objects at once ...
PHY_ScalarType
PHY_ScalarType enumerates possible scalar types.
btGImpactMeshShape(btStridingMeshInterface *meshInterface)
btGImpactQuantizedBvh btGImpactBoxSet
declare Quantized trees, (you can change to float based trees)
void buildSet()
this rebuild the entire set
int getVertexCount() const
virtual const btCollisionShape * getChildShape(int index) const
Gets the child.
virtual void setMargin(btScalar margin)