Merge branch 'indev' of https://github.com/Mauler125/r5sdk into indev

This commit is contained in:
PixieCore 2022-07-08 20:31:33 +02:00
commit 6d916ae2c9
4 changed files with 74 additions and 39 deletions

View File

@ -3126,9 +3126,22 @@ inline float matrix3x4_t::GetSylvestersCriterion()const
// | / | /
// |/ |/
// 0---4 --> +x
//
void PointsFromBox(const Vector3D& mins, const Vector3D& maxs, Vector3D* points);
void BuildTransformedBox(Vector3D* v2, Vector3D const& bbmin, Vector3D const& bbmax, const matrix3x4_t& m);
// generate the corner points of a angled box:
// +y*r _+z*u
// ^ /|
// | /
// | 3---7
// /| /|
// / | / |
// 2---6 |
// | 1|--5
// | / | /
// |/ |/
// 0---4 --> +x*f
void PointsFromAngledBox(const QAngle& angles, const Vector3D& mins, const Vector3D& maxs, Vector3D* points);
void BuildTransformedAngledBox(Vector3D* v2, const QAngle& a, Vector3D const& bbmin, Vector3D const& bbmax, const matrix3x4_t& m);

View File

@ -5826,7 +5826,6 @@ const Quaternion RandomQuaternion(IUniformRandomStream* pRnd)
// | / | /
// |/ |/
// 0---4 --> +x
//
void PointsFromBox(const Vector3D& mins, const Vector3D& maxs, Vector3D* points)
{
points[0][0] = mins[0];
@ -5877,5 +5876,50 @@ void BuildTransformedBox(Vector3D* v2, Vector3D const& bbmin, Vector3D const& bb
VectorTransform(v[7], m, v2[7]);
}
// Generate the corner points of a angled box:
// +y*r _+z*u
// ^ /|
// | /
// | 3---7
// /| /|
// / | / |
// 2---6 |
// | 1|--5
// | / | /
// |/ |/
// 0---4 --> +x*f
void PointsFromAngledBox(const QAngle& angles, const Vector3D& mins, const Vector3D& maxs, Vector3D* points)
{
Vector3D forward;
Vector3D up;
Vector3D right;
AngleVectors(angles, &forward, &right, &up);
points[0] = (forward * mins.x) + (right * maxs.y) + (up * maxs.z);
points[1] = (forward * mins.x) + (right * mins.y) + (up * maxs.z);
points[2] = (forward * maxs.x) + (right * mins.y) + (up * maxs.z);
points[3] = (forward * maxs.x) + (right * maxs.y) + (up * maxs.z);
points[4] = (forward * mins.x) + (right * maxs.y) + (up * mins.z);
points[5] = (forward * mins.x) + (right * mins.y) + (up * mins.z);
points[6] = (forward * maxs.x) + (right * mins.y) + (up * mins.z);
points[7] = (forward * maxs.x) + (right * maxs.y) + (up * mins.z);
}
void BuildTransformedAngledBox(Vector3D* v2, const QAngle& a, Vector3D const& bbmin, Vector3D const& bbmax, const matrix3x4_t& m)
{
Vector3D v[8];
PointsFromAngledBox(a, bbmin, bbmax, v);
VectorTransform(v[0], m, v2[0]);
VectorTransform(v[1], m, v2[1]);
VectorTransform(v[2], m, v2[2]);
VectorTransform(v[3], m, v2[3]);
VectorTransform(v[4], m, v2[4]);
VectorTransform(v[5], m, v2[5]);
VectorTransform(v[6], m, v2[6]);
VectorTransform(v[7], m, v2[7]);
}
#endif // !defined(__SPU__)

View File

@ -13,45 +13,25 @@
#include "tier2/renderutils.h"
#include "engine/debugoverlay.h"
Vector3D* GetBoxCorners(Vector3D org, QAngle ang, Vector3D mins, Vector3D maxs)
void DrawAngledBox(const Vector3D& origin, const QAngle& angles, Vector3D mins, Vector3D maxs, int r, int g, int b, int a, bool throughSolid)
{
Vector3D forward;
Vector3D up;
Vector3D right;
AngleVectors(ang, &forward, &right, &up);
Vector3D orgs[8];
orgs[0] = org + (forward * mins.x) + (right * maxs.y) + (up * maxs.z);
orgs[1] = org + (forward * mins.x) + (right * mins.y) + (up * maxs.z);
orgs[2] = org + (forward * maxs.x) + (right * mins.y) + (up * maxs.z);
orgs[3] = org + (forward * maxs.x) + (right * maxs.y) + (up * maxs.z);
orgs[4] = org + (forward * mins.x) + (right * maxs.y) + (up * mins.z);
orgs[5] = org + (forward * mins.x) + (right * mins.y) + (up * mins.z);
orgs[6] = org + (forward * maxs.x) + (right * mins.y) + (up * mins.z);
orgs[7] = org + (forward * maxs.x) + (right * maxs.y) + (up * mins.z);
PointsFromAngledBox(angles, mins, maxs, &*orgs);
return orgs;
}
v_RenderLine(origin + orgs[0], origin + orgs[1], Color(r, g, b, a), throughSolid);
v_RenderLine(origin + orgs[1], origin + orgs[2], Color(r, g, b, a), throughSolid);
v_RenderLine(origin + orgs[2], origin + orgs[3], Color(r, g, b, a), throughSolid);
v_RenderLine(origin + orgs[3], origin + orgs[0], Color(r, g, b, a), throughSolid);
void DrawAngledBox(Vector3D org, QAngle ang, Vector3D mins, Vector3D maxs, int r, int g, int b, int a, bool throughSolid)
{
Vector3D* orgs = GetBoxCorners(org, ang, mins, maxs);
v_RenderLine(origin + orgs[4], origin + orgs[5], Color(r, g, b, a), throughSolid);
v_RenderLine(origin + orgs[5], origin + orgs[6], Color(r, g, b, a), throughSolid);
v_RenderLine(origin + orgs[6], origin + orgs[7], Color(r, g, b, a), throughSolid);
v_RenderLine(origin + orgs[7], origin + orgs[4], Color(r, g, b, a), throughSolid);
v_RenderLine(orgs[0], orgs[1], Color(r, g, b, a), throughSolid);
v_RenderLine(orgs[1], orgs[2], Color(r, g, b, a), throughSolid);
v_RenderLine(orgs[2], orgs[3], Color(r, g, b, a), throughSolid);
v_RenderLine(orgs[3], orgs[0], Color(r, g, b, a), throughSolid);
v_RenderLine(orgs[4], orgs[5], Color(r, g, b, a), throughSolid);
v_RenderLine(orgs[5], orgs[6], Color(r, g, b, a), throughSolid);
v_RenderLine(orgs[6], orgs[7], Color(r, g, b, a), throughSolid);
v_RenderLine(orgs[7], orgs[4], Color(r, g, b, a), throughSolid);
v_RenderLine(orgs[0], orgs[4], Color(r, g, b, a), throughSolid);
v_RenderLine(orgs[1], orgs[5], Color(r, g, b, a), throughSolid);
v_RenderLine(orgs[2], orgs[6], Color(r, g, b, a), throughSolid);
v_RenderLine(orgs[3], orgs[7], Color(r, g, b, a), throughSolid);
v_RenderLine(origin + orgs[0], origin + orgs[4], Color(r, g, b, a), throughSolid);
v_RenderLine(origin + orgs[1], origin + orgs[5], Color(r, g, b, a), throughSolid);
v_RenderLine(origin + orgs[2], origin + orgs[6], Color(r, g, b, a), throughSolid);
v_RenderLine(origin + orgs[3], origin + orgs[7], Color(r, g, b, a), throughSolid);
}
void RenderCapsule(const Vector3D& vStart, const Vector3D& vEnd, const float& flRadius, Color c)

View File

@ -2,9 +2,7 @@
#define RENDERUTILS_H
#include "mathlib/vector.h"
Vector3D* GetBoxCorners(Vector3D org, QAngle ang, Vector3D mins, Vector3D maxs);
void DrawAngledBox(Vector3D org, QAngle ang, Vector3D mins, Vector3D maxs, int r, int g, int b, int a, bool throughSolid);
void DrawAngledBox(const Vector3D& origin, const QAngle& angles, Vector3D mins, Vector3D maxs, int r, int g, int b, int a, bool throughSolid);
void RenderCapsule(const Vector3D& vStart, const Vector3D& vEnd, const float& flRadius, Color c);
#endif // RENDERUTILS_H