public static SimWaypoint CreateLocal(Vector3 from, CollisionPlane CP)
        {
            SimPathStore   PathStore        = CP.PathStore;
            float          POINTS_PER_METER = PathStore.POINTS_PER_METER;
            int            PX = PathStore.ARRAY_X(from.X);
            int            PY = PathStore.ARRAY_Y(from.Y);
            SimWaypoint    WP;
            CollisionIndex CI = CollisionIndex.CreateCollisionIndex(from, PathStore);

            lock (CI)
            {
                WP = CI.FindWayPoint(from.Z);
                if (WP != null)
                {
                    return(WP);
                }
                from.X = PX / POINTS_PER_METER;
                from.Y = PY / POINTS_PER_METER;
                Vector3d GlobalPos = PathStore.LocalToGlobal(from);
                if (GlobalPos.X < 256 || GlobalPos.Y < 256)
                {
                    CollisionPlane.Debug("bad global " + GlobalPos);
                }
                WP            = new SimWaypointImpl(from, GlobalPos, CI, CP, PathStore);
                WP.IsPassable = true;
            }
            // wp._IncomingArcs = new ArrayList();
            // wp._OutgoingArcs = new ArrayList();
            //  PathStore.EnsureKnown(wp);
            return(WP);
        }
 private SimWaypointImpl(Vector3 local, Vector3d global, CollisionIndex Ci, CollisionPlane Cp, SimPathStore pathStore)
 {
     _MinZ      = local.Z;
     _MaxZ      = _MinZ + 1.5f;
     CIndex     = Ci;
     _Plane     = Cp;
     _PathStore = pathStore;
     _GlobalPos = global;// RoundPoint(firstP, PathStore);
     _LocalPos  = local;
     //PX = PX0;
     //PY = PY0;
     //PathStore.SimWaypoint[PX, PY] = this;
     //TaintMatrix();
     //UpdateMatrix(pathStore.GL);
     _Passable     = true;
     _IncomingArcs = null;
     _OutgoingArcs = null;
 }
        public float DefaultHeight(int y, int x, float[,] GroundPlane, float[,] Heights, CollisionIndex[,] MeshIndex)
        {
            float gp        = GroundPlane[x, y];
            float testPlane = gp;

            CollisionIndex W = MeshIndex[x, y];

            if (W == null)
            {
                return(testPlane);
            }

            if (testPlane + 2f < MinZ)
            {
                testPlane = MinZ - 2;
            }
            //Heights[x, y] = testPlane;
            return(W.GetZLevel(testPlane, testPlane + 16f, CollisionIndex.AvatarCapsuleZ));
        }
        public static CollisionIndex CreateCollisionIndex(Vector3 from, SimPathStore PathStore)
        {
            float          POINTS_PER_METER = PathStore.POINTS_PER_METER;
            int            PX = PathStore.ARRAY_X(from.X);
            int            PY = PathStore.ARRAY_Y(from.Y);
            CollisionIndex WP;

            lock (PathStore.MeshIndex)
            {
                WP = PathStore.MeshIndex[PX, PY];
                if (WP != null)
                {
                    return(WP);
                }
                from.X = PX / POINTS_PER_METER;
                from.Y = PY / POINTS_PER_METER;
                Vector3d GlobalPos = PathStore.GetPathStore().LocalToGlobal(from);
                WP = new CollisionIndex(from, GlobalPos, PX, PY, PathStore);
            }
            return(WP);
        }
示例#5
0
 public static CollisionIndex CreateCollisionIndex(Vector3 from, SimPathStore PathStore)
 {
     float POINTS_PER_METER = PathStore.POINTS_PER_METER;
     int PX = PathStore.ARRAY_X(from.X);
     int PY = PathStore.ARRAY_Y(from.Y);
     CollisionIndex WP;
     lock (PathStore.MeshIndex)
     {
         WP = PathStore.MeshIndex[PX, PY];
         if (WP != null) return WP;
         from.X = PX / POINTS_PER_METER;
         from.Y = PY / POINTS_PER_METER;
         Vector3d GlobalPos = PathStore.GetPathStore().LocalToGlobal(from);
         WP = new CollisionIndex(from, GlobalPos, PX, PY, PathStore);
     }
     return WP;
 }
