public override bool Raycast(GameSystem.GameCore.SerializableMath.Vector3 startPoint, GameSystem.GameCore.SerializableMath.Vector3 endPoint, out GameSystem.GameCore.SerializableMath.Vector3[] hitPoint, out CollisionProxy[] hitObject, int mask = -1) { // transfer serializable math position to bullet math position BulletSharp.Math.Vector3 start = startPoint.ToBullet(), end = endPoint.ToBullet(); var callback = new AllHitsRayResultCallback(start, end); // set group mask filter callback.CollisionFilterMask = (short)mask; world.RayTest(start, end, callback); if (callback.HasHit) { hitPoint = callback.HitPointWorld.ToSerializableArray(); hitObject = callback.CollisionObjects.SelectToArray(colObj => (CollisionProxy)colObj.UserObject); } else { hitPoint = new GameSystem.GameCore.SerializableMath.Vector3[0]; hitObject = new CollisionProxy[0]; } return(callback.HasHit); }
public override bool Raycast(GameSystem.GameCore.SerializableMath.Vector3 startPoint, GameSystem.GameCore.SerializableMath.Vector3 endPoint, out GameSystem.GameCore.SerializableMath.Vector3 hitPoint, out CollisionProxy hitObject, int mask = -1) { // transfer serializable math position to bullet math position BulletSharp.Math.Vector3 start = startPoint.ToBullet(), end = endPoint.ToBullet(); var callback = new ClosestRayResultCallback(ref start, ref end); // set group mask filter callback.CollisionFilterMask = (short)mask; world.RayTest(start, end, callback); if (callback.HasHit) { hitPoint = callback.HitPointWorld.ToSerializable(); hitObject = (CollisionProxy)callback.CollisionObject.UserObject; } else { hitPoint = GameSystem.GameCore.SerializableMath.Vector3.Zero; hitObject = null; } return(callback.HasHit); }