Add array sizes to math functions

This commit is contained in:
2025-04-29 18:17:00 +03:00
parent 1b6c858a1b
commit 7ee69fc397
17 changed files with 810 additions and 810 deletions

View File

@@ -2,89 +2,89 @@
#include <math.h>
void BH_Vec2fAdd(const float *a,
const float *b,
float *out)
void BH_Vec2fAdd(const float a[2],
const float b[2],
float out[2])
{
out[0] = a[0] + b[0];
out[1] = a[1] + b[1];
}
void BH_Vec2fSub(const float *a,
const float *b,
float *out)
void BH_Vec2fSub(const float a[2],
const float b[2],
float out[2])
{
out[0] = a[0] - b[0];
out[1] = a[1] - b[1];
}
void BH_Vec2fMul(const float *a,
const float *b,
float *out)
void BH_Vec2fMul(const float a[2],
const float b[2],
float out[2])
{
out[0] = a[0] * b[0];
out[1] = a[1] * b[1];
}
void BH_Vec2fScale(const float *a,
const float b,
float *out)
void BH_Vec2fScale(const float a[2],
float b,
float out[2])
{
out[0] = a[0] * b;
out[1] = a[1] * b;
}
void BH_Vec2fMulAdd(const float *a,
const float *b,
const float *c,
float *out)
void BH_Vec2fMulAdd(const float a[2],
const float b[2],
const float c[2],
float out[2])
{
out[0] = a[0] * b[0] + c[0];
out[1] = a[1] * b[1] + c[1];
}
void BH_Vec2fNegate(const float *in,
float *out)
void BH_Vec2fNegate(const float in[2],
float out[2])
{
out[0] = -in[0];
out[1] = -in[1];
}
float BH_Vec2fDot(const float *a,
const float *b)
float BH_Vec2fDot(const float a[2],
const float b[2])
{
return a[0] * b[0] + a[1] * b[1];
}
float BH_Vec2fCross(const float *a,
const float *b)
float BH_Vec2fCross(const float a[2],
const float b[2])
{
return a[0] * b[1] - a[1] * b[0];
}
float BH_Vec2fLength(const float *in)
float BH_Vec2fLength(const float in[2])
{
return sqrtf(BH_Vec2fDot(in, in));
}
void BH_Vec2fNormal(const float *in,
float *out)
void BH_Vec2fNormal(const float in[2],
float out[2])
{
BH_Vec2fScale(in, 1.0f / BH_Vec2fLength(in), out);
}
float BH_Vec2fNormalEx(const float *in,
float *out)
float BH_Vec2fNormalEx(const float in[2],
float out[2])
{
float length;
@@ -94,28 +94,28 @@ float BH_Vec2fNormalEx(const float *in,
}
void BH_Vec2fMin(const float *a,
const float *b,
float *out)
void BH_Vec2fMin(const float a[2],
const float b[2],
float out[2])
{
if (a[0] < b[0]) out[0] = a[0]; else out[0] = b[0];
if (a[1] < b[1]) out[1] = a[1]; else out[1] = b[1];
}
void BH_Vec2fMax(const float *a,
const float *b,
float *out)
void BH_Vec2fMax(const float a[2],
const float b[2],
float out[2])
{
if (a[0] > b[0]) out[0] = a[0]; else out[0] = b[0];
if (a[1] > b[1]) out[1] = a[1]; else out[1] = b[1];
}
void BH_Vec2fLerp(const float *a,
const float *b,
void BH_Vec2fLerp(const float a[2],
const float b[2],
float t,
float *out)
float out[2])
{
float tmp[2];
@@ -125,9 +125,9 @@ void BH_Vec2fLerp(const float *a,
}
void BH_Vec2fProject(const float *a,
const float *b,
float *out)
void BH_Vec2fProject(const float a[2],
const float b[2],
float out[2])
{
float amount;
@@ -136,12 +136,12 @@ void BH_Vec2fProject(const float *a,
}
void BH_Vec2fBarycentric(const float *a,
const float *b,
const float *c,
void BH_Vec2fBarycentric(const float a[2],
const float b[2],
const float c[2],
float v,
float w,
float *out)
float out[2])
{
float tmp1[2], tmp2[2];
float u;