Panda3D
 All Classes Functions Variables Enumerations
bulletCylinderShape.cxx
1 // Filename: bulletCylinderShape.cxx
2 // Created by: enn0x (17Feb10)
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 "bulletCylinderShape.h"
16 
17 TypeHandle BulletCylinderShape::_type_handle;
18 
19 ////////////////////////////////////////////////////////////////////
20 // Function: BulletCylinderShape::Constructor
21 // Access: Published
22 // Description:
23 ////////////////////////////////////////////////////////////////////
24 BulletCylinderShape::
25 BulletCylinderShape(const LVector3 &half_extents, BulletUpAxis up) {
26 
27  btVector3 btHalfExtents = LVecBase3_to_btVector3(half_extents);
28 
29  switch (up) {
30  case X_up:
31  _shape = new btCylinderShapeX(btHalfExtents);
32  break;
33  case Y_up:
34  _shape = new btCylinderShape(btHalfExtents);
35  break;
36  case Z_up:
37  _shape = new btCylinderShapeZ(btHalfExtents);
38  break;
39  default:
40  bullet_cat.error() << "invalid up-axis:" << up << endl;
41  break;
42  }
43 
44  _shape->setUserPointer(this);
45 }
46 
47 ////////////////////////////////////////////////////////////////////
48 // Function: BulletCylinderShape::Constructor
49 // Access: Published
50 // Description:
51 ////////////////////////////////////////////////////////////////////
52 BulletCylinderShape::
53 BulletCylinderShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) {
54 
55  switch (up) {
56  case X_up:
57  _shape = new btCylinderShapeX(btVector3(0.5 * height, radius, radius));
58  break;
59  case Y_up:
60  _shape = new btCylinderShape(btVector3(radius, 0.5 * height, radius));
61  break;
62  case Z_up:
63  _shape = new btCylinderShapeZ(btVector3(radius, radius, 0.5 * height));
64  break;
65  default:
66  bullet_cat.error() << "invalid up-axis:" << up << endl;
67  break;
68  }
69 
70  _shape->setUserPointer(this);
71 }
72 
73 ////////////////////////////////////////////////////////////////////
74 // Function: BulletCylinderShape::ptr
75 // Access: Public
76 // Description:
77 ////////////////////////////////////////////////////////////////////
78 btCollisionShape *BulletCylinderShape::
79 ptr() const {
80 
81  return _shape;
82 }
83 
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85