void ComputeLandingHeights() { 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; PrimitiveBaseShape newcube = PrimitiveBaseShape.CreateBox(); uint localId = 6666666; PhysicsVector position = new PhysicsVector(1, 1, 30); OdePrim oprim = (OdePrim)ps.AddPrimShape("FallingPrim_" + localId, newcube, position, new PhysicsVector(0.1f, 0.1f, 2f), Quaternion.Identity, true); oprim.LocalID = localId + 100000; oprim.SubscribeEvents(30000); for (int y = MAPSPACE1; y >= 0; y--) { fy = fy - StepSize; position.Y = fy; float fx = 256.1f; for (int x = MAPSPACE1; x >= 0; x--) { fx = fx - StepSize; position.X = fx; if (needsInit) { LandingHieghts[x, y] = float.MinValue; } if (MeshIndex[x, y] == null) { continue; } float z = MinZ; bool FoundClearZ = false; while (z < MaxZ && !FoundClearZ) { float ClearZ = z; position.Z = z; if (!ps.IsSomethingAt(oprim)) { FoundClearZ = true; float CapZ = 2f + z; while (z < CapZ && FoundClearZ) { if (ps.IsSomethingAt(oprim)) { FoundClearZ = false; break; } } FoundClearZ = true; break; } z += 0.1f; } if (FoundClearZ) { LandingHieghts[x, y] = z; } //FallingPrims[x, y] = new } } _HeightMap = LandingHieghts; }