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.cpp117
1 files changed, 86 insertions, 31 deletions
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index 27301026d35..e8fa5c0ff3d 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -17,12 +17,14 @@
*/
#include "camera.h"
+#include "integrator.h"
#include "graph.h"
#include "light.h"
#include "mesh.h"
#include "object.h"
#include "scene.h"
#include "nodes.h"
+#include "particles.h"
#include "shader.h"
#include "blender_sync.h"
@@ -84,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;
@@ -194,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 */
@@ -227,10 +230,12 @@ void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::DupliObject
object->use_motion = true;
}
- sync_mesh_motion(b_ob, object->mesh, motion);
+ /* mesh deformation blur not supported yet */
+ if(!scene->integrator->motion_blur)
+ sync_mesh_motion(b_ob, object->mesh, motion);
}
- return;
+ return object;
}
/* test if we need to sync */
@@ -244,13 +249,15 @@ 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_updated = true;
}
- /* 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();
@@ -260,7 +267,15 @@ 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);
+ /* random number */
+ 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]);
+ }
+ else
+ object->random_id = hash_int_2d(object->random_id, 0);
/* visibility flags for both parent */
object->visibility = object_ray_visibility(b_ob) & PATH_RAY_ALL;
@@ -269,6 +284,10 @@ void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::DupliObject
object->random_id ^= hash_int(hash_string(b_parent.name().c_str()));
}
+ /* make holdout objects on excluded layer invisible for non-camera rays */
+ if(use_holdout && (layer_flag & render_layer.exclude_layer))
+ object->visibility &= ~(PATH_RAY_ALL - PATH_RAY_CAMERA);
+
/* camera flag is not actually used, instead is tested
* against render layer flags */
if(object->visibility & PATH_RAY_CAMERA) {
@@ -285,10 +304,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 */
@@ -304,12 +323,15 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion)
mesh_map.pre_sync();
object_map.pre_sync();
mesh_synced.clear();
+ particle_system_map.pre_sync();
}
/* 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;
@@ -322,45 +344,70 @@ 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 */
- object_create_duplilist(*b_ob, b_scene);
+ 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());
BL::Object b_dup_ob = b_dup->object();
bool dup_hide = (b_v3d)? b_dup_ob.hide(): b_dup_ob.hide_render();
+ bool emitter_hide = false;
+
+ if(b_dup_ob.is_duplicator()) {
+ /* duplicators hidden by default */
+ emitter_hide = true;
+
+ /* check if we should render or hide particle emitter */
+ BL::Object::particle_systems_iterator b_psys;
+ for(b_dup_ob.particle_systems.begin(b_psys); b_psys != b_dup_ob.particle_systems.end(); ++b_psys)
+ if(b_psys->settings().use_render_emitter())
+ emitter_hide = false;
+ }
+
+ if(!(b_dup->hide() || dup_hide || emitter_hide)) {
+ /* 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++;
+ }
- if(!(b_dup->hide() || dup_hide)) {
- sync_object(*b_ob, b_index, *b_dup, tfm, ob_layer, motion, b_dup->particle_index() + particle_offset);
}
-
- ++b_index;
}
- object_free_duplilist(*b_ob);
+ b_ob->dupli_list_clear();
}
/* 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)
+
+ 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;
+ }
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();
@@ -379,6 +426,8 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion)
scene->mesh_manager->tag_update(scene);
if(object_map.post_sync())
scene->object_manager->tag_update(scene);
+ if(particle_system_map.post_sync())
+ scene->particle_system_manager->tag_update(scene);
mesh_synced.clear();
}
}
@@ -393,11 +442,13 @@ void BlenderSync::sync_motion(BL::SpaceView3D b_v3d, BL::Object b_override)
if(b_override)
b_cam = b_override;
+ Camera prevcam = *(scene->camera);
+
/* go back and forth one frame */
int frame = b_scene.frame_current();
for(int motion = -1; motion <= 1; motion += 2) {
- scene_frame_set(b_scene, frame + motion);
+ b_scene.frame_set(frame + motion, 0.0f);
/* camera object */
if(b_cam)
@@ -407,7 +458,11 @@ void BlenderSync::sync_motion(BL::SpaceView3D b_v3d, BL::Object b_override)
sync_objects(b_v3d, motion);
}
- scene_frame_set(b_scene, frame);
+ b_scene.frame_set(frame, 0.0f);
+
+ /* tag camera for motion update */
+ if(scene->camera->motion_modified(prevcam))
+ scene->camera->tag_update();
}
CCL_NAMESPACE_END