Panda3D
physxBoxShape.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 physxBoxShape.cxx
10  * @author enn0x
11  * @date 2009-09-16
12  */
13 
14 #include "physxBoxShape.h"
15 #include "physxBoxShapeDesc.h"
16 #include "physxManager.h"
17 
18 TypeHandle PhysxBoxShape::_type_handle;
19 
20 /**
21  *
22  */
23 void PhysxBoxShape::
24 link(NxShape *shapePtr) {
25 
26  _ptr = shapePtr->isBox();
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 PhysxBoxShape::
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  */
52 void PhysxBoxShape::
53 save_to_desc(PhysxBoxShapeDesc &shapeDesc) const {
54 
55  nassertv(_error_type == ET_ok);
56  _ptr->saveToDesc(shapeDesc._desc);
57 }
58 
59 /**
60  * Sets the box dimensions.
61  *
62  * The dimensions are the 'radii' of the box, meaning 1/2 extents in x
63  * dimension, 1/2 extents in y dimension, 1/2 extents in z dimension.
64  */
65 void PhysxBoxShape::
66 set_dimensions(const LVector3f &vec) {
67 
68  nassertv(_error_type == ET_ok);
69  _ptr->setDimensions(PhysxManager::vec3_to_nxVec3(vec));
70 }
71 
72 /**
73  * Retrieves the dimensions of the box.
74  *
75  * The dimensions are the 'radii' of the box, meaning 1/2 extents in x
76  * dimension, 1/2 extents in y dimension, 1/2 extents in z dimension.
77  */
78 LVector3f PhysxBoxShape::
79 get_dimensions() const {
80 
81  nassertr(_error_type == ET_ok, LVector3f::zero());
82  return PhysxManager::nxVec3_to_vec3(_ptr->getDimensions());
83 }
LVector3f get_dimensions() const
Retrieves the dimensions of the box.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void save_to_desc(PhysxBoxShapeDesc &shapeDesc) const
Saves the state of the shape object to a descriptor.
void set_dimensions(const LVector3f &dimensions)
Sets the box dimensions.
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition: physxManager.I:27
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
Definition: physxManager.I:36
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Actors are the main simulation objects.
Definition: physxActor.h:44
Descriptor class for PhysxBoxShape.
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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.