Collada: fixed export when 'active UV Layer only' was selected
[blender.git] / source / blender / collada / GeometryExporter.cpp
index 29ffcf53ee96467f8282f9a83dcd655f1e455b34..c7ad2ff39754404e8e37189989b7422ceb014155 100644 (file)
@@ -279,15 +279,18 @@ void GeometryExporter::createPolylist(short material_index,
                
        // if mesh has uv coords writes <input> for TEXCOORD
        int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
-
+       int active_uv_index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE)-1;
        for (i = 0; i < num_layers; i++) {
-               // char *name = CustomData_get_layer_name(&me->fdata, CD_MTFACE, i);
-               COLLADASW::Input input3(COLLADASW::InputSemantic::TEXCOORD,
-                                       makeUrl(makeTexcoordSourceId(geom_id, i)),
-                                       2, // offset always 2, this is only until we have optimized UV sets
-                                       i  // set number equals UV map index
-                                       );
-               til.push_back(input3);
+               if (!this->export_settings->active_uv_only || i == active_uv_index) {
+
+                       // char *name = CustomData_get_layer_name(&me->fdata, CD_MTFACE, i);
+                       COLLADASW::Input input3(COLLADASW::InputSemantic::TEXCOORD,
+                                                                       makeUrl(makeTexcoordSourceId(geom_id, i)),
+                                                                       2, // offset always 2, this is only until we have optimized UV sets
+                                                                       i  // set number equals UV map index
+                                                                       );
+                       til.push_back(input3);
+               }
        }
 
        if (has_color) {