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:
authorBenoit Bolsee <benoit.bolsee@online.be>2018-10-11 15:06:34 +0300
committerBenoit Bolsee <benoit.bolsee@online.be>2018-10-11 15:06:34 +0300
commitad21793c69429dea4489603a77b95ac733966bcc (patch)
tree6f851c7467fca916394e6fb3edf2e92112220bdd
parentb389f1e9572b9ee606c2e4ae347f5520f2d38a9c (diff)
Interactive mode: new scene.flag SCE_INTERACTIVE to update the depsgraph without frame change but running physics.
Interactive button added on time line.
m---------release/scripts/addons0
m---------release/scripts/addons_contrib0
-rw-r--r--release/scripts/startup/bl_ui/space_time.py2
-rw-r--r--source/blender/blenkernel/intern/rigidbody.c18
-rw-r--r--source/blender/editors/screen/screen_ops.c6
-rw-r--r--source/blender/makesdna/DNA_scene_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_scene.c7
7 files changed, 33 insertions, 1 deletions
diff --git a/release/scripts/addons b/release/scripts/addons
-Subproject 5f7fba0565a7c9ae93eae31a08fc9bbbd16d333
+Subproject 0923bdf725b088ba584e6b1246f1ad986be436b
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
-Subproject fecc0db5600405a0c14c70120ae279222861ef8
+Subproject 15b25a42783d1e516b5298d70b582fae2559ae1
diff --git a/release/scripts/startup/bl_ui/space_time.py b/release/scripts/startup/bl_ui/space_time.py
index 10cd2f6d47b..d9b0e2e6298 100644
--- a/release/scripts/startup/bl_ui/space_time.py
+++ b/release/scripts/startup/bl_ui/space_time.py
@@ -38,6 +38,8 @@ class TIME_HT_editor_buttons(Header):
layout.separator_spacer()
+ layout.prop(scene, "use_interactive_mode", text="", icon='GAME', toggle=True)
+
layout.prop(toolsettings, "use_keyframe_insert_auto", text="", toggle=True)
row = layout.row(align=True)
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 95b558f5b43..737359aae93 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -1661,6 +1661,24 @@ void BKE_rigidbody_do_simulation(Depsgraph *depsgraph, Scene *scene, float ctime
PTCacheID pid;
int startframe, endframe;
+ if (scene->flag & SCE_INTERACTIVE) {
+ /* No caching when in interactive mode */
+ if (rbw->shared->physics_world == NULL)
+ return;
+ else if (rbw->objects == NULL)
+ rigidbody_update_ob_array(rbw);
+
+ rigidbody_update_simulation(depsgraph, scene, rbw, false);
+
+ /* TODO: get the actual time difference from previous step so that the physics simulation is real time */
+ timestep = 1.0f / (float)FPS * rbw->time_scale;
+ /* step simulation by the requested timestep, steps per second are adjusted to take time scale into account */
+ RB_dworld_step_simulation(rbw->shared->physics_world, timestep, INT_MAX, 1.0f / (float)rbw->steps_per_second * min_ff(rbw->time_scale, 1.0f));
+
+ rigidbody_update_simulation_post_step(depsgraph, rbw);
+ return;
+ }
+
BKE_ptcache_id_from_rigidbody(&pid, NULL, rbw);
BKE_ptcache_id_time(&pid, scene, ctime, &startframe, &endframe, NULL);
cache = rbw->shared->pointcache;
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 9ce0956aa66..fad9990409e 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -3882,6 +3882,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
ScrArea *sa;
int sync;
float time;
+ int pfra = scene->r.cfra;
/* sync, don't sync, or follow scene setting */
if (sad->flag & ANIMPLAY_FLAG_SYNC) sync = 1;
@@ -3939,7 +3940,10 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
/* reset 'jumped' flag before checking if we need to jump... */
sad->flag &= ~ANIMPLAY_FLAG_JUMPED;
- if (sad->flag & ANIMPLAY_FLAG_REVERSE) {
+ if (scene->flag & SCE_INTERACTIVE) {
+ /* TODO: remember what was the frame increment so that it can be used in physics simulation to stick to real time */
+ scene->r.cfra = pfra;
+ } else if (sad->flag & ANIMPLAY_FLAG_REVERSE) {
/* jump back to end? */
if (PRVRANGEON) {
if (scene->r.cfra < scene->r.psfra) {
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 15e8f950686..0ed0ffcdc15 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1936,6 +1936,7 @@ typedef enum eVGroupSelect {
#define SCE_NLA_EDIT_ON (1<<2)
#define SCE_FRAME_DROP (1<<3)
#define SCE_KEYS_NO_SELONLY (1<<4)
+#define SCE_INTERACTIVE (1<<5)
/* return flag BKE_scene_base_iter_next functions */
/* #define F_ERROR -1 */ /* UNUSED */
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 11d56206d6e..c3d5b8adf13 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -6194,6 +6194,13 @@ void RNA_def_scene(BlenderRNA *brna)
"(in timeline and when jumping between keyframes)");
RNA_def_property_update(prop, NC_SCENE | ND_FRAME, NULL);
+ /* Timeline / Interactive mode */
+ prop = RNA_def_property(srna, "use_interactive_mode", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_INTERACTIVE);
+ RNA_def_property_ui_text(prop, "Run interactive mode for physics",
+ "The scene frame is no longer incrementing (and thus animation is stopped) but the physics engine still executes");
+ RNA_def_property_update(prop, NC_SCENE | ND_FRAME, NULL);
+
/* Stamp */
prop = RNA_def_property(srna, "use_stamp_note", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "r.stamp_udata");