15 #include "physxScene.h" 16 #include "physxManager.h" 17 #include "physxActorDesc.h" 18 #include "physxForceFieldDesc.h" 19 #include "physxForceFieldShapeGroupDesc.h" 20 #include "physxControllerDesc.h" 21 #include "physxSceneStats2.h" 22 #include "physxConstraintDominance.h" 23 #include "physxVehicle.h" 24 #include "physxVehicleDesc.h" 25 #include "physxCloth.h" 26 #include "physxClothDesc.h" 27 #include "physxSoftBody.h" 28 #include "physxSoftBodyDesc.h" 32 PStatCollector PhysxScene::_pcollector_fetch_results(
"App:PhysX:Fetch Results");
33 PStatCollector PhysxScene::_pcollector_update_transforms(
"App:PhysX:Update Transforms");
34 PStatCollector PhysxScene::_pcollector_debug_renderer(
"App:PhysX:Debug Renderer");
35 PStatCollector PhysxScene::_pcollector_simulate(
"App:PhysX:Simulate");
37 PStatCollector PhysxScene::_pcollector_softbody(
"App:PhysX:Softbody");
45 link(NxScene *scenePtr) {
49 _ptr->userData =
this;
53 _cm = NxCreateControllerManager(NxGetPhysicsSDKAllocator());
57 NxMaterial *materials[5];
60 while (NxU32 i=_ptr->getMaterialArray(materials, 5, iterator)) {
63 material->link(materials[i]);
77 for (
unsigned int i=0; i < _vehicles.size(); i++) {
78 _vehicles[i]->release();
82 NxU32 nControllers = _cm->getNbControllers();
84 for (NxU32 i=0; i < nControllers; i++) {
85 NxController *controllerPtr = _cm->getController(i);
91 NxActor **actors = _ptr->getActors();
92 NxU32 nActors = _ptr->getNbActors();
94 for (NxU32 i=0; i < nActors; i++) {
104 NxU32 nJoints = _ptr->getNbJoints();
106 _ptr->resetJointIterator();
107 for (NxU32 i=0; i < nJoints; i++) {
108 NxJoint *jointPtr = _ptr->getNextJoint();
114 NxForceField **fields = _ptr->getForceFields();
115 NxU32 nFields = _ptr->getNbForceFields();
117 for (NxU32 i=0; i < nFields; i++) {
123 NxU32 nGroups = _ptr->getNbForceFieldShapeGroups();
125 _ptr->resetForceFieldShapeGroupsIterator();
126 for (NxU32 i=0; i < nGroups; i++) {
127 NxForceFieldShapeGroup *groupPtr = _ptr->getNextForceFieldShapeGroup();
133 NxCloth **cloths = _ptr->getCloths();
134 NxU32 nCloths = _ptr->getNbCloths();
136 for (NxU32 i=0; i < nCloths; i++) {
142 NxSoftBody **softbodies = _ptr->getSoftBodies();
143 NxU32 nSoftbodies = _ptr->getNbSoftBodies();
145 for (NxU32 i=0; i < nSoftbodies; i++) {
151 NxMaterial *materials[5];
154 while (NxU32 i=_ptr->getMaterialArray(materials, 5, iterator)) {
162 _cm->purgeControllers();
163 NxReleaseControllerManager(_cm);
165 _ptr->userData = NULL;
166 _error_type = ET_released;
179 nassertv(_error_type == ET_ok);
182 NxPhysicsSDK *sdk = NxGetPhysicsSDK();
183 sdk->releaseScene(*_ptr);
202 nassertv(_error_type == ET_ok);
204 _pcollector_simulate.start();
207 for (
unsigned int i=0; i < _vehicles.size(); i++) {
209 vehicle->update_vehicle(dt);
213 for (NxU32 i=0; i < _cm->getNbControllers(); i++) {
214 NxController *controllerPtr = _cm->getController(i);
216 controller->update_controller(dt);
219 _cm->updateControllers();
225 _pcollector_simulate.stop();
244 nassertv(_error_type == ET_ok);
245 nassertv(_ptr != NULL);
247 _pcollector_fetch_results.start();
248 _ptr->fetchResults(NX_RIGID_BODY_FINISHED,
true);
249 _pcollector_fetch_results.stop();
252 _pcollector_update_transforms.start();
254 NxU32 nbTransforms = 0;
255 NxActiveTransform *activeTransforms = _ptr->getActiveTransforms(nbTransforms);
257 if (nbTransforms && activeTransforms) {
258 for (NxU32 i=0; i<nbTransforms; ++i) {
262 void *userData = activeTransforms[i].userData;
270 _pcollector_update_transforms.stop();
273 _pcollector_debug_renderer.start();
274 _debugNode->update(_ptr);
275 _pcollector_debug_renderer.stop();
277 nassertv(_ptr->isWritable());
280 _pcollector_cloth.start();
282 NxCloth **cloths = _ptr->getCloths();
283 for (NxU32 i=0; i < _ptr->getNbCloths(); i++) {
288 _pcollector_cloth.stop();
291 _pcollector_softbody.start();
293 NxSoftBody **softbodies = _ptr->getSoftBodies();
294 for (NxU32 i=0; i < _ptr->getNbSoftBodies(); i++) {
299 _pcollector_softbody.stop();
311 nassertv(_error_type == ET_ok);
312 _ptr->setTiming(0, 0, NX_TIMESTEP_VARIABLE);
335 nassertv(_error_type == ET_ok);
336 _ptr->setTiming(maxTimestep, maxIter, NX_TIMESTEP_FIXED);
347 nassertv(_error_type == ET_ok);
348 nassertv_always(!gravity.
is_nan());
364 _ptr->getGravity(gravity);
373 unsigned int PhysxScene::
374 get_num_actors()
const {
376 nassertr(_error_type == ET_ok,-1);
378 return _ptr->getNbActors();
389 nassertr(_error_type == ET_ok, NULL);
393 nassertr(actor, NULL);
395 NxActor *actorPtr = _ptr->createActor(desc._desc);
396 nassertr(actorPtr, NULL);
398 actor->link(actorPtr);
409 get_actor(
unsigned int idx)
const {
411 nassertr(_error_type == ET_ok, NULL);
412 nassertr_always(idx < _ptr->getNbActors(), NULL);
414 NxActor *actorPtr = _ptr->getActors()[idx];
437 nassertr(_error_type == ET_ok, NULL);
447 enable_contact_reporting(
bool enabled) {
449 nassertv(_error_type == ET_ok);
452 _ptr->setUserContactReport(&_contact_report);
453 _contact_report.enable();
456 _ptr->setUserContactReport(NULL);
457 _contact_report.disable();
467 is_contact_reporting_enabled()
const {
469 nassertr(_error_type == ET_ok,
false);
471 return _contact_report.is_enabled();
480 enable_trigger_reporting(
bool enabled) {
482 nassertv(_error_type == ET_ok);
485 _ptr->setUserTriggerReport(&_trigger_report);
486 _trigger_report.enable();
489 _ptr->setUserTriggerReport(NULL);
490 _trigger_report.disable();
500 is_trigger_reporting_enabled()
const {
502 nassertr(_error_type == ET_ok,
false);
504 return _trigger_report.is_enabled();
513 enable_controller_reporting(
bool enabled) {
515 nassertv(_error_type == ET_ok);
518 _controller_report.enable();
521 _controller_report.disable();
531 is_controller_reporting_enabled()
const {
533 nassertr(_error_type == ET_ok,
false);
535 return _controller_report.is_enabled();
553 nassertr(_error_type == ET_ok, -1);
554 return _ptr->getNbMaterials();
571 nassertr(_error_type == ET_ok, NULL);
575 nassertr(material, NULL);
577 NxMaterial *materialPtr = _ptr->createMaterial(desc._desc);
578 nassertr(materialPtr, NULL);
580 material->link(materialPtr);
594 nassertr(_error_type == ET_ok, NULL);
597 nassertr(material, NULL);
601 NxMaterial *materialPtr = _ptr->createMaterial(desc);
602 nassertr(materialPtr, NULL);
604 material->link(materialPtr);
621 nassertr(_error_type == ET_ok, -1);
622 return _ptr->getHighestMaterialIndex();
641 nassertr(_error_type == ET_ok, NULL);
643 NxMaterial *materialPtr = _ptr->getMaterialFromIndex(idx);
658 nassertr(_error_type == ET_ok, NULL);
659 nassertr_always(idx < _ptr->getNbMaterials(), NULL);
661 NxU32 n = _ptr->getNbMaterials();
662 NxMaterial **materials =
new NxMaterial *[n];
666 materialCount = _ptr->getMaterialArray(materials, n, iterator);
667 nassertr((materialCount == n), NULL);
669 NxMaterial *materialPtr = materials[idx];
683 nassertr(_error_type == ET_ok, -1);
684 return _cm->getNbControllers();
696 nassertr(_error_type == ET_ok, NULL);
697 nassertr(desc.is_valid(), NULL);
699 PhysxController *controller = PhysxController::factory(desc.ptr()->getType());
700 nassertr(controller, NULL);
702 desc.ptr()->callback = &_controller_report;
703 desc.ptr()->userData = controller;
705 NxController *controllerPtr = _cm->createController(_ptr,*desc.ptr());
706 nassertr(controllerPtr, NULL);
708 controller->link(controllerPtr);
709 controller->get_actor()->set_name(
"");
722 nassertr(_error_type == ET_ok, NULL);
723 nassertr_always(idx < _cm->getNbControllers(), NULL);
725 NxController *controllerPtr = _cm->getController(idx);
741 nassertr(_error_type == ET_ok, -1);
742 return _ptr->getNbJoints();
753 nassertr(_error_type == ET_ok, NULL);
754 nassertr(desc.is_valid(), NULL);
756 PhysxJoint *joint = PhysxJoint::factory(desc.ptr()->getType());
757 nassertr(joint, NULL);
759 NxJoint *jointPtr = _ptr->createJoint(*desc.ptr());
760 nassertr(jointPtr, NULL);
762 joint->link(jointPtr);
776 nassertr(_error_type == ET_ok, NULL);
777 nassertr_always(idx < _ptr->getNbJoints(), NULL);
780 NxU32 nJoints = _ptr->getNbJoints();
782 _ptr->resetJointIterator();
783 for (NxU32 i=0; i <= idx; i++) {
784 jointPtr = _ptr->getNextJoint();
798 nassertr(_error_type == ET_ok, -1);
799 return _ptr->getNbForceFields();
810 nassertr(_error_type == ET_ok, NULL);
813 desc.create_kernel(_ptr);
818 nassertr(field, NULL);
820 NxForceField *fieldPtr = _ptr->createForceField(desc._desc);
821 nassertr(fieldPtr, NULL);
823 field->link(fieldPtr);
837 nassertr(_error_type == ET_ok, NULL);
838 nassertr_always(idx < _ptr->getNbForceFields(), NULL);
840 NxForceField **fields = _ptr->getForceFields();
841 NxForceField *fieldPtr = fields[idx];
855 nassertr(_error_type == ET_ok, -1);
856 return _ptr->getNbForceFieldShapeGroups();
868 nassertr(_error_type == ET_ok, NULL);
871 nassertr(group, NULL);
873 NxForceFieldShapeGroup *groupPtr = _ptr->createForceFieldShapeGroup(desc._desc);
874 nassertr(groupPtr, NULL);
876 group->link(groupPtr);
890 nassertr(_error_type == ET_ok, NULL);
891 nassertr_always(idx < _ptr->getNbForceFieldShapeGroups(), NULL);
893 _ptr->resetForceFieldShapeGroupsIterator();
894 NxForceFieldShapeGroup *groupPtr = NULL;
897 groupPtr = _ptr->getNextForceFieldShapeGroup();
911 nassertr(_error_type == ET_ok, -1);
912 return _ptr->getNbCloths();
923 nassertr(_error_type == ET_ok, NULL);
926 nassertr(cloth, NULL);
928 NxCloth *clothPtr = _ptr->createCloth(desc._desc);
929 nassertr(clothPtr, NULL);
931 cloth->link(clothPtr);
945 nassertr(_error_type == ET_ok, NULL);
946 nassertr_always(idx < _ptr->getNbCloths(), NULL);
948 NxCloth **cloths = _ptr->getCloths();
949 NxCloth *clothPtr = cloths[idx];
962 nassertr(_error_type == ET_ok, -1);
963 return _ptr->getNbSoftBodies();
974 nassertr(_error_type == ET_ok, NULL);
977 nassertr(softbody, NULL);
979 NxSoftBody *softbodyPtr = _ptr->createSoftBody(desc._desc);
980 nassertr(softbodyPtr, NULL);
982 softbody->link(softbodyPtr);
996 nassertr(_error_type == ET_ok, NULL);
997 nassertr_always(idx < _ptr->getNbSoftBodies(), NULL);
999 NxSoftBody **softbodies = _ptr->getSoftBodies();
1000 NxSoftBody *softbodyPtr = softbodies[idx];
1013 nassertr(_error_type == ET_ok, -1);
1014 return _vehicles.size();
1025 nassertr(_error_type == ET_ok, NULL);
1029 nassertr(vehicle, NULL);
1031 vehicle->create(
this, desc);
1045 nassertr(_error_type == ET_ok, NULL);
1046 nassertr_always(idx < _vehicles.size(), NULL);
1048 return _vehicles[idx];
1057 get_stats2()
const {
1059 nassertr(_error_type == ET_ok, NULL);
1071 PhysxShapesType shapesType,
1075 nassertr(_error_type == ET_ok,
false);
1077 NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : NULL;
1079 return _ptr->raycastAnyShape(ray._ray, (NxShapesType)shapesType,
1080 mask.get_mask(), ray._length, groupsPtr);
1092 PhysxShapesType shapesType,
1098 nassertr(_error_type == ET_ok, hit);
1100 NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : NULL;
1102 NxU32 hints = NX_RAYCAST_SHAPE | NX_RAYCAST_IMPACT | NX_RAYCAST_DISTANCE;
1103 if (smoothNormal ==
true) {
1104 hints |= NX_RAYCAST_NORMAL;
1107 hints |= NX_RAYCAST_FACE_NORMAL;
1110 _ptr->raycastClosestShape(ray._ray, (NxShapesType)shapesType, hit,
1111 mask.get_mask(), ray._length, hints, groupsPtr);
1126 PhysxShapesType shapesType,
1132 nassertr(_error_type == ET_ok, report);
1134 NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : NULL;
1136 NxU32 hints = NX_RAYCAST_SHAPE | NX_RAYCAST_IMPACT | NX_RAYCAST_DISTANCE;
1137 if (smoothNormal ==
true) {
1138 hints |= NX_RAYCAST_NORMAL;
1141 hints |= NX_RAYCAST_FACE_NORMAL;
1144 _ptr->raycastAllShapes(ray._ray, report, (NxShapesType)shapesType,
1145 mask.get_mask(), ray._length, hints, groupsPtr);
1158 PhysxShapesType shapesType,
1162 nassertr(_error_type == ET_ok,
false);
1164 NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : NULL;
1166 return _ptr->raycastAnyBounds(ray._ray, (NxShapesType)shapesType,
1167 mask.get_mask(), ray._length, groupsPtr);
1183 nassertr(_error_type == ET_ok, hit);
1185 NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : NULL;
1187 NxU32 hints = NX_RAYCAST_SHAPE | NX_RAYCAST_IMPACT | NX_RAYCAST_DISTANCE;
1188 if (smoothNormal ==
true) {
1189 hints |= NX_RAYCAST_NORMAL;
1192 hints |= NX_RAYCAST_FACE_NORMAL;
1195 _ptr->raycastClosestBounds(ray._ray, (NxShapesType)shapesType, hit,
1196 mask.get_mask(), ray._length, hints, groupsPtr);
1212 PhysxShapesType shapesType,
1218 nassertr(_error_type == ET_ok, report);
1220 NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : NULL;
1222 NxU32 hints = NX_RAYCAST_SHAPE | NX_RAYCAST_IMPACT | NX_RAYCAST_DISTANCE;
1223 if (smoothNormal ==
true) {
1224 hints |= NX_RAYCAST_NORMAL;
1227 hints |= NX_RAYCAST_FACE_NORMAL;
1230 _ptr->raycastAllBounds(ray._ray, report, (NxShapesType)shapesType,
1231 mask.get_mask(), ray._length, hints, groupsPtr);
1246 PhysxShapesType shapesType,
1247 PhysxMask mask,
bool accurateCollision)
const {
1251 nassertr(_error_type == ET_ok, report);
1255 _ptr->overlapSphereShapes(worldSphere, (NxShapesType)shapesType, 0, NULL, &report,
1256 mask.get_mask(), NULL, accurateCollision);
1271 PhysxShapesType shapesType,
1272 PhysxMask mask,
bool accurateCollision)
const {
1276 nassertr(_error_type == ET_ok, report);
1280 NxCapsule worldCapsule(segment, radius);
1282 _ptr->overlapCapsuleShapes(worldCapsule, (NxShapesType)shapesType, 0, NULL, &report,
1283 mask.get_mask(), NULL, accurateCollision);
1305 PhysxContactPairFlag flag,
bool value) {
1307 nassertv(_error_type == ET_ok);
1309 NxActor *ptrA = actorA.ptr();
1310 NxActor *ptrB = actorB.ptr();
1311 NxU32 flags = _ptr->getActorPairFlags(*ptrA, *ptrB);
1313 if (value ==
true) {
1320 _ptr->setActorPairFlags(*ptrA, *ptrB, flags);
1334 PhysxContactPairFlag flag) {
1336 nassertr(_error_type == ET_ok,
false);
1338 NxActor *ptrA = actorA.ptr();
1339 NxActor *ptrB = actorB.ptr();
1340 NxU32 flags = _ptr->getActorPairFlags(*ptrA, *ptrB);
1342 return (flags && flag) ? true :
false;
1357 nassertv(_error_type == ET_ok);
1359 NxShape *ptrA = shapeA.ptr();
1360 NxShape *ptrB = shapeB.ptr();
1361 NxU32 flags = _ptr->getShapePairFlags(*ptrA, *ptrB);
1363 if (value ==
true) {
1364 flags |= NX_IGNORE_PAIR;
1367 flags &= ~(NX_IGNORE_PAIR);
1370 _ptr->setShapePairFlags(*ptrA, *ptrB, flags);
1386 nassertr(_error_type == ET_ok,
false);
1388 NxShape *ptrA = shapeA.ptr();
1389 NxShape *ptrB = shapeB.ptr();
1390 NxU32 flags = _ptr->getShapePairFlags(*ptrA, *ptrB);
1392 return (flags && NX_IGNORE_PAIR) ? true :
false;
1423 PhysxContactPairFlag flag,
bool value) {
1425 nassertv(_error_type == ET_ok);
1427 NxU32 flags = _ptr->getActorGroupPairFlags(g1, g2);
1428 if (value ==
true) {
1434 _ptr->setActorGroupPairFlags(g1, g2, flags);
1445 PhysxContactPairFlag flag) {
1447 nassertr(_error_type == ET_ok,
false);
1448 NxU32 flags = _ptr->getActorGroupPairFlags(g1, g2);
1449 return (flags && flag) ? true :
false;
1460 nassertv(_error_type == ET_ok);
1461 _ptr->setFilterOps((NxFilterOp)op0, (NxFilterOp)op1, (NxFilterOp)op2);
1472 nassertv(_error_type == ET_ok);
1473 _ptr->setFilterBool(flag);
1484 nassertv(_error_type == ET_ok);
1485 _ptr->setFilterConstant0(mask.get_mask());
1496 nassertv(_error_type == ET_ok);
1497 _ptr->setFilterConstant1(mask.get_mask());
1508 nassertr(_error_type == ET_ok,
false);
1509 return _ptr->getFilterBool();
1522 nassertr(_error_type == ET_ok, mask);
1524 NxGroupsMask _mask = ptr()->getFilterConstant0();
1525 mask.set_mask(_mask);
1540 nassertr(_error_type == ET_ok, mask);
1542 NxGroupsMask _mask = ptr()->getFilterConstant1();
1543 mask.set_mask(_mask);
1556 nassertr(_error_type == ET_ok, FO_and);
1562 _ptr->getFilterOps(op0, op1, op2);
1564 return (PhysxFilterOp)op0;
1575 nassertr(_error_type == ET_ok, FO_and);
1581 _ptr->getFilterOps(op0, op1, op2);
1583 return (PhysxFilterOp)op1;
1594 nassertr(_error_type == ET_ok, FO_and);
1600 _ptr->getFilterOps(op0, op1, op2);
1602 return (PhysxFilterOp)op2;
1624 nassertv(_error_type == ET_ok);
1625 nassertv(g1 >= 0 && g1 < 32);
1626 nassertv(g2 >= 0 && g2 < 32);
1628 _ptr->setGroupCollisionFlag((NxCollisionGroup)g1, (NxCollisionGroup)g2, enable);
1641 nassertr(_error_type == ET_ok,
false);
1642 nassertr(g1 >= 0 && g1 < 32,
false);
1643 nassertr(g2 >= 0 && g2 < 32,
false);
1645 return _ptr->getGroupCollisionFlag((NxCollisionGroup)g1, (NxCollisionGroup)g2);
1656 nassertr(_error_type == ET_ok,
false);
1657 return (_ptr->getFlags() & flag) ?
true :
false;
1670 nassertr(_error_type == ET_ok,
false);
1671 return (_ptr->getSimType() & NX_SIMULATION_HW) ?
true :
false;
1730 nassertv(_error_type == ET_ok);
1734 NxConstraintDominance d = dominance.get_dominance();
1735 _ptr->setDominanceGroupPair((NxDominanceGroup)g1, (NxDominanceGroup)g2, d);
1748 nassertr(_error_type == ET_ok, result);
1749 nassertr(g1 < 32, result);
1750 nassertr(g2 < 32, result);
1752 result.set_dominance(_ptr->getDominanceGroupPair((NxDominanceGroup)g1, (NxDominanceGroup)g2));
1770 nassertr(_error_type == ET_ok, NULL);
1772 if (_wheelShapeMaterial == NULL) {
1774 materialDesc.
set_flag(PhysxMaterialDesc::MF_disable_friction,
true);
1778 return _wheelShapeMaterial;
Objects of this class are returned by the 'overlap shape' methods, for example overlapSphereShapes.
bool get_group_collision_flag(unsigned int g1, unsigned int g2)
Determines if collision detection is performed between a pair of groups.
Descriptor class for materials.
PhysxMaterial * get_wheel_shape_material()
Gets the shared material for all wheel shapes.
PhysxRaycastHit raycast_closest_shape(const PhysxRay &ray, PhysxShapesType shapesType=ST_all, PhysxMask mask=PhysxMask::all_on(), PhysxGroupsMask *groups=NULL, bool smoothNormal=true) const
Returns the first shape that is hit along the ray.
void set_filter_constant1(const PhysxGroupsMask &mask)
Setups filtering's K1 value.
PhysxVehicle * get_vehicle(unsigned int idx) const
Returns the n-th vehicle from the array of all the vehicles in the scene.
PhysxRaycastReport raycast_all_bounds(const PhysxRay &ray, PhysxShapesType shapesType=ST_all, PhysxMask mask=PhysxMask::all_on(), PhysxGroupsMask *groups=NULL, bool smoothNormal=true) const
Returns a PhysxRaycastReport object which can be used to iterate over all shapes that have been enclo...
unsigned int get_num_materials() const
Return the number of materials in the scene.
void set_group_collision_flag(unsigned int g1, unsigned int g2, bool enable)
Specifies if collision should be performed by a pair of shape groups.
unsigned int get_num_joints() const
Returns the number of joints in the scene (excluding "dead" joints).
unsigned int get_num_force_fields() const
Gets the number of force fields in the scene.
void set_flag(PhysxMaterialFlag flag, bool value)
Sets flags which control the behavior of a material.
bool is_valid() const
Returns true if the descriptor is valid.
unsigned int get_num_soft_bodies() const
Gets the number of soft bodies in the scene.
PhysxGroupsMask get_filter_constant1() const
Gets filtering constant K1.
static PhysxManager * get_global_ptr()
Returns a pointer to the global PhysxManager object.
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
Abstract base class for the different types of joints.
bool is_valid() const
Returns true if the descriptor is valid.
Abstract base class for shapes.
static const LVector3f & zero()
Returns a zero-length vector.
void set_filter_bool(bool flag)
Setups filtering's boolean value.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Descriptor for PhysxCloth.
bool is_valid() const
Returns true if the descriptor is valid.
Abstract base class for joint descriptors.
PhysxSoftBody * create_soft_body(PhysxSoftBodyDesc &desc)
Creates a soft body in this scene.
unsigned int get_num_vehicles() const
Returns the number of vehicles in the scene.
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
unsigned int get_num_cloths() const
Gets the number of cloths in the scene.
Descriptor class for force fields.
void set_filter_constant0(const PhysxGroupsMask &mask)
Setups filtering's K0 value.
bool is_nan() const
Returns true if any component of the vector is not-a-number, false otherwise.
void update_transform(const LMatrix4f &m)
Updates the transform of an assigned NodePath.
PhysxGroupsMask get_filter_constant0() const
Gets filtering constant K0.
bool get_actor_pair_flag(PhysxActor &actorA, PhysxActor &actorB, PhysxContactPairFlag flag)
Retrieves a single flag for the given pair of actors.
PhysxController * get_controller(unsigned int idx) const
Retrieves the n-th controller within the scene.
A class for describing a shape's surface properties.
PhysxCloth * create_cloth(PhysxClothDesc &desc)
Creates a cloth in this scene.
Descriptor class for a character controller.
PhysxMaterial * get_material_from_index(unsigned int idx) const
Retrieves the material with the given material index.
void set_timing_variable()
Sets simulation timing parameters used in simulate.
This structure captures results for a single raycast query.
A lightweight class that represents a single element that may be timed and/or counted via stats...
bool get_actor_group_pair_flag(unsigned int g1, unsigned int g2, PhysxContactPairFlag flag)
Retrieves a single flag set with PhysxScene::set_actor_group_pair_flag()
bool raycast_any_bounds(const PhysxRay &ray, PhysxShapesType shapesType=ST_all, PhysxMask mask=PhysxMask::all_on(), PhysxGroupsMask *groups=NULL) const
Returns true if any axis aligned bounding box enclosing a shape is intersected by the ray...
PhysxForceFieldShapeGroup * create_force_field_shape_group(PhysxForceFieldShapeGroupDesc &desc)
Creates a new force field shape group in this scene.
bool is_hardware_scene() const
Returns TRUE if the the scene is simulated in hardware.
PhysxOverlapReport overlap_capsule_shapes(const LPoint3f &p0, const LPoint3f &p1, float radius, PhysxShapesType shapesType=ST_all, PhysxMask mask=PhysxMask::all_on(), bool accurateCollision=true) const
Returns the set of shapes overlapped by the world-space capsule.
PhysxFilterOp get_filter_op1() const
Retrieves the op1 filtering operation.
PhysxConstraintDominance get_dominance_group_pair(unsigned int g1, unsigned int g2)
Samples the dominance matrix.
Abstract base class for character controllers.
Descriptor for PhysxSoftBody.
PhysxForceFieldShapeGroup * get_force_field_shape_group(unsigned int idx) const
Returns the n-th force field shape group in this scene.
bool get_flag(PhysxSceneFlag flag) const
Return the specified scene flag flag.
This is a 4-by-4 transform matrix.
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
void fetch_results()
Waits until the simulation has finished, and then updates the scene graph with with simulation result...
PhysxRaycastReport raycast_all_shapes(const PhysxRay &ray, PhysxShapesType shapesType=ST_all, PhysxMask mask=PhysxMask::all_on(), PhysxGroupsMask *groups=NULL, bool smoothNormal=true) const
Returns a PhysxRaycastReport object which can be used to iterate over all shapes that have been hit b...
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
Descriptor for PhysxActor.
void set_dominance_group_pair(unsigned int g1, unsigned int g2, PhysxConstraintDominance dominance)
Specifies the dominance behavior of constraints between two actors with two certain dominance groups...
Actors are the main simulation objects.
void set_actor_pair_flag(PhysxActor &actorA, PhysxActor &actorB, PhysxContactPairFlag flag, bool value)
Sets the pair flags for the given pair of actors.
PhysxMaterial * get_material(unsigned int idx) const
Retrieves the n-th material from the array of materials.
PhysxMaterial * create_material()
Creates a new PhysxMaterial using the default settings of PhysxMaterialDesc.
PhysxRaycastHit raycast_closest_bounds(const PhysxRay &ray, PhysxShapesType shapesType=ST_all, PhysxMask mask=PhysxMask::all_on(), PhysxGroupsMask *groups=NULL, bool smoothNormal=true) const
Returns the first axis aligned bounding box enclosing a shape that is hit along the ray...
void set_shape_pair_flag(PhysxShape &shapeA, PhysxShape &shapeB, bool value)
Disables or enables contact generation for a pair of shapes.
PhysxCloth * get_cloth(unsigned int idx) const
Returns the n-th cloth from the array of all the cloths in the scene.
PhysxFilterOp get_filter_op0() const
Retrieves the op0 filtering operation.
PhysxJoint * get_joint(unsigned int idx) const
Retrieve the n-th joint from the array of all the joints in the scene.
void set_actor_group_pair_flag(unsigned int g1, unsigned int g2, PhysxContactPairFlag flag, bool value)
With this method one can set contact reporting flags between actors belonging to a pair of groups...
PhysxJoint * create_joint(PhysxJointDesc &desc)
Creates a joint in this scene.
void simulate(float dt)
Advances the simulation by an elapsedTime time.
LVector3f get_gravity() const
Retrieves the current gravity setting.
PhysxSoftBody * get_soft_body(unsigned int idx) const
Returns the n-th soft body from the array of all the soft bodies in the scene.
bool is_valid() const
Returns true if the descriptor is valid.
void set_gravity(const LVector3f &gravity)
Sets a constant gravity for the entire scene.
PhysxController * create_controller(PhysxControllerDesc &controllerDesc)
Creates a new character controller.
void set_timing_fixed(float maxTimestep=1.0f/60.0f, unsigned int maxIter=8)
Sets simulation timing parameters used in simulate.
PhysxOverlapReport overlap_sphere_shapes(const LPoint3f ¢er, float radius, PhysxShapesType shapesType=ST_all, PhysxMask mask=PhysxMask::all_on(), bool accurateCollision=true) const
Returns the set of shapes overlapped by the world-space sphere.
PhysxForceField * create_force_field(PhysxForceFieldDesc &desc)
Creates a force field in this scene.
PhysxDebugGeomNode * get_debug_geom_node()
Retrieves the debug geom node for this scene.
TypeHandle is the identifier used to differentiate C++ class types.
unsigned int get_hightest_material_index() const
Returns current highest valid material index.
bool raycast_any_shape(const PhysxRay &ray, PhysxShapesType shapesType=ST_all, PhysxMask mask=PhysxMask::all_on(), PhysxGroupsMask *groups=NULL) const
Returns true if any shape is intersected by the ray.
PhysxForceField * get_force_field(unsigned int idx) const
Returns the n-th force field from the array of all the force fields in the scene. ...
void set_filter_ops(PhysxFilterOp op0, PhysxFilterOp op1, PhysxFilterOp op2)
Setups filtering operations.
PhysxFilterOp get_filter_op2() const
Retrieves the op2 filtering operation.
static LMatrix4f nxMat34_to_mat4(const NxMat34 &m)
Converts from NxMat34 to LMatrix4f.
unsigned int get_num_force_field_shape_groups() const
Gets the number of force field shape groups in the scene.
Objects of this class are returned by the 'raycast all' methods.
Represents an ray as an origin and direction.
PhysxVehicle * create_vehicle(PhysxVehicleDesc &desc)
Creates a vehicle in this scene.
unsigned int get_num_controllers() const
Return the number of controllers in the scene.
Renderable geometry which represents visualizations of physics objects.
Expresses the dominance relationship of a constraint.
bool get_shape_pair_flag(PhysxShape &shapeA, PhysxShape &shapeB)
Returns /true/ if contact generation between a pair of shapes is enabled, and /false/ if contact gene...
bool get_filter_bool() const
Retrieves filtering's boolean value.