Exemplo n.º 1
0
        internal override Rect GetBounds(GraphTransform inverseTransform)
        {
            if (this.verts == null)
            {
                this.RebuildMesh();
            }
            Int3[] array = ArrayPool <Int3> .Claim((this.verts != null)?this.verts.Length : 0);

            int[] array2;
            this.GetMesh(ref array, out array2, inverseTransform);
            Rect result = default(Rect);

            for (int i = 0; i < array2.Length; i++)
            {
                Vector3 vector = (Vector3)array[array2[i]];
                if (i == 0)
                {
                    result = new Rect(vector.x, vector.z, 0f, 0f);
                }
                else
                {
                    result.xMax = Math.Max(result.xMax, vector.x);
                    result.yMax = Math.Max(result.yMax, vector.z);
                    result.xMin = Math.Min(result.xMin, vector.x);
                    result.yMin = Math.Min(result.yMin, vector.z);
                }
            }
            ArrayPool <Int3> .Release(ref array, false);

            return(result);
        }
Exemplo n.º 2
0
        // Token: 0x06002691 RID: 9873 RVA: 0x001A83A8 File Offset: 0x001A65A8
        internal override Rect GetBounds(GraphTransform inverseTranform)
        {
            List <List <Vector3> > list = ListPool <List <Vector3> > .Claim();

            this.GetContour(list);
            Rect result = default(Rect);

            for (int i = 0; i < list.Count; i++)
            {
                List <Vector3> list2 = list[i];
                for (int j = 0; j < list2.Count; j++)
                {
                    Vector3 vector = inverseTranform.InverseTransform(list2[j]);
                    if (j == 0)
                    {
                        result = new Rect(vector.x, vector.z, 0f, 0f);
                    }
                    else
                    {
                        result.xMax = Math.Max(result.xMax, vector.x);
                        result.yMax = Math.Max(result.yMax, vector.z);
                        result.xMin = Math.Min(result.xMin, vector.x);
                        result.yMin = Math.Min(result.yMin, vector.z);
                    }
                }
            }
            ListPool <List <Vector3> > .Release(ref list);

            return(result);
        }
Exemplo n.º 3
0
        // Token: 0x06002696 RID: 9878 RVA: 0x001A8890 File Offset: 0x001A6A90
        public void OnDrawGizmosSelected()
        {
            List <List <Vector3> > list = ListPool <List <Vector3> > .Claim();

            this.GetContour(list);
            Color color = Color.Lerp(NavmeshCut.GizmoColor, Color.white, 0.5f);

            color.a     *= 0.5f;
            Gizmos.color = color;
            NavmeshBase    navmeshBase    = (AstarPath.active != null) ? (AstarPath.active.data.recastGraph ?? AstarPath.active.data.navmesh) : null;
            GraphTransform graphTransform = (navmeshBase != null) ? navmeshBase.transform : GraphTransform.identityTransform;
            float          y  = this.GetY(graphTransform);
            float          y2 = y - this.height * 0.5f;
            float          y3 = y + this.height * 0.5f;

            for (int i = 0; i < list.Count; i++)
            {
                List <Vector3> list2 = list[i];
                for (int j = 0; j < list2.Count; j++)
                {
                    Vector3 vector  = graphTransform.InverseTransform(list2[j]);
                    Vector3 vector2 = graphTransform.InverseTransform(list2[(j + 1) % list2.Count]);
                    Vector3 point   = vector;
                    Vector3 point2  = vector2;
                    Vector3 point3  = vector;
                    Vector3 point4  = vector2;
                    point.y  = (point2.y = y2);
                    point3.y = (point4.y = y3);
                    Gizmos.DrawLine(graphTransform.Transform(point), graphTransform.Transform(point2));
                    Gizmos.DrawLine(graphTransform.Transform(point3), graphTransform.Transform(point4));
                    Gizmos.DrawLine(graphTransform.Transform(point), graphTransform.Transform(point3));
                }
            }
            ListPool <List <Vector3> > .Release(ref list);
        }
