Panda3D
bulletMultiSphereShape.cxx
1 // Filename: bulletMultiSphereShape.cxx
2 // Created by: enn0x (05Jan12)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "bulletMultiSphereShape.h"
16 
17 #include "geomVertexReader.h"
18 
19 TypeHandle BulletMultiSphereShape::_type_handle;
20 
21 ////////////////////////////////////////////////////////////////////
22 // Function: BulletMultiSphereShape::Constructor
23 // Access: Published
24 // Description:
25 ////////////////////////////////////////////////////////////////////
26 BulletMultiSphereShape::
27 BulletMultiSphereShape(const PTA_LVecBase3 &points, const PTA_stdfloat &radii) {
28 
29  int num_spheres = min(points.size(), radii.size());
30 
31  // Convert points
32  btVector3 *bt_points = new btVector3[num_spheres];
33  for (int i=0; i<num_spheres; i++) {
34  bt_points[i] = LVecBase3_to_btVector3(points[i]);
35  }
36 
37  // Convert radii
38  btScalar *bt_radii = new btScalar[num_spheres];
39  for (int j=0; j<num_spheres; j++) {
40  bt_radii[j] = (PN_stdfloat)radii[j];
41  }
42 
43  // Create shape
44  _shape = new btMultiSphereShape(bt_points, bt_radii, num_spheres);
45  _shape->setUserPointer(this);
46 }
47 
48 ////////////////////////////////////////////////////////////////////
49 // Function: BulletMultiSphereShape::ptr
50 // Access: Public
51 // Description:
52 ////////////////////////////////////////////////////////////////////
53 btCollisionShape *BulletMultiSphereShape::
54 ptr() const {
55 
56  return _shape;
57 }
58 
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85