Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract transfrom from a DB model only if is selected by the user #56

Merged
merged 9 commits into from
Mar 30, 2024

Conversation

dvdvideo1234
Copy link
Owner

Currently TA can still hit the limit of the internally stored models in the source engine via calling util.IsValidModel directly or triggering a ENT:SetModel routine that later fills a space in this array too. When registering transform we have

  164 [24-03-24 19:13:42] SERVER > TRACKASSEMBLY [LUA] IsModel: File >> {nil}|true|models/ron/plarail/scenery/aj01.mdl|
  165 [24-03-24 19:13:42] SERVER > TRACKASSEMBLY [LUA] MakeEntityNone: Create {2}|models/ron/plarail/scenery/aj01.mdl|
  166 [24-03-24 19:13:42] SERVER > TRACKASSEMBLY [LUA] GetTransformOA: Extract {1}|0.000000 0.000000 0.000000|-0.000 90.000 0.000|
  167 [24-03-24 19:13:42] SERVER > TRACKASSEMBLY [LUA] GetTransformOA: Extract {2}|-0.000008 175.999985 0.000000|-0.000 -90.000 0.000|
  168 [24-03-24 19:13:42] SERVER > TRACKASSEMBLY [LUA] IsModel: File >> {nil}|true|models/ron/plarail/scenery/aj01_2.mdl|
  169 [24-03-24 19:13:42] SERVER > TRACKASSEMBLY [LUA] GetTransformOA: Update {2}|models/ron/plarail/scenery/aj01_2.mdl|
  170 [24-03-24 19:13:42] SERVER > TRACKASSEMBLY [LUA] GetTransformOA: Extract {1}|0.000000 0.000000 0.000000|-0.000 90.000 0.000|
  171 [24-03-24 19:13:42] SERVER > TRACKASSEMBLY [LUA] GetTransformOA: Extract {2}|-0.000004 87.999992 0.000000|-0.000 -90.000 0.000|
  172 [24-03-24 19:13:42] SERVER > TRACKASSEMBLY [LUA] IsModel: File >> {nil}|true|models/ron/plarail/scenery/aj02.mdl|
  173 [24-03-24 19:13:42] SERVER > TRACKASSEMBLY [LUA] GetTransformOA: Update {2}|models/ron/plarail/scenery/aj02.mdl|
  174 [24-03-24 19:13:42] SERVER > TRACKASSEMBLY [LUA] GetTransformOA: Extract {1}|0.000000 0.000000 0.000000|-0.000 90.000 0.000|
  175 [24-03-24 19:13:42] SERVER > TRACKASSEMBLY [LUA] GetTransformOA: Extract {2}|0.000000 0.000000 -35.999996|-0.000 90.000 0.000|
  176 [24-03-24 19:13:42] SERVER > TRACKASSEMBLY [LUA] IsModel: File >> {nil}|true|models/ron/plarail/scenery/aj03.mdl|
  177 [24-03-24 19:13:42] SERVER > TRACKASSEMBLY [LUA] GetTransformOA: Update {2}|models/ron/plarail/scenery/aj03.mdl|
  178 [24-03-24 19:13:42] SERVER > TRACKASSEMBLY [LUA] GetTransformOA: Extract {1}|0.000000 0.000000 0.000000|-0.000 -90.000 0.000|
  179 [24-03-24 19:13:42] SERVER > TRACKASSEMBLY [LUA] GetTransformOA: Extract {2}|-0.000004 87.999992 0.000000|-0.000 90.000 0.000|
  180 [24-03-24 19:13:42] SERVER > TRACKASSEMBLY [LUA] GetTransformOA: Extract {3}|-0.000004 87.999992 35.999996|-0.000 90.000 0.000|

This caches a transform POA dummy entity which is used to extract the parameters for model X, however every ENT:SetModel call on this entity fills one slot in the internal strings table of 4K limit

