Patch from Banlu Kemiyatorn

replace VecMulf(var,-1) with new VecNegf(var) function.
This commit is contained in:
2008-12-16 12:32:10 +00:00
parent 4da3c4b9d5
commit 882d85a968
13 changed files with 39 additions and 31 deletions

View File

@@ -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. */

View File

@@ -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];

View File

@@ -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

View File

@@ -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; w<maxw; w++){
VecSubf(temp2,ptn[w].co,temp);
@@ -1877,7 +1877,7 @@ void reset_particle(ParticleData *pa, ParticleSystem *psys, ParticleSystemModifi
}
/* create rotation quat */
VecMulf(rot_vec,-1.0);
VecNegf(rot_vec);
vectoquat(rot_vec, OB_POSX, OB_POSZ, q2);
/* randomize rotation quat */
@@ -3022,7 +3022,7 @@ static void particle_intersect_face(void *userdata, int index, const BVHTreeRay
CalcNormFloat(t0, t1, t2, col->nor);
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);

View File

@@ -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);

View File

@@ -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*/

View File

@@ -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 */

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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; pass<totpass; pass++) {
for(i=0; i<tree->totface; 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);

View File

@@ -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

View File

@@ -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);