[Bf-blender-cvs] [5e162187780] temp-vse-preview-transform: Still issues with gizmo drawing...

Richard Antalik noreply at git.blender.org
Fri Sep 10 11:40:18 CEST 2021


Commit: 5e16218778093a074c6d1d0e6b548211dac81816
Author: Richard Antalik
Date:   Thu Sep 9 09:11:56 2021 +0200
Branches: temp-vse-preview-transform
https://developer.blender.org/rB5e16218778093a074c6d1d0e6b548211dac81816

Still issues with gizmo drawing...

===================================================================

M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
M	source/blender/editors/transform/transform_gizmo_2d.c

===================================================================

diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index bc19f6ed809..f5979d6471b 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -62,8 +62,8 @@
 #include "MEM_guardedalloc.h"
 #include "readfile.h"
 
-#include "SEQ_sequencer.h"
 #include "SEQ_iterator.h"
+#include "SEQ_sequencer.h"
 
 #include "RNA_access.h"
 
@@ -635,6 +635,7 @@ static bool seq_transform_origin_set(Sequence *seq, void *UNUSED(user_data))
 {
   StripTransform *transform = seq->strip->transform;
   transform->origin[0] = transform->origin[1] = 0.0f;
+  return true;
 }
 
 /* NOLINTNEXTLINE: readability-function-size */
@@ -1104,7 +1105,7 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
     /* Keep this block, even when empty. */
     LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
       SequencerToolSettings *sequencer_tool_settings = SEQ_tool_settings_ensure(scene);
-      sequencer_tool_settings->pivot_point = V3D_AROUND_LOCAL_ORIGINS;
+      sequencer_tool_settings->pivot_point = V3D_AROUND_CENTER_MEDIAN;
 
       if (scene->ed != NULL) {
         SEQ_for_each_callback(&scene->ed->seqbase, seq_transform_origin_set, NULL);
diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
index 6fd06b47656..8e911203b4d 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
@@ -909,6 +909,7 @@ static int gizmo_cage2d_test_select(bContext *C, wmGizmo *gz, const int mval[2])
 
 typedef struct RectTransformInteraction {
   float orig_mouse[2];
+  float orig_mouse_pivot_comp[2];
   float orig_matrix_offset[4][4];
   float orig_matrix_final_no_offset[4][4];
   Dial *dial;
@@ -932,6 +933,14 @@ static int gizmo_cage2d_invoke(bContext *C, wmGizmo *gz, const wmEvent *event)
     zero_v2(data->orig_mouse);
   }
 
+  float pivot[2];
+  zero_v2(pivot);
+  if (RNA_property_is_set(gz->ptr, RNA_struct_find_property(gz->ptr, "pivot"))) {
+    RNA_float_get_array(gz->ptr, "pivot", pivot);
+  }
+  copy_v2_v2(data->orig_mouse_pivot_comp, data->orig_mouse);
+  sub_v2_v2(data->orig_mouse_pivot_comp, pivot);
+
   gz->interaction_data = data;
 
   return OPERATOR_RUNNING_MODAL;
@@ -1001,29 +1010,37 @@ static int gizmo_cage2d_modal(bContext *C,
 
       data->dial = BLI_dial_init(test_co, FLT_EPSILON);
 
-      MUL_V2_V3_M4_FINAL(test_co, data->orig_mouse);
+      MUL_V2_V3_M4_FINAL(test_co, data->orig_mouse_pivot_comp);
       BLI_dial_angle(data->dial, test_co);
     }
 
+    float pivot[3];
+    if (RNA_property_is_set(
+            gz->ptr,
+            RNA_struct_find_property(gz->ptr, "pivot"))) {  // XXX this can be easily 0-1 range
+      zero_v3(pivot);
+      RNA_float_get_array(gz->ptr, "pivot", pivot);
+      sub_v2_v2(point_local, pivot);
+    }
+    else {
+      copy_v3_v3(pivot, data->orig_matrix_offset[3]);
+    }
+
     /* rotate */
     MUL_V2_V3_M4_FINAL(test_co, point_local);
     const float angle = BLI_dial_angle(data->dial, test_co);
 
     float matrix_space_inv[4][4];
     float matrix_rotate[4][4];
-    float pivot[3];
-
-    copy_v3_v3(pivot, data->orig_matrix_offset[3]);
-
     invert_m4_m4(matrix_space_inv, gz->matrix_space);
-
     unit_m4(matrix_rotate);
     mul_m4_m4m4(matrix_rotate, matrix_rotate, matrix_space_inv);
     rotate_m4(matrix_rotate, 'Z', -angle);
-    mul_m4_m4m4(matrix_rotate, matrix_rotate, gz->matrix_space);
+    mul_m4_m4m4(matrix_rotate, matrix_rotate, gz->matrix_space);  // XXX M x inv(M) == Mid???
 
     zero_v3(matrix_rotate[3]);
     transform_pivot_set_m4(matrix_rotate, pivot);
+    printf("%f\n", RAD2DEG(angle));
 
     mul_m4_m4m4(gz->matrix_offset, matrix_rotate, data->orig_matrix_offset);
 
@@ -1189,6 +1206,9 @@ static void GIZMO_GT_cage_2d(wmGizmoType *gzt)
   static float unit_v2[2] = {1.0f, 1.0f};
   RNA_def_float_vector(
       gzt->srna, "dimensions", 2, unit_v2, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX);
+  static float pivot_v2[2] = {0.0f, 0.0f};
+  RNA_def_float_vector(
+      gzt->srna, "pivot", 2, pivot_v2, 0, FLT_MAX, "Pivot Point", "", 0.0f, FLT_MAX);
   RNA_def_enum_flag(gzt->srna, "transform", rna_enum_transform, 0, "Transform Options", "");
   RNA_def_enum(gzt->srna,
                "draw_style",
diff --git a/source/blender/editors/transform/transform_gizmo_2d.c b/source/blender/editors/transform/transform_gizmo_2d.c
index 717daf18216..0e8587a04d2 100644
--- a/source/blender/editors/transform/transform_gizmo_2d.c
+++ b/source/blender/editors/transform/transform_gizmo_2d.c
@@ -151,6 +151,7 @@ typedef struct GizmoGroup2D {
 
   /* Sequencer uses matrix instead of values above. */
   float seq_matrix[4][4];
+  float seq_center_point[2];
   bool use_seq_matrix;
 
   bool no_cage;
@@ -242,30 +243,37 @@ static bool gizmo2d_calc_bounds(const bContext *C, float *r_center, GizmoGroup2D
 
     Sequence *seq = NULL;
     SEQ_ITERATOR_FOREACH (seq, strips) {
-      ggd->max[0] = seq->strip->stripdata->orig_width / 2;
-      ggd->min[0] = -ggd->max[0];
-      ggd->max[1] = seq->strip->stripdata->orig_height / 2;
-      ggd->min[1] = -ggd->max[1];
       const StripTransform *transform = seq->strip->transform;
-      const float pivot[2] = {transform->origin[0], transform->origin[1]};
-      float transform_matrix[3][3];
-      loc_rot_size_to_mat3(transform_matrix,
-                           (const float[]){transform->xofs, transform->yofs},
-                           0,
-                           (const float[]){transform->scale_x, transform->scale_y});
-      transform_pivot_set_m3(transform_matrix, pivot);
-      mul_m3_v2(transform_matrix, ggd->max);
-      mul_m3_v2(transform_matrix, ggd->min);
 
       float seq_loc[3] = {transform->xofs, transform->yofs, 0};
       float seq_rot[3][3];
       unit_m3(seq_rot);
       rotate_m3(seq_rot, transform->rotation);
-      float seq_scale[3] = {1, 1, 0};
+
+      // float seq_scale[3] = {1, 1, 1};
+      float seq_scale[3] = {transform->scale_x, transform->scale_y, 1};
+
+      float pivot[2] = {transform->origin[0], transform->origin[1]};
       float seq_mat_pivot[3] = {pivot[0], pivot[1], 0};
       loc_rot_size_to_mat4(ggd->seq_matrix, seq_loc, seq_rot, seq_scale);
       transform_pivot_set_m4(ggd->seq_matrix, seq_mat_pivot);
 
+      RNA_float_set_array(ggd->cage->ptr, "pivot", pivot);
+
+      add_v2_v2(pivot, (const float[]){transform->xofs, transform->yofs});
+      copy_v2_v2(ggd->seq_center_point, pivot);  // xxx this is bit awkward, that I need to specify
+                                                 // pivot again, this time in sequencer space
+
+      /*ggd->max[0] = transform->scale_x * seq->strip->stripdata->orig_width / 2;
+      ggd->min[0] = -ggd->max[0];
+      ggd->max[1] = transform->scale_y * seq->strip->stripdata->orig_height / 2;
+      ggd->min[1] = -ggd->max[1];*/
+
+      ggd->max[0] = seq->strip->stripdata->orig_width / 2;
+      ggd->min[0] = -ggd->max[0];
+      ggd->max[1] = seq->strip->stripdata->orig_height / 2;
+      ggd->min[1] = -ggd->max[1];
+
       ggd->use_seq_matrix = true;
     }
 
@@ -567,7 +575,12 @@ static void gizmo2d_xform_refresh(const bContext *C, wmGizmoGroup *gzgroup)
       float mid[2];
       const float *min = ggd->min;
       const float *max = ggd->max;
-      mid_v2_v2v2(mid, min, max);
+      if (ggd->use_seq_matrix) {
+        copy_v2_v2(mid, ggd->seq_center_point);
+      }
+      else {
+        mid_v2_v2v2(mid, min, max);
+      }
 
       gzop = WM_gizmo_operator_get(ggd->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X);
       PropertyRNA *prop_center_override = RNA_struct_find_property(&gzop->ptr, "center_override");



More information about the Bf-blender-cvs mailing list