DRW: Add access to object dupli parent

This commit is contained in:
Clément Foucault 2018-11-26 15:23:16 +01:00
parent 15add11595
commit 408cdf0cba
3 changed files with 43 additions and 8 deletions

View File

@ -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);

View File

@ -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();

View File

@ -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;