Possible resolution: Adjust asmlib.GetNormalSpawn or some of its internal routines ( most likely LocatePOA ). The idea is that if a model is chosen from the user it will be ghosted. So if it does, the entity must be spawned and a slot will be filled anyway. In this case the transform temporary entity can be used for extracting the position and angle. Currently TA in Lua database mode will call the extraction for every model in the database parametrized to use transform attachments with notation !<attachment_id> for points, origins and angles ( POA ). The DB cache must obtain a KV pair that stores the current initialization status if the picked model and to extract it only if needed a.k.a. when this internal flag is false ( attachment not yet loaded ). Loading the attachment will trigger this flag to true and one model will be inserted in the internal game model cache.

@Grocel
Copy link

Grocel commented Mar 24, 2024

  1. The TOOL:Think hooks looks much better now.
  2. Your planned resolution to the model string table problem is reasonable and would scale much better with the count of installed models. Using the dummy entity is fine in this context too. It is way less likely to have any unintended side effects than the old solution. It might even reduce the load time of the game and of the tool.

@dvdvideo1234 dvdvideo1234 changed the title Added: Rearranged the think hook Extract transfrom from a DB model only if is selected by the user Mar 25, 2024
@dvdvideo1234
Copy link
Owner Author

The model being existent in the cache according to the log:

  364 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl] = {}
  365 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Size"] = 2
  366 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"] = {}
  367 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][1] = {}
  368 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][1]["O"] = {}
  369 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][1]["O"][1] = 0
  370 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][1]["O"][2] = 0
  371 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][1]["O"][3] = 0
  372 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][1]["O"]["Slot"] = "!1"
  373 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][1]["A"] = {}
  374 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][1]["A"][1] = -0
  375 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][1]["A"][2] = 90
  376 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][1]["A"][3] = 0
  377 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][1]["A"]["Slot"] = "!1"
  378 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][1]["P"] = {}
  379 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][1]["P"][1] = 0
  380 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][1]["P"][2] = 0
  381 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][1]["P"][3] = 0
  382 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][2] = {}
  383 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][2]["O"] = {}
  384 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][2]["O"][1] = -7.6932037700317e-06
  385 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][2]["O"][2] = 175.99998474121
  386 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][2]["O"][3] = 0
  387 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][2]["O"]["Slot"] = "!2"
  388 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][2]["A"] = {}
  389 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][2]["A"][1] = -0
  390 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][2]["A"][2] = -90
  391 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][2]["A"][3] = 0
  392 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][2]["A"]["Slot"] = "!2"
  393 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][2]["P"] = {}
  394 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][2]["P"][1] = -7.6932037700317e-06
  395 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][2]["P"][2] = 175.99998474121
  396 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Offs"][2]["P"][3] = 0
  397 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Type"] = "Plarail"
  398 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Unit"] = "NULL"
  399 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Name"] = "AJ-01 Station"
  400 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] CacheQueryPiece: tCache[models/ron/plarail/scenery/aj01.mdl]["Slot"] = "models/ron/plarail/scenery/aj01.mdl"
  401 [24-03-27 18:59:32] SERVER > TRACKASSEMBLY [LUA] IsModel: Deep >> {true}|true|models/ron/plarail/scenery/aj01.mdl|

@dvdvideo1234
Copy link
Owner Author

dvdvideo1234 commented Mar 27, 2024

Hey, @Grocel