Exemplo n.º 4
0
        public static Bounds InverseTransform(this GraphTransform self, Bounds bounds)
        {
            if (self.onlyTranslational)
            {
                return(new Bounds(bounds.center - self.translation.ToUnityV3(), bounds.size));
            }

            var corners = PF.ArrayPool <Vector3> .Claim(8);

            var extents = bounds.extents;

            corners[0] = self.InverseTransform(bounds.center + new Vector3(extents.x, extents.y, extents.z));
            corners[1] = self.InverseTransform(bounds.center + new Vector3(extents.x, extents.y, -extents.z));
            corners[2] = self.InverseTransform(bounds.center + new Vector3(extents.x, -extents.y, extents.z));
            corners[3] = self.InverseTransform(bounds.center + new Vector3(extents.x, -extents.y, -extents.z));
            corners[4] = self.InverseTransform(bounds.center + new Vector3(-extents.x, extents.y, extents.z));
            corners[5] = self.InverseTransform(bounds.center + new Vector3(-extents.x, extents.y, -extents.z));
            corners[6] = self.InverseTransform(bounds.center + new Vector3(-extents.x, -extents.y, extents.z));
            corners[7] = self.InverseTransform(bounds.center + new Vector3(-extents.x, -extents.y, -extents.z));

            var min = corners[0];
            var max = corners[0];

            for (int i = 1; i < 8; i++)
            {
                min = Vector3.Min(min, corners[i]);
                max = Vector3.Max(max, corners[i]);
            }
            PF.ArrayPool <Vector3> .Release(ref corners);

            return(new Bounds((min + max) * 0.5f, max - min));
        }
 // Token: 0x060024D3 RID: 9427 RVA: 0x0019D2FC File Offset: 0x0019B4FC
 public void Initialize(GraphTransform transform, float scale)
 {
     this.up                 = (transform.Transform(Vector3.up) - transform.Transform(Vector3.zero)).normalized;
     this.upheight           = this.up * this.height;
     this.finalRadius        = this.diameter * scale * 0.5f;
     this.finalRaycastRadius = this.thickRaycastDiameter * scale * 0.5f;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Bounds in XZ space after transforming using the *inverse* transform of the inverseTransform parameter.
        /// The transformation will typically transform the vertices to graph space and this is used to
        /// figure out which tiles the cut intersects.
        /// </summary>
        public override Rect GetBounds(GraphTransform inverseTransform)
        {
            var buffers = ListPool <List <Vector3> > .Claim();

            GetContour(buffers);

            Rect r = new Rect();

            for (int i = 0; i < buffers.Count; i++)
            {
                var buffer = buffers[i];
                for (int k = 0; k < buffer.Count; k++)
                {
                    var p = inverseTransform.InverseTransform(buffer[k]);
                    if (k == 0)
                    {
                        r = new Rect(p.x, p.z, 0, 0);
                    }
                    else
                    {
                        r.xMax = System.Math.Max(r.xMax, p.x);
                        r.yMax = System.Math.Max(r.yMax, p.z);
                        r.xMin = System.Math.Min(r.xMin, p.x);
                        r.yMin = System.Math.Min(r.yMin, p.z);
                    }
                }
            }

            ListPool <List <Vector3> > .Release(ref buffers);

            return(r);
        }
Exemplo n.º 7
0
 /** Sets up several variables using the specified matrix and scale.
  * \see GraphCollision.up
  * \see GraphCollision.upheight
  * \see GraphCollision.finalRadius
  * \see GraphCollision.finalRaycastRadius
  */
 public void Initialize(GraphTransform transform, float scale)
 {
     up                 = (transform.Transform(Vector3.up) - transform.Transform(Vector3.zero)).normalized;
     upheight           = up * height;
     finalRadius        = diameter * scale * 0.5F;
     finalRaycastRadius = thickRaycastDiameter * scale * 0.5F;
 }
Exemplo n.º 8
0
 // Token: 0x06002435 RID: 9269 RVA: 0x001968A0 File Offset: 0x00194AA0
 public void Refresh()
 {
     if (base.transform.hasChanged)
     {
         this.transformation       = new GraphTransform(base.transform.localToWorldMatrix * this.originalMatrix);
         base.transform.hasChanged = false;
     }
 }
Exemplo n.º 9
0
        public void SetTransform(GraphTransform transform)
        {
            Transform tr = new TranslateTransform(transform.TranslateX, transform.TranslateY);
            Transform sc = new ScaleTransform(transform.ScaleX, transform.ScaleY);

            this.context.PushTransform(tr);
            this.context.PushTransform(sc);
        }
Exemplo n.º 10
0
 public void Refresh()
 {
     // Avoid updating the GraphTransform if the object has not moved
     if (transform.hasChanged)
     {
         transformation       = new GraphTransform(transform.localToWorldMatrix * originalMatrix);
         transform.hasChanged = false;
     }
 }
Exemplo n.º 11
0
    /** Called when a requested path has finished calculation.
     * A path is first requested by #SearchPath, it is then calculated, probably in the same or the next frame.
     * Finally it is returned to the seeker which forwards it to this function.\n
     */
    public virtual void OnPathComplete(Path _p)
    {
        ABPath p = _p as ABPath;

        if (p == null)
        {
            throw new System.Exception("This function only handles ABPaths, do not use special path types");
        }

        canSearchAgain = true;

        // Claim the new path
        p.Claim(this);

        // Path couldn't be calculated of some reason.
        // More info in p.errorLog (debug string)
        if (p.error)
        {
            p.Release(this);
            return;
        }

        // Release the previous path
        if (path != null)
        {
            path.Release(this);
        }

        // Replace the old path
        path = p;

        // Make sure the path contains at least 2 points
        if (path.vectorPath.Count == 1)
        {
            path.vectorPath.Add(path.vectorPath[0]);
        }
        interpolator.SetPath(path.vectorPath);

        // REPLACEMENT
        // var graph = AstarData.GetGraph(path.path[0]) as ITransformedGraph;
        // movementPlane = graph != null ? graph.transform : GraphTransform.identityTransform;
        var graphRotation = new Vector3(-90, 0, 0);

        movementPlane = new GraphTransform(Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(graphRotation), Vector3.one));

        // Reset some variables
        TargetReached = false;

        // Simulate movement from the point where the path was requested
        // to where we are right now. This reduces the risk that the agent
        // gets confused because the first point in the path is far away
        // from the current position (possibly behind it which could cause
        // the agent to turn around, and that looks pretty bad).
        interpolator.MoveToLocallyClosestPoint((GetFeetPosition() + p.originalStartPoint) * 0.5f);
        interpolator.MoveToLocallyClosestPoint(GetFeetPosition());
    }
