Manipulator: rename struct members
Rename: - matrix -> matrix_basis - user_scale -> scale_basis - scale -> scale_final Match RNA names being added to custom-manipulator branch.
This commit is contained in:
@@ -66,13 +66,13 @@ static void arrow2d_draw_geom(wmManipulator *mpr, const float matrix[4][4], cons
|
||||
const float size_h = size / 2.0f;
|
||||
const float arrow_length = RNA_float_get(mpr->ptr, "length");
|
||||
const float arrow_angle = RNA_float_get(mpr->ptr, "angle");
|
||||
const float draw_line_ofs = (mpr->line_width * 0.5f) / mpr->scale;
|
||||
const float draw_line_ofs = (mpr->line_width * 0.5f) / mpr->scale_final;
|
||||
|
||||
uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
gpuPushMatrix();
|
||||
gpuMultMatrix(matrix);
|
||||
gpuScaleUniform(mpr->scale);
|
||||
gpuScaleUniform(mpr->scale_final);
|
||||
gpuRotate2D(RAD2DEGF(arrow_angle));
|
||||
/* local offset */
|
||||
gpuTranslate2f(
|
||||
@@ -107,7 +107,7 @@ static void manipulator_arrow2d_draw(const bContext *UNUSED(C), wmManipulator *m
|
||||
|
||||
glLineWidth(mpr->line_width);
|
||||
glEnable(GL_BLEND);
|
||||
arrow2d_draw_geom(mpr, mpr->matrix, col);
|
||||
arrow2d_draw_geom(mpr, mpr->matrix_basis, col);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
if (mpr->interaction_data) {
|
||||
@@ -129,7 +129,7 @@ static void manipulator_arrow2d_invoke(
|
||||
{
|
||||
ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__);
|
||||
|
||||
copy_m4_m4(inter->init_matrix, mpr->matrix);
|
||||
copy_m4_m4(inter->init_matrix, mpr->matrix_basis);
|
||||
mpr->interaction_data = inter;
|
||||
}
|
||||
|
||||
@@ -139,11 +139,11 @@ static int manipulator_arrow2d_test_select(
|
||||
const float mval[2] = {event->mval[0], event->mval[1]};
|
||||
const float arrow_length = RNA_float_get(mpr->ptr, "length");
|
||||
const float arrow_angle = RNA_float_get(mpr->ptr, "angle");
|
||||
const float line_len = arrow_length * mpr->scale;
|
||||
const float line_len = arrow_length * mpr->scale_final;
|
||||
float mval_local[2];
|
||||
|
||||
copy_v2_v2(mval_local, mval);
|
||||
sub_v2_v2(mval_local, mpr->matrix[3]);
|
||||
sub_v2_v2(mval_local, mpr->matrix_basis[3]);
|
||||
|
||||
float line[2][2];
|
||||
line[0][0] = line[0][1] = line[1][0] = 0.0f;
|
||||
|
||||
@@ -83,8 +83,8 @@ static void manipulator_arrow_matrix_world_get(wmManipulator *mpr, float r_matri
|
||||
{
|
||||
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
|
||||
|
||||
copy_m4_m4(r_matrix, arrow->manipulator.matrix);
|
||||
madd_v3_v3fl(r_matrix[3], arrow->manipulator.matrix[2], arrow->data.offset);
|
||||
copy_m4_m4(r_matrix, arrow->manipulator.matrix_basis);
|
||||
madd_v3_v3fl(r_matrix[3], arrow->manipulator.matrix_basis[2], arrow->data.offset);
|
||||
}
|
||||
|
||||
static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, const float color[4])
|
||||
@@ -188,7 +188,7 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons
|
||||
manipulator_color_get(&arrow->manipulator, highlight, col);
|
||||
manipulator_arrow_matrix_world_get(&arrow->manipulator, final_matrix);
|
||||
|
||||
mul_mat3_m4_fl(final_matrix, arrow->manipulator.scale);
|
||||
mul_mat3_m4_fl(final_matrix, arrow->manipulator.scale_final);
|
||||
mul_m4_m4m4(final_matrix, final_matrix, arrow->manipulator.matrix_offset);
|
||||
|
||||
gpuPushMatrix();
|
||||
@@ -253,7 +253,7 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve
|
||||
|
||||
copy_v3_v3(orig_origin, inter->init_matrix[3]);
|
||||
orig_origin[3] = 1.0f;
|
||||
add_v3_v3v3(offset, orig_origin, arrow->manipulator.matrix[2]);
|
||||
add_v3_v3v3(offset, orig_origin, arrow->manipulator.matrix_basis[2]);
|
||||
offset[3] = 1.0f;
|
||||
|
||||
/* calculate view vector */
|
||||
@@ -267,7 +267,7 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve
|
||||
|
||||
/* first determine if view vector is really close to the direction. If it is, we use
|
||||
* vertical movement to determine offset, just like transform system does */
|
||||
if (RAD2DEG(acos(dot_v3v3(viewvec, arrow->manipulator.matrix[2]))) > 5.0f) {
|
||||
if (RAD2DEG(acos(dot_v3v3(viewvec, arrow->manipulator.matrix_basis[2]))) > 5.0f) {
|
||||
/* multiply to projection space */
|
||||
mul_m4_v4(rv3d->persmat, orig_origin);
|
||||
mul_v4_fl(orig_origin, 1.0f / orig_origin[3]);
|
||||
@@ -312,11 +312,11 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve
|
||||
cross_v3_v3v3(plane, tangent, viewvec);
|
||||
|
||||
const float plane_offset = dot_v3v3(plane, offset);
|
||||
const float plane_dir = dot_v3v3(plane, arrow->manipulator.matrix[2]);
|
||||
const float plane_dir = dot_v3v3(plane, arrow->manipulator.matrix_basis[2]);
|
||||
const float fac = (plane_dir != 0.0f) ? (plane_offset / plane_dir) : 0.0f;
|
||||
facdir = (fac < 0.0) ? -1.0 : 1.0;
|
||||
if (isfinite(fac)) {
|
||||
mul_v3_v3fl(offset, arrow->manipulator.matrix[2], fac);
|
||||
mul_v3_v3fl(offset, arrow->manipulator.matrix_basis[2], fac);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -378,7 +378,7 @@ static void manipulator_arrow_invoke(
|
||||
inter->init_mval[0] = event->mval[0];
|
||||
inter->init_mval[1] = event->mval[1];
|
||||
|
||||
inter->init_scale = mpr->scale;
|
||||
inter->init_scale = mpr->scale_final;
|
||||
|
||||
manipulator_arrow_matrix_world_get(mpr, inter->init_matrix);
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ static void manipulator_rect_transform_draw(const bContext *UNUSED(C), wmManipul
|
||||
};
|
||||
|
||||
gpuPushMatrix();
|
||||
gpuMultMatrix(mpr->matrix);
|
||||
gpuMultMatrix(mpr->matrix_basis);
|
||||
gpuMultMatrix(mpr->matrix_offset);
|
||||
if (transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) {
|
||||
gpuScaleUniform(scale[0]);
|
||||
@@ -283,7 +283,7 @@ static int manipulator_rect_transform_test_select(
|
||||
const int transform_flag = RNA_enum_get(mpr->ptr, "transform");
|
||||
|
||||
/* rotate mouse in relation to the center and relocate it */
|
||||
sub_v2_v2v2(point_local, mouse, mpr->matrix[3]);
|
||||
sub_v2_v2v2(point_local, mouse, mpr->matrix_basis[3]);
|
||||
point_local[0] -= mpr->matrix_offset[3][0];
|
||||
point_local[1] -= mpr->matrix_offset[3][1];
|
||||
//rotate_m2(matrot, -cage->transform.rotation);
|
||||
|
||||
@@ -100,10 +100,10 @@ static void dial_calc_matrix(const wmManipulator *mpr, float mat[4][4])
|
||||
float rot[3][3];
|
||||
const float up[3] = {0.0f, 0.0f, 1.0f};
|
||||
|
||||
rotation_between_vecs_to_mat3(rot, up, mpr->matrix[2]);
|
||||
rotation_between_vecs_to_mat3(rot, up, mpr->matrix_basis[2]);
|
||||
copy_m4_m3(mat, rot);
|
||||
copy_v3_v3(mat[3], mpr->matrix[3]);
|
||||
mul_mat3_m4_fl(mat, mpr->scale);
|
||||
copy_v3_v3(mat[3], mpr->matrix_basis[3]);
|
||||
mul_mat3_m4_fl(mat, mpr->scale_final);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
@@ -202,12 +202,12 @@ static void dial_ghostarc_get_angles(
|
||||
|
||||
/* we might need to invert the direction of the angles */
|
||||
float view_vec[3], axis_vec[3];
|
||||
ED_view3d_global_to_vector(rv3d, mpr->matrix[3], view_vec);
|
||||
normalize_v3_v3(axis_vec, mpr->matrix[2]);
|
||||
ED_view3d_global_to_vector(rv3d, mpr->matrix_basis[3], view_vec);
|
||||
normalize_v3_v3(axis_vec, mpr->matrix_basis[2]);
|
||||
|
||||
float proj_outer_rel[3];
|
||||
mul_v3_project_m4_v3(proj_outer_rel, mat, co_outer);
|
||||
sub_v3_v3(proj_outer_rel, mpr->matrix[3]);
|
||||
sub_v3_v3(proj_outer_rel, mpr->matrix_basis[3]);
|
||||
|
||||
float proj_mval_new_rel[3];
|
||||
float proj_mval_init_rel[3];
|
||||
@@ -215,7 +215,7 @@ static void dial_ghostarc_get_angles(
|
||||
float ray_co[3], ray_no[3];
|
||||
float ray_lambda;
|
||||
|
||||
plane_from_point_normal_v3(dial_plane, mpr->matrix[3], axis_vec);
|
||||
plane_from_point_normal_v3(dial_plane, mpr->matrix_basis[3], axis_vec);
|
||||
|
||||
if (!ED_view3d_win_to_ray(ar, v3d, inter->init_mval, ray_co, ray_no, false) ||
|
||||
!isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false))
|
||||
@@ -223,7 +223,7 @@ static void dial_ghostarc_get_angles(
|
||||
goto fail;
|
||||
}
|
||||
madd_v3_v3v3fl(proj_mval_init_rel, ray_co, ray_no, ray_lambda);
|
||||
sub_v3_v3(proj_mval_init_rel, mpr->matrix[3]);
|
||||
sub_v3_v3(proj_mval_init_rel, mpr->matrix_basis[3]);
|
||||
|
||||
if (!ED_view3d_win_to_ray(ar, v3d, mval, ray_co, ray_no, false) ||
|
||||
!isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false))
|
||||
@@ -231,14 +231,14 @@ static void dial_ghostarc_get_angles(
|
||||
goto fail;
|
||||
}
|
||||
madd_v3_v3v3fl(proj_mval_new_rel, ray_co, ray_no, ray_lambda);
|
||||
sub_v3_v3(proj_mval_new_rel, mpr->matrix[3]);
|
||||
sub_v3_v3(proj_mval_new_rel, mpr->matrix_basis[3]);
|
||||
|
||||
const int draw_options = RNA_enum_get(mpr->ptr, "draw_options");
|
||||
|
||||
/* Start direction from mouse or set by user */
|
||||
const float *proj_init_rel =
|
||||
(draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y) ?
|
||||
mpr->matrix[1] : proj_mval_init_rel;
|
||||
mpr->matrix_basis[1] : proj_mval_init_rel;
|
||||
|
||||
/* return angles */
|
||||
const float start = angle_wrap_rad(angle_signed_on_axis_v3v3_v3(proj_outer_rel, proj_init_rel, axis_vec));
|
||||
@@ -337,7 +337,7 @@ static void manipulator_dial_draw_select(const bContext *C, wmManipulator *mpr,
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
|
||||
copy_v3_v3(clip_plane, rv3d->viewinv[2]);
|
||||
clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix[3]);
|
||||
clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix_basis[3]);
|
||||
glEnable(GL_CLIP_DISTANCE0);
|
||||
}
|
||||
|
||||
@@ -363,8 +363,8 @@ static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr)
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
|
||||
copy_v3_v3(clip_plane, rv3d->viewinv[2]);
|
||||
clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix[3]);
|
||||
clip_plane[3] -= 0.02 * mpr->scale;
|
||||
clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix_basis[3]);
|
||||
clip_plane[3] -= 0.02 * mpr->scale_final;
|
||||
|
||||
glEnable(GL_CLIP_DISTANCE0);
|
||||
}
|
||||
@@ -408,7 +408,7 @@ static void manipulator_dial_setup(wmManipulator *mpr)
|
||||
const float dir_default[3] = {0.0f, 0.0f, 1.0f};
|
||||
|
||||
/* defaults */
|
||||
copy_v3_v3(mpr->matrix[2], dir_default);
|
||||
copy_v3_v3(mpr->matrix_basis[2], dir_default);
|
||||
}
|
||||
|
||||
static void manipulator_dial_invoke(
|
||||
|
||||
@@ -143,8 +143,8 @@ static void grab3d_draw_intern(
|
||||
|
||||
manipulator_color_get(mpr, highlight, col);
|
||||
|
||||
copy_m4_m4(mat, mpr->matrix);
|
||||
mul_mat3_m4_fl(mat, mpr->scale);
|
||||
copy_m4_m4(mat, mpr->matrix_basis);
|
||||
mul_mat3_m4_fl(mat, mpr->scale_final);
|
||||
|
||||
gpuPushMatrix();
|
||||
if (mpr->interaction_data) {
|
||||
|
||||
@@ -96,8 +96,8 @@ static void manipulator_primitive_draw_intern(
|
||||
copy_v4_v4(col_inner, col_outer);
|
||||
col_inner[3] *= 0.5f;
|
||||
|
||||
copy_m4_m4(mat, mpr->matrix);
|
||||
mul_mat3_m4_fl(mat, mpr->scale);
|
||||
copy_m4_m4(mat, mpr->matrix_basis);
|
||||
mul_mat3_m4_fl(mat, mpr->scale_final);
|
||||
|
||||
gpuPushMatrix();
|
||||
gpuMultMatrix(mat);
|
||||
@@ -156,8 +156,8 @@ static void manipulator_primitive_invoke(
|
||||
{
|
||||
ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__);
|
||||
|
||||
copy_m4_m4(inter->init_matrix, mpr->matrix);
|
||||
inter->init_scale = mpr->scale;
|
||||
copy_m4_m4(inter->init_matrix, mpr->matrix_basis);
|
||||
inter->init_scale = mpr->scale_final;
|
||||
|
||||
mpr->interaction_data = inter;
|
||||
}
|
||||
|
||||
@@ -469,7 +469,7 @@ static void manipulator_bisect_prop_depth_get(
|
||||
RNA_property_float_get_array(op->ptr, man->data.prop_plane_co, plane_co);
|
||||
RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane_no);
|
||||
|
||||
value[0] = dot_v3v3(plane_no, plane_co) - dot_v3v3(plane_no, mpr->matrix[3]);
|
||||
value[0] = dot_v3v3(plane_no, plane_co) - dot_v3v3(plane_no, mpr->matrix_basis[3]);
|
||||
}
|
||||
|
||||
static void manipulator_bisect_prop_depth_set(
|
||||
@@ -487,7 +487,7 @@ static void manipulator_bisect_prop_depth_set(
|
||||
RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane);
|
||||
normalize_v3(plane);
|
||||
|
||||
plane[3] = -value[0] - dot_v3v3(plane, mpr->matrix[3]);
|
||||
plane[3] = -value[0] - dot_v3v3(plane, mpr->matrix_basis[3]);
|
||||
|
||||
/* Keep our location, may be offset simply to be inside the viewport. */
|
||||
closest_to_plane_normalized_v3(plane_co, plane, plane_co);
|
||||
|
||||
@@ -903,7 +903,7 @@ static void manipulator_spin_prop_depth_get(
|
||||
RNA_property_float_get_array(op->ptr, man->data.prop_axis_co, plane_co);
|
||||
RNA_property_float_get_array(op->ptr, man->data.prop_axis_no, plane_no);
|
||||
|
||||
value[0] = dot_v3v3(plane_no, plane_co) - dot_v3v3(plane_no, mpr->matrix[3]);
|
||||
value[0] = dot_v3v3(plane_no, plane_co) - dot_v3v3(plane_no, mpr->matrix_basis[3]);
|
||||
}
|
||||
|
||||
static void manipulator_spin_prop_depth_set(
|
||||
@@ -921,7 +921,7 @@ static void manipulator_spin_prop_depth_set(
|
||||
RNA_property_float_get_array(op->ptr, man->data.prop_axis_no, plane);
|
||||
normalize_v3(plane);
|
||||
|
||||
plane[3] = -value[0] - dot_v3v3(plane, mpr->matrix[3]);
|
||||
plane[3] = -value[0] - dot_v3v3(plane, mpr->matrix_basis[3]);
|
||||
|
||||
/* Keep our location, may be offset simply to be inside the viewport. */
|
||||
closest_to_plane_normalized_v3(plane_co, plane, plane_co);
|
||||
|
||||
@@ -87,13 +87,13 @@ struct wmManipulator {
|
||||
* besides this it's up to the manipulators internal code how the
|
||||
* rotation components are used for drawing and interaction.
|
||||
*/
|
||||
float matrix[4][4];
|
||||
float matrix_basis[4][4];
|
||||
/* custom offset from origin */
|
||||
float matrix_offset[4][4];
|
||||
/* runtime property, set the scale while drawing on the viewport */
|
||||
float scale;
|
||||
float scale_final;
|
||||
/* user defined scale, in addition to the original one */
|
||||
float user_scale;
|
||||
float scale_basis;
|
||||
/* user defined width for line drawing */
|
||||
float line_width;
|
||||
/* manipulator colors (uses default fallbacks if not defined) */
|
||||
|
||||
@@ -94,7 +94,7 @@ static wmManipulator *wm_manipulator_create(
|
||||
|
||||
WM_manipulator_properties_sanitize(mpr->ptr, 0);
|
||||
|
||||
unit_m4(mpr->matrix);
|
||||
unit_m4(mpr->matrix_basis);
|
||||
unit_m4(mpr->matrix_offset);
|
||||
|
||||
return mpr;
|
||||
@@ -149,7 +149,7 @@ static void manipulator_init(wmManipulator *mpr)
|
||||
{
|
||||
const float color_default[4] = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
|
||||
mpr->user_scale = 1.0f;
|
||||
mpr->scale_basis = 1.0f;
|
||||
mpr->line_width = 1.0f;
|
||||
|
||||
/* defaults */
|
||||
@@ -278,16 +278,16 @@ static void wm_manipulator_set_matrix_rotation_from_yz_axis__internal(
|
||||
void WM_manipulator_set_matrix_rotation_from_z_axis(
|
||||
wmManipulator *mpr, const float z_axis[3])
|
||||
{
|
||||
wm_manipulator_set_matrix_rotation_from_z_axis__internal(mpr->matrix, z_axis);
|
||||
wm_manipulator_set_matrix_rotation_from_z_axis__internal(mpr->matrix_basis, z_axis);
|
||||
}
|
||||
void WM_manipulator_set_matrix_rotation_from_yz_axis(
|
||||
wmManipulator *mpr, const float y_axis[3], const float z_axis[3])
|
||||
{
|
||||
wm_manipulator_set_matrix_rotation_from_yz_axis__internal(mpr->matrix, y_axis, z_axis);
|
||||
wm_manipulator_set_matrix_rotation_from_yz_axis__internal(mpr->matrix_basis, y_axis, z_axis);
|
||||
}
|
||||
void WM_manipulator_set_matrix_location(wmManipulator *mpr, const float origin[3])
|
||||
{
|
||||
copy_v3_v3(mpr->matrix[3], origin);
|
||||
copy_v3_v3(mpr->matrix_basis[3], origin);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,7 +320,7 @@ void WM_manipulator_set_flag(wmManipulator *mpr, const int flag, const bool enab
|
||||
|
||||
void WM_manipulator_set_scale(wmManipulator *mpr, const float scale)
|
||||
{
|
||||
mpr->user_scale = scale;
|
||||
mpr->scale_basis = scale;
|
||||
}
|
||||
|
||||
void WM_manipulator_set_line_width(wmManipulator *mpr, const float line_width)
|
||||
@@ -457,7 +457,7 @@ void wm_manipulator_calculate_scale(wmManipulator *mpr, const bContext *C)
|
||||
scale *= ED_view3d_pixel_size(rv3d, matrix_world[3]) / U.pixelsize;
|
||||
}
|
||||
else {
|
||||
scale *= ED_view3d_pixel_size(rv3d, mpr->matrix[3]) / U.pixelsize;
|
||||
scale *= ED_view3d_pixel_size(rv3d, mpr->matrix_basis[3]) / U.pixelsize;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -465,7 +465,7 @@ void wm_manipulator_calculate_scale(wmManipulator *mpr, const bContext *C)
|
||||
}
|
||||
}
|
||||
|
||||
mpr->scale = scale * mpr->user_scale;
|
||||
mpr->scale_final = mpr->scale_basis * scale;
|
||||
}
|
||||
|
||||
static void manipulator_update_prop_data(wmManipulator *mpr)
|
||||
|
||||
Reference in New Issue
Block a user