Fix #108233: Move retopology overlay color to view3d overlay #108301

Open
Jorijn de Graaf wants to merge 1 commits from bonj/blender:retopology-overlay-color into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
16 changed files with 47 additions and 24 deletions
Showing only changes of commit 4406f19130 - Show all commits

View File

@ -329,7 +329,6 @@ const bTheme U_theme_default = {
.edge_bevel = RGBA(0x00a5ffff),
.face = RGBA(0xffffff02),
.face_select = RGBA(0xffa5522e),
.face_retopology = RGBA(0x50c8ff0f),
.face_back = RGBA(0xff0000b3),
.face_front = RGBA(0x0000ffb3),
.face_dot = RGBA(0xff8a00ff),

View File

@ -6645,10 +6645,11 @@ class VIEW3D_PT_overlay_edit_mesh_shading(Panel):
col.active = display_all
row = col.row(align=True)
row.prop(overlay, "show_retopology", text="")
sub = row.row()
sub.active = overlay.show_retopology
sub.prop(overlay, "retopology_offset", text="Retopology")
row.prop(overlay, "show_retopology", text="Retopology")
row = col.row(align=True)
row.active = overlay.show_retopology
row.prop(overlay, "retopology_offset", text="Offset")
row.prop(overlay, "retopology_color", text="")
col.prop(overlay, "show_weight", text="Vertex Group Weights")
if overlay.show_weight:

View File

@ -8,6 +8,9 @@
#include "CLG_log.h"
#include "MEM_guardedalloc.h"
#include "DNA_genfile.h"
#include "DNA_movieclip_types.h"
#include "BLI_assert.h"
@ -99,7 +102,7 @@ static void version_geometry_nodes_add_realize_instance_nodes(bNodeTree *ntree)
}
}
void blo_do_versions_400(FileData * /*fd*/, Library * /*lib*/, Main *bmain)
void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
{
if (!MAIN_VERSION_ATLEAST(bmain, 400, 1)) {
LISTBASE_FOREACH (Mesh *, mesh, &bmain->meshes) {
@ -133,5 +136,22 @@ void blo_do_versions_400(FileData * /*fd*/, Library * /*lib*/, Main *bmain)
*/
{
/* Keep this block, even when empty. */
/* Color for retopology overlay. */
if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "retopology_color[4]")) {
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.retopology_color[0] = 0.3125f;
v3d->overlay.retopology_color[1] = 0.78125f;
v3d->overlay.retopology_color[2] = 1.0f;
v3d->overlay.retopology_color[3] = 0.0625f;
}
}
}
}
}
}
}

View File

