Refactor, separate docs from headers, add ru docs

Doxygen kind'a sucks and I need multilanguage documentation, so I did
that. Also, separated massive Math.h file into smaller files.
This commit is contained in:
2025-06-21 20:12:15 +03:00
parent 7ee69fc397
commit fc774fd0ff
116 changed files with 10693 additions and 3521 deletions

37
include/BH/Math/Box2f.h Normal file
View File

@@ -0,0 +1,37 @@
#ifndef BH_MATH_BOX2F_H
#define BH_MATH_BOX2F_H
#include "../Common.h"
void BH_Box2fUnion(const float aMin[2],
const float aMax[2],
const float bMin[2],
const float bMax[2],
float outMin[2],
float outMax[2]);
int BH_Box2fIntersect(const float aMin[2],
const float aMax[2],
const float bMin[2],
const float bMax[2],
float outMin[2],
float outMax[2]);
int BH_Box2fContains(const float aMin[2],
const float aMax[2],
const float point[2]);
int BH_Box2fEnclose(const float *points,
size_t size,
float outMin[2],
float outMax[2]);
#endif /* BH_MATH_BOX2F_H */

37
include/BH/Math/Box3f.h Normal file
View File

@@ -0,0 +1,37 @@
#ifndef BH_MATH_BOX3F_H
#define BH_MATH_BOX3F_H
#include "../Common.h"
void BH_Box3fUnion(const float aMin[3],
const float aMax[3],
const float bMin[3],
const float bMax[3],
float outMin[3],
float outMax[3]);
int BH_Box3fIntersect(const float aMin[3],
const float aMax[3],
const float bMin[3],
const float bMax[3],
float outMin[3],
float outMax[3]);
int BH_Box3fContains(const float aMin[3],
const float aMax[3],
const float point[3]);
int BH_Box3fEnclose(const float *points,
size_t size,
float outMin[3],
float outMax[3]);
#endif /* BH_MATH_BOX3F_H */

23
include/BH/Math/Line.h Normal file
View File

@@ -0,0 +1,23 @@
#ifndef BH_MATH_LINE_H
#define BH_MATH_LINE_H
#include "../Common.h"
int BH_LineFromPoints(const float a[2],
const float b[2],
float out[3]);
float BH_LineDistance(const float line[3],
const float point[2]);
void BH_LineClosestPoint(const float line[3],
const float point[2],
float out[2]);
#endif /* BH_MATH_LINE_H */

81
include/BH/Math/Mat3f.h Normal file
View File

@@ -0,0 +1,81 @@
#ifndef BH_MATH_MAT3F_H
#define BH_MATH_MAT3F_H
#include "../Common.h"
void BH_Mat3fIdentity(float out[9]);
void BH_Mat3fAdd(const float a[9],
const float b[9],
float out[9]);
void BH_Mat3fSub(const float a[9],
const float b[9],
float out[9]);
void BH_Mat3fMul(const float a[9],
const float b[9],
float out[9]);
void BH_Mat3fScale(const float a[9],
float b,
float out[9]);
void BH_Mat3fTranspose(const float in[9],
float out[9]);
float BH_Mat3fTrace(const float in[9]);
float BH_Mat3fDet(const float in[9]);
int BH_Mat3fInverse(const float in[9],
float out[9]);
void BH_Mat3fFromScale(float x,
float y,
float out[9]);
void BH_Mat3fFromTranslation(float x,
float y,
float out[9]);
void BH_Mat3fFromRotation(float angle,
float out[9]);
void BH_Mat3fApplyVec3f(float a[9],
float b[3],
float out[3]);
void BH_Mat3fApplyVec2f(float a[9],
float b[2],
float out[2]);
#endif /* BH_MATH_MAT3F */

136
include/BH/Math/Mat4f.h Normal file
View File

