Add array sizes to math functions
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -6,24 +6,24 @@
|
|||||||
#define PI 3.14159265358979323846f
|
#define PI 3.14159265358979323846f
|
||||||
|
|
||||||
|
|
||||||
void BH_Box2fUnion(const float *aMin,
|
void BH_Box2fUnion(const float aMin[2],
|
||||||
const float *aMax,
|
const float aMax[2],
|
||||||
const float *bMin,
|
const float bMin[2],
|
||||||
const float *bMax,
|
const float bMax[2],
|
||||||
float *outMin,
|
float outMin[2],
|
||||||
float *outMax)
|
float outMax[2])
|
||||||
{
|
{
|
||||||
BH_Vec2fMin(aMin, bMin, outMin);
|
BH_Vec2fMin(aMin, bMin, outMin);
|
||||||
BH_Vec2fMax(aMax, bMax, outMax);
|
BH_Vec2fMax(aMax, bMax, outMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BH_Box2fIntersect(const float *aMin,
|
int BH_Box2fIntersect(const float aMin[2],
|
||||||
const float *aMax,
|
const float aMax[2],
|
||||||
const float *bMin,
|
const float bMin[2],
|
||||||
const float *bMax,
|
const float bMax[2],
|
||||||
float *outMin,
|
float outMin[2],
|
||||||
float *outMax)
|
float outMax[2])
|
||||||
{
|
{
|
||||||
BH_Vec2fMax(aMin, bMin, outMin);
|
BH_Vec2fMax(aMin, bMin, outMin);
|
||||||
BH_Vec2fMin(aMax, bMax, outMax);
|
BH_Vec2fMin(aMax, bMax, outMax);
|
||||||
@@ -35,9 +35,9 @@ int BH_Box2fIntersect(const float *aMin,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BH_Box2fContains(const float *aMin,
|
int BH_Box2fContains(const float aMin[2],
|
||||||
const float *aMax,
|
const float aMax[2],
|
||||||
const float *point)
|
const float point[2])
|
||||||
{
|
{
|
||||||
if (point[0] < aMin[0] || point[1] < aMin[1])
|
if (point[0] < aMin[0] || point[1] < aMin[1])
|
||||||
return BH_ERROR;
|
return BH_ERROR;
|
||||||
@@ -51,8 +51,8 @@ int BH_Box2fContains(const float *aMin,
|
|||||||
|
|
||||||
int BH_Box2fEnclose(const float *points,
|
int BH_Box2fEnclose(const float *points,
|
||||||
size_t size,
|
size_t size,
|
||||||
float *outMin,
|
float outMin[2],
|
||||||
float *outMax)
|
float outMax[2])
|
||||||
{
|
{
|
||||||
float tmp1[2], tmp2[2];
|
float tmp1[2], tmp2[2];
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|||||||
@@ -6,24 +6,24 @@
|
|||||||
#define PI 3.14159265358979323846f
|
#define PI 3.14159265358979323846f
|
||||||
|
|
||||||
|
|
||||||
void BH_Box3fUnion(const float *aMin,
|
void BH_Box3fUnion(const float aMin[3],
|
||||||
const float *aMax,
|
const float aMax[3],
|
||||||
const float *bMin,
|
const float bMin[3],
|
||||||
const float *bMax,
|
const float bMax[3],
|
||||||
float *outMin,
|
float outMin[3],
|
||||||
float *outMax)
|
float outMax[3])
|
||||||
{
|
{
|
||||||
BH_Vec3fMin(aMin, bMin, outMin);
|
BH_Vec3fMin(aMin, bMin, outMin);
|
||||||
BH_Vec3fMax(aMax, bMax, outMax);
|
BH_Vec3fMax(aMax, bMax, outMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BH_Box3fIntersect(const float *aMin,
|
int BH_Box3fIntersect(const float aMin[3],
|
||||||
const float *aMax,
|
const float aMax[3],
|
||||||
const float *bMin,
|
const float bMin[3],
|
||||||
const float *bMax,
|
const float bMax[3],
|
||||||
float *outMin,
|
float outMin[3],
|
||||||
float *outMax)
|
float outMax[3])
|
||||||
{
|
{
|
||||||
BH_Vec3fMax(aMin, bMin, outMin);
|
BH_Vec3fMax(aMin, bMin, outMin);
|
||||||
BH_Vec3fMin(aMax, bMax, outMax);
|
BH_Vec3fMin(aMax, bMax, outMax);
|
||||||
@@ -35,9 +35,9 @@ int BH_Box3fIntersect(const float *aMin,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BH_Box3fContains(const float *aMin,
|
int BH_Box3fContains(const float aMin[3],
|
||||||
const float *aMax,
|
const float aMax[3],
|
||||||
const float *point)
|
const float point[3])
|
||||||
{
|
{
|
||||||
if (point[0] < aMin[0] || point[1] < aMin[1] || point[2] < aMin[2])
|
if (point[0] < aMin[0] || point[1] < aMin[1] || point[2] < aMin[2])
|
||||||
return BH_ERROR;
|
return BH_ERROR;
|
||||||
@@ -51,8 +51,8 @@ int BH_Box3fContains(const float *aMin,
|
|||||||
|
|
||||||
int BH_Box3fEnclose(const float *points,
|
int BH_Box3fEnclose(const float *points,
|
||||||
size_t size,
|
size_t size,
|
||||||
float *outMin,
|
float outMin[3],
|
||||||
float *outMax)
|
float outMax[3])
|
||||||
{
|
{
|
||||||
float tmp1[3], tmp2[3];
|
float tmp1[3], tmp2[3];
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
#define PI 3.14159265358979323846f
|
#define PI 3.14159265358979323846f
|
||||||
|
|
||||||
|
|
||||||
int BH_LineFromPoints(const float *a,
|
int BH_LineFromPoints(const float a[2],
|
||||||
const float *b,
|
const float b[2],
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
float tmp[2];
|
float tmp[2];
|
||||||
|
|
||||||
@@ -23,16 +23,16 @@ int BH_LineFromPoints(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float BH_LineDistance(const float *line,
|
float BH_LineDistance(const float line[3],
|
||||||
const float *point)
|
const float point[2])
|
||||||
{
|
{
|
||||||
return BH_Vec2fDot(line, point) - line[2];
|
return BH_Vec2fDot(line, point) - line[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_LineClosestPoint(const float *line,
|
void BH_LineClosestPoint(const float line[3],
|
||||||
const float *point,
|
const float point[2],
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
float tmp[2];
|
float tmp[2];
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#define PI 3.14159265358979323846f
|
#define PI 3.14159265358979323846f
|
||||||
|
|
||||||
|
|
||||||
void BH_Mat3fIdentity(float *out)
|
void BH_Mat3fIdentity(float out[9])
|
||||||
{
|
{
|
||||||
static const float ident[9] =
|
static const float ident[9] =
|
||||||
{
|
{
|
||||||
@@ -20,9 +20,9 @@ void BH_Mat3fIdentity(float *out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Mat3fAdd(const float *a,
|
void BH_Mat3fAdd(const float a[9],
|
||||||
const float *b,
|
const float b[9],
|
||||||
float *out)
|
float out[9])
|
||||||
{
|
{
|
||||||
BH_Vec3fAdd(&a[0], &b[0], &out[0]);
|
BH_Vec3fAdd(&a[0], &b[0], &out[0]);
|
||||||
BH_Vec3fAdd(&a[3], &b[3], &out[3]);
|
BH_Vec3fAdd(&a[3], &b[3], &out[3]);
|
||||||
@@ -30,9 +30,9 @@ void BH_Mat3fAdd(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Mat3fSub(const float *a,
|
void BH_Mat3fSub(const float a[9],
|
||||||
const float *b,
|
const float b[9],
|
||||||
float *out)
|
float out[9])
|
||||||
{
|
{
|
||||||
BH_Vec3fSub(&a[0], &b[0], &out[0]);
|
BH_Vec3fSub(&a[0], &b[0], &out[0]);
|
||||||
BH_Vec3fSub(&a[3], &b[3], &out[3]);
|
BH_Vec3fSub(&a[3], &b[3], &out[3]);
|
||||||
@@ -40,9 +40,9 @@ void BH_Mat3fSub(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Mat3fMul(const float *a,
|
void BH_Mat3fMul(const float a[9],
|
||||||
const float *b,
|
const float b[9],
|
||||||
float *out)
|
float out[9])
|
||||||
{
|
{
|
||||||
float tmp[9], row[3];
|
float tmp[9], row[3];
|
||||||
|
|
||||||
@@ -62,9 +62,9 @@ void BH_Mat3fMul(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Mat3fScale(const float *a,
|
void BH_Mat3fScale(const float a[9],
|
||||||
float b,
|
float b,
|
||||||
float *out)
|
float out[9])
|
||||||
{
|
{
|
||||||
BH_Vec3fScale(&a[0], b, &out[0]);
|
BH_Vec3fScale(&a[0], b, &out[0]);
|
||||||
BH_Vec3fScale(&a[3], b, &out[3]);
|
BH_Vec3fScale(&a[3], b, &out[3]);
|
||||||
@@ -72,8 +72,8 @@ void BH_Mat3fScale(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Mat3fTranspose(const float *in,
|
void BH_Mat3fTranspose(const float in[9],
|
||||||
float *out)
|
float out[9])
|
||||||
{
|
{
|
||||||
float tmp[9];
|
float tmp[9];
|
||||||
|
|
||||||
@@ -85,13 +85,13 @@ void BH_Mat3fTranspose(const float *in,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float BH_Mat3fTrace(const float *in)
|
float BH_Mat3fTrace(const float in[9])
|
||||||
{
|
{
|
||||||
return in[0] + in[4] + in[8];
|
return in[0] + in[4] + in[8];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float BH_Mat3fDet(const float *in)
|
float BH_Mat3fDet(const float in[9])
|
||||||
{
|
{
|
||||||
float a, b, c, result;
|
float a, b, c, result;
|
||||||
|
|
||||||
@@ -108,8 +108,8 @@ float BH_Mat3fDet(const float *in)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BH_Mat3fInverse(const float *in,
|
int BH_Mat3fInverse(const float in[9],
|
||||||
float *out)
|
float out[9])
|
||||||
{
|
{
|
||||||
float a, b, c, det;
|
float a, b, c, det;
|
||||||
float tmp[16];
|
float tmp[16];
|
||||||
@@ -153,7 +153,7 @@ int BH_Mat3fInverse(const float *in,
|
|||||||
|
|
||||||
void BH_Mat3fFromScale(float x,
|
void BH_Mat3fFromScale(float x,
|
||||||
float y,
|
float y,
|
||||||
float *out)
|
float out[9])
|
||||||
{
|
{
|
||||||
BH_Mat3fIdentity(out);
|
BH_Mat3fIdentity(out);
|
||||||
out[0] = x;
|
out[0] = x;
|
||||||
@@ -163,7 +163,7 @@ void BH_Mat3fFromScale(float x,
|
|||||||
|
|
||||||
void BH_Mat3fFromTranslation(float x,
|
void BH_Mat3fFromTranslation(float x,
|
||||||
float y,
|
float y,
|
||||||
float *out)
|
float out[9])
|
||||||
{
|
{
|
||||||
BH_Mat3fIdentity(out);
|
BH_Mat3fIdentity(out);
|
||||||
out[6] = x;
|
out[6] = x;
|
||||||
@@ -172,7 +172,7 @@ void BH_Mat3fFromTranslation(float x,
|
|||||||
|
|
||||||
|
|
||||||
void BH_Mat3fFromRotation(float angle,
|
void BH_Mat3fFromRotation(float angle,
|
||||||
float *out)
|
float out[9])
|
||||||
{
|
{
|
||||||
float c, s;
|
float c, s;
|
||||||
|
|
||||||
@@ -187,9 +187,9 @@ void BH_Mat3fFromRotation(float angle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Mat3fApplyVec3f(float *a,
|
void BH_Mat3fApplyVec3f(float a[9],
|
||||||
float *b,
|
float b[3],
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
float tmp[3], row[3];
|
float tmp[3], row[3];
|
||||||
|
|
||||||
@@ -201,9 +201,9 @@ void BH_Mat3fApplyVec3f(float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Mat3fApplyVec2f(float *a,
|
void BH_Mat3fApplyVec2f(float a[9],
|
||||||
float *b,
|
float b[2],
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
float tmp[3], row[3];
|
float tmp[3], row[3];
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#define PI 3.14159265358979323846f
|
#define PI 3.14159265358979323846f
|
||||||
|
|
||||||
|
|
||||||
void BH_Mat4fIdentity(float *out)
|
void BH_Mat4fIdentity(float out[16])
|
||||||
{
|
{
|
||||||
const float ident[16] =
|
const float ident[16] =
|
||||||
{
|
{
|
||||||
@@ -21,9 +21,9 @@ void BH_Mat4fIdentity(float *out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Mat4fAdd(const float *a,
|
void BH_Mat4fAdd(const float a[16],
|
||||||
const float *b,
|
const float b[16],
|
||||||
float *out)
|
float out[16])
|
||||||
{
|
{
|
||||||
BH_Vec4fAdd(&a[0], &b[0], &out[0]);
|
BH_Vec4fAdd(&a[0], &b[0], &out[0]);
|
||||||
BH_Vec4fAdd(&a[4], &b[4], &out[4]);
|
BH_Vec4fAdd(&a[4], &b[4], &out[4]);
|
||||||
@@ -32,9 +32,9 @@ void BH_Mat4fAdd(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Mat4fSub(const float *a,
|
void BH_Mat4fSub(const float a[16],
|
||||||
const float *b,
|
const float b[16],
|
||||||
float *out)
|
float out[16])
|
||||||
{
|
{
|
||||||
BH_Vec4fSub(&a[0], &b[0], &out[0]);
|
BH_Vec4fSub(&a[0], &b[0], &out[0]);
|
||||||
BH_Vec4fSub(&a[4], &b[4], &out[4]);
|
BH_Vec4fSub(&a[4], &b[4], &out[4]);
|
||||||
@@ -43,9 +43,9 @@ void BH_Mat4fSub(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Mat4fMul(const float *a,
|
void BH_Mat4fMul(const float a[16],
|
||||||
const float *b,
|
const float b[16],
|
||||||
float *out)
|
float out[16])
|
||||||
{
|
{
|
||||||
float tmp[16], row[4];
|
float tmp[16], row[4];
|
||||||
|
|
||||||
@@ -73,9 +73,9 @@ void BH_Mat4fMul(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Mat4fScale(const float *a,
|
void BH_Mat4fScale(const float a[16],
|
||||||
float b,
|
float b,
|
||||||
float *out)
|
float out[16])
|
||||||
{
|
{
|
||||||
BH_Vec4fScale(&a[0], b, &out[0]);
|
BH_Vec4fScale(&a[0], b, &out[0]);
|
||||||
BH_Vec4fScale(&a[4], b, &out[4]);
|
BH_Vec4fScale(&a[4], b, &out[4]);
|
||||||
@@ -84,8 +84,8 @@ void BH_Mat4fScale(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Mat4fTranspose(const float *in,
|
void BH_Mat4fTranspose(const float in[16],
|
||||||
float *out)
|
float out[16])
|
||||||
{
|
{
|
||||||
float tmp[16];
|
float tmp[16];
|
||||||
|
|
||||||
@@ -98,13 +98,13 @@ void BH_Mat4fTranspose(const float *in,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float BH_Mat4fTrace(const float *in)
|
float BH_Mat4fTrace(const float in[16])
|
||||||
{
|
{
|
||||||
return in[0] + in[5] + in[10] + in[15];
|
return in[0] + in[5] + in[10] + in[15];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float BH_Mat4fDet(const float *in)
|
float BH_Mat4fDet(const float in[16])
|
||||||
{
|
{
|
||||||
float a, b, c, d, e, f, result;
|
float a, b, c, d, e, f, result;
|
||||||
|
|
||||||
@@ -125,8 +125,8 @@ float BH_Mat4fDet(const float *in)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BH_Mat4fInverse(const float *in,
|
int BH_Mat4fInverse(const float in[16],
|
||||||
float *out)
|
float out[16])
|
||||||
{
|
{
|
||||||
float a, b, c, d, e, f, det;
|
float a, b, c, d, e, f, det;
|
||||||
float tmp[16];
|
float tmp[16];
|
||||||
@@ -189,7 +189,7 @@ int BH_Mat4fInverse(const float *in,
|
|||||||
void BH_Mat4fFromScale(float x,
|
void BH_Mat4fFromScale(float x,
|
||||||
float y,
|
float y,
|
||||||
float z,
|
float z,
|
||||||
float *out)
|
float out[16])
|
||||||
{
|
{
|
||||||
BH_Mat4fIdentity(out);
|
BH_Mat4fIdentity(out);
|
||||||
out[0] = x;
|
out[0] = x;
|
||||||
@@ -201,7 +201,7 @@ void BH_Mat4fFromScale(float x,
|
|||||||
void BH_Mat4fFromTranslation(float x,
|
void BH_Mat4fFromTranslation(float x,
|
||||||
float y,
|
float y,
|
||||||
float z,
|
float z,
|
||||||
float *out)
|
float out[16])
|
||||||
{
|
{
|
||||||
BH_Mat4fIdentity(out);
|
BH_Mat4fIdentity(out);
|
||||||
out[12] = x;
|
out[12] = x;
|
||||||
@@ -211,7 +211,7 @@ void BH_Mat4fFromTranslation(float x,
|
|||||||
|
|
||||||
|
|
||||||
void BH_Mat4fFromRotationX(float angle,
|
void BH_Mat4fFromRotationX(float angle,
|
||||||
float *out)
|
float out[16])
|
||||||
{
|
{
|
||||||
float c, s;
|
float c, s;
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ void BH_Mat4fFromRotationX(float angle,
|
|||||||
|
|
||||||
|
|
||||||
void BH_Mat4fFromRotationY(float angle,
|
void BH_Mat4fFromRotationY(float angle,
|
||||||
float *out)
|
float out[16])
|
||||||
{
|
{
|
||||||
float c, s;
|
float c, s;
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ void BH_Mat4fFromRotationY(float angle,
|
|||||||
|
|
||||||
|
|
||||||
void BH_Mat4fFromRotationZ(float angle,
|
void BH_Mat4fFromRotationZ(float angle,
|
||||||
float *out)
|
float out[16])
|
||||||
{
|
{
|
||||||
float c, s;
|
float c, s;
|
||||||
|
|
||||||
@@ -258,9 +258,9 @@ void BH_Mat4fFromRotationZ(float angle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Mat4fFromAxis(const float *axis,
|
void BH_Mat4fFromAxis(const float axis[3],
|
||||||
float angle,
|
float angle,
|
||||||
float *out)
|
float out[16])
|
||||||
{
|
{
|
||||||
float x, y, z, length;
|
float x, y, z, length;
|
||||||
float c, s, moc, xx, xy, xz, yy, yz, zz;
|
float c, s, moc, xx, xy, xz, yy, yz, zz;
|
||||||
@@ -303,7 +303,7 @@ void BH_Mat4fFromAxis(const float *axis,
|
|||||||
void BH_Mat4fFromEuler(float roll,
|
void BH_Mat4fFromEuler(float roll,
|
||||||
float pitch,
|
float pitch,
|
||||||
float yaw,
|
float yaw,
|
||||||
float *out)
|
float out[16])
|
||||||
{
|
{
|
||||||
float rs, rc, ys, yc, ps, pc;
|
float rs, rc, ys, yc, ps, pc;
|
||||||
|
|
||||||
@@ -327,8 +327,8 @@ void BH_Mat4fFromEuler(float roll,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Mat4fFromQuat4f(const float *in,
|
void BH_Mat4fFromQuat4f(const float in[4],
|
||||||
float *out)
|
float out[16])
|
||||||
{
|
{
|
||||||
BH_Quat4fToMat4f(in, out);
|
BH_Quat4fToMat4f(in, out);
|
||||||
}
|
}
|
||||||
@@ -340,7 +340,7 @@ void BH_Mat4fFromOrtho(float xMin,
|
|||||||
float yMax,
|
float yMax,
|
||||||
float zMin,
|
float zMin,
|
||||||
float zMax,
|
float zMax,
|
||||||
float *out)
|
float out[16])
|
||||||
{
|
{
|
||||||
float dx, dy, dz;
|
float dx, dy, dz;
|
||||||
|
|
||||||
@@ -363,7 +363,7 @@ void BH_Mat4fFromFrustum(float fov,
|
|||||||
float aspect,
|
float aspect,
|
||||||
float zMin,
|
float zMin,
|
||||||
float zMax,
|
float zMax,
|
||||||
float *out)
|
float out[16])
|
||||||
{
|
{
|
||||||
float t, dz;
|
float t, dz;
|
||||||
|
|
||||||
@@ -381,10 +381,10 @@ void BH_Mat4fFromFrustum(float fov,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Mat4fFromLookAt(const float *position,
|
void BH_Mat4fFromLookAt(const float position[3],
|
||||||
const float *at,
|
const float at[3],
|
||||||
const float *up,
|
const float up[3],
|
||||||
float *out)
|
float out[16])
|
||||||
{
|
{
|
||||||
float cameraDir[3], cameraRight[3], cameraUp[3];
|
float cameraDir[3], cameraRight[3], cameraUp[3];
|
||||||
|
|
||||||
@@ -416,9 +416,9 @@ void BH_Mat4fFromLookAt(const float *position,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Mat4fApplyVec4f(const float *a,
|
void BH_Mat4fApplyVec4f(const float a[16],
|
||||||
const float *b,
|
const float b[4],
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
float tmp[4], row[4];
|
float tmp[4], row[4];
|
||||||
|
|
||||||
@@ -431,9 +431,9 @@ void BH_Mat4fApplyVec4f(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Mat4fApplyVec3f(const float *a,
|
void BH_Mat4fApplyVec3f(const float a[16],
|
||||||
const float *b,
|
const float b[3],
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
float tmp[4], row[4];
|
float tmp[4], row[4];
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ float BH_Lerpf(float a, float b, float t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Triangle3fBarycentric(const float *a,
|
void BH_Triangle3fBarycentric(const float a[3],
|
||||||
const float *b,
|
const float b[3],
|
||||||
const float *c,
|
const float c[3],
|
||||||
const float *point,
|
const float point[3],
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
float tmp1[3], tmp2[3], tmp3[3];
|
float tmp1[3], tmp2[3], tmp3[3];
|
||||||
float t11, t12, t22, t31, t32, denom;
|
float t11, t12, t22, t31, t32, denom;
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
#define PI 3.14159265358979323846f
|
#define PI 3.14159265358979323846f
|
||||||
|
|
||||||
|
|
||||||
int BH_PlaneFromPoints(const float *a,
|
int BH_PlaneFromPoints(const float a[3],
|
||||||
const float *b,
|
const float b[3],
|
||||||
const float *c,
|
const float c[3],
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
float tmp1[3], tmp2[3];
|
float tmp1[3], tmp2[3];
|
||||||
|
|
||||||
@@ -25,16 +25,16 @@ int BH_PlaneFromPoints(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float BH_PlaneDistance(const float *plane,
|
float BH_PlaneDistance(const float plane[4],
|
||||||
const float *point)
|
const float point[3])
|
||||||
{
|
{
|
||||||
return BH_Vec3fDot(plane, point) - plane[3];
|
return BH_Vec3fDot(plane, point) - plane[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_PlaneClosestPoint(const float *plane,
|
void BH_PlaneClosestPoint(const float plane[4],
|
||||||
const float *point,
|
const float point[3],
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
float tmp[3];
|
float tmp[3];
|
||||||
|
|
||||||
|
|||||||
@@ -7,15 +7,15 @@
|
|||||||
#define PI 3.14159265358979323846f
|
#define PI 3.14159265358979323846f
|
||||||
|
|
||||||
|
|
||||||
void BH_Quat4fIdentity(float *out)
|
void BH_Quat4fIdentity(float out[4])
|
||||||
{
|
{
|
||||||
static const float ident[4] = {0.0f, 0.0f, 0.0f, 1.0f};
|
static const float ident[4] = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||||
memcpy(out, ident, sizeof(ident));
|
memcpy(out, ident, sizeof(ident));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Quat4fConjugate(const float *in,
|
void BH_Quat4fConjugate(const float in[4],
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
out[0] = -in[0];
|
out[0] = -in[0];
|
||||||
out[1] = -in[1];
|
out[1] = -in[1];
|
||||||
@@ -24,8 +24,8 @@ void BH_Quat4fConjugate(const float *in,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Quat4fInverse(const float *in,
|
void BH_Quat4fInverse(const float in[4],
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
float dot;
|
float dot;
|
||||||
|
|
||||||
@@ -35,9 +35,9 @@ void BH_Quat4fInverse(const float *in,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Quat4fMul(const float *a,
|
void BH_Quat4fMul(const float a[4],
|
||||||
const float *b,
|
const float b[4],
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
float tmp1[4], tmp2[4], tmp3[4];
|
float tmp1[4], tmp2[4], tmp3[4];
|
||||||
float w;
|
float w;
|
||||||
@@ -52,10 +52,10 @@ void BH_Quat4fMul(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Quat4fSlerp(const float *a,
|
void BH_Quat4fSlerp(const float a[4],
|
||||||
const float *b,
|
const float b[4],
|
||||||
float t,
|
float t,
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
float angle, denom;
|
float angle, denom;
|
||||||
float from[4], to[4];
|
float from[4], to[4];
|
||||||
@@ -77,7 +77,7 @@ void BH_Quat4fSlerp(const float *a,
|
|||||||
void BH_Quat4fFromEuler(float roll,
|
void BH_Quat4fFromEuler(float roll,
|
||||||
float pitch,
|
float pitch,
|
||||||
float yaw,
|
float yaw,
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
float cr, cp, cy, sr, sp, sy;
|
float cr, cp, cy, sr, sp, sy;
|
||||||
|
|
||||||
@@ -95,9 +95,9 @@ void BH_Quat4fFromEuler(float roll,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Quat4fFromAxis(const float *axis,
|
void BH_Quat4fFromAxis(const float axis[3],
|
||||||
float angle,
|
float angle,
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
float c, s;
|
float c, s;
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ void BH_Quat4fFromAxis(const float *axis,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Quat4fToEuler(const float *in,
|
void BH_Quat4fToEuler(const float in[4],
|
||||||
float *roll,
|
float *roll,
|
||||||
float *pitch,
|
float *pitch,
|
||||||
float *yaw)
|
float *yaw)
|
||||||
@@ -155,8 +155,8 @@ void BH_Quat4fToEuler(const float *in,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Quat4fToAxis(const float *in,
|
void BH_Quat4fToAxis(const float in[4],
|
||||||
float *axis,
|
float axis[3],
|
||||||
float *angle)
|
float *angle)
|
||||||
{
|
{
|
||||||
*angle = 2.0f * acosf(in[3]);
|
*angle = 2.0f * acosf(in[3]);
|
||||||
@@ -179,8 +179,8 @@ void BH_Quat4fToAxis(const float *in,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Quat4fToMat4f(const float *in,
|
void BH_Quat4fToMat4f(const float in[4],
|
||||||
float *out)
|
float out[16])
|
||||||
{
|
{
|
||||||
float xx, xy, xz, xw, yy, yz, yw, zz, zw;
|
float xx, xy, xz, xw, yy, yz, yw, zz, zw;
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,11 @@
|
|||||||
#define PI 3.14159265358979323846f
|
#define PI 3.14159265358979323846f
|
||||||
|
|
||||||
|
|
||||||
int BH_Ray2fIntersectLine(const float *start,
|
int BH_Ray2fIntersectLine(const float start[2],
|
||||||
const float *direction,
|
const float direction[2],
|
||||||
const float *line,
|
const float line[3],
|
||||||
float *t,
|
float *t,
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
float tmp1[2];
|
float tmp1[2];
|
||||||
float denom, time;
|
float denom, time;
|
||||||
@@ -31,10 +31,10 @@ int BH_Ray2fIntersectLine(const float *start,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BH_Ray2fIntersectTime(const float *aStart,
|
int BH_Ray2fIntersectTime(const float aStart[2],
|
||||||
const float *aDirection,
|
const float aDirection[2],
|
||||||
const float *bStart,
|
const float bStart[2],
|
||||||
const float *bDirection,
|
const float bDirection[2],
|
||||||
float *time1,
|
float *time1,
|
||||||
float *time2)
|
float *time2)
|
||||||
{
|
{
|
||||||
@@ -58,12 +58,12 @@ int BH_Ray2fIntersectTime(const float *aStart,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BH_Ray2fIntersectRay(const float *aStart,
|
int BH_Ray2fIntersectRay(const float aStart[2],
|
||||||
const float *aDirection,
|
const float aDirection[2],
|
||||||
const float *bStart,
|
const float bStart[2],
|
||||||
const float *bDirection,
|
const float bDirection[2],
|
||||||
float *t,
|
float *t,
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
float tmp[2];
|
float tmp[2];
|
||||||
float time1, time2;
|
float time1, time2;
|
||||||
@@ -81,12 +81,12 @@ int BH_Ray2fIntersectRay(const float *aStart,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BH_Ray2fIntersectSegment(const float *aStart,
|
int BH_Ray2fIntersectSegment(const float aStart[2],
|
||||||
const float *aDirection,
|
const float aDirection[2],
|
||||||
const float *bStart,
|
const float bStart[2],
|
||||||
const float *bEnd,
|
const float bEnd[2],
|
||||||
float *t,
|
float *t,
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
float tmp[2];
|
float tmp[2];
|
||||||
float time1, time2;
|
float time1, time2;
|
||||||
@@ -105,11 +105,11 @@ int BH_Ray2fIntersectSegment(const float *aStart,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BH_Segment2fIntersectLine(const float *start,
|
int BH_Segment2fIntersectLine(const float start[2],
|
||||||
const float *end,
|
const float end[2],
|
||||||
const float *line,
|
const float line[3],
|
||||||
float *t,
|
float *t,
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
float tmp[2];
|
float tmp[2];
|
||||||
float denom, time;
|
float denom, time;
|
||||||
@@ -131,12 +131,12 @@ int BH_Segment2fIntersectLine(const float *start,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BH_Segment2fIntersectSegment(const float *aStart,
|
int BH_Segment2fIntersectSegment(const float aStart[2],
|
||||||
const float *aEnd,
|
const float aEnd[2],
|
||||||
const float *bStart,
|
const float bStart[2],
|
||||||
const float *bEnd,
|
const float bEnd[2],
|
||||||
float *t,
|
float *t,
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
float tmp1[2], tmp2[2];
|
float tmp1[2], tmp2[2];
|
||||||
float time1, time2;
|
float time1, time2;
|
||||||
@@ -156,12 +156,12 @@ int BH_Segment2fIntersectSegment(const float *aStart,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BH_Ray2fIntersectBox2f(const float *aStart,
|
int BH_Ray2fIntersectBox2f(const float aStart[2],
|
||||||
const float *aDirection,
|
const float aDirection[2],
|
||||||
const float *bMin,
|
const float bMin[2],
|
||||||
const float *bMax,
|
const float bMax[2],
|
||||||
float *t,
|
float *t,
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
float timeNear, timeFar, hitNear, hitFar, denom, tmp;
|
float timeNear, timeFar, hitNear, hitFar, denom, tmp;
|
||||||
int i;
|
int i;
|
||||||
@@ -215,12 +215,12 @@ int BH_Ray2fIntersectBox2f(const float *aStart,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BH_Segment2fIntersectBox2f(const float *aStart,
|
int BH_Segment2fIntersectBox2f(const float aStart[2],
|
||||||
const float *aEnd,
|
const float aEnd[2],
|
||||||
const float *bMin,
|
const float bMin[2],
|
||||||
const float *bMax,
|
const float bMax[2],
|
||||||
float *t,
|
float *t,
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
float tmp[3];
|
float tmp[3];
|
||||||
float time;
|
float time;
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
#define PI 3.14159265358979323846f
|
#define PI 3.14159265358979323846f
|
||||||
|
|
||||||
|
|
||||||
int BH_Ray3fIntersectPlane(const float *start,
|
int BH_Ray3fIntersectPlane(const float start[3],
|
||||||
const float *direction,
|
const float direction[3],
|
||||||
const float *plane,
|
const float plane[4],
|
||||||
float *t,
|
float *t,
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
float tmp1[3];
|
float tmp1[3];
|
||||||
float denom, time;
|
float denom, time;
|
||||||
@@ -32,13 +32,13 @@ int BH_Ray3fIntersectPlane(const float *start,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BH_Ray3fIntersectTriangle(const float *start,
|
int BH_Ray3fIntersectTriangle(const float start[3],
|
||||||
const float *direction,
|
const float direction[3],
|
||||||
const float *a,
|
const float a[3],
|
||||||
const float *b,
|
const float b[3],
|
||||||
const float *c,
|
const float c[3],
|
||||||
float *t,
|
float *t,
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
float plane[4];
|
float plane[4];
|
||||||
float tmp1[3], tmp2[3], tmp3[3];
|
float tmp1[3], tmp2[3], tmp3[3];
|
||||||
@@ -78,11 +78,11 @@ int BH_Ray3fIntersectTriangle(const float *start,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BH_Segment3fIntersectPlane(const float *start,
|
int BH_Segment3fIntersectPlane(const float start[3],
|
||||||
const float *end,
|
const float end[3],
|
||||||
const float *plane,
|
const float plane[4],
|
||||||
float *t,
|
float *t,
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
float tmp[3];
|
float tmp[3];
|
||||||
float denom, time;
|
float denom, time;
|
||||||
@@ -104,13 +104,13 @@ int BH_Segment3fIntersectPlane(const float *start,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BH_Segment3fIntersectTriangle(const float *start,
|
int BH_Segment3fIntersectTriangle(const float start[3],
|
||||||
const float *end,
|
const float end[3],
|
||||||
const float *a,
|
const float a[3],
|
||||||
const float *b,
|
const float b[3],
|
||||||
const float *c,
|
const float c[3],
|
||||||
float *t,
|
float *t,
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
float plane[4];
|
float plane[4];
|
||||||
float tmp1[3], tmp2[3], tmp3[3];
|
float tmp1[3], tmp2[3], tmp3[3];
|
||||||
@@ -150,12 +150,12 @@ int BH_Segment3fIntersectTriangle(const float *start,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BH_Ray3fIntersectBox3f(const float *aStart,
|
int BH_Ray3fIntersectBox3f(const float aStart[3],
|
||||||
const float *aDirection,
|
const float aDirection[3],
|
||||||
const float *bMin,
|
const float bMin[3],
|
||||||
const float *bMax,
|
const float bMax[3],
|
||||||
float *t,
|
float *t,
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
float timeNear, timeFar, hitNear, hitFar, denom, tmp;
|
float timeNear, timeFar, hitNear, hitFar, denom, tmp;
|
||||||
int i;
|
int i;
|
||||||
@@ -210,12 +210,12 @@ int BH_Ray3fIntersectBox3f(const float *aStart,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BH_Segment3fIntersectBox3f(const float *aStart,
|
int BH_Segment3fIntersectBox3f(const float aStart[3],
|
||||||
const float *aEnd,
|
const float aEnd[3],
|
||||||
const float *bMin,
|
const float bMin[3],
|
||||||
const float *bMax,
|
const float bMax[3],
|
||||||
float *t,
|
float *t,
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
float tmp[3];
|
float tmp[3];
|
||||||
float time;
|
float time;
|
||||||
|
|||||||
@@ -2,89 +2,89 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec2fAdd(const float *a,
|
void BH_Vec2fAdd(const float a[2],
|
||||||
const float *b,
|
const float b[2],
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
out[0] = a[0] + b[0];
|
out[0] = a[0] + b[0];
|
||||||
out[1] = a[1] + b[1];
|
out[1] = a[1] + b[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec2fSub(const float *a,
|
void BH_Vec2fSub(const float a[2],
|
||||||
const float *b,
|
const float b[2],
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
out[0] = a[0] - b[0];
|
out[0] = a[0] - b[0];
|
||||||
out[1] = a[1] - b[1];
|
out[1] = a[1] - b[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec2fMul(const float *a,
|
void BH_Vec2fMul(const float a[2],
|
||||||
const float *b,
|
const float b[2],
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
out[0] = a[0] * b[0];
|
out[0] = a[0] * b[0];
|
||||||
out[1] = a[1] * b[1];
|
out[1] = a[1] * b[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec2fScale(const float *a,
|
void BH_Vec2fScale(const float a[2],
|
||||||
const float b,
|
float b,
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
out[0] = a[0] * b;
|
out[0] = a[0] * b;
|
||||||
out[1] = a[1] * b;
|
out[1] = a[1] * b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec2fMulAdd(const float *a,
|
void BH_Vec2fMulAdd(const float a[2],
|
||||||
const float *b,
|
const float b[2],
|
||||||
const float *c,
|
const float c[2],
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
out[0] = a[0] * b[0] + c[0];
|
out[0] = a[0] * b[0] + c[0];
|
||||||
out[1] = a[1] * b[1] + c[1];
|
out[1] = a[1] * b[1] + c[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec2fNegate(const float *in,
|
void BH_Vec2fNegate(const float in[2],
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
out[0] = -in[0];
|
out[0] = -in[0];
|
||||||
out[1] = -in[1];
|
out[1] = -in[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float BH_Vec2fDot(const float *a,
|
float BH_Vec2fDot(const float a[2],
|
||||||
const float *b)
|
const float b[2])
|
||||||
{
|
{
|
||||||
return a[0] * b[0] + a[1] * b[1];
|
return a[0] * b[0] + a[1] * b[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float BH_Vec2fCross(const float *a,
|
float BH_Vec2fCross(const float a[2],
|
||||||
const float *b)
|
const float b[2])
|
||||||
{
|
{
|
||||||
return a[0] * b[1] - a[1] * b[0];
|
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));
|
return sqrtf(BH_Vec2fDot(in, in));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec2fNormal(const float *in,
|
void BH_Vec2fNormal(const float in[2],
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
BH_Vec2fScale(in, 1.0f / BH_Vec2fLength(in), out);
|
BH_Vec2fScale(in, 1.0f / BH_Vec2fLength(in), out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float BH_Vec2fNormalEx(const float *in,
|
float BH_Vec2fNormalEx(const float in[2],
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
float length;
|
float length;
|
||||||
|
|
||||||
@@ -94,28 +94,28 @@ float BH_Vec2fNormalEx(const float *in,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec2fMin(const float *a,
|
void BH_Vec2fMin(const float a[2],
|
||||||
const float *b,
|
const float b[2],
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
if (a[0] < b[0]) out[0] = a[0]; else out[0] = b[0];
|
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];
|
if (a[1] < b[1]) out[1] = a[1]; else out[1] = b[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec2fMax(const float *a,
|
void BH_Vec2fMax(const float a[2],
|
||||||
const float *b,
|
const float b[2],
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
if (a[0] > b[0]) out[0] = a[0]; else out[0] = b[0];
|
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];
|
if (a[1] > b[1]) out[1] = a[1]; else out[1] = b[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec2fLerp(const float *a,
|
void BH_Vec2fLerp(const float a[2],
|
||||||
const float *b,
|
const float b[2],
|
||||||
float t,
|
float t,
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
float tmp[2];
|
float tmp[2];
|
||||||
|
|
||||||
@@ -125,9 +125,9 @@ void BH_Vec2fLerp(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec2fProject(const float *a,
|
void BH_Vec2fProject(const float a[2],
|
||||||
const float *b,
|
const float b[2],
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
float amount;
|
float amount;
|
||||||
|
|
||||||
@@ -136,12 +136,12 @@ void BH_Vec2fProject(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec2fBarycentric(const float *a,
|
void BH_Vec2fBarycentric(const float a[2],
|
||||||
const float *b,
|
const float b[2],
|
||||||
const float *c,
|
const float c[2],
|
||||||
float v,
|
float v,
|
||||||
float w,
|
float w,
|
||||||
float *out)
|
float out[2])
|
||||||
{
|
{
|
||||||
float tmp1[2], tmp2[2];
|
float tmp1[2], tmp2[2];
|
||||||
float u;
|
float u;
|
||||||
|
|||||||
@@ -1,72 +1,72 @@
|
|||||||
#include <BH/Math.h>
|
#include <BH/Math.h>
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec2iAdd(const int *a,
|
void BH_Vec2iAdd(const int a[2],
|
||||||
const int *b,
|
const int b[2],
|
||||||
int *out)
|
int out[2])
|
||||||
{
|
{
|
||||||
out[0] = a[0] + b[0];
|
out[0] = a[0] + b[0];
|
||||||
out[1] = a[1] + b[1];
|
out[1] = a[1] + b[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec2iSub(const int *a,
|
void BH_Vec2iSub(const int a[2],
|
||||||
const int *b,
|
const int b[2],
|
||||||
int *out)
|
int out[2])
|
||||||
{
|
{
|
||||||
out[0] = a[0] - b[0];
|
out[0] = a[0] - b[0];
|
||||||
out[1] = a[1] - b[1];
|
out[1] = a[1] - b[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec2iMul(const int *a,
|
void BH_Vec2iMul(const int a[2],
|
||||||
const int *b,
|
const int b[2],
|
||||||
int *out)
|
int out[2])
|
||||||
{
|
{
|
||||||
out[0] = a[0] * b[0];
|
out[0] = a[0] * b[0];
|
||||||
out[1] = a[1] * b[1];
|
out[1] = a[1] * b[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec2iScale(const int *a,
|
void BH_Vec2iScale(const int a[2],
|
||||||
int b,
|
int b,
|
||||||
int *out)
|
int out[2])
|
||||||
{
|
{
|
||||||
out[0] = a[0] * b;
|
out[0] = a[0] * b;
|
||||||
out[1] = a[1] * b;
|
out[1] = a[1] * b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec2iMulAdd(const int *a,
|
void BH_Vec2iMulAdd(const int a[2],
|
||||||
const int *b,
|
const int b[2],
|
||||||
const int *c,
|
const int c[2],
|
||||||
int *out)
|
int out[2])
|
||||||
{
|
{
|
||||||
out[0] = a[0] * b[0] + c[0];
|
out[0] = a[0] * b[0] + c[0];
|
||||||
out[1] = a[1] * b[1] + c[1];
|
out[1] = a[1] * b[1] + c[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec2iNegate(const int *in,
|
void BH_Vec2iNegate(const int in[2],
|
||||||
int *out)
|
int out[2])
|
||||||
{
|
{
|
||||||
out[0] = -in[0];
|
out[0] = -in[0];
|
||||||
out[1] = -in[1];
|
out[1] = -in[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec2iMin(const int *a,
|
void BH_Vec2iMin(const int a[2],
|
||||||
const int *b,
|
const int b[2],
|
||||||
int *out)
|
int out[2])
|
||||||
{
|
{
|
||||||
if (a[0] < b[0]) out[0] = a[0]; else out[0] = b[0];
|
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];
|
if (a[1] < b[1]) out[1] = a[1]; else out[1] = b[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec2iMax(const int *a,
|
void BH_Vec2iMax(const int a[2],
|
||||||
const int *b,
|
const int b[2],
|
||||||
int *out)
|
int out[2])
|
||||||
{
|
{
|
||||||
if (a[0] > b[0]) out[0] = a[0]; else out[0] = b[0];
|
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];
|
if (a[1] > b[1]) out[1] = a[1]; else out[1] = b[1];
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3fAdd(const float *a,
|
void BH_Vec3fAdd(const float a[3],
|
||||||
const float *b,
|
const float b[3],
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
out[0] = a[0] + b[0];
|
out[0] = a[0] + b[0];
|
||||||
out[1] = a[1] + b[1];
|
out[1] = a[1] + b[1];
|
||||||
@@ -13,9 +13,9 @@ void BH_Vec3fAdd(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3fSub(const float *a,
|
void BH_Vec3fSub(const float a[3],
|
||||||
const float *b,
|
const float b[3],
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
out[0] = a[0] - b[0];
|
out[0] = a[0] - b[0];
|
||||||
out[1] = a[1] - b[1];
|
out[1] = a[1] - b[1];
|
||||||
@@ -23,9 +23,9 @@ void BH_Vec3fSub(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3fMul(const float *a,
|
void BH_Vec3fMul(const float a[3],
|
||||||
const float *b,
|
const float b[3],
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
out[0] = a[0] * b[0];
|
out[0] = a[0] * b[0];
|
||||||
out[1] = a[1] * b[1];
|
out[1] = a[1] * b[1];
|
||||||
@@ -33,9 +33,9 @@ void BH_Vec3fMul(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3fScale(const float *a,
|
void BH_Vec3fScale(const float a[3],
|
||||||
const float b,
|
float b,
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
out[0] = a[0] * b;
|
out[0] = a[0] * b;
|
||||||
out[1] = a[1] * b;
|
out[1] = a[1] * b;
|
||||||
@@ -43,10 +43,10 @@ void BH_Vec3fScale(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3fMulAdd(const float *a,
|
void BH_Vec3fMulAdd(const float a[3],
|
||||||
const float *b,
|
const float b[3],
|
||||||
const float *c,
|
const float c[3],
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
out[0] = a[0] * b[0] + c[0];
|
out[0] = a[0] * b[0] + c[0];
|
||||||
out[1] = a[1] * b[1] + c[1];
|
out[1] = a[1] * b[1] + c[1];
|
||||||
@@ -54,8 +54,8 @@ void BH_Vec3fMulAdd(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3fNegate(const float *in,
|
void BH_Vec3fNegate(const float in[3],
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
out[0] = -in[0];
|
out[0] = -in[0];
|
||||||
out[1] = -in[1];
|
out[1] = -in[1];
|
||||||
@@ -63,16 +63,16 @@ void BH_Vec3fNegate(const float *in,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float BH_Vec3fDot(const float *a,
|
float BH_Vec3fDot(const float a[3],
|
||||||
const float *b)
|
const float b[3])
|
||||||
{
|
{
|
||||||
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3fCross(const float *a,
|
void BH_Vec3fCross(const float a[3],
|
||||||
const float *b,
|
const float b[3],
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
float tmp[3];
|
float tmp[3];
|
||||||
|
|
||||||
@@ -83,21 +83,21 @@ void BH_Vec3fCross(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float BH_Vec3fLength(const float *in)
|
float BH_Vec3fLength(const float in[3])
|
||||||
{
|
{
|
||||||
return sqrtf(BH_Vec3fDot(in, in));
|
return sqrtf(BH_Vec3fDot(in, in));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3fNormal(const float *in,
|
void BH_Vec3fNormal(const float in[3],
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
BH_Vec3fScale(in, 1.0f / BH_Vec3fLength(in), out);
|
BH_Vec3fScale(in, 1.0f / BH_Vec3fLength(in), out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float BH_Vec3fNormalEx(const float *in,
|
float BH_Vec3fNormalEx(const float in[3],
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
float length;
|
float length;
|
||||||
|
|
||||||
@@ -107,9 +107,9 @@ float BH_Vec3fNormalEx(const float *in,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3fMin(const float *a,
|
void BH_Vec3fMin(const float a[3],
|
||||||
const float *b,
|
const float b[3],
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
if (a[0] < b[0]) out[0] = a[0]; else out[0] = b[0];
|
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];
|
if (a[1] < b[1]) out[1] = a[1]; else out[1] = b[1];
|
||||||
@@ -117,9 +117,9 @@ void BH_Vec3fMin(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3fMax(const float *a,
|
void BH_Vec3fMax(const float a[3],
|
||||||
const float *b,
|
const float b[3],
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
if (a[0] > b[0]) out[0] = a[0]; else out[0] = b[0];
|
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];
|
if (a[1] > b[1]) out[1] = a[1]; else out[1] = b[1];
|
||||||
@@ -127,10 +127,10 @@ void BH_Vec3fMax(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3fLerp(const float *a,
|
void BH_Vec3fLerp(const float a[3],
|
||||||
const float *b,
|
const float b[3],
|
||||||
float t,
|
float t,
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
float tmp[3];
|
float tmp[3];
|
||||||
|
|
||||||
@@ -140,9 +140,9 @@ void BH_Vec3fLerp(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3fProject(const float *a,
|
void BH_Vec3fProject(const float a[3],
|
||||||
const float *b,
|
const float b[3],
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
float amount;
|
float amount;
|
||||||
|
|
||||||
@@ -151,12 +151,12 @@ void BH_Vec3fProject(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3fBarycentric(const float *a,
|
void BH_Vec3fBarycentric(const float a[3],
|
||||||
const float *b,
|
const float b[3],
|
||||||
const float *c,
|
const float c[3],
|
||||||
float v,
|
float v,
|
||||||
float w,
|
float w,
|
||||||
float *out)
|
float out[3])
|
||||||
{
|
{
|
||||||
float tmp1[3], tmp2[3];
|
float tmp1[3], tmp2[3];
|
||||||
float u;
|
float u;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include <BH/Math.h>
|
#include <BH/Math.h>
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3iAdd(const int *a,
|
void BH_Vec3iAdd(const int a[3],
|
||||||
const int *b,
|
const int b[3],
|
||||||
int *out)
|
int out[3])
|
||||||
{
|
{
|
||||||
out[0] = a[0] + b[0];
|
out[0] = a[0] + b[0];
|
||||||
out[1] = a[1] + b[1];
|
out[1] = a[1] + b[1];
|
||||||
@@ -11,9 +11,9 @@ void BH_Vec3iAdd(const int *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3iSub(const int *a,
|
void BH_Vec3iSub(const int a[3],
|
||||||
const int *b,
|
const int b[3],
|
||||||
int *out)
|
int out[3])
|
||||||
{
|
{
|
||||||
out[0] = a[0] - b[0];
|
out[0] = a[0] - b[0];
|
||||||
out[1] = a[1] - b[1];
|
out[1] = a[1] - b[1];
|
||||||
@@ -21,9 +21,9 @@ void BH_Vec3iSub(const int *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3iMul(const int *a,
|
void BH_Vec3iMul(const int a[3],
|
||||||
const int *b,
|
const int b[3],
|
||||||
int *out)
|
int out[3])
|
||||||
{
|
{
|
||||||
out[0] = a[0] * b[0];
|
out[0] = a[0] * b[0];
|
||||||
out[1] = a[1] * b[1];
|
out[1] = a[1] * b[1];
|
||||||
@@ -31,9 +31,9 @@ void BH_Vec3iMul(const int *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3iScale(const int *a,
|
void BH_Vec3iScale(const int a[3],
|
||||||
int b,
|
int b,
|
||||||
int *out)
|
int out[3])
|
||||||
{
|
{
|
||||||
out[0] = a[0] * b;
|
out[0] = a[0] * b;
|
||||||
out[1] = a[1] * b;
|
out[1] = a[1] * b;
|
||||||
@@ -41,10 +41,10 @@ void BH_Vec3iScale(const int *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3iMulAdd(const int *a,
|
void BH_Vec3iMulAdd(const int a[3],
|
||||||
const int *b,
|
const int b[3],
|
||||||
const int *c,
|
const int c[3],
|
||||||
int *out)
|
int out[3])
|
||||||
{
|
{
|
||||||
out[0] = a[0] * b[0] + c[0];
|
out[0] = a[0] * b[0] + c[0];
|
||||||
out[1] = a[1] * b[1] + c[1];
|
out[1] = a[1] * b[1] + c[1];
|
||||||
@@ -52,8 +52,8 @@ void BH_Vec3iMulAdd(const int *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3iNegate(const int *in,
|
void BH_Vec3iNegate(const int in[3],
|
||||||
int *out)
|
int out[3])
|
||||||
{
|
{
|
||||||
out[0] = -in[0];
|
out[0] = -in[0];
|
||||||
out[1] = -in[1];
|
out[1] = -in[1];
|
||||||
@@ -61,9 +61,9 @@ void BH_Vec3iNegate(const int *in,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3iMin(const int *a,
|
void BH_Vec3iMin(const int a[3],
|
||||||
const int *b,
|
const int b[3],
|
||||||
int *out)
|
int out[3])
|
||||||
{
|
{
|
||||||
if (a[0] < b[0]) out[0] = a[0]; else out[0] = b[0];
|
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];
|
if (a[1] < b[1]) out[1] = a[1]; else out[1] = b[1];
|
||||||
@@ -71,9 +71,9 @@ void BH_Vec3iMin(const int *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec3iMax(const int *a,
|
void BH_Vec3iMax(const int a[3],
|
||||||
const int *b,
|
const int b[3],
|
||||||
int *out)
|
int out[3])
|
||||||
{
|
{
|
||||||
if (a[0] > b[0]) out[0] = a[0]; else out[0] = b[0];
|
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];
|
if (a[1] > b[1]) out[1] = a[1]; else out[1] = b[1];
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec4fAdd(const float *a,
|
void BH_Vec4fAdd(const float a[4],
|
||||||
const float *b,
|
const float b[4],
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
out[0] = a[0] + b[0];
|
out[0] = a[0] + b[0];
|
||||||
out[1] = a[1] + b[1];
|
out[1] = a[1] + b[1];
|
||||||
@@ -13,9 +13,9 @@ void BH_Vec4fAdd(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec4fSub(const float *a,
|
void BH_Vec4fSub(const float a[4],
|
||||||
const float *b,
|
const float b[4],
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
out[0] = a[0] - b[0];
|
out[0] = a[0] - b[0];
|
||||||
out[1] = a[1] - b[1];
|
out[1] = a[1] - b[1];
|
||||||
@@ -24,9 +24,9 @@ void BH_Vec4fSub(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec4fMul(const float *a,
|
void BH_Vec4fMul(const float a[4],
|
||||||
const float *b,
|
const float b[4],
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
out[0] = a[0] * b[0];
|
out[0] = a[0] * b[0];
|
||||||
out[1] = a[1] * b[1];
|
out[1] = a[1] * b[1];
|
||||||
@@ -35,9 +35,9 @@ void BH_Vec4fMul(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec4fScale(const float *a,
|
void BH_Vec4fScale(const float a[4],
|
||||||
const float b,
|
float b,
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
out[0] = a[0] * b;
|
out[0] = a[0] * b;
|
||||||
out[1] = a[1] * b;
|
out[1] = a[1] * b;
|
||||||
@@ -46,10 +46,10 @@ void BH_Vec4fScale(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec4fMulAdd(const float *a,
|
void BH_Vec4fMulAdd(const float a[4],
|
||||||
const float *b,
|
const float b[4],
|
||||||
const float *c,
|
const float c[4],
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
out[0] = a[0] * b[0] + c[0];
|
out[0] = a[0] * b[0] + c[0];
|
||||||
out[1] = a[1] * b[1] + c[1];
|
out[1] = a[1] * b[1] + c[1];
|
||||||
@@ -58,8 +58,8 @@ void BH_Vec4fMulAdd(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec4fNegate(const float *in,
|
void BH_Vec4fNegate(const float in[4],
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
out[0] = -in[0];
|
out[0] = -in[0];
|
||||||
out[1] = -in[1];
|
out[1] = -in[1];
|
||||||
@@ -68,28 +68,28 @@ void BH_Vec4fNegate(const float *in,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float BH_Vec4fDot(const float *a,
|
float BH_Vec4fDot(const float a[4],
|
||||||
const float *b)
|
const float b[4])
|
||||||
{
|
{
|
||||||
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
|
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float BH_Vec4fLength(const float *in)
|
float BH_Vec4fLength(const float in[4])
|
||||||
{
|
{
|
||||||
return sqrtf(BH_Vec4fDot(in, in));
|
return sqrtf(BH_Vec4fDot(in, in));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec4fNormal(const float *in,
|
void BH_Vec4fNormal(const float in[4],
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
BH_Vec4fScale(in, 1.0f / BH_Vec4fLength(in), out);
|
BH_Vec4fScale(in, 1.0f / BH_Vec4fLength(in), out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float BH_Vec4fNormalEx(const float *in,
|
float BH_Vec4fNormalEx(const float in[4],
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
float length;
|
float length;
|
||||||
|
|
||||||
@@ -99,9 +99,9 @@ float BH_Vec4fNormalEx(const float *in,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec4fMin(const float *a,
|
void BH_Vec4fMin(const float a[4],
|
||||||
const float *b,
|
const float b[4],
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
if (a[0] < b[0]) out[0] = a[0]; else out[0] = b[0];
|
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];
|
if (a[1] < b[1]) out[1] = a[1]; else out[1] = b[1];
|
||||||
@@ -110,9 +110,9 @@ void BH_Vec4fMin(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec4fMax(const float *a,
|
void BH_Vec4fMax(const float a[4],
|
||||||
const float *b,
|
const float b[4],
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
if (a[0] > b[0]) out[0] = a[0]; else out[0] = b[0];
|
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];
|
if (a[1] > b[1]) out[1] = a[1]; else out[1] = b[1];
|
||||||
@@ -121,10 +121,10 @@ void BH_Vec4fMax(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec4fLerp(const float *a,
|
void BH_Vec4fLerp(const float a[4],
|
||||||
const float *b,
|
const float b[4],
|
||||||
float t,
|
float t,
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
float tmp[4];
|
float tmp[4];
|
||||||
|
|
||||||
@@ -134,9 +134,9 @@ void BH_Vec4fLerp(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec4fProject(const float *a,
|
void BH_Vec4fProject(const float a[4],
|
||||||
const float *b,
|
const float b[4],
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
float amount;
|
float amount;
|
||||||
|
|
||||||
@@ -145,12 +145,12 @@ void BH_Vec4fProject(const float *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec4fBarycentric(const float *a,
|
void BH_Vec4fBarycentric(const float a[4],
|
||||||
const float *b,
|
const float b[4],
|
||||||
const float *c,
|
const float c[4],
|
||||||
float v,
|
float v,
|
||||||
float w,
|
float w,
|
||||||
float *out)
|
float out[4])
|
||||||
{
|
{
|
||||||
float tmp1[4], tmp2[4];
|
float tmp1[4], tmp2[4];
|
||||||
float u;
|
float u;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include <BH/Math.h>
|
#include <BH/Math.h>
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec4iAdd(const int *a,
|
void BH_Vec4iAdd(const int a[4],
|
||||||
const int *b,
|
const int b[4],
|
||||||
int *out)
|
int out[4])
|
||||||
{
|
{
|
||||||
out[0] = a[0] + b[0];
|
out[0] = a[0] + b[0];
|
||||||
out[1] = a[1] + b[1];
|
out[1] = a[1] + b[1];
|
||||||
@@ -12,9 +12,9 @@ void BH_Vec4iAdd(const int *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec4iSub(const int *a,
|
void BH_Vec4iSub(const int a[4],
|
||||||
const int *b,
|
const int b[4],
|
||||||
int *out)
|
int out[4])
|
||||||
{
|
{
|
||||||
out[0] = a[0] - b[0];
|
out[0] = a[0] - b[0];
|
||||||
out[1] = a[1] - b[1];
|
out[1] = a[1] - b[1];
|
||||||
@@ -23,9 +23,9 @@ void BH_Vec4iSub(const int *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec4iMul(const int *a,
|
void BH_Vec4iMul(const int a[4],
|
||||||
const int *b,
|
const int b[4],
|
||||||
int *out)
|
int out[4])
|
||||||
{
|
{
|
||||||
out[0] = a[0] * b[0];
|
out[0] = a[0] * b[0];
|
||||||
out[1] = a[1] * b[1];
|
out[1] = a[1] * b[1];
|
||||||
@@ -34,9 +34,9 @@ void BH_Vec4iMul(const int *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec4iScale(const int *a,
|
void BH_Vec4iScale(const int a[4],
|
||||||
int b,
|
int b,
|
||||||
int *out)
|
int out[4])
|
||||||
{
|
{
|
||||||
out[0] = a[0] * b;
|
out[0] = a[0] * b;
|
||||||
out[1] = a[1] * b;
|
out[1] = a[1] * b;
|
||||||
@@ -45,10 +45,10 @@ void BH_Vec4iScale(const int *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec4iMulAdd(const int *a,
|
void BH_Vec4iMulAdd(const int a[4],
|
||||||
const int *b,
|
const int b[4],
|
||||||
const int *c,
|
const int c[4],
|
||||||
int *out)
|
int out[4])
|
||||||
{
|
{
|
||||||
out[0] = a[0] * b[0] + c[0];
|
out[0] = a[0] * b[0] + c[0];
|
||||||
out[1] = a[1] * b[1] + c[1];
|
out[1] = a[1] * b[1] + c[1];
|
||||||
@@ -57,8 +57,8 @@ void BH_Vec4iMulAdd(const int *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec4iNegate(const int *in,
|
void BH_Vec4iNegate(const int in[4],
|
||||||
int *out)
|
int out[4])
|
||||||
{
|
{
|
||||||
out[0] = -in[0];
|
out[0] = -in[0];
|
||||||
out[1] = -in[1];
|
out[1] = -in[1];
|
||||||
@@ -67,9 +67,9 @@ void BH_Vec4iNegate(const int *in,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec4iMin(const int *a,
|
void BH_Vec4iMin(const int a[4],
|
||||||
const int *b,
|
const int b[4],
|
||||||
int *out)
|
int out[4])
|
||||||
{
|
{
|
||||||
if (a[0] < b[0]) out[0] = a[0]; else out[0] = b[0];
|
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];
|
if (a[1] < b[1]) out[1] = a[1]; else out[1] = b[1];
|
||||||
@@ -78,9 +78,9 @@ void BH_Vec4iMin(const int *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BH_Vec4iMax(const int *a,
|
void BH_Vec4iMax(const int a[4],
|
||||||
const int *b,
|
const int b[4],
|
||||||
int *out)
|
int out[4])
|
||||||
{
|
{
|
||||||
if (a[0] > b[0]) out[0] = a[0]; else out[0] = b[0];
|
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];
|
if (a[1] > b[1]) out[1] = a[1]; else out[1] = b[1];
|
||||||
|
|||||||
Reference in New Issue
Block a user