[Bf-blender-cvs] [11275b73636] master: Realtime Compositor: Extend option to enable compositor

Omar Emara noreply at git.blender.org
Wed Nov 23 12:27:50 CET 2022


Commit: 11275b736366f6df9b8314b65940001c57736523
Author: Omar Emara
Date:   Wed Nov 23 13:26:46 2022 +0200
Branches: master
https://developer.blender.org/rB11275b736366f6df9b8314b65940001c57736523

Realtime Compositor: Extend option to enable compositor

This patch turns the checkbox option to enable the viewport compositor
into a 3-option enum that allows:

- Disabled.
- Enabled.
- Enabled only in camera view.

See T102353.

Differential Revision: https://developer.blender.org/D16509

Reviewed By: Clement Foucault

===================================================================

M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/draw/intern/draw_manager.c
M	source/blender/makesdna/DNA_view3d_types.h
M	source/blender/makesrna/intern/rna_space.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 38b277a1337..dda5e8beb10 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -6211,8 +6211,8 @@ class VIEW3D_PT_shading_compositor(Panel):
     def draw(self, context):
         shading = context.space_data.shading
 
-        layout = self.layout
-        layout.prop(shading, "use_compositor")
+        row = self.layout.row()
+        row.prop(shading, "use_compositor", expand=True)
 
 
 class VIEW3D_PT_gizmo_display(Panel):
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 5e87751a9d4..b4c4c5c8d47 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -45,6 +45,7 @@
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_userdef_types.h"
+#include "DNA_view3d_types.h"
 #include "DNA_world_types.h"
 
 #include "ED_gpencil.h"
@@ -1247,7 +1248,7 @@ static bool is_compositor_enabled(void)
     return false;
   }
 
-  if (!(DST.draw_ctx.v3d->shading.flag & V3D_SHADING_COMPOSITOR)) {
+  if (DST.draw_ctx.v3d->shading.use_compositor == V3D_SHADING_USE_COMPOSITOR_DISABLED) {
     return false;
   }
 
@@ -1263,6 +1264,11 @@ static bool is_compositor_enabled(void)
     return false;
   }
 
+  if (DST.draw_ctx.v3d->shading.use_compositor == V3D_SHADING_USE_COMPOSITOR_CAMERA &&
+      DST.draw_ctx.rv3d->persp != RV3D_CAMOB) {
+    return false;
+  }
+
   return true;
 }
 
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index f3e56ba7039..c09868b44fb 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -147,7 +147,11 @@ typedef struct View3DShading {
   char background_type;
   char cavity_type;
   char wire_color_type;
-  char _pad[2];
+
+  /** When to preview the compositor output in the viewport. View3DShadingUseCompositor. */
+  char use_compositor;
+
+  char _pad;
 
   /** FILE_MAXFILE. */
   char studio_light[256];
@@ -491,7 +495,6 @@ enum {
   V3D_SHADING_SCENE_LIGHTS_RENDER = (1 << 12),
   V3D_SHADING_SCENE_WORLD_RENDER = (1 << 13),
   V3D_SHADING_STUDIOLIGHT_VIEW_ROTATION = (1 << 14),
-  V3D_SHADING_COMPOSITOR = (1 << 15),
 };
 
 /** #View3D.debug_flag */
@@ -516,6 +519,15 @@ enum {
   V3D_SHADING_CAVITY_BOTH = 2,
 };
 
+/** #View3DShading.use_compositor */
+typedef enum View3DShadingUseCompositor {
+  V3D_SHADING_USE_COMPOSITOR_DISABLED = 0,
+  /** The compositor is enabled only in camera view. */
+  V3D_SHADING_USE_COMPOSITOR_CAMERA = 1,
+  /** The compositor is always enabled regardless of the view. */
+  V3D_SHADING_USE_COMPOSITOR_ALWAYS = 2,
+} View3DShadingUseCompositor;
+
 /** #View3DOverlay.flag */
 enum {
   V3D_OVERLAY_FACE_ORIENTATION = (1 << 0),
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index e0341e76667..17c373f2924 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -3959,6 +3959,25 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
       {0, NULL, 0, NULL, NULL},
   };
 
+  static const EnumPropertyItem use_compositor_items[] = {
+      {V3D_SHADING_USE_COMPOSITOR_DISABLED,
+       "DISABLED",
+       0,
+       "Disabled",
+       "The compositor is disabled"},
+      {V3D_SHADING_USE_COMPOSITOR_CAMERA,
+       "CAMERA",
+       0,
+       "Camera",
+       "The compositor is enabled only in camera view"},
+      {V3D_SHADING_USE_COMPOSITOR_ALWAYS,
+       "ALWAYS",
+       0,
+       "Always",
+       "The compositor is always enabled regardless of the view"},
+      {0, NULL, 0, NULL, NULL},
+  };
+
   /* Note these settings are used for both 3D viewport and the OpenGL render
    * engine in the scene, so can't assume to always be part of a screen. */
   srna = RNA_def_struct(brna, "View3DShading", NULL);
@@ -4245,12 +4264,12 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
   RNA_def_property_flag(prop, PROP_HIDDEN);
   RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
 
-  prop = RNA_def_property(srna, "use_compositor", PROP_BOOLEAN, PROP_NONE);
-  RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_COMPOSITOR);
+  prop = RNA_def_property(srna, "use_compositor", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_sdna(prop, NULL, "use_compositor");
+  RNA_def_property_enum_items(prop, use_compositor_items);
   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
-  RNA_def_property_boolean_default(prop, false);
   RNA_def_property_ui_text(
-      prop, "Compositor", "Preview the compositor output inside the viewport");
+      prop, "Compositor", "When to preview the compositor output inside the viewport");
   RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL);
 }



More information about the Bf-blender-cvs mailing list