Skip to content

Fix: Placeables not welding to displacements - #1883

Open
NickCloudAT wants to merge 1 commit into
TTT-2:masterfrom
NickCloudAT:master
Open

Fix: Placeables not welding to displacements#1883
NickCloudAT wants to merge 1 commit into
TTT-2:masterfrom
NickCloudAT:master

Conversation

@NickCloudAT

Copy link
Copy Markdown
Contributor

Fix placeables welding to displacements
Ensure placeables weld correctly to displacements by switching from util.TraceEntity to util.TraceHull using the entity's OBB mins/maxs and an increased vertical trace distance. Add an optional tr parameter to ENT:WeldToSurface so callers can provide trace data (placement now forwards tr). Update CHANGELOG with the fix.

Note: This was the only "plausible" solution I could come up for now instead of re-doing everything. Default TTT pretty much only does one check like in "StickEntity", but TTT2 does another trace in WeldToSurface. Default TTT by that uses the players position for the trace which works without any issues.

This will now only fallback to a (still more robust than previous) solution with TraceHull instead of TraceEntity. Beware!! This can and will still fail on certain, uneven/bumpy displacements if it falls back to the TraceHull function! Setting the margin (the +256) to a quite big number works, but feels like it would cause other issues..

Would fix: #1881

Fix placeables welding to displacements
Ensure placeables weld correctly to displacements by switching from util.TraceEntity to util.TraceHull using the entity's OBB mins/maxs and an increased vertical trace distance. Add an optional `tr` parameter to ENT:WeldToSurface so callers can provide trace data (placement now forwards `tr`). Update CHANGELOG with the fix.

Note: This was the only "plausible" solution I could come up for now instead of re-doing everything.
Default TTT pretty much only does one check like in "StickEntity", but TTT2 does another trace in WeldToSurface. Default TTT by that uses the players position for the trace which works without any issues.

This will now only fallback to a (still more robust than previous) solution with TraceHull instead of TraceEntity. Beware!! This can and will still fail on certain, uneven/bumpy displacements if it falls back to the TraceHull function! Setting the margin (the +256) to a quite big number works, but feels like it would cause other issues..
@xproot

xproot commented Sep 7, 2026

Copy link
Copy Markdown

+1 please add this

@saibotk

saibotk commented Sep 9, 2026

Copy link
Copy Markdown
Member

Thanks for tackling this @NickCloudAT

Can you explain the solution in more detail? Im not that deep into the welding code atm and id appreciate a little walkthrough of why this failed before and how the hull trace fixes it.

Also some questions i have atm:

  • Is this trace angle even correct and does it point towards the position im looking at? I mean it seems like it does, i am just not sure when reading the code right now
  • If the hull trace is a more correct solution, why should we bother passing an existing trace? And if i read this code, when and where is the weld function even called besides the stick function? And why is it fine for that function to use its own trace?

@NickCloudAT

Copy link
Copy Markdown
Contributor Author

Member

To be quite frank, I don't really understand the welding code myself lol.

Default TTT only has one trace (the one we currently have in the StickEntity function) but TTT2 then calls "WeldToSurface" which handles all the weld stuff but does another trace without knowing about the player.. So the trace pretty much originates from the entity getting placed/welded.

So my thought was: Either we add a mandatory player parameter to "WeldToSurface" or we just add an optional "trace/tr" parameter which would be used instead of the traceHull if not nil.

So with my PR you could in theory still weld a placeable without needing a player by just calling "WeldToSurface" and providing no "tr" which will then fallback to the traceHull.
I switched to traceHull because it seems to be more reliable in hitting displacements.

If the hull trace is a more correct solution, why should we bother passing an existing trace? And if i read this code, when and where is the weld function even called besides the stick function? And why is it fine for that function to use its own trace?

To make a point here: Before and after my PR, the trace function in "WeldToSurface" was never aware of the player nor did it use the players position (which is the problem). But we already have the tracedata from the player in "StickEntity" so I just pass that through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PlaceableEntityBase: Entity does not stick on displacements

3 participants