Panda3D
physxPlaneShape.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 physxPlaneShape.cxx
10  * @author enn0x
11  * @date 2009-09-16
12  */
13 
14 #include "physxPlaneShape.h"
15 #include "physxPlaneShapeDesc.h"
16 #include "physxManager.h"
17 
18 TypeHandle PhysxPlaneShape::_type_handle;
19 
20 /**
21  *
22  */
23 void PhysxPlaneShape::
24 link(NxShape *shapePtr) {
25 
26  _ptr = shapePtr->isPlane();
27  _ptr->userData = this;
28  _error_type = ET_ok;
29 
30  set_name(shapePtr->getName());
31 
32  PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData;
33  actor->_shapes.add(this);
34 }
35 
36 /**
37  *
38  */
39 void PhysxPlaneShape::
40 unlink() {
41 
42  _ptr->userData = nullptr;
43  _error_type = ET_released;
44 
45  PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData;
46  actor->_shapes.remove(this);
47 }
48 
49 /**
50  * Saves the state of the shape object to a descriptor.
51  */
53 save_to_desc(PhysxPlaneShapeDesc &shapeDesc) const {
54 
55  nassertv(_error_type == ET_ok);
56  _ptr->saveToDesc(shapeDesc._desc);
57 }
58 
59 /**
60  * Sets the plane equation. - normal: Normal for the plane, in the global
61  * frame. Range: direction vector - d: Distance coefficient of the plane
62  * equation. Range: (-inf,inf)
63  */
65 set_plane(const LVector3f &normal, float d) {
66 
67  nassertv(_error_type == ET_ok);
68  _ptr->setPlane(PhysxManager::vec3_to_nxVec3(normal), d);
69 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_plane(const LVector3f &normal, float d)
Sets the plane equation.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Descriptor class for PhysxPlaneShape.
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition: physxManager.I:27
Actors are the main simulation objects.
Definition: physxActor.h:44
void set_name(const char *name)
Sets a name string for this object.
Definition: physxShape.cxx:100
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
void save_to_desc(PhysxPlaneShapeDesc &shapeDesc) const
Saves the state of the shape object to a descriptor.