forked from bartvdbraak/blender
having a nice break/esc behavior on bake
other occasions like ALT_A needs that too
This commit is contained in:
parent
c57d5bca73
commit
731e7e3915
@ -49,5 +49,10 @@ extern void sbObjectStep(struct Object *ob, float framnr, float (*vertexCos)[
|
|||||||
/* makes totally fresh start situation, resets time */
|
/* makes totally fresh start situation, resets time */
|
||||||
extern void sbObjectToSoftbody(struct Object *ob);
|
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
|
#endif
|
||||||
|
|
||||||
|
@ -82,6 +82,11 @@ variables on the UI for now
|
|||||||
#include "BIF_editdeform.h"
|
#include "BIF_editdeform.h"
|
||||||
#include "BIF_graphics.h"
|
#include "BIF_graphics.h"
|
||||||
#include "PIL_time.h"
|
#include "PIL_time.h"
|
||||||
|
|
||||||
|
/* callbacks for errors and interrupts and some goo */
|
||||||
|
static int (*SB_localInterruptCallBack)(void) = NULL;
|
||||||
|
|
||||||
|
|
||||||
/* ********** soft body engine ******* */
|
/* ********** 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 */
|
/* simulates one step. framenr is in frames */
|
||||||
void sbObjectStep(Object *ob, float framenr, float (*vertexCos)[3], int numVerts)
|
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();
|
sct=PIL_check_seconds_timer();
|
||||||
if (sct-sst > 0.5f) printf("%3.0f%% \r",100.0f*timedone);
|
if (sct-sst > 0.5f) printf("%3.0f%% \r",100.0f*timedone);
|
||||||
}
|
}
|
||||||
|
if (SB_localInterruptCallBack && SB_localInterruptCallBack()) break;
|
||||||
|
|
||||||
}
|
}
|
||||||
/* move snapped to final position */
|
/* move snapped to final position */
|
||||||
interpolate_exciter(ob, 2, 2);
|
interpolate_exciter(ob, 2, 2);
|
||||||
|
@ -1384,11 +1384,12 @@ void softbody_bake(Object *ob)
|
|||||||
SoftBody *sb;
|
SoftBody *sb;
|
||||||
ScrArea *sa;
|
ScrArea *sa;
|
||||||
float frameleno= G.scene->r.framelen;
|
float frameleno= G.scene->r.framelen;
|
||||||
int cfrao= CFRA, sfra=100000, efra=0;
|
int cfrao= CFRA, sfra=100000, efra=0, didbreak =0;
|
||||||
unsigned short event=0;
|
|
||||||
short val;
|
|
||||||
|
|
||||||
G.scene->r.framelen= 1.0; // baking has to be in uncorrected time
|
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) {
|
if(ob) {
|
||||||
sb= ob->soft;
|
sb= ob->soft;
|
||||||
@ -1427,16 +1428,14 @@ void softbody_bake(Object *ob)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
screen_swapbuffers();
|
screen_swapbuffers();
|
||||||
|
//blender_test_break() has a granularity of 10 ms, who cares .. baking the unit cube is kinda boring
|
||||||
while(qtest()) {
|
if (blender_test_break()){
|
||||||
|
didbreak = 1;
|
||||||
event= extern_qread(&val);
|
break;
|
||||||
if(event==ESCKEY) break;
|
|
||||||
}
|
}
|
||||||
if(event==ESCKEY) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(event==ESCKEY) {
|
}
|
||||||
|
if(didbreak) {
|
||||||
if(ob)
|
if(ob)
|
||||||
sbObjectToSoftbody(ob); // free bake
|
sbObjectToSoftbody(ob); // free bake
|
||||||
else {
|
else {
|
||||||
@ -1452,6 +1451,8 @@ void softbody_bake(Object *ob)
|
|||||||
|
|
||||||
/* restore */
|
/* restore */
|
||||||
waitcursor(0);
|
waitcursor(0);
|
||||||
|
sbSetInterruptCallBack(NULL); // softbody module won't ESC
|
||||||
|
G.afbreek=0; // reset global break system
|
||||||
|
|
||||||
if(ob)
|
if(ob)
|
||||||
ob->softflag &= ~OB_SB_BAKEDO;
|
ob->softflag &= ~OB_SB_BAKEDO;
|
||||||
|
Loading…
Reference in New Issue
Block a user