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
diff options
context:
space:
mode:
Diffstat (limited to 'intern/cycles/blender/blender_object.cpp')
-rw-r--r--intern/cycles/blender/blender_object.cpp75
1 files changed, 46 insertions, 29 deletions
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index 1b920249733..a18cb79c102 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -86,11 +86,11 @@ static uint object_ray_visibility(BL::Object b_ob)
/* Light */
-void BlenderSync::sync_light(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm)
+void BlenderSync::sync_light(BL::Object b_parent, int persistent_id[OBJECT_PERSISTENT_ID_SIZE], BL::Object b_ob, Transform& tfm)
{
/* test if we need to sync */
Light *light;
- ObjectKey key(b_parent, b_index, b_ob);
+ ObjectKey key(b_parent, persistent_id, b_ob);
if(!light_map.sync(&light, b_ob, b_parent, key))
return;
@@ -196,23 +196,24 @@ void BlenderSync::sync_background_light()
/* Object */
-void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::DupliObject b_dupli_ob, Transform& tfm, uint layer_flag, int motion, int particle_id)
+Object *BlenderSync::sync_object(BL::Object b_parent, int persistent_id[OBJECT_PERSISTENT_ID_SIZE], BL::DupliObject b_dupli_ob, Transform& tfm, uint layer_flag, int motion)
{
BL::Object b_ob = (b_dupli_ob ? b_dupli_ob.object() : b_parent);
/* light is handled separately */
if(object_is_light(b_ob)) {
if(!motion)
- sync_light(b_parent, b_index, b_ob, tfm);
- return;
+ sync_light(b_parent, persistent_id, b_ob, tfm);
+
+ return NULL;
}
/* only interested in object that we can create meshes from */
if(!object_is_mesh(b_ob))
- return;
+ return NULL;
/* key to lookup object */
- ObjectKey key(b_parent, b_index, b_ob);
+ ObjectKey key(b_parent, persistent_id, b_ob);
Object *object;
/* motion vector case */
@@ -234,7 +235,7 @@ void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::DupliObject
sync_mesh_motion(b_ob, object->mesh, motion);
}
- return;
+ return object;
}
/* test if we need to sync */
@@ -248,13 +249,14 @@ void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::DupliObject
/* mesh sync */
object->mesh = sync_mesh(b_ob, object_updated);
+ /* sspecial case not tracked by object update flags */
if(use_holdout != object->use_holdout) {
object->use_holdout = use_holdout;
scene->object_manager->tag_update(scene);
}
- /* object sync */
- /* transform comparison should not be needed, but duplis don't work perfect
+ /* object sync
+ * transform comparison should not be needed, but duplis don't work perfect
* in the depsgraph and may not signal changes, so this is a workaround */
if(object_updated || (object->mesh && object->mesh->need_update) || tfm != object->tfm) {
object->name = b_ob.name().c_str();
@@ -264,7 +266,10 @@ void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::DupliObject
object->motion.post = tfm;
object->use_motion = false;
- object->random_id = hash_int_2d(hash_string(object->name.c_str()), b_index);
+ object->random_id = hash_string(object->name.c_str());
+ if(persistent_id)
+ for(int i = 0; i < OBJECT_PERSISTENT_ID_SIZE; i++)
+ object->random_id = hash_int_2d(object->random_id, persistent_id[i]);
/* visibility flags for both parent */
object->visibility = object_ray_visibility(b_ob) & PATH_RAY_ALL;
@@ -289,10 +294,10 @@ void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::DupliObject
object->dupli_uv = make_float2(0.0f, 0.0f);
}
- object->particle_id = particle_id;
-
object->tag_update(scene);
}
+
+ return object;
}
/* Object Loop */
@@ -314,7 +319,9 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion)
/* object loop */
BL::Scene::objects_iterator b_ob;
BL::Scene b_sce = b_scene;
- int particle_offset = 1; /* first particle is dummy for regular, non-instanced objects */
+
+ /* global particle index counter */
+ int particle_id = 1;
bool cancel = false;
@@ -327,16 +334,14 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion)
if(!hide) {
progress.set_sync_status("Synchronizing object", (*b_ob).name());
- int num_particles = object_count_particles(*b_ob);
-
if(b_ob->is_duplicator()) {
- hide = true; /* duplicators hidden by default */
+ /* duplicators hidden by default */
+ hide = true;
/* dupli objects */
b_ob->dupli_list_create(b_scene, 2);
BL::Object::dupli_list_iterator b_dup;
- int b_index = 0;
for(b_ob->dupli_list.begin(b_dup); b_dup != b_ob->dupli_list.end(); ++b_dup) {
Transform tfm = get_transform(b_dup->matrix());
@@ -345,7 +350,8 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion)
bool emitter_hide = false;
if(b_dup_ob.is_duplicator()) {
- emitter_hide = true; /* duplicators hidden by default */
+ /* duplicators hidden by default */
+ emitter_hide = true;
/* check if we should render or hide particle emitter */
BL::Object::particle_systems_iterator b_psys;
@@ -355,21 +361,34 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion)
}
if(!(b_dup->hide() || dup_hide || emitter_hide)) {
- sync_object(*b_ob, b_index, *b_dup, tfm, ob_layer, motion, b_dup->particle_index() + particle_offset);
+ /* the persistent_id allows us to match dupli objects
+ * between frames and updates */
+ BL::Array<int, OBJECT_PERSISTENT_ID_SIZE> persistent_id = b_dup->persistent_id();
+
+ /* sync object and mesh or light data */
+ Object *object = sync_object(*b_ob, persistent_id.data, *b_dup, tfm, ob_layer, motion);
+
+ /* sync possible particle data, note particle_id
+ * starts counting at 1, first is dummy particle */
+ if(!motion && object && sync_dupli_particle(*b_ob, *b_dup, object)) {
+ if(particle_id != object->particle_id) {
+ object->particle_id = particle_id;
+ scene->object_manager->tag_update(scene);
+ }
+
+ particle_id++;
+ }
+
}
-
- ++b_index;
}
b_ob->dupli_list_clear();
}
- /* sync particles and check if we should render or hide particle emitter */
+ /* check if we should render or hide particle emitter */
BL::Object::particle_systems_iterator b_psys;
- for(b_ob->particle_systems.begin(b_psys); b_psys != b_ob->particle_systems.end(); ++b_psys) {
- if(!motion)
- sync_particles(*b_ob, *b_psys);
+ for(b_ob->particle_systems.begin(b_psys); b_psys != b_ob->particle_systems.end(); ++b_psys) {
if(b_psys->settings().use_render_emitter())
hide = false;
}
@@ -377,10 +396,8 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion)
if(!hide) {
/* object itself */
Transform tfm = get_transform(b_ob->matrix_world());
- sync_object(*b_ob, 0, PointerRNA_NULL, tfm, ob_layer, motion, 0);
+ sync_object(*b_ob, NULL, PointerRNA_NULL, tfm, ob_layer, motion);
}
-
- particle_offset += num_particles;
}
cancel = progress.get_cancel();