BGE: Fix for bugs #34428, #20856, #20281. These were all multi-uv bugs caused by...
authorMitchell Stokes <mogurijin@gmail.com>
Sat, 2 Mar 2013 18:05:52 +0000 (18:05 +0000)
committerMitchell Stokes <mogurijin@gmail.com>
Sat, 2 Mar 2013 18:05:52 +0000 (18:05 +0000)
source/gameengine/Converter/BL_BlenderDataConversion.cpp

index f861b105ba3c4270a23f1a54e788046866b5fb48..e3fd662e16fe0258ae81e95ffa53281b3d80f622 100644 (file)
@@ -35,6 +35,8 @@
 #endif
 
 #include <math.h>
+#include <vector>
+#include <algorithm>
 
 #include "BL_BlenderDataConversion.h"
 #include "KX_BlenderGL.h"
@@ -506,12 +508,17 @@ static void GetUVs(BL_Material *material, MTF_localLayer *layers, MFace *mface,
                uvs[0][0] = uvs[1][0] = uvs[2][0] = uvs[3][0] = MT_Point2(0.f, 0.f);
        }
        
+       vector<STR_String> found_layers;
+
        for (int vind = 0; vind<MAXTEX; vind++)
        {
                BL_Mapping &map = material->mapping[vind];
 
                if (!(map.mapping & USEUV)) continue;
 
+               if (std::find(found_layers.begin(), found_layers.end(), map.uvCoName) != found_layers.end())
+                       continue;
+
                //If no UVSet is specified, try grabbing one from the UV/Image editor
                if (map.uvCoName.IsEmpty() && tface)
                {                       
@@ -544,6 +551,7 @@ static void GetUVs(BL_Material *material, MTF_localLayer *layers, MFace *mface,
                                        uvs[3][unit].setValue(0.0f, 0.0f);
 
                                ++unit;
+                               found_layers.push_back(map.uvCoName);
                                break;
                        }
                }