Example #1
0
void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm, uint visibility)
{
	/* light is handled separately */
	if(object_is_light(b_ob)) {
		sync_light(b_parent, b_index, b_ob, tfm);
		return;
	}

	/* only interested in object that we can create meshes from */
	if(!object_is_mesh(b_ob))
		return;

	/* test if we need to sync */
	ObjectKey key(b_parent, b_index, b_ob);
	Object *object;
	bool object_updated = false;

	if(object_map.sync(&object, b_ob, b_parent, key))
		object_updated = true;
	
	/* mesh sync */
	object->mesh = sync_mesh(b_ob, object_updated);

	/* object sync */
	if(object_updated || (object->mesh && object->mesh->need_update)) {
		object->name = b_ob.name().c_str();
		object->tfm = tfm;
		
		object->visibility = object_ray_visibility(b_ob) & visibility;
		if(b_parent.ptr.data != b_ob.ptr.data)
			object->visibility &= object_ray_visibility(b_parent);

		object->tag_update(scene);
	}
}
Example #2
0
void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm, uint layer_flag)
{
	/* light is handled separately */
	if(object_is_light(b_ob)) {
		sync_light(b_parent, b_index, b_ob, tfm);
		return;
	}

	/* only interested in object that we can create meshes from */
	if(!object_is_mesh(b_ob))
		return;

	/* test if we need to sync */
	ObjectKey key(b_parent, b_index, b_ob);
	Object *object;
	bool object_updated = false;

	if(object_map.sync(&object, b_ob, b_parent, key))
		object_updated = true;
	
	/* holdout? */
	bool holdout = (layer_flag & render_layer.holdout_layer) != 0;

	/* mesh sync */
	object->mesh = sync_mesh(b_ob, holdout, object_updated);

	/* object sync */
	if(object_updated || (object->mesh && object->mesh->need_update)) {
		object->name = b_ob.name().c_str();
		object->pass_id = b_ob.pass_index();
		object->tfm = tfm;

		/* visibility flags for both parent */
		object->visibility = object_ray_visibility(b_ob) & PATH_RAY_ALL;
		if(b_parent.ptr.data != b_ob.ptr.data)
			object->visibility &= object_ray_visibility(b_parent);

		/* camera flag is not actually used, instead is tested
		   against render layer flags */
		if(object->visibility & PATH_RAY_CAMERA) {
			object->visibility |= layer_flag << PATH_RAY_LAYER_SHIFT;
			object->visibility &= ~PATH_RAY_CAMERA;
		}

		object->tag_update(scene);
	}
}
Example #3
0
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,
                                 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;
	
	/* 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, b_dupli_ob, tfm, use_portal);

		return NULL;
	}

	/* only interested in object that we can create meshes from */
	if(!object_is_mesh(b_ob)) {
		return NULL;
	}

	/* Perform object culling. */
	if(culling.test(scene, b_ob, tfm)) {
		return NULL;
	}

	/* Visibility flags for both parent and child. */
	bool use_holdout = (layer_flag & render_layer.holdout_layer) != 0;
	uint visibility = object_ray_visibility(b_ob) & PATH_RAY_ALL_VISIBILITY;

	if(b_parent.ptr.data != b_ob.ptr.data) {
		visibility &= object_ray_visibility(b_parent);
	}

	/* Make holdout objects on excluded layer invisible for non-camera rays. */
	if(use_holdout && (layer_flag & render_layer.exclude_layer)) {
		visibility &= ~(PATH_RAY_ALL_VISIBILITY - PATH_RAY_CAMERA);
	}

	/* Hide objects not on render layer from camera rays. */
	if(!(layer_flag & render_layer.layer)) {
		visibility &= ~PATH_RAY_CAMERA;
	}

	/* Don't export completely invisible objects. */
	if(visibility == 0) {
		return NULL;
	}

	/* key to lookup object */
	ObjectKey key(b_parent, persistent_id, b_ob);
	Object *object;

	/* motion vector case */
	if(motion) {
		object = object_map.find(key);

		if(object && (scene->need_motion() == Scene::MOTION_PASS ||
		              object_use_motion(b_parent, b_ob)))
		{
			/* object transformation */
			if(tfm != object->tfm) {
				VLOG(1) << "Object " << b_ob.name() << " motion detected.";
				if(motion_time == -1.0f || motion_time == 1.0f) {
					object->use_motion = true;
				}
			}

			if(motion_time == -1.0f) {
				object->motion.pre = tfm;
			}
			else if(motion_time == 1.0f) {
				object->motion.post = tfm;
			}

			/* mesh deformation */
			if(object->mesh)
				sync_mesh_motion(b_ob, object, motion_time);
		}

		return object;
	}

	/* test if we need to sync */
	bool object_updated = false;

	if(object_map.sync(&object, b_ob, b_parent, key))
		object_updated = true;
	
	/* mesh sync */
	object->mesh = sync_mesh(b_ob, object_updated, hide_tris);

	/* special case not tracked by object update flags */

	/* holdout */
	if(use_holdout != object->use_holdout) {
		object->use_holdout = use_holdout;
		scene->object_manager->tag_update(scene);
		object_updated = true;
	}

	if(visibility != object->visibility) {
		object->visibility = visibility;
		object_updated = true;
	}

	PointerRNA cobject = RNA_pointer_get(&b_ob.ptr, "cycles");
	bool is_shadow_catcher = get_boolean(cobject, "is_shadow_catcher");
	if(is_shadow_catcher != object->is_shadow_catcher) {
		object->is_shadow_catcher = is_shadow_catcher;
		object_updated = true;
	}

	/* 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();
		object->pass_id = b_ob.pass_index();
		object->tfm = tfm;
		object->motion.pre = transform_empty();
		object->motion.post = transform_empty();
		object->use_motion = false;

		/* motion blur */
		if(scene->need_motion() == Scene::MOTION_BLUR && object->mesh) {
			Mesh *mesh = object->mesh;

			mesh->use_motion_blur = false;

			if(object_use_motion(b_parent, b_ob)) {
				if(object_use_deform_motion(b_parent, b_ob)) {
					mesh->motion_steps = object_motion_steps(b_ob);
					mesh->use_motion_blur = true;
				}

				vector<float> times = object->motion_times();
				foreach(float time, times)
					motion_times.insert(time);
			}
		}
