private OctagonalVector AllocateLowerBoundRoot(OctagonalVector v) { OctagonalVector dV = v - _rootVector; OctagonalVector oldRoot = new OctagonalVector( (dV.X < 0) ? ((-dV.X - 1) >> _depth) + 1 : 0, (dV.Y < 0) ? ((-dV.Y - 1) >> _depth) + 1 : 0, (dV.Z < 0) ? ((-dV.Z - 1) >> _depth) + 1 : 0); List <int> oldRootPath = oldRoot.CalculatePath(); int oldRootPathLength = oldRootPath.Count(); if (oldRootPathLength > 0) { for (int i = 0; i < oldRootPathLength; i++) { _root = new Octant(oldRootPath[i], _root); } _rootVector -= oldRoot << _depth; _depth += oldRootPathLength; } return(dV); }
public OctagonalVector AllocateNode(OctagonalVector v, OctantNode node) { lock (this) { if (_root == null) { _rootVector = v; _depth = 0; _root = node; return(new OctagonalVector(0, 0, 0)); } OctagonalVector dV = AllocateLowerBoundRoot(v); AllocateVector(dV.CalculatePath(), node); return(dV); } }