Changeset View
Changeset View
Standalone View
Standalone View
source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
| Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | if (dot_v3v3(cross, axis) >= 0) { | ||||
| angle = 2 * M_PI - angle; | angle = 2 * M_PI - angle; | ||||
| } | } | ||||
| return angle; | return angle; | ||||
| } | } | ||||
| static float clamp_nonzero(const float value, const float epsilon) | static float clamp_nonzero(const float value, const float epsilon) | ||||
| { | { | ||||
| BLI_assert(!(epsilon < 0.0f)); | BLI_assert(!(epsilon < 0.0f)); | ||||
| /* Return closest value with `abs(value) >= epsilon`. */ | |||||
| if (value < 0.0f) { | if (value < 0.0f) { | ||||
| return min_ff(value, -epsilon); | return min_ff(value, -epsilon); | ||||
| } | } | ||||
| return max_ff(value, epsilon); | return max_ff(value, epsilon); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, | ||||
| /* Only use material offsets if we have 2 or more materials. */ | /* Only use material offsets if we have 2 or more materials. */ | ||||
| const short mat_nrs = ctx->object->totcol > 1 ? ctx->object->totcol : 1; | const short mat_nrs = ctx->object->totcol > 1 ? ctx->object->totcol : 1; | ||||
| const short mat_nr_max = mat_nrs - 1; | const short mat_nr_max = mat_nrs - 1; | ||||
| const short mat_ofs = mat_nrs > 1 ? smd->mat_ofs : 0; | const short mat_ofs = mat_nrs > 1 ? smd->mat_ofs : 0; | ||||
| const short mat_ofs_rim = mat_nrs > 1 ? smd->mat_ofs_rim : 0; | const short mat_ofs_rim = mat_nrs > 1 ? smd->mat_ofs_rim : 0; | ||||
| float(*poly_nors)[3] = NULL; | float(*poly_nors)[3] = NULL; | ||||
| /* #ofs_front and #ofs_back are the offset from the original | |||||
| * surface along the normal, where #oft_front is along the positive | |||||
| * and #oft_back is along the negative normal. */ | |||||
| const float ofs_front = (smd->offset_fac + 1.0f) * 0.5f * smd->offset; | const float ofs_front = (smd->offset_fac + 1.0f) * 0.5f * smd->offset; | ||||
| const float ofs_back = ofs_front - smd->offset * smd->offset_fac; | const float ofs_back = ofs_front - smd->offset * smd->offset_fac; | ||||
| const float ofs_front_clamped = clamp_nonzero(smd->offset > 0 ? ofs_front : ofs_back, 1e-5f); | /* #ofs_front_clamped and #ofs_back_clamped are the same as | ||||
| const float ofs_back_clamped = clamp_nonzero(smd->offset > 0 ? ofs_back : ofs_front, 1e-5f); | * #ofs_front and #ofs_back, but never zero. */ | ||||
| const float ofs_front_clamped = clamp_nonzero(ofs_front, 1e-5f); | |||||
| const float ofs_back_clamped = clamp_nonzero(ofs_back, 1e-5f); | |||||
| const float offset_fac_vg = smd->offset_fac_vg; | const float offset_fac_vg = smd->offset_fac_vg; | ||||
| const float offset_fac_vg_inv = 1.0f - smd->offset_fac_vg; | const float offset_fac_vg_inv = 1.0f - smd->offset_fac_vg; | ||||
| const float offset = fabsf(smd->offset) * smd->offset_clamp; | const float offset = fabsf(smd->offset) * smd->offset_clamp; | ||||
| const bool do_angle_clamp = smd->flag & MOD_SOLIDIFY_OFFSET_ANGLE_CLAMP; | const bool do_angle_clamp = smd->flag & MOD_SOLIDIFY_OFFSET_ANGLE_CLAMP; | ||||
| const bool do_flip = (smd->flag & MOD_SOLIDIFY_FLIP) != 0; | /* #do_flip, flips the normals of the result. This is inverted if negative thickness | ||||
| * is used, since simple soldify with negative thickness keeps the faces facing outside. */ | |||||
| const bool do_flip = ((smd->flag & MOD_SOLIDIFY_FLIP) != 0) == (smd->offset > 0); | |||||
| const bool do_rim = smd->flag & MOD_SOLIDIFY_RIM; | const bool do_rim = smd->flag & MOD_SOLIDIFY_RIM; | ||||
| const bool do_shell = ((smd->flag & MOD_SOLIDIFY_RIM) && (smd->flag & MOD_SOLIDIFY_NOSHELL)) == | const bool do_shell = ((smd->flag & MOD_SOLIDIFY_RIM) && (smd->flag & MOD_SOLIDIFY_NOSHELL)) == | ||||
| 0; | 0; | ||||
| const bool do_clamp = (smd->offset_clamp != 0.0f); | const bool do_clamp = (smd->offset_clamp != 0.0f); | ||||
| const float bevel_convex = smd->bevel_convex; | const float bevel_convex = smd->bevel_convex; | ||||
| MDeformVert *dvert; | MDeformVert *dvert; | ||||
| ▲ Show 20 Lines • Show All 2,378 Lines • Show Last 20 Lines | |||||