diff options
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 95 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_camera_types.h | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_camera.c | 6 |
3 files changed, 69 insertions, 38 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 40a38d7f78c..4ef02243cd5 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -921,7 +921,7 @@ void view3d_calc_camera_border(Scene *scene, ARegion *ar, RegionView3D *rv3d, Vi } } -static void drawviewborder_grid3(float x1, float x2, float y1, float y2, float fac, char diagonal) +static void drawviewborder_grid3(float x1, float x2, float y1, float y2, float fac) { float x3, y3, x4, y4; @@ -931,46 +931,63 @@ static void drawviewborder_grid3(float x1, float x2, float y1, float y2, float f y4= y1 + (1.0f - fac) * (y2-y1); glBegin(GL_LINES); - switch(diagonal) { - case '\0': - glVertex2f(x1, y3); - glVertex2f(x2, y3); + glVertex2f(x1, y3); + glVertex2f(x2, y3); - glVertex2f(x1, y4); - glVertex2f(x2, y4); + glVertex2f(x1, y4); + glVertex2f(x2, y4); - glVertex2f(x3, y1); - glVertex2f(x3, y2); + glVertex2f(x3, y1); + glVertex2f(x3, y2); - glVertex2f(x4, y1); - glVertex2f(x4, y2); - break; - case 'H': /* hoz */ - glVertex2f(x1, y1); - glVertex2f(x2, y4); + glVertex2f(x4, y1); + glVertex2f(x4, y2); + glEnd(); +} + +/* harmonious triangle */ +static void drawviewborder_triangle(float x1, float x2, float y1, float y2, const char golden, const char dir) +{ + float ofs; + float w= x2 - x1; + float h= y2 - y1; + + glBegin(GL_LINES); + if(w > h) { + if(golden) { + ofs = w * (1.0f-(1.0f/1.61803399)); + } + else { + ofs = h * (h / w); + } + if(dir == 'B') SWAP(float, y1, y2); - glVertex2f(x1, y3); + glVertex2f(x1, y1); glVertex2f(x2, y2); glVertex2f(x2, y1); - glVertex2f(x1, y4); + glVertex2f(x1 + (w - ofs), y2); - glVertex2f(x2, y3); glVertex2f(x1, y2); - break; - case 'V': /* vert */ - glVertex2f(x1, y1); - glVertex2f(x4, y2); + glVertex2f(x1 + ofs, y1); + } + else { + if(golden) { + ofs = h * (1.0f-(1.0f/1.61803399)); + } + else { + ofs = w * (w / h); + } + if(dir == 'B') SWAP(float, x1, x2); - glVertex2f(x3, y1); + glVertex2f(x1, y1); glVertex2f(x2, y2); - glVertex2f(x1, y2); - glVertex2f(x4, y1); - - glVertex2f(x3, y2); glVertex2f(x2, y1); - break; + glVertex2f(x1, y1 + ofs); + + glVertex2f(x1, y2); + glVertex2f(x2, y1 + (h - ofs)); } glEnd(); } @@ -1083,22 +1100,32 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) if (ca->dtx & CAM_DTX_THIRDS) { UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); - drawviewborder_grid3(x1, x2, y1, y2, 1.0f/3.0f, '\0'); + drawviewborder_grid3(x1, x2, y1, y2, 1.0f/3.0f); } if (ca->dtx & CAM_DTX_GOLDEN) { UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); - drawviewborder_grid3(x1, x2, y1, y2, 1.0f-(1.0f/1.61803399), '\0'); + drawviewborder_grid3(x1, x2, y1, y2, 1.0f-(1.0f/1.61803399)); + } + + if (ca->dtx & CAM_DTX_GOLDEN_TRI_A) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + drawviewborder_triangle(x1, x2, y1, y2, 0, 'A'); + } + + if (ca->dtx & CAM_DTX_GOLDEN_TRI_B) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + drawviewborder_triangle(x1, x2, y1, y2, 0, 'B'); } - if (ca->dtx & CAM_DTX_GOLDEN_DIAG_H) { + if (ca->dtx & CAM_DTX_HARMONY_TRI_A) { UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); - drawviewborder_grid3(x1, x2, y1, y2, 1.0f-(1.0f/1.61803399), 'H'); + drawviewborder_triangle(x1, x2, y1, y2, 1, 'A'); } - if (ca->dtx & CAM_DTX_GOLDEN_DIAG_V) { + if (ca->dtx & CAM_DTX_HARMONY_TRI_B) { UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); - drawviewborder_grid3(x1, x2, y1, y2, 1.0f-(1.0f/1.61803399), 'V'); + drawviewborder_triangle(x1, x2, y1, y2, 1, 'B'); } if (ca->flag & CAM_SHOWTITLESAFE) { diff --git a/source/blender/makesdna/DNA_camera_types.h b/source/blender/makesdna/DNA_camera_types.h index d64b72c6f40..952b4e799b5 100644 --- a/source/blender/makesdna/DNA_camera_types.h +++ b/source/blender/makesdna/DNA_camera_types.h @@ -76,8 +76,10 @@ typedef struct Camera { #define CAM_DTX_CENTER_DIAG 2 #define CAM_DTX_THIRDS 4 #define CAM_DTX_GOLDEN 8 -#define CAM_DTX_GOLDEN_DIAG_H 16 -#define CAM_DTX_GOLDEN_DIAG_V 32 +#define CAM_DTX_GOLDEN_TRI_A 16 +#define CAM_DTX_GOLDEN_TRI_B 32 +#define CAM_DTX_HARMONY_TRI_A 64 +#define CAM_DTX_HARMONY_TRI_B 128 /* flag */ #define CAM_SHOWLIMITS 1 diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c index 14a2f27bd8c..089c8c44943 100644 --- a/source/blender/makesrna/intern/rna_camera.c +++ b/source/blender/makesrna/intern/rna_camera.c @@ -72,8 +72,10 @@ void RNA_def_camera(BlenderRNA *brna) {CAM_DTX_CENTER_DIAG, "CENTER_DIAGONAL", 0, "Center Diagonal", ""}, {CAM_DTX_THIRDS, "THIRDS", 0, "Thirds", ""}, {CAM_DTX_GOLDEN, "GOLDEN", 0, "Golden", ""}, - {CAM_DTX_GOLDEN_DIAG_H, "GOLDEN_DIAGONAL_H", 0, "Golden Diagonal Hoz", ""}, - {CAM_DTX_GOLDEN_DIAG_V, "GOLDEN_DIAGONAL_V", 0, "Golden Diagonal Vert", ""}, + {CAM_DTX_GOLDEN_TRI_A, "GOLDEN_TRIANGLE_A", 0, "Golden Triangle A", ""}, + {CAM_DTX_GOLDEN_TRI_B, "GOLDEN_TRIANGLE_B", 0, "Golden Triangle B", ""}, + {CAM_DTX_HARMONY_TRI_A, "HARMONY_TRIANGLE_A", 0, "Harmonious Triangle A", ""}, + {CAM_DTX_HARMONY_TRI_B, "HARMONY_TRIANGLE_B", 0, "Harmonious Triangle B", ""}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_lens_unit_items[] = { {0, "MILLIMETERS", 0, "Millimeters", ""}, |