Skip to content

Commit

Permalink
Fixed: Super-elevation auto update not working on node update
Browse files Browse the repository at this point in the history
Fixed: Node settings not being copied in some cases
Added: Scene builder addon content
Updated: Use trace fraction when calling `GetCurveTransform`
  • Loading branch information
dvdvideo1234 committed Nov 17, 2024
1 parent 68ede4d commit 70c3f83
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 34 deletions.
6 changes: 4 additions & 2 deletions data/trackassembly/tools/peaces_manager/create_report.bat
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ set emd_chew_dbase=%emd_chew_gmod%\garrysmod\data\trackassembly\exp\trackasmlib_
set emd_chew_skip=%emd_chew_repo%\data\trackassembly\tools\peaces_manager\models_ignored.txt

:: How many addons are to be processed
set emd_chew_addfrm=30
set emd_chew_addcnt=30
set emd_chew_addfrm=31
set emd_chew_addcnt=31

:: GMA addons to be processed
set emd_chew_addlst[1]=740453553
Expand Down Expand Up @@ -64,6 +64,7 @@ set emd_chew_addlst[27]=1955876643
set emd_chew_addlst[28]=3071058065
set emd_chew_addlst[29]=3297918081
set emd_chew_addlst[30]=3314861708
set emd_chew_addlst[31]=2233731395

:: Folder list for extraction and the directories they will be extracted
set emd_chew_adddir[1]=AlexCookie's 2ft track pack
Expand Down Expand Up @@ -96,6 +97,7 @@ set emd_chew_adddir[27]=Trackmania United Props
set emd_chew_adddir[28]=RockMan's Fortification
set emd_chew_adddir[29]=SligWolf's Suspension Train
set emd_chew_adddir[30]=Modular City Street
set emd_chew_adddir[31]=Scene Builder

:: Show the current folder
echo Running in: %emd_chew_pathb%
Expand Down
23 changes: 22 additions & 1 deletion lua/autorun/trackassembly_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ local asmlib = trackasmlib; if(not asmlib) then -- Module present
------------ CONFIGURE ASMLIB ------------

asmlib.InitBase("track","assembly")
asmlib.SetOpVar("TOOL_VERSION","8.806")
asmlib.SetOpVar("TOOL_VERSION","8.807")

------------ CONFIGURE GLOBAL INIT OPVARS ------------

Expand Down Expand Up @@ -557,6 +557,7 @@ if(CLIENT) then
asmlib.WorkshopID("RockMan's Fortification" , "3071058065")
asmlib.WorkshopID("SligWolf's Suspension Train" , "3297918081")
asmlib.WorkshopID("Modular City Street" , "3314861708")
asmlib.WorkshopID("Scene Builder" , "2233731395")

asmlib.SetAction("CLEAR_GHOSTS" , function() asmlib.ClearGhosts() end)
asmlib.SetAction("CTXMENU_OPEN" , function() asmlib.IsFlag("tg_context_menu", true ) end)
Expand Down Expand Up @@ -4751,6 +4752,26 @@ else
PIECES:Record({"models/propper/dingles_modular_streets/highway_street_1024turn.mdl", "#", "#", 2, "", "-512,-1024,120", "0,-90,0"})
PIECES:Record({"models/propper/dingles_modular_streets/highway_street_1024turn_tall.mdl", "#", "#", 1, "", "1024,512,248"})
PIECES:Record({"models/propper/dingles_modular_streets/highway_street_1024turn_tall.mdl", "#", "#", 2, "", "-512,-1024,248", "0,-90,0"})
asmlib.Categorize("Scene Builder")
PIECES:Record({"models/scene_building/sewer_system/arch_small_hall.mdl", "#", "#", 1, "", "0, 47,0", "0,90,0"})
PIECES:Record({"models/scene_building/sewer_system/arch_small_hall.mdl", "#", "#", 2, "", "0,-47,0", "0,-90,0"})
PIECES:Record({"models/scene_building/sewer_system/arch_small_hall_med.mdl", "#", "#", 1, "", "0, 23,0", "0,90,0"})
PIECES:Record({"models/scene_building/sewer_system/arch_small_hall_med.mdl", "#", "#", 2, "", "0,-23,0", "0,-90,0"})
PIECES:Record({"models/scene_building/sewer_system/arch_small_hall_small.mdl", "#", "#", 1, "", "0, 11,0", "0,90,0"})
PIECES:Record({"models/scene_building/sewer_system/arch_small_hall_small.mdl", "#", "#", 2, "", "0,-11,0", "0,-90,0"})
PIECES:Record({"models/scene_building/sewer_system/arch_hall_corner.mdl", "#", "#", 1, "", "0,47,0", "0,90,0"})
PIECES:Record({"models/scene_building/sewer_system/arch_hall_corner.mdl", "#", "#", 2, "", "47,0,0"})
PIECES:Record({"models/scene_building/sewer_system/arch_hall_3way.mdl", "#", "#", 1, "", "0,47,0", "0,90,0"})
PIECES:Record({"models/scene_building/sewer_system/arch_hall_3way.mdl", "#", "#", 2, "", "47,0,0"})
PIECES:Record({"models/scene_building/sewer_system/arch_hall_3way.mdl", "#", "#", 3, "", "0,-47,0", "0,-90,0"})
PIECES:Record({"models/scene_building/sewer_system/arch_hall_4way.mdl", "#", "#", 1, "", "0,47,0", "0,90,0"})
PIECES:Record({"models/scene_building/sewer_system/arch_hall_4way.mdl", "#", "#", 2, "", "47,0,0"})
PIECES:Record({"models/scene_building/sewer_system/arch_hall_4way.mdl", "#", "#", 3, "", "0,-47,0", "0,-90,0"})
PIECES:Record({"models/scene_building/sewer_system/arch_hall_4way.mdl", "#", "#", 4, "", "-47,0,0", "0,-180,0"})
PIECES:Record({"models/scene_building/sewer_system/arch_small_door1.mdl", "#", "#", 1, "", "0, 47,0", "0,90,0"})
PIECES:Record({"models/scene_building/sewer_system/arch_small_door1.mdl", "#", "#", 2, "", "0,-47,0", "0,-90,0"})
PIECES:Record({"models/scene_building/sewer_system/arch_small_door2.mdl", "#", "#", 1, "", "0, 47,0", "0,90,0"})
PIECES:Record({"models/scene_building/sewer_system/arch_small_door2.mdl", "#", "#", 2, "", "0,-47,0", "0,-90,0"})
if(gsMoDB == "SQL") then sqlCommit() end
end

