Cleanup: indentation from braces in '#if 0'
This commit is contained in:
parent
ab33692bc2
commit
5ca8ac51d0
|
@ -544,114 +544,115 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
|
|||
* Once we fully switch to Mesh evaluation of modifiers, we can expect to get that flag from the COW copy.
|
||||
* But for now, it is lost in the DM intermediate step, so we need to directly check orig object's data. */
|
||||
#if 0
|
||||
if (!(mesh->flag & ME_AUTOSMOOTH)) {
|
||||
if (!(mesh->flag & ME_AUTOSMOOTH))
|
||||
#else
|
||||
if (!(((Mesh *)ob->data)->flag & ME_AUTOSMOOTH)) {
|
||||
if (!(((Mesh *)ob->data)->flag & ME_AUTOSMOOTH))
|
||||
#endif
|
||||
modifier_setError((ModifierData *)wnmd, "Enable 'Auto Smooth' option in mesh settings");
|
||||
return mesh;
|
||||
}
|
||||
{
|
||||
modifier_setError((ModifierData *)wnmd, "Enable 'Auto Smooth' option in mesh settings");
|
||||
return mesh;
|
||||
}
|
||||
|
||||
Mesh *result;
|
||||
BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
|
||||
Mesh *result;
|
||||
BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
|
||||
|
||||
const int numVerts = result->totvert;
|
||||
const int numEdges = result->totedge;
|
||||
const int numLoops = result->totloop;
|
||||
const int numPolys = result->totpoly;
|
||||
const int numVerts = result->totvert;
|
||||
const int numEdges = result->totedge;
|
||||
const int numLoops = result->totloop;
|
||||
const int numPolys = result->totpoly;
|
||||
|
||||
MEdge *medge = result->medge;
|
||||
MPoly *mpoly = result->mpoly;
|
||||
MVert *mvert = result->mvert;
|
||||
MLoop *mloop = result->mloop;
|
||||
MEdge *medge = result->medge;
|
||||
MPoly *mpoly = result->mpoly;
|
||||
MVert *mvert = result->mvert;
|
||||
MLoop *mloop = result->mloop;
|
||||
|
||||
/* Right now:
|
||||
/* Right now:
|
||||
* If weight = 50 then all faces are given equal weight.
|
||||
* If weight > 50 then more weight given to faces with larger vals (face area / corner angle).
|
||||
* If weight < 50 then more weight given to faces with lesser vals. However current calculation
|
||||
* does not converge to min/max.
|
||||
*/
|
||||
float weight = ((float)wnmd->weight) / 50.0f;
|
||||
if (wnmd->weight == 100) {
|
||||
weight = (float)SHRT_MAX;
|
||||
}
|
||||
else if (wnmd->weight == 1) {
|
||||
weight = 1 / (float)SHRT_MAX;
|
||||
}
|
||||
else if ((weight - 1) * 25 > 1) {
|
||||
weight = (weight - 1) * 25;
|
||||
}
|
||||
float weight = ((float)wnmd->weight) / 50.0f;
|
||||
if (wnmd->weight == 100) {
|
||||
weight = (float)SHRT_MAX;
|
||||
}
|
||||
else if (wnmd->weight == 1) {
|
||||
weight = 1 / (float)SHRT_MAX;
|
||||
}
|
||||
else if ((weight - 1) * 25 > 1) {
|
||||
weight = (weight - 1) * 25;
|
||||
}
|
||||
|
||||
CustomData *pdata = &result->pdata;
|
||||
float (*polynors)[3] = CustomData_get_layer(pdata, CD_NORMAL);
|
||||
if (!polynors) {
|
||||
polynors = CustomData_add_layer(pdata, CD_NORMAL, CD_CALLOC, NULL, numPolys);
|
||||
CustomData_set_layer_flag(pdata, CD_NORMAL, CD_FLAG_TEMPORARY);
|
||||
}
|
||||
BKE_mesh_calc_normals_poly(
|
||||
mvert, NULL, numVerts, mloop, mpoly, numLoops, numPolys, polynors, false);
|
||||
CustomData *pdata = &result->pdata;
|
||||
float(*polynors)[3] = CustomData_get_layer(pdata, CD_NORMAL);
|
||||
if (!polynors) {
|
||||
polynors = CustomData_add_layer(pdata, CD_NORMAL, CD_CALLOC, NULL, numPolys);
|
||||
CustomData_set_layer_flag(pdata, CD_NORMAL, CD_FLAG_TEMPORARY);
|
||||
}
|
||||
BKE_mesh_calc_normals_poly(
|
||||
mvert, NULL, numVerts, mloop, mpoly, numLoops, numPolys, polynors, false);
|
||||
|
||||
const float split_angle = mesh->smoothresh;
|
||||
short (*clnors)[2];
|
||||
CustomData *ldata = &result->ldata;
|
||||
clnors = CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL);
|
||||
const float split_angle = mesh->smoothresh;
|
||||
short(*clnors)[2];
|
||||
CustomData *ldata = &result->ldata;
|
||||
clnors = CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL);
|
||||
|
||||
/* Keep info whether we had clnors, it helps when generating clnor spaces and default normals. */
|
||||
const bool has_clnors = clnors != NULL;
|
||||
if (!clnors) {
|
||||
clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, numLoops);
|
||||
}
|
||||
/* Keep info whether we had clnors, it helps when generating clnor spaces and default normals. */
|
||||
const bool has_clnors = clnors != NULL;
|
||||
if (!clnors) {
|
||||
clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, numLoops);
|
||||
}
|
||||
|
||||
MDeformVert *dvert;
|
||||
int defgrp_index;
|
||||
MOD_get_vgroup(ctx->object, mesh, wnmd->defgrp_name, &dvert, &defgrp_index);
|
||||
MDeformVert *dvert;
|
||||
int defgrp_index;
|
||||
MOD_get_vgroup(ctx->object, mesh, wnmd->defgrp_name, &dvert, &defgrp_index);
|
||||
|
||||
WeightedNormalData wn_data = {
|
||||
.numVerts = numVerts,
|
||||
.numEdges = numEdges,
|
||||
.numLoops = numLoops,
|
||||
.numPolys = numPolys,
|
||||
WeightedNormalData wn_data = {
|
||||
.numVerts = numVerts,
|
||||
.numEdges = numEdges,
|
||||
.numLoops = numLoops,
|
||||
.numPolys = numPolys,
|
||||
|
||||
.mvert = mvert,
|
||||
.medge = medge,
|
||||
.mvert = mvert,
|
||||
.medge = medge,
|
||||
|
||||
.mloop = mloop,
|
||||
.clnors = clnors,
|
||||
.has_clnors = has_clnors,
|
||||
.split_angle = split_angle,
|
||||
.mloop = mloop,
|
||||
.clnors = clnors,
|
||||
.has_clnors = has_clnors,
|
||||
.split_angle = split_angle,
|
||||
|
||||
.mpoly = mpoly,
|
||||
.polynors = polynors,
|
||||
.poly_strength = CustomData_get_layer_named(
|
||||
&result->pdata, CD_PROP_INT, MOD_WEIGHTEDNORMALS_FACEWEIGHT_CDLAYER_ID),
|
||||
.mpoly = mpoly,
|
||||
.polynors = polynors,
|
||||
.poly_strength = CustomData_get_layer_named(
|
||||
&result->pdata, CD_PROP_INT, MOD_WEIGHTEDNORMALS_FACEWEIGHT_CDLAYER_ID),
|
||||
|
||||
.dvert = dvert,
|
||||
.defgrp_index = defgrp_index,
|
||||
.use_invert_vgroup = (wnmd->flag & MOD_WEIGHTEDNORMAL_INVERT_VGROUP) != 0,
|
||||
.dvert = dvert,
|
||||
.defgrp_index = defgrp_index,
|
||||
.use_invert_vgroup = (wnmd->flag & MOD_WEIGHTEDNORMAL_INVERT_VGROUP) != 0,
|
||||
|
||||
.weight = weight,
|
||||
.mode = wnmd->mode,
|
||||
};
|
||||
.weight = weight,
|
||||
.mode = wnmd->mode,
|
||||
};
|
||||
|
||||
switch (wnmd->mode) {
|
||||
case MOD_WEIGHTEDNORMAL_MODE_FACE:
|
||||
wn_face_area(wnmd, &wn_data);
|
||||
break;
|
||||
case MOD_WEIGHTEDNORMAL_MODE_ANGLE:
|
||||
wn_corner_angle(wnmd, &wn_data);
|
||||
break;
|
||||
case MOD_WEIGHTEDNORMAL_MODE_FACE_ANGLE:
|
||||
wn_face_with_angle(wnmd, &wn_data);
|
||||
break;
|
||||
}
|
||||
switch (wnmd->mode) {
|
||||
case MOD_WEIGHTEDNORMAL_MODE_FACE:
|
||||
wn_face_area(wnmd, &wn_data);
|
||||
break;
|
||||
case MOD_WEIGHTEDNORMAL_MODE_ANGLE:
|
||||
wn_corner_angle(wnmd, &wn_data);
|
||||
break;
|
||||
case MOD_WEIGHTEDNORMAL_MODE_FACE_ANGLE:
|
||||
wn_face_with_angle(wnmd, &wn_data);
|
||||
break;
|
||||
}
|
||||
|
||||
MEM_SAFE_FREE(wn_data.loop_to_poly);
|
||||
MEM_SAFE_FREE(wn_data.mode_pair);
|
||||
MEM_SAFE_FREE(wn_data.items_data);
|
||||
MEM_SAFE_FREE(wn_data.loop_to_poly);
|
||||
MEM_SAFE_FREE(wn_data.mode_pair);
|
||||
MEM_SAFE_FREE(wn_data.items_data);
|
||||
|
||||
/* Currently Modifier stack assumes there is no poly normal data passed around... */
|
||||
CustomData_free_layers(pdata, CD_NORMAL, numPolys);
|
||||
return result;
|
||||
/* Currently Modifier stack assumes there is no poly normal data passed around... */
|
||||
CustomData_free_layers(pdata, CD_NORMAL, numPolys);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void initData(ModifierData *md)
|
||||
|
|
Loading…
Reference in New Issue