Bugfix: 3d view with scene layer lock were not updated when the
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 26 Oct 2009 12:42:25 +0000 (12:42 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 26 Oct 2009 12:42:25 +0000 (12:42 +0000)
scene layer or other 3d view layers were changed.

source/blender/editors/include/ED_view3d.h
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_outliner/space_outliner.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/makesrna/intern/rna_scene.c
source/blender/windowmanager/WM_types.h

index 2752402fb6655ae5d39167b769a2c872dfe8b3ba..be2822d8c49e1d9d726f5d09d1ed97d7725b1d0d 100644 (file)
@@ -43,6 +43,7 @@ struct EditFace;
 struct ImBuf;
 struct Scene;
 struct bContext;
+struct Main;
 
 /* for derivedmesh drawing callbacks, for view3d_select, .... */
 typedef struct ViewContext {
@@ -136,5 +137,7 @@ struct RegionView3D *ED_view3d_context_rv3d(struct bContext *C);
 
 void ED_view3d_init_mats_rv3d(struct Object *ob, struct RegionView3D *rv3d);
 
+void ED_view3d_scene_layers_update(struct Main *bmain, struct Scene *scene);
+
 #endif /* ED_VIEW3D_H */
 
index 47806ba7937cf77fa50d2e41f91e338ee3d28928..f05c652c39d1bdafc800ad84a8b2328cf1b1d7ad 100644 (file)
@@ -252,6 +252,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn)
                                case ND_MODE:
                                case ND_RENDER_OPTIONS:
                                case ND_KEYINGSET:
+                               case ND_LAYER:
                                        ED_area_tag_redraw(sa);
                                        break;
                                        
index 826a313217a62c4fc4a720f57c9af4db4c32d2e0..93fdc96e9f7523503910b1f5f9f7490b80cb3e29 100644 (file)
@@ -121,6 +121,7 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn)
                                case ND_KEYINGSET:
                                case ND_FRAME:
                                case ND_RENDER_OPTIONS:
+                               case ND_LAYER:
                                        ED_region_tag_redraw(ar);
                                        break;
                        }
index 695d86bb51b102ac598440755047b38451705d91..ae0c73e71cc2967f4b6e158bff7b06a1227e5fff 100644 (file)
@@ -445,6 +445,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
                                case ND_FRAME:
                                case ND_OB_ACTIVE:
                                case ND_OB_SELECT:
+                               case ND_LAYER:
                                        ED_region_tag_redraw(ar);
                                        break;
                                case ND_MODE:
@@ -551,6 +552,7 @@ static void view3d_header_area_listener(ARegion *ar, wmNotifier *wmn)
                                case ND_OB_ACTIVE:
                                case ND_OB_SELECT:
                                case ND_MODE:
+                               case ND_LAYER:
                                        ED_region_tag_redraw(ar);
                                        break;
                        }
@@ -598,6 +600,7 @@ static void view3d_buttons_area_listener(ARegion *ar, wmNotifier *wmn)
                                case ND_OB_ACTIVE:
                                case ND_OB_SELECT:
                                case ND_MODE:
+                               case ND_LAYER:
                                        ED_region_tag_redraw(ar);
                                        break;
                        }
index 8a232b71c369302bdff251baff633059ab8e74c2..1e11699556ac83f01c16d956cda22fe7a3316902 100644 (file)
@@ -134,7 +134,6 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event);
 #define B_VIEWBUT      104
 #define B_PERSP                105
 #define B_VIEWRENDER   106
-#define B_STARTGAME    107
 #define B_MODESELECT 108
 #define B_AROUND       109
 #define B_SEL_VERT     110
@@ -169,9 +168,50 @@ static RegionView3D *wm_region_view3d(const bContext *C)
        return NULL;
 }
 
+static void copy_view3d_lock_space(View3D *vd, Scene *scene)
+{
+       int bit;
+
+       if(vd->scenelock && vd->localvd==NULL) {
+               vd->lay= scene->lay;
+               vd->camera= scene->camera;
+               
+               if(vd->camera==0 && vd->persp==V3D_CAMOB)
+                       vd->persp= V3D_PERSP;
+               
+               if((vd->lay & vd->layact) == 0) {
+                       for(bit= 0; bit<32; bit++) {
+                               if(vd->lay & (1<<bit)) {
+                                       vd->layact= 1<<bit;
+                                       break;
+                               }
+                       }
+               }
+       }
+}
+
+void ED_view3d_scene_layers_update(Main *bmain, Scene *scene)
+{
+       bScreen *sc;
+       ScrArea *sa;
+       SpaceLink *sl;
+       
+       /* from scene copy to the other views */
+       for(sc=bmain->screen.first; sc; sc=sc->id.next) {
+               if(sc->scene!=scene)
+                       continue;
+
+               for(sa=sc->areabase.first; sa; sa=sa->next)
+                       for(sl=sa->spacedata.first; sl; sl=sl->next)
+                               if(sl->spacetype==SPACE_VIEW3D)
+                                       copy_view3d_lock_space((View3D*)sl, scene);
+       }
+}
+
 // XXX quickly ported across
 static void handle_view3d_lock(bContext *C) 
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        ScrArea *sa= CTX_wm_area(C);
        View3D *v3d= CTX_wm_view3d(C);