@@ -0,0 +1,136 @@
#ifndef BH_MATH_MAT4F_H
#define BH_MATH_MAT4F_H
#include "../Common.h"
void BH_Mat4fIdentity(float out[16]);
void BH_Mat4fAdd(const float a[16],
const float b[16],
float out[16]);
void BH_Mat4fSub(const float a[16],
const float b[16],
float out[16]);
void BH_Mat4fMul(const float a[16],
const float b[16],
float out[16]);
void BH_Mat4fScale(const float a[16],
float b,
float out[16]);
void BH_Mat4fTranspose(const float in[16],
float out[16]);
float BH_Mat4fTrace(const float in[16]);
float BH_Mat4fDet(const float in[16]);
int BH_Mat4fInverse(const float in[16],
float out[16]);
void BH_Mat4fFromScale(float x,
float y,
float z,
float out[16]);
void BH_Mat4fFromTranslation(float x,
float y,
float z,
float out[16]);
void BH_Mat4fFromRotationX(float angle,
float out[16]);
void BH_Mat4fFromRotationY(float angle,
float out[16]);
void BH_Mat4fFromRotationZ(float angle,
float out[16]);
void BH_Mat4fFromAxis(const float axis[3],
float angle,
float out[16]);
void BH_Mat4fFromEuler(float roll,
float pitch,
float yaw,
float out[16]);
void BH_Mat4fFromQuat4f(const float in[4],
float out[16]);
void BH_Mat4fFromOrtho(float xMin,
float xMax,
float yMin,
float yMax,
float zMin,
float zMax,
float out[16]);
void BH_Mat4fFromFrustum(float fov,
float aspect,
float zMin,
float zMax,
float out[16]);
void BH_Mat4fFromLookAt(const float position[3],
const float at[3],
const float up[3],
float out[16]);
void BH_Mat4fApplyVec4f(const float a[16],
const float b[4],
float out[4]);
void BH_Mat4fApplyVec3f(const float a[16],
const float b[3],
float out[3]);
#endif /* BH_MATH_MAT4F */

17
include/BH/Math/Misc.h Normal file
View File

@@ -0,0 +1,17 @@
#ifndef BH_MATH_MISC_H
#define BH_MATH_MISC_H
#include "../Common.h"
float BH_Lerpf(float a, float b, float t);
void BH_Triangle3fBarycentric(const float a[3],
const float b[3],
const float c[3],
const float point[3],
float out[3]);
#endif /* BH_MATH_MISC */

24
include/BH/Math/Plane.h Normal file
View File

@@ -0,0 +1,24 @@
#ifndef BH_MATH_PLANE_H
#define BH_MATH_PLANE_H
#include "../Common.h"
int BH_PlaneFromPoints(const float a[3],
const float b[3],
const float c[3],
float out[4]);
float BH_PlaneDistance(const float plane[4],
const float point[3]);
void BH_PlaneClosestPoint(const float plane[4],
const float point[3],
float out[3]);
#endif /* BH_MATH_PLANE_H */

105
include/BH/Math/Quat.h Normal file
View File

@@ -0,0 +1,105 @@
#ifndef BH_MATH_QUAT_H
#define BH_MATH_QUAT_H
#include "../Common.h"
#include "Vec4f.h"
#define BH_Quat4fAdd(a, b, out) \
BH_Vec4fAdd(a, b, out)
#define BH_Quat4fSub(a, b, out) \
BH_Vec4fSub(a, b, out)
#define BH_Quat4fScale(a, b, out) \
BH_Vec4fScale(a, b, out)
#define BH_Quat4fNegate(in, out) \
BH_Vec4fNegate(in, out)
#define BH_Quat4fDot(a, b) \
BH_Vec4fDot(a, b)
#define BH_Quat4fLength(in) \
BH_Vec4fLength(in)
#define BH_Quat4fNormal(in, out) \
BH_Vec4fNormal(in, out)
#define BH_Quat4fLerp(a, b, t, out) \
BH_Vec4fLerp(a, b, t, out)
void BH_Quat4fIdentity(float out[4]);
void BH_Quat4fConjugate(const float in[4],
float out[4]);
void BH_Quat4fInverse(const float in[4],
float out[4]);
void BH_Quat4fMul(const float a[4],
const float b[4],
float out[4]);
void BH_Quat4fSlerp(const float a[4],
const float b[4],
float t,
float out[4]);
void BH_Quat4fFromEuler(float roll,
float pitch,
float yaw,
float out[4]);
void BH_Quat4fFromAxis(const float axis[3],
float angle,
float out[4]);
void BH_Quat4fToEuler(const float in[4],
float *roll,
float *pitch,
float *yaw);
void BH_Quat4fToAxis(const float in[4],
float axis[3],
float *angle);
void BH_Quat4fToMat4f(const float in[4],
float out[16]);
#endif /* BH_MATH_QUAT */

76
include/BH/Math/Ray2f.h Normal file
View File

