2.5
Anim playback part 1 (needs more test, will do after commit) - added the update_for_new_frame() back - proper evaluation of time change notifier in WM level - fixed redraw flushes for menus while animation plays.
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
#include "DNA_texture_types.h"
|
||||
#include "DNA_view3d_types.h"
|
||||
#include "DNA_windowmanager_types.h"
|
||||
|
||||
@@ -42,6 +43,10 @@
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_depsgraph.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_node.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
@@ -50,24 +55,66 @@
|
||||
|
||||
/* ***************** depsgraph calls and anim updates ************* */
|
||||
|
||||
static unsigned int screen_view3d_layers(bScreen *screen)
|
||||
{
|
||||
if(screen) {
|
||||
unsigned int layer= screen->scene->lay; /* as minimum this */
|
||||
ScrArea *sa;
|
||||
|
||||
/* get all used view3d layers */
|
||||
for(sa= screen->areabase.first; sa; sa= sa->next) {
|
||||
if(sa->spacetype==SPACE_VIEW3D)
|
||||
layer |= ((View3D *)sa->spacedata.first)->lay;
|
||||
}
|
||||
return layer;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* generic update flush, reads from context Screen (layers) and scene */
|
||||
/* this is for compliancy, later it can do all windows etc */
|
||||
void ED_anim_dag_flush_update(bContext *C)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
bScreen *screen= CTX_wm_screen(C);
|
||||
int layer= scene->lay; /* as minimum this */
|
||||
|
||||
if(screen) {
|
||||
ScrArea *sa;
|
||||
|
||||
/* get all used view3d layers */
|
||||
for(sa= screen->areabase.first; sa; sa= sa->next) {
|
||||
if(sa->spacetype==SPACE_VIEW3D)
|
||||
layer |= ((View3D *)sa->spacedata.first)->lay;
|
||||
}
|
||||
}
|
||||
|
||||
DAG_scene_flush_update(scene, layer, 0);
|
||||
DAG_scene_flush_update(scene, screen_view3d_layers(screen), 0);
|
||||
}
|
||||
|
||||
|
||||
/* results in fully updated anim system */
|
||||
/* in future sound should be on WM level, only 1 sound can play! */
|
||||
void ED_update_for_newframe(bContext *C, int mute)
|
||||
{
|
||||
bScreen *screen= CTX_wm_screen(C);
|
||||
Scene *scene= screen->scene;
|
||||
|
||||
//extern void audiostream_scrub(unsigned int frame); /* seqaudio.c */
|
||||
|
||||
/* this function applies the changes too */
|
||||
/* XXX future: do all windows */
|
||||
scene_update_for_newframe(scene, screen_view3d_layers(screen)); /* BKE_scene.h */
|
||||
|
||||
//if ( (CFRA>1) && (!mute) && (G.scene->audio.flag & AUDIO_SCRUB))
|
||||
// audiostream_scrub( CFRA );
|
||||
|
||||
/* 3d window, preview */
|
||||
//BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
|
||||
|
||||
/* all movie/sequence images */
|
||||
//BIF_image_update_frame();
|
||||
|
||||
/* composite */
|
||||
if(scene->use_nodes && scene->nodetree)
|
||||
ntreeCompositTagAnimated(scene->nodetree);
|
||||
|
||||
/* update animated texture nodes */
|
||||
{
|
||||
Tex *tex;
|
||||
for(tex= G.main->tex.first; tex; tex= tex->id.next)
|
||||
if( tex->use_nodes && tex->nodetree ) {
|
||||
ntreeTexTagAnimated( tex->nodetree );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -286,6 +286,7 @@ void ANIM_nla_mapping_apply(struct Object *ob, struct Ipo *ipo, short restore, s
|
||||
|
||||
/* generic update flush, reads from Context screen (layers) and scene */
|
||||
void ED_anim_dag_flush_update(struct bContext *C);
|
||||
void ED_update_for_newframe(struct bContext *C, int mute);
|
||||
|
||||
/* ************************************************* */
|
||||
/* OPERATORS */
|
||||
|
||||
@@ -230,9 +230,19 @@ static void buttons_header_area_draw(const bContext *C, ARegion *ar)
|
||||
UI_view2d_view_restore(C);
|
||||
}
|
||||
|
||||
static void buttons_main_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
/* reused! */
|
||||
static void buttons_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
{
|
||||
/* context changes */
|
||||
switch(wmn->category) {
|
||||
case NC_SCENE:
|
||||
switch(wmn->data) {
|
||||
case ND_FRAME:
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* only called once, from space/spacetypes.c */
|
||||
@@ -255,7 +265,7 @@ void ED_spacetype_buttons(void)
|
||||
art->regionid = RGN_TYPE_WINDOW;
|
||||
art->init= buttons_main_area_init;
|
||||
art->draw= buttons_main_area_draw;
|
||||
art->listener= buttons_main_area_listener;
|
||||
art->listener= buttons_area_listener;
|
||||
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
|
||||
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
@@ -268,7 +278,7 @@ void ED_spacetype_buttons(void)
|
||||
|
||||
art->init= buttons_header_area_init;
|
||||
art->draw= buttons_header_area_draw;
|
||||
|
||||
art->listener= buttons_area_listener;
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
/* regions: channels */
|
||||
|
||||
@@ -203,6 +203,17 @@ static void time_header_area_draw(const bContext *C, ARegion *ar)
|
||||
UI_view2d_view_restore(C);
|
||||
}
|
||||
|
||||
static void time_header_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
{
|
||||
/* context changes */
|
||||
switch(wmn->category) {
|
||||
|
||||
case NC_SCENE:
|
||||
if(wmn->data==ND_FRAME)
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* ******************** default callbacks for time space ***************** */
|
||||
|
||||
@@ -314,6 +325,7 @@ void ED_spacetype_time(void)
|
||||
|
||||
art->init= time_header_area_init;
|
||||
art->draw= time_header_area_draw;
|
||||
art->listener= time_header_area_listener;
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
BKE_spacetype_register(st);
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include "BIF_gl.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
@@ -203,6 +204,19 @@ static void view3d_main_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
|
||||
}
|
||||
|
||||
static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
{
|
||||
/* context changes */
|
||||
switch(wmn->category) {
|
||||
case NC_SCENE:
|
||||
switch(wmn->data) {
|
||||
case ND_FRAME:
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* add handlers, stuff you only do once or on area/region changes */
|
||||
static void view3d_header_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
@@ -295,7 +309,7 @@ void ED_spacetype_view3d(void)
|
||||
art->regionid = RGN_TYPE_WINDOW;
|
||||
art->draw= view3d_main_area_draw;
|
||||
art->init= view3d_main_area_init;
|
||||
|
||||
art->listener= view3d_main_area_listener;
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
/* regions: header */
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
|
||||
#include "ED_screen.h"
|
||||
#include "ED_space_api.h"
|
||||
#include "ED_anim_api.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
@@ -127,6 +128,25 @@ void wm_event_do_notifiers(bContext *C)
|
||||
{
|
||||
wmWindowManager *wm= CTX_wm_manager(C);
|
||||
wmNotifier *note;
|
||||
wmWindow *win;
|
||||
|
||||
/* cache & catch WM level notifiers, such as frame change */
|
||||
/* XXX todo, multiwindow scenes */
|
||||
for(win= wm->windows.first; win; win= win->next) {
|
||||
int do_anim= 0;
|
||||
|
||||
for(note= wm->queue.first; note; note= note->next) {
|
||||
if(note->window==win)
|
||||
if(note->category==NC_SCENE)
|
||||
if(note->data==ND_FRAME)
|
||||
do_anim= 1;
|
||||
}
|
||||
if(do_anim) {
|
||||
/* depsgraph gets called, might send more notifiers */
|
||||
CTX_wm_window_set(C, win);
|
||||
ED_update_for_newframe(C, 1);
|
||||
}
|
||||
}
|
||||
|
||||
while( (note=wm_notifier_next(wm)) ) {
|
||||
wmWindow *win;
|
||||
@@ -158,15 +178,11 @@ void wm_event_do_notifiers(bContext *C)
|
||||
}
|
||||
}
|
||||
|
||||
/* mark regions to redraw if overlapped with rect */
|
||||
static void wm_flush_regions(bScreen *screen, rcti *dirty)
|
||||
/* mark area-regions to redraw if overlapped with rect */
|
||||
static void wm_flush_regions_down(bScreen *screen, rcti *dirty)
|
||||
{
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
|
||||
for(ar= screen->regionbase.first; ar; ar= ar->next)
|
||||
if(BLI_isect_rcti(dirty, &ar->winrct, NULL))
|
||||
ar->do_draw= 1;
|
||||
|
||||
for(sa= screen->areabase.first; sa; sa= sa->next)
|
||||
for(ar= sa->regionbase.first; ar; ar= ar->next)
|
||||
@@ -174,18 +190,42 @@ static void wm_flush_regions(bScreen *screen, rcti *dirty)
|
||||
ar->do_draw= 1;
|
||||
}
|
||||
|
||||
/* mark menu-regions to redraw if overlapped with rect */
|
||||
static void wm_flush_regions_up(bScreen *screen, rcti *dirty)
|
||||
{
|
||||
ARegion *ar;
|
||||
|
||||
for(ar= screen->regionbase.first; ar; ar= ar->next)
|
||||
if(BLI_isect_rcti(dirty, &ar->winrct, NULL))
|
||||
ar->do_draw= 1;
|
||||
}
|
||||
|
||||
|
||||
/* all the overlay management, menus, actionzones, region tabs, etc */
|
||||
static void wm_flush_draw_update(bContext *C)
|
||||
{
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
bScreen *screen= CTX_wm_screen(C);
|
||||
|
||||
/* flush redraws of screen regions (menus) down */
|
||||
for(ar= screen->regionbase.last; ar; ar= ar->prev) {
|
||||
if(ar->swinid && ar->do_draw) {
|
||||
wm_flush_regions(screen, &ar->winrct);
|
||||
}
|
||||
}
|
||||
if(screen->regionbase.first) {
|
||||
/* flush redraws of area-regions up to menus */
|
||||
for(sa= screen->areabase.first; sa; sa= sa->next)
|
||||
for(ar= sa->regionbase.first; ar; ar= ar->next)
|
||||
if(ar->swinid && ar->do_draw)
|
||||
wm_flush_regions_up(screen, &ar->winrct);
|
||||
|
||||
/* flush overlapping menus */
|
||||
for(ar= screen->regionbase.last; ar; ar= ar->prev)
|
||||
if(ar->swinid && ar->do_draw)
|
||||
wm_flush_regions_up(screen, &ar->winrct);
|
||||
|
||||
|
||||
/* flush redraws of menus down to areas */
|
||||
for(ar= screen->regionbase.last; ar; ar= ar->prev)
|
||||
if(ar->swinid && ar->do_draw)
|
||||
wm_flush_regions_down(screen, &ar->winrct);
|
||||
}
|
||||
|
||||
/* sets redraws for Azones, future region tabs, etc */
|
||||
ED_area_overdraw_flush(C);
|
||||
|
||||
Reference in New Issue
Block a user