WM: option not to draw arrow manipulator stem
authorCampbell Barton <ideasman42@gmail.com>
Thu, 14 Jun 2018 07:25:55 +0000 (09:25 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 14 Jun 2018 07:25:55 +0000 (09:25 +0200)
source/blender/editors/include/ED_manipulator_library.h
source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c

index e8eeb0f1d7a3aab38f93e4d750bf07ccec9ee2f2..fca0f5c8806fa5483b7af259d80359f401b7a9de 100644 (file)
@@ -73,6 +73,7 @@ enum {
        ED_MANIPULATOR_ARROW_STYLE_CONE          = 3,
 };
 
+/* transform */
 enum {
        /* inverted offset during interaction - if set it also sets constrained below */
        ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED      = (1 << 3),
@@ -80,6 +81,12 @@ enum {
        ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED   = (1 << 4),
 };
 
+/* draw_options */
+enum {
+       /* Show arrow stem. */
+       ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM      = (1 << 0),
+};
+
 void ED_manipulator_arrow3d_set_ui_range(struct wmManipulator *mpr, const float min, const float max);
 void ED_manipulator_arrow3d_set_range_fac(struct wmManipulator *mpr, const float range_fac);
 
index 9ab8b6a9f7ccf2ba6a2999360013f8dfac807801..8516b9d8244f1c5d3c85642b1923fb8ae21e8c72 100644 (file)
@@ -92,6 +92,7 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select,
        uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
        bool unbind_shader = true;
        const int draw_style = RNA_enum_get(arrow->manipulator.ptr, "draw_style");
+       const int draw_options = RNA_enum_get(arrow->manipulator.ptr, "draw_options");
 
        immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
 
@@ -131,9 +132,13 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select,
                        {0.0f, 0.0f, arrow_length},
                };
 
-               glLineWidth(arrow->manipulator.line_width);
-               wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_STRIP);
-
+               if (draw_options & ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM) {
+                       glLineWidth(arrow->manipulator.line_width);
+                       wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_STRIP);
+               }
+               else {
+                       immUniformColor4fv(color);
+               }
 
                /* *** draw arrow head *** */
 
@@ -455,14 +460,28 @@ static void MANIPULATOR_WT_arrow_3d(wmManipulatorType *wt)
                {ED_MANIPULATOR_ARROW_STYLE_CONE, "CONE", 0, "Cone", ""},
                {0, NULL, 0, NULL, NULL}
        };
+       static EnumPropertyItem rna_enum_draw_options_items[] = {
+               {ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM, "STEM", 0, "Stem", ""},
+               {0, NULL, 0, NULL, NULL}
+       };
        static EnumPropertyItem rna_enum_transform_items[] = {
                {ED_MANIPULATOR_ARROW_XFORM_FLAG_INVERTED, "INVERT", 0, "Inverted", ""},
                {ED_MANIPULATOR_ARROW_XFORM_FLAG_CONSTRAINED, "CONSTRAIN", 0, "Constrained", ""},
                {0, NULL, 0, NULL, NULL}
        };
 
-       RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style_items, ED_MANIPULATOR_ARROW_STYLE_NORMAL, "Draw Style", "");
-       RNA_def_enum_flag(wt->srna, "transform", rna_enum_transform_items, 0, "Transform", "");
+       RNA_def_enum(
+               wt->srna, "draw_style", rna_enum_draw_style_items,
+               ED_MANIPULATOR_ARROW_STYLE_NORMAL,
+               "Draw Style", "");
+       RNA_def_enum_flag(
+               wt->srna, "draw_options", rna_enum_draw_options_items,
+               ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM,
+               "Draw Options", "");
+       RNA_def_enum_flag(
+               wt->srna, "transform", rna_enum_transform_items,
+               0,
+               "Transform", "");
 
        RNA_def_float(wt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX);
        RNA_def_float_vector(wt->srna, "aspect", 2, NULL, 0, FLT_MAX, "Aspect", "Cone/box style only", 0.0f, FLT_MAX);