Fixed: Ray projection not normalizing direction rays

Fixed: Return values of ray projection match convention
Fixed: `InitLocalify` is procedure and return nil is not needed
Updated: Readme to include missed `Plarail Advance` [1512053748]
Renamed: Some of the internal variables `simetral` to `bisector`
This commit is contained in:
Deyan Dobromirov 2022-08-11 18:16:51 +03:00
parent 85abbaa86b
commit 52a91beb07
4 changed files with 20 additions and 16 deletions

View File

@ -91,7 +91,7 @@ local asmlib = trackasmlib; if(not asmlib) then -- Module present
------------ CONFIGURE ASMLIB ------------
asmlib.InitBase("track","assembly")
asmlib.SetOpVar("TOOL_VERSION","8.687")
asmlib.SetOpVar("TOOL_VERSION","8.688")
asmlib.SetIndexes("V" ,1,2,3)
asmlib.SetIndexes("A" ,1,2,3)
asmlib.SetIndexes("WV",1,2,3)

View File

@ -4221,9 +4221,11 @@ end
* vP > Position vector to be projected
]]--
function ProjectRay(vO, vD, vP)
local vR = Vector(vP); vR:Sub(vO)
local nD = vR:Dot(vD); vR:Set(vD)
vR:Mul(nD); vR:Add(vO); return vR
local vN = vD:GetNormalized()
local vX = Vector(vP); vX:Sub(vO)
local nD = vX:Dot(vN); vX:Set(vN)
vX:Mul(nD); vX:Add(vO);
return nD, vN, vX
end
--[[
@ -4945,10 +4947,10 @@ end
function InitLocalify(vCode)
local auCod = GetOpVar("LOCALIFY_AUTO") -- Automatic translation code
local cuCod = tostring(vCode or auCod) -- No language code then english
if(SERVER) then LogInstance("Server "..GetReport(vCode)); return nil end
if(SERVER) then LogInstance("Server "..GetReport(vCode)); return end
local thSet = GetOpVar("LOCALIFY_TABLE"); tableEmpty(thSet)
local auSet = GetLocalify(auCod); if(not auSet) then
LogInstance("Mismatch "..GetReport(auCod)); return nil end
LogInstance("Mismatch "..GetReport(auCod)); return end
if(cuCod ~= auCod) then local cuSet = GetLocalify(cuCod)
if(cuSet) then -- When the language infornation is extracted apply on success
for key, val in pairs(auSet) do auSet[key] = (cuSet[key] or auSet[key]) end

View File

@ -786,7 +786,7 @@ end
* curve note closest location can be updated with. Three cases:
* 1. Both neighbours are active points. Intersect their active rays
* 2. Only one node is an active point. Project on its active ray
* 3. None of the neighbours are active points. Project on simetral
* 3. None of the neighbours 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
@ -814,18 +814,18 @@ function TOOL:GetCurveNodeActive(iD, vPnt, bMute)
else
if(tS[3]) then -- Previous is an active point
if(not bMute) then asmlib.Notify(ply,"Node projection prev !","HINT") end
return asmlib.ProjectRay(tS[1], tS[2]:Forward(), vPnt), 1
local mr, nr, xr = asmlib.ProjectRay(tS[1], tS[2]:Forward(), vPnt); return xr, 1
elseif(tE[3]) then -- Next is an active point
if(not bMute) then asmlib.Notify(ply,"Node projection next !","HINT") end
return asmlib.ProjectRay(tE[1], tE[2]:Forward(), vPnt), 1
local mr, nr, xr = asmlib.ProjectRay(tE[1], tE[2]:Forward(), vPnt); return xr, 1
else -- None of the previous and next nodes are active points
if(not bMute) then asmlib.Notify(ply,"Node project simetral !","HINT") end
if(not bMute) then asmlib.Notify(ply,"Node project bisector !","HINT") end
local vS, vE = tC.Node[iS], tC.Node[iE] -- Read start and finish nodes
local vD = Vector(vE); vD:Sub(vS) -- Direction from start to finish
local vM = Vector(vD); vM:Mul(0.5); vM:Add(vS) -- Simetral origin
local vX = asmlib.ProjectRay(vS, vD, vPnt) -- Projection point
local vV = Vector(vPnt); vV:Sub(vX) -- Simetral direction vector
return asmlib.ProjectRay(vM, vV, vPnt), 0
local vO = Vector(vD); vO:Mul(0.5); vO:Add(vS) -- Bisector origin
local mr, nr, xr = asmlib.ProjectRay(vS, vD, vPnt) -- Projection point
vD:Set(vPnt); vD:Sub(xr) -- Bisector direction vector
local ms, ns, xs = asmlib.ProjectRay(vO, vD, vPnt); return xs, 0
end
end
end

View File

@ -209,10 +209,10 @@ set being solid with fading door `CLOSED` function state:
8. Pressing `ATTACK2` ( Def: `Right Mouse Button` ) + `SPEED` ( Def: `SHIFT` ) + `USE` ( Def: `E` )
* `CURVE` and `TURN`: Updates selected curve node in condition:
* When trace is a track piece, utilizes the trace entity active point as a curve node.
* Otherwise will check various conditions and pick the most suitable curve node location vector:
* Otherwise will check various conditions and pick the [most suitable curve node location vector][ref-node-intersect]:
1. When both neighbour (`start` **and** `final`) nodes are track active points will intersect their rays
2. When only one (`start` **or** `final`) node is an active point will project the hit node on its ray
3. When **none of the neighbors** are active points will project the hit node on their line simetral
3. When **none of the neighbors** are active points will project the hit node on their line bisector
9. Pressing `RELOAD` ( Def: `R` )
* When trace entity is a valid piece will just remove it.
* When `trackassembly_devmode` is enabled, will update the log control options.
@ -376,6 +376,7 @@ anymore to maintain cetain track packs leading in **NO SUPPORT**, which is also
* [Ron's Minitrain Props](https://steamcommunity.com/sharedfiles/filedetails/?id=728833183)
* [Battleship's abandoned rails](https://steamcommunity.com/sharedfiles/filedetails/?id=807162936)
* [Ron's G-Scale track pack](https://steamcommunity.com/sharedfiles/filedetails/?id=865735701) [**(AUTHOR)**][ref-maintained]
* [Ron's Plarail Advance](https://steamcommunity.com/sharedfiles/filedetails/?id=1512053748) [**(AUTHOR)**][ref-maintained]
* [AlexCookie's 2ft track pack](https://steamcommunity.com/sharedfiles/filedetails/?id=740453553)
* [SligWolf's Tiny hover racer](https://steamcommunity.com/sharedfiles/filedetails/?id=1375275167)
* [Joe's track pack](https://steamcommunity.com/sharedfiles/filedetails/?id=1658816805)
@ -491,3 +492,4 @@ avoiding any version mismatches and confusions. So please don't upload the scrip
[ref-wiki-ta]: https://github.com/dvdvideo1234/TrackAssemblyTool/wiki
[ref-work-turn]: https://www.youtube.com/watch?v=_qcol4_-_ZQ
[ref-user-mbones]: https://steamcommunity.com/profiles/76561198348454446
[ref-node-intersect]: https://www.youtube.com/watch?v=2MCagAUCU_M