Page MenuHome

Correctly display number of cached frames during simulation with negative start frame
Needs ReviewPublic

Authored by Benjamin Meyer (Anvilarion) on Mar 25 2019, 6:59 PM.

Details

Summary

I noticed, that the cloth simulation does not display the number of baked frames correctly when the start frame is negative even though Blender allows me to do this. As the line

* - cfra: frame for the cache, can be negative

is in the code i thought, that this is a bug and tried to solved it. This involed mainly magic number removal.

The part with

if (pid->cache->cached_frames)
    return pid->cache->cached_frames[cfra - pid->cache->startframe];

comes with quite a speed up for longer simulations, as otherwise Blender tries to read all cache files at every simulated frame, which on my system requires most of the baking time for aid simulations.

I consulted the page https://wiki.blender.org/wiki/Process/Module_Owners/List as to whom to give this for review but it doesn't list someone for "Physics / Other", which is where I would place this patch. Seeing that it might benefit the Rigid Body Simulation as well, I added Sergej Reich.
EDIT: .. and going by the recent commits I was wrong.
From a coding point of view, I tried to follow what I saw in the file, but as I am not that experienced in the C language I could have missed a guildeline or language feature.

Diff Detail

Event Timeline

source/blender/blenkernel/intern/pointcache.c
2888

Not sure what exactly info in this context. first_cacheable_frame ?
Also not sure why can't se always use cache->startframe - 1 ?

source/blender/blenkernel/intern/pointcache.c
2888

Not sure what exactly info in this context. first_cacheable_frame ?

From what I see in the code: For every pointcache there are data frames and (optionally) an info frame. The cache files of the data frames contain the simulation result and if a simulation desires it can have an info frame, which may contain other information. Which infomration is stored in data frames and which is stored in the info frame is determined by the pid->data_types and pid->info_types flags respectively.

Also not sure why can't se always use cache->startframe - 1 ?

To the best of my knowledge we can totally do this. It was just chosen to use 0 before so I thought it might be some kind of design decision. With your consent I would change it, so that the code becomes simpler.