public string DistanceVectorString(Vector3 loc) { SimPathStore R = PathStore; return(String.Format("{0:0.0#}m ", Vector3.Distance(SimPosition, loc)) + String.Format("{0}/{1:0.0#}/{2:0.0#}/{3:0.0#}", R.RegionName, loc.X, loc.Y, loc.Z)); }
void AddFieldEffects(byte[,] from, byte[,] to, byte when, int iterations, byte step) { byte fronteer = when; int xsizem1 = MaxXPt - 1; while (iterations-- > 0) { byte self = (byte)(fronteer - step); for (int y = MaxYPt - 1; y > 0; y--) { for (int x = xsizem1; x > 0; x--) { byte b = from[x, y]; if (b > 2 && b < fronteer) { if (SimPathStore.Special(b) && b != SimPathStore.BRIDGY) { continue; } if (SurroundingBlocked0(x, y, fronteer, from) > 1) { to[x, y] = self; } } } } fronteer -= step; } }
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 SimMesh(MeshableObject simObject, Primitive prim, SimPathStore PS) : base(new Box3Fill(true), new List <Box3Fill>(), PS) { RootObject = simObject; Prim = prim; Update(RootObject); }
public override double GetZFor(Vector3d v3) { // return v3.Z; Vector3 local = SimPathStore.GlobalToLocal(v3); return(MoverPlaneZ.GetHeight(local)); }
public static SimWaypoint CreateGlobal(Vector3d v3d) { Vector3 v3 = SimPathStore.GlobalToLocal(v3d); SimPathStore PathStore = SimPathStore.GetPathStore(v3d); return(CreateLocal(v3, PathStore)); }
public override CmdResult ExecuteRequest(CmdRequest args) { if (args.Length < 1) { return(ShowUsage()); // " goto sim/x/y/z"; } int argsUsed; SimPosition position = WorldSystem.GetVector(args, out argsUsed); if (position == null) { return(Failure("Teleport - Cannot resolve to a location: " + args.str)); } SimPathStore ps = position.PathStore; ulong handle = SimRegion.GetRegionHandle(ps); TheSimAvatar.StopMoving(); if (Client.Self.Teleport(handle, position.SimPosition)) { return(Success("Teleported to " + Client.Network.CurrentSim)); } else { return(Failure("Teleport failed: " + Client.Self.TeleportMessage)); } }
void CalcBoxesFromMeshes(Mesh M, IList <Box3Fill> innerBoxes) { #if COLLIDER_TRIANGLE triangles = M.triangles; #endif SimPathStore.TrianglesToBoxes(M.triangles, OuterBox, PadXYZ, innerBoxes); }
private void UpdatePathOccupiedFast(SimPathStore pathStore) { float detail = pathStore.StepSize; // -0.001f; float MinX = OuterBox.MinX; float MaxX = OuterBox.MaxX; float MinY = OuterBox.MinY; float MaxY = OuterBox.MaxY; float MinZ = OuterBox.MinZ; float MaxZ = OuterBox.MaxZ; for (float x = MinX; x <= MaxX; x += detail) { for (float y = MinY; y <= MaxY; y += detail) { foreach (CollisionObject B in InnerBoxes) { if (B.IsInsideXY(x, y)) { PathStore.SetObjectAt(x, y, this, MinZ, MaxZ); //return true; break; } } } } PathStore.SetObjectAt(MaxX, MaxY, this, MinZ, MaxZ); }
public void ForceUpdatePathOccupied(SimPathStore pathStore) { if (!IsRegionAttached()) { return; } // if (!IsSculpted) { UpdateOccupied(pathStore); PathStore.AddedCount++; return; } new Thread(new ThreadStart(delegate() { try { UpdateOccupied(pathStore); } catch (Exception) { //lock (PathStore) { PathStore = null;//.Remove(PathStore); } } })).Start(); }
private void InitFromPos(SimPosition position) { this.reg = position.PathStore; this.pos = position.SimPosition + lateV3; this.rot = position.SimRotation; late = null; lateV3 = Vector3.Zero; }
public string DistanceVectorString(Vector3d loc3d) { Vector3 loc = SimPathStore.GlobalToLocal(loc3d); SimPathStore R = SimPathStore.GetPathStore(loc3d); return(String.Format("{0:0.0#}m ", Vector3d.Distance(GlobalPosition, loc3d)) + String.Format("{0}/{1:0.0#}/{2:0.0#}/{3:0.0#}", R.RegionName, loc.X, loc.Y, loc.Z)); }
public string DistanceVectorString(SimPosition pos) { Vector3 loc = pos.SimPosition; SimPathStore R = pos.PathStore; return(String.Format("{0:0.0#}m ", Vector3d.Distance(GlobalPosition, pos.GlobalPosition)) + String.Format("{0}/{1:0.0#}/{2:0.0#}/{3:0.0#}", R.RegionName, loc.X, loc.Y, loc.Z)); }
/// <summary> /// object.ToString() override. /// Returns the textual description of the node. /// </summary> /// <returns>String describing this node.</returns> public override string ToString() { // return "(" + _GlobalPos.ToRawString() + ")"; SimPathStore R = PathStore; Vector3 loc = SimPosition; return(String.Format("{0}/{1:0.00}/{2:0.00}/{3:0.00}", R.RegionName, loc.X, loc.Y, loc.Z)); }
public override IList <Vector3d> GetSimplifedRoute(Vector3d vstart, IList <Vector3d> v3s) { if (UsedBigZ > 0 || PreXp) { return(SimPathStore.GetSimplifedRoute(vstart, v3s, 20, 0.5f)); } return(SimPathStore.GetSimplifedRoute(vstart, v3s, 45, 2f)); }
public string DistanceVectorString(Vector3d loc3d) { Vector3 loc = SimPathStore.GlobalToLocal(loc3d); SimPathStore R = SimPathStore.GetPathStore(loc3d); return(String.Format("{0:0.00}m ", DistanceNoZ(GetWorldPosition(), loc3d)) + String.Format("{0}/{1:0.00}/{2:0.00}/{3:0.00}", R.RegionName, loc.X, loc.Y, loc.Z)); }
public static Vector3 RoundPoint(Vector3 vect3, SimPathStore PathStore) { double POINTS_PER_METER = PathStore.POINTS_PER_METER; vect3.X = (float)(Math.Round(vect3.X * POINTS_PER_METER, 0) / POINTS_PER_METER); vect3.Y = (float)(Math.Round(vect3.Y * POINTS_PER_METER, 0) / POINTS_PER_METER); vect3.Z = (float)(Math.Round(vect3.Z * POINTS_PER_METER, 0) / POINTS_PER_METER); return(vect3); }
public void SetPathStore(SimPathStore simPathStore) { PathStore = simPathStore; IList <CollisionPlane> CPs = simPathStore.Matrixes; if (CPs.Count > 0) { OnNewCollisionPlane(CPs[0]); } }
public PanelPathFinder(SimPathStore simPathStore) { PathStore = simPathStore; SetStyle(ControlStyles.ResizeRedraw, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.UserPaint, true); InitializeComponent(); // ResetMatrix(mMatrix); }
public string DistanceVectorString(SimPosition obj) { if (!obj.IsRegionAttached) { Vector3 loc = obj.SimPosition; SimPathStore R = obj.PathStore; return(String.Format("unknown relative {0}/{1:0.0#}/{2:0.0#}/{3:0.0#}", R.RegionName, loc.X, loc.Y, loc.Z)); } return(DistanceVectorString(obj.GlobalPosition)); }
public virtual SimRoute GetSegment(double start, double distlen, SimPathStore PathStore) { IList <SimRoute> newmoves = new List <SimRoute>(); double len = Length; if (distlen <= 0.0 || start + distlen > len) { distlen = len - start; } SimWaypoint First = StartNode; SimWaypoint Last = EndNode; foreach (SimRoute move in GetSegments()) { double mlen = move.Length; if (mlen > start) { First = move.GetPointAt(start, PathStore); if (distlen + start < mlen) { Last = move.GetPointAt(distlen + start, PathStore); newmoves.Add(new SimRoute(First, EndNode)); break; // start and end in a single segment } Last = move.EndNode; newmoves.Add(new SimRoute(First, EndNode)); distlen -= (mlen - start); start = 0.0f; continue; // have a start but need distlen more } if (start > 0) { start -= mlen; continue; // still scanning for start } else { if (distlen > mlen) { distlen -= mlen; newmoves.Add(move); continue; // add whole segment and get distlen more } else { First = move.StartNode; EndNode = move.GetPointAt(mlen, PathStore); newmoves.Add(new SimRoute(First, EndNode)); break; // this completed it } } } return(new SimRouteMulti(newmoves)); }
private CollisionIndex(Vector3 local, Vector3d global, int PX0, int PY0, SimPathStore pathStore) { PathStore = pathStore; _GlobalPos = global; _LocalPos = local; PX = PX0; PY = PY0; PathStore.MeshIndex[PX, PY] = this; TaintMatrix(); //pathStore.NeedsUpdate = true; // UpdateMatrix(pathStore.CurrentPlane); }
public virtual double Distance(Vector3d P) { if (minX == maxX || minY == maxY) // vertical or horizontal { if (InRouteBox(P)) // not outside the box { return(0); } } Vector3d Projection = ProjectOnLine(P, _StartNode.Position, _EndNode.Position); return(SimPathStore.DistanceNoZ(Projection, P)); }
public virtual IList <SimWaypoint> GetWayPoints(double apart, SimPathStore PathStore) { IList <SimWaypoint> points = new List <SimWaypoint>(); double len = Length; double way = 0.0f; while (way < len) { points.Add(GetPointAt(way, PathStore)); way += apart; } points.Add(EndNode); return(points); }
public SimCollisionPlaneMover(SimMover mover, SimPosition finalGoal, double finalDistance) : base(mover, finalGoal, finalDistance) { CollisionPlane MoverPlane = MoverPlaneZ; float startZ = (float)SimPathStore.CalcStartZ(mover.SimPosition.Z, finalGoal.SimPosition.Z); double diff = MoverPlane.MinZ - startZ; MoverPlane.MinZ = startZ; MoverPlane.MaxZ = startZ + 3; if (diff > .5 || diff < -0.5f) { MoverPlane.HeightMapNeedsUpdate = true; } }
/// <summary> /// Make sure this the non-simplfied route /// </summary> /// <param name="route"></param> private void DepricateRoute(IEnumerable <Vector3d> route, double finalDist) { List <Vector3d> reallyDepricate = new List <Vector3d>(); List <ThreadStart> listUndo = new List <ThreadStart>(); const int time = 120; Vector3d first = default(Vector3d); foreach (Vector3d list in route) { if (first == default(Vector3d)) { first = list; continue; } if (Vector3d.Distance(first, list) > finalDist) { break; } reallyDepricate.Add(list); } Mover.IndicateRoute(reallyDepricate, Color.Orchid); foreach (Vector3d list in reallyDepricate) { PathStore.BlockPointTemp(SimPathStore.GlobalToLocal(list), listUndo, SimPathStore.BLOCKED); } if (listUndo.Count == 0) { return; } string tmp = string.Format("Blocking {0} points for {1} seconds", listUndo.Count, time); Thread thr = new Thread(() => { Debug(tmp); Thread.Sleep(time * 1000); Debug("Un-{0}", tmp); foreach (ThreadStart undo in listUndo) { undo(); } }) { Name = tmp }; thr.Start(); }
public override CmdResult ExecuteRequest(CmdRequest args) { bool asLocal = args.IsTrue("--local"); SimPosition pos, pos2; if (!args.TryGetValue("start", out pos)) { pos = TheSimAvatar; } if (!args.TryGetValue("end", out pos2)) { pos = TheSimAvatar; } Vector3d from, to; if (pos2 == null) { pos2 = pos; pos = TheSimAvatar; } from = pos.GlobalPosition; to = pos2.GlobalPosition; Vector3d offset = Vector3d.Zero; if (asLocal) { offset = pos.PathStore.GlobalStart; } bool onlyStart, faked; var path = SimPathStore.GetPath(null, from, to, 1, out onlyStart, out faked); WriteLine("onlyStart=" + onlyStart); WriteLine("faked=" + faked); WriteLine("start=" + VectorRoundString(from - offset)); WriteLine("end=" + VectorRoundString(to - offset)); WriteLine("pstart=" + pos); WriteLine("pend=" + pos2); WriteLine("len=" + path.Count); int step = 0; foreach (Vector3d vector3D in path) { WriteLine("p" + step + "=" + VectorRoundString(vector3D - offset)); step++; } return(Success("SUCCESS " + Name)); }
public override SimWaypoint GetPointAt(double p, SimPathStore PathStore) { if (p <= 0.0f) { return(StartNode); } foreach (SimRoute move in MoveList) { double mlen = move.Length; if (mlen > p) { return(move.GetPointAt(p, PathStore)); } p -= mlen; } return(EndNode); }
public virtual SimRouteMulti Divide(int by, SimPathStore PathStore) { IList <SimRoute> moves = new List <SimRoute>(); double len = Length; double seglen = len / by; SimWaypoint beg = StartNode; int current = 1; while (current < by) { SimWaypoint end = GetPointAt(seglen * current, PathStore); SimRoute move = new SimRoute(beg, end); moves.Add(move); beg = end; } return(CopyProperties(this, new SimRouteMulti(moves))); }
public override CmdResult ExecuteRequest(CmdRequest args) { SimPosition pos; if (!args.TryGetValue("pos", out pos)) { pos = TheSimAvatar; } SimPathStore R = pos.PathStore; Vector3 v3 = pos.SimPosition; WriteLine("SimZInfo: " + pos + " " + R.GetGroundLevel(v3.X, v3.Y)); SimWaypoint WP = R.GetWaypointOf(v3); WriteLine("WaypointInfo: {0}", WP.OccupiedString(R.GetCollisionPlane(v3.Z))); return(Success("Ran " + Name)); }