]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
restore the wrapping behavior on tcMod scroll for compatibility reasons
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 21 Sep 2013 18:30:38 +0000 (18:30 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 21 Sep 2013 18:30:38 +0000 (18:30 +0000)
(this matches Quake3 logic)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12012 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c

index 76931c357033927c4a79cf27b092438d881776ba..a5870e751854cac8599f2010f1897954cf2488bc 100644 (file)
@@ -8003,6 +8003,7 @@ static void R_tcMod_ApplyToMatrix(matrix4x4_t *texmatrix, q3shaderinfo_layer_tcm
        int w, h, idx;
        float shadertime;
        float f;
+       float offsetd[2];
        float tcmat[12];
        matrix4x4_t matrix, temp;
        // if shadertime exceeds about 9 hours (32768 seconds), just wrap it,
@@ -8039,10 +8040,12 @@ static void R_tcMod_ApplyToMatrix(matrix4x4_t *texmatrix, q3shaderinfo_layer_tcm
                        Matrix4x4_CreateScale3(&matrix, tcmod->parms[0], tcmod->parms[1], 1);
                        break;
                case Q3TCMOD_SCROLL:
-                       // this particular tcmod is the most prone to precision breakdown
-                       // at large values, but as we wrap shadertime it won't be obvious
-                       // in practice.
-                       Matrix4x4_CreateTranslate(&matrix, tcmod->parms[0] * rsurface.shadertime, tcmod->parms[1] * rsurface.shadertime, 0);
+                       // this particular tcmod is a "bug for bug" compatible one with regards to
+                       // Quake3, the wrapping is unnecessary with our shadetime fix but quake3
+                       // specifically did the wrapping and so we must mimic that...
+                       offsetd[0] = tcmod->parms[0] * rsurface.shadertime;
+                       offsetd[1] = tcmod->parms[1] * rsurface.shadertime;
+                       Matrix4x4_CreateTranslate(&matrix, offsetd[0] - floor(offsetd[0]), offsetd[1] - floor(offsetd[1]), 0);
                        break;
                case Q3TCMOD_PAGE: // poor man's animmap (to store animations into a single file, useful for HTTP downloaded textures)
                        w = (int) tcmod->parms[0];