Panda3D
physxSphereShape.cxx
1 // Filename: physxSphereShape.cxx
2 // Created by: enn0x (16Sep09)
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 "physxSphereShape.h"
16 #include "physxSphereShapeDesc.h"
17 
18 TypeHandle PhysxSphereShape::_type_handle;
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: PhysxSphereShape::link
22 // Access: Public
23 // Description:
24 ////////////////////////////////////////////////////////////////////
25 void PhysxSphereShape::
26 link(NxShape *shapePtr) {
27 
28  _ptr = shapePtr->isSphere();
29  _ptr->userData = this;
30  _error_type = ET_ok;
31 
32  set_name(shapePtr->getName());
33 
34  PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData;
35  actor->_shapes.add(this);
36 }
37 
38 ////////////////////////////////////////////////////////////////////
39 // Function: PhysxSphereShape::unlink
40 // Access: Public
41 // Description:
42 ////////////////////////////////////////////////////////////////////
43 void PhysxSphereShape::
44 unlink() {
45 
46  _ptr->userData = NULL;
47  _error_type = ET_released;
48 
49  PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData;
50  actor->_shapes.remove(this);
51 }
52 
53 ////////////////////////////////////////////////////////////////////
54 // Function : PhysxSphereShape::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: PhysxSphereShape::set_radius
68 // Access: Published
69 // Description: Sets the sphere radius.
70 ////////////////////////////////////////////////////////////////////
72 set_radius(float radius) {
73 
74  nassertv(_error_type == ET_ok);
75  _ptr->setRadius(radius);
76 }
77 
78 ////////////////////////////////////////////////////////////////////
79 // Function: PhysxSphereShape::get_radius
80 // Access: Published
81 // Description: Returns the radius of the sphere.
82 ////////////////////////////////////////////////////////////////////
84 get_radius() const {
85 
86  nassertr(_error_type == ET_ok, 0.0f);
87  return _ptr->getRadius();
88 }
89 
Descriptor class for PhysxSphereShape.
void save_to_desc(PhysxSphereShapeDesc &shapeDesc) const
Saves the state of the shape object to a descriptor.
float get_radius() const
Returns the radius of the sphere.
void set_radius(float radius)
Sets the sphere radius.
Actors are the main simulation objects.
Definition: physxActor.h:48
void set_name(const char *name)
Sets a name string for this object.
Definition: physxShape.cxx:112
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85