示例#6
0
        public float DefaultHeight(int y, int x, float[,] GroundPlane, float[,] Heights, CollisionIndex[,] MeshIndex)
        {
            float gp = GroundPlane[x, y];
            float testPlane = gp;

            CollisionIndex W = MeshIndex[x, y];
            if (W == null) return testPlane;

            if (testPlane + 2f < MinZ)
            {
                testPlane = MinZ - 2;
            }
            //Heights[x, y] = testPlane;
            return W.GetZLevel(testPlane, testPlane + 16f, CollisionIndex.AvatarCapsuleZ);
        }
示例#7
0
        internal int NeighborLevelDifLessThan(float low, float high, float originZ, int PX, int PY, 
            float[,] heights, CollisionIndex[,] cI, CollisionObject collisionObject, float mostDiff,
            bool objToNothingBump, bool objToSelfBump)
        {
            float O = NeighborLevel(low, high, originZ, PX, PY, heights);

            if (objToSelfBump)
            {
                if (collisionObject != null)
                {
                    var FO = cI[PX, PY];
                    if (FO != null)
                    {
                        var fO = FO.GetObjectAt(O);
                        if (fO == collisionObject) return 1;
                        if (FO.Contains(collisionObject)) return 1;
                    }
                }
                return 0;
            }
            if (objToNothingBump)
            {
                var FO = cI[PX, PY];
                if (collisionObject != null)
                {
                    if (FO == null) return 1;                   
                    var fO = FO.GetObjectAt(O);
                    if (fO != collisionObject) return 1;
                    return 0;
                }
                else
                {                   
                    if (FO == null) return 0;                   
                    var fO = FO.GetObjectAt(O);
                    if (fO != null) return 1;
                    return 0;
                }
                return 0;
            }


            if (!DiffLessThan(O, originZ, mostDiff))
            {
                if (collisionObject != null)
                {
                    var FO = cI[PX, PY];
                    if (FO != null)
                    {
                        var fO = FO.GetObjectAt(O);
                        if (fO == collisionObject) return 0;
                        // experimental
                        //if (FO.Contains(collisionObject)) return 0;
                    }
                }
                return 1;
            }
            return 0;
        }
示例#8
0
        public int NeighborBump(int PX, int PY, float low, float high, float originZ, float mostDiff,
            float[,] heights, CollisionIndex[,] cI, CollisionObject collisionObject, bool objToNothingBump, bool objToSelfBump)
        {
            int found = 0;

            found += NeighborLevelDifLessThan(low, high, originZ, PX, PY + 1, heights, cI,
                                              collisionObject, mostDiff, objToNothingBump, objToSelfBump);
            found += NeighborLevelDifLessThan(low, high, originZ, PX + 1, PY + 1, heights, cI,
                                              collisionObject, mostDiff, objToNothingBump, objToSelfBump);
            found += NeighborLevelDifLessThan(low, high, originZ, PX + 1, PY, heights, cI,
                                              collisionObject, mostDiff, objToNothingBump, objToSelfBump);
            found += NeighborLevelDifLessThan(low, high, originZ, PX, PY - 1, heights, cI,
                                              collisionObject, mostDiff, objToNothingBump, objToSelfBump);
            found += NeighborLevelDifLessThan(low, high, originZ, PX - 1, PY - 1, heights, cI,
                                              collisionObject, mostDiff, objToNothingBump, objToSelfBump);
            found += NeighborLevelDifLessThan(low, high, originZ, PX - 1, PY, heights, cI,
                                              collisionObject, mostDiff, objToNothingBump, objToSelfBump);
            found += NeighborLevelDifLessThan(low, high, originZ, PX + 1, PY - 1, heights, cI,
                                              collisionObject, mostDiff, objToNothingBump, objToSelfBump);
            found += NeighborLevelDifLessThan(low, high, originZ, PX - 1, PY + 1, heights, cI,
                                              collisionObject, mostDiff, objToNothingBump, objToSelfBump);
            return found;
        }
