Collada Exporter: sanitize a bit lnor export.

In case `BKE_mesh_calc_normals_split()` would fail, exporter would read
uninitialized random mem... Should not happen, but better be safe than sorry.
This commit is contained in:
Bastien Montagne 2015-05-11 17:22:18 +02:00
parent 2c4736e6db
commit 1bf685488c

@ -606,7 +606,7 @@ void GeometryExporter::create_normals(std::vector<Normal> &normals, std::vector<
MVert *verts = me->mvert;
MLoop *mloops = me->mloop;
float(*lnors)[3];
float(*lnors)[3] = NULL;
bool use_custom_normals = false;
BKE_mesh_calc_normals_split(me);
@ -630,14 +630,19 @@ void GeometryExporter::create_normals(std::vector<Normal> &normals, std::vector<
last_normal_index++;
}
MLoop *mloop = mloops + mpoly->loopstart;
BCPolygonNormalsIndices poly_indices;
for (int loop_index = 0; loop_index < mpoly->totloop; loop_index++) {
unsigned int loop_idx = mpoly->loopstart + loop_index;
if (use_vertex_normals) {
float normalized[3];
normalize_v3_v3(normalized, lnors[loop_idx]);
if (use_custom_normals) {
normalize_v3_v3(normalized, lnors[loop_idx]);
}
else {
normal_short_to_float_v3(normalized, verts[mloops[loop_index].v].no);
normalize_v3(normalized);
}
Normal n = { normalized[0], normalized[1], normalized[2] };
if (shared_normal_indices.find(n) != shared_normal_indices.end()) {