Undo-Induced Crashes and Object Rotation Reset#12
Undo-Induced Crashes and Object Rotation Reset#12zvodd wants to merge 2 commits intoAIGODLIKE:developfrom
Conversation
Place Tool (TODO other tools). Fix intermited rotation loss when repicking objects - Place Tool
|
Thank you for your PR. It seems that this still needs further modification |
(Previous commit regression)
|
Yes, sorry. For the above commit 77c9b17
I understand you are busy, and not necessary able to actively maintain the project. It's cumbersome to review random pull request to small projects when you have many other projects. No pressure - feel free not to merge this pull request or review at your leasure. |
See #11
Fix UNDO related invalid object references causing blender to crash - Place Tool.
Fix intermited rotation loss when repicking objects - Place Tool
Refactor Memory Safety and Transform Logic
Summary This PR resolves stability issues by moving away from direct object references and fixes placement logic to preserve local object rotation.
Refactor _runtime.py: Replaced bpy.types.Object references with Object Names (strings).
Validation: Implemented a helper to fetch objects via context.scene.objects.get(name). This ensures that if an object is deleted or replaced during an Undo, the tool receives None instead of a corrupted pointer.
Undo Handler: Added a bpy.app.handlers.undo_post listener to clear _runtime.py caches, forcing the tool to re-evaluate the scene state safely after a database reload.
Preserve Spin: Instead of reconstructing matrices from scratch in gzg.py, the gizmo matrix now uses the object's current matrix_world.to_quaternion() multiplied by the alignment offset.
Operator Logic: Updated op.py to calculate a "Rotation Offset" on invoke. During the modal loop, this offset is applied to the surface hit normal, allowing objects to maintain their local "spin" (e.g., a chair facing a specific direction) while still conforming to the floor/wall normal.
Migrated persistent state variables (like axis and invert_axis) into PlaceToolProps to ensure they are properly serialized and handled by Blender's native Undo system.