@@ -181,9 +221,13 @@ static void handle_view3d_lock(bContext *C)
                        /* copy to scene */
                        scene->lay= v3d->lay;
                        scene->camera= v3d->camera;
+
+                       /* not through notifiery, listener don't have context
+                          and non-open screens or spaces need to be updated too */
+                       ED_view3d_scene_layers_update(bmain, scene);
                        
                        /* notifiers for scene update */
-                       WM_event_add_notifier(C, NC_SCENE, scene);
+                       WM_event_add_notifier(C, NC_SCENE|ND_LAYER, scene);
                }
        }
 }
@@ -1713,21 +1757,11 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event)
                }
                break;
                
-       case B_VIEWBUT:
-       
-
-       case B_PERSP:
-       
-               
-               break;
        case B_VIEWRENDER:
                if (sa->spacetype==SPACE_VIEW3D) {
 // XXX                 BIF_do_ogl_render(v3d, shift);
                }
                break;
-       case B_STARTGAME:
-// XXX         start_game();
-               break;
        case B_MODESELECT:
                WM_operator_properties_create(&props_ptr, "OBJECT_OT_mode_set");
                RNA_enum_set(&props_ptr, "mode", v3d->modeselect);
index 3ab147701dfa2e310ef2feb89f999437eb97508f..899d600abcd20d3de9faefcc544d73b59d447229 100644 (file)
@@ -76,14 +76,16 @@ EnumPropertyItem proportional_editing_items[] = {
 
 #include "BKE_context.h"
 #include "BKE_global.h"
-#include "BKE_scene.h"
+#include "BKE_main.h"
 #include "BKE_node.h"
 #include "BKE_pointcache.h"
+#include "BKE_scene.h"
 
 #include "BLI_threads.h"
 
 #include "ED_info.h"
 #include "ED_node.h"
+#include "ED_view3d.h"
 
 #include "RE_pipeline.h"
 
@@ -160,6 +162,14 @@ static void rna_Scene_layer_set(PointerRNA *ptr, const int *values)
        scene->lay= layer_set(scene->lay, values);
 }
 
+static void rna_Scene_layer_update(bContext *C, PointerRNA *ptr)
+{
+       Main *bmain= CTX_data_main(C);
+       Scene *scene= (Scene*)ptr->data;
+
+       ED_view3d_scene_layers_update(bmain, scene);
+}
+
 static void rna_Scene_start_frame_set(PointerRNA *ptr, int value)
 {
        Scene *data= (Scene*)ptr->data;
@@ -2219,9 +2229,9 @@ void RNA_def_scene(BlenderRNA *brna)
        prop= RNA_def_property(srna, "visible_layers", PROP_BOOLEAN, PROP_LAYER_MEMBER);
        RNA_def_property_boolean_sdna(prop, NULL, "lay", 1);
        RNA_def_property_array(prop, 20);
-       RNA_def_property_ui_text(prop, "Visible Layers", "Layers visible when rendering the scene.");
        RNA_def_property_boolean_funcs(prop, NULL, "rna_Scene_layer_set");
-       
+       RNA_def_property_ui_text(prop, "Visible Layers", "Layers visible when rendering the scene.");
+       RNA_def_property_update(prop, NC_SCENE|ND_LAYER, "rna_Scene_layer_update");
        
        /* Frame Range Stuff */
        prop= RNA_def_property(srna, "current_frame", PROP_INT, PROP_TIME);
index d326fadeba4c57ff028b94b49ae8a1672b8909c0..3d31341c66a3e4157673c9f88d9efda5c4e86313 100644 (file)
@@ -165,6 +165,7 @@ typedef struct wmNotifier {
 #define ND_COMPO_RESULT                (11<<16)
 #define ND_KEYINGSET           (12<<16)
 #define ND_SCENEDELETE         (13<<16)
+#define ND_LAYER                       (14<<16)
 
        /* NC_OBJECT Object */
 #define        ND_TRANSFORM            (16<<16)