Revision: 39688
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39688
Author:   jhk
Date:     2011-08-25 07:30:12 +0000 (Thu, 25 Aug 2011)
Log Message:
-----------
Fix for [#28239] Particles Billboard 3x3 Split Error.
* Patch by Alex Fraser.

Modified Paths:
--------------
    trunk/blender/source/blender/render/intern/source/convertblender.c

Modified: trunk/blender/source/blender/render/intern/source/convertblender.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/convertblender.c  
2011-08-25 06:16:26 UTC (rev 39687)
+++ trunk/blender/source/blender/render/intern/source/convertblender.c  
2011-08-25 07:30:12 UTC (rev 39688)
@@ -1345,8 +1345,11 @@
        VlakRen *vlr;
        MTFace *mtf;
        float xvec[3], yvec[3], zvec[3], bb_center[3];
+       /* Number of tiles */
        int totsplit = bb->uv_split * bb->uv_split;
-       float uvx = 0.0f, uvy = 0.0f, uvdx = 1.0f, uvdy = 1.0f, time = 0.0f;
+       int tile, x, y;
+       /* Tile offsets */
+       float uvx = 0.0f, uvy = 0.0f, uvdx = 1.0f, uvdy = 1.0f, time = 0.0f;
 
        vlr= RE_findOrAddVlak(obr, obr->totvlak++);
        vlr->v1= RE_findOrAddVert(obr, obr->totvert++);
@@ -1420,11 +1423,14 @@
                else if(bb->split_offset==PART_BB_OFF_RANDOM)
                        time = (float)fmod(time + bb->random, 1.0f);
 
-               uvx = uvdx * floor((float)(bb->uv_split * bb->uv_split) * 
(float)fmod((double)time, (double)uvdx));
-               uvy = uvdy * floor((1.0f - time) * (float)bb->uv_split);
-
-               if(fmod(time, 1.0f / bb->uv_split) == 0.0f)
-                       uvy -= uvdy;
+               /* Find the coordinates in tile space (integer), then convert 
to UV
+                * space (float). Note that Y is flipped. */
+               tile = (int)((time + FLT_EPSILON10) * totsplit);
+               x = tile % bb->uv_split;
+               y = tile / bb->uv_split;
+               y = (bb->uv_split - 1) - y;
+               uvx = uvdx * x;
+               uvy = uvdy * y;
        }
 
        /* normal UVs */

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to