Vector3 min = new Vector3(-10, -10, -10); Vector3 max = new Vector3(10, 10, 10); octree = new Octree(min, max, MAX_DEPTH, MAX_ITEMS_PER_NODE, new Octree.Collider () { @Override public boolean intersects (BoundingBox nodeBounds, GameObject geometry) { return nodeBounds.intersects(geometry.box); } @Override public boolean intersects (Frustum frustum, GameObject geometry) { return frustum.boundsInFrustum(geometry.box); } @Override public float intersects (Ray ray, GameObject geometry) { if (Intersector.intersectRayBounds(ray, geometry.box, new Vector3())) { return tmp.dst2(ray.origin); } return Float.MAX_VALUE; } }); // Adding game objects to the octree octree.add(gameObject1); octree.add(gameObject2); // Querying the result ObjectSet result = new ObjectSet<>(); octree.query(cam.frustum, result); // Rendering the result for (GameObject gameObject : result) { modelBatch.render(gameObject); }
| Modifier and Type | Class and Description |
|---|---|
| public static interface | Octree.
Interface used by octree to handle geometries' collisions against BoundingBox, Frustum and Ray. |
| protected class | |
| public static class |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final Octree. | |
| pack-priv final int | |
| pack-priv final Pool | |
| protected Octree | |
| pack-priv static final Vector3 |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| pack-priv Octree | |
| public ObjectSet | |
| public ObjectSet | |
| public ObjectSet | query(BoundingBox
- The bounding box to query aabb, ObjectSet<T> - Set to be populated with objects inside the BoundingBoxes result)Method to query geometries inside nodes that the aabb intersects. |
| public ObjectSet | |
| public T | |
| public void | |
| public void |
| collider | back to summary |
|---|---|
| pack-priv final Octree. | |
| maxItemsPerNode | back to summary |
|---|---|
| pack-priv final int maxItemsPerNode | |
| nodePool | back to summary |
|---|---|
| pack-priv final Pool<Octree<T>. | |
| root | back to summary |
|---|---|
| protected Octree<T>. | |
| tmp | back to summary |
|---|---|
| pack-priv static final Vector3 tmp | |
| Octree | back to summary |
|---|---|
| public Octree(Vector3 minimum, Vector3 maximum, int maxDepth, int maxItemsPerNode, Octree. | |
| add | back to summary |
|---|---|
| public void add(T object) | |
| createNode | back to summary |
|---|---|
| pack-priv Octree | |
| getAll | back to summary |
|---|---|
| public ObjectSet Method to retrieve all the geometries.
| |
| getNodesBoxes | back to summary |
|---|---|
| public ObjectSet Method to get nodes as bounding boxes. Useful for debug purpose. | |
| query | back to summary |
|---|---|
| public ObjectSet Method to query geometries inside nodes that the aabb intersects. Can be used as broad phase.
| |
| query | back to summary |
|---|---|
| public ObjectSet Method to query geometries inside nodes that the frustum intersects. Can be used as broad phase. | |
| rayCast | back to summary |
|---|---|
| public T rayCast(Ray ray, Octree. | |
| remove | back to summary |
|---|---|
| public void remove(T object) | |
| update | back to summary |
|---|---|
| public void update(T object) | |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: if they are intersectingMethod to calculate intersection between aabb and the geometry. |
| public boolean | Returns: if they are intersectingMethod to calculate intersection between frustum and the geometry. |
| public float | Returns: distance between ray and geometryMethod to calculate intersection between ray and the geometry. |
| intersects | back to summary |
|---|---|
| public boolean intersects(BoundingBox nodeBounds, T geometry) Method to calculate intersection between aabb and the geometry.
| |
| intersects | back to summary |
|---|---|
| public boolean intersects(Frustum frustum, T geometry) Method to calculate intersection between frustum and the geometry.
| |
| intersects | back to summary |
|---|---|
| public float intersects(Ray ray, T geometry) Method to calculate intersection between ray and the geometry.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final BoundingBox | |
| private Octree. | |
| private final Array | |
| pack-priv boolean | |
| pack-priv int |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| protected void | |
| private void | |
| private void | |
| protected void | |
| protected void | |
| protected boolean | |
| private void | |
| protected void | |
| protected void | |
| protected void | |
| protected boolean | |
| private void |
| bounds | back to summary |
|---|---|
| pack-priv final BoundingBox bounds | |
| children | back to summary |
|---|---|
| private Octree. | |
| geometries | back to summary |
|---|---|
| private final Array<T> geometries | |
| leaf | back to summary |
|---|---|
| pack-priv boolean leaf | |
| level | back to summary |
|---|---|
| pack-priv int level | |
| OctreeNode | back to summary |
|---|---|
| protected OctreeNode() | |
| add | back to summary |
|---|---|
| protected void add(T geometry) | |
| clearChildren | back to summary |
|---|---|
| private void clearChildren() | |
| free | back to summary |
|---|---|
| private void free() | |
| getAll | back to summary |
|---|---|
| protected void getAll(ObjectSet<T> resultSet) Get all geometries using Depth-First Search recursion. | |
| getBoundingBox | back to summary |
|---|---|
| protected void getBoundingBox(ObjectSet<BoundingBox> bounds) Get bounding boxes using Depth-First Search recursion. | |
| isLeaf | back to summary |
|---|---|
| protected boolean isLeaf() | |
| merge | back to summary |
|---|---|
| private void merge() | |
| query | back to summary |
|---|---|
| protected void query(BoundingBox aabb, ObjectSet<T> result) | |
| query | back to summary |
|---|---|
| protected void query(Frustum frustum, ObjectSet<T> result) | |
| rayCast | back to summary |
|---|---|
| protected void rayCast(Ray ray, Octree. | |
| remove | back to summary |
|---|---|
| protected boolean remove(T object) | |
| split | back to summary |
|---|---|
| private void split() | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv float | |
| pack-priv T | |
| pack-priv float |
| Access | Constructor and Description |
|---|---|
| public |
| distance | back to summary |
|---|---|
| pack-priv float distance | |
| geometry | back to summary |
|---|---|
| pack-priv T geometry | |
| maxDistanceSq | back to summary |
|---|---|
| pack-priv float maxDistanceSq | |
| RayCastResult | back to summary |
|---|---|
| public RayCastResult() | |