Exemple #1
0
    // NetNode
    // Token: 0x060034C5 RID: 13509 RVA: 0x0023CECC File Offset: 0x0023B2CC
    private void RefreshJunctionData(ushort nodeID, int segmentIndex, int segmentIndex2, NetInfo info, NetInfo info2, ushort segmentID, ushort segmentID2, ref uint instanceIndex, ref RenderManager.Instance data)
    {
        data.m_position    = this.m_position;
        data.m_rotation    = Quaternion.identity;
        data.m_initialized = true;
        float   vscale      = info.m_netAI.GetVScale();
        Vector3 CornerPos2L = Vector3.zero;
        Vector3 CornerPos2R = Vector3.zero;
        Vector3 CornerDir2L = Vector3.zero;
        Vector3 CornerDir2R = Vector3.zero;
        bool    startNode   = Singleton <NetManager> .instance.m_segments.m_buffer[(int)segmentID].m_startNode == nodeID;

        Singleton <NetManager> .instance.m_segments.m_buffer[(int)segmentID].CalculateCorner(segmentID, true, startNode, false, out var CornerPosL, out var CornerDirL, out _);
        Singleton <NetManager> .instance.m_segments.m_buffer[(int)segmentID].CalculateCorner(segmentID, true, startNode, true, out var CornerPosR, out var CornerDirR, out _);
        bool startNode2 = (Singleton <NetManager> .instance.m_segments.m_buffer[(int)segmentID2].m_startNode == nodeID);

        Singleton <NetManager> .instance.m_segments.m_buffer[(int)segmentID2].CalculateCorner(segmentID2, true, startNode2, true, out CornerPos2L, out CornerDir2L, out _);
        Singleton <NetManager> .instance.m_segments.m_buffer[(int)segmentID2].CalculateCorner(segmentID2, true, startNode2, false, out CornerPos2R, out CornerDir2R, out _);
        Vector3 b = (CornerPos2R - CornerPos2L) * (info.m_halfWidth / info2.m_halfWidth * 0.5f - 0.5f);

        CornerPos2L -= b;
        CornerPos2R += b;
        NetSegment.CalculateMiddlePoints(CornerPosL, -CornerDirL, CornerPos2L, -CornerDir2L, true, true, out var bpointL, out var cpointL);
        NetSegment.CalculateMiddlePoints(CornerPosR, -CornerDirR, CornerPos2R, -CornerDir2R, true, true, out var bpointR, out var cpointR);
        data.m_dataMatrix0             = NetSegment.CalculateControlMatrix(CornerPosL, bpointL, cpointL, CornerPos2L, CornerPosR, bpointR, cpointR, CornerPos2R, this.m_position, vscale);
        data.m_extraData.m_dataMatrix2 = NetSegment.CalculateControlMatrix(CornerPosR, bpointR, cpointR, CornerPos2R, CornerPosL, bpointL, cpointL, CornerPos2L, this.m_position, vscale);
        data.m_dataVector0             = new Vector4(0.5f / info.m_halfWidth, 1f / info.m_segmentLength, 1f, 1f);
        Vector4 colorLocation;
        Vector4 vector7;

        if (NetNode.BlendJunction(nodeID))
        {
            colorLocation = RenderManager.GetColorLocation(86016u + (uint)nodeID);
            vector7       = colorLocation;
        }
        else
        {
            colorLocation = RenderManager.GetColorLocation((uint)(49152 + segmentID));
            vector7       = RenderManager.GetColorLocation((uint)(49152 + segmentID2));
        }
        data.m_dataVector3  = new Vector4(colorLocation.x, colorLocation.y, vector7.x, vector7.y);
        data.m_dataInt0     = (8 | segmentIndex | segmentIndex2 << 4);
        data.m_dataColor0   = info.m_color;
        data.m_dataColor0.a = 0f;
        data.m_dataFloat0   = Singleton <WeatherManager> .instance.GetWindSpeed(data.m_position);

        if (info.m_requireSurfaceMaps)
        {
            Singleton <TerrainManager> .instance.GetSurfaceMapping(data.m_position, out data.m_dataTexture0, out data.m_dataTexture1, out data.m_dataVector1);
        }
        instanceIndex = (uint)data.m_nextInstance;
    }
        private Mesh GetSegmentMesh(ushort segmentId, out Vector3 position)
        {
            NetSegment segment = netManager.m_segments.m_buffer[segmentId];
            NetInfo    info    = segment.Info;

            NetInfo.Segment seg = info.m_segments.Length == 1 ? info.m_segments[0] : info.m_segments[2];

            Vector3 position1 = netManager.m_nodes.m_buffer[(int)segment.m_startNode].m_position;
            Vector3 position2 = netManager.m_nodes.m_buffer[(int)segment.m_endNode].m_position;

            position = (position1 + position2) * 0.5f;

            float vscale = info.m_netAI.GetVScale();

            segment.CalculateCorner(segmentId, true, true, true, out Vector3 cornerPos1, out Vector3 cornerDirection1,
                                    out bool smooth1);
            segment.CalculateCorner(segmentId, true, false, true, out Vector3 cornerPos2, out Vector3 cornerDirection2,
                                    out bool smooth2);
            segment.CalculateCorner(segmentId, true, true, false, out Vector3 cornerPos3, out Vector3 cornerDirection3,
                                    out smooth1);
            segment.CalculateCorner(segmentId, true, false, false, out Vector3 cornerPos4, out Vector3 cornerDirection4,
                                    out smooth2);

            NetSegment.CalculateMiddlePoints(cornerPos1, cornerDirection1, cornerPos4, cornerDirection4, smooth1,
                                             smooth2, out Vector3 middlePos1_1, out Vector3 middlePos2_1);
            NetSegment.CalculateMiddlePoints(cornerPos3, cornerDirection3, cornerPos2, cornerDirection2, smooth1,
                                             smooth2, out Vector3 middlePos1_2, out Vector3 middlePos2_2);

            Matrix4x4 leftMatrix = NetSegment.CalculateControlMatrix(cornerPos1, middlePos1_1, middlePos2_1,
                                                                     cornerPos4, cornerPos3, middlePos1_2, middlePos2_2, cornerPos2, position, vscale);
            Matrix4x4 rightMatrix = NetSegment.CalculateControlMatrix(cornerPos3, middlePos1_2, middlePos2_2,
                                                                      cornerPos2, cornerPos1, middlePos1_1, middlePos2_1, cornerPos4, position, vscale);

            Bezier3 leftBezier = new Bezier3(
                leftMatrix.GetColumn(0),
                leftMatrix.GetColumn(1),
                leftMatrix.GetColumn(2),
                leftMatrix.GetColumn(3));
            Bezier3 rightBezier = new Bezier3(
                rightMatrix.GetColumn(0),
                rightMatrix.GetColumn(1),
                rightMatrix.GetColumn(2),
                rightMatrix.GetColumn(3));

            Mesh mesh = BendMesh(seg.m_segmentMesh, leftBezier, rightBezier, info);

            return(mesh);
        }
