| 125 | // PT: TODO: use PhysXSampleApplication helper for this |
| 126 | |
| 127 | static PxRigidActor* createRigidActor( PxScene& scene, PxPhysics& physics, |
| 128 | const PxTransform& pose, const PxGeometry& geometry, PxMaterial& material, |
| 129 | const PxFilterData* fd, const PxReal* density, const PxReal* mass, PxU32 flags) |
| 130 | { |
| 131 | const bool isDynamic = (density && *density) || (mass && *mass); |
| 132 | |
| 133 | PxRigidActor* actor = isDynamic ? static_cast<PxRigidActor*>(physics.createRigidDynamic(pose)) |
| 134 | : static_cast<PxRigidActor*>(physics.createRigidStatic(pose)); |
| 135 | if(!actor) |
| 136 | return NULL; |
| 137 | |
| 138 | PxShape* shape = PxRigidActorExt::createExclusiveShape(*actor, geometry, material); |
| 139 | if(!shape) |
| 140 | { |
| 141 | actor->release(); |
| 142 | return NULL; |
| 143 | } |
| 144 | |
| 145 | if(fd) |
| 146 | shape->setSimulationFilterData(*fd); |
| 147 | |
| 148 | if(isDynamic) |
| 149 | { |
| 150 | PxRigidDynamic* body = static_cast<PxRigidDynamic*>(actor); |
| 151 | { |
| 152 | if(density) |
| 153 | PxRigidBodyExt::updateMassAndInertia(*body, *density); |
| 154 | else |
| 155 | PxRigidBodyExt::setMassAndUpdateInertia(*body, *mass); |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | scene.addActor(*actor); |
| 160 | |
| 161 | return actor; |
| 162 | } |
| 163 | |
| 164 | static PxRigidActor* createBox( PxScene& scene, PxPhysics& physics, |
| 165 | const PxTransform& pose, const PxVec3& dimensions, const PxReal density, PxMaterial& m, const PxFilterData* fd, PxU32 flags) |
no test coverage detected