Panda3D
physxCapsuleController.cxx
1 // Filename: physxCapsuleController.cxx
2 // Created by: enn0x (24Sep09)
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 "physxCapsuleController.h"
16 
17 TypeHandle PhysxCapsuleController::_type_handle;
18 
19 ////////////////////////////////////////////////////////////////////
20 // Function: PhysxCapsuleController::link
21 // Access: Public
22 // Description:
23 ////////////////////////////////////////////////////////////////////
24 void PhysxCapsuleController::
25 link(NxController *controllerPtr) {
26 
27  nassertv(controllerPtr->getType() == NX_CONTROLLER_CAPSULE);
28 
29  // Link self
30  _ptr = (NxCapsuleController *)controllerPtr;
31  _error_type = ET_ok;
32 
33  PhysxScene *scene = (PhysxScene *)_ptr->getActor()->getScene().userData;
34  scene->_controllers.add(this);
35 
36  // Link actor
37  PT(PhysxActor) actor = new PhysxActor();
38  actor->link(_ptr->getActor());
39  actor->link_controller(this);
40 }
41 
42 ////////////////////////////////////////////////////////////////////
43 // Function: PhysxCapsuleController::unlink
44 // Access: Public
45 // Description:
46 ////////////////////////////////////////////////////////////////////
47 void PhysxCapsuleController::
48 unlink() {
49 
50  // Unlink actor
51  PT(PhysxActor) actor = (PhysxActor *)ptr()->getActor()->userData;
52  actor->unlink();
53 
54  // Unlink self
55  _error_type = ET_released;
56 
57  PhysxScene *scene = (PhysxScene *)_ptr->getActor()->getScene().userData;
58  scene->_controllers.remove(this);
59 }
60 
61 ////////////////////////////////////////////////////////////////////
62 // Function: PhysxCapsuleController::set_radius
63 // Access: Published
64 // Description: Resets the controller's radius.
65 ////////////////////////////////////////////////////////////////////
67 set_radius(float radius) {
68 
69  nassertv(_error_type == ET_ok);
70  _ptr->setRadius(radius);
71 }
72 
73 ////////////////////////////////////////////////////////////////////
74 // Function: PhysxCapsuleController::set_height
75 // Access: Published
76 // Description: Resets the controller's height.
77 ////////////////////////////////////////////////////////////////////
79 set_height(float height) {
80 
81  nassertv(_error_type == ET_ok);
82  _ptr->setHeight(height);
83 }
84 
85 ////////////////////////////////////////////////////////////////////
86 // Function: PhysxCapsuleController::get_radius
87 // Access: Published
88 // Description: Returns the controller's radius.
89 ////////////////////////////////////////////////////////////////////
91 get_radius() const {
92 
93  nassertr(_error_type == ET_ok, 0.0f);
94  return _ptr->getRadius();
95 }
96 
97 ////////////////////////////////////////////////////////////////////
98 // Function: PhysxCapsuleController::get_height
99 // Access: Published
100 // Description: Returns the controller's height.
101 ////////////////////////////////////////////////////////////////////
103 get_height() const {
104 
105  nassertr(_error_type == ET_ok, 0.0f);
106  return _ptr->getHeight();
107 }
108 
float get_radius() const
Returns the controller's radius.
void set_height(float height)
Resets the controller's height.
A scene is a collection of bodies, constraints, and effectors which can interact. ...
Definition: physxScene.h:73
void set_radius(float radius)
Resets the controller's radius.
Actors are the main simulation objects.
Definition: physxActor.h:48
float get_height() const
Returns the controller's height.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85