Example #4
0
void BlenderSync::sync_curve_settings()
{
  PointerRNA csscene = RNA_pointer_get(&b_scene.ptr, "cycles_curves");

  CurveSystemManager *curve_system_manager = scene->curve_system_manager;
  CurveSystemManager prev_curve_system_manager = *curve_system_manager;

  curve_system_manager->use_curves = get_boolean(csscene, "use_curves");

  curve_system_manager->primitive = (CurvePrimitiveType)get_enum(
      csscene, "primitive", CURVE_NUM_PRIMITIVE_TYPES, CURVE_LINE_SEGMENTS);
  curve_system_manager->curve_shape = (CurveShapeType)get_enum(
      csscene, "shape", CURVE_NUM_SHAPE_TYPES, CURVE_THICK);
  curve_system_manager->resolution = get_int(csscene, "resolution");
  curve_system_manager->subdivisions = get_int(csscene, "subdivisions");
  curve_system_manager->use_backfacing = !get_boolean(csscene, "cull_backfacing");

  /* Triangles */
  if (curve_system_manager->primitive == CURVE_TRIANGLES) {
    /* camera facing planes */
    if (curve_system_manager->curve_shape == CURVE_RIBBON) {
      curve_system_manager->triangle_method = CURVE_CAMERA_TRIANGLES;
      curve_system_manager->resolution = 1;
    }
    else if (curve_system_manager->curve_shape == CURVE_THICK) {
      curve_system_manager->triangle_method = CURVE_TESSELATED_TRIANGLES;
    }
  }
  /* Line Segments */
  else if (curve_system_manager->primitive == CURVE_LINE_SEGMENTS) {
    if (curve_system_manager->curve_shape == CURVE_RIBBON) {
      /* tangent shading */
      curve_system_manager->line_method = CURVE_UNCORRECTED;
      curve_system_manager->use_encasing = true;
      curve_system_manager->use_backfacing = false;
      curve_system_manager->use_tangent_normal_geometry = true;
    }
    else if (curve_system_manager->curve_shape == CURVE_THICK) {
      curve_system_manager->line_method = CURVE_ACCURATE;
      curve_system_manager->use_encasing = false;
      curve_system_manager->use_tangent_normal_geometry = false;
    }
  }
  /* Curve Segments */
  else if (curve_system_manager->primitive == CURVE_SEGMENTS) {
    if (curve_system_manager->curve_shape == CURVE_RIBBON) {
      curve_system_manager->primitive = CURVE_RIBBONS;
      curve_system_manager->use_backfacing = false;
    }
  }

  if (curve_system_manager->modified_mesh(prev_curve_system_manager)) {
    BL::BlendData::objects_iterator b_ob;

    for (b_data.objects.begin(b_ob); b_ob != b_data.objects.end(); ++b_ob) {
      if (object_is_mesh(*b_ob)) {
        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 ((b_psys->settings().render_type() == BL::ParticleSettings::render_type_PATH) &&
              (b_psys->settings().type() == BL::ParticleSettings::type_HAIR)) {
            BL::ID key = BKE_object_is_modified(*b_ob) ? *b_ob : b_ob->data();
            mesh_map.set_recalc(key);
            object_map.set_recalc(*b_ob);
          }
        }
      }
    }
  }

  if (curve_system_manager->modified(prev_curve_system_manager))
    curve_system_manager->tag_update(scene);
}
Example #5
0
void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm, uint layer_flag, int motion)
{
	/* light is handled separately */
	if(object_is_light(b_ob)) {
		if(!motion)
			sync_light(b_parent, b_index, b_ob, tfm);
		return;
	}

	/* only interested in object that we can create meshes from */
	if(!object_is_mesh(b_ob))
		return;

	/* key to lookup object */
	ObjectKey key(b_parent, b_index, b_ob);
	Object *object;

	/* 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;
			}

			sync_mesh_motion(b_ob, object->mesh, motion);
		}

		return;
	}

	/* test if we need to sync */
	bool object_updated = false;

	if(object_map.sync(&object, b_ob, b_parent, key))
		object_updated = true;
	
	bool use_holdout = (layer_flag & render_layer.holdout_layer) != 0;
	
	/* mesh sync */
	object->mesh = sync_mesh(b_ob, object_updated);

	if(use_holdout != object->use_holdout) {
		object->use_holdout = use_holdout;
		scene->object_manager->tag_update(scene);
	}

	/* object sync */
	if(object_updated || (object->mesh && object->mesh->need_update)) {
		object->name = b_ob.name().c_str();
		object->pass_id = b_ob.pass_index();
		object->tfm = tfm;
		object->motion.pre = tfm;
		object->motion.post = tfm;
		object->use_motion = false;

		/* visibility flags for both parent */
		object->visibility = object_ray_visibility(b_ob) & PATH_RAY_ALL;
		if(b_parent.ptr.data != b_ob.ptr.data)
			object->visibility &= object_ray_visibility(b_parent);

		/* camera flag is not actually used, instead is tested
		   against render layer flags */
		if(object->visibility & PATH_RAY_CAMERA) {
			object->visibility |= layer_flag << PATH_RAY_LAYER_SHIFT;
			object->visibility &= ~PATH_RAY_CAMERA;
		}

		object->tag_update(scene);
	}
}
Example #6
0
Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
                                 BL::ViewLayer &b_view_layer,
                                 BL::DepsgraphObjectInstance &b_instance,
                                 float motion_time,
                                 bool show_self,
                                 bool show_particles,
                                 BlenderObjectCulling &culling,
                                 bool *use_portal)
{
  const bool is_instance = b_instance.is_instance();
  BL::Object b_ob = b_instance.object();
  BL::Object b_parent = is_instance ? b_instance.parent() : b_instance.object();
  BL::Object b_ob_instance = is_instance ? b_instance.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 (is_instance) {
    persistent_id_array = b_instance.persistent_id();
    persistent_id = persistent_id_array.data;
  }

  /* light is handled separately */
  if (!motion && object_is_light(b_ob)) {
    /* TODO: don't use lights for excluded layers used as mask layer,
     * when dynamic overrides are back. */
#if 0
    if (!((layer_flag & view_layer.holdout_layer) && (layer_flag & view_layer.exclude_layer)))
#endif
    {
      sync_light(b_parent,
                 persistent_id,
                 b_ob,
                 b_ob_instance,
                 is_instance ? b_instance.random_id() : 0,
                 tfm,
                 use_portal);
    }

    return NULL;
  }

  /* only interested in object that we can create meshes from */
  if (!object_is_mesh(b_ob)) {
    return NULL;
  }

  /* Perform object culling. */
  if (culling.test(scene, b_ob, tfm)) {
    return NULL;
  }

  /* Visibility flags for both parent and child. */
  PointerRNA cobject = RNA_pointer_get(&b_ob.ptr, "cycles");
  bool use_holdout = get_boolean(cobject, "is_holdout") ||
                     b_parent.holdout_get(PointerRNA_NULL, b_view_layer);
  uint visibility = object_ray_visibility(b_ob) & PATH_RAY_ALL_VISIBILITY;

  if (b_parent.ptr.data != b_ob.ptr.data) {
    visibility &= object_ray_visibility(b_parent);
  }

  /* TODO: make holdout objects on excluded layer invisible for non-camera rays. */
#if 0
  if (use_holdout && (layer_flag & view_layer.exclude_layer)) {
    visibility &= ~(PATH_RAY_ALL_VISIBILITY - PATH_RAY_CAMERA);
  }
#endif

  /* Clear camera visibility for indirect only objects. */
  bool use_indirect_only = b_parent.indirect_only_get(PointerRNA_NULL, b_view_layer);
  if (use_indirect_only) {
    visibility &= ~PATH_RAY_CAMERA;
  }

  /* Don't export completely invisible objects. */
  if (visibility == 0) {
    return NULL;
  }

  /* key to lookup object */
  ObjectKey key(b_parent, persistent_id, b_ob_instance);
  Object *object;

  /* motion vector case */
  if (motion) {
    object = object_map.find(key);

    if (object && object->use_motion()) {
      /* Set transform at matching motion time step. */
      int time_index = object->motion_step(motion_time);
      if (time_index >= 0) {
        object->motion[time_index] = tfm;
      }

      /* mesh deformation */
      if (object->mesh)
        sync_mesh_motion(b_depsgraph, b_ob, object, motion_time);
    }

    return object;
  }

  /* test if we need to sync */
  bool object_updated = false;

  if (object_map.sync(&object, b_ob, b_parent, key))
    object_updated = true;

  /* mesh sync */
  object->mesh = sync_mesh(
      b_depsgraph, b_ob, b_ob_instance, object_updated, show_self, show_particles);

  /* special case not tracked by object update flags */

  /* holdout */
  if (use_holdout != object->use_holdout) {
    object->use_holdout = use_holdout;
    scene->object_manager->tag_update(scene);
    object_updated = true;
  }

  if (visibility != object->visibility) {
    object->visibility = visibility;
    object_updated = true;
  }

  bool is_shadow_catcher = get_boolean(cobject, "is_shadow_catcher");
  if (is_shadow_catcher != object->is_shadow_catcher) {
    object->is_shadow_catcher = is_shadow_catcher;
    object_updated = true;
  }

  /* sync the asset name for Cryptomatte */
  BL::Object parent = b_ob.parent();
  ustring parent_name;
  if (parent) {
    while (parent.parent()) {
      parent = parent.parent();
    }
    parent_name = parent.name();
  }
  else {
    parent_name = b_ob.name();
  }
  if (object->asset_name != parent_name) {
    object->asset_name = parent_name;
    object_updated = true;
  }

  /* 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();
    object->pass_id = b_ob.pass_index();
    object->tfm = tfm;
    object->motion.clear();

    /* motion blur */
    Scene::MotionType need_motion = scene->need_motion();
    if (need_motion != Scene::MOTION_NONE && object->mesh) {
      Mesh *mesh = object->mesh;
      mesh->use_motion_blur = false;
      mesh->motion_steps = 0;

      uint motion_steps;

      if (need_motion == Scene::MOTION_BLUR) {
        motion_steps = object_motion_steps(b_parent, b_ob);
        mesh->motion_steps = motion_steps;
        if (motion_steps && object_use_deform_motion(b_parent, b_ob)) {
          mesh->use_motion_blur = true;
        }
      }
      else {
        motion_steps = 3;
        mesh->motion_steps = motion_steps;
      }

      object->motion.clear();
      object->motion.resize(motion_steps, transform_empty());

      if (motion_steps) {
        object->motion[motion_steps / 2] = tfm;

        for (size_t step = 0; step < motion_steps; step++) {
          motion_times.insert(object->motion_time(step));
        }
      }
    }

    /* dupli texture coordinates and random_id */
    if (is_instance) {
      object->dupli_generated = 0.5f * get_float3(b_instance.orco()) -
                                make_float3(0.5f, 0.5f, 0.5f);
      object->dupli_uv = get_float2(b_instance.uv());
      object->random_id = b_instance.random_id();
    }
    else {
      object->dupli_generated = make_float3(0.0f, 0.0f, 0.0f);
      object->dupli_uv = make_float2(0.0f, 0.0f);
      object->random_id = hash_int_2d(hash_string(object->name.c_str()), 0);
    }

    object->tag_update(scene);
  }

  if (is_instance) {
    /* Sync possible particle data. */
    sync_dupli_particle(b_parent, b_instance, object);
  }

  return object;
}
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)
{
	BL::Object b_ob = (b_dupli_ob ? b_dupli_ob.object() : b_parent);
	
	/* 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);

		return NULL;
	}

	/* only interested in object that we can create meshes from */
	if(!object_is_mesh(b_ob))
		return NULL;

	/* key to lookup object */
	ObjectKey key(b_parent, persistent_id, b_ob);
	Object *object;

	/* 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;
			}

			/* mesh deformation blur not supported yet */
			if(!scene->integrator->motion_blur)
				sync_mesh_motion(b_ob, object->mesh, motion);
		}

		return object;
	}

	/* test if we need to sync */
	bool object_updated = false;

	if(object_map.sync(&object, b_ob, b_parent, key))
		object_updated = true;
	
	bool use_holdout = (layer_flag & render_layer.holdout_layer) != 0;
	
	/* mesh sync */
	object->mesh = sync_mesh(b_ob, object_updated, hide_tris);

	/* special case not tracked by object update flags */

	/* holdout */
	if(use_holdout != object->use_holdout) {
		object->use_holdout = use_holdout;
		scene->object_manager->tag_update(scene);
		object_updated = true;
	}

	/* visibility flags for both parent and child */
	uint visibility = object_ray_visibility(b_ob) & PATH_RAY_ALL_VISIBILITY;
	if(b_parent.ptr.data != b_ob.ptr.data) {
		visibility &= object_ray_visibility(b_parent);
		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))
		visibility &= ~(PATH_RAY_ALL_VISIBILITY - PATH_RAY_CAMERA);

	/* camera flag is not actually used, instead is tested against render layer
	 * flags */
	if(visibility & PATH_RAY_CAMERA) {
		visibility |= layer_flag << PATH_RAY_LAYER_SHIFT;
		visibility &= ~PATH_RAY_CAMERA;
	}

	if(visibility != object->visibility) {
		object->visibility = visibility;
		object_updated = true;
	}

	/* 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();
		object->pass_id = b_ob.pass_index();
		object->tfm = tfm;
		object->motion.pre = tfm;
		object->motion.post = tfm;
		object->use_motion = false;

		/* 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);

		if(b_parent.ptr.data != b_ob.ptr.data)
			object->random_id ^= hash_int(hash_string(b_parent.name().c_str()));

		/* dupli texture coordinates */
		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());
		}
		else {
			object->dupli_generated = make_float3(0.0f, 0.0f, 0.0f);
			object->dupli_uv = make_float2(0.0f, 0.0f);
		}

		object->tag_update(scene);
	}

	return object;
}
Example #8
0
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Sync recalc flags from blender to OctaneRender. Actual update is done separate,
// so we can do it later on if doing it immediate is not suitable.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool BlenderSync::sync_recalc() {
    BL::BlendData::materials_iterator b_mat;
    for(b_data.materials.begin(b_mat); b_mat != b_data.materials.end(); ++b_mat)
        if(b_mat->is_updated() || (b_mat->node_tree() && b_mat->node_tree().is_updated()))
            shader_map.set_recalc(*b_mat);

    //FIXME: Perhaps not needed...
    BL::BlendData::textures_iterator b_tex;
    for(b_data.textures.begin(b_tex); b_tex != b_data.textures.end(); ++b_tex)
        if(b_tex->is_updated() || (b_tex->node_tree() && b_tex->node_tree().is_updated()))
            shader_map.set_recalc(*b_tex);

    BL::BlendData::lamps_iterator b_lamp;
    for(b_data.lamps.begin(b_lamp); b_lamp != b_data.lamps.end(); ++b_lamp)
        if(b_lamp->is_updated() || (b_lamp->node_tree() && b_lamp->node_tree().is_updated()))
            shader_map.set_recalc(*b_lamp);

    BL::BlendData::objects_iterator b_ob;
    for(b_data.objects.begin(b_ob); b_ob != b_data.objects.end(); ++b_ob) {
        if(b_ob->is_updated()) {
            if(object_is_light(*b_ob)) light_object_map.set_recalc(*b_ob);
            else object_map.set_recalc(*b_ob);
        }

        BL::SmokeDomainSettings b_domain = BlenderSync::object_smoke_domain_find(*b_ob);
        if(b_domain && b_domain.cache_file_format() == BL::SmokeDomainSettings::cache_file_format_OPENVDB) { // Workaround, smoke is not tagged for update by BKE_scene_update_for_newframe()
            bool is_export = scene->session->b_session && scene->session->b_session->export_type != ::OctaneEngine::OctaneClient::SceneExportTypes::NONE;
            BL::ID b_ob_data = b_ob->data();
            PointerRNA oct_mesh = RNA_pointer_get(&b_ob_data.ptr, "octane");
            bool is_reshapable = scene->meshes_type == Mesh::RESHAPABLE_PROXY || (scene->meshes_type == Mesh::AS_IS && static_cast<Mesh::MeshType>(RNA_enum_get(&oct_mesh, "mesh_type")) == Mesh::RESHAPABLE_PROXY);

            if(is_export) {
                BL::ID key = BKE_object_is_modified(*b_ob) ? *b_ob : b_ob->data();
                mesh_map.set_recalc(key);
            }
            else if((interactive && is_reshapable) || (!interactive && (scene->anim_mode == FULL || (scene->anim_mode == MOVABLE_PROXIES && is_reshapable)))) {
                BL::ID key = BKE_object_is_modified(*b_ob) ? *b_ob : b_ob->data();
                mesh_map.set_recalc(key);
            }
        }
        else if(object_is_curve(*b_ob)) { // Workaround, curves are not tagged for update by BKE_scene_update_for_newframe()
            if(b_ob->is_updated_data() || b_ob->data().is_updated()) {
                BL::ID key = BKE_object_is_modified(*b_ob) ? *b_ob : b_ob->data();
                mesh_map.set_recalc(key);
            }
            else {
                bool is_export = scene->session->b_session && scene->session->b_session->export_type != ::OctaneEngine::OctaneClient::SceneExportTypes::NONE;
                BL::ID b_ob_data = b_ob->data();
                PointerRNA oct_mesh = RNA_pointer_get(&b_ob_data.ptr, "octane");
                bool is_reshapable = scene->meshes_type == Mesh::RESHAPABLE_PROXY || (scene->meshes_type == Mesh::AS_IS && static_cast<Mesh::MeshType>(RNA_enum_get(&oct_mesh, "mesh_type")) == Mesh::RESHAPABLE_PROXY);

                if(is_export) {
                    BL::ID key = BKE_object_is_modified(*b_ob) ? *b_ob : b_ob->data();
                    mesh_map.set_recalc(key);
                }
                else if((interactive && is_reshapable) || (!interactive && (scene->anim_mode == FULL || (scene->anim_mode == MOVABLE_PROXIES && is_reshapable)))) {
                    BL::ID key = BKE_object_is_modified(*b_ob) ? *b_ob : b_ob->data();
                    mesh_map.set_recalc(key);
                }
            }
        }
        else if(object_is_mesh(*b_ob)) {
            if(b_ob->is_updated_data() || b_ob->data().is_updated()) {
                BL::ID key = BKE_object_is_modified(*b_ob) ? *b_ob : b_ob->data();
                mesh_map.set_recalc(key);
            }
            else if(!interactive && BKE_object_is_modified(*b_ob)) { // Workaround, some modified meshes are not tagged for update by BKE_scene_update_for_newframe()
                bool is_export = scene->session->b_session && scene->session->b_session->export_type != ::OctaneEngine::OctaneClient::SceneExportTypes::NONE;
                BL::ID b_ob_data = b_ob->data();
                PointerRNA oct_mesh = RNA_pointer_get(&b_ob_data.ptr, "octane");
                bool is_reshapable = scene->meshes_type == Mesh::RESHAPABLE_PROXY || (scene->meshes_type == Mesh::AS_IS && static_cast<Mesh::MeshType>(RNA_enum_get(&oct_mesh, "mesh_type")) == Mesh::RESHAPABLE_PROXY);

                if(is_export) {
                    BL::ID key = *b_ob;
                    mesh_map.set_recalc(key);
                }
                else if(scene->anim_mode == FULL || (scene->anim_mode == MOVABLE_PROXIES && is_reshapable)) {
                    BL::ID key = *b_ob;
                    mesh_map.set_recalc(key);
                }
            }
        }
        else if(object_is_light(*b_ob)) {
            if(b_ob->is_updated_data() || b_ob->data().is_updated())
                light_map.set_recalc(b_ob->data());
        }
    }

    //BL::BlendData::meshes_iterator b_mesh;
    //for(b_data.meshes.begin(b_mesh); b_mesh != b_data.meshes.end(); ++b_mesh)
    //	if(b_mesh->is_updated() || b_mesh->is_updated_data())
    //		mesh_map.set_recalc(*b_mesh);

    BL::BlendData::worlds_iterator b_world;
    for(b_data.worlds.begin(b_world); b_world != b_data.worlds.end(); ++b_world) {
        if(world_map == b_world->ptr.data && (b_world->is_updated() || (b_world->node_tree() && b_world->node_tree().is_updated()))) {
            world_recalc = true;
        }
    }

    bool recalc =
        shader_map.has_recalc() ||
        object_map.has_recalc() ||
        light_map.has_recalc() ||
        mesh_map.has_recalc() ||
        BlendDataObjects_is_updated_get(&b_data.ptr) ||
        world_recalc;

    return recalc;
} //sync_recalc()
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, float motion_time, bool hide_tris)
{
	BL::Object b_ob = (b_dupli_ob ? b_dupli_ob.object() : b_parent);
	bool motion = motion_time != 0.0f;
	
	/* 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);

		return NULL;
	}

	/* only interested in object that we can create meshes from */
	if(!object_is_mesh(b_ob))
		return NULL;

	/* key to lookup object */
	ObjectKey key(b_parent, persistent_id, b_ob);
	Object *object;

	/* motion vector case */
	if(motion) {
		object = object_map.find(key);

		if(object && (scene->need_motion() == Scene::MOTION_PASS || object_use_motion(b_ob))) {
			/* object transformation */
			if(tfm != object->tfm) {
				if(motion_time == -1.0f) {
					object->motion.pre = tfm;
					object->use_motion = true;
				}
				else if(motion_time == 1.0f) {
					object->motion.post = tfm;
					object->use_motion = true;
				}
			}

			/* mesh deformation */
			if(object->mesh)
				sync_mesh_motion(b_ob, object, motion_time);
		}

		return object;
	}

	/* test if we need to sync */
	bool object_updated = false;

	if(object_map.sync(&object, b_ob, b_parent, key))
		object_updated = true;
	
	bool use_holdout = (layer_flag & render_layer.holdout_layer) != 0;
	
	/* mesh sync */
	object->mesh = sync_mesh(b_ob, object_updated, hide_tris);

	/* special case not tracked by object update flags */

	/* holdout */
	if(use_holdout != object->use_holdout) {
		object->use_holdout = use_holdout;
		scene->object_manager->tag_update(scene);
		object_updated = true;
	}

	/* visibility flags for both parent and child */
	uint visibility = object_ray_visibility(b_ob) & PATH_RAY_ALL_VISIBILITY;
	if(b_parent.ptr.data != b_ob.ptr.data) {
		visibility &= object_ray_visibility(b_parent);
	}

	/* make holdout objects on excluded layer invisible for non-camera rays */
	if(use_holdout && (layer_flag & render_layer.exclude_layer))
		visibility &= ~(PATH_RAY_ALL_VISIBILITY - PATH_RAY_CAMERA);

	/* camera flag is not actually used, instead is tested against render layer
	 * flags */
	if(visibility & PATH_RAY_CAMERA) {
		visibility |= layer_flag << PATH_RAY_LAYER_SHIFT;
		visibility &= ~PATH_RAY_CAMERA;
	}

	if(visibility != object->visibility) {
		object->visibility = visibility;
		object_updated = true;
	}

	/* 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();
		object->pass_id = b_ob.pass_index();
		object->tfm = tfm;
		object->motion.pre = tfm;
		object->motion.post = tfm;
		object->use_motion = false;

		/* motion blur */
		if(scene->need_motion() == Scene::MOTION_BLUR && object->mesh) {
			Mesh *mesh = object->mesh;

			mesh->use_motion_blur = false;

			if(object_use_motion(b_ob)) {
				if(object_use_deform_motion(b_ob)) {
					mesh->motion_steps = object_motion_steps(b_ob);
					mesh->use_motion_blur = true;
				}

				vector<float> times = object->motion_times();
				foreach(float time, times)
					motion_times.insert(time);
			}
		}