I think we are ready with this. Could you please ask @marchc1 to test this branch. If it works I will merge it.
In the logs I see GetTransformOA getting called only once per model ( the function which will create/update the dummy ).
Every time a piece is selected on the server/client it will run POA location and update the cached record internally

  360 [24-03-27 20:54:02] CLIENT > TRACKASSEMBLY [LUA] MakeEntityNone: Create {-1}|models/ron/plarail/tracks/misc/ar01.mdl|
  361 [24-03-27 20:54:02] CLIENT > TRACKASSEMBLY [LUA] GetTransformOA: Extract {1}|0.000000 0.000000 0.000000|-0.000 -90.000 0.000|
  362 [24-03-27 20:54:02] CLIENT > TRACKASSEMBLY [LUA] LocatePOA: Origin transform from model {1}|1|0,0,0|
  363 [24-03-27 20:54:02] CLIENT > TRACKASSEMBLY [LUA] GetTransformOA: Extract {1}|0.000000 0.000000 0.000000|-0.000 -90.000 0.000|
  364 [24-03-27 20:54:02] CLIENT > TRACKASSEMBLY [LUA] LocatePOA: Angle transform from model {1}|1|-0,-90,0|
  365 [24-03-27 20:54:02] CLIENT > TRACKASSEMBLY [LUA] GetTransformOA: Extract {2}|-0.000008 175.999985 0.000000|-0.000 90.000 0.000|
  366 [24-03-27 20:54:02] CLIENT > TRACKASSEMBLY [LUA] LocatePOA: Origin transform from model {2}|2|-7.6932037700317e-06,175.99998474121,0|
  367 [24-03-27 20:54:02] CLIENT > TRACKASSEMBLY [LUA] GetTransformOA: Extract {2}|-0.000008 175.999985 0.000000|-0.000 90.000 0.000|
  368 [24-03-27 20:54:02] CLIENT > TRACKASSEMBLY [LUA] LocatePOA: Angle transform from model {2}|2|-0,90,0|
  369 [24-03-27 20:54:02] CLIENT > TRACKASSEMBLY [LUA] GetCacheSpawn: Allocate {[Sk$Bh]Trick or treat KID!}
  370 [24-03-27 20:54:02] CLIENT > TRACKASSEMBLY [LUA] GetCacheRadius: Allocate <[Sk$Bh]Trick or treat KID!>
  371 [24-03-27 20:54:02] CLIENT > TRACKASSEMBLY [LUA] TOOL.ElevateGhost: (false) <2.2499997615814>
  372 [24-03-27 20:54:22] CLIENT > TRACKASSEMBLY [LUA] BIND_PRESS: (+attack) Skipped
  328 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] IsModel: File >> {nil}|true|models/ron/plarail/tracks/misc/ar01.mdl|
  329 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] MakeEntityNone: Create {169}|models/ron/plarail/tracks/misc/ar01.mdl|
  330 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] GetTransformOA: Extract {1}|0.000000 0.000000 0.000000|-0.000 -90.000 0.000|
  331 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] LocatePOA: Origin transform from model {1}|1|0,0,0|
  332 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] GetTransformOA: Extract {1}|0.000000 0.000000 0.000000|-0.000 -90.000 0.000|
  333 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] LocatePOA: Angle transform from model {1}|1|-0,-90,0|
  334 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] GetTransformOA: Extract {2}|-0.000008 175.999985 0.000000|-0.000 90.000 0.000|
  335 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] LocatePOA: Origin transform from model {2}|2|-7.6932037700317e-06,175.99998474121,0|
  336 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] GetTransformOA: Extract {2}|-0.000008 175.999985 0.000000|-0.000 90.000 0.000|
  337 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] LocatePOA: Angle transform from model {2}|2|-0,90,0|
  338 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] GetPlayerSpot: Cached {[Sk$Bh]Trick or treat KID!}
  339 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] GetCacheSpawn: Allocate {[Sk$Bh]Trick or treat KID!}
  340 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] IsModel: Deep >> {true}|true|models/ron/plarail/tracks/misc/ar01.mdl|
  341 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] SetPosBound: (OFF) Skip
  342 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] AttachBodyGroups: SetBodygroup {1}|0|0|0|
  343 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] AttachBodyGroups: Success {0}
  344 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] CacheQueryAdditions: Record not located
  345 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] AttachAdditions: Model skip <models/ron/plarail/tracks/misc/ar01.mdl>
  346 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] MakePiece: {Entity [170][gmod_plarail_ar01]}|models/ron/plarail/tracks/misc/ar01.mdl|
  347 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] ApplyPhysicalSettings: {Entity [170][gmod_plarail_ar01]}|false|true|true|metal|
  348 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] ApplyPhysicalSettings: Success
  349 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] ApplyPhysicalAnchor: {Entity [170][gmod_plarail_ar01]}|nil|false|true|false|0|
  350 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] ApplyPhysicalAnchor: NoCollide base invalid {nil}|nil|
  351 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] ApplyPhysicalAnchor: Success
  352 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] TOOL.LeftClick: (Spawn) Success
  353 [24-03-27 20:54:22] SERVER > TRACKASSEMBLY [LUA] DELAY_ACTION: Freeze:[true]

