From 882d85a96827cb50d1fc4a2ac1d63b902aab8f86 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 16 Dec 2008 12:32:10 +0000 Subject: Patch from Banlu Kemiyatorn replace VecMulf(var,-1) with new VecNegf(var) function. --- source/blender/blenkernel/intern/collision.c | 2 +- source/blender/blenkernel/intern/constraint.c | 14 +++++++------- source/blender/blenkernel/intern/effect.c | 2 +- source/blender/blenkernel/intern/particle_system.c | 8 ++++---- source/blender/blenlib/BLI_arithb.h | 1 + source/blender/blenlib/intern/arithb.c | 11 +++++++++-- source/blender/blenlib/intern/graph.c | 6 +++--- source/blender/gpu/intern/gpu_material.c | 2 +- source/blender/radiosity/intern/source/radfactors.c | 4 ++-- source/blender/radiosity/intern/source/radrender.c | 4 ++-- source/blender/render/intern/source/occlusion.c | 10 +++++----- source/blender/render/intern/source/rendercore.c | 4 ++-- source/blender/render/intern/source/shadeinput.c | 2 +- 13 files changed, 39 insertions(+), 31 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 775f1dee241..0b5465ea25d 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -1236,7 +1236,7 @@ int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModifierDat if(out_normalVelocity < 0.0) { out_normalVelocity*= -1.0; - VecMulf(out_normal, -1.0); + VecNegf(out_normal); } */ /* Inelastic repulsion impulse. */ diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 5639f00ee39..b668a1f214d 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1044,7 +1044,7 @@ static void vectomat (float *vec, float *target_up, short axis, short upflag, sh n[2] = 1.0; } if (axis > 2) axis -= 3; - else VecMulf(n,-1); + else VecNegf(n); /* n specifies the transformation of the track axis */ if (flags & TARGET_Z_UP) { @@ -2182,7 +2182,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * Projf(vec2, vec, cob->matrix[0]); VecSubf(totmat[1], vec, vec2); Normalize(totmat[1]); - VecMulf(totmat[1],-1); + VecNegf(totmat[1]); /* the x axis is fixed */ totmat[0][0] = cob->matrix[0][0]; @@ -2200,7 +2200,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * Projf(vec2, vec, cob->matrix[0]); VecSubf(totmat[2], vec, vec2); Normalize(totmat[2]); - VecMulf(totmat[2],-1); + VecNegf(totmat[2]); /* the x axis is fixed */ totmat[0][0] = cob->matrix[0][0]; @@ -2265,7 +2265,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * Projf(vec2, vec, cob->matrix[1]); VecSubf(totmat[0], vec, vec2); Normalize(totmat[0]); - VecMulf(totmat[0],-1); + VecNegf(totmat[0]); /* the y axis is fixed */ totmat[1][0] = cob->matrix[1][0]; @@ -2283,7 +2283,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * Projf(vec2, vec, cob->matrix[1]); VecSubf(totmat[2], vec, vec2); Normalize(totmat[2]); - VecMulf(totmat[2],-1); + VecNegf(totmat[2]); /* the y axis is fixed */ totmat[1][0] = cob->matrix[1][0]; @@ -2348,7 +2348,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * Projf(vec2, vec, cob->matrix[2]); VecSubf(totmat[0], vec, vec2); Normalize(totmat[0]); - VecMulf(totmat[0],-1); + VecNegf(totmat[0]); /* the z axis is fixed */ totmat[2][0] = cob->matrix[2][0]; @@ -2366,7 +2366,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * Projf(vec2, vec, cob->matrix[2]); VecSubf(totmat[1], vec, vec2); Normalize(totmat[1]); - VecMulf(totmat[1],-1); + VecNegf(totmat[1]); /* the z axis is fixed */ totmat[2][0] = cob->matrix[2][0]; diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 122c6c71a6c..0338ec92414 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -251,7 +251,7 @@ static float eff_calc_visibility(Object *ob, float *co, float *dir) return 0; VECCOPY(norm, dir); - VecMulf(norm, -1.0); + VecNegf(norm); len = Normalize(norm); // check all collision objects diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 39226faff1e..8a964c5b32e 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -831,7 +831,7 @@ void psys_thread_distribute_particle(ParticleThread *thread, ParticleData *pa, C VecCopyf(tan,seam->tan); VecSubf(temp2,co1,temp); if(Inpf(tan,temp2)<0.0f) - VecMulf(tan,-1.0f); + VecNegf(tan); } for(w=0; wnor); VECSUB(temp, co2, co1); if(Inpf(col->nor, temp) > 0.0f) - VecMulf(col->nor, -1.0f); + VecNegf(col->nor); VECCOPY(col->vel,vel); @@ -3802,7 +3802,7 @@ static void boid_body(BoidVecFunc *bvf, ParticleData *pa, ParticleSystem *psys, VecRotToQuat(pa->state.vel,bank,q); VECCOPY(dvec,pa->state.vel); - VecMulf(dvec,-1.0f); + VecNegf(dvec); vectoquat(dvec, OB_POSX, OB_POSZ, q2); QuatMul(pa->state.rot,q,q2); diff --git a/source/blender/blenlib/BLI_arithb.h b/source/blender/blenlib/BLI_arithb.h index e4b983d9ba3..fd58aa318da 100644 --- a/source/blender/blenlib/BLI_arithb.h +++ b/source/blender/blenlib/BLI_arithb.h @@ -241,6 +241,7 @@ int VecLen(int *v1, int *v2); float VecLenf(float *v1, float *v2); float VecLength(float *v); void VecMulf(float *v1, float f); +void VecNegf(float *v1); int VecLenCompare(float *v1, float *v2, float limit); int VecCompare(float *v1, float *v2, float limit); diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c index e606092f72d..61cbf791bf1 100644 --- a/source/blender/blenlib/intern/arithb.c +++ b/source/blender/blenlib/intern/arithb.c @@ -2183,6 +2183,13 @@ void VecMulf(float *v1, float f) v1[2]*= f; } +void VecNegf(float *v1) +{ + v1[0] = -v1[0]; + v1[1] = -v1[1]; + v1[2] = -v1[2]; +} + void VecOrthoBasisf(float *v, float *v1, float *v2) { float f = sqrt(v[0]*v[0] + v[1]*v[1]); @@ -3945,7 +3952,7 @@ int SweepingSphereIntersectsTriangleUV(float p1[3], float p2[3], float radius, f Normalize(nor); /* flip normal */ - if(Inpf(nor,vel)>0.0f) VecMulf(nor,-1.0f); + if(Inpf(nor,vel)>0.0f) VecNegf(nor); a=Inpf(p1,nor)-Inpf(v0,nor); nordotv=Inpf(nor,vel); @@ -4616,7 +4623,7 @@ void tangent_from_uv(float *uv1, float *uv2, float *uv3, float *co1, float *co2, /* check flip */ if ((ct[0]*n[0] + ct[1]*n[1] + ct[2]*n[2]) < 0.0f) - VecMulf(tang, -1.0f); + VecNegf(tang); } /* used for zoom values*/ diff --git a/source/blender/blenlib/intern/graph.c b/source/blender/blenlib/intern/graph.c index 8f35b38379e..bcd8a2ce7cd 100644 --- a/source/blender/blenlib/intern/graph.c +++ b/source/blender/blenlib/intern/graph.c @@ -809,15 +809,15 @@ static void testAxialSymmetry(BGraph *graph, BNode* root_node, BNode* node1, BNo if (abs(nor[0]) > abs(nor[1]) && abs(nor[0]) > abs(nor[2]) && nor[0] < 0) { - VecMulf(nor, -1); + VecNegf(nor); } else if (abs(nor[1]) > abs(nor[0]) && abs(nor[1]) > abs(nor[2]) && nor[1] < 0) { - VecMulf(nor, -1); + VecNegf(nor); } else if (abs(nor[2]) > abs(nor[1]) && abs(nor[2]) > abs(nor[0]) && nor[2] < 0) { - VecMulf(nor, -1); + VecNegf(nor); } /* mirror node2 along axis */ diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 46df003cbbc..87703bc73bf 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -306,7 +306,7 @@ void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float v if(material->dynproperty & DYN_LAMP_VEC) { VECCOPY(lamp->dynvec, lamp->vec); Normalize(lamp->dynvec); - VecMulf(lamp->dynvec, -1.0f); + VecNegf(lamp->dynvec); Mat4Mul3Vecfl(viewmat, lamp->dynvec); } diff --git a/source/blender/radiosity/intern/source/radfactors.c b/source/blender/radiosity/intern/source/radfactors.c index ba4dbf1b793..d5b7c1caef3 100644 --- a/source/blender/radiosity/intern/source/radfactors.c +++ b/source/blender/radiosity/intern/source/radfactors.c @@ -535,10 +535,10 @@ void progressiverad() if(shoot->first->f & RAD_TWOSIDED) { VECCOPY(unshot, shoot->unshot); - VecMulf(shoot->norm, -1.0); + VecNegf(shoot->norm); if(makeformfactors(shoot)) applyformfactors(shoot); - VecMulf(shoot->norm, -1.0); + VecNegf(shoot->norm); VECCOPY(shoot->unshot, unshot); } diff --git a/source/blender/radiosity/intern/source/radrender.c b/source/blender/radiosity/intern/source/radrender.c index 68b5fa81f43..454a7d01688 100644 --- a/source/blender/radiosity/intern/source/radrender.c +++ b/source/blender/radiosity/intern/source/radrender.c @@ -299,10 +299,10 @@ static void progressiverad_rr(Render *re) /* ...unless it's two sided */ if(shootrf->flag & RAD_TWOSIDED) { VECCOPY(unshot, shootrf->unshot); - VecMulf(shootrf->norm, -1.0); + VecNegf(shootrf->norm); makeformfactors_rr(re, shoot, shootrf); applyformfactors_rr(re, shoot, shootrf); - VecMulf(shootrf->norm, -1.0); + VecNegf(shootrf->norm); VECCOPY(shootrf->unshot, unshot); } diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index d2d2cf3fb77..494feb96c18 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -181,8 +181,8 @@ static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr, /* not a pretty solution, but fixes common cases */ if(shi->obr->ob && shi->obr->ob->transflag & OB_NEG_SCALE) { - VecMulf(shi->vn, -1.0f); - VecMulf(shi->vno, -1.0f); + VecNegf(shi->vn); + VecNegf(shi->vno); } /* init material vars */ @@ -1288,7 +1288,7 @@ static void occ_compute_passes(Render *re, OcclusionTree *tree, int totpass) for(pass=0; passtotface; i++) { occ_face(&tree->face[i], co, n, NULL); - VecMulf(n, -1.0f); + VecNegf(n); VECADDFAC(co, co, n, 1e-8f); occ_lookup(tree, 0, &tree->face[i], co, n, &occ[i], NULL); @@ -1321,7 +1321,7 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, f aocolor= WO_AOPLAIN; VECCOPY(nn, n); - VecMulf(nn, -1.0f); + VecNegf(nn); occ_lookup(tree, thread, exclude, co, nn, &occ, (aocolor)? bn: NULL); @@ -1525,7 +1525,7 @@ static void *exec_strandsurface_sample(void *data) CalcCent3f(co, co1, co2, co3); CalcNormFloat(co1, co2, co3, n); } - VecMulf(n, -1.0f); + VecNegf(n); sample_occ_tree(re, re->occlusiontree, NULL, co, n, othread->thread, 0, col); VECCOPY(othread->facecol[a], col); diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index c3b281f2a23..5dfb509939b 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -1505,8 +1505,8 @@ static void shade_sample_sss(ShadeSample *ssamp, Material *mat, ObjectInstanceRe /* not a pretty solution, but fixes common cases */ if(shi->obr->ob && shi->obr->ob->transflag & OB_NEG_SCALE) { - VecMulf(shi->vn, -1.0f); - VecMulf(shi->vno, -1.0f); + VecNegf(shi->vn); + VecNegf(shi->vno); } /* if nodetree, use the material that we are currently preprocessing diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index 476330152ec..1cd8ec110f9 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -354,7 +354,7 @@ void shade_input_set_strand(ShadeInput *shi, StrandRen *strand, StrandPoint *spo Normalize(shi->vn); if(INPR(shi->vn, shi->view) < 0.0f) - VecMulf(shi->vn, -1.0f); + VecNegf(shi->vn); } VECCOPY(shi->vno, shi->vn); -- cgit v1.2.3