mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-20 21:00:52 +00:00
backup
alot more changes here added some matrix functions most of the point3 and point4 is now converted over to simd functions matrix now has a lot done by simd but transpose/normal/affine inverse/ inverse still to do
This commit is contained in:
parent
8908bbe462
commit
fb986e375d
5 changed files with 336 additions and 44 deletions
|
|
@ -52,22 +52,132 @@ extern ISA gISA;
|
|||
//------------------------------------------------------------------------------
|
||||
// Forward declare math_backend
|
||||
namespace math_backend {
|
||||
namespace float4 {
|
||||
namespace float3 {
|
||||
// Operators
|
||||
void add(const float* a, const float* b, float* r);
|
||||
void sub(const float* a, const float* b, float* r);
|
||||
void mul(const float* a, const float* b, float* r);
|
||||
void mul_scalar(const float* a, float s, float* r);
|
||||
void div(const float* a, const float* b, float* r);
|
||||
void div_scalar(const float* a, float s, float* r);
|
||||
float dot(const float* a, const float* b);
|
||||
void lerp(const float* from, const float* to, float f, float* r);
|
||||
|
||||
// Vector math
|
||||
float dot(const float* a, const float* b);
|
||||
|
||||
inline float lengthSquared(const float* a)
|
||||
{
|
||||
return dot(a, a);
|
||||
}
|
||||
|
||||
inline float length(const float* a)
|
||||
{
|
||||
return sqrt(lengthSquared(a));
|
||||
}
|
||||
|
||||
inline void normalize(float* a)
|
||||
{
|
||||
float len = length(a);
|
||||
mul_scalar(a, 1.0f / len, a);
|
||||
}
|
||||
|
||||
inline void normalizeSafe(float* a)
|
||||
{
|
||||
float len = length(a);
|
||||
if (len >= POINT_EPSILON)
|
||||
mul_scalar(a, 1.0f / len, a);
|
||||
}
|
||||
|
||||
inline void normalizeMag(float* a, float r)
|
||||
{
|
||||
float len = length(a);
|
||||
if (len >= POINT_EPSILON)
|
||||
mul_scalar(a, r / len, a);
|
||||
}
|
||||
|
||||
void lerp(const float* from, const float* to, float f, float* r);
|
||||
void addArray(const class Point4F* a, const class Point4F* b, class Point4F* r, size_t n);
|
||||
void subArray(const class Point4F* a, const class Point4F* b, class Point4F* r, size_t n);
|
||||
void mulArray(const class Point4F* a, const class Point4F* b, class Point4F* r, size_t n);
|
||||
void mulArrayScalar(const class Point4F* a, float s, class Point4F* r, size_t n);
|
||||
void lerpArray(const class Point4F* from, const class Point4F* to, float f, class Point4F* r, size_t n);
|
||||
}
|
||||
|
||||
namespace float4 {
|
||||
// Operators
|
||||
void add(const float* a, const float* b, float* r);
|
||||
void sub(const float* a, const float* b, float* r);
|
||||
void mul(const float* a, const float* b, float* r);
|
||||
void mul_scalar(const float* a, float s, float* r);
|
||||
void div(const float* a, const float* b, float* r);
|
||||
void div_scalar(const float* a, float s, float* r);
|
||||
|
||||
// Vector math
|
||||
float dot(const float* a, const float* b);
|
||||
|
||||
inline float lengthSquared(const float* a)
|
||||
{
|
||||
return dot(a, a);
|
||||
}
|
||||
|
||||
inline float length(const float* a)
|
||||
{
|
||||
return sqrt(lengthSquared(a));
|
||||
}
|
||||
|
||||
inline void normalize(float* a)
|
||||
{
|
||||
float len = length(a);
|
||||
mul_scalar(a, 1.0f / len, a);
|
||||
}
|
||||
|
||||
inline void normalizeSafe(float* a)
|
||||
{
|
||||
float len = length(a);
|
||||
if(len >= POINT_EPSILON)
|
||||
mul_scalar(a, 1.0f / len, a);
|
||||
}
|
||||
|
||||
inline void normalizeMag(float* a, float r)
|
||||
{
|
||||
float len = length(a);
|
||||
if (len >= POINT_EPSILON)
|
||||
mul_scalar(a, r / len, a);
|
||||
}
|
||||
|
||||
void lerp(const float* from, const float* to, float f, float* r);
|
||||
void addArray(const class Point4F* a, const class Point4F* b, class Point4F* r, size_t n);
|
||||
void subArray(const class Point4F* a, const class Point4F* b, class Point4F* r, size_t n);
|
||||
void mulArray(const class Point4F* a, const class Point4F* b, class Point4F* r, size_t n);
|
||||
void mulArrayScalar(const class Point4F* a, float s, class Point4F* r, size_t n);
|
||||
void lerpArray(const class Point4F* from, const class Point4F* to, float f, class Point4F* r, size_t n);
|
||||
}
|
||||
|
||||
namespace float_mat4x4 {
|
||||
void multiply_mat4(const float* A, const float* B, float* R);
|
||||
void multiply_float4(const float* m, const float* p, float* R);
|
||||
inline void multiply_float3(const float* m, const float* p, float* R)
|
||||
{
|
||||
float va[4] = { p[0], p[1], p[2], 1.0f };
|
||||
float vr[4];
|
||||
multiply_float4(m, va, vr);
|
||||
R[0] = vr[0];
|
||||
R[1] = vr[1];
|
||||
R[2] = vr[2];
|
||||
}
|
||||
|
||||
inline void multiply_vector(const float* m, const float* v, float* R)
|
||||
{
|
||||
// vector, w = 0
|
||||
float va[4] = { v[0], v[1], v[2], 0.0f };
|
||||
float vr[4];
|
||||
multiply_float4(m, va, vr);
|
||||
R[0] = vr[0];
|
||||
R[1] = vr[1];
|
||||
R[2] = vr[2];
|
||||
}
|
||||
|
||||
void scale(float* M, const float* S);
|
||||
}
|
||||
} // namespace math_backend
|
||||
|
||||
//--------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue