#ifdef _MSC_VER
#pragma warning(disable:4996)
#endif
namespace FLOAT_MATH
{
void fm_inverseRT(const REAL matrix[16],const REAL pos[3],REAL t[3])
{ … }
REAL fm_getDeterminant(const REAL matrix[16])
{ … }
REAL fm_squared(REAL x) { return x*x; };
void fm_decomposeTransform(const REAL local_transform[16],REAL trans[3],REAL rot[4],REAL scale[3])
{ … }
void fm_getSubMatrix(int32_t ki,int32_t kj,REAL pDst[16],const REAL matrix[16])
{ … }
void fm_inverseTransform(const REAL matrix[16],REAL inverse_matrix[16])
{ … }
void fm_identity(REAL matrix[16])
{ … }
void fm_quatToEuler(const REAL quat[4],REAL &ax,REAL &ay,REAL &az)
{ … }
void fm_eulerToMatrix(REAL ax,REAL ay,REAL az,REAL *matrix)
{ … }
void fm_getAABB(uint32_t vcount,const REAL *points,uint32_t pstride,REAL *bmin,REAL *bmax)
{ … }
void fm_eulerToQuat(const REAL *euler,REAL *quat)
{ … }
void fm_eulerToQuat(REAL roll,REAL pitch,REAL yaw,REAL *quat)
{ … }
void fm_quatToMatrix(const REAL *quat,REAL *matrix)
{ … }
void fm_quatRotate(const REAL *quat,const REAL *v,REAL *r)
{ … }
void fm_getTranslation(const REAL *matrix,REAL *t)
{ … }
void fm_matrixToQuat(const REAL *matrix,REAL *quat)
{ … }
REAL fm_sphereVolume(REAL radius)
{ … }
REAL fm_cylinderVolume(REAL radius,REAL h)
{ … }
REAL fm_capsuleVolume(REAL radius,REAL h)
{ … }
void fm_transform(const REAL matrix[16],const REAL v[3],REAL t[3])
{ … }
void fm_rotate(const REAL matrix[16],const REAL v[3],REAL t[3])
{ … }
REAL fm_distance(const REAL *p1,const REAL *p2)
{ … }
REAL fm_distanceSquared(const REAL *p1,const REAL *p2)
{ … }
REAL fm_distanceSquaredXZ(const REAL *p1,const REAL *p2)
{ … }
REAL fm_computePlane(const REAL *A,const REAL *B,const REAL *C,REAL *n)
{ … }
REAL fm_distToPlane(const REAL *plane,const REAL *p)
{ … }
REAL fm_dot(const REAL *p1,const REAL *p2)
{ … }
void fm_cross(REAL *cross,const REAL *a,const REAL *b)
{ … }
REAL fm_computeNormalVector(REAL *n,const REAL *p1,const REAL *p2)
{ … }
bool fm_computeWindingOrder(const REAL *p1,const REAL *p2,const REAL *p3)
{ … }
REAL fm_normalize(REAL *n)
{ … }
void fm_matrixMultiply(const REAL *pA,const REAL *pB,REAL *pM)
{ … }
void fm_eulerToQuatDX(REAL x,REAL y,REAL z,REAL *quat)
{ … }
void fm_eulerToMatrixDX(REAL x,REAL y,REAL z,REAL *matrix)
{ … }
void fm_scale(REAL x,REAL y,REAL z,REAL *fscale)
{ … }
void fm_composeTransform(const REAL *position,const REAL *quat,const REAL *scale,REAL *matrix)
{ … }
void fm_setTranslation(const REAL *translation,REAL *matrix)
{ … }
static REAL enorm0_3d ( REAL x0, REAL y0, REAL z0, REAL x1, REAL y1, REAL z1 )
{ … }
static REAL triangle_area_3d ( REAL x1, REAL y1, REAL z1, REAL x2,REAL y2, REAL z2, REAL x3, REAL y3, REAL z3 )
{ … }
REAL fm_computeArea(const REAL *p1,const REAL *p2,const REAL *p3)
{ … }
void fm_lerp(const REAL *p1,const REAL *p2,REAL *dest,REAL lerpValue)
{ … }
bool fm_pointTestXZ(const REAL *p,const REAL *i,const REAL *j)
{
bool ret = false;
if (((( i[2] <= p[2] ) && ( p[2] < j[2] )) || (( j[2] <= p[2] ) && ( p[2] < i[2] ))) && ( p[0] < (j[0] - i[0]) * (p[2] - i[2]) / (j[2] - i[2]) + i[0]))
ret = true;
return ret;
};
bool fm_insideTriangleXZ(const REAL *p,const REAL *p1,const REAL *p2,const REAL *p3)
{ … }
bool fm_insideAABB(const REAL *pos,const REAL *bmin,const REAL *bmax)
{ … }
uint32_t fm_clipTestPoint(const REAL *bmin,const REAL *bmax,const REAL *pos)
{ … }
uint32_t fm_clipTestPointXZ(const REAL *bmin,const REAL *bmax,const REAL *pos)
{ … }
uint32_t fm_clipTestAABB(const REAL *bmin,const REAL *bmax,const REAL *p1,const REAL *p2,const REAL *p3,uint32_t &andCode)
{ … }
bool intersect(const REAL *si,const REAL *ei,const REAL *bmin,const REAL *bmax,REAL *time)
{ … }
bool fm_lineTestAABB(const REAL *p1,const REAL *p2,const REAL *bmin,const REAL *bmax,REAL &time)
{ … }
bool fm_lineTestAABBXZ(const REAL *p1,const REAL *p2,const REAL *bmin,const REAL *bmax,REAL &time)
{ … }
void fm_minmax(const REAL *p,REAL *bmin,REAL *bmax)
{ … }
REAL fm_solveX(const REAL *plane,REAL y,REAL z)
{ … }
REAL fm_solveY(const REAL *plane,REAL x,REAL z)
{ … }
REAL fm_solveZ(const REAL *plane,REAL x,REAL y)
{ … }
void fm_getAABBCenter(const REAL *bmin,const REAL *bmax,REAL *center)
{ … }
FM_Axis fm_getDominantAxis(const REAL normal[3])
{ … }
bool fm_lineSphereIntersect(const REAL *center,REAL radius,const REAL *p1,const REAL *p2,REAL *intersect)
{ … }
#define DOT(p1,p2) …
bool fm_raySphereIntersect(const REAL *center,REAL radius,const REAL *pos,const REAL *dir,REAL distance,REAL *intersect)
{ … }
void fm_catmullRom(REAL *out_vector,const REAL *p1,const REAL *p2,const REAL *p3,const REAL *p4, const REAL s)
{ … }
bool fm_intersectAABB(const REAL *bmin1,const REAL *bmax1,const REAL *bmin2,const REAL *bmax2)
{ … }
bool fm_insideAABB(const REAL *obmin,const REAL *obmax,const REAL *tbmin,const REAL *tbmax)
{ … }
void fm_rotationArc(const REAL *v0,const REAL *v1,REAL *quat)
{ … }
REAL fm_distancePointLineSegment(const REAL *Point,const REAL *LineStart,const REAL *LineEnd,REAL *intersection,LineSegmentType &type,REAL epsilon)
{ … }
#ifndef BEST_FIT_PLANE_H
#define BEST_FIT_PLANE_H
template <class Type> class Eigen
{ … };
#endif
bool fm_computeBestFitPlane(uint32_t vcount,
const REAL *points,
uint32_t vstride,
const REAL *weights,
uint32_t wstride,
REAL *plane,
REAL *center)
{ … }
bool fm_colinear(const REAL a1[3],const REAL a2[3],const REAL b1[3],const REAL b2[3],REAL epsilon)
{ … }
bool fm_colinear(const REAL *p1,const REAL *p2,const REAL *p3,REAL epsilon)
{ … }
void fm_initMinMax(const REAL *p,REAL *bmin,REAL *bmax)
{ … }
IntersectResult fm_intersectLineSegments2d(const REAL *a1,const REAL *a2,const REAL *b1,const REAL *b2,REAL *intersection)
{ … }
IntersectResult fm_intersectLineSegments2dTime(const REAL *a1,const REAL *a2,const REAL *b1,const REAL *b2,REAL &t1,REAL &t2)
{ … }
bool fm_intersectPointPlane(const REAL *p1,const REAL *p2,REAL *split,const REAL *plane)
{ … }
PlaneTriResult fm_getSidePlane(const REAL *p,const REAL *plane,REAL epsilon)
{ … }
#ifndef PLANE_TRIANGLE_INTERSECTION_H
#define PLANE_TRIANGLE_INTERSECTION_H
#define MAXPTS …
template <class Type> class point
{ … };
template <class Type> class plane
{ … };
template <class Type> class polygon
{ … };
#endif
static inline void add(const REAL *p,REAL *dest,uint32_t tstride,uint32_t &pcount)
{ … }
PlaneTriResult fm_planeTriIntersection(const REAL *_plane,
const REAL *triangle,
uint32_t tstride,
REAL epsilon,
REAL *front,
uint32_t &fcount,
REAL *back,
uint32_t &bcount)
{ … }
void computeOBB(uint32_t vcount,const REAL *points,uint32_t pstride,REAL *sides,REAL *matrix)
{ … }
void fm_computeBestFitOBB(uint32_t vcount,const REAL *points,uint32_t pstride,REAL *sides,REAL *matrix,bool bruteForce)
{ … }
void fm_computeBestFitOBB(uint32_t vcount,const REAL *points,uint32_t pstride,REAL *sides,REAL *pos,REAL *quat,bool bruteForce)
{ … }
void fm_computeBestFitABB(uint32_t vcount,const REAL *points,uint32_t pstride,REAL *sides,REAL *pos)
{ … }
void fm_planeToMatrix(const REAL *plane,REAL *matrix)
{ … }
void fm_planeToQuat(const REAL *plane,REAL *quat,REAL *pos)
{ … }
void fm_eulerMatrix(REAL ax,REAL ay,REAL az,REAL *matrix)
{ … }
#ifndef VERTEX_INDEX_H
#define VERTEX_INDEX_H
namespace VERTEX_INDEX
{
class KdTreeNode;
KdTreeNodeVector;
enum Axes
{ … };
class KdTreeFindNode
{ … };
class KdTreeInterface
{ … };
class KdTreeNode
{ … };
#define MAX_BUNDLE_SIZE …
class KdTreeNodeBundle
{ … };
DoubleVector;
FloatVector;
class KdTree : public KdTreeInterface
{ … };
};
class MyVertexIndex : public fm_VertexIndex
{ … };
fm_VertexIndex * fm_createVertexIndex(double granularity,bool snapToGrid)
{ … }
fm_VertexIndex * fm_createVertexIndex(float granularity,bool snapToGrid)
{ … }
void fm_releaseVertexIndex(fm_VertexIndex *vindex)
{ … }
#endif
REAL fm_computeBestFitAABB(uint32_t vcount,const REAL *points,uint32_t pstride,REAL *bmin,REAL *bmax)
{ … }
#define vector(a,b,c) …
#define innerProduct(v,q) …
#define crossProduct(a,b,c) …
bool fm_lineIntersectsTriangle(const REAL *rayStart,const REAL *rayEnd,const REAL *p1,const REAL *p2,const REAL *p3,REAL *sect)
{ … }
bool fm_rayIntersectsTriangle(const REAL *p,const REAL *d,const REAL *v0,const REAL *v1,const REAL *v2,REAL &t)
{ … }
inline REAL det(const REAL *p1,const REAL *p2,const REAL *p3)
{ … }
REAL fm_computeMeshVolume(const REAL *vertices,uint32_t tcount,const uint32_t *indices)
{ … }
const REAL * fm_getPoint(const REAL *points,uint32_t pstride,uint32_t index)
{ … }
bool fm_insideTriangle(REAL Ax, REAL Ay,
REAL Bx, REAL By,
REAL Cx, REAL Cy,
REAL Px, REAL Py)
{ … }
REAL fm_areaPolygon2d(uint32_t pcount,const REAL *points,uint32_t pstride)
{ … }
bool fm_pointInsidePolygon2d(uint32_t pcount,const REAL *points,uint32_t pstride,const REAL *point,uint32_t xindex,uint32_t yindex)
{ … }
uint32_t fm_consolidatePolygon(uint32_t pcount,const REAL *points,uint32_t pstride,REAL *_dest,REAL epsilon)
{ … }
#ifndef RECT3D_TEMPLATE
#define RECT3D_TEMPLATE
template <class T> class Rect3d
{ … };
#endif
void splitRect(uint32_t axis,
const Rect3d<REAL> &source,
Rect3d<REAL> &b1,
Rect3d<REAL> &b2,
const REAL *midpoint)
{ … }
bool fm_computeSplitPlane(uint32_t vcount,
const REAL *vertices,
uint32_t ,
const uint32_t * ,
REAL *plane)
{ … }
#pragma warning(disable:4100)
void fm_nearestPointInTriangle(const REAL * ,const REAL * ,const REAL * ,const REAL * ,REAL * )
{ … }
static REAL Partial(const REAL *a,const REAL *p)
{ … }
REAL fm_areaTriangle(const REAL *p0,const REAL *p1,const REAL *p2)
{ … }
void fm_subtract(const REAL *A,const REAL *B,REAL *diff)
{ … }
void fm_multiplyTransform(const REAL *pA,const REAL *pB,REAL *pM)
{ … }
void fm_multiply(REAL *A,REAL scaler)
{ … }
void fm_add(const REAL *A,const REAL *B,REAL *sum)
{ … }
void fm_copy3(const REAL *source,REAL *dest)
{ … }
uint32_t fm_copyUniqueVertices(uint32_t vcount,const REAL *input_vertices,REAL *output_vertices,uint32_t tcount,const uint32_t *input_indices,uint32_t *output_indices)
{ … }
bool fm_isMeshCoplanar(uint32_t tcount,const uint32_t *indices,const REAL *vertices,bool doubleSided)
{ … }
bool fm_samePlane(const REAL p1[4],const REAL p2[4],REAL normalEpsilon,REAL dEpsilon,bool doubleSided)
{ … }
void fm_initMinMax(REAL bmin[3],REAL bmax[3])
{ … }
void fm_inflateMinMax(REAL bmin[3], REAL bmax[3], REAL ratio)
{ … }
#ifndef TESSELATE_H
#define TESSELATE_H
UintVector;
class Myfm_Tesselate : public fm_Tesselate
{ … };
fm_Tesselate * fm_createTesselate(void)
{ … }
void fm_releaseTesselate(fm_Tesselate *t)
{ … }
#endif
#ifndef RAY_ABB_INTERSECT
#define RAY_ABB_INTERSECT
#define IR(x) …
#define RAYAABB_EPSILON …
bool fm_intersectRayAABB(const float MinB[3],const float MaxB[3],const float origin[3],const float dir[3],float coord[3])
{ … }
bool fm_intersectLineSegmentAABB(const float bmin[3],const float bmax[3],const float p1[3],const float p2[3],float intersect[3])
{ … }
#endif
#ifndef OBB_TO_AABB
#define OBB_TO_AABB
#pragma warning(disable:4100)
void fm_OBBtoAABB(const float [3],const float [3],const float [16],float [3],float [3])
{ … }
const REAL * computePos(uint32_t index,const REAL *vertices,uint32_t vstride)
{ … }
void computeNormal(uint32_t index,REAL *normals,uint32_t nstride,const REAL *normal)
{ … }
void fm_computeMeanNormals(uint32_t vcount,
const REAL *vertices,
uint32_t vstride,
REAL *normals,
uint32_t nstride,
uint32_t tcount,
const uint32_t *indices)
{ … }
#endif
#define BIGNUMBER …
static inline void Set(REAL *n,REAL x,REAL y,REAL z)
{
n[0] = x;
n[1] = y;
n[2] = z;
};
static inline void Copy(REAL *dest,const REAL *source)
{ … }
REAL fm_computeBestFitSphere(uint32_t vcount,const REAL *points,uint32_t pstride,REAL *center)
{ … }
void fm_computeBestFitCapsule(uint32_t vcount,const REAL *points,uint32_t pstride,REAL &radius,REAL &height,REAL matrix[16],bool bruteForce)
{ … }
#ifndef TRIANGULATE_H
#define TRIANGULATE_H
TU32;
class TVec
{ … };
TVecVector;
TU32Vector;
class CTriangulator
{ … };
CTriangulator::CTriangulator(void)
{ … }
CTriangulator::~CTriangulator()
{ … }
void CTriangulator::triangulate(TU32Vector &indices)
{ … }
void CTriangulator::_process(TU32Vector &indices)
{ … }
double CTriangulator::_area()
{ … }
bool CTriangulator::_snip(int32_t u, int32_t v, int32_t w, int32_t n, int32_t *V)
{ … }
bool CTriangulator::_insideTriangle(const TVec& A, const TVec& B, const TVec& C,const TVec& P)
{ … }
class Triangulate : public fm_Triangulate
{ … };
fm_Triangulate * fm_createTriangulate(void)
{ … }
void fm_releaseTriangulate(fm_Triangulate *t)
{ … }
#endif
bool validDistance(const REAL *p1,const REAL *p2,REAL epsilon)
{ … }
bool fm_isValidTriangle(const REAL *p1,const REAL *p2,const REAL *p3,REAL epsilon)
{ … }
void fm_multiplyQuat(const REAL *left,const REAL *right,REAL *quat)
{ … }
bool fm_computeCentroid(uint32_t vcount,
const REAL *points,
REAL *center)
{ … }
bool fm_computeCentroid(uint32_t vcount,
const REAL *points,
uint32_t triCount,
const uint32_t *indices,
REAL *center)
{ … }
#ifndef TEMPLATE_VEC3
#define TEMPLATE_VEC3
template <class Type> class Vec3
{ … };
#endif
void fm_transformAABB(const REAL bmin[3],const REAL bmax[3],const REAL matrix[16],REAL tbmin[3],REAL tbmax[3])
{ … }
REAL fm_normalizeQuat(REAL n[4])
{ … }
};