forked from bartvdbraak/blender
python scriptlink for ObjectUpdate and ObDataUpdate, Redraw events are not practice in many real world cases, this can give more specific updates.
Discussed with Caedes, Brecht and Ton, can rework if needed.
This commit is contained in:
parent
c5c53b0f2d
commit
f33faa8f5f
@ -2163,6 +2163,7 @@ void object_handle_update(Object *ob)
|
||||
}
|
||||
else
|
||||
where_is_object(ob);
|
||||
if (G.f & G_DOSCRIPTLINKS) BPY_do_pyscript((ID *)ob, SCRIPT_OBJECTUPDATE);
|
||||
}
|
||||
|
||||
if(ob->recalc & OB_RECALC_DATA) {
|
||||
@ -2228,6 +2229,7 @@ void object_handle_update(Object *ob)
|
||||
psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated;
|
||||
}
|
||||
}
|
||||
if (G.f & G_DOSCRIPTLINKS) BPY_do_pyscript((ID *)ob, SCRIPT_OBDATAUPDATE);
|
||||
}
|
||||
|
||||
/* the no-group proxy case, we call update */
|
||||
|
@ -61,6 +61,9 @@ typedef struct ScriptLink {
|
||||
* RENDER script links for clean-up actions */
|
||||
#define SCRIPT_POSTRENDER 32
|
||||
|
||||
#define SCRIPT_OBJECTUPDATE 64
|
||||
#define SCRIPT_OBDATAUPDATE 128
|
||||
|
||||
/* **************** SPACE HANDLERS ********************* */
|
||||
/* these are special scriptlinks that can be assigned to
|
||||
* a given space in a given ScrArea to:
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: gen_utils.c 11932 2007-09-03 17:28:50Z stiv $
|
||||
* $Id$
|
||||
*
|
||||
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
||||
*
|
||||
@ -238,6 +238,10 @@ char *event_to_name( short event )
|
||||
switch ( event ) {
|
||||
case SCRIPT_FRAMECHANGED:
|
||||
return "FrameChanged";
|
||||
case SCRIPT_OBJECTUPDATE:
|
||||
return "ObjectUpdate";
|
||||
case SCRIPT_OBDATAUPDATE:
|
||||
return "ObDataUpdate";
|
||||
case SCRIPT_ONLOAD:
|
||||
return "OnLoad";
|
||||
case SCRIPT_ONSAVE:
|
||||
@ -406,6 +410,10 @@ PyObject *EXPP_getScriptLinks( ScriptLink * slink, PyObject * value,
|
||||
|
||||
if( !strcmp( eventname, "FrameChanged" ) )
|
||||
event = SCRIPT_FRAMECHANGED;
|
||||
else if( !strcmp( eventname, "ObjectUpdate" ) )
|
||||
event = SCRIPT_OBJECTUPDATE;
|
||||
else if( !strcmp( eventname, "ObDataUpdate" ) )
|
||||
event = SCRIPT_OBDATAUPDATE;
|
||||
else if( !strcmp( eventname, "Redraw" ) )
|
||||
event = SCRIPT_REDRAW;
|
||||
else if( !strcmp( eventname, "Render" ) )
|
||||
@ -562,6 +570,10 @@ PyObject *EXPP_addScriptLink(ScriptLink *slink, PyObject *args, int is_scene)
|
||||
|
||||
if( !strcmp( eventname, "FrameChanged" ) )
|
||||
event = SCRIPT_FRAMECHANGED;
|
||||
else if( !strcmp( eventname, "ObjectUpdate" ) )
|
||||
event = SCRIPT_OBJECTUPDATE;
|
||||
else if( !strcmp( eventname, "ObDataUpdate" ) )
|
||||
event = SCRIPT_OBDATAUPDATE;
|
||||
else if( !strcmp( eventname, "Redraw" ) )
|
||||
event = SCRIPT_REDRAW;
|
||||
else if( !strcmp( eventname, "Render" ) )
|
||||
|
@ -268,7 +268,7 @@ void do_scriptbuts(unsigned short event)
|
||||
allqueue(REDRAWOOPS, 0);
|
||||
}
|
||||
|
||||
void draw_scriptlink(uiBlock *block, ScriptLink *script, int sx, int sy, int scene)
|
||||
void draw_scriptlink(uiBlock *block, ScriptLink *script, int sx, int sy, int idcode)
|
||||
{
|
||||
char str[256];
|
||||
|
||||
@ -276,10 +276,13 @@ void draw_scriptlink(uiBlock *block, ScriptLink *script, int sx, int sy, int sce
|
||||
strcpy(str, "FrameChanged%x 1|");
|
||||
strcat(str, "Redraw%x 4|");
|
||||
strcat(str, "Render%x 16|");
|
||||
if (scene) {
|
||||
if (idcode==ID_SCE) {
|
||||
strcat(str, "OnLoad%x 2|");
|
||||
strcat(str, "OnSave%x 8");
|
||||
}
|
||||
} else {
|
||||
strcat(str, "ObjectUpdate%x 64|");
|
||||
strcat(str, "ObDataUpdate%x 128");
|
||||
}
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefButS(block, MENU, 1, str, (short)sx, (short)sy, 140, 19, &script->flag[script->actscript-1], 0, 0, 0, 0, "Script links for this event");
|
||||
|
||||
@ -291,7 +294,7 @@ void draw_scriptlink(uiBlock *block, ScriptLink *script, int sx, int sy, int sce
|
||||
|
||||
uiDefButS(block, NUM, REDRAWBUTSSCRIPT, str, (short)(sx+140), (short)sy-20,60,19, &script->actscript, 1, script->totscript, 0, 0, "Total / Active Script link (LeftMouse + Drag to change)");
|
||||
|
||||
if (scene) {
|
||||
if (idcode==ID_SCE) {
|
||||
|
||||
if (script->totscript<32767)
|
||||
uiDefBut(block, BUT, B_SSCRIPT_ADD, "New", (short)(sx+240), (short)sy-20, 40, 19, 0, 0, 0, 0, 0, "Add a new Script link");
|
||||
|
Loading…
Reference in New Issue
Block a user