Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vpd import #162

Open
wants to merge 4 commits into
base: blender-v4
Choose a base branch
from
Open

Fix vpd import #162

wants to merge 4 commits into from

Conversation

rintrint
Copy link

@rintrint rintrint commented Jun 26, 2024

As title.

@rintrint
Copy link
Author

rintrint commented Jun 26, 2024

I don't know what is the purpose of BoneConverterPoseMode. And what is the different between BoneConverter and BoneConverterPoseMode. In my case, I can deprecate BoneConverterPoseMode. So I'm not sure it is necessary or not.

Here is my test case. The behavior is as expected when deprecating BoneConverterPoseMode. The leg issue is due to the IK settings. Enabling rotation and setting it to 0.01 can temporarily fix it. Finding a suitable value for mmd_ik_limit_override takes some time.

https://bowlroll.net/file/315881
https://bowlroll.net/file/316794

Snipaste_2024-06-27_04-38-20 Snipaste_2024-06-27_04-41-08

@Kashouryo
Copy link

rintrint, your fix doesn't work on Blender version 4.2.3 according to #180
It will simply crash. More error information on the issue mentioned above.

@rintrint
Copy link
Author

rintrint, your fix doesn't work on Blender version 4.2.3 according to #180 It will simply crash. More error information on the issue mentioned above.

The VPD file and model I tested work fine. Could you provide more details about which VPD and model you used? Where did you download them from? That way I can test it myself.

I think we don't need to open a new issue since this hasn't been merged into the main branch yet. Let's just discuss it here.

@rintrint
Copy link
Author

The problem is fixed now.

Blender itself provides context.temp_override for safe context overriding in Blender 3.0+. However, the script was using its own custom implementation FnContext.temp_override_objects, which tried to handle multiple context properties at once and could cause instability.

I removed FnContext.temp_override_objects from importer because I discovered that the bone and shape key modifications don't actually require context override. The crashes were happening because doing complex bone modifications within a context override block is risky.

The fix was simple - just remove the context override and directly call self.__assignToArmature(obj). The bone transformations work fine without it since they're just property modifications, not operator calls.

I kept FnContext.temp_override_objects in the exporter since it's working properly there, with proper state backup and restoration. The exporter's usage is also simpler - just reading states rather than modifying them extensively.

This demonstrates that sometimes the best solution is to remove unnecessary complexity rather than trying to fix it.

@rintrint
Copy link
Author

rintrint commented Oct 30, 2024

The reason why I didn't experience crashes before is because I clicked on the MMD root (the cross-shaped empty object at the feet). Generally, this is the most correct approach, unless you want to discard shape keys for some reason.

@Kashouryo
Copy link

Thanks! This fixes the issue. I never seen a python plugin that crashes Blender entirely without even giving it a chance to spit out error messages.

@rintrint
Copy link
Author

rintrint commented Nov 3, 2024

This appears to be a Blender API issue. I have reported it to the Blender developers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants