code cleanup: use zero_v3

This commit is contained in:
Campbell Barton
2012-03-23 20:18:09 +00:00
parent 402a9d5938
commit 7ff77ed4ea
16 changed files with 59 additions and 58 deletions

View File

@@ -185,8 +185,10 @@ static void cdDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
for (i=0; i<dm->numVertData; i++) {
DO_MINMAX(cddm->mvert[i].co, min_r, max_r);
}
} else {
min_r[0] = min_r[1] = min_r[2] = max_r[0] = max_r[1] = max_r[2] = 0.0;
}
else {
zero_v3(min_r);
zero_v3(max_r);
}
}

View File

@@ -486,10 +486,10 @@ static void collision_compute_barycentric ( float pv[3], float p1[3], float p2[3
DO_INLINE void collision_interpolateOnTriangle ( float to[3], float v1[3], float v2[3], float v3[3], double w1, double w2, double w3 )
{
to[0] = to[1] = to[2] = 0;
VECADDMUL ( to, v1, w1 );
VECADDMUL ( to, v2, w2 );
VECADDMUL ( to, v3, w3 );
zero_v3(to);
VECADDMUL(to, v1, w1);
VECADDMUL(to, v2, w2);
VECADDMUL(to, v3, w3);
}
#ifndef WITH_ELTOPO

View File

@@ -2878,7 +2878,7 @@ static void minmax_new_data (void *cdata)
data->minmaxflag = TRACK_Z;
data->offset = 0.0f;
data->cache[0] = data->cache[1] = data->cache[2] = 0.0f;
zero_v3(data->cache);
data->flag = 0;
}
@@ -3535,10 +3535,9 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
target->release(target);
if(fail == TRUE)
{
if (fail == TRUE) {
/* Don't move the point */
co[0] = co[1] = co[2] = 0.0f;
zero_v3(co);
}
/* co is in local object coordinates, change it to global and update target position */

View File

@@ -155,9 +155,8 @@ Curve *add_curve(const char *name, int type)
{
Curve *cu;
cu= alloc_libblock(&G.main->curve, ID_CU, name);
cu->size[0]= cu->size[1]= cu->size[2]= 1.0;
cu = alloc_libblock(&G.main->curve, ID_CU, name);
copy_v3_fl(cu->size, 1.0f);
cu->flag= CU_FRONT|CU_BACK|CU_DEFORM_BOUNDS_OFF|CU_PATH_RADIUS;
cu->pathlen= 100;
cu->resolu= cu->resolv= (type == OB_SURF) ? 4 : 12;
@@ -392,7 +391,7 @@ void tex_space_curve(Curve *cu)
cu->size[1]= (max[1]-min[1])/2.0f;
cu->size[2]= (max[2]-min[2])/2.0f;
cu->rot[0]= cu->rot[1]= cu->rot[2]= 0.0f;
zero_v3(cu->rot);
if(cu->size[0]==0.0f) cu->size[0]= 1.0f;
else if(cu->size[0]>0.0f && cu->size[0]<0.00001f) cu->size[0]= 0.00001f;

View File

@@ -1250,7 +1250,8 @@ static void emDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
}
}
else {
min_r[0] = min_r[1] = min_r[2] = max_r[0] = max_r[1] = max_r[2] = 0.0;
zero_v3(min_r);
zero_v3(max_r);
}
}
static int emDM_getNumVerts(DerivedMesh *dm)

View File

@@ -2205,8 +2205,8 @@ static void RVBlurBitmap2_byte ( unsigned char* map, int width,int height,
for (x=0;x<halfWidth;x++) {
index=(x+y*width)*4;
fx=0;
curColor[0]=curColor[1]=curColor[2]=0;
curColor2[0]=curColor2[1]=curColor2[2]=0;
zero_v3(curColor);
zero_v3(curColor2);
for (i=x-halfWidth;i<x+halfWidth;i++) {
if ((i>=0)&&(i<width)) {
@@ -2236,7 +2236,7 @@ static void RVBlurBitmap2_byte ( unsigned char* map, int width,int height,
for (x=halfWidth;x<width-halfWidth;x++) {
index=(x+y*width)*4;
fx=0;
curColor[0]=curColor[1]=curColor[2]=0;
zero_v3(curColor);
for (i=x-halfWidth;i<x+halfWidth;i++) {
curColor[0]+=map[(i+y*width)*4+GlowR]*filter[fx];
curColor[1]+=map[(i+y*width)*4+GlowG]*filter[fx];
@@ -2259,8 +2259,8 @@ static void RVBlurBitmap2_byte ( unsigned char* map, int width,int height,
for (y=0;y<halfWidth;y++) {
index=(x+y*width)*4;
fy=0;
curColor[0]=curColor[1]=curColor[2]=0;
curColor2[0]=curColor2[1]=curColor2[2]=0;
zero_v3(curColor);
zero_v3(curColor2);
for (i=y-halfWidth;i<y+halfWidth;i++) {
if ((i>=0)&&(i<height)) {
/* Bottom */
@@ -2289,7 +2289,7 @@ static void RVBlurBitmap2_byte ( unsigned char* map, int width,int height,
for (y=halfWidth;y<height-halfWidth;y++) {
index=(x+y*width)*4;
fy=0;
curColor[0]=curColor[1]=curColor[2]=0;
zero_v3(curColor);
for (i=y-halfWidth;i<y+halfWidth;i++) {
curColor[0]+=map[(x+i*width)*4+GlowR]*filter[fy];
curColor[1]+=map[(x+i*width)*4+GlowG]*filter[fy];
@@ -2406,7 +2406,7 @@ static void RVBlurBitmap2_float ( float* map, int width,int height,
for (x=halfWidth;x<width-halfWidth;x++) {
index=(x+y*width)*4;
fx=0;
curColor[0]=curColor[1]=curColor[2]=0;
zero_v3(curColor);
for (i=x-halfWidth;i<x+halfWidth;i++) {
curColor[0]+=map[(i+y*width)*4+GlowR]*filter[fx];
curColor[1]+=map[(i+y*width)*4+GlowG]*filter[fx];
@@ -2429,8 +2429,8 @@ static void RVBlurBitmap2_float ( float* map, int width,int height,
for (y=0;y<halfWidth;y++) {
index=(x+y*width)*4;
fy=0;
curColor[0]=curColor[1]=curColor[2]=0;
curColor2[0]=curColor2[1]=curColor2[2]=0;
zero_v3(curColor);
zero_v3(curColor2);
for (i=y-halfWidth;i<y+halfWidth;i++) {
if ((i>=0)&&(i<height)) {
/* Bottom */
@@ -2459,7 +2459,7 @@ static void RVBlurBitmap2_float ( float* map, int width,int height,
for (y=halfWidth;y<height-halfWidth;y++) {
index=(x+y*width)*4;
fy=0;
curColor[0]=curColor[1]=curColor[2]=0;
zero_v3(curColor);
for (i=y-halfWidth;i<y+halfWidth;i++) {
curColor[0]+=map[(x+i*width)*4+GlowR]*filter[fy];
curColor[1]+=map[(x+i*width)*4+GlowG]*filter[fy];

View File

@@ -322,7 +322,7 @@ static short EDBM_Extrude_edge(Object *obedit, BMEditMesh *em, const char hflag,
BMO_op_exec(bm, &extop);
nor[0] = nor[1] = nor[2] = 0.0f;
zero_v3(nor);
BMO_ITER(ele, &siter, bm, &extop, "geomout", BM_ALL) {
BM_elem_select_set(bm, ele, TRUE);
@@ -337,11 +337,11 @@ static short EDBM_Extrude_edge(Object *obedit, BMEditMesh *em, const char hflag,
BMO_op_finish(bm, &extop);
if (nor[0] == 0.0f && nor[1] == 0.0f && nor[2] == 0.0f) return 'g'; // grab
return 'n'; // normal constraint
/* grab / normal constraint */
return is_zero_v3(nor) ? 'g' : 'n';
}
static short EDBM_Extrude_vert(Object *obedit, BMEditMesh *em, const char hflag, float *nor)
static short EDBM_Extrude_vert(Object *obedit, BMEditMesh *em, const char hflag, float nor[3])
{
BMIter iter;
BMEdge *eed;
@@ -435,7 +435,7 @@ static int EDBM_Extrude_Mesh(Scene *scene, Object *obedit, BMEditMesh *em, wmOpe
float stacknor[3] = {0.0f, 0.0f, 0.0f};
float *nor = norin ? norin : stacknor;
nor[0] = nor[1] = nor[2] = 0.0f;
zero_v3(nor);
if (em->selectmode & SCE_SELECT_VERTEX) {
if (em->bm->totvertsel == 0) nr = 0;
@@ -482,12 +482,12 @@ static int EDBM_Extrude_Mesh(Scene *scene, Object *obedit, BMEditMesh *em, wmOpe
}
else {
/* We need to force immediate calculation here because
* transform may use derived objects (which are now stale).
*
* This shouldn't be necessary, derived queries should be
* automatically building this data if invalid. Or something.
*/
/* We need to force immediate calculation here because
* transform may use derived objects (which are now stale).
*
* This shouldn't be necessary, derived queries should be
* automatically building this data if invalid. Or something.
*/
// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
object_handle_update(scene, obedit);

View File

@@ -178,7 +178,7 @@ static int return_editlattice_indexar(Lattice *editlatt, int *tot, int **indexar
*indexar= index= MEM_mallocN(4*totvert, "hook indexar");
*tot= totvert;
nr= 0;
cent[0]= cent[1]= cent[2]= 0.0;
zero_v3(cent);
a= editlatt->pntsu*editlatt->pntsv*editlatt->pntsw;
bp= editlatt->def;
@@ -251,7 +251,7 @@ static int return_editcurve_indexar(Object *obedit, int *tot, int **indexar, flo
*indexar= index= MEM_mallocN(4*totvert, "hook indexar");
*tot= totvert;
nr= 0;
cent[0]= cent[1]= cent[2]= 0.0;
zero_v3(cent);
for(nu= editnurb->first; nu; nu= nu->next) {
if(nu->type == CU_BEZIER) {

View File

@@ -1599,7 +1599,7 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d)
asp= ( (float)ibuf->y)/(float)ibuf->x;
vec[0] = vec[1] = vec[2] = 0.0;
zero_v3(vec);
ED_view3d_project_float_v2(ar, vec, sco, rv3d->persmat);
cx = sco[0];
cy = sco[1];

View File

@@ -314,7 +314,7 @@ static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event
#ifdef NDOF_FLY_DRAW_TOOMUCH
fly->redraw= 1;
#endif
fly->dvec_prev[0] = fly->dvec_prev[1] = fly->dvec_prev[2] = 0.0f;
zero_v3(fly->dvec_prev);
fly->timer = WM_event_add_timer(CTX_wm_manager(C), win, TIMER, 0.01f);

View File

@@ -225,7 +225,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode)
tottrans= 0; // global!
INIT_MINMAX(min, max);
centroid[0]=centroid[1]=centroid[2]= 0.0;
zero_v3(centroid);
if (obedit->type==OB_MESH) {
Mesh *me= obedit->data;
@@ -874,7 +874,7 @@ static int snap_curs_to_sel(bContext *C, wmOperator *UNUSED(op))
count= 0;
INIT_MINMAX(min, max);
centroid[0]= centroid[1]= centroid[2]= 0.0;
zero_v3(centroid);
if (obedit) {
tottrans=0;

View File

@@ -807,7 +807,7 @@ void ED_view3d_project_float_v3(ARegion *ar, const float vec[3], float adr[3], f
adr[2] = vec4[2]/vec4[3];
}
else {
adr[0] = adr[1] = adr[2] = 0.0f;
zero_v3(adr);
}
}

View File

@@ -287,8 +287,8 @@ int calc_manipulator_stats(const bContext *C)
rv3d->twdrawflag= 0xFFFF;
/* transform widget centroid/center */
scene->twcent[0]= scene->twcent[1]= scene->twcent[2]= 0.0f;
INIT_MINMAX(scene->twmin, scene->twmax);
zero_v3(scene->twcent);
if(obedit) {
ob= obedit;
@@ -1104,20 +1104,19 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
static void drawsolidcube(float size)
{
static float cube[8][3] = {
{-1.0, -1.0, -1.0},
{-1.0, -1.0, 1.0},
{-1.0, 1.0, 1.0},
{-1.0, 1.0, -1.0},
{ 1.0, -1.0, -1.0},
{ 1.0, -1.0, 1.0},
{ 1.0, 1.0, 1.0},
{ 1.0, 1.0, -1.0}, };
float n[3];
{-1.0, -1.0, -1.0},
{-1.0, -1.0, 1.0},
{-1.0, 1.0, 1.0},
{-1.0, 1.0, -1.0},
{ 1.0, -1.0, -1.0},
{ 1.0, -1.0, 1.0},
{ 1.0, 1.0, 1.0},
{ 1.0, 1.0, -1.0}, };
float n[3] = {0.0f};
glPushMatrix();
glScalef(size, size, size);
n[0]=0; n[1]=0; n[2]=0;
glBegin(GL_QUADS);
n[0]= -1.0;
glNormal3fv(n);

View File

@@ -699,7 +699,8 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
}
else if (em->bm->totvertsel > 3) {
BMIter iter;
normal[0] = normal[1] = normal[2] = 0.0f;
zero_v3(normal);
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {

View File

@@ -226,7 +226,7 @@ typedef struct bPoseChannel {
float pose_head[3]; /* actually pose_mat[3] */
float pose_tail[3]; /* also used for drawing help lines... */
float limitmin[3], limitmax[3]; /* DOF constraint */
float limitmin[3], limitmax[3]; /* DOF constraint, note! - these are stored in degrees, not radians */
float stiffness[3]; /* DOF stiffness */
float ikstretch;
float ikrotweight; /* weight of joint rotation constraint */

View File

@@ -70,7 +70,7 @@ static void initData(ModifierData *md)
*/
amd->start_cap = amd->end_cap = amd->curve_ob = amd->offset_ob = NULL;
amd->count = 2;
amd->offset[0] = amd->offset[1] = amd->offset[2] = 0;
zero_v3(amd->offset);
amd->scale[0] = 1;
amd->scale[1] = amd->scale[2] = 0;
amd->length = 0;