| 178 | //----------------------------------------------------------------------------// |
| 179 | |
| 180 | void Picking::grabActor(const PxVec3& worldImpact, const PxVec3& rayOrigin) |
| 181 | { |
| 182 | if(!mSelectedActor |
| 183 | || (mSelectedActor->getType() != PxActorType::eRIGID_DYNAMIC |
| 184 | && mSelectedActor->getType() != PxActorType::eARTICULATION_LINK)) |
| 185 | return; |
| 186 | |
| 187 | PxScene& scene = mFrame.getActiveScene(); |
| 188 | PxPhysics& physics = scene.getPhysics(); |
| 189 | |
| 190 | //create a shape less actor for the mouse |
| 191 | { |
| 192 | mMouseActor = physics.createRigidDynamic(PxTransform(worldImpact, PxQuat(PxIdentity))); |
| 193 | mMouseActor->setRigidBodyFlag(PxRigidBodyFlag::eKINEMATIC, true); |
| 194 | mMouseActor->setMass(1.0f); |
| 195 | mMouseActor->setMassSpaceInertiaTensor(PxVec3(1.0f, 1.0f, 1.0f)); |
| 196 | |
| 197 | scene.addActor(*mMouseActor); |
| 198 | } |
| 199 | PxRigidActor* pickedActor = static_cast<PxRigidActor*>(mSelectedActor); |
| 200 | |
| 201 | #if USE_D6_JOINT_FOR_MOUSE |
| 202 | mMouseJoint = PxD6JointCreate( physics, |
| 203 | mMouseActor, |
| 204 | PxTransform(PxIdentity), |
| 205 | pickedActor, |
| 206 | PxTransform(pickedActor->getGlobalPose().transformInv(worldImpact))); |
| 207 | mMouseJoint->setMotion(PxD6Axis::eSWING1, PxD6Motion::eFREE); |
| 208 | mMouseJoint->setMotion(PxD6Axis::eSWING2, PxD6Motion::eFREE); |
| 209 | mMouseJoint->setMotion(PxD6Axis::eTWIST, PxD6Motion::eFREE); |
| 210 | #elif USE_SPHERICAL_JOINT_FOR_MOUSE |
| 211 | mMouseJoint = PxSphericalJointCreate(physics, |
| 212 | mMouseActor, |
| 213 | PxTransform(PxIdentity), |
| 214 | pickedActor, |
| 215 | PxTransform(pickedActor->getGlobalPose().transformInv(worldImpact))); |
| 216 | #else |
| 217 | mMouseJoint = PxDistanceJointCreate(physics, |
| 218 | mMouseActor, |
| 219 | PxTransform(PxIdentity), |
| 220 | pickedActor, |
| 221 | PxTransform(pickedActor->getGlobalPose().transformInv(worldImpact))); |
| 222 | mMouseJoint->setMaxDistance(0.0f); |
| 223 | mMouseJoint->setMinDistance(0.0f); |
| 224 | mMouseJoint->setDistanceJointFlags(PxDistanceJointFlag::eMAX_DISTANCE_ENABLED); |
| 225 | #endif |
| 226 | |
| 227 | mDistanceToPicked = (worldImpact - rayOrigin).magnitude(); |
| 228 | } |
| 229 | |
| 230 | //----------------------------------------------------------------------------// |
| 231 |
nothing calls this directly
no test coverage detected