public static JRigidbody[] OverlapMesh(Shape shape, Vector3 position, Quaternion rotation) { var list = new List <JRigidbody>(); JMatrix orientation = rotation.ConvertToJMatrix(), otherOrientation; JVector pos = position.ConvertToJVector(), otherPosition, point, normal; float penetration; foreach (var body in Bodies) { if (body.Key.Shape is Multishape) { continue; } otherPosition = body.Key.Position; otherOrientation = body.Key.Orientation; bool collide = XenoCollide.Detect(shape, body.Key.Shape, ref orientation, ref otherOrientation, ref pos, ref otherPosition, out point, out normal, out penetration); if (collide) { list.Add(body.Value); } } return(list.ToArray()); }
//TODO make this threadsafe. Dangerous code public static bool Raycast(Vector3 origin, Vector3 direction, out JRigidbody body, out Vector3 normal, out float distance) { body = null; normal = Vector3.zero; distance = 0; if (IsInstance) { RigidBody b; JVector n; var v = Instance.World.CollisionSystem.Raycast(origin.ConvertToJVector(), direction.ConvertToJVector(), null, out b, out n, out distance); if (b != null && Bodies.ContainsKey(b)) { body = Bodies[b]; if (body != null) { normal = n; return(v); } } return(false); } return(false); }
public static JRigidbody[] OverlapMesh(Shape shape, Vector3 position, Quaternion rotation) { var list = new List<JRigidbody>(); JMatrix orientation = rotation.ConvertToJMatrix(), otherOrientation; JVector pos = position.ConvertToJVector(),otherPosition, point, normal; float penetration; foreach (var body in Bodies) { if (body.Key.Shape is Multishape) continue; otherPosition = body.Key.Position; otherOrientation = body.Key.Orientation; bool collide = XenoCollide.Detect(shape, body.Key.Shape, ref orientation, ref otherOrientation, ref pos, ref otherPosition, out point, out normal, out penetration); if(collide) list.Add(body.Value); } return list.ToArray(); }
//TODO make this threadsafe. Dangerous code public static bool Raycast(Vector3 origin, Vector3 direction, out JRigidbody body, out Vector3 normal, out float distance) { body = null; normal = Vector3.zero; distance = 0; if (IsInstance) { RigidBody b; JVector n; var v = Instance.World.CollisionSystem.Raycast(origin.ConvertToJVector(), direction.ConvertToJVector(), null, out b, out n, out distance); if (b != null && Bodies.ContainsKey(b)) { body = Bodies[b]; if (body != null) { normal = n; return v; } } return false; } return false; }
public void AddImpulse(Vector3 impulse, Vector3 relativePosition) { Body.ApplyImpulse(impulse.ConvertToJVector(), relativePosition.ConvertToJVector()); }
public void AddImpulse(Vector3 impulse) { Body.ApplyImpulse(impulse.ConvertToJVector()); }
public void AddTorque(Vector3 torque) { Body.AddTorque(torque.ConvertToJVector()); }
public void AddForceAtPosition(Vector3 force, Vector3 position) { Body.AddForce(force.ConvertToJVector(), position.ConvertToJVector()); }
public void AddForce(Vector3 force) { Body.AddForce(force.ConvertToJVector()); }