15 #include "physxForceFieldShapeGroup.h" 16 #include "physxForceFieldShapeGroupDesc.h" 17 #include "physxForceField.h" 18 #include "physxForceFieldShape.h" 20 TypeHandle PhysxForceFieldShapeGroup::_type_handle;
27 void PhysxForceFieldShapeGroup::
28 link(NxForceFieldShapeGroup *groupPtr) {
32 _ptr->userData =
this;
38 scene->_ffgroups.add(
this);
41 NxU32 nShapes = _ptr->getNbShapes();
42 _ptr->resetShapesIterator();
43 for (NxU32 i=0; i < nShapes; i++) {
44 NxForceFieldShape *shapePtr = _ptr->getNextShape();
46 shape->link(shapePtr);
55 void PhysxForceFieldShapeGroup::
59 NxU32 nShapes = _ptr->getNbShapes();
60 _ptr->resetShapesIterator();
61 for (NxU32 i=0; i < nShapes; i++) {
62 NxForceFieldShape *shapePtr = _ptr->getNextShape();
68 _ptr->userData = NULL;
69 _error_type = ET_released;
72 scene->_ffgroups.remove(
this);
83 nassertv(_error_type == ET_ok);
86 _ptr->getScene().releaseForceFieldShapeGroup(*_ptr);
99 nassertr(_error_type == ET_ok, NULL);
100 return (
PhysxScene *)(_ptr->getScene().userData);
112 nassertr(_error_type == ET_ok, NULL);
114 if (_ptr->getForceField() == NULL) {
131 nassertv(_error_type == ET_ok);
132 _ptr->saveToDesc(groupDesc._desc);
146 nassertv(_error_type == ET_ok);
148 _name = name ? name :
"";
149 _ptr->setName(_name.c_str());
160 nassertr(_error_type == ET_ok,
"");
161 return _ptr->getName();
173 nassertr(_error_type == ET_ok, -1);
175 return _ptr->getNbShapes();
187 nassertr(_error_type == ET_ok, NULL);
188 nassertr(desc.is_valid(),NULL);
191 nassertr(shape, NULL);
193 NxForceFieldShape *shapePtr = _ptr->createShape(*desc.ptr());
194 nassertr(shapePtr, NULL);
196 shape->link(shapePtr);
209 nassertr(_error_type == ET_ok, NULL);
210 nassertr_always(idx < _ptr->getNbShapes(), NULL);
212 NxForceFieldShape *shapePtr;
213 NxU32 nShapes = _ptr->getNbShapes();
215 _ptr->resetShapesIterator();
216 for (NxU32 i=0; i <= idx; i++) {
217 shapePtr = _ptr->getNextShape();
PhysxForceFieldShape * get_shape(unsigned int idx) const
Returns the i-th shape in the force field group.
Abstract base class for descriptors for force field shapes descriptors.
PhysxScene * get_scene() const
Returns the scene that owns this force field shape group.
A scene is a collection of bodies, constraints, and effectors which can interact. ...
Abstract base class for force field shapes.
PhysxForceFieldShape * create_shape(PhysxForceFieldShapeDesc &desc)
Creates a force field shape and adds it to the group.
unsigned int get_num_shapes() const
Returns the number of shapes assigned to the force field shape group.
PhysxForceField * get_force_field() const
Returns the force field of this group if this is an include group.
void save_to_desc(PhysxForceFieldShapeGroupDesc &groupDesc) const
Saves the state of the force field shape group object to a descriptor.
const char * get_name() const
Returns the name string.
void release()
Releases the force field shape.
TypeHandle is the identifier used to differentiate C++ class types.
void set_name(const char *name)
Sets a name string for the object that can be retrieved with get_name().