Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/blender/blender_mesh.cpp
| Show First 20 Lines • Show All 766 Lines • ▼ Show 20 Lines | static void create_subd_mesh(Scene *scene, | ||||
| PointerRNA *cmesh, | PointerRNA *cmesh, | ||||
| const vector<Shader*>& used_shaders, | const vector<Shader*>& used_shaders, | ||||
| float dicing_rate, | float dicing_rate, | ||||
| int max_subdivisions) | int max_subdivisions) | ||||
| { | { | ||||
| create_mesh(scene, mesh, b_mesh, used_shaders, true); | create_mesh(scene, mesh, b_mesh, used_shaders, true); | ||||
| SubdParams sdparams(mesh); | SubdParams sdparams(mesh); | ||||
| sdparams.dicing_rate = max(0.1f, RNA_float_get(cmesh, "dicing_rate") * dicing_rate); | |||||
| PointerRNA cobj = RNA_pointer_get(&b_ob.ptr, "cycles"); | |||||
| sdparams.dicing_rate = max(0.1f, RNA_float_get(&cobj, "dicing_rate") * dicing_rate); | |||||
| sdparams.max_level = max_subdivisions; | sdparams.max_level = max_subdivisions; | ||||
| scene->camera->update(); | scene->camera->update(); | ||||
| sdparams.camera = scene->camera; | sdparams.camera = scene->camera; | ||||
| sdparams.objecttoworld = get_transform(b_ob.matrix_world()); | sdparams.objecttoworld = get_transform(b_ob.matrix_world()); | ||||
| /* tesselate */ | /* tesselate */ | ||||
| DiagSplit dsplit(sdparams); | DiagSplit dsplit(sdparams); | ||||
| ▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | if(requested_geometry_flags != Mesh::GEOMETRY_NONE) { | ||||
| * | * | ||||
| * updating meshes here will end up having derived mesh referencing | * updating meshes here will end up having derived mesh referencing | ||||
| * freed data from the blender side. | * freed data from the blender side. | ||||
| */ | */ | ||||
| if(preview && b_ob.type() != BL::Object::type_MESH) | if(preview && b_ob.type() != BL::Object::type_MESH) | ||||
| b_ob.update_from_editmode(); | b_ob.update_from_editmode(); | ||||
| bool need_undeformed = mesh->need_attribute(scene, ATTR_STD_GENERATED); | bool need_undeformed = mesh->need_attribute(scene, ATTR_STD_GENERATED); | ||||
| bool subdivision = experimental && cmesh.data && RNA_enum_get(&cmesh, "subdivision_type"); | |||||
| BL::Mesh b_mesh = object_to_mesh(b_data, b_ob, b_scene, true, !preview, need_undeformed, subdivision); | mesh->subdivision_type = Mesh::SUBDIVISION_NONE; | ||||
| PointerRNA cobj = RNA_pointer_get(&b_ob.ptr, "cycles"); | |||||
| if(cobj.data && b_ob.modifiers.length() > 0 && experimental) { | |||||
| BL::Modifier mod = b_ob.modifiers[b_ob.modifiers.length()-1]; | |||||
| if(mod.type() == BL::Modifier::type_SUBSURF && RNA_int_get(&cobj, "use_cycles_subdivision")) { | |||||
brecht: We should check if the modifier is actually enabled here. | |||||
| BL::SubsurfModifier subsurf(mod); | |||||
| if(subsurf.subdivision_type() == BL::SubsurfModifier::subdivision_type_CATMULL_CLARK) { | |||||
| mesh->subdivision_type = Mesh::SUBDIVISION_CATMULL_CLARK; | |||||
| } | |||||
| else { | |||||
| mesh->subdivision_type = Mesh::SUBDIVISION_LINEAR; | |||||
| } | |||||
| } | |||||
| } | |||||
| BL::Mesh b_mesh = object_to_mesh(b_data, b_ob, b_scene, true, !preview, need_undeformed, mesh->subdivision_type); | |||||
| if(b_mesh) { | if(b_mesh) { | ||||
| if(render_layer.use_surfaces && !hide_tris) { | if(render_layer.use_surfaces && !hide_tris) { | ||||
| if(subdivision) | if(mesh->subdivision_type != Mesh::SUBDIVISION_NONE) | ||||
| create_subd_mesh(scene, mesh, b_ob, b_mesh, &cmesh, used_shaders, | create_subd_mesh(scene, mesh, b_ob, b_mesh, &cmesh, 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 && !subdivision) | if(render_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); | b_data.meshes.remove(b_mesh, false); | ||||
| ▲ Show 20 Lines • Show All 216 Lines • Show Last 20 Lines | |||||
We should check if the modifier is actually enabled here.