Panda3D
physxCapsuleController.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file physxCapsuleController.cxx
10  * @author enn0x
11  * @date 2009-09-24
12  */
13 
14 #include "physxCapsuleController.h"
15 
16 TypeHandle PhysxCapsuleController::_type_handle;
17 
18 /**
19  *
20  */
21 void PhysxCapsuleController::
22 link(NxController *controllerPtr) {
23 
24  nassertv(controllerPtr->getType() == NX_CONTROLLER_CAPSULE);
25 
26  // Link self
27  _ptr = (NxCapsuleController *)controllerPtr;
28  _error_type = ET_ok;
29 
30  PhysxScene *scene = (PhysxScene *)_ptr->getActor()->getScene().userData;
31  scene->_controllers.add(this);
32 
33  // Link actor
34  PT(PhysxActor) actor = new PhysxActor();
35  actor->link(_ptr->getActor());
36  actor->link_controller(this);
37 }
38 
39 /**
40  *
41  */
42 void PhysxCapsuleController::
43 unlink() {
44 
45  // Unlink actor
46  PT(PhysxActor) actor = (PhysxActor *)ptr()->getActor()->userData;
47  actor->unlink();
48 
49  // Unlink self
50  _error_type = ET_released;
51 
52  PhysxScene *scene = (PhysxScene *)_ptr->getActor()->getScene().userData;
53  scene->_controllers.remove(this);
54 }
55 
56 /**
57  * Resets the controller's radius.
58  */
60 set_radius(float radius) {
61 
62  nassertv(_error_type == ET_ok);
63  _ptr->setRadius(radius);
64 }
65 
66 /**
67  * Resets the controller's height.
68  */
70 set_height(float height) {
71 
72  nassertv(_error_type == ET_ok);
73  _ptr->setHeight(height);
74 }
75 
76 /**
77  * Returns the controller's radius.
78  */
80 get_radius() const {
81 
82  nassertr(_error_type == ET_ok, 0.0f);
83  return _ptr->getRadius();
84 }
85 
86 /**
87  * Returns the controller's height.
88  */
90 get_height() const {
91 
92  nassertr(_error_type == ET_ok, 0.0f);
93  return _ptr->getHeight();
94 }
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:69
void set_radius(float radius)
Resets the controller's radius.
Actors are the main simulation objects.
Definition: physxActor.h:44
float get_height() const
Returns the controller's height.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81