Exemple #3
0
        private void CalculateMatrix(float width, float height, out Matrix4x4 left, out Matrix4x4 right)
        {
            var bezierL = new Bezier3()
            {
                a = new Vector3(-width, 0f, -height),
                b = new Vector3(-width, 0f, -height / 3),
                c = new Vector3(-width, 0f, height / 3),
                d = new Vector3(-width, 0f, height),
            };
            var bezierR = new Bezier3()
            {
                a = new Vector3(width, 0f, -height),
                b = new Vector3(width, 0f, -height / 3),
                c = new Vector3(width, 0f, height / 3),
                d = new Vector3(width, 0f, height),
            };

            left  = NetSegment.CalculateControlMatrix(bezierL.a, bezierL.b, bezierL.c, bezierL.d, bezierR.a, bezierR.b, bezierR.c, bezierR.d, Vector3.zero, 0.05f);
            right = NetSegment.CalculateControlMatrix(bezierR.a, bezierR.b, bezierR.c, bezierR.d, bezierL.a, bezierL.b, bezierL.c, bezierL.d, Vector3.zero, 0.05f);
        }
Exemple #4
0
        protected void CalculateMatrix(ITrajectory trajectory, float halfWidth, Vector3 position, out Matrix4x4 left, out Matrix4x4 right)
        {
            var startNormal = trajectory.StartDirection.Turn90(true).MakeFlatNormalized();
            var endNormal   = trajectory.EndDirection.Turn90(false).MakeFlatNormalized();

            var bezierL = new Bezier3()
            {
                a = trajectory.StartPosition - startNormal * halfWidth,
                d = trajectory.EndPosition - endNormal * halfWidth,
            };
            var bezierR = new Bezier3()
            {
                a = trajectory.StartPosition + startNormal * halfWidth,
                d = trajectory.EndPosition + endNormal * halfWidth,
            };

            NetSegment.CalculateMiddlePoints(bezierL.a, trajectory.StartDirection, bezierL.d, trajectory.EndDirection, true, true, out bezierL.b, out bezierL.c);
            NetSegment.CalculateMiddlePoints(bezierR.a, trajectory.StartDirection, bezierR.d, trajectory.EndDirection, true, true, out bezierR.b, out bezierR.c);

            left  = NetSegment.CalculateControlMatrix(bezierL.a, bezierL.b, bezierL.c, bezierL.d, bezierR.a, bezierR.b, bezierR.c, bezierR.d, position, 0.05f);
            right = NetSegment.CalculateControlMatrix(bezierR.a, bezierR.b, bezierR.c, bezierR.d, bezierL.a, bezierL.b, bezierL.c, bezierL.d, position, 0.05f);
        }
