B45ChunkData CreateChunk(IntVector4 index) { B45ChunkData chunk = new B45ChunkData(colliderMan); chunk.BuildList = _chunkRebuildList; writeChunk(index.x, index.y, index.z, chunk); chunk.ChunkPosLod_w = new IntVector4( (index.x), (index.y), (index.z), 0); chunk.bp(); chunk.AddToBuildList(); // make the bv node. if (true) { IntVector3 shiftVec = IntVector3.Zero; shiftVec.x = index.x << Block45Constants._shift; shiftVec.y = index.y << Block45Constants._shift; shiftVec.z = index.z << Block45Constants._shift; try{ // Add try for StackOverflowException BlockVectorNode newRootNode = bvtRoot.reroot(shiftVec); bvtRoot = newRootNode; } catch (Exception e) { Debug.LogWarning("Unexpected exception while creating chunk to" + index + e); return(chunk); } BlockVectorNode bvNode = BlockVectorNode.readNode(shiftVec, bvtRoot); if (bvNode.chunk != null) { // already a chunk has been assigned to this node. something is wrong here. return(chunk); } bvNode.chunk = chunk; chunk._bvNode = bvNode; bvNode.isByteArrayMode = true; } return(chunk); }
B45ChunkData CreateChunk(IntVector3 index) { //LODOctreeNode tmpNode = new LODOctreeNode(null, 0, // new IntVector3( // (index.x<<Block45Constants._shift) / Block45Constants._scaleInverted, // (index.y<<Block45Constants._shift) / Block45Constants._scaleInverted, // (index.z<<Block45Constants._shift) / Block45Constants._scaleInverted)); //B45ChunkData chunk = new B45ChunkData(tmpNode, new byte[B45Block.Block45Size]); B45ChunkData chunk = new B45ChunkData(new byte[B45Block.Block45Size]); chunk.BuildList = _chunkRebuildList; writeChunk(index.x, index.y, index.z, chunk); chunk.ChunkPosLod_w = new IntVector4( (index.x), (index.y), (index.z), 0); // chunk.ChunkPosLod_w = new IntVector4((x<<Block45Constants._shift) * Block45Constants._scale, // (y<<Block45Constants._shift) * Block45Constants._scale, // (z<<Block45Constants._shift) * Block45Constants._scale, 0); chunk.AddToBuildList(); return(chunk); }