public UpdateBoundingBoxForTransform ( |
||
transform | Transform to use for the collidable. | |
return | void |
private void PrepareQueryObject(EntityCollidable queryObject, ref Vector3 position) { RigidTransform transform; transform.Position = position; transform.Orientation = characterBody.Orientation; queryObject.UpdateBoundingBoxForTransform(ref transform, 0); }
void QueryContacts(Vector3 position, EntityCollidable queryObject) { ClearContacts(); //Update the position and orientation of the query object. RigidTransform transform; transform.Position = position; transform.Orientation = character.Body.Orientation; queryObject.UpdateBoundingBoxForTransform(ref transform, 0); foreach (var collidable in character.Body.CollisionInformation.OverlappedCollidables) { if (collidable.BoundingBox.Intersects(queryObject.BoundingBox)) { var pair = new CollidablePair(collidable, queryObject); var pairHandler = NarrowPhaseHelper.GetPairHandler(ref pair); if (pairHandler.CollisionRule == CollisionRule.Normal) { pairHandler.SuppressEvents = true; pairHandler.UpdateCollision(0); pairHandler.SuppressEvents = false; foreach (var contact in pairHandler.Contacts) { //Must check per-contact collision rules, just in case //the pair was actually a 'parent pair.' if (contact.Pair.CollisionRule == CollisionRule.Normal) { ContactData contactData; contactData.Position = contact.Contact.Position; contactData.Normal = contact.Contact.Normal; contactData.Id = contact.Contact.Id; contactData.PenetrationDepth = contact.Contact.PenetrationDepth; contacts.Add(contactData); } } } //TODO: It would be nice if this was a bit easier. //Having to remember to clean up AND give it back is a bit weird, especially with the property-diving. //No one would ever just guess this correctly. //At least hide it behind a NarrowPhaseHelper function. pairHandler.CleanUp(); pairHandler.Factory.GiveBack(pairHandler); } } CategorizeContacts(ref position); }