Exemplo n.º 12
0
 /// <summary>
 /// Sets up several variables using the specified matrix and scale.
 /// See: GraphCollision.up
 /// See: GraphCollision.upheight
 /// See: GraphCollision.finalRadius
 /// See: GraphCollision.finalRaycastRadius
 /// </summary>
 public void Initialize(GraphTransform transform, float scale)
 {
     up                 = (transform.Transform(Vector3.up) - transform.Transform(Vector3.zero)).normalized;
     upheight           = up * height;
     finalRadius        = diameter * scale * 0.5F;
     finalRaycastRadius = thickRaycastDiameter * scale * 0.5F;
     contactFilter      = new ContactFilter2D {
         layerMask = mask, useDepth = false, useLayerMask = true, useNormalAngle = false, useTriggers = false
     };
 }
Exemplo n.º 13
0
        /** Draws some debug lines representing the rect */
        public void DebugDraw(GraphTransform transform, Color color)
        {
            Vector3 p1 = transform.Transform(new Vector3(xmin, 0, ymin));
            Vector3 p2 = transform.Transform(new Vector3(xmin, 0, ymax));
            Vector3 p3 = transform.Transform(new Vector3(xmax, 0, ymax));
            Vector3 p4 = transform.Transform(new Vector3(xmax, 0, ymin));

            Debug.DrawLine(p1, p2, color);
            Debug.DrawLine(p2, p3, color);
            Debug.DrawLine(p3, p4, color);
            Debug.DrawLine(p4, p1, color);
        }
Exemplo n.º 14
0
        // Token: 0x0600246E RID: 9326 RVA: 0x0019C23C File Offset: 0x0019A43C
        public void DebugDraw(GraphTransform transform, Color color)
        {
            Vector3 vector  = transform.Transform(new Vector3((float)this.xmin, 0f, (float)this.ymin));
            Vector3 vector2 = transform.Transform(new Vector3((float)this.xmin, 0f, (float)this.ymax));
            Vector3 vector3 = transform.Transform(new Vector3((float)this.xmax, 0f, (float)this.ymax));
            Vector3 vector4 = transform.Transform(new Vector3((float)this.xmax, 0f, (float)this.ymin));

            Debug.DrawLine(vector, vector2, color);
            Debug.DrawLine(vector2, vector3, color);
            Debug.DrawLine(vector3, vector4, color);
            Debug.DrawLine(vector4, vector, color);
        }
