Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanne Karhu <jhkarh@gmail.com>2009-06-27 19:28:58 +0400
committerJanne Karhu <jhkarh@gmail.com>2009-06-27 19:28:58 +0400
commit912c2f440b447aa8cae9f3e3a86acf51cd495e3d (patch)
tree57b5274640b0c0854f83ff0e3e4ba43902a69ddc /source/blender/makesrna/intern/rna_object_force.c
parent9becf3c310b1051d1e9dc7170cb02d73bc4d6e08 (diff)
Pointcache refresh part 2
* Based on what happens during simulation the cache is marked (also in cache panel, this could possibly be extended to 3d view as well) as: - exact (not marked) - outdated (simulation is not done completely with current settings) - non-exact (frames were skipped during simulation) * The parameter "cache step" effects the number of frames between saved cache frames. - This can save a lot of memory (or disk space) if absolutely frame accurate simulation is not required. - Speeds up the "quick caching" very much. - Frames between cached frames are interpolated from the cached frames. - Current default value of 10 frames works nicely with up/down-arrows (skip 10 frames forwards/backwards on timeline), but can be changed if wanted. * The caching can work in normal or "quick" mode: [Normal cache] - Basic: Calculate what even happens (settings change, big frame steps etc.) and cache results, if possible try to use "cache step" when saving cache frames. - Becomes non-exact: After larger than 1 frame steps. - Becomes outdated: After any change effecting the simulation other than frame steps. - Pros/cons: Freedom of doing anything and playing with particles, but exact results have to calculated from the beginning. [Quick cache] - Basic: Calculate simulation up to current frame automatically on changes with cache step sized jumps in simulation. With multiple "quick cached" simulations the smallest cache step is used. - Becomes non-exact: Always from frame 1 (unless cache step = 1). - Becomes outdated: Never. - Pros/cons: Not very accurate, but super fast! - Todo: Transform of any animated (non-autokeyed) object is locked! Probably needs some tinkering with anim sys overrides. * The simulation can be run forwards or backwards even if it's cache is outdated or non-exact, the following rules apply in these situations: - step forwards (to unknown) -> simulate from last exact frame, store result - step backwards (to known) -> result is interpolated from existing frames, store result, clear cache forwards if current frame is after last exact frame * "Calculate to current frame" runs the simulation from start to current frame with a frame steps of 1. - Baking does the same, but runs the simulation all the way to the end of simulation. - Rendering does this automatically if the simulation is outdated of non-exact, so all rendered simulations will always be updated and exact. * Every cache panel also holds buttons to "Bake all dynamics", "Free all dynamics" and "Update all dynamics to current frame". * Cloth simulation supports the new cache too.
Diffstat (limited to 'source/blender/makesrna/intern/rna_object_force.c')
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c49
1 files changed, 44 insertions, 5 deletions
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index 07408c59538..4d8c728db12 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -31,6 +31,7 @@
#include "DNA_object_types.h"
#include "DNA_object_force.h"
+#include "DNA_scene_types.h"
#include "WM_types.h"
@@ -40,9 +41,38 @@
#include "BKE_context.h"
#include "BKE_pointcache.h"
+#include "BKE_depsgraph.h"
#include "BLI_blenlib.h"
+static void rna_Cache_change(bContext *C, PointerRNA *ptr)
+{
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = CTX_data_active_object(C);
+ PointCache *cache = (PointCache*)ptr->data;
+ PTCacheID *pid = NULL;
+ ListBase pidlist;
+
+ if(!ob)
+ return;
+
+ cache->flag |= PTCACHE_OUTDATED;
+
+ BKE_ptcache_ids_from_object(&pidlist, ob);
+
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+
+ for(pid=pidlist.first; pid; pid=pid->next) {
+ if(pid->cache==cache)
+ break;
+ }
+
+ if(pid)
+ BKE_ptcache_update_info(pid);
+
+ BLI_freelistN(&pidlist);
+}
+
static void rna_Cache_toggle_disk_cache(bContext *C, PointerRNA *ptr)
{
Object *ob = CTX_data_active_object(C);
@@ -240,6 +270,12 @@ static void rna_def_pointcache(BlenderRNA *brna)
RNA_def_property_range(prop, 1, 300000);
RNA_def_property_ui_text(prop, "End", "Frame on which the simulation stops.");
+ prop= RNA_def_property(srna, "step", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "step");
+ RNA_def_property_range(prop, 1, 20);
+ RNA_def_property_ui_text(prop, "Cache Step", "Number of frames between cached frames.");
+ RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_change");
+
/* flags */
prop= RNA_def_property(srna, "baked", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_BAKED);
@@ -257,21 +293,24 @@ static void rna_def_pointcache(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Cache is outdated", "");
+ prop= RNA_def_property(srna, "frames_skipped", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_FRAMES_SKIPPED);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "name");
RNA_def_property_ui_text(prop, "Name", "Cache name");
RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change");
- prop= RNA_def_property(srna, "autocache", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_AUTOCACHE);
- RNA_def_property_ui_text(prop, "Auto Cache", "Cache changes automatically");
- //RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_toggle_autocache");
+ prop= RNA_def_property(srna, "quick_cache", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_QUICK_CACHE);
+ RNA_def_property_ui_text(prop, "Quick Cache", "Update simulation with cache steps");
+ RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_change");
prop= RNA_def_property(srna, "info", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "info");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Cache Info", "Info on current cache status.");
-
}
static void rna_def_collision(BlenderRNA *brna)