Revision: 48906
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48906
Author:   moguri
Date:     2012-07-14 03:45:04 +0000 (Sat, 14 Jul 2012)
Log Message:
-----------
BGE: Fix for having a texture with UV mapping after a texture without UV 
mapping in a material's texture slots. The texture wasn't getting the correct 
UV coordinates due to the "skipped" (non-UV) layer.

Modified Paths:
--------------
    
branches/soc-2012-swiss_cheese/source/gameengine/Converter/BL_BlenderDataConversion.cpp

Modified: 
branches/soc-2012-swiss_cheese/source/gameengine/Converter/BL_BlenderDataConversion.cpp
===================================================================
--- 
branches/soc-2012-swiss_cheese/source/gameengine/Converter/BL_BlenderDataConversion.cpp
     2012-07-14 03:37:39 UTC (rev 48905)
+++ 
branches/soc-2012-swiss_cheese/source/gameengine/Converter/BL_BlenderDataConversion.cpp
     2012-07-14 03:45:04 UTC (rev 48906)
@@ -492,6 +492,7 @@
 
 static void GetUVs(BL_Material *material, MTF_localLayer *layers, MFace 
*mface, MTFace *tface, MT_Point2 uvs[4][MAXTEX])
 {
+       int unit = 0;
        if (tface)
        {
                        
@@ -511,16 +512,19 @@
        {
                BL_Mapping &map = material->mapping[vind];
 
+               if (map.mapping != BL_MappingFlag::USEUV) continue;
+
                //If no UVSet is specified, try grabbing one from the UV/Image 
editor
                if (map.uvCoName.IsEmpty() && tface)
                {                       
-                       uvs[0][vind].setValue(tface->uv[0]);
-                       uvs[1][vind].setValue(tface->uv[1]);
-                       uvs[2][vind].setValue(tface->uv[2]);
+                       uvs[0][unit].setValue(tface->uv[0]);
+                       uvs[1][unit].setValue(tface->uv[1]);
+                       uvs[2][unit].setValue(tface->uv[2]);
 
                        if (mface->v4) 
-                               uvs[3][vind].setValue(tface->uv[3]);
+                               uvs[3][unit].setValue(tface->uv[3]);
 
+                       ++unit;
                        continue;
                }
 
@@ -534,15 +538,16 @@
                        {
                                MT_Point2 uvSet[4];
 
-                               uvs[0][vind].setValue(layer.face->uv[0]);
-                               uvs[1][vind].setValue(layer.face->uv[1]);
-                               uvs[2][vind].setValue(layer.face->uv[2]);
+                               uvs[0][unit].setValue(layer.face->uv[0]);
+                               uvs[1][unit].setValue(layer.face->uv[1]);
+                               uvs[2][unit].setValue(layer.face->uv[2]);
 
                                if (mface->v4) 
-                                       
uvs[3][vind].setValue(layer.face->uv[3]);
+                                       
uvs[3][unit].setValue(layer.face->uv[3]);
                                else
-                                       uvs[3][vind].setValue(0.0f, 0.0f);
+                                       uvs[3][unit].setValue(0.0f, 0.0f);
 
+                               ++unit;
                                break;
                        }
                }
@@ -833,8 +838,6 @@
                material->ras_mode |= USE_LIGHT;
        }
 
-       MT_Point2 uvs[4][MAXTEX];
-
        /* No material, what to do? let's see what is in the UV and set the 
material accordingly
         * light and visible is always on */
        if ( validface ) {

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

Reply via email to