Exemple #5
0
        public void RefreshJunctionData(ushort nodeID, int segmentIndex, ushort nodeSegment, Vector3 centerPos, ref uint instanceIndex, ref RenderManager.Instance data)
        {
            NetNode    thisNode = NetManager.instance.m_nodes.m_buffer[nodeID];
            NetManager instance = Singleton <NetManager> .instance;

            data.m_position    = thisNode.m_position;
            data.m_rotation    = Quaternion.identity;
            data.m_initialized = true;
            float      vScale          = 0.05f;
            Vector3    zero            = Vector3.zero;
            Vector3    zero2           = Vector3.zero;
            Vector3    zero3           = Vector3.zero;
            Vector3    zero4           = Vector3.zero;
            Vector3    vector          = Vector3.zero;
            Vector3    vector2         = Vector3.zero;
            Vector3    a               = Vector3.zero;
            Vector3    a2              = Vector3.zero;
            Vector3    zero5           = Vector3.zero;
            Vector3    zero6           = Vector3.zero;
            Vector3    zero7           = Vector3.zero;
            Vector3    zero8           = Vector3.zero;
            NetSegment netSegment      = instance.m_segments.m_buffer[(int)nodeSegment];
            NetInfo    info            = netSegment.Info;
            ItemClass  connectionClass = info.GetConnectionClass();
            Vector3    vector3         = (nodeID != netSegment.m_startNode) ? netSegment.m_endDirection : netSegment.m_startDirection;
            float      num             = -4f;
            float      num2            = -4f;
            ushort     num3            = 0;
            ushort     num4            = 0;

            for (int i = 0; i < 8; i++)
            {
                ushort segment = thisNode.GetSegment(i);
                if (segment != 0 && segment != nodeSegment)
                {
                    NetInfo   info2            = instance.m_segments.m_buffer[(int)segment].Info;
                    ItemClass connectionClass2 = info2.GetConnectionClass();
                    if (connectionClass.m_service == connectionClass2.m_service)
                    {
                        NetSegment netSegment2 = instance.m_segments.m_buffer[(int)segment];
                        Vector3    vector4     = (nodeID != netSegment2.m_startNode) ? netSegment2.m_endDirection : netSegment2.m_startDirection;
                        float      num5        = vector3.x * vector4.x + vector3.z * vector4.z;
                        if (vector4.z * vector3.x - vector4.x * vector3.z < 0f)
                        {
                            if (num5 > num)
                            {
                                num  = num5;
                                num3 = segment;
                            }
                            num5 = -2f - num5;
                            if (num5 > num2)
                            {
                                num2 = num5;
                                num4 = segment;
                            }
                        }
                        else
                        {
                            if (num5 > num2)
                            {
                                num2 = num5;
                                num4 = segment;
                            }
                            num5 = -2f - num5;
                            if (num5 > num)
                            {
                                num  = num5;
                                num3 = segment;
                            }
                        }
                    }
                }
            }
            bool start = netSegment.m_startNode == nodeID;
            bool flag;

            netSegment.CalculateCorner(nodeSegment, true, start, false, out zero, out zero3, out flag);
            netSegment.CalculateCorner(nodeSegment, true, start, true, out zero2, out zero4, out flag);
            if (num3 != 0 && num4 != 0)
            {
                float num6 = info.m_pavementWidth / info.m_halfWidth * 0.5f;
                float y    = 1f;
                if (num3 != 0)
                {
                    NetSegment netSegment3 = instance.m_segments.m_buffer[(int)num3];
                    NetInfo    info3       = netSegment3.Info;
                    start = (netSegment3.m_startNode == nodeID);
                    netSegment3.CalculateCorner(num3, true, start, true, out vector, out a, out flag);
                    netSegment3.CalculateCorner(num3, true, start, false, out vector2, out a2, out flag);
                    float num7 = info3.m_pavementWidth / info3.m_halfWidth * 0.5f;
                    num6 = (num6 + num7) * 0.5f;
                    y    = 2f * info.m_halfWidth / (info.m_halfWidth + info3.m_halfWidth);
                }
                float num8 = info.m_pavementWidth / info.m_halfWidth * 0.5f;
                float w    = 1f;
                if (num4 != 0)
                {
                    NetSegment netSegment4 = instance.m_segments.m_buffer[(int)num4];
                    NetInfo    info4       = netSegment4.Info;
                    start = (netSegment4.m_startNode == nodeID);
                    netSegment4.CalculateCorner(num4, true, start, true, out zero5, out zero7, out flag);
                    netSegment4.CalculateCorner(num4, true, start, false, out zero6, out zero8, out flag);
                    float num9 = info4.m_pavementWidth / info4.m_halfWidth * 0.5f;
                    num8 = (num8 + num9) * 0.5f;
                    w    = 2f * info.m_halfWidth / (info.m_halfWidth + info4.m_halfWidth);
                }
                Vector3 vector5;
                Vector3 vector6;
                NetSegment.CalculateMiddlePoints(zero, -zero3, vector, -a, true, true, out vector5, out vector6);
                Vector3 vector7;
                Vector3 vector8;
                NetSegment.CalculateMiddlePoints(zero2, -zero4, vector2, -a2, true, true, out vector7, out vector8);
                Vector3 vector9;
                Vector3 vector10;
                NetSegment.CalculateMiddlePoints(zero, -zero3, zero5, -zero7, true, true, out vector9, out vector10);
                Vector3 vector11;
                Vector3 vector12;
                NetSegment.CalculateMiddlePoints(zero2, -zero4, zero6, -zero8, true, true, out vector11, out vector12);

                data.m_dataMatrix0             = NetSegment.CalculateControlMatrix(zero, vector5, vector6, vector, zero, vector5, vector6, vector, thisNode.m_position, vScale);
                data.m_extraData.m_dataMatrix2 = NetSegment.CalculateControlMatrix(zero2, vector7, vector8, vector2, zero2, vector7, vector8, vector2, thisNode.m_position, vScale);
                data.m_extraData.m_dataMatrix3 = NetSegment.CalculateControlMatrix(zero, vector9, vector10, zero5, zero, vector9, vector10, zero5, thisNode.m_position, vScale);
                data.m_dataMatrix1             = NetSegment.CalculateControlMatrix(zero2, vector11, vector12, zero6, zero2, vector11, vector12, zero6, thisNode.m_position, vScale);
                data.m_dataVector0             = new Vector4(0.5f / info.m_halfWidth, 1f / info.m_segmentLength, 0.5f - info.m_pavementWidth / info.m_halfWidth * 0.5f, info.m_pavementWidth / info.m_halfWidth * 0.5f);
                data.m_dataVector1             = centerPos - data.m_position;

                if ((thisNode.m_flags & NetNode.Flags.Junction) == NetNode.Flags.None)
                {
                    data.m_dataVector1.w = (data.m_dataMatrix0.m33 + data.m_extraData.m_dataMatrix2.m33 + data.m_extraData.m_dataMatrix3.m33 + data.m_dataMatrix1.m33) * 0.25f;
                }
                else
                {
                    data.m_dataVector1.w = 0.01f;
                }

                data.m_dataVector2             = new Vector4(num6, y, num8, w);
                data.m_extraData.m_dataVector4 = RenderManager.GetColorLocation(65536u + (uint)nodeID);
            }
            else
            {
                centerPos.x = (zero.x + zero2.x) * 0.5f;
                centerPos.z = (zero.z + zero2.z) * 0.5f;
                vector      = zero2;
                vector2     = zero;
                a           = zero4;
                a2          = zero3;
                float   d        = Mathf.Min(info.m_halfWidth * 1.33333337f, 16f);
                Vector3 vector13 = zero - zero3 * d;
                Vector3 vector14 = vector - a * d;
                Vector3 vector15 = zero2 - zero4 * d;
                Vector3 vector16 = vector2 - a2 * d;
                Vector3 vector17 = zero + zero3 * d;
                Vector3 vector18 = vector + a * d;
                Vector3 vector19 = zero2 + zero4 * d;
                Vector3 vector20 = vector2 + a2 * d;
                data.m_dataMatrix0             = NetSegment.CalculateControlMatrix(zero, vector13, vector14, vector, zero, vector13, vector14, vector, thisNode.m_position, vScale);
                data.m_extraData.m_dataMatrix2 = NetSegment.CalculateControlMatrix(zero2, vector19, vector20, vector2, zero2, vector19, vector20, vector2, thisNode.m_position, vScale);
                data.m_extraData.m_dataMatrix3 = NetSegment.CalculateControlMatrix(zero, vector17, vector18, vector, zero, vector17, vector18, vector, thisNode.m_position, vScale);
                data.m_dataMatrix1             = NetSegment.CalculateControlMatrix(zero2, vector15, vector16, vector2, zero2, vector15, vector16, vector2, thisNode.m_position, vScale);
                data.m_dataMatrix0.SetRow(3, data.m_dataMatrix0.GetRow(3) + new Vector4(0.2f, 0.2f, 0.2f, 0.2f));
                data.m_extraData.m_dataMatrix2.SetRow(3, data.m_extraData.m_dataMatrix2.GetRow(3) + new Vector4(0.2f, 0.2f, 0.2f, 0.2f));
                data.m_extraData.m_dataMatrix3.SetRow(3, data.m_extraData.m_dataMatrix3.GetRow(3) + new Vector4(0.2f, 0.2f, 0.2f, 0.2f));
                data.m_dataMatrix1.SetRow(3, data.m_dataMatrix1.GetRow(3) + new Vector4(0.2f, 0.2f, 0.2f, 0.2f));
                data.m_dataVector0             = new Vector4(0.5f / info.m_halfWidth, 1f / info.m_segmentLength, 0.5f - info.m_pavementWidth / info.m_halfWidth * 0.5f, info.m_pavementWidth / info.m_halfWidth * 0.5f);
                data.m_dataVector1             = centerPos - data.m_position;
                data.m_dataVector1.w           = (data.m_dataMatrix0.m33 + data.m_extraData.m_dataMatrix2.m33 + data.m_extraData.m_dataMatrix3.m33 + data.m_dataMatrix1.m33) * 0.25f;
                data.m_dataVector2             = new Vector4(info.m_pavementWidth / info.m_halfWidth * 0.5f, 1f, info.m_pavementWidth / info.m_halfWidth * 0.5f, 1f);
                data.m_extraData.m_dataVector4 = RenderManager.GetColorLocation(65536u + (uint)nodeID);
            }
            data.m_dataInt0     = segmentIndex;
            data.m_dataColor0   = info.m_color;
            data.m_dataColor0.a = 0f;
            if (info.m_requireSurfaceMaps)
            {
                Singleton <TerrainManager> .instance.GetSurfaceMapping(data.m_position, out data.m_dataTexture0, out data.m_dataTexture1, out data.m_dataVector3);
            }
            instanceIndex = (uint)data.m_nextInstance;
        }
