public static void Correct(JRigidbody body) { lock (CorPool) { if (!CorPool.Contains(body)) CorPool.Add(body); } }
public static void AddBody(JRigidbody body) { CheckInstance(); lock (BodyPool) { if (!BodyPool.Contains(body)) BodyPool.Add(body); } lock (Bodies) if (!Bodies.ContainsValue(body)) Bodies.Add(body.Body, body); }
public static void Correct(JRigidbody body) { lock (CorPool) { if (!CorPool.Contains(body)) { CorPool.Add(body); } } }
void OnEnable() { shape = MakeShape(); cacheTransform = transform; if (Rigidbody == null) { rigidbody = gameObject.AddComponent <JRigidbody>(); rigidbody.Damping = JRigidbody.DampingType.None; rigidbody.UseGravity = false; rigidbody.IsStatic = true; rigidbody.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector; } }
public static void RemoveBody(JRigidbody body) { lock (BodyPoolToRemove) { if (!BodyPoolToRemove.Contains(body)) { BodyPoolToRemove.Add(body); } } lock (Bodies) if (!Bodies.ContainsValue(body)) { Bodies.Remove(body.Body); } }
public static void AddBody(JRigidbody body) { CheckInstance(); lock (BodyPool) { if (!BodyPool.Contains(body)) { BodyPool.Add(body); } } lock (Bodies) if (!Bodies.ContainsValue(body)) { Bodies.Add(body.Body, body); } }
//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 void RemoveBody(JRigidbody body) { lock (BodyPoolToRemove) { if (!BodyPoolToRemove.Contains(body)) BodyPoolToRemove.Add(body); } lock (Bodies) if (!Bodies.ContainsValue(body)) Bodies.Remove(body.Body); }
//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; }
void OnEnable() { shape = MakeShape(); cacheTransform = transform; if (Rigidbody == null) { rigidbody = gameObject.AddComponent<JRigidbody>(); rigidbody.Damping = JRigidbody.DampingType.None; rigidbody.UseGravity = false; rigidbody.IsStatic = true; rigidbody.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector; } }