Manipulator: partial depth support
Use the depth flag added for this purpose. Although this only works for regular currently, not selection.
This commit is contained in:
parent
d47cb2a4e4
commit
0f99793dee
|
@ -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;
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue