Revision: 21478
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21478
Author:   kazanbas
Date:     2009-07-10 10:43:37 +0200 (Fri, 10 Jul 2009)

Log Message:
-----------
Importer fixes:
- remove empty meshes created by add_object call
- make_edges
- don't create a mesh object for non-mesh nodes

Modified Paths:
--------------
    branches/soc-2009-chingachgook/source/blender/collada/DocumentImporter.cpp

Modified: 
branches/soc-2009-chingachgook/source/blender/collada/DocumentImporter.cpp
===================================================================
--- branches/soc-2009-chingachgook/source/blender/collada/DocumentImporter.cpp  
2009-07-10 08:05:13 UTC (rev 21477)
+++ branches/soc-2009-chingachgook/source/blender/collada/DocumentImporter.cpp  
2009-07-10 08:43:37 UTC (rev 21478)
@@ -29,14 +29,15 @@
 extern "C" 
 {
 #include "BKE_main.h"
+#include "BKE_customdata.h"
+#include "BKE_library.h"
+}
 #include "BKE_mesh.h"
-#include "BKE_customdata.h"
+#include "BKE_global.h"
 #include "BKE_context.h"
 #include "BKE_object.h"
 #include "BKE_image.h"
 #include "BKE_material.h"
-#include "BKE_library.h"
-}
 
 #include "BLI_arithb.h"
 
@@ -277,17 +278,8 @@
                                continue;
                        }
                        
-                       Object *ob = add_object(sce, OB_MESH);
+                       // XXX linking object with the first 
<instance_geometry>, though a node may have more of them...
 
-                       const std::string& id = node->getOriginalId();
-                       if (id.length())
-                               rename_id(&ob->id, (char*)id.c_str());
-
-
-                       // XXX
-                       // linking object with the first <instance_geometry>
-                       // though a node may have more of them...
-
                        // TODO: join multiple <instance_geometry> meshes into 
1, and link object with it
                        
                        COLLADAFW::InstanceGeometryPointerArray &geom = 
node->getInstanceGeometries();
@@ -295,7 +287,14 @@
                                fprintf(stderr, "Node hasn't got any 
geometry.\n");
                                continue;
                        }
-                       
+
+                       Object *ob = add_object(sce, OB_MESH);
+
+                       const std::string& id = node->getOriginalId();
+                       if (id.length())
+                               rename_id(&ob->id, (char*)id.c_str());
+
+
                        const COLLADAFW::UniqueId& geom_uid = 
geom[0]->getInstanciatedObjectId();
                        if (uid_mesh_map.find(geom_uid) == uid_mesh_map.end()) {
                                // XXX report to user
@@ -304,8 +303,11 @@
                                fprintf(stderr, "Couldn't find a mesh by 
UID.\n");
                                continue;
                        }
-                       
+
+                       // replace ob->data freeing the old one
+                       Mesh *old_mesh = (Mesh*)ob->data;
                        set_mesh(ob, uid_mesh_map[geom_uid]);
+                       if (old_mesh->id.us == 0) free_libblock(&G.main->mesh, 
old_mesh);
                        
                        float rot[3][3];
                        Mat3One(rot);
@@ -657,8 +659,9 @@
                
                geom_uid_mat_mapping_map[cgeom->getUniqueId()] = mat_prim_map;
                
-               // normals
                mesh_calc_normals(me->mvert, me->totvert, me->mface, 
me->totface, NULL);
+               make_edges(me, 0);
+
                return true;
        }
 


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to