//x ~ (0, setting.maxX * power(2, subdivision)), z ~ (0, setting.maxZ * power(2, subdivision)) public MPPathNode GetStandablePathNode(int u, int v, ushort refH) { float centerx = 0; float centerz = 0; int subdivision = setting.subdivision; QuadTreeLeaf leaf = GetLeaf(u, v, ref centerx, ref centerz, ref subdivision); if (leaf == null || leaf.Slices == null) { return(null); } for (uint i = (uint)leaf.Slices.Length - 1; i > 0; --i) { ulong currentSlice = leaf.Slices[i]; byte currentf = SliceAccessor.flag(currentSlice); ushort currentheight = SliceAccessor.heightGrade(currentSlice); ulong lowerSlice = leaf.Slices[i - 1]; ushort lowerf = SliceAccessor.flag(lowerSlice); ushort lowerheight = SliceAccessor.heightGrade(lowerSlice); if ((currentf & SliceAccessor.SliceCeiling) > 0) { continue; } if (refH >= currentheight || ((lowerf & SliceAccessor.SliceCeiling) > 0 && refH >= lowerheight)) {//pillar roof return(MPPathNodePool.Pop(leaf.Header, u, v, i, subdivision, setting.subdivision, centerx, centerz, currentSlice)); } } ulong floorSlice = leaf.Slices[0]; return(MPPathNodePool.Pop(leaf.Header, u, v, 0, subdivision, setting.subdivision, centerx, centerz, floorSlice)); }
public void Add(uint header, int dx, int dz, uint ih, int sub, int maxSub, float centerx, float centerz, ulong val) { uint uid = header + ih; if (PathNodeCache != null && PathNodeCache.ContainsKey(uid)) { Add(PathNodeCache[uid]); } else { MPPathNode node = MPPathNodePool.Pop(header, dx, dz, ih, sub, maxSub, centerx, centerz, val); Add(node); //add to mem pool if (PathNodeCache != null) { PathNodeCache.Add(node.UID, node); } } }