@@ -0,0 +1,76 @@
#ifndef BH_MATH_RAY2F_H
#define BH_MATH_RAY2F_H
#include "../Common.h"
int BH_Ray2fIntersectLine(const float start[2],
const float direction[2],
const float line[3],
float *t,
float out[2]);
int BH_Ray2fIntersectTime(const float aStart[2],
const float aDirection[2],
const float bStart[2],
const float bDirection[2],
float *time1,
float *time2);
int BH_Ray2fIntersectRay(const float aStart[2],
const float aDirection[2],
const float bStart[2],
const float bDirection[2],
float *t,
float out[2]);
int BH_Ray2fIntersectSegment(const float aStart[2],
const float aDirection[2],
const float bStart[2],
const float bEnd[2],
float *t,
float out[2]);
int BH_Segment2fIntersectLine(const float start[2],
const float end[2],
const float line[3],
float *t,
float out[2]);
int BH_Segment2fIntersectSegment(const float aStart[2],
const float aEnd[2],
const float bStart[2],
const float bEnd[2],
float *t,
float out[2]);
int BH_Ray2fIntersectBox2f(const float aStart[2],
const float aDirection[2],
const float bMin[2],
const float bMax[2],
float *t,
float out[2]);
int BH_Segment2fIntersectBox2f(const float aStart[2],
const float aEnd[2],
const float bMin[2],
const float bMax[2],
float *t,
float out[2]);
#endif /* BH_MATH_RAY2F_H */

58
include/BH/Math/Ray3f.h Normal file
View File

@@ -0,0 +1,58 @@
#ifndef BH_MATH_RAY3F_H
#define BH_MATH_RAY3F_H
#include "../Common.h"
int BH_Ray3fIntersectPlane(const float start[3],
const float direction[3],
const float plane[4],
float *t,
float out[3]);
int BH_Ray3fIntersectTriangle(const float start[3],
const float direction[3],
const float a[3],
const float b[3],
const float c[3],
float *t,
float out[3]);
int BH_Segment3fIntersectPlane(const float start[3],
const float end[3],
const float plane[4],
float *t,
float out[3]);
int BH_Segment3fIntersectTriangle(const float start[3],
const float end[3],
const float a[3],
const float b[3],
const float c[3],
float *t,
float out[3]);
int BH_Ray3fIntersectBox3f(const float aStart[3],
const float aDirection[3],
const float bMin[3],
const float bMax[3],
float *t,
float out[3]);
int BH_Segment3fIntersectBox3f(const float aStart[3],
const float aEnd[3],
const float bMin[3],
const float bMax[3],
float *t,
float out[3]);
#endif /* BH_MATH_RAY3F_H */

100
include/BH/Math/Vec2f.h Normal file
View File

@@ -0,0 +1,100 @@
#ifndef BH_MATH_VEC2F_H
#define BH_MATH_VEC2F_H
#include "../Common.h"
void BH_Vec2fAdd(const float a[2],
const float b[2],
float out[2]);
void BH_Vec2fSub(const float a[2],
const float b[2],
float out[2]);
void BH_Vec2fMul(const float a[2],
const float b[2],
float out[2]);
void BH_Vec2fScale(const float a[2],
float b,
float out[2]);
void BH_Vec2fMulAdd(const float a[2],
const float b[2],
const float c[2],
float out[2]);
void BH_Vec2fNegate(const float in[2],
float out[2]);
float BH_Vec2fDot(const float a[2],
const float b[2]);
float BH_Vec2fCross(const float a[2],
const float b[2]);
float BH_Vec2fLength(const float in[2]);
void BH_Vec2fNormal(const float in[2],
float out[2]);
float BH_Vec2fNormalEx(const float in[2],
float out[2]);
void BH_Vec2fMin(const float a[2],
const float b[2],
float out[2]);
void BH_Vec2fMax(const float a[2],
const float b[2],
float out[2]);
void BH_Vec2fLerp(const float a[2],
const float b[2],
float t,
float out[2]);
void BH_Vec2fProject(const float a[2],
const float b[2],
float out[2]);
void BH_Vec2fBarycentric(const float a[2],
const float b[2],
const float c[2],
float v,
float w,
float out[2]);
#endif /* BH_MATH_VEC2F */

52
include/BH/Math/Vec2i.h Normal file
View File

@@ -0,0 +1,52 @@
#ifndef BH_MATH_VEC2I_H
#define BH_MATH_VEC2I_H
#include "../Common.h"
void BH_Vec2iAdd(const int a[2],
const int b[2],
int out[2]);
void BH_Vec2iSub(const int a[2],
const int b[2],
int out[2]);
void BH_Vec2iMul(const int a[2],
const int b[2],
int out[2]);
void BH_Vec2iScale(const int a[2],
int b,
int out[2]);
void BH_Vec2iMulAdd(const int a[2],
const int b[2],
const int c[2],
int out[2]);
void BH_Vec2iNegate(const int in[2],
int out[2]);
void BH_Vec2iMin(const int a[2],
const int b[2],
int out[2]);
void BH_Vec2iMax(const int a[2],
const int b[2],
int out[2]);
#endif /* BH_MATH_VEC2I */

100
include/BH/Math/Vec3f.h Normal file
View File

