Cleanup: Convert BKE_multires.hh enum to enum class
Pull Request: https://projects.blender.org/blender/blender/pulls/130363
This commit is contained in:
@@ -47,13 +47,13 @@ void multires_modifier_update_hidden(DerivedMesh *dm);
|
||||
*/
|
||||
void multiresModifier_set_levels_from_disps(MultiresModifierData *mmd, Object *ob);
|
||||
|
||||
enum MultiresFlags {
|
||||
MULTIRES_USE_LOCAL_MMD = 1,
|
||||
MULTIRES_USE_RENDER_PARAMS = 2,
|
||||
MULTIRES_ALLOC_PAINT_MASK = 4,
|
||||
MULTIRES_IGNORE_SIMPLIFY = 8,
|
||||
enum class MultiresFlags : uint8_t {
|
||||
UseLocalMMD = 1,
|
||||
UseRenderParams = 2,
|
||||
AllocPaintMask = 4,
|
||||
IgnoreSimplify = 8,
|
||||
};
|
||||
ENUM_OPERATORS(MultiresFlags, MULTIRES_IGNORE_SIMPLIFY);
|
||||
ENUM_OPERATORS(MultiresFlags, MultiresFlags::IgnoreSimplify);
|
||||
|
||||
DerivedMesh *multires_make_derived_from_derived(
|
||||
DerivedMesh *dm, MultiresModifierData *mmd, Scene *scene, Object *ob, MultiresFlags flags);
|
||||
@@ -159,15 +159,15 @@ bool multiresModifier_reshapeFromCCG(int tot_level, Mesh *coarse_mesh, SubdivCCG
|
||||
|
||||
/* Subdivide multi-res displacement once. */
|
||||
|
||||
enum eMultiresSubdivideModeType {
|
||||
MULTIRES_SUBDIVIDE_CATMULL_CLARK,
|
||||
MULTIRES_SUBDIVIDE_SIMPLE,
|
||||
MULTIRES_SUBDIVIDE_LINEAR,
|
||||
enum class MultiresSubdivideModeType : int8_t {
|
||||
CatmullClark,
|
||||
Simple,
|
||||
Linear,
|
||||
};
|
||||
|
||||
void multiresModifier_subdivide(Object *object,
|
||||
MultiresModifierData *mmd,
|
||||
eMultiresSubdivideModeType mode);
|
||||
MultiresSubdivideModeType mode);
|
||||
void multires_subdivide_create_tangent_displacement_linear_grids(Object *object,
|
||||
MultiresModifierData *mmd);
|
||||
|
||||
@@ -178,7 +178,7 @@ void multires_subdivide_create_tangent_displacement_linear_grids(Object *object,
|
||||
void multiresModifier_subdivide_to_level(Object *object,
|
||||
MultiresModifierData *mmd,
|
||||
int top_level,
|
||||
eMultiresSubdivideModeType mode);
|
||||
MultiresSubdivideModeType mode);
|
||||
|
||||
/* Subdivision integration, defined in multires_subdiv.cc */
|
||||
|
||||
|
||||
@@ -739,9 +739,9 @@ static DerivedMesh *multires_dm_create_local(Scene *scene,
|
||||
mmd.renderlvl = lvl;
|
||||
mmd.totlvl = totlvl;
|
||||
|
||||
flags |= MULTIRES_USE_LOCAL_MMD;
|
||||
flags |= MultiresFlags::UseLocalMMD;
|
||||
if (alloc_paint_mask) {
|
||||
flags |= MULTIRES_ALLOC_PAINT_MASK;
|
||||
flags |= MultiresFlags::AllocPaintMask;
|
||||
}
|
||||
|
||||
return multires_make_derived_from_derived(dm, &mmd, scene, ob, flags);
|
||||
@@ -1076,7 +1076,7 @@ void multires_modifier_update_mdisps(DerivedMesh *dm, Scene *scene)
|
||||
|
||||
/* create multires DM from original mesh and displacements */
|
||||
lowdm = multires_dm_create_local(
|
||||
scene, ob, cddm, lvl, totlvl, has_mask, MULTIRES_IGNORE_SIMPLIFY);
|
||||
scene, ob, cddm, lvl, totlvl, has_mask, MultiresFlags::IgnoreSimplify);
|
||||
cddm->release(cddm);
|
||||
|
||||
/* gather grid data */
|
||||
@@ -1220,8 +1220,8 @@ DerivedMesh *multires_make_derived_from_derived(
|
||||
CCGDerivedMesh *ccgdm = nullptr;
|
||||
CCGElem **gridData, **subGridData;
|
||||
CCGKey key;
|
||||
const bool render = (flags & MULTIRES_USE_RENDER_PARAMS) != 0;
|
||||
const bool ignore_simplify = (flags & MULTIRES_IGNORE_SIMPLIFY) != 0;
|
||||
const bool render = uint8_t(flags & MultiresFlags::UseRenderParams) != 0;
|
||||
const bool ignore_simplify = uint8_t(flags & MultiresFlags::IgnoreSimplify) != 0;
|
||||
int lvl = multires_get_level(scene, ob, mmd, render, ignore_simplify);
|
||||
int i, gridSize, numGrids;
|
||||
|
||||
@@ -1238,11 +1238,11 @@ DerivedMesh *multires_make_derived_from_derived(
|
||||
false,
|
||||
mmd->flags & eMultiresModifierFlag_ControlEdges,
|
||||
mmd->uv_smooth == SUBSURF_UV_SMOOTH_NONE,
|
||||
flags & MULTIRES_ALLOC_PAINT_MASK,
|
||||
uint8_t(flags & MultiresFlags::AllocPaintMask),
|
||||
render,
|
||||
subsurf_flags);
|
||||
|
||||
if (!(flags & MULTIRES_USE_LOCAL_MMD)) {
|
||||
if (!uint8_t(flags & MultiresFlags::UseLocalMMD)) {
|
||||
ccgdm = (CCGDerivedMesh *)result;
|
||||
|
||||
ccgdm->multires.ob = ob;
|
||||
@@ -1350,7 +1350,7 @@ void multiresModifier_sync_levels_ex(Object *ob_dst,
|
||||
|
||||
if (mmd_src->totlvl > mmd_dst->totlvl) {
|
||||
multiresModifier_subdivide_to_level(
|
||||
ob_dst, mmd_dst, mmd_src->totlvl, MULTIRES_SUBDIVIDE_CATMULL_CLARK);
|
||||
ob_dst, mmd_dst, mmd_src->totlvl, MultiresSubdivideModeType::CatmullClark);
|
||||
}
|
||||
else {
|
||||
multires_del_higher(mmd_dst, ob_dst, mmd_src->totlvl);
|
||||
|
||||
@@ -152,7 +152,7 @@ bool multiresModifier_reshapeFromCCG(const int tot_level, Mesh *coarse_mesh, Sub
|
||||
|
||||
void multiresModifier_subdivide(Object *object,
|
||||
MultiresModifierData *mmd,
|
||||
const eMultiresSubdivideModeType mode)
|
||||
const MultiresSubdivideModeType mode)
|
||||
{
|
||||
const int top_level = mmd->totlvl + 1;
|
||||
multiresModifier_subdivide_to_level(object, mmd, top_level, mode);
|
||||
@@ -161,7 +161,7 @@ void multiresModifier_subdivide(Object *object,
|
||||
void multiresModifier_subdivide_to_level(Object *object,
|
||||
MultiresModifierData *mmd,
|
||||
const int top_level,
|
||||
const eMultiresSubdivideModeType mode)
|
||||
const MultiresSubdivideModeType mode)
|
||||
{
|
||||
if (top_level <= mmd->totlvl) {
|
||||
return;
|
||||
@@ -194,7 +194,7 @@ void multiresModifier_subdivide_to_level(Object *object,
|
||||
* that the mdisps layer is also synchronized. */
|
||||
if (!has_mdisps || top_level == 1 || mmd->totlvl == 0) {
|
||||
multires_reshape_ensure_grids(coarse_mesh, top_level);
|
||||
if (ELEM(mode, MULTIRES_SUBDIVIDE_LINEAR, MULTIRES_SUBDIVIDE_SIMPLE)) {
|
||||
if (ELEM(mode, MultiresSubdivideModeType::Linear, MultiresSubdivideModeType::Simple)) {
|
||||
multires_subdivide_create_tangent_displacement_linear_grids(object, mmd);
|
||||
}
|
||||
else {
|
||||
@@ -218,7 +218,7 @@ void multiresModifier_subdivide_to_level(Object *object,
|
||||
* displacement in sculpt mode at the old top level and then propagated to the new top level. */
|
||||
multires_reshape_free_original_grids(&reshape_context);
|
||||
|
||||
if (ELEM(mode, MULTIRES_SUBDIVIDE_LINEAR, MULTIRES_SUBDIVIDE_SIMPLE)) {
|
||||
if (ELEM(mode, MultiresSubdivideModeType::Linear, MultiresSubdivideModeType::Simple)) {
|
||||
multires_reshape_smooth_object_grids(&reshape_context, mode);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -339,7 +339,7 @@ void multires_reshape_smooth_object_grids_with_details(
|
||||
* Makes it so surface on top level looks smooth. Details are not preserved
|
||||
*/
|
||||
void multires_reshape_smooth_object_grids(const MultiresReshapeContext *reshape_context,
|
||||
enum eMultiresSubdivideModeType mode);
|
||||
enum MultiresSubdivideModeType mode);
|
||||
|
||||
/* --------------------------------------------------------------------
|
||||
* Displacement, space conversion.
|
||||
|
||||
@@ -162,7 +162,7 @@ struct MultiresReshapeSmoothContext {
|
||||
*
|
||||
* NOTE: Uses same enumerator type as Subdivide operator, since the values are the same and
|
||||
* decoupling type just adds extra headache to convert one enumerator to another. */
|
||||
eMultiresSubdivideModeType smoothing_type;
|
||||
MultiresSubdivideModeType smoothing_type;
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -454,8 +454,8 @@ static int get_reshape_level_resolution(const MultiresReshapeContext *reshape_co
|
||||
static bool is_crease_supported(const MultiresReshapeSmoothContext *reshape_smooth_context)
|
||||
{
|
||||
return !ELEM(reshape_smooth_context->smoothing_type,
|
||||
MULTIRES_SUBDIVIDE_LINEAR,
|
||||
MULTIRES_SUBDIVIDE_SIMPLE);
|
||||
MultiresSubdivideModeType::Linear,
|
||||
MultiresSubdivideModeType::Simple);
|
||||
}
|
||||
|
||||
/* Get crease which will be used for communication to OpenSubdiv topology.
|
||||
@@ -483,7 +483,7 @@ static float get_effective_crease_float(const MultiresReshapeSmoothContext *resh
|
||||
|
||||
static void context_init(MultiresReshapeSmoothContext *reshape_smooth_context,
|
||||
const MultiresReshapeContext *reshape_context,
|
||||
const eMultiresSubdivideModeType mode)
|
||||
const MultiresSubdivideModeType mode)
|
||||
{
|
||||
reshape_smooth_context->reshape_context = reshape_context;
|
||||
|
||||
@@ -548,7 +548,8 @@ static bool foreach_topology_info(const blender::bke::subdiv::ForeachContext *fo
|
||||
{
|
||||
MultiresReshapeSmoothContext *reshape_smooth_context =
|
||||
static_cast<MultiresReshapeSmoothContext *>(foreach_context->user_data);
|
||||
const int max_edges = reshape_smooth_context->smoothing_type == MULTIRES_SUBDIVIDE_LINEAR ?
|
||||
const int max_edges = reshape_smooth_context->smoothing_type ==
|
||||
MultiresSubdivideModeType::Linear ?
|
||||
num_edges :
|
||||
reshape_smooth_context->geometry.max_edges;
|
||||
|
||||
@@ -794,7 +795,7 @@ static void foreach_edge(const blender::bke::subdiv::ForeachContext *foreach_con
|
||||
MultiresReshapeSmoothContext *reshape_smooth_context =
|
||||
static_cast<MultiresReshapeSmoothContext *>(foreach_context->user_data);
|
||||
|
||||
if (reshape_smooth_context->smoothing_type == MULTIRES_SUBDIVIDE_LINEAR) {
|
||||
if (reshape_smooth_context->smoothing_type == MultiresSubdivideModeType::Linear) {
|
||||
if (!is_loose) {
|
||||
store_edge(reshape_smooth_context, subdiv_v1, subdiv_v2, 1.0f);
|
||||
}
|
||||
@@ -1451,10 +1452,11 @@ void multires_reshape_smooth_object_grids_with_details(
|
||||
|
||||
MultiresReshapeSmoothContext reshape_smooth_context;
|
||||
if (reshape_context->subdiv->settings.is_simple) {
|
||||
context_init(&reshape_smooth_context, reshape_context, MULTIRES_SUBDIVIDE_SIMPLE);
|
||||
context_init(&reshape_smooth_context, reshape_context, MultiresSubdivideModeType::Simple);
|
||||
}
|
||||
else {
|
||||
context_init(&reshape_smooth_context, reshape_context, MULTIRES_SUBDIVIDE_CATMULL_CLARK);
|
||||
context_init(
|
||||
&reshape_smooth_context, reshape_context, MultiresSubdivideModeType::CatmullClark);
|
||||
}
|
||||
|
||||
geometry_create(&reshape_smooth_context);
|
||||
@@ -1476,7 +1478,7 @@ void multires_reshape_smooth_object_grids_with_details(
|
||||
}
|
||||
|
||||
void multires_reshape_smooth_object_grids(const MultiresReshapeContext *reshape_context,
|
||||
const eMultiresSubdivideModeType mode)
|
||||
const MultiresSubdivideModeType mode)
|
||||
{
|
||||
#ifdef WITH_OPENSUBDIV
|
||||
const int level_difference = (reshape_context->top.level - reshape_context->reshape.level);
|
||||
|
||||
@@ -229,7 +229,8 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l
|
||||
DM_set_only_copy(cddm, &CD_MASK_BAREMESH);
|
||||
tmp_mmd.lvl = mmd->lvl;
|
||||
tmp_mmd.sculptlvl = mmd->lvl;
|
||||
dm = multires_make_derived_from_derived(cddm, &tmp_mmd, scene, ob, MULTIRES_IGNORE_SIMPLIFY);
|
||||
dm = multires_make_derived_from_derived(
|
||||
cddm, &tmp_mmd, scene, ob, MultiresFlags::IgnoreSimplify);
|
||||
|
||||
cddm->release(cddm);
|
||||
|
||||
@@ -256,7 +257,8 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l
|
||||
|
||||
tmp_mmd.lvl = mmd->totlvl;
|
||||
tmp_mmd.sculptlvl = mmd->totlvl;
|
||||
dm = multires_make_derived_from_derived(cddm, &tmp_mmd, scene, ob, MULTIRES_IGNORE_SIMPLIFY);
|
||||
dm = multires_make_derived_from_derived(
|
||||
cddm, &tmp_mmd, scene, ob, MultiresFlags::IgnoreSimplify);
|
||||
cddm->release(cddm);
|
||||
|
||||
return dm;
|
||||
|
||||
@@ -95,17 +95,17 @@ void OBJECT_OT_multires_higher_levels_delete(wmOperatorType *ot)
|
||||
* \{ */
|
||||
|
||||
static EnumPropertyItem prop_multires_subdivide_mode_type[] = {
|
||||
{MULTIRES_SUBDIVIDE_CATMULL_CLARK,
|
||||
{int8_t(MultiresSubdivideModeType::CatmullClark),
|
||||
"CATMULL_CLARK",
|
||||
0,
|
||||
"Catmull-Clark",
|
||||
"Create a new level using Catmull-Clark subdivisions"},
|
||||
{MULTIRES_SUBDIVIDE_SIMPLE,
|
||||
{int8_t(MultiresSubdivideModeType::Simple),
|
||||
"SIMPLE",
|
||||
0,
|
||||
"Simple",
|
||||
"Create a new level using simple subdivisions"},
|
||||
{MULTIRES_SUBDIVIDE_LINEAR,
|
||||
{int8_t(MultiresSubdivideModeType::Linear),
|
||||
"LINEAR",
|
||||
0,
|
||||
"Linear",
|
||||
@@ -123,8 +123,8 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
const eMultiresSubdivideModeType subdivide_mode = (eMultiresSubdivideModeType)RNA_enum_get(
|
||||
op->ptr, "mode");
|
||||
const MultiresSubdivideModeType subdivide_mode = (MultiresSubdivideModeType)RNA_enum_get(op->ptr,
|
||||
"mode");
|
||||
multiresModifier_subdivide(object, mmd, subdivide_mode);
|
||||
|
||||
iter_other(CTX_data_main(C), object, true, multires_update_totlevels, &mmd->totlvl);
|
||||
@@ -165,7 +165,7 @@ void OBJECT_OT_multires_subdivide(wmOperatorType *ot)
|
||||
RNA_def_enum(ot->srna,
|
||||
"mode",
|
||||
prop_multires_subdivide_mode_type,
|
||||
MULTIRES_SUBDIVIDE_CATMULL_CLARK,
|
||||
int8_t(MultiresSubdivideModeType::CatmullClark),
|
||||
"Subdivision Mode",
|
||||
"How the mesh is going to be subdivided to create a new level");
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ static void subdivisions_panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
WM_OP_EXEC_DEFAULT,
|
||||
UI_ITEM_NONE,
|
||||
&op_ptr);
|
||||
RNA_enum_set(&op_ptr, "mode", MULTIRES_SUBDIVIDE_CATMULL_CLARK);
|
||||
RNA_enum_set(&op_ptr, "mode", int8_t(MultiresSubdivideModeType::CatmullClark));
|
||||
RNA_string_set(&op_ptr, "modifier", ((ModifierData *)mmd)->name);
|
||||
|
||||
row = uiLayoutRow(layout, false);
|
||||
@@ -365,7 +365,7 @@ static void subdivisions_panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
WM_OP_EXEC_DEFAULT,
|
||||
UI_ITEM_NONE,
|
||||
&op_ptr);
|
||||
RNA_enum_set(&op_ptr, "mode", MULTIRES_SUBDIVIDE_SIMPLE);
|
||||
RNA_enum_set(&op_ptr, "mode", int8_t(MultiresSubdivideModeType::Simple));
|
||||
RNA_string_set(&op_ptr, "modifier", ((ModifierData *)mmd)->name);
|
||||
uiItemFullO(row,
|
||||
"OBJECT_OT_multires_subdivide",
|
||||
@@ -375,7 +375,7 @@ static void subdivisions_panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
WM_OP_EXEC_DEFAULT,
|
||||
UI_ITEM_NONE,
|
||||
&op_ptr);
|
||||
RNA_enum_set(&op_ptr, "mode", MULTIRES_SUBDIVIDE_LINEAR);
|
||||
RNA_enum_set(&op_ptr, "mode", int8_t(MultiresSubdivideModeType::Linear));
|
||||
RNA_string_set(&op_ptr, "modifier", ((ModifierData *)mmd)->name);
|
||||
|
||||
uiItemS(layout);
|
||||
|
||||
Reference in New Issue
Block a user