3D View: Show view-aligned rotation manipulators
This commit is contained in:
parent
f35572ae9e
commit
fecec7dd68
|
@ -94,6 +94,9 @@ typedef struct DialInteraction {
|
|||
#define DIAL_WIDTH 1.0f
|
||||
#define DIAL_RESOLUTION 48
|
||||
|
||||
/* Could make option, negative to clip more (don't show when view aligned). */
|
||||
#define DIAL_CLIP_BIAS 0.02
|
||||
|
||||
/**
|
||||
* We can't use this for the #wmManipulatorType.matrix_basis_get callback, it conflicts with depth picking.
|
||||
*/
|
||||
|
@ -347,6 +350,7 @@ static void manipulator_dial_draw_select(const bContext *C, wmManipulator *mpr,
|
|||
|
||||
copy_v3_v3(clip_plane, rv3d->viewinv[2]);
|
||||
clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix_basis[3]);
|
||||
clip_plane[3] += DIAL_CLIP_BIAS * mpr->scale_final;
|
||||
glEnable(GL_CLIP_DISTANCE0);
|
||||
}
|
||||
|
||||
|
@ -373,7 +377,7 @@ static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr)
|
|||
|
||||
copy_v3_v3(clip_plane, rv3d->viewinv[2]);
|
||||
clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix_basis[3]);
|
||||
clip_plane[3] -= 0.02f * mpr->scale_final;
|
||||
clip_plane[3] += DIAL_CLIP_BIAS * mpr->scale_final;
|
||||
|
||||
glEnable(GL_CLIP_DISTANCE0);
|
||||
}
|
||||
|
|
|
@ -254,16 +254,18 @@ static bool manipulator_is_axis_visible(
|
|||
const RegionView3D *rv3d, const int twtype,
|
||||
const float idot[3], const int axis_type, const int axis_idx)
|
||||
{
|
||||
bool is_plane = false;
|
||||
const uint aidx_norm = manipulator_orientation_axis(axis_idx, &is_plane);
|
||||
/* don't draw axis perpendicular to the view */
|
||||
if (aidx_norm < 3) {
|
||||
float idot_axis = idot[aidx_norm];
|
||||
if (is_plane) {
|
||||
idot_axis = 1.0f - idot_axis;
|
||||
}
|
||||
if (idot_axis < g_tw_axis_range[is_plane].min) {
|
||||
return false;
|
||||
if ((axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END) == 0) {
|
||||
bool is_plane = false;
|
||||
const uint aidx_norm = manipulator_orientation_axis(axis_idx, &is_plane);
|
||||
/* don't draw axis perpendicular to the view */
|
||||
if (aidx_norm < 3) {
|
||||
float idot_axis = idot[aidx_norm];
|
||||
if (is_plane) {
|
||||
idot_axis = 1.0f - idot_axis;
|
||||
}
|
||||
if (idot_axis < g_tw_axis_range[is_plane].min) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -340,25 +342,31 @@ static void manipulator_get_axis_color(
|
|||
const float alpha_hi = 1.0f;
|
||||
float alpha_fac;
|
||||
|
||||
bool is_plane = false;
|
||||
const int axis_idx_norm = manipulator_orientation_axis(axis_idx, &is_plane);
|
||||
/* get alpha fac based on axis angle, to fade axis out when hiding it because it points towards view */
|
||||
if (axis_idx_norm < 3) {
|
||||
const float idot_min = g_tw_axis_range[is_plane].min;
|
||||
const float idot_max = g_tw_axis_range[is_plane].max;
|
||||
float idot_axis = idot[axis_idx_norm];
|
||||
if (is_plane) {
|
||||
idot_axis = 1.0f - idot_axis;
|
||||
}
|
||||
alpha_fac = (
|
||||
(idot_axis > idot_max) ?
|
||||
1.0f : (idot_axis < idot_min) ?
|
||||
0.0f : ((idot_axis - idot_min) / (idot_max - idot_min)));
|
||||
}
|
||||
else {
|
||||
if (axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END) {
|
||||
/* Never fade rotation rings. */
|
||||
/* trackball rotation axis is a special case, we only draw a slight overlay */
|
||||
alpha_fac = (axis_idx == MAN_AXIS_ROT_T) ? 0.1f : 1.0f;
|
||||
}
|
||||
else {
|
||||
bool is_plane = false;
|
||||
const int axis_idx_norm = manipulator_orientation_axis(axis_idx, &is_plane);
|
||||
/* get alpha fac based on axis angle, to fade axis out when hiding it because it points towards view */
|
||||
if (axis_idx_norm < 3) {
|
||||
const float idot_min = g_tw_axis_range[is_plane].min;
|
||||
const float idot_max = g_tw_axis_range[is_plane].max;
|
||||
float idot_axis = idot[axis_idx_norm];
|
||||
if (is_plane) {
|
||||
idot_axis = 1.0f - idot_axis;
|
||||
}
|
||||
alpha_fac = (
|
||||
(idot_axis > idot_max) ?
|
||||
1.0f : (idot_axis < idot_min) ?
|
||||
0.0f : ((idot_axis - idot_min) / (idot_max - idot_min)));
|
||||
}
|
||||
else {
|
||||
alpha_fac = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
switch (axis_idx) {
|
||||
case MAN_AXIS_TRANS_X:
|
||||
|
|
Loading…
Reference in New Issue