|
|
|
|
@@ -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,7 +538,8 @@ 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 */
|
|
|
|
|
/* First, solid lines. */
|
|
|
|
|
{
|
|
|
|
|
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
|
|
|
|
|
|
@@ -554,8 +570,6 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setlinestyle(0);
|
|
|
|
|
|
|
|
|
|
immUniformThemeColor(TH_BACK);
|
|
|
|
|
imm_draw_line_box(pos, x1i, y1i, x2i, y2i);
|
|
|
|
|
|
|
|
|
|
@@ -567,16 +581,36 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
|
|
|
|
|
}
|
|
|
|
|
#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);
|
|
|
|
|
/* 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};
|
|
|
|
|
|
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
|
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
/* outer line not to confuse with object selection */
|
|
|
|
|
if (v3d->flag2 & V3D_LOCK_CAMERA) {
|
|
|
|
|
UI_GetThemeColor4fv(TH_REDALERT, color1);
|
|
|
|
|
immUniform4fv("color1", color1);
|
|
|
|
|
imm_draw_line_box_dashed(pos, line_origin, x1i - 1, y1i - 1, x2i + 1, y2i + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UI_GetThemeColor4fv(TH_VIEW_OVERLAY, color1);
|
|
|
|
|
immUniform4fv("color1", color1);
|
|
|
|
|
imm_draw_line_box_dashed(pos, line_origin, x1i, y1i, x2i, y2i);
|
|
|
|
|
|
|
|
|
|
/* border */
|
|
|
|
|
if (scene->r.mode & R_BORDER) {
|
|
|
|
|
@@ -587,26 +621,29 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
|
|
|
|
|
x4 = floorf(x1 + (scene->r.border.xmax * (x2 - x1))) + (U.pixelsize - 1);
|
|
|
|
|
y4 = floorf(y1 + (scene->r.border.ymax * (y2 - y1))) + (U.pixelsize - 1);
|
|
|
|
|
|
|
|
|
|
imm_cpack(0x4040FF);
|
|
|
|
|
imm_draw_line_box(pos, x3, y3, x4, y4);
|
|
|
|
|
immUniform4f("color1", 0.25f, 0.25f, 1.0f, 1.0f);
|
|
|
|
|
imm_draw_line_box_dashed(pos, line_origin, x3, y3, x4, y4);
|
|
|
|
|
}
|
|
|
|
|
immUnbindProgram();
|
|
|
|
|
|
|
|
|
|
/* safety border */
|
|
|
|
|
if (ca) {
|
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
|
UI_GetThemeColorBlend3f(TH_VIEW_OVERLAY, TH_BACK, 0.25f, color1);
|
|
|
|
|
color1[3] = 1.0f;
|
|
|
|
|
immUniform4fv("color1", color1);
|
|
|
|
|
|
|
|
|
|
if (ca->dtx & CAM_DTX_CENTER) {
|
|
|
|
|
float x3, y3;
|
|
|
|
|
|
|
|
|
|
x3 = x1 + 0.5f * (x2 - x1);
|
|
|
|
|
y3 = y1 + 0.5f * (y2 - y1);
|
|
|
|
|
|
|
|
|
|
immUniformThemeColorBlendShade(TH_VIEW_OVERLAY, TH_BACK, 0.25f, 0);
|
|
|
|
|
immBegin(PRIM_LINES, 4);
|
|
|
|
|
|
|
|
|
|
immAttrib2f(line_origin, x1, y3);
|
|
|
|
|
immVertex2f(pos, x1, y3);
|
|
|
|
|
immVertex2f(pos, x2, y3);
|
|
|
|
|
|
|
|
|
|
immAttrib2f(line_origin, x3, y1);
|
|
|
|
|
immVertex2f(pos, x3, y1);
|
|
|
|
|
immVertex2f(pos, x3, y2);
|
|
|
|
|
|
|
|
|
|
@@ -614,13 +651,13 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ca->dtx & CAM_DTX_CENTER_DIAG) {
|
|
|
|
|
|
|
|
|
|
immUniformThemeColorBlendShade(TH_VIEW_OVERLAY, TH_BACK, 0.25f, 0);
|
|
|
|
|
immBegin(PRIM_LINES, 4);
|
|
|
|
|
|
|
|
|
|
immAttrib2f(line_origin, x1, y1);
|
|
|
|
|
immVertex2f(pos, x1, y1);
|
|
|
|
|
immVertex2f(pos, x2, y2);
|
|
|
|
|
|
|
|
|
|
immAttrib2f(line_origin, x1, y2);
|
|
|
|
|
immVertex2f(pos, x1, y2);
|
|
|
|
|
immVertex2f(pos, x2, y1);
|
|
|
|
|
|
|
|
|
|
@@ -628,49 +665,43 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ca->dtx & CAM_DTX_THIRDS) {
|
|
|
|
|
immUniformThemeColorBlendShade(TH_VIEW_OVERLAY, TH_BACK, 0.25f, 0);
|
|
|
|
|
drawviewborder_grid3(pos, x1, x2, y1, y2, 1.0f / 3.0f);
|
|
|
|
|
drawviewborder_grid3(pos, line_origin, x1, x2, y1, y2, 1.0f / 3.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ca->dtx & CAM_DTX_GOLDEN) {
|
|
|
|
|
immUniformThemeColorBlendShade(TH_VIEW_OVERLAY, TH_BACK, 0.25f, 0);
|
|
|
|
|
drawviewborder_grid3(pos, x1, x2, y1, y2, 1.0f - (1.0f / 1.61803399f));
|
|
|
|
|
drawviewborder_grid3(pos, line_origin, x1, x2, y1, y2, 1.0f - (1.0f / 1.61803399f));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ca->dtx & CAM_DTX_GOLDEN_TRI_A) {
|
|
|
|
|
immUniformThemeColorBlendShade(TH_VIEW_OVERLAY, TH_BACK, 0.25f, 0);
|
|
|
|
|
drawviewborder_triangle(pos, x1, x2, y1, y2, 0, 'A');
|
|
|
|
|
drawviewborder_triangle(pos, line_origin, x1, x2, y1, y2, 0, 'A');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ca->dtx & CAM_DTX_GOLDEN_TRI_B) {
|
|
|
|
|
immUniformThemeColorBlendShade(TH_VIEW_OVERLAY, TH_BACK, 0.25f, 0);
|
|
|
|
|
drawviewborder_triangle(pos, x1, x2, y1, y2, 0, 'B');
|
|
|
|
|
drawviewborder_triangle(pos, line_origin, x1, x2, y1, y2, 0, 'B');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ca->dtx & CAM_DTX_HARMONY_TRI_A) {
|
|
|
|
|
immUniformThemeColorBlendShade(TH_VIEW_OVERLAY, TH_BACK, 0.25f, 0);
|
|
|
|
|
drawviewborder_triangle(pos, x1, x2, y1, y2, 1, 'A');
|
|
|
|
|
drawviewborder_triangle(pos, line_origin, x1, x2, y1, y2, 1, 'A');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ca->dtx & CAM_DTX_HARMONY_TRI_B) {
|
|
|
|
|
immUniformThemeColorBlendShade(TH_VIEW_OVERLAY, TH_BACK, 0.25f, 0);
|
|
|
|
|
drawviewborder_triangle(pos, x1, x2, y1, y2, 1, 'B');
|
|
|
|
|
drawviewborder_triangle(pos, line_origin, x1, x2, y1, y2, 1, 'B');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ca->flag & CAM_SHOW_SAFE_MARGINS) {
|
|
|
|
|
UI_draw_safe_areas(
|
|
|
|
|
pos, x1, x2, y1, y2,
|
|
|
|
|
pos, line_origin, x1, x2, y1, y2,
|
|
|
|
|
scene->safe_areas.title,
|
|
|
|
|
scene->safe_areas.action);
|
|
|
|
|
|
|
|
|
|
if (ca->flag & CAM_SHOW_SAFE_CENTER) {
|
|
|
|
|
UI_draw_safe_areas(
|
|
|
|
|
pos, x1, x2, y1, y2,
|
|
|
|
|
pos, line_origin, x1, x2, y1, y2,
|
|
|
|
|
scene->safe_areas.title_center,
|
|
|
|
|
scene->safe_areas.action_center);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
immUnbindProgram();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ca->flag & CAM_SHOWSENSOR) {
|
|
|
|
|
/* determine sensor fit, and get sensor x/y, for auto fit we
|
|
|
|
|
@@ -704,22 +735,26 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* draw */
|
|
|
|
|
float color[4];
|
|
|
|
|
UI_GetThemeColorShade4fv(TH_VIEW_OVERLAY, 100, color);
|
|
|
|
|
UI_draw_roundbox_4fv(false, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 2.0f, color);
|
|
|
|
|
}
|
|
|
|
|
UI_GetThemeColorShade4fv(TH_VIEW_OVERLAY, 100, color1);
|
|
|
|
|
immUniform4fv("color1", color1);
|
|
|
|
|
|
|
|
|
|
/* TODO Was using UI_draw_roundbox_4fv(false, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 2.0f, color).
|
|
|
|
|
* We'll probably need a new imm_draw_line_roundbox_dashed dor that - though in practice the
|
|
|
|
|
* 2.0f round corner effect was nearly not visible anyway... */
|
|
|
|
|
imm_draw_line_box_dashed(pos, line_origin, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setlinestyle(0);
|
|
|
|
|
immUnbindProgram();
|
|
|
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* camera name - draw in highlighted text color */
|
|
|
|
|
if (ca && (ca->flag & CAM_SHOWNAME)) {
|
|
|
|
|
UI_FontThemeColor(BLF_default(), TH_TEXT_HI);
|
|
|
|
|
BLF_draw_default(
|
|
|
|
|
x1i, y1i - (0.7f * U.widget_unit), 0.0f,
|
|
|
|
|
BLF_draw_default(x1i, y1i - (0.7f * U.widget_unit), 0.0f,
|
|
|
|
|
v3d->camera->id.name + 2, sizeof(v3d->camera->id.name) - 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void drawrenderborder(ARegion *ar, View3D *v3d)
|
|
|
|
|
|