Make pTraceResult as pass arg
This commit is contained in:
parent
fde876b4e1
commit
fb519778e7
5 changed files with 140 additions and 293 deletions
|
|
@ -136,7 +136,6 @@ static_assert(
|
|||
|
||||
struct TraceOptions
|
||||
{
|
||||
uint64_t InteractsAs = 0;
|
||||
uint64_t InteractsWith = static_cast<uint64_t>(MASK_SHOT_PHYSICS);
|
||||
uint64_t InteractsExclude = 0;
|
||||
int DrawBeam = 0;
|
||||
|
|
@ -146,104 +145,25 @@ struct TraceResult
|
|||
{
|
||||
TraceResult()
|
||||
{
|
||||
m_flFraction = 1.0f;
|
||||
m_bStartInSolid = false;
|
||||
m_bExactHitPoint = false;
|
||||
m_pEnt = nullptr;
|
||||
m_pHitbox = nullptr;
|
||||
m_pSurfaceProperties = nullptr;
|
||||
HitEntity = nullptr;
|
||||
AllSolid = 0;
|
||||
Fraction = 1.0F;
|
||||
}
|
||||
|
||||
explicit TraceResult(const CGameTrace* pTrace, bool bResult)
|
||||
explicit TraceResult(const CGameTrace* pTrace)
|
||||
{
|
||||
m_bTraceShapeResult = bResult;
|
||||
m_pSurfaceProperties = pTrace->m_pSurfaceProperties;
|
||||
m_pEnt = pTrace->m_pEnt;
|
||||
m_pHitbox = pTrace->m_pHitbox;
|
||||
m_hBody = pTrace->m_hBody;
|
||||
m_hShape = pTrace->m_hShape;
|
||||
m_nContents = pTrace->m_nContents;
|
||||
m_BodyTransform = pTrace->m_BodyTransform;
|
||||
m_ShapeAttributes = pTrace->m_ShapeAttributes;
|
||||
m_vStartPos = pTrace->m_vStartPos;
|
||||
m_vEndPos = pTrace->m_vEndPos;
|
||||
m_vHitNormal = pTrace->m_vHitNormal;
|
||||
m_vHitPoint = pTrace->m_vHitPoint;
|
||||
m_flHitOffset = pTrace->m_flHitOffset;
|
||||
m_flFraction = pTrace->m_flFraction;
|
||||
m_nTriangle = pTrace->m_nTriangle;
|
||||
m_nHitboxBoneIndex = pTrace->m_nHitboxBoneIndex;
|
||||
m_eRayType = pTrace->m_eRayType;
|
||||
m_bStartInSolid = pTrace->m_bStartInSolid;
|
||||
m_bExactHitPoint = pTrace->m_bExactHitPoint;
|
||||
EndPos = pTrace->m_vEndPos;
|
||||
HitEntity = pTrace->m_pEnt;
|
||||
Fraction = pTrace->m_flFraction;
|
||||
AllSolid = pTrace->m_bStartInSolid;
|
||||
Normal = pTrace->m_vHitNormal;
|
||||
}
|
||||
|
||||
TraceResult(const TraceResult&) = delete;
|
||||
TraceResult& operator=(const TraceResult&) = delete;
|
||||
|
||||
TraceResult(TraceResult&&) = default;
|
||||
TraceResult& operator=(TraceResult&&) = default;
|
||||
|
||||
const Vector& StartPos() const { return m_vStartPos; }
|
||||
const Vector& EndPos() const { return m_vEndPos; }
|
||||
const Vector& HitPoint() const { return m_vHitPoint; }
|
||||
const Vector& Normal() const { return m_vHitNormal; }
|
||||
|
||||
float Fraction() const { return m_flFraction; }
|
||||
float HitOffset() const { return m_flHitOffset; }
|
||||
|
||||
bool DidHit() const { return m_flFraction < 1.0f; }
|
||||
bool IsAllSolid() const { return m_bStartInSolid; }
|
||||
bool HasExactHit() const { return m_bExactHitPoint; }
|
||||
|
||||
CEntityInstance* HitEntity() const { return m_pEnt; }
|
||||
|
||||
int TriangleIndex() const { return m_nTriangle; }
|
||||
int HitboxBoneIndex() const { return m_nHitboxBoneIndex; }
|
||||
|
||||
CHitBox* Hitbox() const { return const_cast<CHitBox*>(m_pHitbox); }
|
||||
|
||||
int Contents() const { return m_nContents; }
|
||||
RayType_t RayType() const { return m_eRayType; }
|
||||
|
||||
IPhysicsBody* Body() const { return m_hBody; }
|
||||
IPhysicsShape* Shape() const { return m_hShape; }
|
||||
|
||||
const CTransform& BodyTransform() const { return m_BodyTransform; }
|
||||
const RnCollisionAttr_t& ShapeAttributes() const { return m_ShapeAttributes; }
|
||||
|
||||
CPhysSurfaceProperties* Surface() const { return const_cast<CPhysSurfaceProperties*>(m_pSurfaceProperties); }
|
||||
|
||||
private:
|
||||
bool m_bTraceShapeResult; // return value from RayTrace::TraceShapeEx
|
||||
|
||||
const CPhysSurfaceProperties *m_pSurfaceProperties;
|
||||
CEntityInstance *m_pEnt;
|
||||
const CHitBox *m_pHitbox;
|
||||
|
||||
HPhysicsBody m_hBody;
|
||||
HPhysicsShape m_hShape;
|
||||
|
||||
uint64 m_nContents; // contents on other side of surface hit
|
||||
|
||||
CTransform m_BodyTransform;
|
||||
RnCollisionAttr_t m_ShapeAttributes;
|
||||
|
||||
Vector m_vStartPos; // start position
|
||||
Vector m_vEndPos; // final position
|
||||
Vector m_vHitNormal; // surface normal at impact
|
||||
Vector m_vHitPoint; // exact hit point if m_bExactHitPoint is true, otherwise equal to m_vEndPos
|
||||
|
||||
float m_flHitOffset; // surface normal hit offset
|
||||
float m_flFraction; // time completed, 1.0 = didn't hit anything
|
||||
|
||||
int32 m_nTriangle; // the index of the triangle that was hit
|
||||
int16 m_nHitboxBoneIndex; // the index of the hitbox bone that was hit
|
||||
|
||||
RayType_t m_eRayType;
|
||||
|
||||
bool m_bStartInSolid; // if true, the initial point was in a solid area
|
||||
bool m_bExactHitPoint; // if true, then m_vHitPoint is the exact hit point of the query and the shape
|
||||
Vector EndPos;
|
||||
CEntityInstance* HitEntity;
|
||||
float Fraction;
|
||||
int AllSolid;
|
||||
Vector Normal;
|
||||
};
|
||||
|
||||
class CRayTraceInterface
|
||||
|
|
@ -251,25 +171,29 @@ class CRayTraceInterface
|
|||
public:
|
||||
virtual ~CRayTraceInterface() = default;
|
||||
|
||||
virtual TraceResult TraceShape(const Vector& vecStart,
|
||||
virtual bool TraceShape(const Vector& vecStart,
|
||||
const QAngle& angAngles,
|
||||
CEntityInstance* pIgnoreEntity,
|
||||
TraceOptions* pTraceOptions) = 0;
|
||||
TraceOptions* pTraceOptions,
|
||||
TraceResult* pTraceResult) = 0;
|
||||
|
||||
virtual TraceResult TraceEndShape(const Vector& vecStart,
|
||||
virtual bool TraceEndShape(const Vector& vecStart,
|
||||
const Vector& vecEnd,
|
||||
CEntityInstance* pIgnoreEntity,
|
||||
TraceOptions* pTraceOptions) = 0;
|
||||
TraceOptions* pTraceOptions,
|
||||
TraceResult* pTraceResult) = 0;
|
||||
|
||||
virtual TraceResult TraceHullShape(const Vector& vecStart,
|
||||
virtual bool TraceHullShape(const Vector& vecStart,
|
||||
const Vector& vecEnd,
|
||||
const Vector& vecMins,
|
||||
const Vector& vecMaxs,
|
||||
CEntityInstance* pIgnoreEntity,
|
||||
TraceOptions* pTraceOptions) = 0;
|
||||
TraceOptions* pTraceOptions,
|
||||
TraceResult* pTraceResult) = 0;
|
||||
|
||||
virtual TraceResult TraceShapeEx(const Vector& vecStart,
|
||||
virtual bool TraceShapeEx(const Vector& vecStart,
|
||||
const Vector& vecEnd,
|
||||
CTraceFilter* pTraceFilter,
|
||||
Ray_t* pRay) = 0;
|
||||
Ray_t* pRay,
|
||||
TraceResult* pTraceResult) = 0;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue