Example #1
0
 public SimMesh(MeshableObject simObject, Primitive prim, SimPathStore PS)
     : base(new Box3Fill(true), new List<Box3Fill>(), PS)
 {
     RootObject = simObject;
     Prim = prim;
     Update(RootObject);
 }
Example #2
0
 public void SetPathStore(SimPathStore simPathStore)
 {
     PathStore = simPathStore;
     IList<CollisionPlane> CPs = simPathStore.Matrixes;
     if (CPs.Count > 0)
         OnNewCollisionPlane(CPs[0]);
 }
Example #3
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);
 }
Example #4
0
 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;
 }
Example #5
0
 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;
 }
Example #6
0
        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);
        }
Example #7
0
 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();
 }
Example #8
0
 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);            
     }
 }
Example #9
0
 public void SetPathStoreAtOffset(Vector2 v2, SimPathStore value)
 {
     RegisterPathStore((GetGridLocation() + v2), value);
 }
Example #10
0
 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();
     }
 }
Example #11
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;
 }
Example #12
0
 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);
 }
Example #13
0
 public SimHeading(SimPathStore reg, Vector3 pos, Quaternion rot)
 {
     this.reg = reg;
     this.pos = pos;
     this.rot = rot;
 }
Example #14
0
 private void InitFromPos(SimPosition position)
 {
     this.reg = position.PathStore;
     this.pos = position.SimPosition + lateV3;
     this.rot = position.SimRotation;
     late = null;
     lateV3 = Vector3.Zero;
 }
Example #15
0
 public MoverTracking(Vector3 firstP, Quaternion firtsR, SimPathStore store)
 {
     LastPosition = firstP;
     Store = store;
     LastRotation = firtsR;
 }
Example #16
0
 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;
     }
 }
Example #17
0
        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);
        }
Example #18
0
 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;
 }
Example #19
0
        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);
        }
Example #20
0
 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));
 }
Example #21
0
        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;
        }
Example #22
0
 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));
 }
Example #23
0
 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;
 }
Example #24
0
        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);
        }
Example #25
0
 internal static CollisionIndex CreateCollisionIndex(float x, float y, SimPathStore simPathStore)
 {
     return CreateCollisionIndex(new Vector3(x, y, 0), simPathStore);
 }
Example #26
0
 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;
     };
 }
Example #27
0
 protected SimMesh(Box3Fill o, IList<Box3Fill> i, SimPathStore R)
     : base(o, i, R)
 {
     
 }
Example #28
0
 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;
 }
Example #29
0
 public RuntimeMesh(IComparable id, Box3Fill outer, IList<Box3Fill> inners, SimPathStore paths)
     : base(outer, inners, paths)
 {
     ID = id;
 }
Example #30
0
 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));           
 }