public Simulation(float x, float y, float width, float height) { //objects = new Quadtree<Object>(x, y, width, height, 10); objects = new BruteForceBoundingVolumeHierarchy <Object>(); ObjectsProbe = new BVHProbe <Object>(objects); TimeStep = 1 / 60f; // 60 times per second }
public Simulation(float x, float y, float width, float height) { //objects = new Quadtree<Object>(x, y, width, height, 10); objects = new BruteForceBoundingVolumeHierarchy<Object>(); ObjectsProbe = new BVHProbe<Object>(objects); TimeStep = 1 / 60f; // 60 times per second }
public Simulation(Pathing.NavMesh navMesh) { this.NavMesh = navMesh; this.Settings = new Settings(); Running = true; sweepAndPrune = new SweepAndPrune1D <Unit>(false); //staticObjects = new BruteForceBoundingVolumeHierarchy<Object>(); //staticObjects = new Quadtree<Object>(0, 0, width, height, 5); staticObjects = new Quadtree <Object>(10); StaticObjectsProbe = new BVHProbe <Object>(staticObjects); //unitObjects = new BruteForceBoundingVolumeHierarchy<Unit>(); //unitObjects = new Quadtree<Unit>(0, 0, width, height, 5); unitObjects = new Quadtree <Unit>(4); UnitObjectsProbe = new BVHProbe <Unit>(unitObjects); projectiles = new List <Projectile>(); }
public Simulation(Pathing.NavMesh navMesh) { this.NavMesh = navMesh; this.Settings = new Settings(); Running = true; sweepAndPrune = new SweepAndPrune1D<Unit>(false); //staticObjects = new BruteForceBoundingVolumeHierarchy<Object>(); //staticObjects = new Quadtree<Object>(0, 0, width, height, 5); staticObjects = new Quadtree<Object>(10); StaticObjectsProbe = new BVHProbe<Object>(staticObjects); //unitObjects = new BruteForceBoundingVolumeHierarchy<Unit>(); //unitObjects = new Quadtree<Unit>(0, 0, width, height, 5); unitObjects = new Quadtree<Unit>(4); UnitObjectsProbe = new BVHProbe<Unit>(unitObjects); projectiles = new List<Projectile>(); }
private List <Common.Tuple <T, float> > AdvanceHelper <T>(BVHProbe <T> objectsProbe, Vector3 velocity) where T : IObject { var results = new List <Common.Tuple <T, float> >(); Vector3 p0 = Position; Vector3 p1 = Position + velocity; var list = objectsProbe.BVH.Cull(new Bounding.Line(p0, p1)); if (list != null && list.Count > 0) { RayIntersection rOut; foreach (var o in list) { #if MOTION_DEBUG var bvhBounding = objectsProbe.BVH.GetBounding(o); var worldBounding = o.WorldBounding; if (!bvhBounding.Equals(worldBounding)) { throw new Exception("Object world bounding is not the same as the bounding in the BVH"); } #endif bool hit = Intersection.Intersect(o.WorldBounding, new Ray(p0, Vector3.Normalize(velocity)), out rOut); if (hit) { results.Add(new Common.Tuple <T, float>(o, rOut.Distance)); } #if MOTION_DEBUG else { throw new Exception("You shouldn't be able to end up here. Means Cull() and intersect aren't synced. This could be due to your datastructure boundings not being updated properly."); } #endif } } return(results); }
public void InitAfterDeserialization(System.Runtime.Serialization.StreamingContext context) { StaticObjectsProbe = new BVHProbe <Object>(staticObjects); UnitObjectsProbe = new BVHProbe <Unit>(unitObjects); }
public void InitAfterDeserialization(System.Runtime.Serialization.StreamingContext context) { StaticObjectsProbe = new BVHProbe<Object>(staticObjects); UnitObjectsProbe = new BVHProbe<Unit>(unitObjects); }