Panda3D
physxBoxForceFieldShape.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 physxBoxForceFieldShape.cxx
10  * @author enn0x
11  * @date 2009-11-15
12  */
13 
16 #include "physxManager.h"
17 
18 TypeHandle PhysxBoxForceFieldShape::_type_handle;
19 
20 /**
21  *
22  */
23 void PhysxBoxForceFieldShape::
24 link(NxForceFieldShape *shapePtr) {
25 
26  _ptr = shapePtr->isBox();
27  _ptr->userData = this;
28  _error_type = ET_ok;
29 
30  set_name(shapePtr->getName());
31 
32  PhysxForceFieldShapeGroup *group = (PhysxForceFieldShapeGroup *)_ptr->getShapeGroup().userData;
33  group->_shapes.add(this);
34 }
35 
36 /**
37  *
38  */
39 void PhysxBoxForceFieldShape::
40 unlink() {
41 
42  _ptr->userData = nullptr;
43  _error_type = ET_released;
44 
45  PhysxForceFieldShapeGroup *group = (PhysxForceFieldShapeGroup *)_ptr->getShapeGroup().userData;
46  group->_shapes.remove(this);
47 }
48 
49 /**
50  * Saves the state of the shape object to a descriptor.
51  */
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  */
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  */
79 get_dimensions() const {
80 
81  nassertr(_error_type == ET_ok, LVector3f::zero());
82  return PhysxManager::nxVec3_to_vec3(_ptr->getDimensions());
83 }
void save_to_desc(PhysxBoxForceFieldShapeDesc &shapeDesc) const
Saves the state of the shape object to a descriptor.
void set_dimensions(const LVector3f &dimensions)
Sets the box dimensions.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
LVector3f get_dimensions() const
Retrieves the dimensions of the box.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_name(const char *name)
Sets a name string for this object.
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
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
Descriptor for a box force field shape.