[Bf-blender-cvs] [dc4c1be1a44] blender2.8: New object API function : BKE_object_eval_reset()

Dalai Felinto noreply at git.blender.org
Fri Dec 14 11:54:35 CET 2018


Commit: dc4c1be1a4455e84d1f72ce2703ab7425152965c
Author: Dalai Felinto
Date:   Fri Dec 14 08:40:33 2018 -0200
Branches: blender2.8
https://developer.blender.org/rBdc4c1be1a4455e84d1f72ce2703ab7425152965c

New object API function : BKE_object_eval_reset()

This restores the object->data to a non-modifier evaluated state.

So this allow us to change evaluated object modifier stack directly and
get BKE_mesh_new_from_object() for the evalauted object.

===================================================================

M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/intern/object_update.c
M	source/blender/editors/object/object_bake_api.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 136f3749910..7a595511892 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -221,6 +221,10 @@ void BKE_object_tfm_protected_restore(
         const ObjectTfmProtectedChannels *obtfm,
         const short protectflag);
 
+
+void BKE_object_eval_reset(
+        struct Object *ob_eval);
+
 /* Dependency graph evaluation callbacks. */
 void BKE_object_eval_local_transform(
         struct Depsgraph *depsgraph,
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 10bf6aed898..cbc67e23d66 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -69,6 +69,18 @@
 #include "DEG_depsgraph.h"
 #include "DEG_depsgraph_query.h"
 
+/**
+ * Restore the object->data to a non-modifier evaluated state.
+ *
+ * Some changes done directly in evaluated object require them to be reset
+ * before being re-evaluated.
+ * For example, we need to call this before BKE_mesh_new_from_object(),
+ * in case we removed/added modifiers in the evaluated object.
+ **/
+void BKE_object_eval_reset(Object *ob_eval)
+{
+	BKE_object_free_derived_caches(ob_eval);
+}
 
 void BKE_object_eval_local_transform(Depsgraph *depsgraph, Object *ob)
 {
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index 6e7124adc98..dff9ae77417 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -844,8 +844,7 @@ static int bake(
 				md = md_next;
 			}
 
-			/* We need to restore object->data to a non-modifier-evaluated state. */
-			BKE_object_free_derived_caches(ob_low_eval);
+			BKE_object_eval_reset(ob_low_eval);
 			me_cage = bake_mesh_new_from_object(depsgraph, bmain, scene, ob_low_eval);
 			RE_bake_pixels_populate(me_cage, pixel_array_low, num_pixels, &bake_images, uv_layer);
 		}



More information about the Bf-blender-cvs mailing list