@Grocel
Copy link

Grocel commented Mar 27, 2024

Nice, that you got it done. 👍

  1. I am not sure if is usefull to ask @marchc1, because he would no longer be able to reproduce the crash as the crash had be fixed on engine level last week. The fix already has been deployed to the x64 branch of the game. He is very invited to test this, though.

  2. That GetTransformOA is called only once per model is nice. But did you confirm that MakeEntityNone or any other model caching function (ent:SetModel) is no longer called for every DB entry right away. If so it would be a huge win, no more unneeded precaches. Remember: To much precache is a precrash 💥😄
    It isn't very clear from the logs if your changes are accually effective to our goal or not. What I can tell so far is, that it is called when the tool is accually used, which is at least a step in the right direction.

@dvdvideo1234
Copy link
Owner Author

dvdvideo1234 commented Mar 28, 2024

Hey @Grocel

Generally it is OK to have one MakeEntityNone Create/Update log per model. GetTransformOA is called for every slot so I do not break feature track pack creators are using !1 for origin and 1,2,3 for the angle for example

I can confirm. Precache is used only when the model is about to be ghosted or spanned. The algorithm is pretty much the following:

  1. Track pack creators insert !1
  2. I inset !1 in the database
  3. RegisterPOA is called on insert trigger
  4. Flag is rizen to later process !1 in LocatePOA
  5. Cache is updated with 0,0,0 value on insert
  6. Flag is enabled. Disable it as we have to spawn
  7. Create/Update the dummy entity for the model when not present or different
  8. Extract the offsets from !1 and fill the 0,0,0
  9. Run LocatePOA on snap to get the offsets
  10. Return a pointer to the updated record from !1

I must test also the ghosting on all the modes. When OK the spawn will too as it also uses GetNormalSpwan

@Grocel
Copy link

Grocel commented Mar 28, 2024

Looks fine for me then.

@Grocel
Copy link

Grocel commented Mar 28, 2024

IsString you removed was for sKey, not sModel, are you sure you want to do this?

@dvdvideo1234
Copy link
Owner Author

Just noticed... My bad.. Must return this ...

@dvdvideo1234
Copy link
Owner Author

Must test this in LUA and SQL modes for ghosting and spawning before merging. But I am 95% sure it will be OK

Added: Selection search point slot being taken with priority
Updated: Spawn margin sends message to the user
@dvdvideo1234
Copy link
Owner Author

