Skip to content

Commit

Permalink
Fixed: Additional piece offsets. Positive goes to the right and up
Browse files Browse the repository at this point in the history
Removed: F,R,U spawn direction vectors. Not needed anymore
Removed: Dedicated negate angle routine. Not needed anymore
Removed: Calculation of F,R,U spawn direction. Extracted from the angle instead
  • Loading branch information
dvdvideo1234 committed Feb 1, 2025
1 parent ee9920c commit 821632a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
5 changes: 1 addition & 4 deletions 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","9.775")
asmlib.SetOpVar("TOOL_VERSION","9.776")

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

Expand Down Expand Up @@ -304,9 +304,6 @@ asmlib.SetOpVar("STRUCT_SPAWN",{
end,
},
{Name = "Origin",
{"F" , "VEC", "Origin forward vector"},
{"R" , "VEC", "Origin right vector"},
{"U" , "VEC", "Origin up vector"},
{"BPos", "VEC", "Base coordinate position"},
{"BAng", "ANG", "Base coordinate angle"},
{"OPos", "VEC", "Origin position"},
Expand Down
23 changes: 4 additions & 19 deletions lua/trackassembly/trackasmlib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -872,14 +872,6 @@ function GridAngle(aBase, nvDec)
aBase:SetUnpacked(P, Y, R) return aBase
end

function NegAngle(aBase, bP, bY, bR)
if(not aBase) then LogInstance("Base invalid"); return nil end
local P, Y, R = aBase:Unpack()
P = (IsHere(bP) and (bP and -P or P) or -P)
Y = (IsHere(bY) and (bY and -Y or Y) or -Y)
R = (IsHere(bR) and (bR and -R or R) or -R)
aBase:SetUnpacked(P, Y, R); return aBase
end
------------- VECTOR ---------------

function BasisVector(vBase, aUnit)
Expand Down Expand Up @@ -4530,22 +4522,15 @@ function GetNormalSpawn(oPly,ucsPos,ucsAng,shdModel,ivhdPoID,
if(ucsAng) then stSpawn.BAng:Set(ucsAng) end
stSpawn.OPos:Set(stSpawn.BPos); stSpawn.OAng:Set(stSpawn.BAng)
-- Initialize F, R, U Copy the UCS like that to support database POA
stSpawn.ANxt:SetUnpacked(tonumber(ucsAngP) or 0,
tonumber(ucsAngY) or 0,
tonumber(ucsAngR) or 0)
stSpawn.PNxt:SetUnpacked(tonumber(ucsPosX) or 0,
tonumber(ucsPosY) or 0,
tonumber(ucsPosZ) or 0)
local pX, pY, pZ = (tonumber(ucsPosX) or 0), (tonumber(ucsPosY) or 0), (tonumber(ucsPosZ) or 0)
local aP, aY, aR = (tonumber(ucsAngP) or 0), (tonumber(ucsAngY) or 0), (tonumber(ucsAngR) or 0)
stSpawn.ANxt:SetUnpacked(-aP, -aY, aR)
stSpawn.PNxt:SetUnpacked( pX, -pY, pZ)
-- Integrate additional position offset into the origin position
if(not (stSpawn.ANxt:IsZero() and stSpawn.PNxt:IsZero())) then
NegAngle(stSpawn.ANxt, true, true, false)
local vW, aW = LocalToWorld(stSpawn.PNxt, stSpawn.ANxt, stSpawn.BPos, stSpawn.BAng)
stSpawn.OPos:Set(vW); stSpawn.OAng:Set(aW)
end
-- Update snap directions
stSpawn.F:Set(stSpawn.OAng:Forward())
stSpawn.R:Set(stSpawn.OAng:Right())
stSpawn.U:Set(stSpawn.OAng:Up())
-- Read holder record
stSpawn.HPnt:SetUnpacked(hdPOA.P:Get())
stSpawn.HOrg:SetUnpacked(hdPOA.O:Get())
Expand Down

0 comments on commit 821632a

Please sign in to comment.