Exemple #6
0
    // NetNode
    // Token: 0x060034C6 RID: 13510 RVA: 0x0023D1EC File Offset: 0x0023B5EC

    /// <param name="centerPos">position between left corner and right corner of segmentID (or something like that).</param>
    private static void RefreshJunctionData(ref NetNode This, ushort nodeID, int segmentIndex, ushort SegmentID, Vector3 centerPos, ref uint instanceIndex, ref RenderManager.Instance data)
    {
        Vector3 cornerPos_right = Vector3.zero, cornerDir_right = Vector3.zero, cornerPos_left = Vector3.zero, cornerDir_left = Vector3.zero,
                cornerPosA_right = Vector3.zero, cornerDirA_right = Vector3.zero, cornerPosA_left = Vector3.zero, cornerDirA_left = Vector3.zero,
                cornerPosB_right = Vector3.zero, cornerDirB_right = Vector3.zero, cornerPosB_left = Vector3.zero, cornerDirB_left = Vector3.zero;

        NetManager instance = Singleton <NetManager> .instance;

        data.m_position    = This.m_position;
        data.m_rotation    = Quaternion.identity;
        data.m_initialized = true;
        NetSegment segment         = SegmentID.ToSegment();
        NetInfo    info            = segment.Info;
        float      vscale          = info.m_netAI.GetVScale();
        ItemClass  connectionClass = info.GetConnectionClass();
        bool       bStartNode      = nodeID == segment.m_startNode;
        Vector3    dir             = !bStartNode ? segment.m_endDirection : segment.m_startDirection;
        float      dot_A           = -4f;
        float      dot_B           = -4f;
        ushort     segmentID_A     = 0;
        ushort     segmentID_B     = 0;

        for (int i = 0; i < 8; i++)
        {
            ushort segmentID2 = This.GetSegment(i);
            if (segmentID2 != 0 && segmentID2 != SegmentID)
            {
                NetInfo   info2            = instance.m_segments.m_buffer[(int)segmentID2].Info;
                ItemClass connectionClass2 = info2.GetConnectionClass();
                if (connectionClass.m_service == connectionClass2.m_service)
                {
                    NetSegment segment2    = segmentID2.ToSegment();
                    bool       bStartNode2 = nodeID != segment2.m_startNode;
                    Vector3    dir2        = !bStartNode2 ? segment2.m_endDirection : segment2.m_startDirection;
                    float      dot         = dir.x * dir2.x + dir.z * dir2.z;
                    float      determinent = dir2.z * dir.x - dir2.x * dir.z;
                    bool       bRight      = determinent > 0;
                    bool       bWide       = dot < 0;
                    // 180 -> det=0 dot=-1
                    if (!bRight)
                    {
                        if (dot > dot_A) // most accute
                        {
                            dot_A       = dot;
                            segmentID_A = segmentID2;
                        }
                        dot = -2f - dot;
                        if (dot > dot_B) // widest
                        {
                            dot_B       = dot;
                            segmentID_B = segmentID2;
                        }
                    }
                    else
                    {
                        if (dot > dot_B) // most accute
                        {
                            dot_B       = dot;
                            segmentID_B = segmentID2;
                        }
                        dot = -2f - dot;
                        if (dot > dot_A) // widest
                        {
                            dot_A       = dot;
                            segmentID_A = segmentID2;
                        }
                    }
                }
            }
        }
        segment.CalculateCorner(SegmentID, true, bStartNode, false, out cornerPos_right, out cornerDir_right, out _);
        segment.CalculateCorner(SegmentID, true, bStartNode, true, out cornerPos_left, out cornerDir_left, out _);
        if (segmentID_A != 0 && segmentID_B != 0)
        {
            float pavementRatio_avgA = info.m_pavementWidth / info.m_halfWidth * 0.5f;
            float averageWidthA      = 1f;
            if (segmentID_A != 0)
            {
                NetSegment segment_A = instance.m_segments.m_buffer[(int)segmentID_A];
                NetInfo    infoA     = segment_A.Info;
                bStartNode = (segment_A.m_startNode == nodeID);
                segment_A.CalculateCorner(segmentID_A, true, bStartNode, true, out cornerPosA_right, out cornerDirA_right, out _);
                segment_A.CalculateCorner(segmentID_A, true, bStartNode, false, out cornerPosA_left, out cornerDirA_left, out _);
                float pavementRatioA = infoA.m_pavementWidth / infoA.m_halfWidth * 0.5f;
                pavementRatio_avgA = (pavementRatio_avgA + pavementRatioA) * 0.5f;
                averageWidthA      = 2f * info.m_halfWidth / (info.m_halfWidth + infoA.m_halfWidth);
            }
            float pavementRatio_avgB = info.m_pavementWidth / info.m_halfWidth * 0.5f;
            float averageWithB       = 1f;
            if (segmentID_B != 0)
            {
                NetSegment segment_B = instance.m_segments.m_buffer[(int)segmentID_B];
                NetInfo    infoB     = segment_B.Info;
                bStartNode = (segment_B.m_startNode == nodeID);
                segment_B.CalculateCorner(segmentID_B, true, bStartNode, true, out cornerPosB_right, out cornerDirB_right, out _);
                segment_B.CalculateCorner(segmentID_B, true, bStartNode, false, out cornerPosB_left, out cornerDirB_left, out _);
                float pavementRatioB = infoB.m_pavementWidth / infoB.m_halfWidth * 0.5f;
                pavementRatio_avgB = (pavementRatio_avgB + pavementRatioB) * 0.5f;
                averageWithB       = 2f * info.m_halfWidth / (info.m_halfWidth + infoB.m_halfWidth);
            }

            Bezier3 bezierA_right = new Bezier3
            {
                a = cornerPos_right,
                d = cornerPosA_right,
            };

            NetSegment.CalculateMiddlePoints(bezierA_right.a, -cornerDir_right, bezierA_right.d, -cornerDirA_right, true, true, out bezierA_right.b, out bezierA_right.c);
            NetSegment.CalculateMiddlePoints(cornerPos_left, -cornerDir_left, cornerPosA_left, -cornerDirA_left, true, true, out var cpoint2_Aleft, out var cpoint3_Aleft);
            NetSegment.CalculateMiddlePoints(cornerPos_right, -cornerDir_right, cornerPosB_right, -cornerDirB_right, true, true, out var cpoint2_Bright, out var cpoint3_Bright);
            NetSegment.CalculateMiddlePoints(cornerPos_left, -cornerDir_left, cornerPosB_left, -cornerDirB_left, true, true, out var cpoint2_Bleft, out var cpoint3_Bleft);

            data.m_dataMatrix0             = NetSegment.CalculateControlMatrix(bezierA_right.a, bezierA_right.b, bezierA_right.c, bezierA_right.d, bezierA_right.a, bezierA_right.b, bezierA_right.c, bezierA_right.d, This.m_position, vscale);
            data.m_extraData.m_dataMatrix2 = NetSegment.CalculateControlMatrix(cornerPos_left, cpoint2_Aleft, cpoint3_Aleft, cornerPosA_left, cornerPos_left, cpoint2_Aleft, cpoint3_Aleft, cornerPosA_left, This.m_position, vscale);
            data.m_extraData.m_dataMatrix3 = NetSegment.CalculateControlMatrix(cornerPos_right, cpoint2_Bright, cpoint3_Bright, cornerPosB_right, cornerPos_right, cpoint2_Bright, cpoint3_Bright, cornerPosB_right, This.m_position, vscale);
            data.m_dataMatrix1             = NetSegment.CalculateControlMatrix(cornerPos_left, cpoint2_Bleft, cpoint3_Bleft, cornerPosB_left, cornerPos_left, cpoint2_Bleft, cpoint3_Bleft, cornerPosB_left, This.m_position, vscale);

            // Vector4(1/width | 1/length | 0.5 - pavement/width | pavement/width )
            data.m_dataVector0   = new Vector4(0.5f / info.m_halfWidth, 1f / info.m_segmentLength, 0.5f - info.m_pavementWidth / info.m_halfWidth * 0.5f, info.m_pavementWidth / info.m_halfWidth * 0.5f);
            data.m_dataVector1   = centerPos - data.m_position;
            data.m_dataVector1.w = (data.m_dataMatrix0.m31 + data.m_dataMatrix0.m32 + data.m_extraData.m_dataMatrix2.m31 + data.m_extraData.m_dataMatrix2.m32 + data.m_extraData.m_dataMatrix3.m31 + data.m_extraData.m_dataMatrix3.m32 + data.m_dataMatrix1.m31 + data.m_dataMatrix1.m32) * 0.125f;
            data.m_dataVector2   = new Vector4(pavementRatio_avgA, averageWidthA, pavementRatio_avgB, averageWithB);
        }
        else
        {
            centerPos.x = (cornerPos_right.x + cornerPos_left.x) * 0.5f;
            centerPos.z = (cornerPos_right.z + cornerPos_left.z) * 0.5f;
            var cornerPos_left_prev  = cornerPos_left;
            var cornerPos_right_prev = cornerPos_right;
            cornerDirB_right = cornerDir_left;
            cornerDirB_left  = cornerDir_right;
            float   d        = info.m_netAI.GetEndRadius() * 1.33333337f;
            Vector3 vector13 = cornerPos_right - cornerDir_right * d;
            Vector3 vector14 = cornerPos_left_prev - cornerDirB_right * d;
            Vector3 vector15 = cornerPos_left - cornerDir_left * d;
            Vector3 vector16 = cornerPos_right_prev - cornerDirB_left * d;
            Vector3 vector17 = cornerPos_right + cornerDir_right * d;
            Vector3 vector18 = cornerPos_left_prev + cornerDirB_right * d;
            Vector3 vector19 = cornerPos_left + cornerDir_left * d;
            Vector3 vector20 = cornerPos_right_prev + cornerDirB_left * d;
            data.m_dataMatrix0             = NetSegment.CalculateControlMatrix(cornerPos_right, vector13, vector14, cornerPos_left_prev, cornerPos_right, vector13, vector14, cornerPos_left_prev, This.m_position, vscale);
            data.m_extraData.m_dataMatrix2 = NetSegment.CalculateControlMatrix(cornerPos_left, vector19, vector20, cornerPos_right_prev, cornerPos_left, vector19, vector20, cornerPos_right_prev, This.m_position, vscale);
            data.m_extraData.m_dataMatrix3 = NetSegment.CalculateControlMatrix(cornerPos_right, vector17, vector18, cornerPos_left_prev, cornerPos_right, vector17, vector18, cornerPos_left_prev, This.m_position, vscale);
            data.m_dataMatrix1             = NetSegment.CalculateControlMatrix(cornerPos_left, vector15, vector16, cornerPos_right_prev, cornerPos_left, vector15, vector16, cornerPos_right_prev, This.m_position, vscale);
            data.m_dataMatrix0.SetRow(3, data.m_dataMatrix0.GetRow(3) + new Vector4(0.2f, 0.2f, 0.2f, 0.2f));
            data.m_extraData.m_dataMatrix2.SetRow(3, data.m_extraData.m_dataMatrix2.GetRow(3) + new Vector4(0.2f, 0.2f, 0.2f, 0.2f));
            data.m_extraData.m_dataMatrix3.SetRow(3, data.m_extraData.m_dataMatrix3.GetRow(3) + new Vector4(0.2f, 0.2f, 0.2f, 0.2f));
            data.m_dataMatrix1.SetRow(3, data.m_dataMatrix1.GetRow(3) + new Vector4(0.2f, 0.2f, 0.2f, 0.2f));
            data.m_dataVector0   = new Vector4(0.5f / info.m_halfWidth, 1f / info.m_segmentLength, 0.5f - info.m_pavementWidth / info.m_halfWidth * 0.5f, info.m_pavementWidth / info.m_halfWidth * 0.5f);
            data.m_dataVector1   = centerPos - data.m_position;
            data.m_dataVector1.w = (data.m_dataMatrix0.m31 + data.m_dataMatrix0.m32 + data.m_extraData.m_dataMatrix2.m31 + data.m_extraData.m_dataMatrix2.m32 + data.m_extraData.m_dataMatrix3.m31 + data.m_extraData.m_dataMatrix3.m32 + data.m_dataMatrix1.m31 + data.m_dataMatrix1.m32) * 0.125f;
            data.m_dataVector2   = new Vector4(info.m_pavementWidth / info.m_halfWidth * 0.5f, 1f, info.m_pavementWidth / info.m_halfWidth * 0.5f, 1f);
        }
        Vector4 colorLocation;
        Vector4 vector21;

        if (NetNode.BlendJunction(nodeID))
        {
            colorLocation = RenderManager.GetColorLocation(86016u + (uint)nodeID);
            vector21      = colorLocation;
        }
        else
        {
            colorLocation = RenderManager.GetColorLocation((uint)(49152 + SegmentID));
            vector21      = RenderManager.GetColorLocation(86016u + (uint)nodeID);
        }
        data.m_extraData.m_dataVector4 = new Vector4(colorLocation.x, colorLocation.y, vector21.x, vector21.y);
        data.m_dataInt0     = segmentIndex;
        data.m_dataColor0   = info.m_color;
        data.m_dataColor0.a = 0f;
        data.m_dataFloat0   = Singleton <WeatherManager> .instance.GetWindSpeed(data.m_position);

        if (info.m_requireSurfaceMaps)
        {
            Singleton <TerrainManager> .instance.GetSurfaceMapping(data.m_position, out data.m_dataTexture0, out data.m_dataTexture1, out data.m_dataVector3);
        }
        instanceIndex = (uint)data.m_nextInstance;
    }