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); }
public void CreateDefaultRoutes() { CollisionPlane.Debug("CreateDefaultRoutes <{0},{1}>-<{2},{3}> StepSize={4}", StartX, StartY, EndX, EndY, StepSize); return; double W = 0.75f; int made = 0; for (int x = StartX; x < EndX; x += StepSize) { for (int y = StartY; y < EndY; y += StepSize) { made++; SimWaypoint sw00 = CreateXYZ(x, y); SimWaypoint sw01 = CreateXYZ(x, y + StepSize); SimWaypoint sw10 = CreateXYZ(x + StepSize, y); SimWaypoint sw11 = CreateXYZ(x + StepSize, y + StepSize); /* * * Draws two-way Routes StepSize meters appart * * - * | X * * * * */ AddNewArcs(sw00, sw01, W); //dirrection | AddNewArcs(sw00, sw10, W); //dirrection - AddNewArcs(sw00, sw11, W); //dirrection \ AddNewArcs(sw10, sw01, W); //dirrection / } } CollisionPlane.Debug("CreateDefaultRoutes Made {0} waypoints", made); }
public SimRoute Intern2Arc(SimWaypoint s, SimWaypoint e, double W) { InternArc(e, s, W); CollisionPlane.Debug("Intern2Arc: " + s + " <-> " + e); return(InternArc(s, e, W)); }
void ComputeLandingHeightsOld() { float fromZ = MaxZ + 10; float StepSize = PathStore.StepSize; //0.2f int MAPSPACE = PathStore.MAPSPACE; int MAPSPACE1 = MAPSPACE - 1; // 1279 bool needsInit = false; float[,] _HeightMap = HeightMap; if (LandingHieghts == null) { if (_HeightMap != null) { LandingHieghts = (float[, ])_HeightMap.Clone(); } else { LandingHieghts = new float[MAPSPACE, MAPSPACE]; needsInit = true; } } CollisionIndex[,] MeshIndex = PathStore.MeshIndex; // FallingPrims = new FallingPrim[MAPSPACE, MAPSPACE]; float fy = 256.1f; OdeScene ps = PathStore.odeScene; fallingPrims = 0; for (int y = MAPSPACE1; y >= 0; y--) { fy = fy - StepSize; float fx = 256.1f; for (int x = MAPSPACE1; x >= 0; x--) { fx = fx - StepSize; if (needsInit) { LandingHieghts[x, y] = float.MinValue; } if (MeshIndex[x, y] == null) { continue; } //FallingPrims[x, y] = new FallingPrim(ps, this, new PhysicsVector(fx, fy, fromZ), x, y, 0f); fallingPrims++; } int MaxTries = 100; while (fallingPrims > 0 && MaxTries-- > 0) { // CollisionPlane.Debug("fallingPrims=" + fallingPrims); ps.Simulate(0.133f); } //CollisionPlane.Debug("fallingPrims left over {0} MaxTries Left over = {1}", fallingPrims, MaxTries); ps.Simulate(0.133f); // for removal of remainders or not needed? if (fallingPrims < 10) { _HeightMap = LandingHieghts; } if (fallingPrims != 0) { CollisionPlane.Debug("fallingPrims left over {0} MaxTries Left over = {1}", fallingPrims, MaxTries); } else if (y % 100 == 0) { CollisionPlane.Debug("Y={0} MaxTries Left over = {1}", y, MaxTries); } } }