Fix T37753: encapsulated the creation of the source ID into one function to ensure the id is always created correctly

This commit is contained in:
Gaia Clary 2013-12-09 23:18:01 +01:00
parent 61a6d0676f
commit fe81ac0e4e
Notes: blender-bot 2023-02-14 11:29:58 +01:00
Referenced by issue #37753, Collada exporter texcoord-source name error when exporting mesh with multiple uv-maps
2 changed files with 12 additions and 8 deletions

View File

@ -357,9 +357,9 @@ void GeometryExporter::createPolylist(short material_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
makeUrl(makeTexcoordSourceId(geom_id, i, this->export_settings->active_uv_only)),
2, // this is only until we have optimized UV sets
(this->export_settings->active_uv_only) ? 0 : i // only_active_uv exported -> we have only one set
);
til.push_back(input3);
}
@ -474,10 +474,15 @@ void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *me)
}
std::string GeometryExporter::makeTexcoordSourceId(std::string& geom_id, int layer_index)
std::string GeometryExporter::makeTexcoordSourceId(std::string& geom_id, int layer_index, bool is_single_layer)
{
char suffix[20];
sprintf(suffix, "-%d", layer_index);
if (is_single_layer) {
suffix[0] = '\0';
}
else {
sprintf(suffix, "-%d", layer_index);
}
return getIdBySemantics(geom_id, COLLADASW::InputSemantic::TEXCOORD) + suffix;
}
@ -493,7 +498,6 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me)
// write <source> for each layer
// each <source> will get id like meshName + "map-channel-1"
int map_index = 0;
int active_uv_index = CustomData_get_active_layer_index(&me->ldata, CD_MLOOPUV);
for (int a = 0; a < num_layers; a++) {
@ -501,7 +505,7 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me)
MLoopUV *mloops = (MLoopUV *)CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, a);
COLLADASW::FloatSourceF source(mSW);
std::string layer_id = makeTexcoordSourceId(geom_id, map_index++);
std::string layer_id = makeTexcoordSourceId(geom_id, a, this->export_settings->active_uv_only);
source.setId(layer_id);
source.setArrayId(layer_id + ARRAY_ID_SUFFIX);

View File

@ -88,7 +88,7 @@ public:
void createVertexColorSource(std::string geom_id, Mesh *me);
std::string makeTexcoordSourceId(std::string& geom_id, int layer_index);
std::string makeTexcoordSourceId(std::string& geom_id, int layer_index, bool is_single_layer);
//creates <source> for texcoords
void createTexcoordsSource(std::string geom_id, Mesh *me);