[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41926] branches/bmesh/blender/source/ blender: replace macros with math functions
Campbell Barton
ideasman42 at gmail.com
Wed Nov 16 18:37:21 CET 2011
Revision: 41926
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41926
Author: campbellbarton
Date: 2011-11-16 17:37:20 +0000 (Wed, 16 Nov 2011)
Log Message:
-----------
replace macros with math functions
Modified Paths:
--------------
branches/bmesh/blender/source/blender/blenlib/intern/scanfill.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_interp.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_polygon.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_queries.c
branches/bmesh/blender/source/blender/bmesh/operators/primitiveops.c
branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c
branches/bmesh/blender/source/blender/bmesh/tools/BME_bevel.c
branches/bmesh/blender/source/blender/bmesh/tools/BME_weld.c
branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c
branches/bmesh/blender/source/blender/modifiers/intern/MOD_array.c
branches/bmesh/blender/source/blender/modifiers/intern/MOD_edgesplit.c
Modified: branches/bmesh/blender/source/blender/blenlib/intern/scanfill.c
===================================================================
--- branches/bmesh/blender/source/blender/blenlib/intern/scanfill.c 2011-11-16 17:09:41 UTC (rev 41925)
+++ branches/bmesh/blender/source/blender/blenlib/intern/scanfill.c 2011-11-16 17:37:20 UTC (rev 41926)
@@ -869,8 +869,8 @@
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;
}
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_interp.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_interp.c 2011-11-16 17:09:41 UTC (rev 41925)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_interp.c 2011-11-16 17:37:20 UTC (rev 41926)
@@ -621,7 +621,7 @@
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 @@
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 @@
/* 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.*/
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c 2011-11-16 17:09:41 UTC (rev 41925)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c 2011-11-16 17:37:20 UTC (rev 41926)
@@ -589,7 +589,7 @@
if (!md->totdisp || !md->disps)
continue;
- sides=sqrt(md->totdisp);
+ sides= (int)sqrt(md->totdisp);
co = md->disps;
for (x=0; x<sides; x++) {
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_polygon.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_polygon.c 2011-11-16 17:09:41 UTC (rev 41925)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_polygon.c 2011-11-16 17:37:20 UTC (rev 41926)
@@ -108,12 +108,13 @@
#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 @@
/* 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,13 +603,14 @@
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];
co2[2] = 0;
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_queries.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_queries.c 2011-11-16 17:09:41 UTC (rev 41925)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_queries.c 2011-11-16 17:37:20 UTC (rev 41926)
@@ -457,18 +457,14 @@
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));
}
- return acos(edge_angle_cos);
-
+ else {
+ return (float)M_PI / 2.0f; /* acos(0.0) */
+ }
}
/*
Modified: branches/bmesh/blender/source/blender/bmesh/operators/primitiveops.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/primitiveops.c 2011-11-16 17:09:41 UTC (rev 41925)
+++ branches/bmesh/blender/source/blender/bmesh/operators/primitiveops.c 2011-11-16 17:37:20 UTC (rev 41926)
@@ -427,7 +427,7 @@
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);
Modified: branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c 2011-11-16 17:09:41 UTC (rev 41925)
+++ branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c 2011-11-16 17:37:20 UTC (rev 41926)
@@ -886,10 +886,11 @@
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)) {
Modified: branches/bmesh/blender/source/blender/bmesh/tools/BME_bevel.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/tools/BME_bevel.c 2011-11-16 17:09:41 UTC (rev 41925)
+++ branches/bmesh/blender/source/blender/bmesh/tools/BME_bevel.c 2011-11-16 17:37:20 UTC (rev 41926)
@@ -189,7 +189,7 @@
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 {
Modified: branches/bmesh/blender/source/blender/bmesh/tools/BME_weld.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/tools/BME_weld.c 2011-11-16 17:09:41 UTC (rev 41925)
+++ branches/bmesh/blender/source/blender/bmesh/tools/BME_weld.c 2011-11-16 17:37:20 UTC (rev 41926)
@@ -126,11 +126,11 @@
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);
Modified: branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c 2011-11-16 17:09:41 UTC (rev 41925)
+++ branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c 2011-11-16 17:37:20 UTC (rev 41926)
@@ -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 @@
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];
Modified: branches/bmesh/blender/source/blender/modifiers/intern/MOD_array.c
===================================================================
--- branches/bmesh/blender/source/blender/modifiers/intern/MOD_array.c 2011-11-16 17:09:41 UTC (rev 41925)
+++ branches/bmesh/blender/source/blender/modifiers/intern/MOD_array.c 2011-11-16 17:37:20 UTC (rev 41926)
@@ -382,7 +382,7 @@
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
Modified: branches/bmesh/blender/source/blender/modifiers/intern/MOD_edgesplit.c
===================================================================
--- branches/bmesh/blender/source/blender/modifiers/intern/MOD_edgesplit.c 2011-11-16 17:09:41 UTC (rev 41925)
+++ branches/bmesh/blender/source/blender/modifiers/intern/MOD_edgesplit.c 2011-11-16 17:37:20 UTC (rev 41926)
@@ -92,7 +92,7 @@
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);
}
More information about the Bf-blender-cvs
mailing list