@ -94,10 +94,6 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
btheme->tui.wcol_view_item = U_theme_default.tui.wcol_view_item;
}
if (!USER_VERSION_ATLEAST(306, 3)) {
FROM_DEFAULT_V4_UCHAR(space_view3d.face_retopology);
}
if (!USER_VERSION_ATLEAST(306, 8)) {
FROM_DEFAULT_V4_UCHAR(space_node.node_zone_simulation);
FROM_DEFAULT_V4_UCHAR(space_action.simulated_frames);

View File

@ -114,6 +114,7 @@ void OVERLAY_edit_mesh_cache_init(OVERLAY_Data *vedata)
sh = OVERLAY_shader_edit_mesh_depth();
grp = pd->edit_mesh_depth_grp[i] = DRW_shgroup_create(sh, psl->edit_mesh_depth_ps[i]);
DRW_shgroup_uniform_float_copy(grp, "retopologyOffset", retopology_offset);
DRW_shgroup_uniform_vec4_copy(grp, "retopologyColor", v3d->overlay.retopology_color);
}
{
/* Normals */
@ -133,6 +134,7 @@ void OVERLAY_edit_mesh_cache_init(OVERLAY_Data *vedata)
DRW_shgroup_uniform_float_copy(
grp, "normalScreenSize", v3d->overlay.normals_constant_screen_size);
DRW_shgroup_uniform_float_copy(grp, "retopologyOffset", retopology_offset);
DRW_shgroup_uniform_vec4_copy(grp, "retopologyColor", v3d->overlay.retopology_color);
}
{
/* Mesh Analysis Pass */
@ -173,6 +175,7 @@ void OVERLAY_edit_mesh_cache_init(OVERLAY_Data *vedata)
DRW_shgroup_uniform_float_copy(grp, "alpha", face_alpha);
DRW_shgroup_uniform_bool_copy(grp, "selectFaces", select_face);
DRW_shgroup_uniform_float_copy(grp, "retopologyOffset", retopology_offset);
DRW_shgroup_uniform_vec4_copy(grp, "retopologyColor", v3d->overlay.retopology_color);
}
if (do_zbufclip) {
@ -193,6 +196,7 @@ void OVERLAY_edit_mesh_cache_init(OVERLAY_Data *vedata)
DRW_shgroup_uniform_bool_copy(grp, "selectEdges", pd->edit_mesh.do_edges || select_edge);
DRW_shgroup_uniform_bool_copy(grp, "do_smooth_wire", do_smooth_wire);
DRW_shgroup_uniform_float_copy(grp, "retopologyOffset", retopology_offset);
DRW_shgroup_uniform_vec4_copy(grp, "retopologyColor", v3d->overlay.retopology_color);
/* Verts */
state |= DRW_STATE_WRITE_DEPTH;
@ -207,11 +211,13 @@ void OVERLAY_edit_mesh_cache_init(OVERLAY_Data *vedata)
DRW_shgroup_uniform_texture_ref(grp, "depthTex", depth_tex);
DRW_shgroup_uniform_ivec4_copy(grp, "dataMask", vert_mask);
DRW_shgroup_uniform_float_copy(grp, "retopologyOffset", retopology_offset);
DRW_shgroup_uniform_vec4_copy(grp, "retopologyColor", v3d->overlay.retopology_color);
sh = OVERLAY_shader_edit_mesh_skin_root();
grp = pd->edit_mesh_skin_roots_grp[i] = DRW_shgroup_create(sh, psl->edit_mesh_verts_ps[i]);
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
DRW_shgroup_uniform_float_copy(grp, "retopologyOffset", retopology_offset);
DRW_shgroup_uniform_vec4_copy(grp, "retopologyColor", v3d->overlay.retopology_color);
}
/* Face-dots */
if (select_face && show_face_dots) {
@ -222,6 +228,7 @@ void OVERLAY_edit_mesh_cache_init(OVERLAY_Data *vedata)
DRW_shgroup_uniform_texture_ref(grp, "depthTex", depth_tex);
DRW_shgroup_uniform_ivec4_copy(grp, "dataMask", vert_mask);
DRW_shgroup_uniform_float_copy(grp, "retopologyOffset", retopology_offset);
DRW_shgroup_uniform_vec4_copy(grp, "retopologyColor", v3d->overlay.retopology_color);
DRW_shgroup_state_enable(grp, DRW_STATE_WRITE_DEPTH);
}
else {

View File

@ -19,6 +19,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_mesh_common)
.push_constant(Type::BOOL, "selectEdges")
.push_constant(Type::FLOAT, "alpha")
.push_constant(Type::FLOAT, "retopologyOffset")
.push_constant(Type::VEC4, "retopologyColor")
.push_constant(Type::IVEC4, "dataMask")
.vertex_source("overlay_edit_mesh_vert.glsl")
.additional_info("draw_modelmat", "draw_globals");
@ -33,6 +34,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_mesh_common_no_geom)
.push_constant(Type::BOOL, "selectEdges")
.push_constant(Type::FLOAT, "alpha")
.push_constant(Type::FLOAT, "retopologyOffset")
.push_constant(Type::VEC4, "retopologyColor")
.push_constant(Type::IVEC4, "dataMask")
.vertex_source("overlay_edit_mesh_vert_no_geom.glsl")
.additional_info("draw_modelmat", "draw_globals");

View File

