Open slipher opened 1 month ago
I think using a builder paradigm is sensible.
I would rename some of the methods tho:
First of all, I would avoid mixing lower case methods with upper case methods. I would stick to using Upper case for all methods, especially if they are public methods.
passEntity
-> ignoreEntity
skipContents
-> ignoreContents
Trace1
-> TraceIgnoreStart()
Trace2
-> Trace
An alternative API might be something like
trace_t tr = TraceBuilder(ent->r.currentOrigin, origin, ent->clipmask)
.bounds(ent->r.mins, ent->r.maxs)
.passEntity(ent->num())
.IgnoreStart(false)
.Trace();
That's a good idea to make the startsolid behavior one of the build-able parameters. I didn't think of it because the two trace functions return different types, but we could just erase the small amount of extra information, which is almost never used, from trace_t
and always return trace2_t
. I can only spot one place where trace_t::startsolid
is used in sgame, in G_Physics
. But it doesn't even make any sense to me how it's being used.
I propose using a builder interface for traces. For example instead of
We would have instead
The full API would look like this.
vec3_t
variants are omitted for brevity.What do you think? An alternative would be to set the start/end and content masks using builder methods, instead of from the constructor. In this case I would add booleans to track whether those required parameters are set and call Sys::Drop if they are not.
Don't worry about unfinished migrations: if I were to merge this, I would migrate all the callers in sgame.