@@ -0,0 +1,100 @@
#ifndef BH_MATH_VEC3F_H
#define BH_MATH_VEC3F_H
#include "../Common.h"
void BH_Vec3fAdd(const float a[3],
const float b[3],
float out[3]);
void BH_Vec3fSub(const float a[3],
const float b[3],
float out[3]);
void BH_Vec3fMul(const float a[3],
const float b[3],
float out[3]);
void BH_Vec3fScale(const float a[3],
float b,
float out[3]);
void BH_Vec3fMulAdd(const float a[3],
const float b[3],
const float c[3],
float out[3]);
void BH_Vec3fNegate(const float in[3],
float out[3]);
float BH_Vec3fDot(const float a[3],
const float b[3]);
void BH_Vec3fCross(const float a[3],
const float b[3],
float out[3]);
float BH_Vec3fLength(const float in[3]);
void BH_Vec3fNormal(const float in[3],
float out[3]);
float BH_Vec3fNormalEx(const float in[3],
float out[3]);
void BH_Vec3fMin(const float a[3],
const float b[3],
float out[3]);
void BH_Vec3fMax(const float a[3],
const float b[3],
float out[3]);
void BH_Vec3fLerp(const float a[3],
const float b[3],
float t,
float out[3]);
void BH_Vec3fProject(const float a[3],
const float b[3],
float out[3]);
void BH_Vec3fBarycentric(const float a[3],
const float b[3],
const float c[3],
float v,
float w,
float out[3]);
#endif /* BH_MATH_VEC3F_H */

53
include/BH/Math/Vec3i.h Normal file
View File

@@ -0,0 +1,53 @@
#ifndef BH_MATH_VEC3I_H
#define BH_MATH_VEC3I_H
#include "../Common.h"
void BH_Vec3iAdd(const int a[3],
const int b[3],
int out[3]);
void BH_Vec3iSub(const int a[3],
const int b[3],
int out[3]);
void BH_Vec3iMul(const int a[3],
const int b[3],
int out[3]);
void BH_Vec3iScale(const int a[3],
int b,
int out[3]);
void BH_Vec3iMulAdd(const int a[3],
const int b[3],
const int c[3],
int out[3]);
void BH_Vec3iNegate(const int in[3],
int out[3]);
void BH_Vec3iMin(const int a[3],
const int b[3],
int out[3]);
void BH_Vec3iMax(const int a[3],
const int b[3],
int out[3]);
#endif /* BH_MATH_VEC3I */

80
include/BH/Math/Vec4f.h Normal file
View File

@@ -0,0 +1,80 @@
#ifndef BH_MATH_VEC4F_H
#define BH_MATH_VEC4F_H
#include "../Common.h"
void BH_Vec4fAdd(const float a[4],
const float b[4],
float out[4]);
void BH_Vec4fSub(const float a[4],
const float b[4],
float out[4]);
void BH_Vec4fMul(const float a[4],
const float b[4],
float out[4]);
void BH_Vec4fScale(const float a[4],
float b,
float out[4]);
void BH_Vec4fMulAdd(const float a[4],
const float b[4],
const float c[4],
float out[4]);
void BH_Vec4fNegate(const float in[4],
float out[4]);
float BH_Vec4fDot(const float a[4],
const float b[4]);
float BH_Vec4fLength(const float in[4]);
void BH_Vec4fNormal(const float in[4],
float out[4]);
float BH_Vec4fNormalEx(const float in[4],
float out[4]);
void BH_Vec4fMin(const float a[4],
const float b[4],
float out[4]);
void BH_Vec4fMax(const float a[4],
const float b[4],
float out[4]);
void BH_Vec4fLerp(const float a[4],
const float b[4],
float t,
float out[4]);
void BH_Vec4fProject(const float a[4],
const float b[4],
float out[4]);
void BH_Vec4fBarycentric(const float a[4],
const float b[4],
const float c[4],
float v,
float w,
float out[4]);
#endif /* BH_MATH_VEC4F */

54
include/BH/Math/Vec4i.h Normal file
View File

@@ -0,0 +1,54 @@
#ifndef BH_MATH_VEC4I_H
#define BH_MATH_VEC4I_H
#include "../Common.h"
void BH_Vec4iAdd(const int a[4],
const int b[4],
int out[4]);
void BH_Vec4iSub(const int a[4],
const int b[4],
int out[4]);
void BH_Vec4iMul(const int a[4],
const int b[4],
int out[4]);
void BH_Vec4iScale(const int a[4],
int b,
int out[4]);
void BH_Vec4iMulAdd(const int a[4],
const int b[4],
const int c[4],
int out[4]);
void BH_Vec4iNegate(const int in[4],
int out[4]);
void BH_Vec4iMin(const int a[4],
const int b[4],
int out[4]);
void BH_Vec4iMax(const int a[4],
const int b[4],
int out[4]);
#endif /* BH_MATH_VEC4I */