zturtleman / mm3d

Maverick Model 3D is a 3D model editor and animator for games.
https://clover.moe/mm3d
GNU General Public License v2.0
115 stars 24 forks source link

deleteBoneJoint undo is incomplete (doesn't track resulting geometrical transformation) #153

Open m-7761 opened 3 years ago

m-7761 commented 3 years ago

The following matrix code isn't passed to the undo system:

https://github.com/zturtleman/mm3d/blob/8f121241275d3f52dcd0eaab6ef846c8c0b23ded/src/libmm3d/model.cc#L952-L962

I noticed this when wanting to add a "Parent" item to the Properties panel. In the following code I solved it by moving the body into setBoneJointParent, and having it pass the new relative matrix to a new private method called parentBoneJoint that adds the new and previous relative matrices to the undo object, that in turn uses "parentBoneJoint":

https://github.com/mick-p1982/mm3d/commit/21f3ce4de37c8f8adcc4d28883b95b331c94b5cf

This also makes setBoneJointParent useful for actually reparenting joints as a user API.

m-7761 commented 3 years ago

WARNING: I remembered the next day that many loops are written with the assumption that parent nodes are lower in the joint list, so that if reparenting is permitted to break this assumption, something major has to be done about it; a full audit, algorithm, etc. I suppose I will do that shortly.