Exemplo n.º 15
0
        void ResizeAxis(Rectangle r)
        {
            //If the rectangle has zero width or zero height return
            if (r.Width == 0)
            {
                return;
            }
            if (r.Height == 0)
            {
                return;
            }

            //Get the points from the rectangle
            double x1 = r.X - this.CurveArea.X;
            double y1 = r.Y - this.CurveArea.Y;
            double x2 = x1 + r.Width;
            double y2 = y1 + r.Height;

            //Transform rectangle points into real values
            x1 = GraphTransform.InvTranslateX(x1);
            y1 = GraphTransform.InvTranslateY(y1);
            x2 = GraphTransform.InvTranslateX(x2);
            y2 = GraphTransform.InvTranslateY(y2);

            //If logarithmic x axis transform x values
            if (this.AxisTypeX == AxisType.LOG)
            {
                x1 = (double)Math.Pow(10, x1);
                x2 = (double)Math.Pow(10, x2);
            }

            //If logarithmic y axis transform y values
            if (this.AxisTypeY == AxisType.LOG)
            {
                y1 = (double)Math.Pow(10, y1);
                y2 = (double)Math.Pow(10, y2);
            }

            //If this chart has autoscale enabled disable it
            if (this.AutoScale)
            {
                this.AutoScale = false;
            }

            //Set the new axisrange
            this.AxisRangeX = new AxisData(x1, x2, Math.Abs(x2 - x1) / 5);
            this.AxisRangeY = new AxisData(y2, y1, Math.Abs(y1 - y2) / 5);

            //Redraw the control
            RedrawChart();
        }
Exemplo n.º 16
0
        public void GetMesh(ref Int3[] vbuffer, out int[] tbuffer, GraphTransform inverseTransform = null)
        {
            if (this.verts == null)
            {
                this.RebuildMesh();
            }
            if (this.verts == null)
            {
                tbuffer = ArrayPool <int> .Claim(0);

                return;
            }
            if (vbuffer == null || vbuffer.Length < this.verts.Length)
            {
                if (vbuffer != null)
                {
                    ArrayPool <Int3> .Release(ref vbuffer, false);
                }
                vbuffer = ArrayPool <Int3> .Claim(this.verts.Length);
            }
            tbuffer = this.tris;
            if (this.useRotationAndScale)
            {
                Matrix4x4 matrix4x = Matrix4x4.TRS(this.tr.position + this.center, this.tr.rotation, this.tr.localScale * this.meshScale);
                for (int i = 0; i < this.verts.Length; i++)
                {
                    Vector3 vector = matrix4x.MultiplyPoint3x4(this.verts[i]);
                    if (inverseTransform != null)
                    {
                        vector = inverseTransform.InverseTransform(vector);
                    }
                    vbuffer[i] = (Int3)vector;
                }
            }
            else
            {
                Vector3 a = this.tr.position + this.center;
                for (int j = 0; j < this.verts.Length; j++)
                {
                    Vector3 vector2 = a + this.verts[j] * this.meshScale;
                    if (inverseTransform != null)
                    {
                        vector2 = inverseTransform.InverseTransform(vector2);
                    }
                    vbuffer[j] = (Int3)vector2;
                }
            }
        }
