Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/mesh_wrapper.c
| Show First 20 Lines • Show All 338 Lines • ▼ Show 20 Lines | static Mesh *mesh_wrapper_ensure_subdivision(const Object *ob, Mesh *me) | ||||
| SubsurfRuntimeData *runtime_data = BKE_subsurf_modifier_ensure_runtime(smd); | SubsurfRuntimeData *runtime_data = BKE_subsurf_modifier_ensure_runtime(smd); | ||||
| Subdiv *subdiv = BKE_subsurf_modifier_subdiv_descriptor_ensure(smd, &subdiv_settings, me, false); | Subdiv *subdiv = BKE_subsurf_modifier_subdiv_descriptor_ensure(smd, &subdiv_settings, me, false); | ||||
| if (subdiv == NULL) { | if (subdiv == NULL) { | ||||
| /* Happens on bad topology, but also on empty input mesh. */ | /* Happens on bad topology, but also on empty input mesh. */ | ||||
| return me; | return me; | ||||
| } | } | ||||
| const bool use_clnors = BKE_subsurf_modifier_use_custom_loop_normals(smd, me); | |||||
| if (use_clnors) { | |||||
| /* If custom normals are present and the option is turned on calculate the split | |||||
| * normals and clear flag so the normals get interpolated to the result mesh. */ | |||||
| BKE_mesh_calc_normals_split(me); | |||||
| CustomData_clear_layer_flag(&me->ldata, CD_NORMAL, CD_FLAG_TEMPORARY); | |||||
| } | |||||
| Mesh *subdiv_mesh = BKE_subdiv_to_mesh(subdiv, &mesh_settings, me); | Mesh *subdiv_mesh = BKE_subdiv_to_mesh(subdiv, &mesh_settings, me); | ||||
| if (use_clnors) { | |||||
| float(*lnors)[3] = CustomData_get_layer(&subdiv_mesh->ldata, CD_NORMAL); | |||||
| BLI_assert(lnors != NULL); | |||||
| BKE_mesh_set_custom_normals(subdiv_mesh, lnors); | |||||
| CustomData_set_layer_flag(&me->ldata, CD_NORMAL, CD_FLAG_TEMPORARY); | |||||
| CustomData_set_layer_flag(&subdiv_mesh->ldata, CD_NORMAL, CD_FLAG_TEMPORARY); | |||||
| } | |||||
| else if (me->runtime.subsurf_do_loop_normals) { | |||||
| BKE_mesh_calc_normals_split(subdiv_mesh); | |||||
| BKE_mesh_tessface_clear(subdiv_mesh); | |||||
brecht: `BKE_mesh_tessface_clear` is unnecessary and can be removed, I removed it from the place you… | |||||
| } | |||||
| if (subdiv != runtime_data->subdiv) { | if (subdiv != runtime_data->subdiv) { | ||||
| BKE_subdiv_free(subdiv); | BKE_subdiv_free(subdiv); | ||||
| } | } | ||||
| if (subdiv_mesh != me) { | if (subdiv_mesh != me) { | ||||
| if (me->runtime.mesh_eval != NULL) { | if (me->runtime.mesh_eval != NULL) { | ||||
| BKE_id_free(NULL, me->runtime.mesh_eval); | BKE_id_free(NULL, me->runtime.mesh_eval); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines | |||||
BKE_mesh_tessface_clear is unnecessary and can be removed, I removed it from the place you copied it from in rB51a7e4b488a4: Cleanup: remove unused mface tesselation code from modifier stack.