Skip to content

Commit

Permalink
Allocate the s_edit container, change references
Browse files Browse the repository at this point in the history
Preparing for when this container becomes something we create and
destroy, store a pointer to an allocated version in mged_state rather
than the struct itself.
  • Loading branch information
starseeker committed Jan 24, 2025
1 parent 1bd9860 commit 9a2a8db
Show file tree
Hide file tree
Showing 45 changed files with 2,430 additions and 2,433 deletions.
10 changes: 5 additions & 5 deletions src/mged/axes.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ draw_e_axes(struct mged_state *s)
struct bv_axes gas;

if (s->edit_state.global_editing_state == ST_S_EDIT) {
MAT4X3PNT(v_ap1, view_state->vs_gvp->gv_model2view, s->s_edit.e_axes_pos);
MAT4X3PNT(v_ap2, view_state->vs_gvp->gv_model2view, s->s_edit.curr_e_axes_pos);
MAT4X3PNT(v_ap1, view_state->vs_gvp->gv_model2view, s->s_edit->e_axes_pos);
MAT4X3PNT(v_ap2, view_state->vs_gvp->gv_model2view, s->s_edit->curr_e_axes_pos);
} else if (s->edit_state.global_editing_state == ST_O_EDIT) {
point_t m_ap2;

MAT4X3PNT(v_ap1, view_state->vs_gvp->gv_model2view, s->s_edit.e_keypoint);
MAT4X3PNT(m_ap2, s->s_edit.model_changes, s->s_edit.e_keypoint);
MAT4X3PNT(v_ap1, view_state->vs_gvp->gv_model2view, s->s_edit->e_keypoint);
MAT4X3PNT(m_ap2, s->s_edit->model_changes, s->s_edit->e_keypoint);
MAT4X3PNT(v_ap2, view_state->vs_gvp->gv_model2view, m_ap2);
} else
return;
Expand All @@ -130,7 +130,7 @@ draw_e_axes(struct mged_state *s)
VMOVE(gas.label_color, color_scheme->cs_edit_axes_label2);
gas.line_width = axes_state->ax_edit_linewidth2;

bn_mat_mul(rot_mat, view_state->vs_gvp->gv_rotation, s->s_edit.acc_rot_sol);
bn_mat_mul(rot_mat, view_state->vs_gvp->gv_rotation, s->s_edit->acc_rot_sol);
dm_draw_hud_axes(DMP, view_state->vs_gvp->gv_size, rot_mat, &gas);
}

Expand Down
28 changes: 14 additions & 14 deletions src/mged/buttons.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ ill_common(struct mged_state *s) {
edobj = 0; /* sanity */
edsol = 0; /* sanity */
movedir = 0; /* No edit modes set */
MAT_IDN(s->s_edit.model_changes); /* No changes yet */
MAT_IDN(s->s_edit->model_changes); /* No changes yet */

return 1; /* OK */
}
Expand Down Expand Up @@ -587,9 +587,9 @@ be_o_scale(ClientData clientData, Tcl_Interp *UNUSED(interp), int UNUSED(argc),
dm_set_dirty(DMP, 1);
set_e_axes_pos(s, 1);

s->s_edit.edit_absolute_scale = s->edit_state.acc_sc_obj - 1.0;
if (s->s_edit.edit_absolute_scale > 0.0)
s->s_edit.edit_absolute_scale /= 3.0;
s->s_edit->edit_absolute_scale = s->edit_state.acc_sc_obj - 1.0;
if (s->s_edit->edit_absolute_scale > 0.0)
s->s_edit->edit_absolute_scale /= 3.0;
return TCL_OK;
}

Expand All @@ -610,9 +610,9 @@ be_o_xscale(ClientData clientData, Tcl_Interp *UNUSED(interp), int UNUSED(argc),
dm_set_dirty(DMP, 1);
set_e_axes_pos(s, 1);

s->s_edit.edit_absolute_scale = s->edit_state.acc_sc[0] - 1.0;
if (s->s_edit.edit_absolute_scale > 0.0)
s->s_edit.edit_absolute_scale /= 3.0;
s->s_edit->edit_absolute_scale = s->edit_state.acc_sc[0] - 1.0;
if (s->s_edit->edit_absolute_scale > 0.0)
s->s_edit->edit_absolute_scale /= 3.0;
return TCL_OK;
}

