fix Collada: wrong usage of pointer and hidden redeclaration
* Suspicious usage of pointer: short *type = 0; // this creates a null pointer When this is later used for anything then blender would crash. After following the code and check what happens i strongly believe the author wanted to use a short and not a pointer to a short here. * local variable where reused later in same function While this did no harm, i still felt it was better to use a different name here to make things more separated: - moved variable declaraiotns into loop (for int a=0; ...) - renamed uv_images to uv_image_set - renamed index variable from i to j in inner loop that reused same index name from outer loop
This commit is contained in:
@@ -474,9 +474,9 @@ void DocumentImporter::create_constraints(ExtraTags *et, Object *ob)
|
||||
{
|
||||
if (et && et->isProfile("blender")) {
|
||||
std::string name;
|
||||
short* type = 0;
|
||||
et->setData("type", type);
|
||||
BKE_constraint_add_for_object(ob, "Test_con", *type);
|
||||
short type = 0;
|
||||
et->setData("type", &type);
|
||||
BKE_constraint_add_for_object(ob, "Test_con", type);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -587,8 +587,8 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
|
||||
++lamp_done;
|
||||
}
|
||||
while (controller_done < controller.getCount()) {
|
||||
COLLADAFW::InstanceGeometry *geom = (COLLADAFW::InstanceGeometry *)controller[controller_done];
|
||||
ob = mesh_importer.create_mesh_object(node, geom, true, uid_material_map, material_texture_mapping_map);
|
||||
COLLADAFW::InstanceGeometry *geometry = (COLLADAFW::InstanceGeometry *)controller[controller_done];
|
||||
ob = mesh_importer.create_mesh_object(node, geometry, true, uid_material_map, material_texture_mapping_map);
|
||||
if (ob == NULL) {
|
||||
report_unknown_reference(*node, "instance_controller");
|
||||
}
|
||||
|
||||
@@ -149,8 +149,8 @@ void GeometryExporter::operator()(Object *ob)
|
||||
}
|
||||
else {
|
||||
bool all_uv_layers = !this->export_settings->active_uv_only;
|
||||
std::set<Image *> uv_images = bc_getUVImages(ob, all_uv_layers);
|
||||
createPolylists(uv_images, has_uvs, has_color, ob, me, geom_id, norind);
|
||||
std::set<Image *> uv_image_set = bc_getUVImages(ob, all_uv_layers);
|
||||
createPolylists(uv_image_set, has_uvs, has_color, ob, me, geom_id, norind);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -203,8 +203,8 @@ bool ImagesExporter::hasImages(Scene *sce)
|
||||
|
||||
for (node = this->export_settings->export_set; node; node = node->next) {
|
||||
Object *ob = (Object *)node->link;
|
||||
int a;
|
||||
for (a = 0; a < ob->totcol; a++) {
|
||||
|
||||
for (int a = 0; a < ob->totcol; a++) {
|
||||
Material *ma = give_current_material(ob, a + 1);
|
||||
|
||||
// no material, but check all of the slots
|
||||
|
||||
@@ -552,7 +552,7 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
|
||||
{
|
||||
CustomData edata;
|
||||
MEdge *medge;
|
||||
int i, totedge;
|
||||
int totedge;
|
||||
|
||||
if (len == 0)
|
||||
return;
|
||||
@@ -572,7 +572,7 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
|
||||
|
||||
/* set default flags */
|
||||
medge = &mesh->medge[mesh->totedge];
|
||||
for (i = 0; i < len; i++, medge++)
|
||||
for (int i = 0; i < len; i++, medge++)
|
||||
medge->flag = ME_EDGEDRAW | ME_EDGERENDER | SELECT;
|
||||
|
||||
mesh->totedge = totedge;
|
||||
@@ -606,12 +606,12 @@ void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me)
|
||||
unsigned int edge_count = mp->getFaceCount();
|
||||
unsigned int *indices = mp->getPositionIndices().getData();
|
||||
|
||||
for (int i = 0; i < edge_count; i++, med++) {
|
||||
for (int j = 0; j < edge_count; j++, med++) {
|
||||
med->bweight = 0;
|
||||
med->crease = 0;
|
||||
med->flag |= ME_LOOSEEDGE;
|
||||
med->v1 = indices[2 * i];
|
||||
med->v2 = indices[2 * i + 1];
|
||||
med->v1 = indices[2 * j];
|
||||
med->v2 = indices[2 * j + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user