public ColliderManager(AABox area, int depth = 5) { root = new Node(area); for (int i = 0; i < depth; i++) { root.Subdivide(); } }
public void Subdivide() { if (children.Count == 0) { AABox[] subBoxes = new AABox[8]; AABox.Subdivide(volume, subBoxes); for (int i = 0; i < 8; i++) { Node subNode = new Node(subBoxes[i]); children.Add(subNode); } } else { for (int i = 0; i < children.Count; i++) { children[i].Subdivide(); } } }
public bool Intersect(LineTestData intersectData, out EntityID entity) { entity = this.entity; //First test if the bounds intersect if (!AABox.Intersect(box, intersectData.TestBounds)) { return(false); } //Then test if the ray intersects float rayTime; if (!AABox.Intersect(box, intersectData.TestRay, out rayTime)) { return(false); } //Then test if that ray was still within the line return(intersectData.TestLine.SqrMagnitude >= (rayTime * rayTime)); }
public bool Intersect(AABox box, out EntityID entity) { if (AABox.Intersect(volume, box)) { for (int i = 0; i < children.Count; i++) { if (children[i].Intersect(box, out entity)) { return(true); } } for (int i = 0; i < entries.Count; i++) { if (entries[i].Intersect(box, out entity)) { return(true); } } } entity = 0; return(false); }
public bool Intersect(LineTestData intersectData, out EntityID entity) { if (AABox.Intersect(volume, intersectData.TestBounds)) { for (int i = 0; i < children.Count; i++) { if (children[i].Intersect(intersectData, out entity)) { return(true); } } for (int i = 0; i < entries.Count; i++) { if (entries[i].Intersect(intersectData, out entity)) { return(true); } } } entity = 0; return(false); }
public bool Intersect(AABox box, out EntityID entity) { return(root.Intersect(box, out entity)); }
public void Add(AABox box, EntityID entity) { root.Add(new Entry(box, entity)); }
public bool Intersect(AABox box, out EntityID entity) { entity = this.entity; return(AABox.Intersect(this.box, box)); }
public bool Intersect(AABox box) => AABox.Intersect(this.box, box);
public Entry(AABox box, EntityID entity) { this.box = box; this.entity = entity; }
public LineTestData(Line testLine) { TestLine = testLine; TestBounds = testLine.GetBounds(); TestRay = testLine.GetRay(); }
public static bool Intersect(AABox a, AABox b) => a.Min.x <b.Max.x && a.Max.x> b.Min.x && a.Min.y <b.Max.y && a.Max.y> b.Min.y && a.Min.z <b.Max.z && a.Max.z> b.Min.z;
public static bool Contains(AABox box, Vector3 point) => point.x > box.Min.x && point.x <box.Max.x && point.y> box.Min.y && point.y <box.Max.y && point.z> box.Min.z && point.z < box.Max.z;