Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/blender/blender_object.cpp
| Show First 20 Lines • Show All 238 Lines • ▼ Show 20 Lines | #endif | ||||
| if (sync_object_attributes(b_instance, object)) { | if (sync_object_attributes(b_instance, object)) { | ||||
| object_updated = true; | object_updated = true; | ||||
| } | } | ||||
| /* holdout */ | /* holdout */ | ||||
| object->set_use_holdout(use_holdout); | object->set_use_holdout(use_holdout); | ||||
| if (object->use_holdout_is_modified()) { | if (object->use_holdout_is_modified()) { | ||||
| scene->object_manager->tag_update(scene); | scene->get_object_manager()->tag_update(scene); | ||||
| } | } | ||||
| object->set_visibility(visibility); | object->set_visibility(visibility); | ||||
| bool is_shadow_catcher = get_boolean(cobject, "is_shadow_catcher"); | bool is_shadow_catcher = get_boolean(cobject, "is_shadow_catcher"); | ||||
| object->set_is_shadow_catcher(is_shadow_catcher); | object->set_is_shadow_catcher(is_shadow_catcher); | ||||
| float shadow_terminator_offset = get_float(cobject, "shadow_terminator_offset"); | float shadow_terminator_offset = get_float(cobject, "shadow_terminator_offset"); | ||||
| Show All 14 Lines | #endif | ||||
| object->set_asset_name(parent_name); | object->set_asset_name(parent_name); | ||||
| /* object sync | /* object sync | ||||
| * transform comparison should not be needed, but duplis don't work perfect | * 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 */ | * in the depsgraph and may not signal changes, so this is a workaround */ | ||||
| if (object->is_modified() || object_updated || | if (object->is_modified() || object_updated || | ||||
| (object->get_geometry() && object->get_geometry()->is_modified()) || | (object->get_geometry() && object->get_geometry()->is_modified()) || | ||||
| tfm != object->get_tfm()) { | tfm != object->get_tfm()) { | ||||
| object->name = b_ob.name().c_str(); | object->set_name(ustring(b_ob.name().c_str())); | ||||
| object->set_pass_id(b_ob.pass_index()); | object->set_pass_id(b_ob.pass_index()); | ||||
| object->set_color(get_float3(b_ob.color())); | object->set_color(get_float3(b_ob.color())); | ||||
| object->set_tfm(tfm); | object->set_tfm(tfm); | ||||
| array<Transform> motion; | array<Transform> motion; | ||||
| object->set_motion(motion); | object->set_motion(motion); | ||||
| /* motion blur */ | /* motion blur */ | ||||
| Scene::MotionType need_motion = scene->need_motion(); | Scene::MotionType need_motion = scene->need_motion(); | ||||
| Show All 35 Lines | if (is_instance) { | ||||
| object->set_dupli_generated(0.5f * get_float3(b_instance.orco()) - | object->set_dupli_generated(0.5f * get_float3(b_instance.orco()) - | ||||
| make_float3(0.5f, 0.5f, 0.5f)); | make_float3(0.5f, 0.5f, 0.5f)); | ||||
| object->set_dupli_uv(get_float2(b_instance.uv())); | object->set_dupli_uv(get_float2(b_instance.uv())); | ||||
| object->set_random_id(b_instance.random_id()); | object->set_random_id(b_instance.random_id()); | ||||
| } | } | ||||
| else { | else { | ||||
| object->set_dupli_generated(make_float3(0.0f, 0.0f, 0.0f)); | object->set_dupli_generated(make_float3(0.0f, 0.0f, 0.0f)); | ||||
| object->set_dupli_uv(make_float2(0.0f, 0.0f)); | object->set_dupli_uv(make_float2(0.0f, 0.0f)); | ||||
| object->set_random_id(hash_uint2(hash_string(object->name.c_str()), 0)); | object->set_random_id(hash_uint2(hash_string(object->get_name().c_str()), 0)); | ||||
| } | } | ||||
| object->tag_update(scene); | object->tag_update(scene); | ||||
| } | } | ||||
| if (is_instance) { | if (is_instance) { | ||||
| /* Sync possible particle data. */ | /* Sync possible particle data. */ | ||||
| sync_dupli_particle(b_parent, b_instance, object); | sync_dupli_particle(b_parent, b_instance, object); | ||||
| ▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| bool BlenderSync::sync_object_attributes(BL::DepsgraphObjectInstance &b_instance, Object *object) | bool BlenderSync::sync_object_attributes(BL::DepsgraphObjectInstance &b_instance, Object *object) | ||||
| { | { | ||||
| /* Find which attributes are needed. */ | /* Find which attributes are needed. */ | ||||
| AttributeRequestSet requests = object->get_geometry()->needed_attributes(); | AttributeRequestSet requests = object->get_geometry()->needed_attributes(); | ||||
| /* Delete attributes that became unnecessary. */ | /* Delete attributes that became unnecessary. */ | ||||
| vector<ParamValue> &attributes = object->attributes; | vector<ParamValue> &attributes = object->get_attributes(); | ||||
| bool changed = false; | bool changed = false; | ||||
| for (int i = attributes.size() - 1; i >= 0; i--) { | for (int i = attributes.size() - 1; i >= 0; i--) { | ||||
| if (!requests.find(attributes[i].name())) { | if (!requests.find(attributes[i].name())) { | ||||
| attributes.erase(attributes.begin() + i); | attributes.erase(attributes.begin() + i); | ||||
| changed = true; | changed = true; | ||||
| } | } | ||||
| } | } | ||||
| /* Update attribute values. */ | /* Update attribute values. */ | ||||
| foreach (AttributeRequest &req, requests.requests) { | foreach (const AttributeRequest &req, requests.get_requests()) { | ||||
| ustring name = req.name; | const ustring &name = req.get_name(); | ||||
| std::string real_name; | std::string real_name; | ||||
| BlenderAttributeType type = blender_attribute_name_split_type(name, &real_name); | BlenderAttributeType type = blender_attribute_name_split_type(name, &real_name); | ||||
| if (type != BL::ShaderNodeAttribute::attribute_type_GEOMETRY) { | if (type != BL::ShaderNodeAttribute::attribute_type_GEOMETRY) { | ||||
| bool use_instancer = (type == BL::ShaderNodeAttribute::attribute_type_INSTANCER); | bool use_instancer = (type == BL::ShaderNodeAttribute::attribute_type_INSTANCER); | ||||
| float4 value = lookup_instance_property(b_instance, real_name, use_instancer); | float4 value = lookup_instance_property(b_instance, real_name, use_instancer); | ||||
| ▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | void BlenderSync::sync_motion(BL::RenderSettings &b_render, | ||||
| if (b_override) | if (b_override) | ||||
| b_cam = b_override; | b_cam = b_override; | ||||
| int frame_center = b_scene.frame_current(); | int frame_center = b_scene.frame_current(); | ||||
| float subframe_center = b_scene.frame_subframe(); | float subframe_center = b_scene.frame_subframe(); | ||||
| float frame_center_delta = 0.0f; | float frame_center_delta = 0.0f; | ||||
| if (scene->need_motion() != Scene::MOTION_PASS && | if (scene->need_motion() != Scene::MOTION_PASS && | ||||
| scene->camera->get_motion_position() != Camera::MOTION_POSITION_CENTER) { | scene->get_camera()->get_motion_position() != Camera::MOTION_POSITION_CENTER) { | ||||
| float shuttertime = scene->camera->get_shuttertime(); | float shuttertime = scene->get_camera()->get_shuttertime(); | ||||
| if (scene->camera->get_motion_position() == Camera::MOTION_POSITION_END) { | if (scene->get_camera()->get_motion_position() == Camera::MOTION_POSITION_END) { | ||||
| frame_center_delta = -shuttertime * 0.5f; | frame_center_delta = -shuttertime * 0.5f; | ||||
| } | } | ||||
| else { | else { | ||||
| assert(scene->camera->get_motion_position() == Camera::MOTION_POSITION_START); | assert(scene->get_camera()->get_motion_position() == Camera::MOTION_POSITION_START); | ||||
| frame_center_delta = shuttertime * 0.5f; | frame_center_delta = shuttertime * 0.5f; | ||||
| } | } | ||||
| float time = frame_center + subframe_center + frame_center_delta; | float time = frame_center + subframe_center + frame_center_delta; | ||||
| int frame = (int)floorf(time); | int frame = (int)floorf(time); | ||||
| float subframe = time - frame; | float subframe = time - frame; | ||||
| python_thread_state_restore(python_thread_state); | python_thread_state_restore(python_thread_state); | ||||
| b_engine.frame_set(frame, subframe); | b_engine.frame_set(frame, subframe); | ||||
| python_thread_state_save(python_thread_state); | python_thread_state_save(python_thread_state); | ||||
| if (b_cam) { | if (b_cam) { | ||||
| sync_camera_motion(b_render, b_cam, width, height, 0.0f); | sync_camera_motion(b_render, b_cam, width, height, 0.0f); | ||||
| } | } | ||||
| sync_objects(b_depsgraph, b_v3d, 0.0f); | sync_objects(b_depsgraph, b_v3d, 0.0f); | ||||
| } | } | ||||
| /* Insert motion times from camera. Motion times from other objects | /* Insert motion times from camera. Motion times from other objects | ||||
| * have already been added in a sync_objects call. */ | * have already been added in a sync_objects call. */ | ||||
| if (b_cam) { | if (b_cam) { | ||||
| uint camera_motion_steps = object_motion_steps(b_cam, b_cam); | uint camera_motion_steps = object_motion_steps(b_cam, b_cam); | ||||
| for (size_t step = 0; step < camera_motion_steps; step++) { | for (size_t step = 0; step < camera_motion_steps; step++) { | ||||
| motion_times.insert(scene->camera->motion_time(step)); | motion_times.insert(scene->get_camera()->motion_time(step)); | ||||
| } | } | ||||
| } | } | ||||
| /* note iteration over motion_times set happens in sorted order */ | /* note iteration over motion_times set happens in sorted order */ | ||||
| foreach (float relative_time, motion_times) { | foreach (float relative_time, motion_times) { | ||||
| /* center time is already handled. */ | /* center time is already handled. */ | ||||
| if (relative_time == 0.0f) { | if (relative_time == 0.0f) { | ||||
| continue; | continue; | ||||
| Show All 34 Lines | |||||