Update: try fix windows padding
This commit is contained in:
parent
d53a21fd63
commit
801bdbe06f
3 changed files with 36 additions and 25 deletions
|
|
@ -144,11 +144,15 @@ struct TraceOptions
|
||||||
|
|
||||||
struct TraceResult
|
struct TraceResult
|
||||||
{
|
{
|
||||||
Vector EndPos;
|
float EndPosX;
|
||||||
|
float EndPosY;
|
||||||
|
float EndPosZ;
|
||||||
CEntityInstance* HitEntity;
|
CEntityInstance* HitEntity;
|
||||||
float Fraction;
|
float Fraction;
|
||||||
int AllSolid;
|
int AllSolid;
|
||||||
Vector Normal;
|
float NormalX;
|
||||||
|
float NormalY;
|
||||||
|
float NormalZ;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CRayTraceInterface
|
class CRayTraceInterface
|
||||||
|
|
|
||||||
|
|
@ -87,24 +87,24 @@ namespace RayTrace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Explicit, Size = 44)]
|
[StructLayout(LayoutKind.Explicit, Size = 48)]
|
||||||
public struct TraceResult
|
public struct TraceResult
|
||||||
{
|
{
|
||||||
[FieldOffset(0)] public float EndPosX;
|
[FieldOffset(0)] public float EndPosX;
|
||||||
[FieldOffset(4)] public float EndPosY;
|
[FieldOffset(4)] public float EndPosY;
|
||||||
[FieldOffset(8)] public float EndPosZ;
|
[FieldOffset(8)] public float EndPosZ;
|
||||||
[FieldOffset(16)] public nint HitEntity;
|
[FieldOffset(16)] public nint HitEntity;
|
||||||
[FieldOffset(24)] public float Fraction;
|
[FieldOffset(24)] public float Fraction;
|
||||||
[FieldOffset(28)] public int AllSolid;
|
[FieldOffset(28)] public int AllSolid;
|
||||||
[FieldOffset(32)] public float NormalX;
|
[FieldOffset(32)] public float NormalX;
|
||||||
[FieldOffset(36)] public float NormalY;
|
[FieldOffset(36)] public float NormalY;
|
||||||
[FieldOffset(40)] public float NormalZ;
|
[FieldOffset(40)] public float NormalZ;
|
||||||
|
|
||||||
public Vector3 EndPos => new(EndPosX, EndPosY, EndPosZ);
|
public Vector3 EndPos => new(EndPosX, EndPosY, EndPosZ);
|
||||||
public Vector3 Normal => new(NormalX, NormalY, NormalZ);
|
public Vector3 Normal => new(NormalX, NormalY, NormalZ);
|
||||||
public bool DidHit => Fraction < 1.0f;
|
public bool DidHit => Fraction < 1.0f;
|
||||||
public bool IsAllSolid => AllSolid != 0;
|
public bool IsAllSolid => AllSolid != 0;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public static class CRayTrace
|
public static class CRayTrace
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,10 @@ namespace RayTracePlugin::RayTrace
|
||||||
CTraceFilter& filterInc,
|
CTraceFilter& filterInc,
|
||||||
Ray_t rayInc)
|
Ray_t rayInc)
|
||||||
{
|
{
|
||||||
if (!s_TraceShape) return std::nullopt;
|
if (!s_TraceShape) {
|
||||||
|
FP_ERROR("CNavPhysicsInterface::TraceShape is not bound!");
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
CGameTrace tr{};
|
CGameTrace tr{};
|
||||||
Vector startCopy = start;
|
Vector startCopy = start;
|
||||||
|
|
@ -70,11 +73,15 @@ namespace RayTracePlugin::RayTrace
|
||||||
&filterInc, &tr);
|
&filterInc, &tr);
|
||||||
|
|
||||||
TraceResult r{};
|
TraceResult r{};
|
||||||
r.EndPos = tr.m_vEndPos;
|
r.EndPosX = tr.m_vEndPos.x;
|
||||||
|
r.EndPosY = tr.m_vEndPos.y;
|
||||||
|
r.EndPosZ = tr.m_vEndPos.z;
|
||||||
r.HitEntity = tr.m_pEnt;
|
r.HitEntity = tr.m_pEnt;
|
||||||
r.Fraction = tr.m_flFraction;
|
r.Fraction = tr.m_flFraction;
|
||||||
r.AllSolid = tr.m_bStartInSolid;
|
r.AllSolid = tr.m_bStartInSolid;
|
||||||
r.Normal = tr.m_vHitNormal;
|
r.NormalX = tr.m_vHitNormal.x;
|
||||||
|
r.NormalY = tr.m_vHitNormal.y;
|
||||||
|
r.NormalZ = tr.m_vHitNormal.z;
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
@ -117,7 +124,7 @@ namespace RayTracePlugin::RayTrace
|
||||||
if (opts && opts->DrawBeam)
|
if (opts && opts->DrawBeam)
|
||||||
{
|
{
|
||||||
Color col = res.has_value() ? colors::Red().ToValveColor() : colors::Green().ToValveColor();
|
Color col = res.has_value() ? colors::Red().ToValveColor() : colors::Green().ToValveColor();
|
||||||
DrawBeam(origin, res ? res->EndPos : endOrigin, col);
|
DrawBeam(origin, res ? Vector(res->EndPosX, res->EndPosY, res->EndPosZ) : endOrigin, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
@ -153,7 +160,7 @@ namespace RayTracePlugin::RayTrace
|
||||||
if (opts && opts->DrawBeam)
|
if (opts && opts->DrawBeam)
|
||||||
{
|
{
|
||||||
Color col = res.has_value() ? colors::Red().ToValveColor() : colors::Green().ToValveColor();
|
Color col = res.has_value() ? colors::Red().ToValveColor() : colors::Green().ToValveColor();
|
||||||
DrawBeam(origin, res ? res->EndPos : endOrigin, col);
|
DrawBeam(origin, res ? Vector(res->EndPosX, res->EndPosY, res->EndPosZ) : endOrigin, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
@ -186,7 +193,7 @@ namespace RayTracePlugin::RayTrace
|
||||||
if (opts && opts->DrawBeam)
|
if (opts && opts->DrawBeam)
|
||||||
{
|
{
|
||||||
Color col = res.has_value() ? colors::Red().ToValveColor() : colors::Green().ToValveColor();
|
Color col = res.has_value() ? colors::Red().ToValveColor() : colors::Green().ToValveColor();
|
||||||
DrawBeam(vecStart, res ? res->EndPos : vecEnd, col);
|
DrawBeam(vecStart, res ? Vector(res->EndPosX, res->EndPosY, res->EndPosZ) : vecEnd, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue