diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-06-06 14:58:40 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-06-06 15:17:32 +0300 |
commit | e1e41e4447258d42a32fd77092cef26f5733e950 (patch) | |
tree | 18b9999660443f22ecb21e2b9caa718da84e3efa /intern | |
parent | d220e54f281ebf4b851059f96b1190252489e103 (diff) |
Cycles: Support rendering objects from dupli-list
This commit extends the work from Dalai made around scene iterators to
support iterating into objects from dupli-lists.
Changes can be summarized as:
- Depsgraph iterator will hold pointer to an object which created current
duplilist. It is available via `dupli_parent` field of the iterator.
It is only set when duplilist is not NULL and guaranteed to be NULL
for all other cases.
- Introduced new depsgraph.duplis collection which gives a more extended
information about depsgraph iterator. It is basically a collection on top
of DEGObjectsIteratorData.
It is used to provide access to such data as persistent ID, generated space
and so on.
Things which still needs to be done/finished/clarified:
- Need to introduce some sort of `is_instance` boolean property which will
indicate Python and C++ RNA that we are inside of dupli-list.
- Introduce a way to skip dupli-list for particular objects.
So, for example, if we are culling object due to distance we can skip all
objects it was duplicating.
- Introduce a way to skip particular duplicators.
So we can skip iterating into particle system.
- Introduce some cleaner API for C side of operators to access all data such as
persistent ID and friends.
This way we wouldn't need de-reference iterator and could keep access to such
data really abstract. Who knows how we'll be storing internal state of the
operator in the future.
While there is still stuff to do, current state works and moves us in the proper
direction.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/blender/blender_object.cpp | 44 | ||||
-rw-r--r-- | intern/cycles/blender/blender_sync.h | 5 |
2 files changed, 24 insertions, 25 deletions
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index 4ed9f00e51f..eaf257c0c73 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -236,19 +236,24 @@ void BlenderSync::sync_background_light(bool use_portal) /* Object */ -Object *BlenderSync::sync_object(BL::Object& b_parent, - int persistent_id[OBJECT_PERSISTENT_ID_SIZE], - BL::DupliObject& b_dupli_ob, - Transform& tfm, +Object *BlenderSync::sync_object(BL::Depsgraph::duplis_iterator& b_dupli_iter, uint layer_flag, float motion_time, bool hide_tris, BlenderObjectCulling& culling, bool *use_portal) { - BL::Object b_ob = (b_dupli_ob ? b_dupli_ob.object() : b_parent); - bool motion = motion_time != 0.0f; - + BL::Object b_ob = b_dupli_iter->object(); + BL::Object b_parent = b_dupli_iter->parent() ? b_dupli_iter->parent() : b_dupli_iter->object(); + const bool motion = motion_time != 0.0f; + /*const*/ Transform tfm = get_transform(b_ob.matrix_world()); + int *persistent_id = NULL; + BL::Array<int, OBJECT_PERSISTENT_ID_SIZE> persistent_id_array; + if(b_dupli_iter->parent()) { + persistent_id_array = b_dupli_iter->persistent_id(); + persistent_id = persistent_id_array.data; + } + /* light is handled separately */ if(object_is_light(b_ob)) { /* don't use lamps for excluded layers used as mask layer */ @@ -380,10 +385,10 @@ Object *BlenderSync::sync_object(BL::Object& b_parent, } /* dupli texture coordinates and random_id */ - if(b_dupli_ob) { - object->dupli_generated = 0.5f*get_float3(b_dupli_ob.orco()) - make_float3(0.5f, 0.5f, 0.5f); - object->dupli_uv = get_float2(b_dupli_ob.uv()); - object->random_id = b_dupli_ob.random_id(); + if(b_dupli_iter->parent()) { + object->dupli_generated = 0.5f*get_float3(b_dupli_iter->orco()) - make_float3(0.5f, 0.5f, 0.5f); + object->dupli_uv = get_float2(b_dupli_iter->uv()); + object->random_id = b_dupli_iter->random_id(); } else { object->dupli_generated = make_float3(0.0f, 0.0f, 0.0f); @@ -495,10 +500,12 @@ void BlenderSync::sync_objects(float motion_time) bool cancel = false; bool use_portal = false; - BL::Depsgraph::objects_iterator b_ob_iter; - - for(b_depsgraph.objects.begin(b_ob_iter); b_ob_iter != b_depsgraph.objects.end() && !cancel; ++b_ob_iter) { - BL::Object b_ob = *b_ob_iter; + BL::Depsgraph::duplis_iterator b_dupli_iter; + for(b_depsgraph.duplis.begin(b_dupli_iter); + b_dupli_iter != b_depsgraph.duplis.end() && !cancel; + ++b_dupli_iter) + { + BL::Object b_ob = b_dupli_iter->object(); progress.set_sync_status("Synchronizing object", b_ob.name()); /* load per-object culling data */ @@ -509,12 +516,7 @@ void BlenderSync::sync_objects(float motion_time) if(!object_render_hide(b_ob, true, true, hide_tris)) { /* object itself */ - Transform tfm = get_transform(b_ob.matrix_world()); - BL::DupliObject b_empty_dupli_ob(PointerRNA_NULL); - sync_object(b_ob, - NULL, - b_empty_dupli_ob, - tfm, + sync_object(b_dupli_iter, ~(0), /* until we get rid of layers */ motion_time, hide_tris, diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index e509cce3e31..4c8772d4d8f 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -121,10 +121,7 @@ private: BL::Object& b_ob, bool motion, int time_index = 0); - Object *sync_object(BL::Object& b_parent, - int persistent_id[OBJECT_PERSISTENT_ID_SIZE], - BL::DupliObject& b_dupli_ob, - Transform& tfm, + Object *sync_object(BL::Depsgraph::duplis_iterator& b_dupli_iter, uint layer_flag, float motion_time, bool hide_tris, |