/// <summary> /// </summary> /// <param name="entry"> /// </param> /// <param name="block"> /// </param> public static void CreationFuncForSubMeshes(SubMesh entry, OctreeBlock <SubMesh> block) { if (entry.getBoundingInfo().boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) { block.entries.Add(entry); } }
/// <summary> /// </summary> /// <param name="worldMin"> /// </param> /// <param name="worldMax"> /// </param> /// <param name="entries"> /// </param> /// <param name="maxBlockCapacity"> /// </param> /// <param name="currentDepth"> /// </param> /// <param name="maxDepth"> /// </param> /// <param name="target"> /// </param> /// <param name="creationFunc"> /// </param> public static void _CreateBlocks( Vector3 worldMin, Vector3 worldMax, Array <T> entries, int maxBlockCapacity, int currentDepth, int maxDepth, IOctreeContainer <T> target, Action <T, OctreeBlock <T> > creationFunc) { target.blocks = new Array <OctreeBlock <T> >(); var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2); for (var x = 0; x < 2; x++) { for (var y = 0; y < 2; y++) { for (var z = 0; z < 2; z++) { var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z)); var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1)); var block = new OctreeBlock <T>(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc); block.addEntries(entries); target.blocks.Add(block); } } } }