Expand Down
8 changes: 6 additions & 2 deletions lua/trackassembly/trackasmlib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@ function InitBase(sName, sPurp)
SetOpVar("HASH_PROPERTY_TYPES","PROPERTY_TYPES")
SetOpVar("TRACE_CLASS", {[GetOpVar("ENTITY_DEFCLASS")]=true})
SetOpVar("TRACE_DATA",{ -- Used for general trace result storage
length = 0, -- Will store the trace length when needed
start = Vector(), -- Start position of the trace
endpos = Vector(), -- End position of the trace
mask = MASK_SOLID, -- Mask telling it what to hit
Expand Down Expand Up @@ -4616,13 +4617,16 @@ function GetTraceEntityPoint(trEnt, ivPoID, nLen, vDir)
local trPOA = LocatePOA(trRec, ivPoID); if(not IsHere(trPOA)) then
LogInstance("Point missing "..GetReport(ivPoID)); return nil end
local trDt, trAng = GetOpVar("TRACE_DATA"), Angle()
trDt.length = nLen
trDt.start:SetUnpacked(trPOA.O:Get())
trDt.start:Rotate(trEnt:GetAngles())
trDt.start:Add(trEnt:GetPos())
trAng:SetUnpacked(trPOA.A:Get())
trAng:Set(trEnt:LocalToWorldAngles(trAng))
trDt.endpos:Set(vDir or trAng:Forward()); trDt.endpos:Mul(nLen)
trDt.endpos:Add(trDt.start); SetOpVar("TRACE_FILTER", trEnt)
trDt.endpos:Set(vDir or trAng:Forward())
trDt.endpos:Mul(trDt.length)
trDt.endpos:Add(trDt.start)
SetOpVar("TRACE_FILTER", trEnt)
return utilTraceLine(trDt), trDt
end

Expand Down
75 changes: 46 additions & 29 deletions lua/weapons/gmod_tool/stools/trackassembly.lua
Original file line number Diff line number Diff line change
Expand Up @@ -910,9 +910,9 @@ function TOOL:GetCurveTransform(stTrace, bPnt)
tData.Orw:Set(tData.Org); tData.Anw:Set(tData.Ang) -- Transform of POA
tData.ID = oID; tData.Min = oMin -- Point ID and minimum distance
tData.POA = oPOA; tData.Rec = oRec -- POA and cache record
local trDt = asmlib.GetTraceEntityPoint(eEnt, oID, 30000, asmlib.GetOpVar("VEC_DW"))
if(trDt and trDt.Hit) then
nT = ((tData.Orw.z - trDt.HitPos.z) - elevpnt)
local trRz, trDt = asmlib.GetTraceEntityPoint(eEnt, oID, 30000, asmlib.GetOpVar("VEC_DW"))
if(trRz and trRz.Hit) then
nT = (trDt.length * trRz.Fraction - elevpnt)
asmlib.SetAsmConvar(user, "nextz", nT)
end
end -- Use the track piece active end to create relative curve node
Expand All @@ -935,7 +935,7 @@ end
* tC > Curve data stricture with the normal modified
* tData > Reference to the node being inserted
]]
function TOOL:ApplySuperElevation(tC, tData)
function TOOL:ApplySuperElevation(tC, tData, iD)
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
Expand All @@ -944,18 +944,33 @@ function TOOL:ApplySuperElevation(tC, tData)
local crvsuprev = self:GetSuperElevation()
if(not (crvsuprev > 0 and not spnflat)) 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
local iN, nS = tonumber(iD), asmlib.GetOpVar("FULL_SLOPEDG")
if(iN) then
local tR = tC.Rays
local tO, tN = tC.Node, tC.Norm
local vL, vP = tO[iN+1], tO[iN-1]
if(not (vL and vP)) then return 0 end
local vD = Vector(vL); vD:Sub(tData.Org); 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
else
if(not (tC.Size and tC.Size >= 2)) then
asmlib.LogInstance("Two vertices needed", gtLogs); return 0 end
local tR, iN = tC.Rays, tC.Size
local tO, tN = tC.Node, tC.Norm
local vL, vP = tO[iN], tO[iN - 1]
local vD = Vector(tData.Org); vD:Sub(vL); vD:Normalize()
local vF = Vector(tData.Org); 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
end