Hi, @Grocel just validated all the cases

 1994 [24-03-30 13:57:51] CLIENT > TRACKASSEMBLY [SQL] CacheQueryPiece: Save >> {string}|models/ron/plarail/tracks/straight/r20_01.mdl|
 1995 [24-03-30 13:57:51] CLIENT > TRACKASSEMBLY [SQL] RegisterPOA: Origin transform {!1}|models/ron/plarail/tracks/straight/r20_01.mdl|
 1996 [24-03-30 13:57:51] CLIENT > TRACKASSEMBLY [SQL] RegisterPOA: Angle transform {!1}|models/ron/plarail/tracks/straight/r20_01.mdl|
 1997 [24-03-30 13:57:51] CLIENT > TRACKASSEMBLY [SQL] RegisterPOA: Origin transform {!2}|models/ron/plarail/tracks/straight/r20_01.mdl|
 1998 [24-03-30 13:57:51] CLIENT > TRACKASSEMBLY [SQL] RegisterPOA: Angle transform {!2}|models/ron/plarail/tracks/straight/r20_01.mdl|
 1999 [24-03-30 13:57:51] CLIENT > TRACKASSEMBLY [SQL] PIECES.TimerAttach: Called by <CacheQueryPiece> for [models/ron/plarail/tracks/straight/r20_01.mdl]
 2000 [24-03-30 13:57:51] CLIENT > TRACKASSEMBLY [SQL] PIECES.TimerAttach: [CQT] (1800) true, true
 2001 [24-03-30 13:57:51] CLIENT > TRACKASSEMBLY [SQL] PIECES.TimerAttach: Garbage collected
 2002 [24-03-30 13:57:51] CLIENT > TRACKASSEMBLY [SQL] PIECES.TimerAttach: [models/ron/plarail/tracks/straight/r20_01.mdl] @180.94
 2003 [24-03-30 13:57:51] CLIENT > TRACKASSEMBLY [SQL] MakeEntityNone: Create {-1}|models/ron/plarail/tracks/straight/r20_01.mdl|
 2004 [24-03-30 13:57:51] CLIENT > TRACKASSEMBLY [SQL] GetTransformOA: Extract {1}|0.000000 0.000000 0.000000|-0.000 -90.000 0.000|
 2005 [24-03-30 13:57:51] CLIENT > TRACKASSEMBLY [SQL] LocatePOA: Origin transform from model {1}|1|0,0,0|
 2006 [24-03-30 13:57:51] CLIENT > TRACKASSEMBLY [SQL] GetTransformOA: Extract {1}|0.000000 0.000000 0.000000|-0.000 -90.000 0.000|
 2007 [24-03-30 13:57:51] CLIENT > TRACKASSEMBLY [SQL] LocatePOA: Angle transform from model {1}|1|-0,-90,0|
 2008 [24-03-30 13:57:51] CLIENT > TRACKASSEMBLY [SQL] GetTransformOA: Extract {2}|-0.000002 43.999996 0.000000|-0.000 90.000 0.000|
 2009 [24-03-30 13:57:51] CLIENT > TRACKASSEMBLY [SQL] LocatePOA: Origin transform from model {2}|2|-1.9233009425079e-06,43.999996185303,0|
 2010 [24-03-30 13:57:51] CLIENT > TRACKASSEMBLY [SQL] GetTransformOA: Extract {2}|-0.000002 43.999996 0.000000|-0.000 90.000 0.000|
 2011 [24-03-30 13:57:51] CLIENT > TRACKASSEMBLY [SQL] LocatePOA: Angle transform from model {2}|2|-0,90,0|
 2012 [24-03-30 13:57:51] CLIENT > TRACKASSEMBLY [SQL] TOOL.ElevateGhost: (false) <2.2499997615814>

@dvdvideo1234 dvdvideo1234 merged commit ad93c4c into master Mar 30, 2024
1 check passed
@dvdvideo1234 dvdvideo1234 deleted the transform-spawn branch March 30, 2024 12:07
@Grocel
Copy link

Grocel commented Mar 30, 2024

  1. I have checked your changes today and I am happy with the results.
    Today I also discovered that there is a concommand to list the precached models: dumpstringtables_new modelprecache
    I used it to confirm that the tool behaves much better now in terms of model precaching.

  2. There was one error got during testing, though:

[track-assembly-tool] addons/track-assembly-tool/lua/trackassembly/trackasmlib.lua:2284: attempt to index local 'sP' (a nil value)
  1. LocatePOA - addons/track-assembly-tool/lua/trackassembly/trackasmlib.lua:2284
   2. GetNormalSpawn - addons/track-assembly-tool/lua/trackassembly/trackasmlib.lua:4171
    3. LeftClick - addons/track-assembly-tool/lua/weapons/gmod_tool/stools/trackassembly.lua:1074
     4. unknown - gamemodes/sandbox/entities/weapons/gmod_tool/shared.lua:228

The custom piece (in dsv/sligwolf_s_traintrackassembly_pieces.txt) I have added that caused the error:
This example is just a test case with no real use. It was used for developing upcoming changes to SligWolf's addons.

