Skip to content

Commit

Permalink
Fixed: Curve node remove reverts the value of the last node
Browse files Browse the repository at this point in the history
Fixed: Curve node remove on the client checks its status
Fixed: Lower the network latency when sending normal vectors
Added: User preferences for amount of super-elevation
Sorted: Russian translation by phrase hash
  • Loading branch information
dvdvideo1234 committed Nov 15, 2024
1 parent b69a709 commit 1bfb85f
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 148 deletions.
14 changes: 10 additions & 4 deletions lua/autorun/trackassembly_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ asmlib.SetBorder(gsToolPrefL.."spawnrate", 1, 10)
asmlib.SetBorder(gsToolPrefL.."sgradmenu", 1, 16)
asmlib.SetBorder(gsToolPrefL.."dtmessage", 0, 10)
asmlib.SetBorder(gsToolPrefL.."ghostblnd", 0, 1)
asmlib.SetBorder(gsToolPrefL.."crvsuprev", 0, 1)
asmlib.SetBorder(gsToolPrefL.."rtradmenu", -gnMaxRot, gnMaxRot)

------------ CONFIGURE LOGGING ------------
Expand Down Expand Up @@ -574,7 +575,7 @@ if(CLIENT) then

asmlib.SetAction("UPDATE_CURVE_NODE",
function(nLen) local oPly, sLog = netReadEntity(), "*UPDATE_CURVE_NODE"
local vNode, vNorm, vBase = netReadVector(), netReadVector(), netReadVector()
local vNode, vNorm, vBase = netReadVector(), netReadNormal(), netReadVector()
local vOrgw, aAngw, bRayw = netReadVector(), netReadAngle() , netReadBool()
local iD, tC = netReadUInt(16), asmlib.GetCacheCurve(oPly)
tC.Node[iD]:Set(vNode); tC.Norm[iD]:Set(vNorm)
Expand All @@ -584,9 +585,14 @@ if(CLIENT) then
asmlib.SetAction("DELETE_CURVE_NODE",
function(nLen) local oPly, sLog = netReadEntity(), "*DELETE_CURVE_NODE"
local tC = asmlib.GetCacheCurve(oPly)
tC.Size = (tC.Size - 1) -- Register the index before wiping the data for drawing
tableRemove(tC.Node); tableRemove(tC.Norm)
tableRemove(tC.Base); tableRemove(tC.Rays)
if(tC.Size and tC.Size > 0) then
tC.Size = (tC.Size - 1) -- Register the index before wiping the data for drawing
tableRemove(tC.Node); tableRemove(tC.Norm)
tableRemove(tC.Base); tableRemove(tC.Rays)
if(tC.Size and tC.Size > 0) then
tC.Norm[tC.Size]:Set(tC.Rays[tC.Size][2]:Up())
end
end
end)

asmlib.SetAction("DELETE_ALL_CURVE_NODE",
Expand Down
58 changes: 40 additions & 18 deletions lua/weapons/gmod_tool/stools/trackassembly.lua
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ TOOL.ClientConVar = {
[ "upspanchor" ] = 0,
[ "crvturnlm" ] = 0.95,
[ "crvleanlm" ] = 0.95,
[ "crvsuprev" ] = 0.45,
[ "flipoverid" ] = ""
}

Expand Down Expand Up @@ -204,6 +205,10 @@ TOOL.Category = languageGetPhrase and languageGetPhrase("tool."..gsToolNameL..
TOOL.Command = nil -- Command on click (nil for default)
TOOL.ConfigName = nil -- Configure file name (nil for default)

function TOOL:GetSuperElevation()
return mathClamp(self:GetClientNumber("crvsuprev", 0), 0, 1)
end

function TOOL:GetCurveFactor()
return asmlib.GetAsmConvar("curvefact", "FLT")
end
Expand Down Expand Up @@ -787,15 +792,15 @@ end
--[[
* Uses heuristics to provide the best suitable location the
* curve note closest location can be updated with. Three cases:
* 1. Both neighbors are active points. Intersect their active rays
* 2. Only one node is an active point. Project on its active ray
* 3. None of the neighbors are active points. Project on line bisector
* iD > Curve node index to be updated
* vPnt > The new location to update the node with
* bMute > Mute mode. Used to disable server status messages
* Returns multiple values:
* 1. Curve node calculated heuristics location vector
* 2. The amount of neighbor nodes that are active rays
* V > Curve node calculated heuristics location vector
* N > The amount of neighbor nodes that are active rays
* (2) Both neighbors are active points. Intersect their active rays
* (1) Only one node is an active point. Project on its active ray
* (0) None of the neighbors are active points. Project on line bisector
]]--
function TOOL:GetCurveNodeActive(iD, vPnt, bMute)
local user = self:GetOwner()
Expand Down Expand Up @@ -863,6 +868,9 @@ function TOOL:CurveClear(bAll, bMute)
tableRemove(tC.Rays)
tableEmpty(tC.Snap); tC.SSize = 0
tableRemove(tC.Base); tC.Size = (tC.Size - 1)
if(tC.Size and tC.Size > 0) then
tC.Norm[tC.Size]:Set(tC.Rays[tC.Size][2]:Up())
end
end
end; return tC -- Returns the updated curve nodes table
end
Expand Down Expand Up @@ -914,24 +922,36 @@ function TOOL:GetCurveTransform(stTrace, bPnt)
return tData
end

function TOOL:ApplySuperElevation(tC, tData)
if(not tData) then -- The node being managed
asmlib.LogInstance("Data missing", gtLogs); return 0 end
if(not tC) then -- The curve containing all nodes
asmlib.LogInstance("Curve missing", gtLogs); return 0 end
local spnflat = self:GetSpawnFlat()
local crvsuprev = self:GetSuperElevation()
if(not (spnflat and crvsuprev > 0) then
asmlib.LogInstance("Auto roll disabled", gtLogs); return 0 end
if(not (tC.Size and tC.Size >= 2)) then
asmlib.LogInstance("Two vertices needed", gtLogs); return 0 end
local nS, iN = asmlib.GetOpVar("FULL_SLOPEDG"), tC.Size
local tO, tR, tN = tC.Node, tC.Rays, tC.Norm
local vL, vP = tO[iN], tO[iN - 1]
local vD = Vector(tData.Org); vD:Sub(vL); vD:Normalize()
local vF = Vector(vL); vF:Sub(vP); vF:Normalize()
local aN = vF:AngleEx(tR[iN][2]:Up())
local nP = (crvsuprev * nS) * vD:Dot(aN:Right())
aN:RotateAroundAxis(vF, nP)
local vN = aN:Up(); tN[iN]:Set(vN)
return iN, vN
end

function TOOL:CurveInsert(stTrace, bPnt, bMute)
local spnflat, iN, vN = self:GetSpawnFlat(), 0
local user, model = self:GetOwner(), self:GetModel()
local tData = self:GetCurveTransform(stTrace, bPnt); if(not tData) then
asmlib.LogInstance("Transform missing", gtLogs); return nil end
local tC = asmlib.GetCacheCurve(user); if(not tC) then
asmlib.LogInstance("Curve missing", gtLogs); return nil end
if(not spnflat and tC.Size and tC.Size >= 2) then
local nS, iC = asmlib.GetOpVar("FULL_SLOPEDG"), tC.Size
local tO, tR, tN = tC.Node, tC.Rays, tC.Norm
local vA, vB = tO[iC], tO[iC - 1]
local vD = Vector(tData.Org); vD:Sub(vA); vD:Normalize()
local vF = Vector(vA); vF:Sub(vB); vF:Normalize()
local aN = vF:AngleEx(tR[iC][2]:Up())
local nP = 0.5 * nS * vD:Dot(aN:Right())
aN:RotateAroundAxis(vF, nP)
vN = aN:Up(); tN[iC]:Set(vN); iN = iC
end
self:ApplySuperElevation(tC, tData)
tC.Size = (tC.Size + 1) -- Increment stack size. Adding stuff
tableInsert(tC.Node, Vector(tData.Org))
tableInsert(tC.Norm, tData.Ang:Up())
Expand Down Expand Up @@ -987,7 +1007,7 @@ function TOOL:CurveUpdate(stTrace, bPnt, bMute)
netStart(gsLibName.."SendUpdateCurveNode")
netWriteEntity(user)
netWriteVector(tC.Node[mD])
netWriteVector(tC.Norm[mD])
netWriteNormal(tC.Norm[mD])
netWriteVector(tC.Base[mD])
netWriteVector(tC.Rays[mD][1])
netWriteAngle (tC.Rays[mD][2])
Expand Down Expand Up @@ -2496,6 +2516,7 @@ if(CLIENT) then
asmlib.SetNumSlider(CPanel, "ghostblnd", iMaxDec)
asmlib.SetNumSlider(CPanel, "crvturnlm", iMaxDec)
asmlib.SetNumSlider(CPanel, "crvleanlm", iMaxDec)
asmlib.SetNumSlider(CPanel, "crvsuprev", iMaxDec)
asmlib.SetNumSlider(CPanel, "sgradmenu", 0)
asmlib.SetNumSlider(CPanel, "rtradmenu", iMaxDec)
asmlib.SetCheckBox(CPanel, "enradmenu")
Expand Down Expand Up @@ -2654,6 +2675,7 @@ if(CLIENT) then
asmlib.SetAsmConvar(user, "endsvlock", asmlib.GetAsmConvar("endsvlock", "DEF"))
asmlib.SetAsmConvar(user, "curvefact", asmlib.GetAsmConvar("curvefact", "DEF"))
asmlib.SetAsmConvar(user, "curvsmple", asmlib.GetAsmConvar("curvsmple", "DEF"))
asmlib.SetAsmConvar(user, "crvsuprev", asmlib.GetAsmConvar("crvsuprev", "DEF"))
asmlib.SetAsmConvar(user, "spawnrate", asmlib.GetAsmConvar("spawnrate", "DEF"))
asmlib.SetAsmConvar(user, "bnderrmod", asmlib.GetAsmConvar("bnderrmod", "DEF"))
asmlib.SetAsmConvar(user, "maxfruse" , asmlib.GetAsmConvar("maxfruse" , "DEF"))
Expand Down
16 changes: 9 additions & 7 deletions resource/localization/bg/trackassembly.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ tool.trackassembly.buttonas@M=Запомни стойност
tool.trackassembly.client_var=Клиентски предпочитания на играча. Променливи създадени чрез инструмента конфигурация
tool.trackassembly.crvleanlm=Променете тук за да настроите остротата на наклона при сегментиране на кривата
tool.trackassembly.crvleanlm_con=Наклон на кривината\:
tool.trackassembly.crvsuprev=Променете тук за да настроите тежестта на коефицианта за свъхденивалация
tool.trackassembly.crvsuprev_con=Свръх денивелация\:
tool.trackassembly.crvturnlm=Променете тук за да настроите остротата на завоя при сегментиране на кривата
tool.trackassembly.crvturnlm_con=Завой на кривината\:
tool.trackassembly.curvefact=Променете тук за да настроите тангенциалния коефициент на кривата
Expand Down Expand Up @@ -185,10 +187,10 @@ tool.trackassembly.pn_display_lb=Дисплей за парчето
tool.trackassembly.pn_export=Цъкнете за да съхраните базата данни на файл
tool.trackassembly.pn_export_lb=Съхрани DB
tool.trackassembly.pn_extdsv_act=Активен
tool.trackassembly.pn_extdsv_prf=Уникален префикс на базата
tool.trackassembly.pn_extdsv_inf=Допълнителна информация
tool.trackassembly.pn_extdsv_hd=Списъка на DSV базите данни е показан тук
tool.trackassembly.pn_extdsv_inf=Допълнителна информация
tool.trackassembly.pn_extdsv_lb=Външен DSV списък
tool.trackassembly.pn_extdsv_prf=Уникален префикс на базата
tool.trackassembly.pn_externdb_bte=Експорт
tool.trackassembly.pn_externdb_bte_tp=Експортира информацията от панела към файла за използване
tool.trackassembly.pn_externdb_bti=Импорт
Expand All @@ -198,13 +200,13 @@ tool.trackassembly.pn_externdb_ttt=Текущата стойност от кон
tool.trackassembly.pn_pattern=Напишете шаблон тук и натиснете ЕНТЪР за да извършите търсене
tool.trackassembly.pn_pattern_lb=Напишете шаблон
tool.trackassembly.pn_routine=Списъкът с редовно използваните ви парчета трасе
tool.trackassembly.pn_routine_hd=Редовни парчета на\:
tool.trackassembly.pn_routine_use=Срок
tool.trackassembly.pn_routine_end=Ръб
tool.trackassembly.pn_routine_typ=Тип
tool.trackassembly.pn_routine_nam=Име
tool.trackassembly.pn_routine_mod=Модел
tool.trackassembly.pn_routine_hd=Редовни парчета на\:
tool.trackassembly.pn_routine_lb=Рутинни обекти
tool.trackassembly.pn_routine_mod=Модел
tool.trackassembly.pn_routine_nam=Име
tool.trackassembly.pn_routine_typ=Тип
tool.trackassembly.pn_routine_use=Срок
tool.trackassembly.pn_srchcol=Изберете по коя колона да извършите търсене
tool.trackassembly.pn_srchcol_lb=<Търси по>
tool.trackassembly.pntasist=Управлява изобразяването на асистента за лепене
Expand Down
16 changes: 9 additions & 7 deletions resource/localization/en/trackassembly.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ tool.trackassembly.buttonas@M=Memorize value
tool.trackassembly.client_var=Client side player preferences. Convars created in the tool client configuration
tool.trackassembly.crvleanlm=Change this to adjust the lean curving sharpness limit for the segment
tool.trackassembly.crvleanlm_con=Curvature lean\:
tool.trackassembly.crvsuprev=Change this to adjust the super-elevation magnitude used in the corners
tool.trackassembly.crvsuprev_con=Super elevation\:
tool.trackassembly.crvturnlm=Change this to adjust the turn curving sharpness limit for the segment
tool.trackassembly.crvturnlm_con=Curvature turn\:
tool.trackassembly.curvefact=Change this to adjust the curving factor tangent coefficient
Expand Down Expand Up @@ -185,10 +187,10 @@ tool.trackassembly.pn_display_lb=Piece display
tool.trackassembly.pn_export=Click to export the client database as a file
tool.trackassembly.pn_export_lb=Export DB
tool.trackassembly.pn_extdsv_act=Active
tool.trackassembly.pn_extdsv_prf=Database unique prefix
tool.trackassembly.pn_extdsv_inf=Additional information
tool.trackassembly.pn_extdsv_hd=External DSV databases list is displayed here
tool.trackassembly.pn_extdsv_inf=Additional information
tool.trackassembly.pn_extdsv_lb=External DSV list
tool.trackassembly.pn_extdsv_prf=Database unique prefix
tool.trackassembly.pn_externdb_bte=Export
tool.trackassembly.pn_externdb_bte_tp=Exports information from the panel to the file list and apply
tool.trackassembly.pn_externdb_bti=Import
Expand All @@ -198,13 +200,13 @@ tool.trackassembly.pn_externdb_ttt=Current modified configuration value\:
tool.trackassembly.pn_pattern=Write a pattern here and hit ENTER to perform a search
tool.trackassembly.pn_pattern_lb=Write pattern
tool.trackassembly.pn_routine=The list of your frequently used track pieces
tool.trackassembly.pn_routine_hd=Frequent pieces by\:
tool.trackassembly.pn_routine_use=Used
tool.trackassembly.pn_routine_end=End
tool.trackassembly.pn_routine_typ=Type
tool.trackassembly.pn_routine_nam=Name
tool.trackassembly.pn_routine_mod=Model
tool.trackassembly.pn_routine_hd=Frequent pieces by\:
tool.trackassembly.pn_routine_lb=Routine items
tool.trackassembly.pn_routine_mod=Model
tool.trackassembly.pn_routine_nam=Name
tool.trackassembly.pn_routine_typ=Type
tool.trackassembly.pn_routine_use=Used
tool.trackassembly.pn_srchcol=Choose which list column you want to perform a search on
tool.trackassembly.pn_srchcol_lb=<Search by>
tool.trackassembly.pntasist=Controls rendering the tool snap point assistant
Expand Down
2 changes: 2 additions & 0 deletions resource/localization/fr/trackassembly.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ tool.trackassembly.buttonas@M=Mémoriser la valeur
tool.trackassembly.client_var=Préférences utilisateur côté client. Convars créées dans la configuration client de l'outil
tool.trackassembly.crvleanlm=Changer ceci pour ajuster la finesse de la courbure en inclinaison pour le segment
tool.trackassembly.crvleanlm_con=Courbure en inclinaison\:
tool.trackassembly.crvsuprev=Modifiez ceci pour ajuster l'amplitude du dévers utilisé dans les virages
tool.trackassembly.crvsuprev_con=Dévers\:
tool.trackassembly.crvturnlm=Changer ceci pour ajuster la finesse de la courbure en virage pour le segment
tool.trackassembly.crvturnlm_con=Courbure en virage\:
tool.trackassembly.curvefact=Changer ceci pour ajuster le facteur courbe du coefficient tangent
Expand Down
Loading

0 comments on commit 1bfb85f

Please sign in to comment.