function TOOL:CurveInsert(stTrace, bPnt, bMute)
Expand Down Expand Up @@ -1003,30 +1018,28 @@ function TOOL:CurveUpdate(stTrace, bPnt, bMute)
local bTr = (mD and mD > 0 and mL < nrA^2)
if(bTr) then
if(not bPnt) then
local tN, vF = tC.Node, nil
local elevpnt = self:GetElevation()
local vB, tR = tC.Base[mD], tC.Rays[mD]
local vN, vD = tC.Norm[mD], tC.Node[mD]
local vO = Vector(); vO:Set(vD); vO:Sub(vB)
local nextx, nexty, nextz = vO:Unpack()
asmlib.SetAsmConvar(oPly,"nextx", 0)
asmlib.SetAsmConvar(oPly,"nexty", 0)
asmlib.SetAsmConvar(oPly,"nextz", (nextz - elevpnt))
local aO = tR[2]:Forward():AngleEx(vN) --tC.Norm[mD]:Angle()
aO:RotateAroundAxis(tR[2]:Up(), 180)
asmlib.SetAsmConvar(oPly,"nextx", nextx)
asmlib.SetAsmConvar(oPly,"nexty", nextx)
asmlib.SetAsmConvar(oPly,"nextz", nextz - elevpnt)
if(not (tN[mD-1] and tN[mD+1])) then vF = tR[2]:Forward() else
vF = Vector(tN[mD+1]); vF:Sub(tN[mD-1]); vF:Normalize() end
local aO = vF:AngleEx(vN)
local nextpic, nextyaw, nextrol = aO:Unpack()
asmlib.SetAsmConvar(oPly,"nextpic", nextpic)
asmlib.SetAsmConvar(oPly,"nextyaw", 0)
asmlib.SetAsmConvar(oPly,"nextyaw", nextyaw)
asmlib.SetAsmConvar(oPly,"nextrol", nextrol)
return tC
end
end
if(not bTr) then
tC.Node[mD]:Set(tData.Org)
end
tC.Node[mD]:Set(tData.Org)
tC.Norm[mD]:Set(tData.Ang:Up())
if(not bTr) then
tC.Base[mD]:Set(tData.Hit)
end
tC.Base[mD]:Set(tData.Hit)
tC.Rays[mD][1]:Set(tData.Org)
tC.Rays[mD][2]:Set(tData.Ang)
tC.Rays[mD][3] = (tData.POA ~= nil)
Expand All @@ -1040,6 +1053,10 @@ function TOOL:CurveUpdate(stTrace, bPnt, bMute)
tC.Norm[mD]:Normalize()
end
end
if(not bTr) then -- Try to apply the new super-elevation
local iN, vN = self:ApplySuperElevation(tC, tData, mD)
if(iN > 0) then tC.Norm[iN]:Set(vN) end
end
if(not bMute) then
asmlib.Notify(user, "Node ["..mD.."] updated !", "CLEANUP")
netStart(gsLibName.."SendUpdateCurveNode")
Expand Down Expand Up @@ -1992,7 +2009,7 @@ function TOOL:DrawCurveNode(oScreen, oPly, stTrace)
if(not tData) then asmlib.LogInstance("Transform missing", gtLogs); return end
local tC, nS = asmlib.GetCacheCurve(oPly), self:GetSizeUCS()
if(not tC) then asmlib.LogInstance("Curve missing", gtLogs); return end
local nrB, nrS, nrA, mD, mL = 3, 1.5, self:GetActiveRadius()
local nrB, nrS, nrA, mD, mL = 1.5, 1.5, self:GetActiveRadius()
local xyO, xyH = tData.Org:ToScreen(), tData.Hit:ToScreen()
local xyZ = (tData.Org + nS * tData.Ang:Up()):ToScreen()
local xyX = (tData.Org + nS * tData.Ang:Forward()):ToScreen()
Expand Down

0 comments on commit 70c3f83

Please sign in to comment.