Fix [#21145] Preferences: Solid OpenGL lights viewport update
authorMatt Ebb <matt@mke3.net>
Tue, 9 Mar 2010 06:20:08 +0000 (06:20 +0000)
committerMatt Ebb <matt@mke3.net>
Tue, 9 Mar 2010 06:20:08 +0000 (06:20 +0000)
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/makesdna/DNA_view3d_types.h
source/blender/makesrna/intern/rna_userdef.c
source/blender/windowmanager/WM_types.h

index e9f118fb47a8fcefa6bb49593bf26aa7c12bf596..f726b771fb32d84c6f0a8100873147af4a798655 100644 (file)
@@ -57,6 +57,8 @@
 
 #include "BIF_gl.h"
 
+#include "GPU_draw.h"
+
 #include "WM_api.h"
 #include "WM_types.h"
 
@@ -602,8 +604,13 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
                        ED_region_tag_redraw(ar);
                        break;
                case NC_SPACE:
-                       if(wmn->data == ND_SPACE_VIEW3D)
+                       if(wmn->data == ND_SPACE_VIEW3D) {
+                               if (wmn->subtype == NS_VIEW3D_GPU) {
+                                       RegionView3D *rv3d= ar->regiondata;
+                                       rv3d->rflag |= RV3D_GPULIGHT_UPDATE;
+                               }
                                ED_region_tag_redraw(ar);
+                       }
                        break;
                case NC_ID:
                        if(wmn->action == NA_RENAME)
index 42416c2d8ebc8c7adcf617c93ebb1a56e18dc6bf..c5e0f096c049c8a33e9495e6e513a7aa9758fd40 100644 (file)
@@ -2188,6 +2188,12 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
        /* shadow buffers, before we setup matrices */
        if(draw_glsl_material(scene, NULL, v3d, v3d->drawtype))
                gpu_update_lamps_shadows(scene, v3d);
+       
+       /* reset default OpenGL lights if needed (i.e. after preferences have been altered) */
+       if (rv3d->rflag & RV3D_GPULIGHT_UPDATE) {
+               rv3d->rflag &= ~RV3D_GPULIGHT_UPDATE;
+               GPU_default_lights();
+       }
 
        /* clear background */
        UI_GetThemeColor3fv(TH_BACK, col);
index 123aab2d9e0ebb5721a9ec462c711dbb864637a0..12849d02d97534dfc7451bf4050ee940c32835c7 100644 (file)
@@ -229,6 +229,7 @@ typedef struct View3D {
 #define RV3D_FLYMODE                           2
 #define RV3D_CLIPPING                          4
 #define RV3D_NAVIGATING                                8
+#define RV3D_GPULIGHT_UPDATE           16
 
 /* RegionView3d->viewlock */
 #define RV3D_LOCKED                    1
index 2b4a8aad255b12d29867415b6572fab0c10ffcad..7fd15e0e136048fc75212051a6a58510496b2d21 100644 (file)
@@ -201,12 +201,9 @@ static void rna_UserDef_weight_color_update(Main *bmain, Scene *scene, PointerRN
        rna_userdef_update(bmain, scene, ptr);
 }
 
-// XXX - todo, this is not accessible from here and it only works when the userprefs are in the same window.
-// extern int GPU_default_lights(void);
 static void rna_UserDef_viewport_lights_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
-       // GPU_default_lights();
-       WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, NULL);
+       WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D|NS_VIEW3D_GPU, NULL);
        rna_userdef_update(bmain, scene, ptr);
 }
 
index 06f1e7942f78827aaf88734d6bb0d80376fa542d..bb4a7452e0863c7734ad8fdfa8193f178521e7f5 100644 (file)
@@ -267,6 +267,8 @@ typedef struct wmNotifier {
 #define NS_MODE_POSE                   (9<<8)
 #define NS_MODE_PARTICLE               (10<<8)
 
+/* subtype 3d view editing */
+#define NS_VIEW3D_GPU                  (16<<8)
 
 /* action classification */
 #define NOTE_ACTION                    (0x000000FF)