WIP: Alternative trackball rotation proposal #107448

Draft
Chris Clyne (Lateasusual) wants to merge 1 commits from lateasusual/blender:trackball_test into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
2 changed files with 37 additions and 0 deletions

View File

@ -133,6 +133,9 @@ typedef struct TransData {
TransDataCurveHandleFlags *hdata;
/** If set, copy of Object or #bPoseChannel protection. */
short protectflag;
// Local rotation accumulator
short rotmtx_init;
float rotmtx[3][3];
} TransData;
#define TRANSDATA_THREAD_LIMIT 1024

View File

@ -51,7 +51,24 @@ static void transdata_elem_trackball(const TransInfo *t,
float mat_buf[3][3];
const float(*mat)[3] = mat_final;
if (t->flag & T_PROP_EDIT) {
#if 0
float angle_temp;
float axis_temp[3];
mat3_to_axis_angle(axis_temp, &angle_temp, mat_final);
axis_angle_normalized_to_mat3(mat_buf, axis_temp, angle_temp *= td->factor);
#else
if (UNLIKELY(!td->rotmtx_init)) {
unit_m3(td->rotmtx);
td->rotmtx_init = 1;
}
axis_angle_normalized_to_mat3(mat_buf, axis, td->factor * angle);
mul_m3_m3_post(mat_buf, td->rotmtx);
copy_m3_m3(td->rotmtx, mat_buf);
#endif
mat = mat_buf;
}
ElementRotation(t, tc, td, mat, t->around);
@ -94,8 +111,16 @@ static void applyTrackballValue(TransInfo *t, const float axis[3], const float a
float mat_final[3][3];
int i;
// Temp hack since I don't have anywhere better to store this
// - these aren't used for trackball rotations anyway
float (*mat_temp)[3] = t->orient[0].matrix;
axis_angle_normalized_to_mat3(mat_final, axis, angle);
// Combine delta rotation with stored matrix
mul_m3_m3_post(mat_final, mat_temp);
copy_m3_m3(mat_temp, mat_final);
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
if (tc->data_len < TRANSDATA_THREAD_LIMIT) {
TransData *td = tc->data;
@ -128,7 +153,13 @@ static void applyTrackball(TransInfo *t, const int UNUSED(mval[2]))
size_t ofs = 0;
float phi[2];
// Temp hack since I'm not sure where is best to store temporary data like this
float* phi_prev = t->values + 2;
// Get delta phi, and write back resulting phi value
copy_v2_v2(phi, t->values);
sub_v2_v2(phi, phi_prev);
copy_v2_v2(phi_prev, t->values);
transform_snap_increment(t, phi);
@ -194,6 +225,9 @@ void initTrackball(TransInfo *t)
initMouseInputMode(t, &t->mouse, INPUT_TRACKBALL);
// TEMP HACK
unit_m3(t->orient[0].matrix);
t->idx_max = 1;
t->num.idx_max = 1;
t->snap[0] = DEG2RAD(5.0);