# SynchronizeDSV:(SligWolf_s_Train@PIECES) 24-03-30 17:14:55 [ LUA ]
# PIECES:(MODEL	TYPE	NAME	LINEID	POINT	ORIGIN	ANGLE	CLASS)
TRACKASSEMBLY_PIECES	"models/props_lab/blastdoor001b.mdl"	"SligWolf's Train"	"Testcase #1"	1	"NULL"	"!holder"	"NULL"	"NULL"
TRACKASSEMBLY_PIECES	"models/props_lab/blastdoor001b.mdl"	"SligWolf's Train"	"Testcase #1"	2	"NULL"	"0,0,0"	"0, 180, 0"	"NULL"
TRACKASSEMBLY_PIECES	"models/props_lab/blastdoor001b.mdl"	"SligWolf's Train"	"Testcase #1"	3	"NULL"	"20,0,0"	"NULL"	"NULL"

@dvdvideo1234
Copy link
Owner Author

Ah... I see in case the attachment is invalid thank you !

@dvdvideo1234
Copy link
Owner Author

Hey, @Grocel

Add a custom DSV by attaching it to the DSV list
image

# SynchronizeDSV:(Anyone_s_Horrible_Trackpack@PIECES) 24-03-30 19:06:40 [ LUA ]
# PIECES:(MODEL	TYPE	NAME	LINEID	POINT	ORIGIN	ANGLE	CLASS)
TRACKASSEMBLY_PIECES	"models/props_lab/blastdoor001b.mdl"	"POA Test"	"Door"	1	"NULL"	"!test1"	"0,90,0"	"NULL"
TRACKASSEMBLY_PIECES	"models/props_lab/blastdoor001b.mdl"	"POA Test"	"Door"	2	"NULL"	"!1,2,3"	"0,-90,0"	"NULL"
TRACKASSEMBLY_PIECES	"models/props_lab/blastdoor001b.mdl"	"POA Test"	"Door"	3	"NULL"	"1,2,3"	"0,90,0"	"NULL"
TRACKASSEMBLY_PIECES	"models/props_lab/blastdoor001b.mdl"	"POA Test"	"Door"	4	"4,5,6"	"!test1"	"0,-90,0"	"NULL"
TRACKASSEMBLY_PIECES	"models/props_lab/blastdoor001b.mdl"	"POA Test"	"Door"	5	"4,5,6"	"!1,2,3"	"0,90,0"	"NULL"
TRACKASSEMBLY_PIECES	"models/props_lab/blastdoor001b.mdl"	"POA Test"	"Door"	6	"4,5,6"	"1,2,3"	"0,-90,0"	"NULL"
  1. Expected point/origin to be (0,0,0/0,0,0)
    Attachment test1 does not exist and TA tries to decode it resulting
  2. Expected point/origin to be (1,2,3/1,2,3)
    Attachment 1,2,3 does not exists but decoding it and defaulting the point both receive 1,2,3
  3. Expected point/origin to be (1,2,3/1,2,3)
    No attachments here and defaulting the point both receive 1,2,3
  4. Expected point/origin to be (4,5,6/0,0,0)
    Attachment test1 does not exist and TA tries to decode it resulting. Point is decoded to 4,5,6
  5. Expected point/origin to be (4,5,6/1,2,3)
    Attachment 1,2,3 does not exists but decoding it receive 1,2,3. Point is decoded to 4,5,6
  6. Expected point/origin to be (4,5,6/1,2,3)
    No attachments here decoded origin receive 1,2,3. Point is decoded to 4,5,6

@dvdvideo1234
Copy link
Owner Author

dvdvideo1234 commented Mar 30, 2024

Everything is validated. Thanks for testing it in this specific case!

