From 6c2451523435e35838ff89be8d81b8d3337d7c3c Mon Sep 17 00:00:00 2001 From: Deyan Dobromirov Date: Fri, 15 Nov 2024 16:09:54 +0200 Subject: [PATCH] Added: Check of the modified normal exists Added: Description for super-elevation --- lua/autorun/trackassembly_init.lua | 5 +++-- lua/weapons/gmod_tool/stools/trackassembly.lua | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lua/autorun/trackassembly_init.lua b/lua/autorun/trackassembly_init.lua index 7c6c9f69..53daaad9 100644 --- a/lua/autorun/trackassembly_init.lua +++ b/lua/autorun/trackassembly_init.lua @@ -566,8 +566,9 @@ if(CLIENT) then function(nLen) local oPly, sLog = netReadEntity(), "*CREATE_CURVE_NODE" local vNode, vNorm, vBase = netReadVector(), netReadNormal(), netReadVector() local vOrgw, aAngw, bRayw = netReadVector(), netReadAngle() , netReadBool() - local iNorm, tC = netReadUInt(16), asmlib.GetCacheCurve(oPly) -- Read the curve - if(iNorm > 0 and tC.Size and tC.Size >= 2) then tC.Norm[iNorm]:Set(netReadNormal()) end + local iD, tC = netReadUInt(16), asmlib.GetCacheCurve(oPly) -- Read the curve + if(iD > 0 and tC.Norm[iD] and tC.Size and tC.Size => 2) then + tC.Norm[iD]:Set(netReadNormal()) end -- Update the previews curve normal tableInsert(tC.Node, vNode); tableInsert(tC.Norm, vNorm) tableInsert(tC.Base, vBase); tableInsert(tC.Rays, {vOrgw, aAngw, bRayw}) tC.Size = (tC.Size + 1) -- Register the index after writing the data for drawing diff --git a/lua/weapons/gmod_tool/stools/trackassembly.lua b/lua/weapons/gmod_tool/stools/trackassembly.lua index 1ce910d7..bf76e922 100644 --- a/lua/weapons/gmod_tool/stools/trackassembly.lua +++ b/lua/weapons/gmod_tool/stools/trackassembly.lua @@ -922,6 +922,13 @@ function TOOL:GetCurveTransform(stTrace, bPnt) return tData end +--[[ + * Used to apply super-elevation on the previous node + * according to the location of the next node placed + * Must be run BEFORE inserting the new node placed + * tC > Curve data stricture with the normal modified + * tData > Reference to the node being inserted +]] function TOOL:ApplySuperElevation(tC, tData) if(not tData) then -- The node being managed asmlib.LogInstance("Data missing", gtLogs); return 0 end