void FixedUpdate() { if (IsTrigger) { JMatrix otherOrientation; JVector otherPosition, point, normal; float penetration; foreach (var body in JPhysics.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 position, ref otherPosition, out point, out normal, out penetration); var i = new TriggerInfo { Body = body.Value, Point = point, Normal = normal, Penetration = penetration }; if (collide && !collidingBodies.ContainsKey(body.Key)) { collidingBodies.Add(body.Key, body.Value); if (TriggerEnter != null) { TriggerEnter(i); } } else if (!collide && collidingBodies.ContainsKey(body.Key)) { collidingBodies.Remove(body.Key); if (TriggerExit != null) { TriggerExit(i); } } else if (collide && collidingBodies.ContainsKey(body.Key)) { if (TriggerStay != null) { TriggerStay(i); } } } } }
void FixedUpdate() { if (IsTrigger) { JMatrix otherOrientation; JVector otherPosition, point, normal; float penetration; foreach (var body in JPhysics.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 position, ref otherPosition, out point, out normal, out penetration); var i = new TriggerInfo { Body = body.Value, Point = point, Normal = normal, Penetration = penetration }; if (collide && !collidingBodies.ContainsKey(body.Key)) { collidingBodies.Add(body.Key, body.Value); if (TriggerEnter != null) TriggerEnter(i); } else if (!collide && collidingBodies.ContainsKey(body.Key)) { collidingBodies.Remove(body.Key); if (TriggerExit != null) TriggerExit(i); } else if (collide && collidingBodies.ContainsKey(body.Key)) if (TriggerStay != null) TriggerStay(i); } } }