Pathfinding.Int3.DotLong C# (CSharp) Méthode

DotLong() public static méthode

public static DotLong ( Int3 lhs, Int3 rhs ) : long
lhs Int3
rhs Int3
Résultat long
		public static long DotLong (Int3 lhs, Int3 rhs) {
			return
					(long)lhs.x * (long)rhs.x +
					(long)lhs.y * (long)rhs.y +
					(long)lhs.z * (long)rhs.z;
		}
		

Usage Example

        public void Apply(bool forceNewCheck)
        {
            NNConstraint none = NNConstraint.None;

            none.distanceXZ = true;
            int graphIndex = (int)this.startNode.GraphIndex;

            none.graphMask = ~(1 << graphIndex);
            bool   flag    = true;
            NNInfo nearest = AstarPath.active.GetNearest(this.StartTransform.position, none);

            flag &= (nearest.node == this.connectedNode1 && nearest.node != null);
            this.connectedNode1 = (nearest.node as MeshNode);
            this.clamped1       = nearest.clampedPosition;
            if (this.connectedNode1 != null)
            {
                Debug.DrawRay((Vector3)this.connectedNode1.position, Vector3.up * 5f, Color.red);
            }
            NNInfo nearest2 = AstarPath.active.GetNearest(this.EndTransform.position, none);

            flag &= (nearest2.node == this.connectedNode2 && nearest2.node != null);
            this.connectedNode2 = (nearest2.node as MeshNode);
            this.clamped2       = nearest2.clampedPosition;
            if (this.connectedNode2 != null)
            {
                Debug.DrawRay((Vector3)this.connectedNode2.position, Vector3.up * 5f, Color.cyan);
            }
            if (this.connectedNode2 == null || this.connectedNode1 == null)
            {
                return;
            }
            this.startNode.SetPosition((Int3)this.StartTransform.position);
            this.endNode.SetPosition((Int3)this.EndTransform.position);
            if (flag && !forceNewCheck)
            {
                return;
            }
            this.RemoveConnections(this.startNode);
            this.RemoveConnections(this.endNode);
            uint cost = (uint)Mathf.RoundToInt((float)((Int3)(this.StartTransform.position - this.EndTransform.position)).costMagnitude * this.costFactor);

            this.startNode.AddConnection(this.endNode, cost);
            this.endNode.AddConnection(this.startNode, cost);
            Int3 rhs = this.connectedNode2.position - this.connectedNode1.position;

            for (int i = 0; i < this.connectedNode1.GetVertexCount(); i++)
            {
                Int3 vertex  = this.connectedNode1.GetVertex(i);
                Int3 vertex2 = this.connectedNode1.GetVertex((i + 1) % this.connectedNode1.GetVertexCount());
                if (Int3.DotLong((vertex2 - vertex).Normal2D(), rhs) <= 0L)
                {
                    for (int j = 0; j < this.connectedNode2.GetVertexCount(); j++)
                    {
                        Int3 vertex3 = this.connectedNode2.GetVertex(j);
                        Int3 vertex4 = this.connectedNode2.GetVertex((j + 1) % this.connectedNode2.GetVertexCount());
                        if (Int3.DotLong((vertex4 - vertex3).Normal2D(), rhs) >= 0L)
                        {
                            if ((double)Int3.Angle(vertex4 - vertex3, vertex2 - vertex) > 2.9670598109563189)
                            {
                                float num  = 0f;
                                float num2 = 1f;
                                num2 = Math.Min(num2, VectorMath.ClosestPointOnLineFactor(vertex, vertex2, vertex3));
                                num  = Math.Max(num, VectorMath.ClosestPointOnLineFactor(vertex, vertex2, vertex4));
                                if (num2 >= num)
                                {
                                    Vector3 vector  = (Vector3)(vertex2 - vertex) * num + (Vector3)vertex;
                                    Vector3 vector2 = (Vector3)(vertex2 - vertex) * num2 + (Vector3)vertex;
                                    this.startNode.portalA = vector;
                                    this.startNode.portalB = vector2;
                                    this.endNode.portalA   = vector2;
                                    this.endNode.portalB   = vector;
                                    this.connectedNode1.AddConnection(this.startNode, (uint)Mathf.RoundToInt((float)((Int3)(this.clamped1 - this.StartTransform.position)).costMagnitude * this.costFactor));
                                    this.connectedNode2.AddConnection(this.endNode, (uint)Mathf.RoundToInt((float)((Int3)(this.clamped2 - this.EndTransform.position)).costMagnitude * this.costFactor));
                                    this.startNode.AddConnection(this.connectedNode1, (uint)Mathf.RoundToInt((float)((Int3)(this.clamped1 - this.StartTransform.position)).costMagnitude * this.costFactor));
                                    this.endNode.AddConnection(this.connectedNode2, (uint)Mathf.RoundToInt((float)((Int3)(this.clamped2 - this.EndTransform.position)).costMagnitude * this.costFactor));
                                    return;
                                }
                                Debug.LogError(string.Concat(new object[]
                                {
                                    "Wait wut!? ",
                                    num,
                                    " ",
                                    num2,
                                    " ",
                                    vertex,
                                    " ",
                                    vertex2,
                                    " ",
                                    vertex3,
                                    " ",
                                    vertex4,
                                    "\nTODO, fix this error"
                                }));
                            }
                        }
                    }
                }
            }
        }
All Usage Examples Of Pathfinding.Int3::DotLong