Fix: Placeables not welding to displacements - #1883
Conversation
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..
|
+1 please add this |
|
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:
|
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.
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. |
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
trparameter to ENT:WeldToSurface so callers can provide trace data (placement now forwardstr). 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