Exemplo n.º 17
0
        public void DrawTransformGizmos(GraphTransform t, Vector3 pivotPoint, Vector3 forward, Vector3 up)
        {
            Vector3 pivotWorld = t.Transform(pivotPoint);
            Vector3 xWorld     = t.Transform(forward).normalized;
            Vector3 yWorld     = t.Transform(up).normalized;
            Vector3 zWorld     = Vector3.Cross(xWorld, yWorld);

            yWorld = Vector3.Cross(zWorld, xWorld);
            yWorld.Normalize();
            xWorld.Normalize();
            // Gizmos.color = Color.red;
            // Gizmos.DrawLine(pivotWorld, pivotWorld + xWorld);
            // Gizmos.color = Color.green;
            // Gizmos.DrawLine(pivotWorld, pivotWorld + yWorld);
            // Gizmos.color = Color.blue;
            // Gizmos.DrawLine(pivotWorld, pivotWorld + zWorld);
        }
        private protected void MakeContent(TreeViewItem snd)
        {
            var          elem = (snd.GetValue(ContentProperty) as Func <object>)();
            GraphElement ge   = null;

            if (elem is ATransformation t)
            {
                ge = new GraphTransform(t);
            }
            else if (elem is Renderable r)
            {
                ge = new GraphShape(r);
            }
            else if (elem is GraphParent gp)
            {
                ge = gp;
            }
            newElement = MakeContentSub(snd.Header as string, ge);
        }
Exemplo n.º 19
0
            public void DrawWireCube(GraphTransform tr, Bounds bounds, Color color)
            {
                var min = bounds.min;
                var max = bounds.max;

                DrawLine(tr.Transform(new Vector3(min.x, min.y, min.z)), tr.Transform(new Vector3(max.x, min.y, min.z)), color);
                DrawLine(tr.Transform(new Vector3(max.x, min.y, min.z)), tr.Transform(new Vector3(max.x, min.y, max.z)), color);
                DrawLine(tr.Transform(new Vector3(max.x, min.y, max.z)), tr.Transform(new Vector3(min.x, min.y, max.z)), color);
                DrawLine(tr.Transform(new Vector3(min.x, min.y, max.z)), tr.Transform(new Vector3(min.x, min.y, min.z)), color);

                DrawLine(tr.Transform(new Vector3(min.x, max.y, min.z)), tr.Transform(new Vector3(max.x, max.y, min.z)), color);
                DrawLine(tr.Transform(new Vector3(max.x, max.y, min.z)), tr.Transform(new Vector3(max.x, max.y, max.z)), color);
                DrawLine(tr.Transform(new Vector3(max.x, max.y, max.z)), tr.Transform(new Vector3(min.x, max.y, max.z)), color);
                DrawLine(tr.Transform(new Vector3(min.x, max.y, max.z)), tr.Transform(new Vector3(min.x, max.y, min.z)), color);

                DrawLine(tr.Transform(new Vector3(min.x, min.y, min.z)), tr.Transform(new Vector3(min.x, max.y, min.z)), color);
                DrawLine(tr.Transform(new Vector3(max.x, min.y, min.z)), tr.Transform(new Vector3(max.x, max.y, min.z)), color);
                DrawLine(tr.Transform(new Vector3(max.x, min.y, max.z)), tr.Transform(new Vector3(max.x, max.y, max.z)), color);
                DrawLine(tr.Transform(new Vector3(min.x, min.y, max.z)), tr.Transform(new Vector3(min.x, max.y, max.z)), color);
            }
Exemplo n.º 20
0
        private void ResizeAxis(Rectangle r)
        {
            if (r.Width == 0)
            {
                return;
            }
            if (r.Height == 0)
            {
                return;
            }

            double x1 = r.X - this.CurveArea.X;
            double y1 = r.Y - this.CurveArea.Y;
            double x2 = x1 + r.Width;
            double y2 = y1 + r.Height;

            x1 = GraphTransform.InvTranslateX(x1);
            y1 = GraphTransform.InvTranslateY(y1);
            x2 = GraphTransform.InvTranslateX(x2);
            y2 = GraphTransform.InvTranslateY(y2);

            if (this.AxisTypeX == AxisType.LOG)
            {
                x1 = Math.Pow(10, x1);
                x2 = Math.Pow(10, x2);
            }

            if (this.AxisTypeY == AxisType.LOG)
            {
                y1 = Math.Pow(10, y1);
                y2 = Math.Pow(10, y2);
            }

            this.AxisRangeX = new AxisData(x1, x2, Math.Abs(x2 - x1) / 5);
            this.AxisRangeY = new AxisData(y2, y1, Math.Abs(y1 - y2) / 5);


            Invalidate();
        }