image

 2158 [24-03-30 19:28:02] CLIENT > TRACKASSEMBLY [LUA] MakeEntityNone: Create {-1}|models/props_lab/blastdoor001b.mdl|
 2159 [24-03-30 19:28:02] CLIENT > TRACKASSEMBLY [LUA] GetTransformOA: Attachment missing OA {number}|0|models/props_lab/blastdoor001b.mdl
 2160 [24-03-30 19:28:02] CLIENT > TRACKASSEMBLY [LUA] DecodePOA: Mismatch {string}|test1|
 2161 [24-03-30 19:28:02] CLIENT > TRACKASSEMBLY [LUA] LocatePOA: Origin transform from model {1}|test1|0,0,0|
 2162 [24-03-30 19:28:02] CLIENT > TRACKASSEMBLY [LUA] GetTransformOA: Attachment missing OA {number}|0|models/props_lab/blastdoor001b.mdl
 2163 [24-03-30 19:28:02] CLIENT > TRACKASSEMBLY [LUA] LocatePOA: Origin transform from model {2}|1,2,3|1,2,3|
 2164 [24-03-30 19:28:02] CLIENT > TRACKASSEMBLY [LUA] GetTransformOA: Attachment missing OA {number}|0|models/props_lab/blastdoor001b.mdl
 2165 [24-03-30 19:28:02] CLIENT > TRACKASSEMBLY [LUA] DecodePOA: Mismatch {string}|test1|
 2166 [24-03-30 19:28:02] CLIENT > TRACKASSEMBLY [LUA] LocatePOA: Origin transform from model {4}|test1|0,0,0|
 2167 [24-03-30 19:28:02] CLIENT > TRACKASSEMBLY [LUA] GetTransformOA: Attachment missing OA {number}|0|models/props_lab/blastdoor001b.mdl
 2168 [24-03-30 19:28:02] CLIENT > TRACKASSEMBLY [LUA] LocatePOA: Origin transform from model {5}|1,2,3|1,2,3|

@dvdvideo1234
Copy link
Owner Author

Fixed in c6bbdc4

@Grocel
Copy link

Grocel commented Mar 30, 2024

Nice. Did you check if the angle can have this issue too? Does the point support attachments too? Actually I am not even sure what point is used for. Can you clarify the difference between origin and point to me?

Did you also notice my dumpstringtables_new modelprecache section in the other post?

@dvdvideo1234
Copy link
Owner Author

dvdvideo1234 commented Mar 30, 2024

Yep, quite neat thing you have found there indeed ;) The angle will not have such issue, simply because it is single orientation value stored as string in the DB. Nothing else uses it to trigger an automatic auto fill ( Like the origin does trigger one for the point ). The point ( Location that TA searches and selects an origin for on mouse hover ) is ether present or not present. In case of null ( or an empty string ) must be filled with the origin ( Base location vector used for a coordinate system relative to which the next track piece is spawned ) otherwise it is considered that you have 1,2,3 and it must be decoded.

@dvdvideo1234
Copy link
Owner Author

Good example for this is PHX single unit track. Points are situated on the piece edges and he origins where the track must continue.

  PIECES:Record({"models/props_phx/trains/tracks/track_single.mdl", "#", "#", 1, "-0.327,-61.529,8.714", " 15.45284,0,12.548828"})
  PIECES:Record({"models/props_phx/trains/tracks/track_single.mdl", "#", "#", 2, "-0.327, 61.529,8.714", "-16.09597,0,12.548828", "0,180,0"})

@Grocel
Copy link

Grocel commented Mar 30, 2024

Ah, I see. This totally makes sense, because the origin could be a way out of reach for the player to hit without leaving the hit object.

Just for clarification:

  1. Is it possible to insert an attachment name for angles too, so it takes its angles for the entry on spawn?
  2. Is it possible to insert an attachment name for the point? Like in a similar manner to origin?

The description below says, that attachments would be supported at least for angles (ANGLE) too, so I am unsure about this.
https://github.com/dvdvideo1234/TrackAssemblyTool/blob/master/data/trackassembly/set/z_autorun_%5Btrackassembly%5D.txt#L205-L242

@dvdvideo1234
Copy link
Owner Author

dvdvideo1234 commented Mar 30, 2024

Yeah.. Exactly

  1. Yeah... Like in the current version where you can put !1 or !2 in the DB for the angles of a specific model. If attachment is found it is processed just like the origin. Insert (0,0,0) and later extract the transform angle via LocatePOA on spawn. Attachment name can be any string tough, you can even have !2 for point #1 for example. It treats it just like a hash ;) ( I bet that's how it works internally ). For example if you put !1,2,3 it will first try to look up 1,2,3. If no AngPos is found it will try to decode it via DecodePOA or assign 0,0,0 when NULL is present.
  2. Currently nope unless they expand AngPos and GetAttachment(ID) is able to return another vector as well. Ron for example uses attachments in his packs. He wants only to change the models and update them and do not touch the source, because it will be a major hassle if he had to update the code as well after he does the models

