diff options
author | Jeroen Bakker <jeroen@blender.org> | 2021-07-21 09:18:34 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-07-21 09:18:34 +0300 |
commit | 75e41b127941613acd76514c6d8d0bd8cec19079 (patch) | |
tree | 8d6dba6dd5f8fa91d0b5f1140649686ce054be26 | |
parent | 265c3a4724e1a8ec7ad0b048eaa98316018445ec (diff) |
Cleanup: use named enum types.
Added ePreviewRenderMethod and ePreviewType.
-rw-r--r-- | source/blender/editors/include/ED_render.h | 5 | ||||
-rw-r--r-- | source/blender/editors/render/render_preview.c | 20 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_material_types.h | 26 |
3 files changed, 25 insertions, 26 deletions
diff --git a/source/blender/editors/include/ED_render.h b/source/blender/editors/include/ED_render.h index 0fb06639dbf..5cdcbbab42a 100644 --- a/source/blender/editors/include/ED_render.h +++ b/source/blender/editors/include/ED_render.h @@ -72,13 +72,12 @@ struct Scene *ED_render_job_get_current_scene(const struct bContext *C); * - PR_NODE_RENDER: preview is rendered for node editor * - PR_ICON_DEFERRED: No render, we just ensure deferred icon data gets generated. */ - -enum { +typedef enum ePreviewRenderMethod { PR_BUTS_RENDER = 0, PR_ICON_RENDER = 1, PR_NODE_RENDER = 2, PR_ICON_DEFERRED = 3, -}; +} ePreviewRenderMethod; void ED_preview_ensure_dbase(void); void ED_preview_free_dbase(void); diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 5aa63ac56d8..259bbc2353e 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -234,7 +234,7 @@ static Scene *preview_get_scene(Main *pr_main) return pr_main->scenes.first; } -static const char *preview_collection_name(const char pr_type) +static const char *preview_collection_name(const ePreviewType pr_type) { switch (pr_type) { case MA_FLAT: @@ -267,8 +267,8 @@ static const char *preview_collection_name(const char pr_type) static void set_preview_visibility(Scene *scene, ViewLayer *view_layer, - char pr_type, - int pr_method) + const ePreviewType pr_type, + const ePreviewRenderMethod pr_method) { /* Set appropriate layer as visible. */ LayerCollection *lc = view_layer->layer_collections.first; @@ -432,14 +432,12 @@ static Scene *preview_prepare_scene( sce->world->horb = 0.05f; } - if (sp->pr_method == PR_ICON_RENDER && sp->pr_main == G_pr_main_grease_pencil) { - /* For grease pencil, always use sphere for icon renders. */ - set_preview_visibility(sce, view_layer, MA_SPHERE_A, sp->pr_method); - } - else { - /* Use specified preview shape for both preview panel and icon previews. */ - set_preview_visibility(sce, view_layer, mat->pr_type, sp->pr_method); - } + /* For grease pencil, always use sphere for icon renders. */ + const ePreviewType preview_type = (sp->pr_method == PR_ICON_RENDER && + sp->pr_main == G_pr_main_grease_pencil) ? + MA_SPHERE_A : + mat->pr_type; + set_preview_visibility(sce, view_layer, preview_type, sp->pr_method); if (sp->pr_method != PR_ICON_RENDER) { if (mat->nodetree && sp->pr_method == PR_NODE_RENDER) { diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index f9974f14ab0..67cd68afb8a 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -298,18 +298,20 @@ typedef struct Material { #define MAP_ALPHA (1 << 7) /* pr_type */ -#define MA_FLAT 0 -#define MA_SPHERE 1 -#define MA_CUBE 2 -#define MA_SHADERBALL 3 -#define MA_SPHERE_A 4 /* Used for icon renders only. */ -#define MA_TEXTURE 5 -#define MA_LAMP 6 -#define MA_SKY 7 -#define MA_HAIR 10 -#define MA_ATMOS 11 -#define MA_CLOTH 12 -#define MA_FLUID 13 +typedef enum ePreviewType { + MA_FLAT = 0, + MA_SPHERE = 1, + MA_CUBE = 2, + MA_SHADERBALL = 3, + MA_SPHERE_A = 4, /* Used for icon renders only. */ + MA_TEXTURE = 5, + MA_LAMP = 6, + MA_SKY = 7, + MA_HAIR = 10, + MA_ATMOS = 11, + MA_CLOTH = 12, + MA_FLUID = 13, +} ePreviewType; /* pr_flag */ #define MA_PREVIEW_WORLD (1 << 0) |