RaycastHit Scene::raycastClosestShape(const Ray& ray, Enums::ShapesType type, unsigned int group, Real maxDistance, unsigned int hintFlags, RaycastCache cache) const { NxRay inRay; Functions::XYZ<Vec3, NxVec3>(ray.mDirection, inRay.dir); Functions::XYZ<Vec3, NxVec3>(ray.mOrigin, inRay.orig); NxRaycastHit hit; NxShape* nxShape = mScene->raycastClosestShape(inRay, NxShapesType(int(type)), hit, group, maxDistance, hintFlags, 0, cache); RaycastHit out; out.mDistance = hit.distance; out.mFaceID = hit.faceID; out.mFlags = hit.flags; out.mInternalFaceID = hit.internalFaceID; out.mMaterialIndex = hit.materialIndex; out.mU = hit.u; out.mV = hit.v; Functions::XYZ<NxVec3, Vec3>(hit.worldImpact, out.mWorldImpact); Functions::XYZ<NxVec3, Vec3>(hit.worldNormal, out.mWorldNormal); if (nxShape) { PhysXPointer* shapePointer = pointer_cast(nxShape->userData); out.mShape = shapePointer->get<Shape>(); out.mRigidBody = shapePointer->getParent<RigidBody>(); } else { out.mShape = 0; out.mRigidBody = 0; } return out; }
void RigidBody::destroy(void) { if (mActor) { PhysXPointer* ptr = pointer_cast(mActor->userData); NxOgre_Delete(ptr); NxScene& scene = mActor->getScene(); scene.releaseActor(*mActor); } }