示例#9
0
        public byte DefaultCollisionValue(int x, int y, float BumpConstraint, float[,] GroundPlane, byte b, float[,] Heights, CollisionIndex[,] cI)
        {
            if (x < 1 || y < 1 || x >= MaxXPt || y >= MaxYPt) return SimPathStore.BLOCKED;
            if (b == SimPathStore.STICKY_PASSABLE) return b;
            float ZLevel = Heights[x, y];
            float GLevel = GroundPlane[x, y];
            if (ZLevel < GLevel) ZLevel = GLevel;
            var cci = cI[x, y];
            CollisionObject collisionObject = null;
            if (cci != null) collisionObject = cci.GetObjectAt(ZLevel);
            int bumps;
            if (x==270 && y==1275)
            {
                collisionObject = collisionObject;
            }

            // fixed "contiguous objects need to be passable"
            if (collisionObject != null)
            {
                bumps = NeighborBump(x, y, ZLevel, MaxZ, ZLevel, 0.1f, Heights, cI, collisionObject, false, true);
                if (bumps >= 4)
                {
                    return SimPathStore.BRIDGY;
                }
            }

            // this tests for hieght differnces
            bumps = NeighborBump(x, y, ZLevel, MaxZ, ZLevel, BumpConstraint, Heights, cI, 
                collisionObject, false, false);
            if (bumps > 0)
                return SimPathStore.BLOCKED;
            if (bumps > 0)
            {
              //  return SimPathStore.BLOCKED;
            }

            if (BumpConstraintPurple > CollisionIndex.MaxBumpInOpenPath)
            {
                // this looks for transitions between objects
                bumps = NeighborBump(x, y, ZLevel, MaxZ, ZLevel, BumpConstraintPurple, Heights, cI,
                    collisionObject, true, false);
                if (bumps > 0)
                    return SimPathStore.BLOCK_PURPLE;
            }

            if (collisionObject == null)
            {
                float Water = PathStore.WaterHeight;
                if (DiffLessThan(Water, ZLevel, 0.1f))
                {
                    return SimPathStore.WATER_Z;
                }
                if (DiffLessThan(Water, PathStore.GroundPlane[x, y], 0.1f))
                {
                    return SimPathStore.WATER_G;
                }

                float MaxZLevel = MaxZ;
                if (MaxZLevel <= ZLevel - 2)
                {
                    return SimPathStore.TOO_HIGH;
                }
                if (ZLevel + 20 < MaxZLevel) // needs passable
                    return SimPathStore.TOO_LOW;
            }

            // this looks for transitions between objects
            bumps = NeighborBump(x, y, ZLevel, MaxZ, ZLevel, 0.1f, Heights, cI, collisionObject, true, false);
            if (bumps > 0)
            {
                if (collisionObject != null) return SimPathStore.MAYBE_BLOCKED;
                return SimPathStore.MAYBE_BLOCKED;
            }

            // this looks for little bumps
            bumps = NeighborBump(x, y, ZLevel, MaxZ, ZLevel, 0.1f, Heights, cI, null, false, false);
            if (bumps > 0)
                return SimPathStore.BLOCK_PURPLE;


            if (b > 200) return --b;

            CollisionIndex c = cI[x, y];
            if (c != null)
            {
                return c.GetOccupiedValue(GLevel, ZLevel);
            }

            if (b > 10) return --b;
            return SimPathStore.INITIALLY;
        }
示例#10
0
 private static Color OccupiedColor(CollisionPlane CP, Color c, CollisionIndex cIndex)
 {
     //return c;
     if (cIndex != null)
     {
         Color cAdd = cIndex.DebugColor(CP);
         int dense = cIndex.OccupiedCount;
         int A = 240 - 10 * dense;
         if (A < 0) A = 20;
         if (cAdd!=Color.Empty)
         {
             c = cAdd; 
         }
         return Color.FromArgb(A, c.R, c.G, c.B);
     }
     return c;
 }
