[Bf-blender-cvs] [9abbf73d3f6] blender2.8: Cleanup: Wrap object runtime eval members into own struct

Sergey Sharybin noreply at git.blender.org
Wed May 30 11:11:09 CEST 2018


Commit: 9abbf73d3f668a940c8f4d077ef9bc6db0ca7142
Author: Sergey Sharybin
Date:   Wed May 30 10:47:20 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB9abbf73d3f668a940c8f4d077ef9bc6db0ca7142

Cleanup: Wrap object runtime eval members into own struct

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

M	source/blender/blenkernel/intern/object.c
M	source/blender/blenkernel/intern/object_update.c
M	source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
M	source/blender/makesdna/DNA_object_types.h

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

diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 1a491f63249..6fa8caba582 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -341,15 +341,16 @@ void BKE_object_free_derived_caches(Object *ob)
 		ob->derivedDeform = NULL;
 	}
 
-	if (ob->mesh_eval != NULL) {
+	if (ob->runtime.mesh_eval != NULL) {
+		Mesh *mesh_eval = ob->runtime.mesh_eval;
 		/* Restore initial pointer. */
-		ob->data = ob->mesh_eval->id.orig_id;
+		ob->data = mesh_eval->id.orig_id;
 		/* Evaluated mesh points to edit mesh, but does not own it. */
-		ob->mesh_eval->edit_btmesh = NULL;
-		BKE_mesh_free(ob->mesh_eval);
-		BKE_libblock_free_data(&ob->mesh_eval->id, false);
-		MEM_freeN(ob->mesh_eval);
-		ob->mesh_eval = NULL;
+		mesh_eval->edit_btmesh = NULL;
+		BKE_mesh_free(mesh_eval);
+		BKE_libblock_free_data(&mesh_eval->id, false);
+		MEM_freeN(mesh_eval);
+		ob->runtime.mesh_eval = NULL;
 	}
 
 	BKE_object_free_curve_cache(ob);
@@ -2837,8 +2838,7 @@ int BKE_object_obdata_texspace_get(Object *ob, short **r_texflag, float **r_loc,
 Mesh *BKE_object_get_evaluated_mesh(const Depsgraph *depsgraph, Object *ob)
 {
 	Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
-
-	return ob_eval->mesh_eval;
+	return ob_eval->runtime.mesh_eval;
 }
 
 
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 0709d01d5ac..5848de3aa87 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -350,7 +350,7 @@ void BKE_object_eval_uber_data(Depsgraph *depsgraph,
 				 * explicit  way to query final object evaluated data and know for sure
 				 * who owns the newly created mesh datablock.
 				 */
-				ob->mesh_eval = new_mesh;
+				ob->runtime.mesh_eval = new_mesh;
 				/* TODO(sergey): This is kind of compatibility thing, so all render
 				 * engines can use object->data for mesh data for display. This is
 				 * something what we might want to change in the future.
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index 1eeb76ec72b..4d9f1f6b977 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -756,8 +756,8 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
 			{
 				Object *object = (Object *)id_cow;
 				/* Store evaluated mesh, make sure we don't free it. */
-				mesh_eval = object->mesh_eval;
-				object->mesh_eval = NULL;
+				mesh_eval = object->runtime.mesh_eval;
+				object->runtime.mesh_eval = NULL;
 				/* Currently object update will override actual object->data
 				 * to an evaluated version. Need to make sure we don't have
 				 * data set to evaluated one before free anything.
@@ -792,7 +792,7 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
 	if (id_type == ID_OB) {
 		Object *object = (Object *)id_cow;
 		if (mesh_eval != NULL) {
-			object->mesh_eval = mesh_eval;
+			object->runtime.mesh_eval = mesh_eval;
 			/* Do same thing as object update: override actual object data
 			 * pointer with evaluated datablock.
 			 */
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index bdd238d1644..e525a4fae0c 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -143,6 +143,14 @@ typedef struct ObjectDisplay {
 	int flag;
 } ObjectDisplay;
 
+/* Not saved in file! */
+typedef struct Object_Runtime {
+	/* Mesh structure created during object evaluation.
+	 * It has all modifiers applied.
+	 */
+	struct Mesh *mesh_eval;
+} Object_Runtime;
+
 typedef struct Object {
 	ID id;
 	struct AnimData *adt;		/* animation data (must be immediately after id for utilities to use it) */ 
@@ -299,10 +307,8 @@ typedef struct Object {
 	int pad6;
 	int select_color;
 
-	/* Mesh structure created during object evaluation.
-	 * It has all modifiers applied.
-	 */
-	struct Mesh *mesh_eval;
+	/* Runtime evaluation data. */
+	Object_Runtime runtime;
 
 	/* Object Display */
 	struct ObjectDisplay display;



More information about the Bf-blender-cvs mailing list