Fix T56692: The edges are not highlighted in Mark Freestyle Edge

This was not ported yet.
This commit is contained in:
Clément Foucault 2018-09-05 15:42:32 +02:00
parent e8dc73a0c9
commit c05b9bbcc0
Notes: blender-bot 2023-12-22 20:14:11 +01:00
Referenced by issue #56692, The edges are not highlighted in Mark Freestyle Edge
8 changed files with 59 additions and 10 deletions

View File

@ -344,4 +344,8 @@ data_to_c_simple(engines/gpencil/shaders/fx/gpencil_fx_wave_frag.glsl SRC)
list(APPEND INC
)
if(WITH_FREESTYLE)
add_definitions(-DWITH_FREESTYLE)
endif()
blender_add_lib(bf_draw "${SRC}" "${INC}" "${INC_SYS}")

View File

@ -1340,6 +1340,7 @@ enum {
VFLAG_VERTEX_SELECTED = 1 << 1,
VFLAG_FACE_ACTIVE = 1 << 2,
VFLAG_FACE_SELECTED = 1 << 3,
VFLAG_FACE_FREESTYLE = 1 << 4,
};
enum {
@ -1348,6 +1349,7 @@ enum {
VFLAG_EDGE_SELECTED = 1 << 2,
VFLAG_EDGE_SEAM = 1 << 3,
VFLAG_EDGE_SHARP = 1 << 4,
VFLAG_EDGE_FREESTYLE = 1 << 5,
/* Beware to not go over 1 << 7
* (see gpu_shader_edit_mesh_overlay_geom.glsl) */
};
@ -1362,6 +1364,16 @@ static uchar mesh_render_data_looptri_flag(MeshRenderData *rdata, const BMFace *
if (BM_elem_flag_test(efa, BM_ELEM_SELECT))
fflag |= VFLAG_FACE_SELECTED;
#ifdef WITH_FREESTYLE
BMesh *bm = rdata->edit_bmesh->bm;
if (CustomData_has_layer(&bm->edata, CD_FREESTYLE_EDGE)) {
FreestyleFace *ffa = CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_FREESTYLE_FACE);
if (ffa->flag & FREESTYLE_FACE_MARK)
fflag |= VFLAG_FACE_FREESTYLE;
}
#endif
return fflag;
}
@ -1383,11 +1395,21 @@ static void mesh_render_data_edge_flag(
if (!BM_elem_flag_test(eed, BM_ELEM_SMOOTH))
eattr->e_flag |= VFLAG_EDGE_SHARP;
#ifdef WITH_FREESTYLE
BMesh *bm = rdata->edit_bmesh->bm;
if (CustomData_has_layer(&bm->edata, CD_FREESTYLE_EDGE)) {
FreestyleEdge *fed = CustomData_bmesh_get(&bm->edata, eed->head.data, CD_FREESTYLE_EDGE);
if (fed->flag & FREESTYLE_EDGE_MARK)
eattr->e_flag |= VFLAG_EDGE_FREESTYLE;
}
#endif
/* Use a byte for value range */
if (rdata->cd.offset.crease != -1) {
float crease = BM_ELEM_CD_GET_FLOAT(eed, rdata->cd.offset.crease);
if (crease > 0) {
eattr->crease = (char)(crease * 255.0f);
eattr->crease = (uchar)(crease * 255.0f);
}
}
@ -1395,14 +1417,13 @@ static void mesh_render_data_edge_flag(
if (rdata->cd.offset.bweight != -1) {
float bweight = BM_ELEM_CD_GET_FLOAT(eed, rdata->cd.offset.bweight);
if (bweight > 0) {
eattr->bweight = (char)(bweight * 255.0f);
eattr->bweight = (uchar)(bweight * 255.0f);
}
}
}
static uchar mesh_render_data_vertex_flag(MeshRenderData *rdata, const BMVert *eve)
{
uchar vflag = 0;
/* Current vertex */

View File

@ -78,6 +78,14 @@ void DRW_globals_update(void)
UI_GetThemeColor4fv(TH_FACE_DOT, ts.colorFaceDot);
UI_GetThemeColor4fv(TH_BACK, ts.colorBackground);
#ifdef WITH_FREESTYLE
UI_GetThemeColor4fv(TH_FREESTYLE_EDGE_MARK, ts.colorEdgeFreestyle);
UI_GetThemeColor4fv(TH_FREESTYLE_FACE_MARK, ts.colorFaceFreestyle);
#else
zero_v4(ts.colorEdgeFreestyle);
zero_v4(ts.colorFaceFreestyle);
#endif
/* Curve */
UI_GetThemeColor4fv(TH_HANDLE_FREE, ts.colorHandleFree);
UI_GetThemeColor4fv(TH_HANDLE_AUTO, ts.colorHandleAuto);

View File

@ -60,8 +60,10 @@ typedef struct GlobalsUboStorage {
float colorEdgeCrease[4];
float colorEdgeBWeight[4];
float colorEdgeFaceSelect[4];
float colorEdgeFreestyle[4];
float colorFace[4];
float colorFaceSelect[4];
float colorFaceFreestyle[4];
float colorNormal[4];
float colorVNormal[4];
float colorLNormal[4];

View File

@ -21,13 +21,14 @@ layout(std140) uniform globalsBlock {
vec4 colorEdgeCrease;
vec4 colorEdgeBWeight;
vec4 colorEdgeFaceSelect;
vec4 colorEdgeFreestyle;
vec4 colorFace;
vec4 colorFaceSelect;
vec4 colorFaceFreestyle;
vec4 colorNormal;
vec4 colorVNormal;
vec4 colorLNormal;
vec4 colorFaceDot;
vec4 colorDeselect;
vec4 colorOutline;
vec4 colorLampNoAlpha;

View File

@ -3,6 +3,7 @@
#define EDGE_SELECTED (1 << 2)
#define EDGE_SEAM (1 << 3)
#define EDGE_SHARP (1 << 4)
#define EDGE_FREESTYLE (1 << 5)
#define EDGE_VERTEX_ACTIVE (1 << (0 + 8))
#define EDGE_VERTEX_SELECTED (1 << (1 + 8))
@ -13,13 +14,13 @@
vec4 EDIT_MESH_edge_color_outer(int edge_flag, bool face_active, float crease, float bweight)
{
vec4 color = vec4(0.0);
color = ((edge_flag & EDGE_FREESTYLE) != 0) ? colorEdgeFreestyle : color;
color = ((edge_flag & EDGE_SHARP) != 0) ? colorEdgeSharp : color;
color = (crease > 0.0) ? vec4(colorEdgeCrease.rgb, crease) : color;
color = (bweight > 0.0) ? vec4(colorEdgeBWeight.rgb, bweight) : color;
color = ((edge_flag & EDGE_SEAM) != 0) ? colorEdgeSeam : color;
if (face_active)
{
if (face_active) {
color = colorEditMeshActive;
}
return color;
@ -41,8 +42,7 @@ vec4 EDIT_MESH_edge_color_inner(int edge_flag, bool face_active)
vec4 EDIT_MESH_vertex_color(int vertex_flag)
{
if ((vertex_flag & (VERTEX_ACTIVE | VERTEX_SELECTED)) != 0)
{
if ((vertex_flag & (VERTEX_ACTIVE | VERTEX_SELECTED)) != 0) {
return colorEdgeSelect;
}
else {

View File

@ -6,10 +6,20 @@ in ivec4 data;
flat out vec4 faceColor;
#define FACE_SELECTED (1 << 3)
#define FACE_ACTIVE (1 << 2)
#define FACE_SELECTED (1 << 3)
#define FACE_FREESTYLE (1 << 4)
void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
faceColor = ((data.x & FACE_SELECTED) != 0)? colorFaceSelect: colorFace;
if ((data.x & FACE_ACTIVE) != 0)
faceColor = colorFaceSelect;
else if ((data.x & FACE_SELECTED) != 0)
faceColor = colorFaceSelect;
else if ((data.x & FACE_FREESTYLE) != 0)
faceColor = colorFaceFreestyle;
else
faceColor = colorFace;
}

View File

@ -56,6 +56,7 @@ flat out vec2 ssPos[3];
#define FACE_ACTIVE (1 << 2)
#define FACE_SELECTED (1 << 3)
#define FACE_FREESTYLE (1 << 4)
/* project to screen space */
vec2 proj(vec4 pos)
@ -108,6 +109,8 @@ void main()
faceColor = colorFaceSelect;
else if ((vData[0].x & FACE_SELECTED) != 0)
faceColor = colorFaceSelect;
else if ((vData[0].x & FACE_FREESTYLE) != 0)
faceColor = colorFaceFreestyle;
else
faceColor = colorFace;