forked from bartvdbraak/blender
replace macros with math functions
This commit is contained in:
parent
9087cb91d4
commit
707fcc42a3
@ -869,8 +869,8 @@ int BLI_edgefill(short mat_nr)
|
||||
if( compare_v3v3(v2, eve->co, COMPLIMIT)==0) {
|
||||
float inner = angle_v3v3v3(v1, v2, eve->co);
|
||||
|
||||
if (fabs(inner-M_PI) < limit || fabs(inner) < limit) {
|
||||
eve = eve->next;
|
||||
if (fabsf(inner-M_PI) < limit || fabsf(inner) < limit) {
|
||||
eve = eve->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -621,7 +621,7 @@ void BM_multires_smooth_bounds(BMesh *bm, BMFace *f)
|
||||
y
|
||||
*****/
|
||||
|
||||
sides = sqrt(mdp->totdisp);
|
||||
sides = (int)sqrt(mdp->totdisp);
|
||||
for (y=0; y<sides; y++) {
|
||||
add_v3_v3v3(co1, mdn->disps[y*sides], mdl->disps[y]);
|
||||
mul_v3_fl(co1, 0.5);
|
||||
@ -660,7 +660,7 @@ void BM_multires_smooth_bounds(BMesh *bm, BMFace *f)
|
||||
else
|
||||
mdl2 = CustomData_bmesh_get(&bm->ldata, l->radial_next->next->head.data, CD_MDISPS);
|
||||
|
||||
sides = sqrt(mdl1->totdisp);
|
||||
sides = (int)sqrt(mdl1->totdisp);
|
||||
for (y=0; y<sides; y++) {
|
||||
int a1, a2, o1, o2;
|
||||
|
||||
@ -729,12 +729,12 @@ void BM_loop_interp_from_face(BMesh *bm, BMLoop *target, BMFace *source,
|
||||
|
||||
/* find best projection of face XY, XZ or YZ: barycentric weights of
|
||||
the 2d projected coords are the same and faster to compute */
|
||||
xn= (float)fabs(source->no[0]);
|
||||
yn= (float)fabs(source->no[1]);
|
||||
zn= (float)fabs(source->no[2]);
|
||||
if(zn>=xn && zn>=yn) {ax= 0; ay= 1;}
|
||||
else if(yn>=xn && yn>=zn) {ax= 0; ay= 2;}
|
||||
else {ax= 1; ay= 2;}
|
||||
xn= fabsf(source->no[0]);
|
||||
yn= fabsf(source->no[1]);
|
||||
zn= fabsf(source->no[2]);
|
||||
if (zn >= xn && zn >= yn) { ax= 0; ay= 1; }
|
||||
else if (yn >= xn && yn >= zn) { ax= 0; ay= 2; }
|
||||
else { ax= 1; ay= 2; }
|
||||
|
||||
/* scale source face coordinates a bit, so points sitting directonly on an
|
||||
edge will work.*/
|
||||
|
@ -589,7 +589,7 @@ static int bmesh_loop_reverse_loop(BMesh *bm, BMFace *f, BMLoopList *lst)
|
||||
if (!md->totdisp || !md->disps)
|
||||
continue;
|
||||
|
||||
sides=sqrt(md->totdisp);
|
||||
sides= (int)sqrt(md->totdisp);
|
||||
co = md->disps;
|
||||
|
||||
for (x=0; x<sides; x++) {
|
||||
|
@ -108,12 +108,13 @@ static void compute_poly_normal(float normal[3], float (*verts)[3], int nverts)
|
||||
#if 0
|
||||
sub_v3_v3v3(v1, w, v);
|
||||
sub_v3_v3v3(v2, v, u);
|
||||
Normalize_d(v1);
|
||||
Normalize_d(v2);
|
||||
normalize_v3(v1);
|
||||
normalize_v3(v2);
|
||||
|
||||
l = INPR(v1, v2);
|
||||
if (ABS(l-1.0) < 0.1)
|
||||
l = dot_v3v3(v1, v2);
|
||||
if (fabsf(l-1.0) < 0.1f) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
/* newell's method
|
||||
|
||||
@ -516,7 +517,7 @@ void BM_flip_normal(BMesh *bm, BMFace *f)
|
||||
|
||||
/* detects if two line segments cross each other (intersects).
|
||||
note, there could be more winding cases then there needs to be. */
|
||||
static int linecrosses(double *v1, double *v2, double *v3, double *v4)
|
||||
static int UNUSED_FUNCTION(linecrosses)(double *v1, double *v2, double *v3, double *v4)
|
||||
{
|
||||
int w1, w2, w3, w4, w5;
|
||||
|
||||
@ -602,12 +603,13 @@ int BM_Point_In_Face(BMesh *bm, BMFace *f, float co[3])
|
||||
this probably isn't all that accurate, but it has the advantage of
|
||||
being fast (especially compared to projecting into the face orientation)
|
||||
*/
|
||||
xn= (float)fabs(f->no[0]);
|
||||
yn= (float)fabs(f->no[1]);
|
||||
zn= (float)fabs(f->no[2]);
|
||||
if(zn>=xn && zn>=yn) {ax= 0; ay= 1;}
|
||||
else if(yn>=xn && yn>=zn) {ax= 0; ay= 2;}
|
||||
else {ax= 1; ay= 2;}
|
||||
xn= fabsf(f->no[0]);
|
||||
yn= fabsf(f->no[1]);
|
||||
zn= fabsf(f->no[2]);
|
||||
|
||||
if (zn >= xn && zn >= yn) { ax= 0; ay= 1; }
|
||||
else if (yn >= xn && yn >= zn) { ax= 0; ay= 2; }
|
||||
else { ax= 1; ay= 2; }
|
||||
|
||||
co2[0] = co[ax];
|
||||
co2[1] = co[ay];
|
||||
|
@ -457,18 +457,14 @@ int BM_Edge_Share_Faces(BMEdge *e1, BMEdge *e2)
|
||||
|
||||
float BM_Face_Angle(BMesh *UNUSED(bm), BMEdge *e)
|
||||
{
|
||||
BMLoop *l1, *l2;
|
||||
int radlen;
|
||||
float edge_angle_cos = 0.0;
|
||||
|
||||
radlen = BM_Edge_FaceCount(e);
|
||||
if(radlen == 2){
|
||||
l1 = e->l;
|
||||
l2 = e->l->radial_next;
|
||||
edge_angle_cos = INPR(l1->f->no, l2->f->no);
|
||||
if (BM_Edge_FaceCount(e) == 2) {
|
||||
BMLoop *l1= e->l;
|
||||
BMLoop *l2= e->l->radial_next;
|
||||
return acosf(dot_v3v3(l1->f->no, l2->f->no));
|
||||
}
|
||||
else {
|
||||
return (float)M_PI / 2.0f; /* acos(0.0) */
|
||||
}
|
||||
return acos(edge_angle_cos);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -427,7 +427,7 @@ void bmesh_create_monkey_exec(BMesh *bm, BMOperator *op)
|
||||
tv[i]= BM_Make_Vert(bm, v, NULL);
|
||||
BMO_SetFlag(bm, tv[i], VERT_MARK);
|
||||
|
||||
tv[monkeynv+i]= (fabs(v[0]= -v[0])<0.001)?tv[i]: (eve=BM_Make_Vert(bm, v, NULL), mul_m4_v3(mat, eve->co), eve);
|
||||
tv[monkeynv+i]= (fabsf(v[0]= -v[0]) < 0.001f) ? tv[i]: (eve= BM_Make_Vert(bm, v, NULL), mul_m4_v3(mat, eve->co), eve);
|
||||
BMO_SetFlag(bm, tv[monkeynv+i], VERT_MARK);
|
||||
|
||||
mul_m4_v3(mat, tv[i]->co);
|
||||
|
@ -886,10 +886,11 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op)
|
||||
normalize_v3(vec1);
|
||||
normalize_v3(vec2);
|
||||
|
||||
angle = INPR(vec1, vec2);
|
||||
angle = ABS(angle);
|
||||
if (ABS(angle - 1.0f) < 0.01f)
|
||||
angle = dot_v3v3(vec1, vec2);
|
||||
angle = fabsf(angle);
|
||||
if (fabsf(angle - 1.0f) < 0.01f) {
|
||||
totesel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (BMO_TestFlag(bmesh, face, FACE_CUSTOMFILL)) {
|
||||
|
@ -189,7 +189,7 @@ static float BME_bevel_project_vec(float *vec1, float *vec2, float *up_vec, int
|
||||
normalize_v3(vec3);
|
||||
c1 = dot_v3v3(vec3,vec1);
|
||||
c2 = dot_v3v3(vec1,vec1);
|
||||
if (fabs(c1) < 0.000001f || fabs(c2) < 0.000001f) {
|
||||
if (fabsf(c1) < 0.000001f || fabsf(c2) < 0.000001f) {
|
||||
factor = 0.0f;
|
||||
}
|
||||
else {
|
||||
|
@ -126,11 +126,11 @@ int BME_remove_doubles(BME_Mesh *bm, float limit)
|
||||
though) */
|
||||
v2= sb1->v1;
|
||||
if(!(v2->tflag1)) {
|
||||
dist= (float)fabs(v2->co[0]-v->co[0]);
|
||||
dist= fabsf(v2->co[0]-v->co[0]);
|
||||
if(dist<=limit) {
|
||||
dist= (float)fabs(v2->co[1]-v->co[1]);
|
||||
dist= fabsf(v2->co[1]-v->co[1]);
|
||||
if(dist<=limit) {
|
||||
dist= (float)fabs(v2->co[2]-v->co[2]);
|
||||
dist= fabsf(v2->co[2]-v->co[2]);
|
||||
if(dist<=limit) {
|
||||
/*v2 is a double of v. We want to throw out v1 and relink everything to v*/
|
||||
BLI_ghash_insert(vhash,v2, v);
|
||||
|
@ -98,12 +98,12 @@
|
||||
|
||||
#include "editbmesh_bvh.h"
|
||||
|
||||
static void add_normal_aligned(float *nor, float *add)
|
||||
static void add_normal_aligned(float nor[3], const float add[3])
|
||||
{
|
||||
if( INPR(nor, add) < -0.9999f)
|
||||
sub_v3_v3v3(nor, nor, add);
|
||||
if(dot_v3v3(nor, add) < -0.9999f)
|
||||
sub_v3_v3(nor, add);
|
||||
else
|
||||
add_v3_v3v3(nor, nor, add);
|
||||
sub_v3_v3(nor, add);
|
||||
}
|
||||
|
||||
|
||||
@ -783,7 +783,7 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event)
|
||||
|
||||
copy_v3_v3(vec, min);
|
||||
normalize_v3(vec);
|
||||
dot= INPR(vec, nor);
|
||||
dot= dot_v3v3(vec, nor);
|
||||
|
||||
if( fabs(dot)<0.999) {
|
||||
float cross[3], si, q1[4];
|
||||
|
@ -382,7 +382,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
|
||||
if(amd->fit_type == MOD_ARR_FITLENGTH
|
||||
|| amd->fit_type == MOD_ARR_FITCURVE)
|
||||
{
|
||||
float dist = sqrt(INPR(offset[3], offset[3]));
|
||||
float dist = sqrtf(dot_v3v3(offset[3], offset[3]));
|
||||
|
||||
if(dist > 1e-6f)
|
||||
/* this gives length = first copy start to last copy end
|
||||
|
@ -92,7 +92,7 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj
|
||||
if (l->radial_next == l)
|
||||
continue;
|
||||
|
||||
edge_angle_cos = INPR(f->no, l->radial_next->f->no);
|
||||
edge_angle_cos = dot_v3v3(f->no, l->radial_next->f->no);
|
||||
if (edge_angle_cos < threshold) {
|
||||
BMO_SetFlag(bm, l->e, EDGE_MARK);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user