Esempio n. 1
0
        public static void rayTestSingle(VInt3 fromPos, VInt3 toPos, CollisionObject collisionObject, RayResultCallback resultCallback)
        {
            SphereShape sphereShape    = (SphereShape)collisionObject.getCollisionShape();
            VInt3       objectPosition = collisionObject.getWorldTransform().position;
            VInt3       hitNormal      = VInt3.zero;
            VFixedPoint t0             = VFixedPoint.Zero;

            if (rayTestSphere(fromPos, toPos, objectPosition, sphereShape.getRadius(), ref hitNormal, ref t0))
            {
                resultCallback.addSingleResult(collisionObject, hitNormal.Normalize(), t0);
            }
        }
Esempio n. 2
0
        public static void rayTestSingle(VInt3 fromPos, VInt3 toPos, CollisionObject collisionObject, RayResultCallback resultCallback)
        {
            CapsuleShape capsule = (CapsuleShape)collisionObject.getCollisionShape();
            VInt3        p0      = collisionObject.getWorldTransform().TransformPoint(capsule.getUpAxis() * capsule.getHalfHeight());
            VInt3        p1      = collisionObject.getWorldTransform().TransformPoint(capsule.getUpAxis() * -capsule.getHalfHeight());

            VInt3 normal = VInt3.zero; VFixedPoint t = VFixedPoint.Zero;

            if (raycastCapsule(fromPos, toPos, p0, p1, capsule.getRadius(), ref normal, ref t))
            {
                resultCallback.addSingleResult(collisionObject, normal, t);
            }
        }
Esempio n. 3
0
        public static void rayTestSingle(VInt3 fromPos, VInt3 toPos, CollisionObject collisionObject, RayResultCallback resultCallback)
        {
            VIntTransform collisionObjectTransform = collisionObject.getWorldTransform();

            VFixedPoint t = VFixedPoint.Zero;
            VInt3       normal = VInt3.zero;
            VInt3       aabbMin, aabbMax;

            collisionObject.getCollisionShape().getAabb(VIntTransform.Identity, out aabbMin, out aabbMax);
            if (rayTestBox(fromPos, toPos, aabbMax, collisionObject.getWorldTransform(), ref t, ref normal))
            {
                resultCallback.addSingleResult(collisionObject, normal, t);
            }
        }