示例#11
0
 private SimWaypointImpl(Vector3 local, Vector3d global, CollisionIndex Ci, CollisionPlane Cp, SimPathStore pathStore)
 {
     _MinZ = local.Z;
     _MaxZ = _MinZ + 1.5f;
     CIndex = Ci;
     _Plane = Cp;
     _PathStore = pathStore;
     _GlobalPos = global;// RoundPoint(firstP, PathStore);
     _LocalPos = local;
     //PX = PX0;
     //PY = PY0;
     //PathStore.SimWaypoint[PX, PY] = this;
     //TaintMatrix();
     //UpdateMatrix(pathStore.GL);
     _Passable = true;
     _IncomingArcs = null;
     _OutgoingArcs = null;
 }
        public byte DefaultCollisionValue(int x, int y, float BumpConstraint, float[,] GroundPlane, byte b, float[,] Heights, CollisionIndex[,] cI)
        {
            if (x < 1 || y < 1 || x >= MaxXPt || y >= MaxYPt)
            {
                return(SimPathStore.BLOCKED);
            }
            if (b == SimPathStore.STICKY_PASSABLE)
            {
                return(b);
            }
            float ZLevel = Heights[x, y];
            float GLevel = GroundPlane[x, y];

            if (ZLevel < GLevel)
            {
                ZLevel = GLevel;
            }
            var             cci             = cI[x, y];
            CollisionObject collisionObject = null;

            if (cci != null)
            {
                collisionObject = cci.GetObjectAt(ZLevel);
            }
            int bumps;

            if (x == 270 && y == 1275)
            {
                collisionObject = collisionObject;
            }

            // fixed "contiguous objects need to be passable"
            if (collisionObject != null)
            {
                bumps = NeighborBump(x, y, ZLevel, MaxZ, ZLevel, 0.1f, Heights, cI, collisionObject, false, true);
                if (bumps >= 4)
                {
                    return(SimPathStore.BRIDGY);
                }
            }

            // this tests for hieght differnces
            bumps = NeighborBump(x, y, ZLevel, MaxZ, ZLevel, BumpConstraint, Heights, cI,
                                 collisionObject, false, false);
            if (bumps > 0)
            {
                return(SimPathStore.BLOCKED);
            }
            if (bumps > 0)
            {
                //  return SimPathStore.BLOCKED;
            }

            if (BumpConstraintPurple > CollisionIndex.MaxBumpInOpenPath)
            {
                // this looks for transitions between objects
                bumps = NeighborBump(x, y, ZLevel, MaxZ, ZLevel, BumpConstraintPurple, Heights, cI,
                                     collisionObject, true, false);
                if (bumps > 0)
                {
                    return(SimPathStore.BLOCK_PURPLE);
                }
            }

            if (collisionObject == null)
            {
                float Water = PathStore.WaterHeight;
                if (DiffLessThan(Water, ZLevel, 0.1f))
                {
                    return(SimPathStore.WATER_Z);
                }
                if (DiffLessThan(Water, PathStore.GroundPlane[x, y], 0.1f))
                {
                    return(SimPathStore.WATER_G);
                }

                float MaxZLevel = MaxZ;
                if (MaxZLevel <= ZLevel - 2)
                {
                    return(SimPathStore.TOO_HIGH);
                }
                if (ZLevel + 20 < MaxZLevel) // needs passable
                {
                    return(SimPathStore.TOO_LOW);
                }
            }

            // this looks for transitions between objects
            bumps = NeighborBump(x, y, ZLevel, MaxZ, ZLevel, 0.1f, Heights, cI, collisionObject, true, false);
            if (bumps > 0)
            {
                if (collisionObject != null)
                {
                    return(SimPathStore.MAYBE_BLOCKED);
                }
                return(SimPathStore.MAYBE_BLOCKED);
            }

            // this looks for little bumps
            bumps = NeighborBump(x, y, ZLevel, MaxZ, ZLevel, 0.1f, Heights, cI, null, false, false);
            if (bumps > 0)
            {
                return(SimPathStore.BLOCK_PURPLE);
            }


            if (b > 200)
            {
                return(--b);
            }

            CollisionIndex c = cI[x, y];

            if (c != null)
            {
                return(c.GetOccupiedValue(GLevel, ZLevel));
            }

            if (b > 10)
            {
                return(--b);
            }
            return(SimPathStore.INITIALLY);
        }