Expand All @@ -633,9 +633,9 @@ be_o_yscale(ClientData clientData, Tcl_Interp *UNUSED(interp), int UNUSED(argc),
dm_set_dirty(DMP, 1);
set_e_axes_pos(s, 1);

s->s_edit.edit_absolute_scale = s->edit_state.acc_sc[1] - 1.0;
if (s->s_edit.edit_absolute_scale > 0.0)
s->s_edit.edit_absolute_scale /= 3.0;
s->s_edit->edit_absolute_scale = s->edit_state.acc_sc[1] - 1.0;
if (s->s_edit->edit_absolute_scale > 0.0)
s->s_edit->edit_absolute_scale /= 3.0;
return TCL_OK;
}

Expand All @@ -656,9 +656,9 @@ be_o_zscale(ClientData clientData, Tcl_Interp *UNUSED(interp), int UNUSED(argc),
dm_set_dirty(DMP, 1);
set_e_axes_pos(s, 1);

s->s_edit.edit_absolute_scale = s->edit_state.acc_sc[2] - 1.0;
if (s->s_edit.edit_absolute_scale > 0.0)
s->s_edit.edit_absolute_scale /= 3.0;
s->s_edit->edit_absolute_scale = s->edit_state.acc_sc[2] - 1.0;
if (s->s_edit->edit_absolute_scale > 0.0)
s->s_edit->edit_absolute_scale /= 3.0;
return TCL_OK;
}

Expand Down Expand Up @@ -938,7 +938,7 @@ be_s_scale(ClientData clientData, Tcl_Interp *UNUSED(interp), int UNUSED(argc),
edsol = BE_S_SCALE;
mged_set_edflag(s, SSCALE);
mmenu_set(s, MENU_L1, NULL);
s->s_edit.acc_sc_sol = 1.0;
s->s_edit->acc_sc_sol = 1.0;

set_e_axes_pos(s, 1);
return TCL_OK;
Expand Down
42 changes: 21 additions & 21 deletions src/mged/chgmodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,41 +132,41 @@ mged_rot_obj(struct mged_state *s, int iflag, fastf_t *argvect)
}

/* find point for rotation to take place wrt */
VMOVE(model_pt, s->s_edit.e_keypoint);
VMOVE(model_pt, s->s_edit->e_keypoint);

MAT4X3PNT(point, s->s_edit.model_changes, model_pt);
MAT4X3PNT(point, s->s_edit->model_changes, model_pt);

/* Find absolute translation vector to go from "model_pt" to
* "point" without any of the rotations in "s->s_edit.model_changes"
* "point" without any of the rotations in "s->s_edit->model_changes"
*/
VSCALE(s_point, point, s->s_edit.model_changes[15]);
VSCALE(s_point, point, s->s_edit->model_changes[15]);
VSUB2(v_work, s_point, model_pt);

/* REDO "s->s_edit.model_changes" such that:
/* REDO "s->s_edit->model_changes" such that:
* 1. NO rotations (identity)
* 2. trans == v_work
* 3. same scale factor
*/
MAT_IDN(temp);
MAT_DELTAS_VEC(temp, v_work);
temp[15] = s->s_edit.model_changes[15];
MAT_COPY(s->s_edit.model_changes, temp);
temp[15] = s->s_edit->model_changes[15];
MAT_COPY(s->s_edit->model_changes, temp);

/* build new rotation matrix */
MAT_IDN(temp);
bn_mat_angles(temp, argvect[0], argvect[1], argvect[2]);

if (iflag) {
/* apply accumulated rotations */
bn_mat_mul2(s->s_edit.acc_rot_sol, temp);
bn_mat_mul2(s->s_edit->acc_rot_sol, temp);
}

