Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-06-06 17:27:02 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-06-06 17:30:14 +0300
commit81615ddf86173e6525fb92d26dc5cf130a4cdef5 (patch)
tree97dc38f4cc30f2865d7aeb44258f093c3844835f /intern
parentcb97b07e23d37acceff9c487fbed6c3d3c21d370 (diff)
Cycles: Fix infinite update when using duplis
The issue was caused by usage of address of dupli-object (which will vary from iteration process to iteration process) as something denoting whether we've got the data synchronized to Cycles or not. For now solved by using address of original object (the one DupliObject points to) as a pointer for the map. Need to do more thoughts about this.
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/blender/blender_mesh.cpp3
-rw-r--r--intern/cycles/blender/blender_object.cpp29
-rw-r--r--intern/cycles/blender/blender_sync.h6
3 files changed, 28 insertions, 10 deletions
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index 3dfb2b1913d..75933c955ee 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -945,6 +945,7 @@ static void sync_mesh_fluid_motion(BL::Object& b_ob, Scene *scene, Mesh *mesh)
}
Mesh *BlenderSync::sync_mesh(BL::Object& b_ob,
+ BL::Object& b_ob_instance,
bool object_updated,
bool hide_tris)
{
@@ -958,7 +959,7 @@ Mesh *BlenderSync::sync_mesh(BL::Object& b_ob,
/* test if we can instance or if the object is modified */
BL::ID b_ob_data = b_ob.data();
- BL::ID key = (BKE_object_is_modified(b_ob))? b_ob: b_ob_data;
+ BL::ID key = (BKE_object_is_modified(b_ob))? b_ob_instance: b_ob_data;
BL::Material material_override = render_layer.material_override;
/* find shader indices */
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index eaf257c0c73..991b834dcfa 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -94,12 +94,13 @@ static uint object_ray_visibility(BL::Object& b_ob)
void BlenderSync::sync_light(BL::Object& b_parent,
int persistent_id[OBJECT_PERSISTENT_ID_SIZE],
BL::Object& b_ob,
+ BL::Object& b_ob_instance,
Transform& tfm,
bool *use_portal)
{
/* test if we need to sync */
Light *light;
- ObjectKey key(b_parent, persistent_id, b_ob);
+ ObjectKey key(b_parent, persistent_id, b_ob_instance);
if(!light_map.sync(&light, b_ob, b_parent, key)) {
if(light->is_portal)
@@ -243,13 +244,17 @@ Object *BlenderSync::sync_object(BL::Depsgraph::duplis_iterator& b_dupli_iter,
BlenderObjectCulling& culling,
bool *use_portal)
{
+ const bool is_instance = b_dupli_iter->is_instance();
BL::Object b_ob = b_dupli_iter->object();
- BL::Object b_parent = b_dupli_iter->parent() ? b_dupli_iter->parent() : b_dupli_iter->object();
+ BL::Object b_parent = is_instance ? b_dupli_iter->parent()
+ : b_dupli_iter->object();
+ BL::Object b_ob_instance = is_instance ? b_dupli_iter->instance_object()
+ : b_ob;
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()) {
+ if(is_instance) {
persistent_id_array = b_dupli_iter->persistent_id();
persistent_id = persistent_id_array.data;
}
@@ -257,8 +262,16 @@ Object *BlenderSync::sync_object(BL::Depsgraph::duplis_iterator& b_dupli_iter,
/* light is handled separately */
if(object_is_light(b_ob)) {
/* don't use lamps for excluded layers used as mask layer */
- if(!motion && !((layer_flag & render_layer.holdout_layer) && (layer_flag & render_layer.exclude_layer)))
- sync_light(b_parent, persistent_id, b_ob, tfm, use_portal);
+ if(!motion && !((layer_flag & render_layer.holdout_layer) &&
+ (layer_flag & render_layer.exclude_layer)))
+ {
+ sync_light(b_parent,
+ persistent_id,
+ b_ob,
+ b_ob_instance,
+ tfm,
+ use_portal);
+ }
return NULL;
}
@@ -274,7 +287,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph::duplis_iterator& b_dupli_iter,
}
/* key to lookup object */
- ObjectKey key(b_parent, persistent_id, b_ob);
+ ObjectKey key(b_parent, persistent_id, b_ob_instance);
Object *object;
/* motion vector case */
@@ -316,7 +329,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph::duplis_iterator& b_dupli_iter,
bool use_holdout = (layer_flag & render_layer.holdout_layer) != 0;
/* mesh sync */
- object->mesh = sync_mesh(b_ob, object_updated, hide_tris);
+ object->mesh = sync_mesh(b_ob, b_ob_instance, object_updated, hide_tris);
/* special case not tracked by object update flags */
@@ -385,7 +398,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph::duplis_iterator& b_dupli_iter,
}
/* dupli texture coordinates and random_id */
- if(b_dupli_iter->parent()) {
+ if(is_instance) {
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();
diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h
index 4c8772d4d8f..a9f63346e00 100644
--- a/intern/cycles/blender/blender_sync.h
+++ b/intern/cycles/blender/blender_sync.h
@@ -115,7 +115,10 @@ private:
void sync_curve_settings();
void sync_nodes(Shader *shader, BL::ShaderNodeTree& b_ntree);
- Mesh *sync_mesh(BL::Object& b_ob, bool object_updated, bool hide_tris);
+ Mesh *sync_mesh(BL::Object& b_ob,
+ BL::Object& b_ob_instance,
+ bool object_updated,
+ bool hide_tris);
void sync_curves(Mesh *mesh,
BL::Mesh& b_mesh,
BL::Object& b_ob,
@@ -130,6 +133,7 @@ private:
void sync_light(BL::Object& b_parent,
int persistent_id[OBJECT_PERSISTENT_ID_SIZE],
BL::Object& b_ob,
+ BL::Object& b_ob_instance,
Transform& tfm,
bool *use_portal);
void sync_background_light(bool use_portal);