public int updateOctantList(int x, int y, int z)
{
int xmin = 0;
int ymin = 0;
int zmin = 0;
List<int> octList = CommonUtility.getOctantIndicesFromVector3 (new remap.NDNMOG.DiscoveryModule.Vector3 (x, y, z));
string octantName = CommonUtility.getStringFromList (octList);
CommonUtility.GetBoundaries (octantName, ref xmin, ref ymin, ref zmin);
List<string> toDelete = new List<string> ();
// naive strategy for untracking octants: for each octants that's not in range, we remove the octants from tracking list
foreach (DictionaryEntry pair in trackedOctant) {
UnityEngine.Vector3 position = (UnityEngine.Vector3)pair.Value;
if (UnityEngine.Vector3.Distance (position, new UnityEngine.Vector3 (x, y, z)) > UnityConstants.distanceThreshold) {
List<int> newOctList = CommonUtility.getOctantIndicesFromVector3 (new remap.NDNMOG.DiscoveryModule.Vector3 (position.x, position.y, position.z));
untrackOctant (newOctList);
toDelete.Add ((string)pair.Key);
}
}
// Separate deletion from traversal so that snapshot does not fall out of sync
foreach (string str in toDelete) {
trackedOctant.Remove (str);
}
// Z direction on one direction does not work correctly, checking out reasons...
if ((x - xmin > 462) && (x + 512 < 65536)) {
List<int> newOctList = CommonUtility.getOctantIndicesFromVector3 (new remap.NDNMOG.DiscoveryModule.Vector3 (x + 512, y, z));
trackOctant (newOctList);
}
if ((x - xmin < 50) && (x - 512 > 0)) {
List<int> newOctList = CommonUtility.getOctantIndicesFromVector3 (new remap.NDNMOG.DiscoveryModule.Vector3 (x - 512, y, z));
trackOctant (newOctList);
}
if ((y - ymin > 462) && (y + 512 < 65536)) {
List<int> newOctList = CommonUtility.getOctantIndicesFromVector3 (new remap.NDNMOG.DiscoveryModule.Vector3 (x, y + 512, z));
trackOctant (newOctList);
}
if ((y - ymin < 50) && (y - 512 > 0)) {
List<int> newOctList = CommonUtility.getOctantIndicesFromVector3 (new remap.NDNMOG.DiscoveryModule.Vector3 (x, y - 512, z));
trackOctant (newOctList);
}
if ((z - zmin > 462) && (z + 512 < 65536)) {
List<int> newOctList = CommonUtility.getOctantIndicesFromVector3 (new remap.NDNMOG.DiscoveryModule.Vector3 (x, y, z + 512));
trackOctant (newOctList);
}
if ((z - zmin < 50) && (z - 512 > 0)) {
List<int> newOctList = CommonUtility.getOctantIndicesFromVector3 (new remap.NDNMOG.DiscoveryModule.Vector3 (x, y, z - 512));
trackOctant (newOctList);
}
return 1;
}