public SimMesh(MeshableObject simObject, Primitive prim, SimPathStore PS) : base(new Box3Fill(true), new List<Box3Fill>(), PS) { RootObject = simObject; Prim = prim; Update(RootObject); }
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 PathFinderDemo(SimPathStore pathStore) { PathStore = pathStore; //this.PnlGUI = new PanelPathFinder(); InitializeComponent(); CboFormula.SelectedIndex = 0; BtnStartStop.Text = RUN; BtnPause.Text = PAUSE; BtnStart.Text = NODE_START; BtnEnd.Text = NODE_END; BtnX.Text = NODE_X; BtnM.Text = NODE_M; mDelay = TBarSpeed.Value; }
public CollisionPlane(int xsize0, int ysize0, float minZ, SimPathStore pathStore) { TotalCollisionPlanes++; PathStore = pathStore; MaxXPt = xsize0 - 1; MaxYPt = ysize0 - 1; MinZ = minZ; MaxZ = minZ + CollisionIndex.SearchAboveCeilingZ; OuterBox.MinZ = MinZ; OuterBox.MaxZ = MaxZ; OuterBox.MinX = 0; OuterBox.MinY = 0; OuterBox.MaxX = 256f - PathStore.StepSize; OuterBox.MaxY = 256f - PathStore.StepSize; SetDefaultConstraints(); updateWatcher = new Thread(new ThreadStart(UpdateWatcher)); Users = 1; LastUsed = DateTime.Now; }
private void UpdatePathOccupiedVeryFast(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) { PathStore.SetObjectAt(x, y, this, MinZ, MaxZ); //return true; } } 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(); }
protected void RemoveCollisions(SimPathStore simPathStore) { if (simPathStore != PathStore) return; if (PathStore == null) IsSolid = false; else { Box3Fill changed = new Box3Fill(true); RemoveFromWaypoints(changed); simPathStore.Refresh(changed); } }
public void SetPathStoreAtOffset(Vector2 v2, SimPathStore value) { RegisterPathStore((GetGridLocation() + v2), value); }
private void SetCurrentPlane(CollisionPlane value) { if (InvokeRequired) { this.Invoke(new SetCurrentPlaneDelegate(SetCurrentPlane),new object[]{value}); return; } if (value != null && _CurrentPlane != value) { _CurrentPlane = value; if (_CurrentPlane != null) { PathStore = _CurrentPlane.PathStore; PathFinderDemo pfd = PathStore.PanelGUI; if (pfd != null) { pfd.SetPlane(_CurrentPlane); pfd.Text = String.Format("{0} {1}", PathStore.RegionName, _CurrentPlane); } _Matrix = _CurrentPlane.ByteMatrix; } Invalidate(); } }
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; }
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 SimHeading(SimPathStore reg, Vector3 pos, Quaternion rot) { this.reg = reg; this.pos = pos; this.rot = rot; }
private void InitFromPos(SimPosition position) { this.reg = position.PathStore; this.pos = position.SimPosition + lateV3; this.rot = position.SimRotation; late = null; lateV3 = Vector3.Zero; }
public MoverTracking(Vector3 firstP, Quaternion firtsR, SimPathStore store) { LastPosition = firstP; Store = store; LastRotation = firtsR; }
public static SimPathStore GetPathStore(Vector2 loc) { lock (_PathStores) { SimPathStore PS; if (_PathStores.TryGetValue(loc,out PS)) { return PS; } PS = new SimPathStore(loc.ToString(), loc, new Vector3d(loc.X * 256, loc.Y * 256, 0), new Vector3(256, 256, Single.MaxValue)); return PS; } }
public Vector3 LocalOuterEdge(Vector3 startLocal, Vector3d globalEnd, out SimPathStore nextRegion) { SimPathStore rother = GetPathStore(globalEnd); Vector3 vother = GlobalToLocal(globalEnd);//.GetSimPosition(); if (rother == this) { nextRegion = this; return vother; } Vector2 VD = rother.GetGridLocation() - GetGridLocation(); Vector2 SD = new Vector2(Math.Sign(VD.X), Math.Sign(VD.Y)); float x = 128 + SD.X * 127; if (x == 128) { x = (startLocal.X + vother.X) / 2; } float y = 128 + SD.Y * 127; if (y == 128) { y = (startLocal.Y + vother.Y) / 2; } nextRegion = GetPathStore(GetGridLocation() + SD); return new Vector3(x, y, vother.Z); }
static void RegisterPathStore(Vector2 h, SimPathStore value) { lock (_PathStores) if (_PathStores.ContainsKey(h)) { SimPathStore OLD = _PathStores[h]; if (OLD == null || OLD == value) return; throw new ArgumentException("Bad region change " + OLD + " -> " + value); } _PathStores[h] = value; }
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 virtual SimWaypoint GetPointAt(double p, SimPathStore PathStore) { double len = Length; if (p <= 0.0f) return StartNode; if (p >= len) return EndNode; Vector3d dir = EndNode.GlobalPosition - StartNode.GlobalPosition; double X = (dir.X / len) * p; double Y = (dir.Y / len) * p; double Z = (dir.Z / len) * p; return SimWaypointImpl.CreateGlobal(new Vector3d(X, Y, Z)); }
public IList<Box3Fill> InnerBoxes { get; set; }// = new List<Box3Fill>(); public MeshedObject(Box3Fill o, IList<Box3Fill> i, SimPathStore R) { OuterBox = o; InnerBoxes = i; PathStore = null;// R; }
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 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 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); }
internal static CollisionIndex CreateCollisionIndex(float x, float y, SimPathStore simPathStore) { return CreateCollisionIndex(new Vector3(x, y, 0), simPathStore); }
public virtual bool UpdateOccupied(SimPathStore pathStore) { if (pathStore == null) { CollisionPlane.Debug("Cant UpdatePathOccupied for {0}", this);// + " pos " + RootObject.DistanceVectorString(RootObject)); return false; } if (!UpdateMeshPaths) return false; if (MeshOnlySolids && !IsSolid) return false; if (InnerBoxes == null) return false; if (InnerBoxes.Count == 0) return false; if (!IsRegionAttached()) return false; // int t1; try { //lock (PathStore) { if (PathStore == pathStore) return false; PathStore = pathStore;//.Add(pathStore); if (tryFastVersion) { // UpdatePathOccupiedFast(PathStore); // int tc = Environment.TickCount; UpdatePathOccupiedVeryFast(pathStore); // t1 = Environment.TickCount - tc; InnerBoxes = null; PathStore.AddedCount++; // CollisionPlane.Debug("t1 vs t2 = " + t1 ); return true; } } ForceUpdatePathOccupied(pathStore); return true; } catch (Exception e) { // lock (PathStore) { PathStore = null;//.Remove(pathStore); } return false; }; }
protected SimMesh(Box3Fill o, IList<Box3Fill> i, SimPathStore R) : base(o, i, R) { }
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 RuntimeMesh(IComparable id, Box3Fill outer, IList<Box3Fill> inners, SimPathStore paths) : base(outer, inners, paths) { ID = id; }
public static ulong GetRegionHandle(SimPathStore store) { if (store == null) return 0; foreach (var of in CurrentRegions) { if (of.PathStore == store) return of.RegionHandle; } Vector2 loc = store.RegionLocation; uint regionX = (uint) loc.X*256; uint regionY = (uint)loc.Y * 256; return Utils.UIntsToLong(regionX, regionY); //_GridLoc = new Vector2((float)(regionX / 256), (float)(regionY / 256)); }