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/editors
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/editors')
-rw-r--r--source/blender/editors/physics/ed_pointcache.c122
-rw-r--r--source/blender/editors/transform/transform_conversions.c6
2 files changed, 123 insertions, 5 deletions
diff --git a/source/blender/editors/physics/ed_pointcache.c b/source/blender/editors/physics/ed_pointcache.c
index 3374e05883c..893c59a521d 100644
--- a/source/blender/editors/physics/ed_pointcache.c
+++ b/source/blender/editors/physics/ed_pointcache.c
@@ -31,6 +31,7 @@
#include "DNA_scene_types.h"
#include "DNA_object_force.h"
+#include "DNA_modifier_types.h"
#include "BKE_context.h"
#include "BKE_particle.h"
@@ -39,7 +40,7 @@
#include "BKE_utildefines.h"
#include "BKE_pointcache.h"
#include "BKE_global.h"
-#include "BKE_multires.h"
+#include "BKE_modifier.h"
#include "BLI_blenlib.h"
@@ -81,6 +82,7 @@ static int ptcache_bake_all_exec(bContext *C, wmOperator *op)
baker.pid = NULL;
baker.bake = RNA_boolean_get(op->ptr, "bake");
baker.render = 0;
+ baker.quick_step = 1;
baker.break_test = cache_break_test;
baker.break_data = NULL;
baker.progressbar = (void (*)(void *, int))WM_timecursor;
@@ -104,12 +106,11 @@ static int ptcache_free_bake_all_exec(bContext *C, wmOperator *op)
for(pid=pidlist.first; pid; pid=pid->next) {
pid->cache->flag &= ~PTCACHE_BAKED;
- BKE_ptcache_id_reset(scene, pid, PTCACHE_RESET_OUTDATED);
}
+
+ BLI_freelistN(&pidlist);
}
- BLI_freelistN(&pidlist);
-
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
return OPERATOR_FINISHED;
@@ -127,6 +128,8 @@ void PTCACHE_OT_bake_all(wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ RNA_def_boolean(ot->srna, "bake", 0, "Bake", "");
}
void PTCACHE_OT_free_bake_all(wmOperatorType *ot)
{
@@ -142,6 +145,112 @@ void PTCACHE_OT_free_bake_all(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
+/**************************** cloth **********************************/
+static int ptcache_bake_cloth_poll(bContext *C)
+{
+ Scene *scene= CTX_data_scene(C);
+ Object *ob= CTX_data_active_object(C);
+ ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth);
+
+ if(!scene || !ob || ob->id.lib || !clmd)
+ return 0;
+
+ return 1;
+}
+
+static int ptcache_bake_cloth_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ Object *ob= CTX_data_active_object(C);
+ ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth);
+ PTCacheID pid;
+ PTCacheBaker baker;
+
+ BKE_ptcache_id_from_cloth(&pid, ob, clmd);
+
+ baker.scene = scene;
+ baker.pid = &pid;
+ baker.bake = RNA_boolean_get(op->ptr, "bake");
+ baker.render = 0;
+ baker.quick_step = 1;
+ baker.break_test = cache_break_test;
+ baker.break_data = NULL;
+ baker.progressbar = WM_timecursor;
+ baker.progresscontext = CTX_wm_window(C);
+
+ BKE_ptcache_make_cache(&baker);
+
+ WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
+
+ return OPERATOR_FINISHED;
+}
+static int ptcache_free_bake_cloth_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ Object *ob= CTX_data_active_object(C);
+ ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth);
+ PTCacheID pid;
+
+ BKE_ptcache_id_from_cloth(&pid, ob, clmd);
+ pid.cache->flag &= ~PTCACHE_BAKED;
+
+ WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
+
+ return OPERATOR_FINISHED;
+}
+void PTCACHE_OT_cache_cloth(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Bake Cloth";
+ ot->idname= "PTCACHE_OT_cache_cloth";
+
+ /* api callbacks */
+ ot->exec= ptcache_bake_cloth_exec;
+ ot->poll= ptcache_bake_cloth_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ RNA_def_boolean(ot->srna, "bake", 0, "Bake", "");
+}
+void PTCACHE_OT_free_bake_cloth(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Free Cloth Bake";
+ ot->idname= "PTCACHE_OT_free_bake_cloth";
+
+ /* api callbacks */
+ ot->exec= ptcache_free_bake_cloth_exec;
+ ot->poll= ptcache_bake_cloth_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+static int ptcache_bake_from_cloth_cache_exec(bContext *C, wmOperator *op)
+{
+ Object *ob= CTX_data_active_object(C);
+ ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth);
+ PTCacheID pid;
+
+ BKE_ptcache_id_from_cloth(&pid, ob, clmd);
+ pid.cache->flag |= PTCACHE_BAKED;
+
+ return OPERATOR_FINISHED;
+}
+void PTCACHE_OT_bake_from_cloth_cache(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Bake From Cache";
+ ot->idname= "PTCACHE_OT_bake_from_cloth_cache";
+
+ /* api callbacks */
+ ot->exec= ptcache_bake_from_cloth_cache_exec;
+ ot->poll= ptcache_bake_cloth_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
/**************************** particles **********************************/
static int ptcache_bake_particle_system_poll(bContext *C)
{
@@ -168,6 +277,7 @@ static int ptcache_bake_particle_system_exec(bContext *C, wmOperator *op)
baker.pid = &pid;
baker.bake = RNA_boolean_get(op->ptr, "bake");
baker.render = 0;
+ baker.quick_step = 1;
baker.break_test = cache_break_test;
baker.break_data = NULL;
baker.progressbar = (void (*)(void *, int))WM_timecursor;
@@ -188,7 +298,6 @@ static int ptcache_free_bake_particle_system_exec(bContext *C, wmOperator *op)
BKE_ptcache_id_from_particles(&pid, ob, psys);
psys->pointcache->flag &= ~PTCACHE_BAKED;
- BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
@@ -256,6 +365,9 @@ void ED_operatortypes_pointcache(void)
WM_operatortype_append(PTCACHE_OT_cache_particle_system);
WM_operatortype_append(PTCACHE_OT_free_bake_particle_system);
WM_operatortype_append(PTCACHE_OT_bake_from_particles_cache);
+ WM_operatortype_append(PTCACHE_OT_cache_cloth);
+ WM_operatortype_append(PTCACHE_OT_free_bake_cloth);
+ WM_operatortype_append(PTCACHE_OT_bake_from_cloth_cache);
}
//void ED_keymap_pointcache(wmWindowManager *wm)
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index bb1f09ec44e..490ce820b30 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -4674,6 +4674,12 @@ void special_aftertrans_update(TransInfo *t)
/* pointcache refresh */
if (BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH))
ob->recalc |= OB_RECALC_DATA;
+
+ /* Needed for proper updating of "quick cached" dynamics. */
+ /* Creates troubles for moving animated objects without */
+ /* autokey though, probably needed is an anim sys override? */
+ /* Please remove if some other solution is found. -jahka */
+ DAG_object_flush_update(scene, ob, OB_RECALC_OB);
/* Set autokey if necessary */
if (!cancelled)