Rotation of mirrored bones is wrapped to 180 degrees during transformation #114073

Open
opened 2023-10-23 20:11:52 +02:00 by john · 5 comments

Blender Version
Broken: version: 3.5.0, branch: blender-v3.5-release, commit date: 2023-03-29 02:56, hash: 1be25cfff18b

Short description of error
When we transform a bone with X-mirror and use rotation values above 180 degrees, the equivalent mirrored bone has the rotations wrapped 180 degrees.

See:
https://youtu.be/21W7qyeqQrQ?feature=shared

Exact steps for others to reproduce the error

  • Open attached .blend file
  • Select any bone in Pose mode
  • Rotate the bone in the X axis to values above 360 (for example 720)
  • Check the X rotation of the mirrored bone
**Blender Version** Broken: version: 3.5.0, branch: blender-v3.5-release, commit date: 2023-03-29 02:56, hash: `1be25cfff18b` **Short description of error** When we transform a bone with X-mirror and use rotation values above 180 degrees, the equivalent mirrored bone has the rotations wrapped 180 degrees. See: https://youtu.be/21W7qyeqQrQ?feature=shared **Exact steps for others to reproduce the error** - Open attached .blend file - Select any bone in Pose mode - Rotate the bone in the X axis to values above 360 (for example 720) - Check the X rotation of the mirrored bone
john added the
Status
Needs Triage
Priority
Normal
Type
Report
labels 2023-10-23 20:11:53 +02:00

Thanks for the report, @keki-2.

I analyzed the .blend file attached and noticed that the real problem is that the Rotation of mirrored bones is wrapped to 360 degrees during transformation.

It has no real relationship with drivers.
The file can be greatly simplified.

I will edit the report to confirm...

Thanks for the report, @keki-2. I analyzed the .blend file attached and noticed that the real problem is that the Rotation of mirrored bones is wrapped to 360 degrees during transformation. It has no real relationship with drivers. The file can be greatly simplified. I will edit the report to confirm...
Germano Cavalcante changed title from Rotation Drivers on an Armature have different behaviour if you move the driver bone directly or indirectly after rotating more than 180 degrees. to Rotation of mirrored bones is wrapped to 360 degrees during transformation 2023-10-24 22:21:46 +02:00
Germano Cavalcante changed title from Rotation of mirrored bones is wrapped to 360 degrees during transformation to Rotation of mirrored bones is wrapped to 180 degrees during transformation 2023-10-24 22:23:39 +02:00
Author

the problem also shows up if you use a constraint to move the driver bone, not just with the mirror.

the problem also shows up if you use a constraint to move the driver bone, not just with the mirror.
Author
https://youtu.be/EOmwlpKXCMc look

This is another issue @keki-2, and if I'm not mistaken it has already been reported before.

This is another issue @keki-2, and if I'm not mistaken it has already been reported before.

I have been looking for solutions to this problem.
The one below works, but adds a lot of complexity to the code. Especially because of "Relative Mirror".

diff --git a/source/blender/editors/transform/transform_convert_armature.cc b/source/blender/editors/transform/transform_convert_armature.cc
index c4a628d0883..b11e1c9a251 100644
--- a/source/blender/editors/transform/transform_convert_armature.cc
+++ b/source/blender/editors/transform/transform_convert_armature.cc
@@ -1338,7 +1338,21 @@ static void pose_transform_mirror_update(TransInfo *t, TransDataContainer *tc, O
     if (pid) {
       mul_m4_m4m4(pchan_mtx_final, pid->offset_mtx, pchan_mtx_final);
     }
-    BKE_pchan_apply_mat4(pchan, pchan_mtx_final, false);
+
+    float rot[3][3];
+    mat4_to_loc_rot_size(pchan->loc, rot, pchan->size, pchan_mtx_final);
+
+    if (pchan->rotmode == ROT_MODE_EUL && pchan->rotmode == pchan_orig->rotmode) {
+      pchan->eul[0] = pchan_orig->eul[0];
+      pchan->eul[1] = -pchan_orig->eul[1];
+      pchan->eul[2] = -pchan_orig->eul[2];
+      if (pid) {
+        BKE_pchan_mat3_to_rot(pchan, rot, true);
+      }
+    }
+    else {
+      BKE_pchan_mat3_to_rot(pchan, rot, false);
+    }
 
     /* Set flag to let auto key-frame know to key-frame the mirrored bone. */
     pchan->bone->flag |= BONE_TRANSFORM_MIRROR;

There are certainly simpler ways to achieve this.
Maybe we could just set use_compat to true.

I have been looking for solutions to this problem. The one below works, but adds a lot of complexity to the code. Especially because of "Relative Mirror". ```diff diff --git a/source/blender/editors/transform/transform_convert_armature.cc b/source/blender/editors/transform/transform_convert_armature.cc index c4a628d0883..b11e1c9a251 100644 --- a/source/blender/editors/transform/transform_convert_armature.cc +++ b/source/blender/editors/transform/transform_convert_armature.cc @@ -1338,7 +1338,21 @@ static void pose_transform_mirror_update(TransInfo *t, TransDataContainer *tc, O if (pid) { mul_m4_m4m4(pchan_mtx_final, pid->offset_mtx, pchan_mtx_final); } - BKE_pchan_apply_mat4(pchan, pchan_mtx_final, false); + + float rot[3][3]; + mat4_to_loc_rot_size(pchan->loc, rot, pchan->size, pchan_mtx_final); + + if (pchan->rotmode == ROT_MODE_EUL && pchan->rotmode == pchan_orig->rotmode) { + pchan->eul[0] = pchan_orig->eul[0]; + pchan->eul[1] = -pchan_orig->eul[1]; + pchan->eul[2] = -pchan_orig->eul[2]; + if (pid) { + BKE_pchan_mat3_to_rot(pchan, rot, true); + } + } + else { + BKE_pchan_mat3_to_rot(pchan, rot, false); + } /* Set flag to let auto key-frame know to key-frame the mirrored bone. */ pchan->bone->flag |= BONE_TRANSFORM_MIRROR; ``` There are certainly simpler ways to achieve this. Maybe we could just set `use_compat` to `true`.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#114073
No description provided.