@Grocel
Copy link

Grocel commented Mar 30, 2024

  1. Nice, good to know.
  2. I don't get why AngPos would need to get a 2nd vector in order for POINT to support attachments as well. Just extract the attachment position for the string given for POINT like you did for ORIGIN. If needed, users would add a different attachment for POINT then they would use for ORIGIN. You could use the same/similar transforming logic you did with ORIGIN. A point has no angle, so ignore angles for POINT.
  3. It is very useful that attachment are supported. It is very good design. SligWolf and I are working on a large update for our addons. We plan to use attachments only in our addons containing track pieces. :D

@dvdvideo1234
Copy link
Owner Author

  1. Hmm I do not see why not.. you are right. You have to use another hash if you want different points than the origins. Or force it to use some attachment ID and call it done it seems 😄
  2. Neat what do you have in mind 😁

@Grocel
Copy link

Grocel commented Mar 30, 2024

  1. This is quite an expected behavior for me as a user/developer. I would use a different attachment for points if needed. Otherwise I would just leave it blank to have it equal origin.
  2. There are multiple projects going on, but one of them is:
    https://www.youtube.com/watch?v=Xm9RnrCAPb0
    https://www.youtube.com/watch?v=r-VZ2YhJdKk
    Replica of the The Wuppertal Suspension Train, A unique 100 year old monorail system in Germany: https://schwebebahn.de/en

@dvdvideo1234
Copy link
Owner Author

dvdvideo1234 commented Mar 31, 2024

Hello, @Grocel

Added in: 4fc6604

Tested with cartesian products for point being NULL/!NULL and 4,5,6/!4,5,6. Now TA will try to extract !point on spawn but if it fails will fill it again with the origin:

TRACKASSEMBLY_PIECES	"models/props_lab/blastdoor001b.mdl"	"POA Test"	"Door"	7	"!NULL"	"!test1"	"0,90,0"	"NULL"
TRACKASSEMBLY_PIECES	"models/props_lab/blastdoor001b.mdl"	"POA Test"	"Door"	8	"!NULL"	"!1,2,3"	"0,-90,0"	"NULL"
TRACKASSEMBLY_PIECES	"models/props_lab/blastdoor001b.mdl"	"POA Test"	"Door"	9	"!NULL"	"1,2,3"	"0,90,0"	"NULL"
TRACKASSEMBLY_PIECES	"models/props_lab/blastdoor001b.mdl"	"POA Test"	"Door"	10	"!4,5,6"	"!test1"	"0,-90,0"	"NULL"
TRACKASSEMBLY_PIECES	"models/props_lab/blastdoor001b.mdl"	"POA Test"	"Door"	11	"!4,5,6"	"!1,2,3"	"0,90,0"	"NULL"
TRACKASSEMBLY_PIECES	"models/props_lab/blastdoor001b.mdl"	"POA Test"	"Door"	12	"!4,5,6"	"1,2,3"	"0,-90,0"	"NULL"
LocatePOA: Origin transform from spawn {7}|!test1|0,0,0|
LocatePOA: Point transform from spawn {7}|!NULL|0,0,0|
LocatePOA: Origin transform from spawn {8}|!1,2,3|1,2,3|
LocatePOA: Point transform from spawn {8}|!NULL|1,2,3|
LocatePOA: Point transform from spawn {9}|!NULL|1,2,3|
LocatePOA: Origin transform from spawn {10}|!test1|0,0,0|
LocatePOA: Point transform from spawn {10}|!4,5,6|4,5,6|
LocatePOA: Origin transform from spawn {11}|!1,2,3|1,2,3|
LocatePOA: Point transform from spawn {11}|!4,5,6|4,5,6|
LocatePOA: Point transform from spawn {12}|!4,5,6|4,5,6|

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants