You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Overloaded basic math funcs (double and float variants). Use real_t rather than float or double in generic functions (core/math) whenever possible.
Also inlined some more math functions.
This commit is contained in:
@@ -28,19 +28,19 @@
|
||||
/*************************************************************************/
|
||||
#include "triangulate.h"
|
||||
|
||||
float Triangulate::get_area(const Vector<Vector2> &contour)
|
||||
real_t Triangulate::get_area(const Vector<Vector2> &contour)
|
||||
{
|
||||
|
||||
int n = contour.size();
|
||||
const Vector2 *c=&contour[0];
|
||||
|
||||
float A=0.0f;
|
||||
real_t A=0.0;
|
||||
|
||||
for(int p=n-1,q=0; q<n; p=q++)
|
||||
{
|
||||
A+= c[p].cross(c[q]);
|
||||
}
|
||||
return A*0.5f;
|
||||
return A*0.5;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -48,14 +48,14 @@ float Triangulate::get_area(const Vector<Vector2> &contour)
|
||||
defined by A, B, C.
|
||||
*/
|
||||
|
||||
bool Triangulate::is_inside_triangle(float Ax, float Ay,
|
||||
float Bx, float By,
|
||||
float Cx, float Cy,
|
||||
float Px, float Py)
|
||||
bool Triangulate::is_inside_triangle(real_t Ax, real_t Ay,
|
||||
real_t Bx, real_t By,
|
||||
real_t Cx, real_t Cy,
|
||||
real_t Px, real_t Py)
|
||||
|
||||
{
|
||||
float ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy;
|
||||
float cCROSSap, bCROSScp, aCROSSbp;
|
||||
real_t ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy;
|
||||
real_t cCROSSap, bCROSScp, aCROSSbp;
|
||||
|
||||
ax = Cx - Bx; ay = Cy - By;
|
||||
bx = Ax - Cx; by = Ay - Cy;
|
||||
@@ -68,13 +68,13 @@ bool Triangulate::is_inside_triangle(float Ax, float Ay,
|
||||
cCROSSap = cx*apy - cy*apx;
|
||||
bCROSScp = bx*cpy - by*cpx;
|
||||
|
||||
return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f));
|
||||
return ((aCROSSbp >= 0.0) && (bCROSScp >= 0.0) && (cCROSSap >= 0.0));
|
||||
};
|
||||
|
||||
bool Triangulate::snip(const Vector<Vector2> &p_contour,int u,int v,int w,int n,const Vector<int>& V)
|
||||
{
|
||||
int p;
|
||||
float Ax, Ay, Bx, By, Cx, Cy, Px, Py;
|
||||
real_t Ax, Ay, Bx, By, Cx, Cy, Px, Py;
|
||||
const Vector2 *contour=&p_contour[0];
|
||||
|
||||
Ax = contour[V[u]].x;
|
||||
@@ -112,7 +112,7 @@ bool Triangulate::triangulate(const Vector<Vector2> &contour,Vector<int> &result
|
||||
|
||||
/* we want a counter-clockwise polygon in V */
|
||||
|
||||
if ( 0.0f < get_area(contour) )
|
||||
if ( 0.0 < get_area(contour) )
|
||||
for (int v=0; v<n; v++) V[v] = v;
|
||||
else
|
||||
for(int v=0; v<n; v++) V[v] = (n-1)-v;
|
||||
|
||||
Reference in New Issue
Block a user