Panda3D
physxCapsuleForceFieldShape.cxx
1 // Filename: physxCapsuleForceFieldShape.cxx
2 // Created by: enn0x (15Nov09)
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 "physxCapsuleForceFieldShape.h"
16 #include "physxCapsuleForceFieldShapeDesc.h"
17 
18 TypeHandle PhysxCapsuleForceFieldShape::_type_handle;
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: PhysxCapsuleForceFieldShape::link
22 // Access: Public
23 // Description:
24 ////////////////////////////////////////////////////////////////////
25 void PhysxCapsuleForceFieldShape::
26 link(NxForceFieldShape *shapePtr) {
27 
28  _ptr = shapePtr->isCapsule();
29  _ptr->userData = this;
30  _error_type = ET_ok;
31 
32  set_name(shapePtr->getName());
33 
34  PhysxForceFieldShapeGroup *group = (PhysxForceFieldShapeGroup *)_ptr->getShapeGroup().userData;
35  group->_shapes.add(this);
36 }
37 
38 ////////////////////////////////////////////////////////////////////
39 // Function: PhysxCapsuleForceFieldShape::unlink
40 // Access: Public
41 // Description:
42 ////////////////////////////////////////////////////////////////////
43 void PhysxCapsuleForceFieldShape::
44 unlink() {
45 
46  _ptr->userData = NULL;
47  _error_type = ET_released;
48 
49  PhysxForceFieldShapeGroup *group = (PhysxForceFieldShapeGroup *)_ptr->getShapeGroup().userData;
50  group->_shapes.remove(this);
51 }
52 
53 ////////////////////////////////////////////////////////////////////
54 // Function : PhysxCapsuleForceFieldShape::save_to_desc
55 // Access : Published
56 // Description : Saves the state of the shape object to a
57 // descriptor.
58 ////////////////////////////////////////////////////////////////////
61 
62  nassertv(_error_type == ET_ok);
63  _ptr->saveToDesc(shapeDesc._desc);
64 }
65 
66 ////////////////////////////////////////////////////////////////////
67 // Function: PhysxCapsuleForceFieldShape::set_radius
68 // Access: Published
69 // Description: Alters the radius of the capsule.
70 ////////////////////////////////////////////////////////////////////
72 set_radius(float radius) {
73 
74  nassertv(_error_type == ET_ok);
75  _ptr->setRadius(radius);
76 }
77 
78 ////////////////////////////////////////////////////////////////////
79 // Function: PhysxCapsuleForceFieldShape::set_height
80 // Access: Published
81 // Description: Alters the height of the capsule.
82 ////////////////////////////////////////////////////////////////////
84 set_height(float height) {
85 
86  nassertv(_error_type == ET_ok);
87  _ptr->setHeight(height);
88 }
89 
90 ////////////////////////////////////////////////////////////////////
91 // Function: PhysxCapsuleForceFieldShape::get_radius
92 // Access: Published
93 // Description: Retrieves the radius of the capsule.
94 ////////////////////////////////////////////////////////////////////
96 get_radius() const {
97 
98  nassertr(_error_type == ET_ok, 0.0f);
99  return _ptr->getRadius();
100 }
101 
102 ////////////////////////////////////////////////////////////////////
103 // Function: PhysxCapsuleForceFieldShape::get_height
104 // Access: Published
105 // Description: Retrieves the height of the capsule.
106 ////////////////////////////////////////////////////////////////////
108 get_height() const {
109 
110  nassertr(_error_type == ET_ok, 0.0f);
111  return _ptr->getHeight();
112 }
113 
float get_radius() const
Retrieves the radius of the capsule.
void save_to_desc(PhysxCapsuleForceFieldShapeDesc &shapeDesc) const
Saves the state of the shape object to a descriptor.
void set_name(const char *name)
Sets a name string for this object.
void set_height(float height)
Alters the height of the capsule.
float get_height() const
Retrieves the height of the capsule.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
Descriptor for a capsule force field shape.
void set_radius(float radius)
Alters the radius of the capsule.