Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_convert.c')
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c
index fec83ebc899..ee060a117dc 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -1216,10 +1216,14 @@ Mesh *BKE_mesh_new_from_object_to_bmain(Main *bmain,
Object *object,
bool preserve_all_data_layers)
{
+ BLI_assert(ELEM(object->type, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_MESH));
+
Mesh *mesh = BKE_mesh_new_from_object(depsgraph, object, preserve_all_data_layers);
if (mesh == NULL) {
- /* Unable to convert the object to a mesh. */
- return NULL;
+ /* Unable to convert the object to a mesh, return an empty one. */
+ Mesh *mesh_in_bmain = BKE_mesh_add(bmain, ((ID *)object->data)->name + 2);
+ id_us_min(&mesh_in_bmain->id);
+ return mesh_in_bmain;
}
/* Make sure mesh only points original datablocks, also increase users of materials and other
@@ -1233,14 +1237,14 @@ Mesh *BKE_mesh_new_from_object_to_bmain(Main *bmain,
BKE_library_foreach_ID_link(
NULL, &mesh->id, foreach_libblock_make_original_callback, NULL, IDWALK_NOP);
- /* Append the mesh to bmain.
- * We do it a bit longer way since there is no simple and clear way of adding existing datablock
- * to the bmain. So we allocate new empty mesh in the bmain (which guarantess all the naming and
- * orders and flags) and move the temporary mesh in place there. */
+ /* Append the mesh to 'bmain'.
+ * We do it a bit longer way since there is no simple and clear way of adding existing data-block
+ * to the 'bmain'. So we allocate new empty mesh in the 'bmain' (which guarantees all the naming
+ * and orders and flags) and move the temporary mesh in place there. */
Mesh *mesh_in_bmain = BKE_mesh_add(bmain, mesh->id.name + 2);
/* NOTE: BKE_mesh_nomain_to_mesh() does not copy materials and instead it preserves them in the
- * destinaion mesh. So we "steal" all related fields before calling it.
+ * destination mesh. So we "steal" all related fields before calling it.
*
* TODO(sergey): We really better have a function which gets and ID and accepts it for the bmain.
*/