/*XXX*/ MAT_COPY(s->s_edit.acc_rot_sol, temp); /* used to rotate solid/object axis */
/*XXX*/ MAT_COPY(s->s_edit->acc_rot_sol, temp); /* used to rotate solid/object axis */

/* Record the new rotation matrix into the revised
* s->s_edit.model_changes matrix wrt "point"
* s->s_edit->model_changes matrix wrt "point"
*/
wrt_point(s->s_edit.model_changes, temp, s->s_edit.model_changes, point);
wrt_point(s->s_edit->model_changes, temp, s->s_edit->model_changes, point);

new_edit_mats(s);

Expand Down Expand Up @@ -259,7 +259,7 @@ f_sc_obj(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[]
default:
case BE_O_SCALE:
/* global scaling */
incr[15] = 1.0 / (atof(argv[1]) * s->s_edit.model_changes[15]);
incr[15] = 1.0 / (atof(argv[1]) * s->s_edit->model_changes[15]);
break;
case BE_O_XSCALE:
/* local scaling ... X-axis */
Expand All @@ -279,11 +279,11 @@ f_sc_obj(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[]
}

/* find point the scaling is to take place wrt */
VMOVE(temp, s->s_edit.e_keypoint);
VMOVE(temp, s->s_edit->e_keypoint);

MAT4X3PNT(point, s->s_edit.model_changes, temp);
MAT4X3PNT(point, s->s_edit->model_changes, temp);

wrt_point(s->s_edit.model_changes, incr, s->s_edit.model_changes, point);
wrt_point(s->s_edit->model_changes, incr, s->s_edit->model_changes, point);
new_edit_mats(s);

return TCL_OK;
Expand Down Expand Up @@ -347,13 +347,13 @@ f_tr_obj(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[]
new_vertex[i] = atof(argv[i+1]) * s->dbip->dbi_local2base;
}

VMOVE(model_sol_pt, s->s_edit.e_keypoint);
VMOVE(model_sol_pt, s->s_edit->e_keypoint);

MAT4X3PNT(ed_sol_pt, s->s_edit.model_changes, model_sol_pt);
MAT4X3PNT(ed_sol_pt, s->s_edit->model_changes, model_sol_pt);
VSUB2(model_incr, new_vertex, ed_sol_pt);
MAT_DELTAS_VEC(incr, model_incr);
MAT_COPY(old, s->s_edit.model_changes);
bn_mat_mul(s->s_edit.model_changes, incr, old);
MAT_COPY(old, s->s_edit->model_changes);
bn_mat_mul(s->s_edit->model_changes, incr, old);
new_edit_mats(s);

return TCL_OK;
Expand Down Expand Up @@ -411,10 +411,10 @@ f_qorot(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])
ang = atof(argv[7]) * DEG2RAD;

/* Get matrix for rotation about a point, direction vector and apply to
* s->s_edit.model_changes matrix
* s->s_edit->model_changes matrix
*/
bn_mat_arb_rot(temp, specified_pt, direc, ang);
bn_mat_mul2(temp, s->s_edit.model_changes);
bn_mat_mul2(temp, s->s_edit->model_changes);

new_edit_mats(s);

Expand Down
2 changes: 1 addition & 1 deletion src/mged/chgtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ cmd_oed(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])
illump = BU_LIST_NEXT(bv_scene_obj, &gdlp->dl_head_scene_obj);/* any valid solid would do */
edobj = 0; /* sanity */
movedir = 0; /* No edit modes set */
MAT_IDN(s->s_edit.model_changes); /* No changes yet */
MAT_IDN(s->s_edit->model_changes); /* No changes yet */
(void)chg_state(s, ST_VIEW, ST_O_PICK, "internal change of state");
/* reset accumulation local scale factors */
s->edit_state.acc_sc[0] = s->edit_state.acc_sc[1] = s->edit_state.acc_sc[2] = 1.0;
Expand Down
Loading

0 comments on commit 9a2a8db

Please sign in to comment.