@ -54,7 +54,7 @@ vec4 EDIT_MESH_face_color(uint face_flag)
{
vec4 color = colorFace;
vec4 color_active = mix(colorFaceSelect, colorEditMeshActive, 0.5);
color = (retopologyOffset > 0.0) ? colorFaceRetopology : color;
color = (retopologyOffset > 0.0) ? retopologyColor : color;
color = ((face_flag & FACE_FREESTYLE) != 0u) ? colorFaceFreestyle : color;
color = ((face_flag & FACE_SELECTED) != 0u) ? colorFaceSelect : color;
color = ((face_flag & FACE_ACTIVE) != 0u) ? color_active : color;

View File

@ -68,7 +68,6 @@ void DRW_globals_update(void)
UI_GetThemeColor4fv(TH_EDGE_FACESEL, gb->color_edge_face_select);
UI_GetThemeColor4fv(TH_FACE, gb->color_face);
UI_GetThemeColor4fv(TH_FACE_SELECT, gb->color_face_select);
UI_GetThemeColor4fv(TH_FACE_RETOPOLOGY, gb->color_face_retopology);
UI_GetThemeColor4fv(TH_FACE_BACK, gb->color_face_back);
UI_GetThemeColor4fv(TH_FACE_FRONT, gb->color_face_front);
UI_GetThemeColor4fv(TH_NORMAL, gb->color_normal);

View File

@ -48,7 +48,6 @@ struct GlobalsUboStorage {
float4 color_edge_freestyle;
float4 color_face;
float4 color_face_select;
float4 color_face_retopology;
float4 color_face_freestyle;
float4 color_gpencil_vertex;
float4 color_gpencil_vertex_select;
@ -165,7 +164,6 @@ BLI_STATIC_ASSERT_ALIGN(GlobalsUboStorage, 16)
# define colorEdgeFreestyle globalsBlock.color_edge_freestyle
# define colorFace globalsBlock.color_face
# define colorFaceSelect globalsBlock.color_face_select
# define colorFaceRetopology globalsBlock.color_face_retopology
# define colorFaceFreestyle globalsBlock.color_face_freestyle
# define colorGpencilVertex globalsBlock.color_gpencil_vertex
# define colorGpencilVertexSelect globalsBlock.color_gpencil_vertex_select

View File

@ -88,7 +88,6 @@ typedef enum ThemeColorID {
TH_EDGE_FACESEL,
TH_FACE,
TH_FACE_SELECT,
TH_FACE_RETOPOLOGY,
TH_FACE_BACK,
TH_FACE_FRONT,
TH_NORMAL,

View File

@ -396,9 +396,6 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
case TH_FACE_SELECT:
cp = ts->face_select;
break;
case TH_FACE_RETOPOLOGY:
cp = ts->face_retopology;
break;
case TH_FACE_BACK:
cp = ts->face_back;
break;

View File

@ -286,7 +286,8 @@ typedef struct ThemeSpace {
unsigned char edge[4], edge_select[4];
unsigned char edge_seam[4], edge_sharp[4], edge_facesel[4], edge_crease[4], edge_bevel[4];
/** Solid faces. */
unsigned char face[4], face_select[4], face_retopology[4], face_back[4], face_front[4];
unsigned char face[4], face_select[4], face_back[4], face_front[4];
char _pad3[4];
/** Selected color. */
unsigned char face_dot[4];
unsigned char extra_edge_len[4], extra_edge_angle[4], extra_face_angle[4], extra_face_area[4];

View File

@ -40,6 +40,7 @@
.wireframe_threshold = 1.0f, \
.wireframe_opacity = 1.0f, \
.retopology_offset = 0.2f, \
.retopology_color = {0.3125f, 0.78125f, 1.0f, 0.0625f}, \
.viewer_attribute_opacity = 1.0f, \
.xray_alpha_bone = 0.5f, \
.bone_wire_alpha = 1.0f, \

View File

@ -222,6 +222,7 @@ typedef struct View3DOverlay {
float wireframe_threshold;
float wireframe_opacity;
float retopology_offset;
float retopology_color[4];
/** Grease pencil settings. */
float gpencil_paper_opacity;

View File

@ -4572,6 +4572,13 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "retopology_color", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "overlay.retopology_color");
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Retopology Color", "Color for retopology overlay");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL);
prop = RNA_def_property(srna, "show_face_normals", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_FACE_NORMALS);
RNA_def_property_ui_text(prop, "Display Normals", "Display face normals as lines");

View File

@ -2061,11 +2061,6 @@ static void rna_def_userdef_theme_spaces_face(StructRNA *srna)
RNA_def_property_ui_text(prop, "Freestyle Face Mark", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
prop = RNA_def_property(srna, "face_retopology", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Face Retopology", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
prop = RNA_def_property(srna, "face_back", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Face Orientation Back", "");