[Bf-blender-cvs] [8de3778d11b] blender2.8: Getting rid of setlinestyle: 3DView camera view.
Bastien Montagne
noreply at git.blender.org
Wed Apr 26 12:31:35 CEST 2017
Commit: 8de3778d11bf60dcee7bd38de0f5f648f2be7333
Author: Bastien Montagne
Date: Wed Apr 26 12:17:46 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB8de3778d11bf60dcee7bd38de0f5f648f2be7333
Getting rid of setlinestyle: 3DView camera view.
Use new 2D dashed line shader in 3DView camera view.
Note that this also involved converting UI_draw_safe_areas() to this
dashed shader, which means it cannot be used anymore with other shaders.
Part of D2647.
===================================================================
M source/blender/editors/include/UI_interface.h
M source/blender/editors/interface/interface_draw.c
M source/blender/editors/space_sequencer/sequencer_draw.c
M source/blender/editors/space_view3d/view3d_draw.c
===================================================================
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 6146632eaf7..3293b061e76 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -324,7 +324,7 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx,
void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const float color[4]);
void UI_draw_safe_areas(
- unsigned pos, float x1, float x2, float y1, float y2,
+ uint pos, uint line_origin, float x1, float x2, float y1, float y2,
const float title_aspect[2], const float action_aspect[2]);
/* state for scrolldrawing */
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index fac19d7ed9b..1b872984ef2 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -577,11 +577,15 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
/**
* Draw title and text safe areas.
*
- * The first parameter is a PRIM_FLOAT, 2, KEEP_FLOAT vertex attrib
+ * \Note This functionn is to be used with the 2D dashed shader enabled.
+ *
+ * \param pos is a PRIM_FLOAT, 2, KEEP_FLOAT vertex attrib
+ * \param line_origin is a PRIM_FLOAT, 2, KEEP_FLOAT vertex attrib
+ *
* The next 4 parameters are the offsets for the view, not the zones.
*/
void UI_draw_safe_areas(
- unsigned pos, float x1, float x2, float y1, float y2,
+ uint pos, uint line_origin, float x1, float x2, float y1, float y2,
const float title_aspect[2], const float action_aspect[2])
{
const float size_x_half = (x2 - x1) * 0.5f;
@@ -589,15 +593,9 @@ void UI_draw_safe_areas(
const float *safe_areas[] = {title_aspect, action_aspect};
const int safe_len = ARRAY_SIZE(safe_areas);
- bool is_first = true;
for (int i = 0; i < safe_len; i++) {
if (safe_areas[i][0] || safe_areas[i][1]) {
- if (is_first) {
- immUniformThemeColorBlend(TH_VIEW_OVERLAY, TH_BACK, 0.25f);
- is_first = false;
- }
-
float margin_x = safe_areas[i][0] * size_x_half;
float margin_y = safe_areas[i][1] * size_y_half;
@@ -606,7 +604,7 @@ void UI_draw_safe_areas(
float maxx = x2 - margin_x;
float maxy = y2 - margin_y;
- imm_draw_line_box(pos, minx, miny, maxx, maxy);
+ imm_draw_line_box_dashed(pos, line_origin, minx, miny, maxx, maxy);
}
}
}
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index e4fe3a6b145..8be340140bf 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -1044,6 +1044,7 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons
/* safety border */
if (sseq->flag & SEQ_SHOW_SAFE_MARGINS) {
+#if 0 /* Disabled just for this commit, will be fixed in next one. */
UI_draw_safe_areas(
pos, x1, x2, y1, y2,
scene->safe_areas.title,
@@ -1055,6 +1056,7 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons
scene->safe_areas.title_center,
scene->safe_areas.action_center);
}
+#endif
}
immUnbindProgram();
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 5ef4909e857..6d8243ca4b3 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -417,7 +417,7 @@ void ED_view3d_calc_camera_border(
view3d_camera_border(scene, ar, v3d, rv3d, r_viewborder, no_shift, false);
}
-static void drawviewborder_grid3(unsigned pos, float x1, float x2, float y1, float y2, float fac)
+static void drawviewborder_grid3(uint pos, uint line_origin, float x1, float x2, float y1, float y2, float fac)
{
float x3, y3, x4, y4;
@@ -427,28 +427,36 @@ static void drawviewborder_grid3(unsigned pos, float x1, float x2, float y1, flo
y4 = y1 + (1.0f - fac) * (y2 - y1);
immBegin(PRIM_LINES, 8);
+
+ immAttrib2f(line_origin, x1, y3);
immVertex2f(pos, x1, y3);
immVertex2f(pos, x2, y3);
+ immAttrib2f(line_origin, x1, y4);
immVertex2f(pos, x1, y4);
immVertex2f(pos, x2, y4);
+ immAttrib2f(line_origin, x3, y1);
immVertex2f(pos, x3, y1);
immVertex2f(pos, x3, y2);
+ immAttrib2f(line_origin, x4, y1);
immVertex2f(pos, x4, y1);
immVertex2f(pos, x4, y2);
+
immEnd();
}
/* harmonious triangle */
-static void drawviewborder_triangle(unsigned pos, float x1, float x2, float y1, float y2, const char golden, const char dir)
+static void drawviewborder_triangle(
+ uint pos, uint line_origin, float x1, float x2, float y1, float y2, const char golden, const char dir)
{
float ofs;
float w = x2 - x1;
float h = y2 - y1;
immBegin(PRIM_LINES, 6);
+
if (w > h) {
if (golden) {
ofs = w * (1.0f - (1.0f / 1.61803399f));
@@ -458,12 +466,15 @@ static void drawviewborder_triangle(unsigned pos, float x1, float x2, float y1,
}
if (dir == 'B') SWAP(float, y1, y2);
+ immAttrib2f(line_origin, x1, y1);
immVertex2f(pos, x1, y1);
immVertex2f(pos, x2, y2);
+ immAttrib2f(line_origin, x2, y1);
immVertex2f(pos, x2, y1);
immVertex2f(pos, x1 + (w - ofs), y2);
+ immAttrib2f(line_origin, x1, y2);
immVertex2f(pos, x1, y2);
immVertex2f(pos, x1 + ofs, y1);
}
@@ -476,15 +487,19 @@ static void drawviewborder_triangle(unsigned pos, float x1, float x2, float y1,
}
if (dir == 'B') SWAP(float, x1, x2);
+ immAttrib2f(line_origin, x1, y1);
immVertex2f(pos, x1, y1);
immVertex2f(pos, x2, y2);
+ immAttrib2f(line_origin, x2, y1);
immVertex2f(pos, x2, y1);
immVertex2f(pos, x1, y1 + ofs);
+ immAttrib2f(line_origin, x1, y2);
immVertex2f(pos, x1, y2);
immVertex2f(pos, x2, y1 + (h - ofs));
}
+
immEnd();
}
@@ -523,154 +538,170 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
x2i = (int)(x2 + (1.0f - 0.0001f));
y2i = (int)(y2 + (1.0f - 0.0001f));
- /* use the same program for everything */
- unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
- /* passepartout, specified in camera edit buttons */
- if (ca && (ca->flag & CAM_SHOWPASSEPARTOUT) && ca->passepartalpha > 0.000001f) {
- const float winx = (ar->winx + 1);
- const float winy = (ar->winy + 1);
+ /* First, solid lines. */
+ {
+ unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- float alpha = 1.0f;
+ /* passepartout, specified in camera edit buttons */
+ if (ca && (ca->flag & CAM_SHOWPASSEPARTOUT) && ca->passepartalpha > 0.000001f) {
+ const float winx = (ar->winx + 1);
+ const float winy = (ar->winy + 1);
- if (ca->passepartalpha != 1.0f) {
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
- alpha = ca->passepartalpha;
- }
+ float alpha = 1.0f;
- immUniformColor4f(0.0f, 0.0f, 0.0f, alpha);
+ if (ca->passepartalpha != 1.0f) {
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_BLEND);
+ alpha = ca->passepartalpha;
+ }
- if (x1i > 0.0f)
- immRectf(pos, 0.0f, winy, x1i, 0.0f);
- if (x2i < winx)
- immRectf(pos, x2i, winy, winx, 0.0f);
- if (y2i < winy)
- immRectf(pos, x1i, winy, x2i, y2i);
- if (y2i > 0.0f)
- immRectf(pos, x1i, y1i, x2i, 0.0f);
+ immUniformColor4f(0.0f, 0.0f, 0.0f, alpha);
- glDisable(GL_BLEND);
- }
+ if (x1i > 0.0f)
+ immRectf(pos, 0.0f, winy, x1i, 0.0f);
+ if (x2i < winx)
+ immRectf(pos, x2i, winy, winx, 0.0f);
+ if (y2i < winy)
+ immRectf(pos, x1i, winy, x2i, y2i);
+ if (y2i > 0.0f)
+ immRectf(pos, x1i, y1i, x2i, 0.0f);
- setlinestyle(0);
+ glDisable(GL_BLEND);
+ }
- immUniformThemeColor(TH_BACK);
- imm_draw_line_box(pos, x1i, y1i, x2i, y2i);
+ immUniformThemeColor(TH_BACK);
+ imm_draw_line_box(pos, x1i, y1i, x2i, y2i);
#ifdef VIEW3D_CAMERA_BORDER_HACK
- if (view3d_camera_border_hack_test == true) {
- immUniformColor3ubv(view3d_camera_border_hack_col);
- imm_draw_line_box(pos, x1i + 1, y1i + 1, x2i - 1, y2i - 1);
- view3d_camera_border_hack_test = false;
- }
+ if (view3d_camera_border_hack_test == true) {
+ immUniformColor3ubv(view3d_camera_border_hack_col);
+ imm_draw_line_box(pos, x1i + 1, y1i + 1, x2i - 1, y2i - 1);
+ view3d_camera_border_hack_test = false;
+ }
#endif
- setlinestyle(3);
-
- /* outer line not to confuse with object selecton */
- if (v3d->flag2 & V3D_LOCK_CAMERA) {
- immUniformThemeColor(TH_REDALERT);
- imm_draw_line_box(pos, x1i - 1, y1i - 1, x2i + 1, y2i + 1);
+ immUnbindProgram();
}
- immUniformThemeColor(TH_VIEW_OVERLAY);
- imm_draw_line_box(pos, x1i, y1i, x2i, y2i);
-
- /* border */
- if (scene->r.mode & R_BORDER) {
- float x3, y3, x4, y4;
+ /* And now, the dashed lines! */
+ {
+ VertexFormat *format = immVertexFormat();
+ unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
+ unsigned int line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
+ float color1[4] = {1.0f, 1.0f, 1.0f, 1.0f};
- x3 = floorf(x1 + (scene->r.border.xmin * (x2 - x1))) - 1;
- y3 = floorf(y1 + (scene->r.border.ymin * (y2 - y1))) - 1;
- x4 = floorf(x1 + (scene->r.border.xmax * (x2 - x1))) + (U.pixelsize - 1);
- y4 = floorf(y1 + (scene->r.border.ymax * (y2 - y1))) + (U.pixelsize - 1);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_BLEND);
- imm_cpack(0x4040FF);
- imm_draw_line_box(pos, x3, y3, x4, y4);
- }
- immUnbindProgram();
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
- /* safety border */
- if (ca) {
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- if (ca->dtx & CAM_DTX_CENTER) {
- float x3, y3;
+ immUniform1f("view_scale", 1.0f);
+ immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
+ immUniform1f("dash_width", 6.0f);
+ immUniform1f("dash_width_on", 3.0f);
- x3 = x1 + 0.5f * (x2 - x1);
- y3 = y1 + 0.5f * (y2 - y1);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list