| 71 | } |
| 72 | |
| 73 | static PxReal computeInternalRadius(PxRigidActor* actor, PxShape* shape, const PxVec3& dir, /*PxVec3& offset,*/ const PxVec3& centerOffset) |
| 74 | { |
| 75 | const PxBounds3 bounds = PxShapeExt::getWorldBounds(*shape, *actor); |
| 76 | const PxReal diagonal = (bounds.maximum - bounds.minimum).magnitude(); |
| 77 | const PxReal offsetFromOrigin = diagonal * 2.0f; |
| 78 | |
| 79 | PxTransform pose = PxShapeExt::getGlobalPose(*shape, *actor); |
| 80 | |
| 81 | PxReal internalRadius = 0.0f; |
| 82 | const PxReal length = offsetFromOrigin*2.0f; |
| 83 | |
| 84 | // PT: we do a switch here anyway since the code is not *exactly* the same all the time |
| 85 | { |
| 86 | switch(shape->getGeometryType()) |
| 87 | { |
| 88 | case PxGeometryType::eBOX: |
| 89 | case PxGeometryType::eCAPSULE: |
| 90 | { |
| 91 | pose.p = PxVec3(0); |
| 92 | const PxVec3 virtualOrigin = pose.p + dir * offsetFromOrigin; |
| 93 | |
| 94 | PxRaycastHit hit; |
| 95 | |
| 96 | const PxHitFlags sceneQueryFlags = PxHitFlag::ePOSITION|PxHitFlag::eNORMAL; |
| 97 | PxU32 nbHits = PxGeometryQuery::raycast(virtualOrigin, -dir, shape->getGeometry().any(), pose, length, sceneQueryFlags, 1, &hit); |
| 98 | PX_UNUSED(nbHits); |
| 99 | PX_ASSERT(nbHits); |
| 100 | |
| 101 | internalRadius = offsetFromOrigin - hit.distance; |
| 102 | // offset = PxVec3(0.0f); |
| 103 | } |
| 104 | break; |
| 105 | |
| 106 | case PxGeometryType::eSPHERE: |
| 107 | { |
| 108 | PxSphereGeometry geometry; |
| 109 | bool status = shape->getSphereGeometry(geometry); |
| 110 | PX_UNUSED(status); |
| 111 | PX_ASSERT(status); |
| 112 | |
| 113 | internalRadius = geometry.radius; |
| 114 | // offset = PxVec3(0.0f); |
| 115 | } |
| 116 | break; |
| 117 | |
| 118 | case PxGeometryType::eCONVEXMESH: |
| 119 | { |
| 120 | /*PxVec3 saved = pose.p; |
| 121 | pose.p = PxVec3(0); |
| 122 | |
| 123 | // pose.p = geometry.convexMesh->getCenterOfMass(); |
| 124 | // const PxVec3 virtualOrigin = pose.p + dir * offsetFromOrigin; |
| 125 | |
| 126 | // const PxVec3 localCenter = computeCenter(geometry.convexMesh); |
| 127 | // const PxVec3 localCenter = geometry.convexMesh->getCenterOfMass(); |
| 128 | // const PxVec3 virtualOrigin = pose.rotate(localCenter) + dir * offsetFromOrigin; |
| 129 | const PxVec3 localCenter = pose.rotate(geometry.convexMesh->getCenterOfMass()); |
| 130 | const PxVec3 virtualOrigin = localCenter + dir * offsetFromOrigin; |
no test coverage detected