VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
VoltMod::Trace Class Reference

runtime.Trace: line and box traces against the physics world. Game-thread only. More...

#include <Trace.hpp>

Public Member Functions

 Trace (const Bindings &bindings)
 Trace (const Trace &)=delete
Trace & operator= (const Trace &)=delete
Status Available () const
Result< TraceHit > Line (const Vector &from, const Vector &to, const TraceOptions &options={}) const
Result< TraceHit > Box (const Vector &from, const Vector &to, const Vector &mins, const Vector &maxs, const TraceOptions &options={}) const
Result< TraceHit > FromEyes (const Pawn &pawn, float distance, TraceLayers layers=TraceLayers::Solid) const
Result< bool > Clear (const Vector &from, const Vector &to, const TraceOptions &options={}) const
What a trace hit

As Line, Box and FromEyes, empty both when nothing is in the way and when the trace cannot run. Use those where the two need telling apart.

std::optional< TraceHit > FirstHit (const Vector &from, const Vector &to, const TraceOptions &options={}) const
std::optional< TraceHit > FirstHit (const Vector &from, const Vector &to, const Vector &mins, const Vector &maxs, const TraceOptions &options={}) const
std::optional< TraceHit > FirstHit (const Pawn &pawn, float distance, TraceLayers layers=TraceLayers::Solid) const

Detailed Description

runtime.Trace: line and box traces against the physics world. Game-thread only.

const auto clear = runtime.Trace.Clear(eye, target, {.Ignore1 = self, .Ignore2 = other});
if (clear && *clear)
...

Definition at line 50 of file Trace.hpp.

Constructor & Destructor Documentation

◆ Trace() [1/2]

VoltMod::Trace::Trace ( const Bindings & bindings)
inlineexplicit

bindings must outlive this service.

Definition at line 54 of file Trace.hpp.

Referenced by operator=(), and Trace().

◆ Trace() [2/2]

VoltMod::Trace::Trace ( const Trace & )
delete

References Trace().

Member Function Documentation

◆ Available()

Status VoltMod::Trace::Available ( ) const

Unsupported when the Nav_TraceLine slot did not bind.

Definition at line 73 of file Trace.cpp.

References VoltMod::Error::Unsupported().

Referenced by Line().

◆ Box()

Result< TraceHit > VoltMod::Trace::Box ( const Vector & from,
const Vector & to,
const Vector & mins,
const Vector & maxs,
const TraceOptions & options = {} ) const

Sweeps mins..maxs along the path; End is the box origin. Unsupported when the Nav_TraceShape slot did not bind.

Definition at line 97 of file Trace.cpp.

References VoltMod::MakeFilter(), VoltMod::NavPhysics(), VoltMod::ToHit(), and VoltMod::Error::Unsupported().

Referenced by FirstHit().

◆ Clear()

Result< bool > VoltMod::Trace::Clear ( const Vector & from,
const Vector & to,
const TraceOptions & options = {} ) const

Definition at line 135 of file Trace.cpp.

References Line().

◆ FirstHit() [1/3]

std::optional< TraceHit > VoltMod::Trace::FirstHit ( const Pawn & pawn,
float distance,
TraceLayers layers = TraceLayers::Solid ) const

Definition at line 130 of file Trace.cpp.

References FromEyes(), and VoltMod::OnlyHit().

◆ FirstHit() [2/3]

std::optional< TraceHit > VoltMod::Trace::FirstHit ( const Vector & from,
const Vector & to,
const TraceOptions & options = {} ) const

Definition at line 119 of file Trace.cpp.

References Line(), and VoltMod::OnlyHit().

◆ FirstHit() [3/3]

std::optional< TraceHit > VoltMod::Trace::FirstHit ( const Vector & from,
const Vector & to,
const Vector & mins,
const Vector & maxs,
const TraceOptions & options = {} ) const

Definition at line 124 of file Trace.cpp.

References Box(), and VoltMod::OnlyHit().

◆ FromEyes()

Result< TraceHit > VoltMod::Trace::FromEyes ( const Pawn & pawn,
float distance,
TraceLayers layers = TraceLayers::Solid ) const

Along pawn's aim, ignoring the pawn.

Definition at line 113 of file Trace.cpp.

References VoltMod::Pawn::EyeForward(), VoltMod::Pawn::EyePosition(), and Line().

Referenced by FirstHit().

◆ Line()

Result< TraceHit > VoltMod::Trace::Line ( const Vector & from,
const Vector & to,
const TraceOptions & options = {} ) const

Definition at line 82 of file Trace.cpp.

References Available(), VoltMod::MakeFilter(), VoltMod::NavPhysics(), and VoltMod::ToHit().

Referenced by Clear(), FirstHit(), and FromEyes().

◆ operator=()

Trace & VoltMod::Trace::operator= ( const Trace & )
delete

References Trace().


The documentation for this class was generated from the following files: