[Bf-blender-cvs] [408cdf0cbac] blender2.8: DRW: Add access to object dupli parent

Clément Foucault noreply at git.blender.org
Mon Nov 26 21:25:45 CET 2018


Commit: 408cdf0cbacb39a29934818dc6c656517f15a6a5
Author: Clément Foucault
Date:   Mon Nov 26 15:23:16 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB408cdf0cbacb39a29934818dc6c656517f15a6a5

DRW: Add access to object dupli parent

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

M	source/blender/draw/intern/DRW_render.h
M	source/blender/draw/intern/draw_manager.c
M	source/blender/draw/intern/draw_manager.h

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

diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index a5e08b4411c..1d11774d48f 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -516,6 +516,9 @@ bool DRW_object_use_hide_faces(const struct Object *ob);
 
 bool DRW_object_is_visible_psys_in_active_context(const struct Object *object, const struct ParticleSystem *psys);
 
+struct Object *DRW_object_get_dupli_parent(const struct Object *ob);
+struct DupliObject *DRW_object_get_dupli(const struct Object *ob);
+
 /* Draw commands */
 void DRW_draw_pass(DRWPass *pass);
 void DRW_draw_pass_subset(DRWPass *pass, DRWShadingGroup *start_group, DRWShadingGroup *end_group);
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 94b3bbbd57d..9d0fb690b5a 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -234,6 +234,16 @@ bool DRW_object_is_visible_psys_in_active_context(
 	return true;
 }
 
+struct Object *DRW_object_get_dupli_parent(const Object *UNUSED(ob))
+{
+	return DST.dupli_parent;
+}
+
+struct DupliObject *DRW_object_get_dupli(const Object *UNUSED(ob))
+{
+	return DST.dupli_source;
+}
+
 /** \} */
 
 
@@ -1442,7 +1452,11 @@ void DRW_draw_render_loop_ex(
 		drw_engines_world_update(scene);
 
 		const int object_type_exclude_viewport = v3d->object_type_exclude_viewport;
-		DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
+		DEG_OBJECT_ITER_BEGIN(depsgraph, ob,
+		        DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
+		        DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
+		        DEG_ITER_OBJECT_FLAG_VISIBLE |
+		        DEG_ITER_OBJECT_FLAG_DUPLI)
 		{
 			if ((object_type_exclude_viewport & (1 << ob->type)) != 0) {
 				continue;
@@ -1450,9 +1464,11 @@ void DRW_draw_render_loop_ex(
 			if (v3d->localvd && ((v3d->local_view_uuid & ob->base_local_view_bits) == 0)) {
 				continue;
 			}
+			DST.dupli_parent = data_.dupli_parent;
+			DST.dupli_source = data_.dupli_object_current;
 			drw_engines_cache_populate(ob);
 		}
-		DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END;
+		DEG_OBJECT_ITER_END;
 
 		drw_engines_cache_finish();
 
@@ -1871,14 +1887,20 @@ void DRW_render_object_iter(
 	DRW_hair_init();
 
 	const int object_type_exclude_viewport = draw_ctx->v3d ? draw_ctx->v3d->object_type_exclude_viewport : 0;
-	DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
+	DEG_OBJECT_ITER_BEGIN(depsgraph, ob,
+	        DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
+	        DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
+	        DEG_ITER_OBJECT_FLAG_VISIBLE |
+	        DEG_ITER_OBJECT_FLAG_DUPLI)
 	{
 		if ((object_type_exclude_viewport & (1 << ob->type)) == 0) {
+			DST.dupli_parent = data_.dupli_parent;
+			DST.dupli_source = data_.dupli_object_current;
 			DST.ob_state = NULL;
 			callback(vedata, ob, engine, depsgraph);
 		}
 	}
-	DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END
+	DEG_OBJECT_ITER_END
 }
 
 /* Assume a valid gl context is bound (and that the gl_context_mutex has been acquired).
@@ -2076,9 +2098,9 @@ void DRW_draw_select_loop(
 			        v3d->object_type_exclude_viewport | v3d->object_type_exclude_select
 			);
 			bool filter_exclude = false;
-			DEG_OBJECT_ITER_BEGIN(
-			        depsgraph, ob,
+			DEG_OBJECT_ITER_BEGIN(depsgraph, ob,
 			        DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
+			        DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
 			        DEG_ITER_OBJECT_FLAG_VISIBLE |
 			        DEG_ITER_OBJECT_FLAG_DUPLI)
 			{
@@ -2106,6 +2128,8 @@ void DRW_draw_select_loop(
 						Object *ob_orig = DEG_get_original_object(ob);
 						DRW_select_load_id(ob_orig->select_color);
 					}
+					DST.dupli_parent = data_.dupli_parent;
+					DST.dupli_source = data_.dupli_object_current;
 					drw_engines_cache_populate(ob);
 				}
 			}
@@ -2261,7 +2285,11 @@ void DRW_draw_depth_loop(
 		drw_engines_world_update(scene);
 
 		const int object_type_exclude_viewport = v3d->object_type_exclude_viewport;
-		DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
+		DEG_OBJECT_ITER_BEGIN(depsgraph, ob,
+		        DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
+		        DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
+		        DEG_ITER_OBJECT_FLAG_VISIBLE |
+		        DEG_ITER_OBJECT_FLAG_DUPLI)
 		{
 			if ((object_type_exclude_viewport & (1 << ob->type)) != 0) {
 				continue;
@@ -2271,9 +2299,11 @@ void DRW_draw_depth_loop(
 				continue;
 			}
 
+			DST.dupli_parent = data_.dupli_parent;
+			DST.dupli_source = data_.dupli_object_current;
 			drw_engines_cache_populate(ob);
 		}
-		DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END;
+		DEG_OBJECT_ITER_END;
 
 		drw_engines_cache_finish();
 
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index c8a7816c402..07a8f5647a7 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -319,6 +319,8 @@ typedef struct DRWManager {
 	/* State of the object being evaluated if already allocated. */
 	DRWCallState *ob_state;
 	uchar state_cache_id; /* Could be larger but 254 view changes is already a lot! */
+	struct DupliObject *dupli_source;
+	struct Object *dupli_parent;
 
 	/* Rendering state */
 	GPUShader *shader;



More information about the Bf-blender-cvs mailing list