How to activate entities around a physics change
Posted: Wed Jul 03, 2013 7:08 pm
Hi!
I am trying to make entities react to semi-static physics entities change. This is almost always terrain, but sometimes some other static can disappear or move.
This is a quite difficult task, so I decided to start fresh and easy, using raycast to determine the terrain intersection, updating the terrain and the computing a bounding box around the intersection point. For every entity intersecting the box, I would like to activate it. A more advanced solution will be needed, but first let's see how BEPU reacts to this. Suspended objects should fall and objects that are deep inside another object will either slowly rise up, of fall through.
But I am having problems with activating the entities. More precisely, I don't know how to get the entity. Bellow I'll list a pseudocode which obviously doesn't compile with my approach:
Which is the proper way of getting the entity that intersected the box?
Thank you!
I am trying to make entities react to semi-static physics entities change. This is almost always terrain, but sometimes some other static can disappear or move.
This is a quite difficult task, so I decided to start fresh and easy, using raycast to determine the terrain intersection, updating the terrain and the computing a bounding box around the intersection point. For every entity intersecting the box, I would like to activate it. A more advanced solution will be needed, but first let's see how BEPU reacts to this. Suspended objects should fall and objects that are deep inside another object will either slowly rise up, of fall through.
But I am having problems with activating the entities. More precisely, I don't know how to get the entity. Bellow I'll list a pseudocode which obviously doesn't compile with my approach:
Code: Select all
if (RayCastFromCamera(out rcr, World.TERRAIN)) {
EditTerrain.EpdateHeightsAtAP(terrain, rcr.HitData.Location, gameTime, HF, chunkAlloc);
BoundingBox box = new BoundingBox();
box.Min = rcr.HitData.Location - new Vector3(30, 50, 30);
box.Max = rcr.HitData.Location + new Vector3(30, 150, 30);
List<BroadPhaseEntry> overlaps = new List<BroadPhaseEntry>();
Space.BroadPhase.QueryAccelerator.GetEntries(box, overlaps);
foreach (BroadPhaseEntry b in overlaps) {
if (b is ConvexCollidable<CylinderShape>) {
Cylinder c = (Cylinder)b;
c.ActivityInformation.Activate();
}
}
}
Thank you!