Panda3D
|
00001 // Filename: bulletMultiSphereShape.cxx 00002 // Created by: enn0x (05Jan12) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "bulletMultiSphereShape.h" 00016 00017 #include "geomVertexReader.h" 00018 00019 TypeHandle BulletMultiSphereShape::_type_handle; 00020 00021 //////////////////////////////////////////////////////////////////// 00022 // Function: BulletMultiSphereShape::Constructor 00023 // Access: Published 00024 // Description: 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 // Convert points 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 // Convert radii 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 // Create shape 00044 _shape = new btMultiSphereShape(bt_points, bt_radii, num_spheres); 00045 _shape->setUserPointer(this); 00046 } 00047 00048 //////////////////////////////////////////////////////////////////// 00049 // Function: BulletMultiSphereShape::ptr 00050 // Access: Public 00051 // Description: 00052 //////////////////////////////////////////////////////////////////// 00053 btCollisionShape *BulletMultiSphereShape:: 00054 ptr() const { 00055 00056 return _shape; 00057 } 00058