00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "bulletMultiSphereShape.h"
00016
00017 #include "geomVertexReader.h"
00018
00019 TypeHandle BulletMultiSphereShape::_type_handle;
00020
00021
00022
00023
00024
00025
00026 BulletMultiSphereShape::
00027 BulletMultiSphereShape(const PTA_LVecBase3 &points, const PTA_stdfloat &radii) {
00028
00029 int num_spheres = min(points.size(), radii.size());
00030
00031
00032 btVector3 *bt_points = new btVector3[num_spheres];
00033 for (int i=0; i<num_spheres; i++) {
00034 bt_points[i] = LVecBase3_to_btVector3(points[i]);
00035 }
00036
00037
00038 btScalar *bt_radii = new btScalar[num_spheres];
00039 for (int j=0; j<num_spheres; j++) {
00040 bt_radii[j] = (PN_stdfloat)radii[j];
00041 }
00042
00043
00044 _shape = new btMultiSphereShape(bt_points, bt_radii, num_spheres);
00045 _shape->setUserPointer(this);
00046 }
00047
00048
00049
00050
00051
00052
00053 btCollisionShape *BulletMultiSphereShape::
00054 ptr() const {
00055
00056 return _shape;
00057 }
00058