]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix the inverted bumps on some surfaces (no longer uses CrossProduct to get the svector)
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 2 Mar 2004 02:27:59 +0000 (02:27 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 2 Mar 2004 02:27:59 +0000 (02:27 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3953 d7cf8633-e32d-0410-b094-e92efae38249

model_shared.c

index 766ab18f260087d8aca9941bce53b077cf22b8d4..1eb8d34e7f4d50f0e8d6d5ae99c3c7dbaf6de89e 100644 (file)
@@ -625,7 +625,13 @@ void Mod_BuildBumpVectors(const float *v0, const float *v1, const float *v2, con
        f = -DotProduct(tvector3f, normal3f);
        VectorMA(tvector3f, f, normal3f, tvector3f);
        VectorNormalize(tvector3f);
-       CrossProduct(normal3f, tvector3f, svector3f);
+       // note: can't be a CrossProduct as that sometimes flips the texture
+       svector3f[0] = ((tc1[1] - tc0[1]) * (v2[0] - v0[0]) - (tc2[1] - tc0[1]) * (v1[0] - v0[0]));
+       svector3f[1] = ((tc1[1] - tc0[1]) * (v2[1] - v0[1]) - (tc2[1] - tc0[1]) * (v1[1] - v0[1]));
+       svector3f[2] = ((tc1[1] - tc0[1]) * (v2[2] - v0[2]) - (tc2[1] - tc0[1]) * (v1[2] - v0[2]));
+       f = -DotProduct(svector3f, normal3f);
+       VectorMA(svector3f, f, normal3f, svector3f);
+       VectorNormalize(svector3f);
 }
 
 // warning: this is an expensive function!