Panda3D
 All Classes Functions Variables Enumerations
physxPlaneShape.cxx
1 // Filename: physxPlaneShape.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 "physxPlaneShape.h"
16 #include "physxPlaneShapeDesc.h"
17 #include "physxManager.h"
18 
19 TypeHandle PhysxPlaneShape::_type_handle;
20 
21 ////////////////////////////////////////////////////////////////////
22 // Function: PhysxPlaneShape::link
23 // Access: Public
24 // Description:
25 ////////////////////////////////////////////////////////////////////
26 void PhysxPlaneShape::
27 link(NxShape *shapePtr) {
28 
29  _ptr = shapePtr->isPlane();
30  _ptr->userData = this;
31  _error_type = ET_ok;
32 
33  set_name(shapePtr->getName());
34 
35  PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData;
36  actor->_shapes.add(this);
37 }
38 
39 ////////////////////////////////////////////////////////////////////
40 // Function: PhysxPlaneShape::unlink
41 // Access: Public
42 // Description:
43 ////////////////////////////////////////////////////////////////////
44 void PhysxPlaneShape::
45 unlink() {
46 
47  _ptr->userData = NULL;
48  _error_type = ET_released;
49 
50  PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData;
51  actor->_shapes.remove(this);
52 }
53 
54 ////////////////////////////////////////////////////////////////////
55 // Function : PhysxPlaneShape::save_to_desc
56 // Access : Published
57 // Description : Saves the state of the shape object to a
58 // descriptor.
59 ////////////////////////////////////////////////////////////////////
61 save_to_desc(PhysxPlaneShapeDesc &shapeDesc) const {
62 
63  nassertv(_error_type == ET_ok);
64  _ptr->saveToDesc(shapeDesc._desc);
65 }
66 
67 ////////////////////////////////////////////////////////////////////
68 // Function: PhysxPlaneShape::set_plane
69 // Access: Published
70 // Description: Sets the plane equation.
71 // - normal: Normal for the plane, in the global
72 // frame. Range: direction vector
73 // - d: Distance coefficient of the plane equation.
74 // Range: (-inf,inf)
75 ////////////////////////////////////////////////////////////////////
77 set_plane(const LVector3f &normal, float d) {
78 
79  nassertv(_error_type == ET_ok);
80  _ptr->setPlane(PhysxManager::vec3_to_nxVec3(normal), d);
81 }
82 
void set_plane(const LVector3f &normal, float d)
Sets the plane equation.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
void save_to_desc(PhysxPlaneShapeDesc &shapeDesc) const
Saves the state of the shape object to a descriptor.
Descriptor class for PhysxPlaneShape.
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition: physxManager.I:33
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