Commit: 0f99793deeedf06afac25d0bb2211059da1975b4
Author: Campbell Barton
Date:   Fri Jun 23 17:20:25 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB0f99793deeedf06afac25d0bb2211059da1975b4

Manipulator: partial depth support

Use the depth flag added for this purpose.
Although this only works for regular currently, not selection.

===================================================================

M       source/blender/editors/space_view3d/view3d_manipulators.c
M       source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c

===================================================================

diff --git a/source/blender/editors/space_view3d/view3d_manipulators.c 
b/source/blender/editors/space_view3d/view3d_manipulators.c
index 71999143613..3a12fc31ba2 100644
--- a/source/blender/editors/space_view3d/view3d_manipulators.c
+++ b/source/blender/editors/space_view3d/view3d_manipulators.c
@@ -113,7 +113,8 @@ void VIEW3D_WGT_lamp(wmManipulatorGroupType *wgt)
        wgt->idname = "VIEW3D_WGT_lamp";
 
        wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT |
-                     WM_MANIPULATORGROUPTYPE_3D);
+                     WM_MANIPULATORGROUPTYPE_3D |
+                     WM_MANIPULATORGROUPTYPE_DEPTH_3D);
 
        wgt->poll = WIDGETGROUP_lamp_poll;
        wgt->setup = WIDGETGROUP_lamp_setup;
@@ -292,7 +293,8 @@ void VIEW3D_WGT_camera(wmManipulatorGroupType *wgt)
 
        wgt->flag = (WM_MANIPULATORGROUPTYPE_PERSISTENT |
                     WM_MANIPULATORGROUPTYPE_3D |
-                    WM_MANIPULATORGROUPTYPE_SCALE);
+                    WM_MANIPULATORGROUPTYPE_SCALE |
+                    WM_MANIPULATORGROUPTYPE_DEPTH_3D);
 
        wgt->poll = WIDGETGROUP_camera_poll;
        wgt->setup = WIDGETGROUP_camera_setup;
@@ -361,7 +363,8 @@ void VIEW3D_WGT_force_field(wmManipulatorGroupType *wgt)
 
        wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT |
                      WM_MANIPULATORGROUPTYPE_3D |
-                     WM_MANIPULATORGROUPTYPE_SCALE);
+                     WM_MANIPULATORGROUPTYPE_SCALE |
+                     WM_MANIPULATORGROUPTYPE_DEPTH_3D);
 
        wgt->poll = WIDGETGROUP_forcefield_poll;
        wgt->setup = WIDGETGROUP_forcefield_setup;
diff --git 
a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c 
b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
index 15bfa7b171b..f5ef5572fd4 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
@@ -267,16 +267,42 @@ static void manipulators_draw_list(const wmManipulatorMap 
*mmap, const bContext
                glEnable(GL_MULTISAMPLE);
        }
 
+       bool is_depth_prev = false;
+
        /* draw_manipulators contains all visible manipulators - draw them */
        for (LinkData *link = draw_manipulators->first, *link_next; link; link 
= link_next) {
                wmManipulator *mpr = link->data;
                link_next = link->next;
 
+               bool is_depth = (mpr->parent_mgroup->type->flag & 
WM_MANIPULATORGROUPTYPE_DEPTH_3D) != 0;
+
+               /* Weak! since we don't 100% support depth yet (select ignores 
depth) always show highlighted */
+               if (is_depth && (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT)) {
+                       is_depth = false;
+               }
+
+               if (is_depth == is_depth_prev) {
+                       /* pass */
+               }
+               else {
+                       if (is_depth) {
+                               glEnable(GL_DEPTH_TEST);
+                       }
+                       else {
+                               glDisable(GL_DEPTH_TEST);
+                       }
+                       is_depth_prev = is_depth;
+               }
+
                mpr->type->draw(C, mpr);
                /* free/remove manipulator link after drawing */
                BLI_freelinkN(draw_manipulators, link);
        }
 
+       if (is_depth_prev) {
+               glDisable(GL_DEPTH_TEST);
+       }
+
        if (draw_multisample) {
                glDisable(GL_MULTISAMPLE);
        }
@@ -296,13 +322,37 @@ static void manipulator_find_active_3D_loop(const 
bContext *C, ListBase *visible
        int selectionbase = 0;
        wmManipulator *mpr;
 
+       /* TODO(campbell): this depends on depth buffer being written to, 
currently broken for the 3D view. */
+       bool is_depth_prev = false;
+
        for (LinkData *link = visible_manipulators->first; link; link = 
link->next) {
                mpr = link->data;
+               
+               bool is_depth = (mpr->parent_mgroup->type->flag & 
WM_MANIPULATORGROUPTYPE_DEPTH_3D) != 0;
+               if (is_depth == is_depth_prev) {
+                       /* pass */
+               }
+               else {
+                       if (is_depth) {
+                               glEnable(GL_DEPTH_TEST);
+                       }
+                       else {
+                               glDisable(GL_DEPTH_TEST);
+                       }
+                       is_depth_prev = is_depth;
+               }
+
                /* pass the selection id shifted by 8 bits. Last 8 bits are 
used for selected manipulator part id */
+
                mpr->type->draw_select(C, mpr, selectionbase << 8);
 
+
                selectionbase++;
        }
+
+       if (is_depth_prev) {
+               glDisable(GL_DEPTH_TEST);
+       }
 }
 
 static int manipulator_find_intersected_3d_intern(

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to