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:
-rw-r--r--source/blender/blenkernel/BKE_softbody.h5
-rw-r--r--source/blender/blenkernel/intern/softbody.c14
-rw-r--r--source/blender/src/buttons_object.c23
3 files changed, 31 insertions, 11 deletions
diff --git a/source/blender/blenkernel/BKE_softbody.h b/source/blender/blenkernel/BKE_softbody.h
index 3ead7445c03..15200bf46f8 100644
--- a/source/blender/blenkernel/BKE_softbody.h
+++ b/source/blender/blenkernel/BKE_softbody.h
@@ -49,5 +49,10 @@ extern void sbObjectStep(struct Object *ob, float framnr, float (*vertexCos)[
/* makes totally fresh start situation, resets time */
extern void sbObjectToSoftbody(struct Object *ob);
+/* links the softbody module to a 'test for Interrupt' function */
+/* pass NULL to unlink again */
+extern void sbSetInterruptCallBack(int (*f)(void));
+
+
#endif
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 5ab2efece66..58563104d2f 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -82,6 +82,11 @@ variables on the UI for now
#include "BIF_editdeform.h"
#include "BIF_graphics.h"
#include "PIL_time.h"
+
+/* callbacks for errors and interrupts and some goo */
+static int (*SB_localInterruptCallBack)(void) = NULL;
+
+
/* ********** soft body engine ******* */
@@ -3060,6 +3065,13 @@ static int object_has_edges(Object *ob)
}
}
+/* SB global visible functions */
+void sbSetInterruptCallBack(int (*f)(void))
+{
+ SB_localInterruptCallBack = f;
+}
+
+
/* simulates one step. framenr is in frames */
void sbObjectStep(Object *ob, float framenr, float (*vertexCos)[3], int numVerts)
{
@@ -3271,6 +3283,8 @@ void sbObjectStep(Object *ob, float framenr, float (*vertexCos)[3], int numVerts
sct=PIL_check_seconds_timer();
if (sct-sst > 0.5f) printf("%3.0f%% \r",100.0f*timedone);
}
+ if (SB_localInterruptCallBack && SB_localInterruptCallBack()) break;
+
}
/* move snapped to final position */
interpolate_exciter(ob, 2, 2);
diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c
index 8887c401ce0..d05c6138612 100644
--- a/source/blender/src/buttons_object.c
+++ b/source/blender/src/buttons_object.c
@@ -1384,11 +1384,12 @@ void softbody_bake(Object *ob)
SoftBody *sb;
ScrArea *sa;
float frameleno= G.scene->r.framelen;
- int cfrao= CFRA, sfra=100000, efra=0;
- unsigned short event=0;
- short val;
+ int cfrao= CFRA, sfra=100000, efra=0, didbreak =0;
+
G.scene->r.framelen= 1.0; // baking has to be in uncorrected time
+ sbSetInterruptCallBack(blender_test_break); // make softbody module ESC aware
+ G.afbreek=0; // init global break system
if(ob) {
sb= ob->soft;
@@ -1427,16 +1428,14 @@ void softbody_bake(Object *ob)
}
}
screen_swapbuffers();
-
- while(qtest()) {
-
- event= extern_qread(&val);
- if(event==ESCKEY) break;
+ //blender_test_break() has a granularity of 10 ms, who cares .. baking the unit cube is kinda boring
+ if (blender_test_break()){
+ didbreak = 1;
+ break;
}
- if(event==ESCKEY) break;
+
}
-
- if(event==ESCKEY) {
+ if(didbreak) {
if(ob)
sbObjectToSoftbody(ob); // free bake
else {
@@ -1452,6 +1451,8 @@ void softbody_bake(Object *ob)
/* restore */
waitcursor(0);
+ sbSetInterruptCallBack(NULL); // softbody module won't ESC
+ G.afbreek=0; // reset global break system
if(ob)
ob->softflag &= ~OB_SB_BAKEDO;