Engine icon indicating copy to clipboard operation
Engine copied to clipboard

Enhancement: CGameTrace entity filters

Open HugoBDesigner opened this issue 1 month ago • 1 comments

In Scripting, we have CGameTrace, which is an object class returned from functions like TraceLineEx and TracePortalLine. They currently support a single ent to ignore parameter, which is less than ideal if most times you have to set it to GetPlayer(). Additionally, even with collision masks and collision groups changed to various combinations, a trace can only hit objects with collision enabled.

One possible way to address this is by having entity filters, which can take the form of either an array of handles, a dedicated filter class, or the handle of an in-game filter entity. It'd then check a hit against every entity within that filter and, if found, would ignore it and continue the trace. This could be done either in the existing trace functions, or through new functions.

Additionally, if at all possible, there could be a new parameter and/or set of functions that specifically targets a given entity, list of entities, or filter, and if the trace hits it (whether or not it has collisions), then it returns the hit position.

This would help in a number of cases: modders could account for non-colliding brushes (like fizzlers), could avoid targetting special entities (like the player, held objects, weapons, etc.), and just generally give them more flexibility in designing new mechanics.

HugoBDesigner avatar Nov 02 '25 02:11 HugoBDesigner

On the C++ side traces take an arbitrary callback, so ideally that could be exposed for you to do whatever you want. I guess there's potentially re-entrancy issues there though, would need to check for silly things like users doing a trace inside the predicate or something.

TeamSpen210 avatar Nov 02 '25 03:11 TeamSpen210