public static void objectQuerySingle(CollisionObject castObject, VInt3 ToPos, CollisionObject collisionObject, List <CastResult> results, VFixedPoint allowedPenetration) { SphereShape testShape = (SphereShape)castObject.getCollisionShape(); SphereShape sphereShape = (SphereShape)collisionObject.getCollisionShape(); VIntTransform collisionObjectTransform = collisionObject.getWorldTransform(); VFixedPoint d = VFixedPoint.Zero; VFixedPoint tmp = VFixedPoint.Zero; VInt3 normal = VInt3.zero; if (sphereSphereSweep(testShape.getRadius(), castObject.getWorldTransform().position, ToPos, sphereShape.getRadius(), collisionObjectTransform.position, ref d, ref tmp, ref normal)) { CastResult result = new CastResult(); result.hitObject = collisionObject; result.fraction = d; result.normal = normal; results.Add(result); } }
public static void objectQuerySingle(CollisionObject castObject, VInt3 ToPos, CollisionObject collisionObject, List <CastResult> results, VFixedPoint allowedPenetration) { bool needSwap = castObject.getCollisionShape() is CapsuleShape; CollisionObject sphereObject = needSwap ? collisionObject : castObject; CollisionObject capsuleObject = needSwap ? castObject : collisionObject; SphereShape sphere = (SphereShape)sphereObject.getCollisionShape(); CapsuleShape capsule = (CapsuleShape)capsuleObject.getCollisionShape(); VInt3 toPos = needSwap ? sphereObject.getWorldTransform().position - (ToPos - castObject.getWorldTransform().position) : ToPos; VFixedPoint t = VFixedPoint.Zero; VInt3 normal = VInt3.zero; if (sweepSphereCapsule(sphere, sphereObject.getWorldTransform(), ToPos, capsule, capsuleObject.getWorldTransform(), ref normal, ref t)) { CastResult result = new CastResult(); result.hitObject = collisionObject; result.fraction = t; result.normal = normal * (needSwap ? -1 : 1); results.Add(result); } }
public static void objectQuerySingle(CollisionObject castObject, VInt3 ToPos, CollisionObject collisionObject, List <CastResult> results, VFixedPoint allowedPenetration) { VIntTransform castTransform = castObject.getWorldTransform(); bool needSwap = castObject.getCollisionShape() is BoxShape; BoxShape box = (BoxShape)(needSwap ? castObject.getCollisionShape() : collisionObject.getCollisionShape()); VIntTransform boxTransform = needSwap ? castTransform : collisionObject.getWorldTransform(); SphereShape sphere = (SphereShape)(needSwap ? collisionObject.getCollisionShape() : castObject.getCollisionShape()); VInt3 spherePos = needSwap ? collisionObject.getWorldTransform().position : castObject.getWorldTransform().position; VInt3 toPos = needSwap ? spherePos - (ToPos - castTransform.position) : ToPos; VFixedPoint dist = VFixedPoint.Zero; VInt3 normal = VInt3.zero; if (sweepSphereBox(sphere, spherePos, toPos, box, boxTransform, ref dist, ref normal)) { CastResult result = new CastResult(); result.hitObject = collisionObject; result.fraction = dist; result.normal = normal * (needSwap ? -1 : 1); results.Add(result); } }