Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/blender/blender_mesh.cpp
| Show First 20 Lines • Show All 974 Lines • ▼ Show 20 Lines | Mesh *BlenderSync::sync_mesh(BL::Object& b_ob, | ||||
| */ | */ | ||||
| const bool is_interface_locked = b_engine.render() && | const bool is_interface_locked = b_engine.render() && | ||||
| b_engine.render().use_lock_interface(); | b_engine.render().use_lock_interface(); | ||||
| const bool can_free_caches = BlenderSession::headless || is_interface_locked; | const bool can_free_caches = BlenderSession::headless || is_interface_locked; | ||||
| /* test if we can instance or if the object is modified */ | /* test if we can instance or if the object is modified */ | ||||
| BL::ID b_ob_data = b_ob.data(); | BL::ID b_ob_data = b_ob.data(); | ||||
| BL::ID key = (BKE_object_is_modified(b_ob))? b_ob_instance: b_ob_data; | BL::ID key = (BKE_object_is_modified(b_ob))? b_ob_instance: b_ob_data; | ||||
| BL::Material material_override = render_layer.material_override; | BL::Material material_override = view_layer.material_override; | ||||
| /* find shader indices */ | /* find shader indices */ | ||||
| vector<Shader*> used_shaders; | vector<Shader*> used_shaders; | ||||
| BL::Object::material_slots_iterator slot; | BL::Object::material_slots_iterator slot; | ||||
| for(b_ob.material_slots.begin(slot); slot != b_ob.material_slots.end(); ++slot) { | for(b_ob.material_slots.begin(slot); slot != b_ob.material_slots.end(); ++slot) { | ||||
| if(material_override) { | if(material_override) { | ||||
| find_shader(material_override, used_shaders, scene->default_surface); | find_shader(material_override, used_shaders, scene->default_surface); | ||||
| } | } | ||||
| else { | else { | ||||
| BL::ID b_material(slot->material()); | BL::ID b_material(slot->material()); | ||||
| find_shader(b_material, used_shaders, scene->default_surface); | find_shader(b_material, used_shaders, scene->default_surface); | ||||
| } | } | ||||
| } | } | ||||
| if(used_shaders.size() == 0) { | if(used_shaders.size() == 0) { | ||||
| if(material_override) | if(material_override) | ||||
| find_shader(material_override, used_shaders, scene->default_surface); | find_shader(material_override, used_shaders, scene->default_surface); | ||||
| else | else | ||||
| used_shaders.push_back(scene->default_surface); | used_shaders.push_back(scene->default_surface); | ||||
| } | } | ||||
| /* test if we need to sync */ | /* test if we need to sync */ | ||||
| int requested_geometry_flags = Mesh::GEOMETRY_NONE; | int requested_geometry_flags = Mesh::GEOMETRY_NONE; | ||||
| if(render_layer.use_surfaces) { | if(view_layer.use_surfaces) { | ||||
| requested_geometry_flags |= Mesh::GEOMETRY_TRIANGLES; | requested_geometry_flags |= Mesh::GEOMETRY_TRIANGLES; | ||||
| } | } | ||||
| if(render_layer.use_hair) { | if(view_layer.use_hair) { | ||||
| requested_geometry_flags |= Mesh::GEOMETRY_CURVES; | requested_geometry_flags |= Mesh::GEOMETRY_CURVES; | ||||
| } | } | ||||
| Mesh *mesh; | Mesh *mesh; | ||||
| if(!mesh_map.sync(&mesh, key)) { | if(!mesh_map.sync(&mesh, key)) { | ||||
| /* if transform was applied to mesh, need full update */ | /* if transform was applied to mesh, need full update */ | ||||
| if(object_updated && mesh->transform_applied); | if(object_updated && mesh->transform_applied); | ||||
| /* test if shaders changed, these can be object level so mesh | /* test if shaders changed, these can be object level so mesh | ||||
| ▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | if(requested_geometry_flags != Mesh::GEOMETRY_NONE) { | ||||
| */ | */ | ||||
| if(scene->bake_manager->get_baking()) { | if(scene->bake_manager->get_baking()) { | ||||
| mesh->subdivision_type = Mesh::SUBDIVISION_NONE; | mesh->subdivision_type = Mesh::SUBDIVISION_NONE; | ||||
| } | } | ||||
| BL::Mesh b_mesh = object_to_mesh(b_data, | BL::Mesh b_mesh = object_to_mesh(b_data, | ||||
| b_ob, | b_ob, | ||||
| b_scene, | b_scene, | ||||
| b_scene_layer, | b_view_layer, | ||||
| true, | true, | ||||
| !preview, | !preview, | ||||
| need_undeformed, | need_undeformed, | ||||
| mesh->subdivision_type); | mesh->subdivision_type); | ||||
| if(b_mesh) { | if(b_mesh) { | ||||
| if(render_layer.use_surfaces && !hide_tris) { | if(view_layer.use_surfaces && !hide_tris) { | ||||
| if(mesh->subdivision_type != Mesh::SUBDIVISION_NONE) | if(mesh->subdivision_type != Mesh::SUBDIVISION_NONE) | ||||
| create_subd_mesh(scene, mesh, b_ob, b_mesh, used_shaders, | create_subd_mesh(scene, mesh, b_ob, b_mesh, used_shaders, | ||||
| dicing_rate, max_subdivisions); | dicing_rate, max_subdivisions); | ||||
| else | else | ||||
| create_mesh(scene, mesh, b_mesh, used_shaders, false); | create_mesh(scene, mesh, b_mesh, used_shaders, false); | ||||
| create_mesh_volume_attributes(scene, b_ob, mesh, b_scene.frame_current()); | create_mesh_volume_attributes(scene, b_ob, mesh, b_scene.frame_current()); | ||||
| } | } | ||||
| if(render_layer.use_hair && mesh->subdivision_type == Mesh::SUBDIVISION_NONE) | if(view_layer.use_hair && mesh->subdivision_type == Mesh::SUBDIVISION_NONE) | ||||
| sync_curves(mesh, b_mesh, b_ob, false); | sync_curves(mesh, b_mesh, b_ob, false); | ||||
| if(can_free_caches) { | if(can_free_caches) { | ||||
| b_ob.cache_release(); | b_ob.cache_release(); | ||||
| } | } | ||||
| /* free derived mesh */ | /* free derived mesh */ | ||||
| b_data.meshes.remove(b_mesh, false, true, false); | b_data.meshes.remove(b_mesh, false, true, false); | ||||
| ▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | void BlenderSync::sync_mesh_motion(BL::Object& b_ob, | ||||
| if(b_fluid_domain) | if(b_fluid_domain) | ||||
| return; | return; | ||||
| if(ccl::BKE_object_is_deform_modified(b_ob, b_scene, preview)) { | if(ccl::BKE_object_is_deform_modified(b_ob, b_scene, preview)) { | ||||
| /* get derived mesh */ | /* get derived mesh */ | ||||
| b_mesh = object_to_mesh(b_data, | b_mesh = object_to_mesh(b_data, | ||||
| b_ob, | b_ob, | ||||
| b_scene, | b_scene, | ||||
| b_scene_layer, | b_view_layer, | ||||
| true, | true, | ||||
| !preview, | !preview, | ||||
| false, | false, | ||||
| Mesh::SUBDIVISION_NONE); | Mesh::SUBDIVISION_NONE); | ||||
| } | } | ||||
| if(!b_mesh) { | if(!b_mesh) { | ||||
| /* if we have no motion blur on this frame, but on other frames, copy */ | /* if we have no motion blur on this frame, but on other frames, copy */ | ||||
| ▲ Show 20 Lines • Show All 109 Lines • Show Last 20 Lines | |||||