mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Move GetBoxCorners to mathlib
Renamed to 'PointsFromAngledBox' (no longer adds origin by default).
This commit is contained in:
parent
75abedc711
commit
bbf7896218
@ -3126,9 +3126,22 @@ inline float matrix3x4_t::GetSylvestersCriterion()const
|
|||||||
// | / | /
|
// | / | /
|
||||||
// |/ |/
|
// |/ |/
|
||||||
// 0---4 --> +x
|
// 0---4 --> +x
|
||||||
//
|
|
||||||
void PointsFromBox(const Vector3D& mins, const Vector3D& maxs, Vector3D* points);
|
void PointsFromBox(const Vector3D& mins, const Vector3D& maxs, Vector3D* points);
|
||||||
void BuildTransformedBox(Vector3D* v2, Vector3D const& bbmin, Vector3D const& bbmax, const matrix3x4_t& m);
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -5826,7 +5826,6 @@ const Quaternion RandomQuaternion(IUniformRandomStream* pRnd)
|
|||||||
// | / | /
|
// | / | /
|
||||||
// |/ |/
|
// |/ |/
|
||||||
// 0---4 --> +x
|
// 0---4 --> +x
|
||||||
//
|
|
||||||
void PointsFromBox(const Vector3D& mins, const Vector3D& maxs, Vector3D* points)
|
void PointsFromBox(const Vector3D& mins, const Vector3D& maxs, Vector3D* points)
|
||||||
{
|
{
|
||||||
points[0][0] = mins[0];
|
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]);
|
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__)
|
#endif // !defined(__SPU__)
|
||||||
|
@ -13,45 +13,25 @@
|
|||||||
#include "tier2/renderutils.h"
|
#include "tier2/renderutils.h"
|
||||||
#include "engine/debugoverlay.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];
|
Vector3D orgs[8];
|
||||||
orgs[0] = org + (forward * mins.x) + (right * maxs.y) + (up * maxs.z);
|
PointsFromAngledBox(angles, mins, maxs, &*orgs);
|
||||||
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);
|
|
||||||
|
|
||||||
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)
|
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);
|
||||||
Vector3D* orgs = GetBoxCorners(org, ang, mins, maxs);
|
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(origin + orgs[0], origin + orgs[4], Color(r, g, b, a), throughSolid);
|
||||||
v_RenderLine(orgs[1], orgs[2], Color(r, g, b, a), throughSolid);
|
v_RenderLine(origin + orgs[1], origin + orgs[5], Color(r, g, b, a), throughSolid);
|
||||||
v_RenderLine(orgs[2], orgs[3], Color(r, g, b, a), throughSolid);
|
v_RenderLine(origin + orgs[2], origin + orgs[6], Color(r, g, b, a), throughSolid);
|
||||||
v_RenderLine(orgs[3], orgs[0], Color(r, g, b, a), throughSolid);
|
v_RenderLine(origin + orgs[3], origin + orgs[7], 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderCapsule(const Vector3D& vStart, const Vector3D& vEnd, const float& flRadius, Color c)
|
void RenderCapsule(const Vector3D& vStart, const Vector3D& vEnd, const float& flRadius, Color c)
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#define RENDERUTILS_H
|
#define RENDERUTILS_H
|
||||||
#include "mathlib/vector.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(Vector3D org, QAngle ang, 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);
|
void RenderCapsule(const Vector3D& vStart, const Vector3D& vEnd, const float& flRadius, Color c);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user