diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-06-24 19:40:52 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-06-24 19:40:52 +0300 |
commit | a59d7374ea1ce165604975a807fb6e92f9c1d469 (patch) | |
tree | c09f8380bc54d3b14732531632eac434a19acb94 /source/blender/collada/collada_utils.cpp | |
parent | d0856d1d546a07acf29e3a2ac873fe7dc1d7c61b (diff) |
Nuke DM out of collada code.
Also, now use out-of-main temp copy of mesh for export, and fixed a
potential memleak (return without freeing temp copy of mesh, tsst).
Diffstat (limited to 'source/blender/collada/collada_utils.cpp')
-rw-r--r-- | source/blender/collada/collada_utils.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index 22ddeb4edb7..86824800378 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -51,8 +51,8 @@ extern "C" { #include "BKE_global.h" #include "BKE_layer.h" #include "BKE_mesh.h" +#include "BKE_mesh_runtime.h" #include "BKE_scene.h" -#include "BKE_DerivedMesh.h" #include "BKE_main.h" #include "ED_armature.h" @@ -160,13 +160,13 @@ Object *bc_add_object(Main *bmain, Scene *scene, ViewLayer *view_layer, int type } Mesh *bc_get_mesh_copy( - Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type, bool apply_modifiers, bool triangulate) + Depsgraph *depsgraph, Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type, bool apply_modifiers, bool triangulate) { - Mesh *tmpmesh; CustomDataMask mask = CD_MASK_MESH; Mesh *mesh = (Mesh *)ob->data; - DerivedMesh *dm = NULL; + Mesh *tmpmesh = NULL; if (apply_modifiers) { +#if 0 /* Not supported by new system currently... */ switch (export_mesh_type) { case BC_MESH_TYPE_VIEW: { @@ -179,14 +179,20 @@ Mesh *bc_get_mesh_copy( break; } } +#else + tmpmesh = mesh_get_eval_final(depsgraph, scene, ob, mask); +#endif } else { - dm = mesh_create_derived((Mesh *)ob->data, NULL); + tmpmesh = mesh; } - tmpmesh = BKE_mesh_add(bmain, "ColladaMesh"); // name is not important here - DM_to_mesh(dm, tmpmesh, ob, CD_MASK_MESH, true); - tmpmesh->flag = mesh->flag; + BKE_id_copy_ex(NULL, &tmpmesh->id, (ID **)&tmpmesh, + LIB_ID_CREATE_NO_MAIN | + LIB_ID_CREATE_NO_USER_REFCOUNT | + LIB_ID_CREATE_NO_DEG_TAG | + LIB_ID_COPY_NO_PREVIEW, + false); if (triangulate) { bc_triangulate_mesh(tmpmesh); |