2011-04-27 11:58:34 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011, Blender Foundation.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2012-04-30 12:49:26 +00:00
|
|
|
#include "camera.h"
|
2012-10-09 18:37:14 +00:00
|
|
|
#include "integrator.h"
|
2012-01-20 17:49:17 +00:00
|
|
|
#include "graph.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
#include "light.h"
|
|
|
|
#include "mesh.h"
|
|
|
|
#include "object.h"
|
|
|
|
#include "scene.h"
|
2012-01-20 17:49:17 +00:00
|
|
|
#include "nodes.h"
|
2012-10-18 15:00:32 +00:00
|
|
|
#include "particles.h"
|
2012-01-20 17:49:17 +00:00
|
|
|
#include "shader.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
#include "blender_sync.h"
|
|
|
|
#include "blender_util.h"
|
|
|
|
|
|
|
|
#include "util_foreach.h"
|
2012-05-29 10:34:16 +00:00
|
|
|
#include "util_hash.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
/* Utilities */
|
|
|
|
|
2012-05-05 14:33:36 +00:00
|
|
|
bool BlenderSync::BKE_object_is_modified(BL::Object b_ob)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
/* test if we can instance or if the object is modified */
|
2012-05-05 14:33:36 +00:00
|
|
|
if(ccl::BKE_object_is_modified(b_ob, b_scene, preview)) {
|
2011-04-27 11:58:34 +00:00
|
|
|
/* modifiers */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* object level material links */
|
|
|
|
BL::Object::material_slots_iterator slot;
|
2011-08-21 10:32:15 +00:00
|
|
|
for(b_ob.material_slots.begin(slot); slot != b_ob.material_slots.end(); ++slot)
|
2011-04-27 11:58:34 +00:00
|
|
|
if(slot->link() == BL::MaterialSlot::link_OBJECT)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BlenderSync::object_is_mesh(BL::Object b_ob)
|
|
|
|
{
|
|
|
|
BL::ID b_ob_data = b_ob.data();
|
|
|
|
|
|
|
|
return (b_ob_data && (b_ob_data.is_a(&RNA_Mesh) ||
|
|
|
|
b_ob_data.is_a(&RNA_Curve) || b_ob_data.is_a(&RNA_MetaBall)));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BlenderSync::object_is_light(BL::Object b_ob)
|
|
|
|
{
|
|
|
|
BL::ID b_ob_data = b_ob.data();
|
|
|
|
|
|
|
|
return (b_ob_data && b_ob_data.is_a(&RNA_Lamp));
|
|
|
|
}
|
|
|
|
|
2011-09-01 15:53:36 +00:00
|
|
|
static uint object_ray_visibility(BL::Object b_ob)
|
|
|
|
{
|
|
|
|
PointerRNA cvisibility = RNA_pointer_get(&b_ob.ptr, "cycles_visibility");
|
|
|
|
uint flag = 0;
|
|
|
|
|
|
|
|
flag |= get_boolean(cvisibility, "camera")? PATH_RAY_CAMERA: 0;
|
|
|
|
flag |= get_boolean(cvisibility, "diffuse")? PATH_RAY_DIFFUSE: 0;
|
|
|
|
flag |= get_boolean(cvisibility, "glossy")? PATH_RAY_GLOSSY: 0;
|
|
|
|
flag |= get_boolean(cvisibility, "transmission")? PATH_RAY_TRANSMIT: 0;
|
|
|
|
flag |= get_boolean(cvisibility, "shadow")? PATH_RAY_SHADOW: 0;
|
|
|
|
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* Light */
|
|
|
|
|
2012-11-08 16:35:28 +00:00
|
|
|
void BlenderSync::sync_light(BL::Object b_parent, int persistent_id[OBJECT_PERSISTENT_ID_SIZE], BL::Object b_ob, Transform& tfm)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
/* test if we need to sync */
|
|
|
|
Light *light;
|
2012-11-08 16:35:28 +00:00
|
|
|
ObjectKey key(b_parent, persistent_id, b_ob);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-05-31 10:41:01 +00:00
|
|
|
if(!light_map.sync(&light, b_ob, b_parent, key))
|
2011-04-27 11:58:34 +00:00
|
|
|
return;
|
2011-09-27 20:37:24 +00:00
|
|
|
|
|
|
|
BL::Lamp b_lamp(b_ob.data());
|
|
|
|
|
|
|
|
/* type */
|
|
|
|
switch(b_lamp.type()) {
|
|
|
|
case BL::Lamp::type_POINT: {
|
|
|
|
BL::PointLamp b_point_lamp(b_lamp);
|
|
|
|
light->size = b_point_lamp.shadow_soft_size();
|
|
|
|
light->type = LIGHT_POINT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BL::Lamp::type_SPOT: {
|
|
|
|
BL::SpotLamp b_spot_lamp(b_lamp);
|
|
|
|
light->size = b_spot_lamp.shadow_soft_size();
|
2012-06-04 17:17:10 +00:00
|
|
|
light->type = LIGHT_SPOT;
|
|
|
|
light->spot_angle = b_spot_lamp.spot_size();
|
|
|
|
light->spot_smooth = b_spot_lamp.spot_blend();
|
2011-09-27 20:37:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BL::Lamp::type_HEMI: {
|
|
|
|
light->type = LIGHT_DISTANT;
|
|
|
|
light->size = 0.0f;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BL::Lamp::type_SUN: {
|
|
|
|
BL::SunLamp b_sun_lamp(b_lamp);
|
|
|
|
light->size = b_sun_lamp.shadow_soft_size();
|
|
|
|
light->type = LIGHT_DISTANT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BL::Lamp::type_AREA: {
|
|
|
|
BL::AreaLamp b_area_lamp(b_lamp);
|
|
|
|
light->size = 1.0f;
|
2013-01-09 21:09:20 +00:00
|
|
|
light->axisu = transform_get_column(&tfm, 0);
|
|
|
|
light->axisv = transform_get_column(&tfm, 1);
|
2011-09-27 20:37:24 +00:00
|
|
|
light->sizeu = b_area_lamp.size();
|
|
|
|
if(b_area_lamp.shape() == BL::AreaLamp::shape_RECTANGLE)
|
|
|
|
light->sizev = b_area_lamp.size_y();
|
|
|
|
else
|
|
|
|
light->sizev = light->sizeu;
|
|
|
|
light->type = LIGHT_AREA;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-10-15 23:49:01 +00:00
|
|
|
/* location and (inverted!) direction */
|
2013-01-09 21:09:20 +00:00
|
|
|
light->co = transform_get_column(&tfm, 3);
|
|
|
|
light->dir = -transform_get_column(&tfm, 2);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
/* shader */
|
|
|
|
vector<uint> used_shaders;
|
|
|
|
|
2011-12-09 00:24:48 +00:00
|
|
|
find_shader(b_lamp, used_shaders, scene->default_light);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
if(used_shaders.size() == 0)
|
|
|
|
used_shaders.push_back(scene->default_light);
|
|
|
|
|
|
|
|
light->shader = used_shaders[0];
|
|
|
|
|
2011-09-27 20:37:24 +00:00
|
|
|
/* shadow */
|
2011-10-15 23:49:01 +00:00
|
|
|
PointerRNA clamp = RNA_pointer_get(&b_lamp.ptr, "cycles");
|
|
|
|
light->cast_shadow = get_boolean(clamp, "cast_shadow");
|
2013-01-30 15:57:15 +00:00
|
|
|
light->use_mis = get_boolean(clamp, "use_multiple_importance_sampling");
|
2012-06-13 11:44:48 +00:00
|
|
|
light->samples = get_int(clamp, "samples");
|
2011-09-27 20:37:24 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* tag */
|
|
|
|
light->tag_update(scene);
|
|
|
|
}
|
|
|
|
|
2012-01-20 17:49:17 +00:00
|
|
|
void BlenderSync::sync_background_light()
|
|
|
|
{
|
|
|
|
BL::World b_world = b_scene.world();
|
|
|
|
|
2012-01-22 13:56:39 +00:00
|
|
|
if(b_world) {
|
|
|
|
PointerRNA cworld = RNA_pointer_get(&b_world.ptr, "cycles");
|
|
|
|
bool sample_as_light = get_boolean(cworld, "sample_as_light");
|
|
|
|
|
|
|
|
if(sample_as_light) {
|
|
|
|
/* test if we need to sync */
|
|
|
|
Light *light;
|
|
|
|
ObjectKey key(b_world, 0, b_world);
|
|
|
|
|
|
|
|
if(light_map.sync(&light, b_world, b_world, key) ||
|
|
|
|
world_recalc ||
|
|
|
|
b_world.ptr.data != world_map)
|
|
|
|
{
|
|
|
|
light->type = LIGHT_BACKGROUND;
|
|
|
|
light->map_resolution = get_int(cworld, "sample_map_resolution");
|
2012-06-13 11:44:48 +00:00
|
|
|
light->samples = get_int(cworld, "samples");
|
2012-01-22 13:56:39 +00:00
|
|
|
light->shader = scene->default_background;
|
|
|
|
|
|
|
|
light->tag_update(scene);
|
|
|
|
light_map.set_recalc(b_world);
|
|
|
|
}
|
2012-01-20 17:49:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
world_map = b_world.ptr.data;
|
|
|
|
world_recalc = false;
|
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* Object */
|
|
|
|
|
2012-12-28 14:21:30 +00:00
|
|
|
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, bool hide_tris)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2012-10-04 21:40:39 +00:00
|
|
|
BL::Object b_ob = (b_dupli_ob ? b_dupli_ob.object() : b_parent);
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* light is handled separately */
|
|
|
|
if(object_is_light(b_ob)) {
|
2012-04-30 12:49:26 +00:00
|
|
|
if(!motion)
|
2012-11-08 16:35:28 +00:00
|
|
|
sync_light(b_parent, persistent_id, b_ob, tfm);
|
|
|
|
|
|
|
|
return NULL;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* only interested in object that we can create meshes from */
|
|
|
|
if(!object_is_mesh(b_ob))
|
2012-11-08 16:35:28 +00:00
|
|
|
return NULL;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-04-30 12:49:26 +00:00
|
|
|
/* key to lookup object */
|
2012-11-08 16:35:28 +00:00
|
|
|
ObjectKey key(b_parent, persistent_id, b_ob);
|
2011-04-27 11:58:34 +00:00
|
|
|
Object *object;
|
2012-04-30 12:49:26 +00:00
|
|
|
|
|
|
|
/* motion vector case */
|
|
|
|
if(motion) {
|
|
|
|
object = object_map.find(key);
|
|
|
|
|
|
|
|
if(object) {
|
|
|
|
if(tfm != object->tfm) {
|
|
|
|
if(motion == -1)
|
|
|
|
object->motion.pre = tfm;
|
|
|
|
else
|
|
|
|
object->motion.post = tfm;
|
|
|
|
|
|
|
|
object->use_motion = true;
|
|
|
|
}
|
|
|
|
|
2012-10-09 18:37:14 +00:00
|
|
|
/* mesh deformation blur not supported yet */
|
|
|
|
if(!scene->integrator->motion_blur)
|
|
|
|
sync_mesh_motion(b_ob, object->mesh, motion);
|
2012-04-30 12:49:26 +00:00
|
|
|
}
|
|
|
|
|
2012-11-08 16:35:28 +00:00
|
|
|
return object;
|
2012-04-30 12:49:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* test if we need to sync */
|
2011-04-27 11:58:34 +00:00
|
|
|
bool object_updated = false;
|
|
|
|
|
2011-11-12 14:29:52 +00:00
|
|
|
if(object_map.sync(&object, b_ob, b_parent, key))
|
|
|
|
object_updated = true;
|
|
|
|
|
2012-05-02 09:33:45 +00:00
|
|
|
bool use_holdout = (layer_flag & render_layer.holdout_layer) != 0;
|
|
|
|
|
2011-11-12 14:29:52 +00:00
|
|
|
/* mesh sync */
|
2012-12-28 14:21:30 +00:00
|
|
|
object->mesh = sync_mesh(b_ob, object_updated, hide_tris);
|
2012-05-02 09:33:45 +00:00
|
|
|
|
2012-11-08 16:35:28 +00:00
|
|
|
/* sspecial case not tracked by object update flags */
|
2012-05-02 09:33:45 +00:00
|
|
|
if(use_holdout != object->use_holdout) {
|
|
|
|
object->use_holdout = use_holdout;
|
|
|
|
scene->object_manager->tag_update(scene);
|
2012-11-09 23:28:51 +00:00
|
|
|
object_updated = true;
|
2012-05-02 09:33:45 +00:00
|
|
|
}
|
2011-11-12 14:29:52 +00:00
|
|
|
|
2012-11-08 16:35:28 +00:00
|
|
|
/* object sync
|
|
|
|
* transform comparison should not be needed, but duplis don't work perfect
|
2012-09-03 13:18:23 +00:00
|
|
|
* 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) {
|
2011-10-03 17:42:24 +00:00
|
|
|
object->name = b_ob.name().c_str();
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
object->pass_id = b_ob.pass_index();
|
2011-04-27 11:58:34 +00:00
|
|
|
object->tfm = tfm;
|
2012-04-30 12:49:26 +00:00
|
|
|
object->motion.pre = tfm;
|
|
|
|
object->motion.post = tfm;
|
|
|
|
object->use_motion = false;
|
2011-12-21 20:51:43 +00:00
|
|
|
|
2012-11-10 14:50:34 +00:00
|
|
|
/* random number */
|
2012-11-08 16:35:28 +00:00
|
|
|
object->random_id = hash_string(object->name.c_str());
|
2012-11-10 14:50:34 +00:00
|
|
|
|
|
|
|
if(persistent_id) {
|
2012-11-08 16:35:28 +00:00
|
|
|
for(int i = 0; i < OBJECT_PERSISTENT_ID_SIZE; i++)
|
|
|
|
object->random_id = hash_int_2d(object->random_id, persistent_id[i]);
|
2012-11-10 14:50:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
object->random_id = hash_int_2d(object->random_id, 0);
|
2012-05-29 10:34:16 +00:00
|
|
|
|
2011-12-21 20:51:43 +00:00
|
|
|
/* visibility flags for both parent */
|
|
|
|
object->visibility = object_ray_visibility(b_ob) & PATH_RAY_ALL;
|
2012-05-29 10:34:16 +00:00
|
|
|
if(b_parent.ptr.data != b_ob.ptr.data) {
|
2011-09-01 15:53:36 +00:00
|
|
|
object->visibility &= object_ray_visibility(b_parent);
|
2012-05-29 10:34:16 +00:00
|
|
|
object->random_id ^= hash_int(hash_string(b_parent.name().c_str()));
|
|
|
|
}
|
2011-09-01 15:53:36 +00:00
|
|
|
|
2012-11-09 23:28:51 +00:00
|
|
|
/* 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);
|
|
|
|
|
2011-12-21 20:51:43 +00:00
|
|
|
/* camera flag is not actually used, instead is tested
|
2012-06-09 17:22:52 +00:00
|
|
|
* against render layer flags */
|
2011-12-21 20:51:43 +00:00
|
|
|
if(object->visibility & PATH_RAY_CAMERA) {
|
|
|
|
object->visibility |= layer_flag << PATH_RAY_LAYER_SHIFT;
|
|
|
|
object->visibility &= ~PATH_RAY_CAMERA;
|
|
|
|
}
|
|
|
|
|
2012-10-04 21:40:39 +00:00
|
|
|
if (b_dupli_ob) {
|
|
|
|
object->dupli_generated = get_float3(b_dupli_ob.orco());
|
|
|
|
object->dupli_uv = get_float2(b_dupli_ob.uv());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
object->dupli_generated = make_float3(0.0f, 0.0f, 0.0f);
|
|
|
|
object->dupli_uv = make_float2(0.0f, 0.0f);
|
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
object->tag_update(scene);
|
|
|
|
}
|
2012-11-08 16:35:28 +00:00
|
|
|
|
|
|
|
return object;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
2012-12-09 12:43:40 +00:00
|
|
|
static bool object_dupli_hide_original(BL::Object::dupli_type_enum dupli_type)
|
|
|
|
{
|
|
|
|
return (dupli_type == BL::Object::dupli_type_VERTS ||
|
|
|
|
dupli_type == BL::Object::dupli_type_FACES ||
|
|
|
|
dupli_type == BL::Object::dupli_type_FRAMES);
|
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* Object Loop */
|
|
|
|
|
2012-04-30 12:49:26 +00:00
|
|
|
void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
/* layer data */
|
2012-02-28 16:44:45 +00:00
|
|
|
uint scene_layer = render_layer.scene_layer;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-04-30 12:49:26 +00:00
|
|
|
if(!motion) {
|
|
|
|
/* prepare for sync */
|
|
|
|
light_map.pre_sync();
|
|
|
|
mesh_map.pre_sync();
|
|
|
|
object_map.pre_sync();
|
|
|
|
mesh_synced.clear();
|
2012-10-18 15:00:32 +00:00
|
|
|
particle_system_map.pre_sync();
|
2012-04-30 12:49:26 +00:00
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
/* object loop */
|
|
|
|
BL::Scene::objects_iterator b_ob;
|
2012-05-23 09:46:33 +00:00
|
|
|
BL::Scene b_sce = b_scene;
|
2012-11-08 16:35:28 +00:00
|
|
|
|
|
|
|
/* global particle index counter */
|
|
|
|
int particle_id = 1;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
bool cancel = false;
|
|
|
|
|
|
|
|
for(; b_sce && !cancel; b_sce = b_sce.background_set()) {
|
|
|
|
for(b_sce.objects.begin(b_ob); b_ob != b_sce.objects.end() && !cancel; ++b_ob) {
|
2012-05-23 09:46:33 +00:00
|
|
|
bool hide = (render_layer.use_viewport_visibility)? b_ob->hide(): b_ob->hide_render();
|
2012-09-04 13:29:07 +00:00
|
|
|
uint ob_layer = get_layer(b_ob->layers(), b_ob->layers_local_view(), render_layer.use_localview, object_is_light(*b_ob));
|
2012-06-08 16:17:57 +00:00
|
|
|
hide = hide || !(ob_layer & scene_layer);
|
|
|
|
|
|
|
|
if(!hide) {
|
2012-09-28 12:37:20 +00:00
|
|
|
progress.set_sync_status("Synchronizing object", (*b_ob).name());
|
2012-06-08 16:17:57 +00:00
|
|
|
|
2012-05-23 09:46:33 +00:00
|
|
|
if(b_ob->is_duplicator()) {
|
2012-11-08 16:35:28 +00:00
|
|
|
/* duplicators hidden by default */
|
|
|
|
hide = true;
|
2012-06-08 16:17:57 +00:00
|
|
|
|
2012-05-23 09:46:33 +00:00
|
|
|
/* dupli objects */
|
2012-11-03 15:36:02 +00:00
|
|
|
b_ob->dupli_list_create(b_scene, 2);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-05-23 09:46:33 +00:00
|
|
|
BL::Object::dupli_list_iterator b_dup;
|
2012-06-13 08:10:59 +00:00
|
|
|
|
2012-05-23 09:46:33 +00:00
|
|
|
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();
|
2012-10-16 15:38:52 +00:00
|
|
|
bool emitter_hide = false;
|
|
|
|
|
|
|
|
if(b_dup_ob.is_duplicator()) {
|
2012-11-27 21:47:55 +00:00
|
|
|
/* duplicators hidden by default, except dupliframes which duplicate self */
|
|
|
|
if(b_dup_ob.dupli_type() != BL::Object::dupli_type_FRAMES)
|
|
|
|
emitter_hide = true;
|
2012-10-16 15:38:52 +00:00
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
2012-01-11 13:55:00 +00:00
|
|
|
|
2012-12-09 12:43:40 +00:00
|
|
|
/* hide original object for duplis */
|
|
|
|
BL::Object parent = b_dup_ob.parent();
|
|
|
|
if(parent && object_dupli_hide_original(parent.dupli_type()))
|
|
|
|
if(b_dup->type() == BL::DupliObject::type_GROUP)
|
|
|
|
dup_hide = true;
|
|
|
|
|
2012-10-16 15:38:52 +00:00
|
|
|
if(!(b_dup->hide() || dup_hide || emitter_hide)) {
|
2012-11-08 16:35:28 +00:00
|
|
|
/* 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 */
|
2012-12-28 14:21:30 +00:00
|
|
|
Object *object = sync_object(*b_ob, persistent_id.data, *b_dup, tfm, ob_layer, motion, false);
|
2012-11-08 16:35:28 +00:00
|
|
|
|
|
|
|
/* 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++;
|
|
|
|
}
|
|
|
|
|
2012-06-08 16:17:57 +00:00
|
|
|
}
|
2012-05-23 09:46:33 +00:00
|
|
|
}
|
2011-11-10 16:02:46 +00:00
|
|
|
|
2012-11-03 15:36:02 +00:00
|
|
|
b_ob->dupli_list_clear();
|
2012-05-23 09:46:33 +00:00
|
|
|
}
|
2011-11-10 16:02:46 +00:00
|
|
|
|
2012-11-08 16:35:28 +00:00
|
|
|
/* check if we should render or hide particle emitter */
|
2012-05-23 09:46:33 +00:00
|
|
|
BL::Object::particle_systems_iterator b_psys;
|
2012-10-18 15:00:32 +00:00
|
|
|
|
2012-12-28 14:21:30 +00:00
|
|
|
bool hair_present = false;
|
|
|
|
bool show_emitter = false;
|
|
|
|
bool hide_tris = false;
|
|
|
|
|
|
|
|
for(b_ob->particle_systems.begin(b_psys); b_psys != b_ob->particle_systems.end(); ++b_psys) {
|
|
|
|
|
|
|
|
if((b_psys->settings().render_type()==BL::ParticleSettings::render_type_PATH)&&(b_psys->settings().type()==BL::ParticleSettings::type_HAIR))
|
|
|
|
hair_present = true;
|
|
|
|
|
|
|
|
if(b_psys->settings().use_render_emitter()) {
|
2012-05-23 09:46:33 +00:00
|
|
|
hide = false;
|
2012-12-28 14:21:30 +00:00
|
|
|
show_emitter = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(hair_present && !show_emitter)
|
|
|
|
hide_tris = true;
|
2012-12-09 12:43:40 +00:00
|
|
|
|
|
|
|
/* hide original object for duplis */
|
|
|
|
BL::Object parent = b_ob->parent();
|
|
|
|
if(parent && object_dupli_hide_original(parent.dupli_type()))
|
|
|
|
hide = true;
|
2011-11-10 16:02:46 +00:00
|
|
|
|
2012-05-23 09:46:33 +00:00
|
|
|
if(!hide) {
|
|
|
|
/* object itself */
|
|
|
|
Transform tfm = get_transform(b_ob->matrix_world());
|
2012-12-28 14:21:30 +00:00
|
|
|
sync_object(*b_ob, NULL, PointerRNA_NULL, tfm, ob_layer, motion, hide_tris);
|
2012-05-23 09:46:33 +00:00
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
2012-09-04 13:29:07 +00:00
|
|
|
|
|
|
|
cancel = progress.get_cancel();
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-28 12:37:20 +00:00
|
|
|
progress.set_sync_status("");
|
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
if(!cancel && !motion) {
|
2012-04-30 12:49:26 +00:00
|
|
|
sync_background_light();
|
|
|
|
|
|
|
|
/* handle removed data and modified pointers */
|
|
|
|
if(light_map.post_sync())
|
|
|
|
scene->light_manager->tag_update(scene);
|
|
|
|
if(mesh_map.post_sync())
|
|
|
|
scene->mesh_manager->tag_update(scene);
|
|
|
|
if(object_map.post_sync())
|
|
|
|
scene->object_manager->tag_update(scene);
|
2012-10-18 15:00:32 +00:00
|
|
|
if(particle_system_map.post_sync())
|
|
|
|
scene->particle_system_manager->tag_update(scene);
|
2012-04-30 12:49:26 +00:00
|
|
|
mesh_synced.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BlenderSync::sync_motion(BL::SpaceView3D b_v3d, BL::Object b_override)
|
|
|
|
{
|
|
|
|
if(scene->need_motion() == Scene::MOTION_NONE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* get camera object here to deal with camera switch */
|
|
|
|
BL::Object b_cam = b_scene.camera();
|
|
|
|
if(b_override)
|
|
|
|
b_cam = b_override;
|
|
|
|
|
2012-10-15 21:12:58 +00:00
|
|
|
Camera prevcam = *(scene->camera);
|
|
|
|
|
2012-04-30 12:49:26 +00:00
|
|
|
/* go back and forth one frame */
|
|
|
|
int frame = b_scene.frame_current();
|
|
|
|
|
|
|
|
for(int motion = -1; motion <= 1; motion += 2) {
|
2012-11-03 15:36:02 +00:00
|
|
|
b_scene.frame_set(frame + motion, 0.0f);
|
2012-04-30 12:49:26 +00:00
|
|
|
|
|
|
|
/* camera object */
|
|
|
|
if(b_cam)
|
|
|
|
sync_camera_motion(b_cam, motion);
|
|
|
|
|
|
|
|
/* mesh objects */
|
|
|
|
sync_objects(b_v3d, motion);
|
|
|
|
}
|
2012-01-20 17:49:17 +00:00
|
|
|
|
2012-11-03 15:36:02 +00:00
|
|
|
b_scene.frame_set(frame, 0.0f);
|
2012-10-15 21:12:58 +00:00
|
|
|
|
|
|
|
/* tag camera for motion update */
|
|
|
|
if(scene->camera->motion_modified(prevcam))
|
|
|
|
scene->camera->tag_update();
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|