Exemplo n.º 21
0
 /// <summary>Y coordinate of the center of the bounding box in graph space</summary>
 internal float GetY(GraphTransform transform)
 {
     return(transform.InverseTransform(useRotationAndScale ? tr.TransformPoint(center) : tr.position + center).y);
 }
Exemplo n.º 22
0
        private static void FindAllContours(GridGraph grid, Action <Vector3[], bool> callback, GridNodeBase[] nodes = null)
        {
            if (grid is LayerGridGraph)
            {
                nodes = (nodes ?? (grid as LayerGridGraph).nodes);
            }
            nodes = (nodes ?? grid.nodes);
            int[] neighbourXOffsets = grid.neighbourXOffsets;
            int[] neighbourZOffsets = grid.neighbourZOffsets;
            int[] array;
            if (grid.neighbours == NumNeighbours.Six)
            {
                array = GridGraph.hexagonNeighbourIndices;
            }
            else
            {
                RuntimeHelpers.InitializeArray(array = new int[4], fieldof(< PrivateImplementationDetails >.$field - 02E4414E7DFA0F3AA2387EE8EA7AB31431CB406A).FieldHandle);
            }
            int[] array2 = array;
            float num    = (grid.neighbours != NumNeighbours.Six) ? 0.5f : 0.333333343f;

            if (nodes != null)
            {
                Dictionary <Int3, int> dictionary  = new Dictionary <Int3, int>();
                Dictionary <int, int>  dictionary2 = new Dictionary <int, int>();
                HashSet <int>          hashSet     = new HashSet <int>();
                List <Vector3>         vertices    = ListPool <Vector3> .Claim();

                foreach (GridNodeBase gridNodeBase in nodes)
                {
                    if (gridNodeBase != null && gridNodeBase.Walkable && !gridNodeBase.HasConnectionsToAllEightNeighbours)
                    {
                        for (int j = 0; j < array2.Length; j++)
                        {
                            int num2 = array2[j];
                            if (gridNodeBase.GetNeighbourAlongDirection(num2) == null)
                            {
                                int     num3   = array2[(j - 1 + array2.Length) % array2.Length];
                                int     num4   = array2[(j + 1) % array2.Length];
                                Vector3 vector = new Vector3((float)gridNodeBase.XCoordinateInGrid + 0.5f, 0f, (float)gridNodeBase.ZCoordinateInGrid + 0.5f);
                                vector.x += (float)neighbourXOffsets[num2] * num;
                                vector.z += (float)neighbourZOffsets[num2] * num;
                                vector.y  = grid.transform.InverseTransform((Vector3)gridNodeBase.position).y;
                                Vector3 vector3;
                                Vector3 vector2 = vector3 = vector;
                                vector3.x += (float)neighbourXOffsets[num3] * num;
                                vector3.z += (float)neighbourZOffsets[num3] * num;
                                vector2.x += (float)neighbourXOffsets[num4] * num;
                                vector2.z += (float)neighbourZOffsets[num4] * num;
                                Int3 key  = (Int3)vector3;
                                Int3 key2 = (Int3)vector2;
                                int  key3;
                                if (dictionary.TryGetValue(key, out key3))
                                {
                                    dictionary.Remove(key);
                                }
                                else
                                {
                                    int count = vertices.Count;
                                    dictionary[key] = count;
                                    key3            = count;
                                    vertices.Add(vector3);
                                }
                                int num5;
                                if (dictionary.TryGetValue(key2, out num5))
                                {
                                    dictionary.Remove(key2);
                                }
                                else
                                {
                                    int count = vertices.Count;
                                    dictionary[key2] = count;
                                    num5             = count;
                                    vertices.Add(vector2);
                                }
                                dictionary2.Add(key3, num5);
                                hashSet.Add(num5);
                            }
                        }
                    }
                }
                GraphTransform transform    = grid.transform;
                List <Vector3> vertexBuffer = ListPool <Vector3> .Claim();

                RVONavmesh.CompressContour(dictionary2, hashSet, delegate(List <int> chain, bool cycle)
                {
                    vertexBuffer.Clear();
                    Vector3 vector4 = vertices[chain[0]];
                    vertexBuffer.Add(vector4);
                    for (int k = 1; k < chain.Count - 1; k++)
                    {
                        Vector3 vector5 = vertices[chain[k]];
                        Vector3 vector6 = vector5 - vector4;
                        Vector3 vector7 = vertices[chain[k + 1]] - vector4;
                        if (((Mathf.Abs(vector6.x) > 0.01f || Mathf.Abs(vector7.x) > 0.01f) && (Mathf.Abs(vector6.z) > 0.01f || Mathf.Abs(vector7.z) > 0.01f)) || Mathf.Abs(vector6.y) > 0.01f || Mathf.Abs(vector7.y) > 0.01f)
                        {
                            vertexBuffer.Add(vector5);
                        }
                        vector4 = vector5;
                    }
                    vertexBuffer.Add(vertices[chain[chain.Count - 1]]);
                    Vector3[] array3 = vertexBuffer.ToArray();
                    transform.Transform(array3);
                    callback(array3, cycle);
                });
                ListPool <Vector3> .Release(vertexBuffer);

                ListPool <Vector3> .Release(vertices);
            }
        }
 /// <summary>
 /// Applies transformation on the current pass.
 /// </summary>
 /// <param name="transform">The transform.</param>
 public void SetTransform(GraphTransform transform)
 {
     _g.TranslateTransform((float)transform.TranslateX, (float)transform.TranslateY);
     _g.ScaleTransform((float)transform.ScaleX, (float)transform.ScaleY);
 }
