mgear-dev / mgear4

mGear v.4.x.x (python 3 ready) https://mgear4.readthedocs.io
MIT License
266 stars 94 forks source link

Fixed the mirroring bug that occurs when using a custom control naming pattern or when side names 'L' and 'R' are changed. #285

Open joji2468ng opened 1 year ago

joji2468ng commented 1 year ago

The fix involves swapping the side label in control names based on the rig’s naming convention. It adapts dynamically by using guide data’s naming patterns to identify and swap the current side label, e.g., from ‘L’ to ‘R’ and vice versa."

The function uses the guide data's naming patterns to identify the current side label, (e.g., "L", "R", etc.) in the provided name, and swap it to the opposite side.

Reported: http://forum.mgear-framework.com/t/control-mirroring-broken/3687

miquelcampos commented 1 year ago

@joji2468ng Thanks for all the hard work on this. I still need to check this one, but in general, I think accessing the embedded data of the guide is not a good idea in this case. The main reasons are:

We have the information about custom side labels in each control.

image

I need to review the code I did because this issue also affects other tools like mirror pose. I would like to take some time here and work consistently across all the tools.

Feel free to keep researching this, but please understand that I will be very picky in this area. 🙇‍♂️ 🙏

joji2468ng commented 10 months ago

Sorry for the late reply to this.

The main reasons are:

  • old rigs will not have the embedded data. And I may make this data optional in new rigs
  • Probably not the fastest way to find
  • Ideally should support not mGear rigs. But this is not a high priority

All I need in a rig node is to embed naming rules for both controllers and joints. Simply having the side label on a controller node isn't sufficient information to replace the side label if the name rule was changed by a user. It could be a must-have metadata to add for naming rules and extensions naming on the rig data if you consider making the guide data optional there.

I've already tested the other tool like mirroring pose using the viewport menu. All function works with the new code.

When it comes to the guide data not existing on an old rig, we can add a conditional statement for rig version checking to avoid the non-existing attribute. If it doesn't exist, the name replacement process could work with what we have right now.

スクリーンショット 2023-11-19 103831