/// <summary> /// Convert from bullet list to serialized math array /// </summary> public static GameSystem.GameCore.SerializableMath.Vector3[] ToSerializableArray(this List <BulletSharp.Math.Vector3> vs) { GameSystem.GameCore.SerializableMath.Vector3[] vectors = new GameSystem.GameCore.SerializableMath.Vector3[vs.Count]; for (int i = 0; i < vs.Count; i++) { vectors[i] = vs[i].ToSerializable(); } return(vectors); }
/// <summary> /// Convert from bullet array to serialized math array /// </summary> public static GameSystem.GameCore.SerializableMath.Vector3[] ToSerializable(this BulletSharp.Math.Vector3[] vs) { GameSystem.GameCore.SerializableMath.Vector3[] vectors = new GameSystem.GameCore.SerializableMath.Vector3[vs.Length]; for (int i = 0; i < vs.Length; i++) { vectors[i] = vs[i].ToSerializable(); } return(vectors); }
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); }
/// <summary> /// Convert from serialized math to bullet /// </summary> public static BulletSharp.Math.Vector3 ToBullet(this GameSystem.GameCore.SerializableMath.Vector3 v) { return(new BulletSharp.Math.Vector3(v.x, v.y, v.z)); }