Exemplo n.º 24
0
 /// <summary>
 /// Set transform component from TRS matrix.
 /// </summary>
 /// <param name="transform">Transform component.</param>
 /// <param name="matrix">Transform matrix. This parameter is passed by reference
 /// to improve performance; no changes will be made to it.</param>
 public static void SetTransformFromMatrix(GraphTransform transform, ref Matrix4x4 matrix)
 {
     // transform.localPosition = ExtractTranslationFromMatrix(ref matrix);
     // transform.localRotation = ExtractRotationFromMatrix(ref matrix);
     // transform.localScale = ExtractScaleFromMatrix(ref matrix);
 }
Exemplo n.º 25
0
 // Token: 0x060026DC RID: 9948
 internal abstract Rect GetBounds(GraphTransform transform);
Exemplo n.º 26
0
 public abstract Rect GetBounds(GraphTransform transform);
        public override void OnSceneGUI(NavGraph target)
        {
            Event e = Event.current;

            var graph = target as GridGraph;

            graph.UpdateTransform();
            var currentTransform = graph.transform * Matrix4x4.Scale(new Vector3(graph.width, 1, graph.depth));

            if (e.type == EventType.MouseDown)
            {
                isMouseDown = true;
            }
            else if (e.type == EventType.MouseUp)
            {
                isMouseDown = false;
            }

            if (!isMouseDown)
            {
                savedTransform  = currentTransform;
                savedDimensions = new Vector2(graph.width, graph.depth);
                savedNodeSize   = graph.nodeSize;
            }

            Handles.matrix = Matrix4x4.identity;
            Handles.color  = AstarColor.BoundsHandles;
#if UNITY_5_5_OR_NEWER
            Handles.CapFunction cap = Handles.CylinderHandleCap;
#else
            Handles.DrawCapFunction cap = Handles.CylinderCap;
#endif

            var center = currentTransform.Transform(new Vector3(0.5f, 0, 0.5f));
            if (Tools.current == Tool.Scale)
            {
                const float HandleScale = 0.1f;

                Vector3 mn = Vector3.zero;
                Vector3 mx = Vector3.zero;
                EditorGUI.BeginChangeCheck();
                for (int i = 0; i < handlePoints.Length; i++)
                {
                    var     ps = currentTransform.Transform(handlePoints[i]);
                    Vector3 p  = savedTransform.InverseTransform(Handles.Slider(ps, ps - center, HandleScale * HandleUtility.GetHandleSize(ps), cap, 0));

                    // Snap to increments of whole nodes
                    p.x = Mathf.Round(p.x * savedDimensions.x) / savedDimensions.x;
                    p.z = Mathf.Round(p.z * savedDimensions.y) / savedDimensions.y;

                    if (i == 0)
                    {
                        mn = mx = p;
                    }
                    else
                    {
                        mn = Vector3.Min(mn, p);
                        mx = Vector3.Max(mx, p);
                    }
                }

                if (EditorGUI.EndChangeCheck())
                {
                    graph.center        = savedTransform.Transform((mn + mx) * 0.5f);
                    graph.unclampedSize = Vector2.Scale(new Vector2(mx.x - mn.x, mx.z - mn.z), savedDimensions) * savedNodeSize;
                }
            }
            else if (Tools.current == Tool.Move)
            {
                EditorGUI.BeginChangeCheck();
                center = Handles.PositionHandle(graph.center, Tools.pivotRotation == PivotRotation.Global ? Quaternion.identity : Quaternion.Euler(graph.rotation));

                if (EditorGUI.EndChangeCheck() && Tools.viewTool != ViewTool.Orbit)
                {
                    graph.center = center;
                }
            }
            else if (Tools.current == Tool.Rotate)
            {
                EditorGUI.BeginChangeCheck();
                var rot = Handles.RotationHandle(Quaternion.Euler(graph.rotation), graph.center);

                if (EditorGUI.EndChangeCheck() && Tools.viewTool != ViewTool.Orbit)
                {
                    graph.rotation = rot.eulerAngles;
                }
            }

            Handles.matrix = Matrix4x4.identity;
        }
        /// <summary>
        /// Called when a requested path has been calculated.
        /// A path is first requested by <see cref="UpdatePath"/>, it is then calculated, probably in the same or the next frame.
        /// Finally it is returned to the seeker which forwards it to this function.
        /// </summary>
        protected override void OnPathComplete(Path newPath)
        {
            ABPath p = newPath as ABPath;

            if (p == null)
            {
                throw new System.Exception("This function only handles ABPaths, do not use special path types");
            }

            waitingForPathCalculation = false;

            // Increase the reference count on the new path.
            // This is used for object pooling to reduce allocations.
            p.Claim(this);

            // Path couldn't be calculated of some reason.
            // More info in p.errorLog (debug string)
            if (p.error)
            {
                p.Release(this);
                return;
            }

            // Release the previous path.
            if (path != null)
            {
                path.Release(this);
            }

            // Replace the old path
            path = p;

            // Make sure the path contains at least 2 points
            if (path.vectorPath.Count == 1)
            {
                path.vectorPath.Add(path.vectorPath[0]);
            }
            interpolator.SetPath(path.vectorPath);

            var graph         = path.path.Count > 0 ? AstarData.GetGraph(path.path[0]) as ITransformedGraph : null;
            var graphRotation = new Vector3(-90, 0, 0);

            movementPlane = new GraphTransform(Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(graphRotation), Vector3.one));

            // Reset some variables
            reachedEndOfPath = false;

            // Simulate movement from the point where the path was requested
            // to where we are right now. This reduces the risk that the agent
            // gets confused because the first point in the path is far away
            // from the current position (possibly behind it which could cause
            // the agent to turn around, and that looks pretty bad).
            interpolator.MoveToLocallyClosestPoint((GetFeetPosition() + p.originalStartPoint) * 0.5f);
            interpolator.MoveToLocallyClosestPoint(GetFeetPosition());

            // Update which point we are moving towards.
            // Note that we need to do this here because otherwise the remainingDistance field might be incorrect for 1 frame.
            // (due to interpolator.remainingDistance being incorrect).
            interpolator.MoveToCircleIntersection2D(position, pickNextWaypointDist, movementPlane);

            var distanceToEnd = remainingDistance;

            if (distanceToEnd <= endReachedDistance)
            {
                reachedEndOfPath = true;
                OnTargetReached();
            }
        }
Exemplo n.º 29
0
 // Token: 0x06002695 RID: 9877 RVA: 0x001A884F File Offset: 0x001A6A4F
 internal float GetY(GraphTransform transform)
 {
     return(transform.InverseTransform(this.useRotationAndScale ? this.tr.TransformPoint(this.center) : (this.tr.position + this.center)).y);
 }
Exemplo n.º 30
0
 /// <summary>
 /// Applies transformation on the current pass.
 /// </summary>
 /// <param name="transform">The transform.</param>
 public void SetTransform(GraphTransform transform)
 {
     _session.Transform = Matrix3x2.CreateTranslation(transform.TranslateX / transform.ScaleX, transform.TranslateY / transform.ScaleY) * Matrix3x2.CreateScale(transform.ScaleX, transform.ScaleY);
 }