digicreatures / rigacar

Blender addon to generate rig for cars
GNU General Public License v3.0
406 stars 59 forks source link

Bake operators fix #96

Open Griperis opened 1 year ago

Griperis commented 1 year ago

By using bpy_extras.anim_utils module directly there is more control over baking actions, but the steering pose transform bone needs to be reset in order to bake steering correctly.

The root of the issues was in inconsistency between the bpy.ops.nla.bake operator, if the internal functions are used directly it's behaviour is more controlled.

Blend with follow path constraint and baked rotation and steering from this PR. (Blender 3.4) bmw27_with_rig.zip

Closes #93, Closes #95, Closes #97, Closes #98

Edit: .zip with changes from this MR: rigacar-bake-operator-fix.zip

ExtremeAddons commented 1 year ago

Bingo! I tested the code by replacing it with your file. Bake seems to work again in Blender 3.4. Good job!

Griperis commented 1 year ago

Nice, thanks @ExtremeAddons. Let's bump @spoonless here so the code can get to master.

spoonless commented 1 year ago

thanks for the fix @Griperis . The bake operator is a real nightmare in Blender. However, I would like to make it work properly when baking action from NLA strips. I'm on it...

Griperis commented 1 year ago

Hopefuly the code will help you a bit @spoonless. Although can you elaborate on what you mean by

work properly when baking action from NLA strips?

Like having selected NLA strip and clicking the bake buttons it bakes the animation into the NLA strip?

spoonless commented 1 year ago

yep but the bake is correct only if your strip starts at frame 1 and you keep the default settings. Which is supposed to be not the case in most situations for a NLA editor. You can tweak the speed of the animation and even the start frame and the end frame. That's why I originally used the NLA bake operator to avoid having to deal with all those cases. But as the NLA bake operator becomes so restricted in Blender 3.4, your solution is probably the safest. It is just that I have to provide the necessary code to deal with the most common cases when someone would like to bake animation from the NLA editor. I didn't take time to read the code of the original NLA bake operator but I suppose it has to deal with that. I just tried to introduce a function to recompute the correct frame number before adding the key in the action. It seems to be good enough at least for a first release.

Griperis commented 1 year ago

I think it is possible that with some smart tweak to the code I provided will work also with NLA. In order to fix this issue I actually looked how the nla operator is implemented, and it's just a call with different parameters to the bpy_extras.anim_utils.bake_action_objects. And there weren't that many changes. Maybe there are changes in the NLA itself which I am not aware of, then it won't work. But it indeed seems like a very important use case, that I wasn't aware of.

Nacreo commented 1 year ago

Hey there! Unfortunately I can not get it to work. I ran the code as a script, imported it as a module and addon but it does not solve the problem. After reading rigacar still works in 3.1 I downloaded that version but it still was not working. I then imported a model with a working rig I created back in 2.8 with the same addon and also that wasn't working anymore.. Any ideas? Thanks in advance!

Ledjob commented 1 year ago

Tried on 3.4 works fine ! thanks

Alucardrangel commented 1 year ago

hey I'm new to blender and I don't rely know how to use the fix at all so can you show how

vilestorm commented 1 year ago

hey I'm new to blender and I don't rely know how to use the fix at all so can you show how

Remove the old Rigacar from your blender properties and install his files which have the fix :)

timtyson3d commented 1 year ago

how exactly am I supposted to transfer his data into my project

dilmandila commented 1 year ago

How do I install this fix? I tried copying the contents of the file, pasting onto a text document and saving as bake_operators.py to replace in original AddOn, but it is not working when I try to install in Blender 3.5

Might be something a noob is missing....

Griperis commented 1 year ago

Sometimes wheel rotation can be baked in the wrong direction, I will test that and also try to fix it. I will provide a .zip file here, so you can download the hotfix, before @spoonless works on the proper fix.

The baking wheel rotation was fixed, and there was an issue with the non-reset transform. This issue was also happening in 3.3, not only 3.4.

Also I have checked and it seems like the NLA strips can be edited, and to my understanding it works the same as in 3.3. Or is there a different expected behaviour @spoonless?

Addon .zip with the version of addon from this MR: rigacar-bake-operator-fix.zip