Blender cloth simulator air pressure enhancement

Hi everyone,

I have just added a simple air pressure feature to Blender cloth simulator, and spring length scaling factor, hope it will be useful for somebody :slight_smile: See screenshots:


And there is a YouTube video demostrates this feature (warning, a bit outdated):

but I’m afraid that new users can’t post link… Anyway, if you google “blender cloth pressure” then you can find my video easily…

And there is a patch against svn r45571:

diff.zip (3.51 KB)

Finally I have a question: My code added a new property “spring length scaling” to Cloth modifier, whose default value is 1.0. But when I open old blend files contain Cloth simulation, the property is loaded as 0.0, breaks the simulation :frowning: What should I do to let the program load the default value correctly if old blend file doesn’t contain this property?

2 Likes

readfile.c is where you want to look, probably in the ‘do versions’ part.

Though what really should happen is the old files don’t break on loading but simulate how they did before you added these changes i.e. spring_length_scaling == 0 is the old behavior while spring_length_scaling > 0 is the new fancy stuff.

People get mad when a new change breaks all the work they did to get whatever they were working on ‘perfect’…

Oh, and you really should use the patch tracker on projects.blender.org once you get this nailed down because it’ll just get lost/ignored here.

----edit----

just watched the video – that’s super cool…

You could probably do a:

factor = foo * clmd->sim_parms->spring_length_scale ? clmd->sim_parms->spring_length_scale : 1.0f;

to just have it disabled when the factor is 0, not that I really understand if having a 0 spring length is valid or not. Or just use do_versions to set it to 1 on loading old files.

That looks terrific! I wish it will be in trunk soon!

Hi Uncle Entity,

Thanks for your advice, after checking ‘do_versions’ function in readfile.c I think I shouldn’t change it now, instead I added check code in the simulator, only use spring_length_scale if it’s positive, otherwise 1.0 (default value) will be used… And I have just submitted a patch on blender patch tracker (#30941).

That looks terrific! I wish it will be in trunk soon!

Thanks for your reply :slight_smile: Any new ideas and suggestions are welcome…

When the cloth collides with the plane, has no crinkles, crinkle control would be interesting
Thanks for your work

So apparently this will be in blender 2.81 :smiley:

https://developer.blender.org/T30941

Sure took a while though! :smiley:

Now in master

Quick demo:

front left: cloth with air pressure
front right: cloth without air pressure
back: soft body (not carefully matched, just for rough comparison)

Video’s short because the soft body sim took by far the longest, so I imagine cloth with pressure will be a satisfactory substitute under at least some circumstances for its time-saving benefits alone?

1 Like