Workbench: Added Object Color to collection_properties
authorJeroen Bakker <j.bakker@atmind.nl>
Mon, 16 Apr 2018 13:01:31 +0000 (15:01 +0200)
committerJeroen Bakker <j.bakker@atmind.nl>
Mon, 16 Apr 2018 13:01:31 +0000 (15:01 +0200)
release/scripts/addons
release/scripts/addons_contrib
release/scripts/startup/bl_ui/properties_collection.py
release/scripts/startup/bl_ui/properties_render.py
source/blender/blenkernel/intern/scene.c
source/blender/draw/engines/workbench/workbench_engine.c
source/blender/draw/engines/workbench/workbench_materials.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_layer.c

index c88411ff7776a2db5d6ef6117a1b2faa42a95611..8f2fd7e23f0b5ce023440182f51c40e88d663325 160000 (submodule)
@@ -1 +1 @@
-Subproject commit c88411ff7776a2db5d6ef6117a1b2faa42a95611
+Subproject commit 8f2fd7e23f0b5ce023440182f51c40e88d663325
index 310578043dec1aae382eb6a447ae1d103792d7e6..34a27a42d781d80f9f1833bad8cc5b2abcac2933 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 310578043dec1aae382eb6a447ae1d103792d7e6
+Subproject commit 34a27a42d781d80f9f1833bad8cc5b2abcac2933
index e48df3a0a610559642e5f067524281ec52bac1ac..cced6262be5e1eea4b630086b72f5c49ff5125b6 100644 (file)
@@ -86,6 +86,24 @@ class COLLECTION_PT_clay_settings(CollectionButtonsPanel, Panel):
         col.template_override_property(collection_props, scene_props, "hair_brightness_randomness")
 
 
+class COLLECTION_PT_workbench_settings(CollectionButtonsPanel, Panel):
+    bl_label = "Render Settings"
+    COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
+
+    @classmethod
+    def poll(cls, context):
+        return context.view_render.engine in cls.COMPAT_ENGINES
+
+    def draw(self, context):
+        layout = self.layout
+        scene_props = context.scene.collection_properties['BLENDER_WORKBENCH']
+        collection = get_collection_from_context(context)
+        collection_props = collection.engine_overrides['BLENDER_WORKBENCH']
+
+        col = layout.column()
+        col.template_override_property(collection_props, scene_props, "object_color")
+
+
 class COLLECTION_PT_object_mode_settings(CollectionButtonsPanel, Panel):
     bl_label = "Object Mode Settings"
 
@@ -170,6 +188,7 @@ class COLLECTION_PT_paint_vertex_mode_settings(CollectionButtonsPanel, Panel):
 classes = (
     COLLECTION_PT_context_collection,
     COLLECTION_PT_clay_settings,
+    COLLECTION_PT_workbench_settings,
     COLLECTION_PT_object_mode_settings,
     COLLECTION_PT_edit_mode_settings,
     COLLECTION_PT_paint_weight_mode_settings,
index 15b175617d693e02944672bad40ce718fbfc8cd9..78b9f007bc0fb27c0ed42bf3bd8b131810839ee2 100644 (file)
@@ -912,6 +912,18 @@ class RENDER_PT_eevee_film(RenderButtonsPanel, Panel):
         col.prop(rd, "alpha_mode", text="Alpha")
 
 
+class RENDER_PT_workbench_collection_settings(RenderButtonsPanel, Panel):
+    bl_label = "Workbench Collection Settings"
+    COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
+
+    def draw(self, context):
+        layout = self.layout
+        props = context.scene.collection_properties['BLENDER_WORKBENCH']
+
+        col = layout.column()
+        col.prop(props, "object_color")
+
+
 classes = (
     RENDER_MT_presets,
     RENDER_MT_ffmpeg_presets,
@@ -941,6 +953,7 @@ classes = (
     RENDER_PT_eevee_motion_blur,
     RENDER_PT_eevee_depth_of_field,
     RENDER_PT_eevee_bloom,
+    RENDER_PT_workbench_collection_settings,
 )
 
 if __name__ == "__main__":  # only for live edit.
index 9a7c10d31deefce42c667b91560fe39831c5dd30..628d9584f0e861e947d36308798c38a6aaa2034a 100644 (file)
@@ -115,6 +115,7 @@ const char *RE_engine_id_BLENDER_RENDER = "BLENDER_RENDER";
 const char *RE_engine_id_BLENDER_GAME = "BLENDER_GAME";
 const char *RE_engine_id_BLENDER_CLAY = "BLENDER_CLAY";
 const char *RE_engine_id_BLENDER_EEVEE = "BLENDER_EEVEE";
+const char *RE_engine_id_BLENDER_WORKBENCH = "BLENDER_WORKBENCH";
 const char *RE_engine_id_CYCLES = "CYCLES";
 
 void free_avicodecdata(AviCodecData *acd)
index bcaed908ec6bf972280f045769cae2789601890f..4507346660638ecd8ae743a6f9f2b10eb5513951 100644 (file)
@@ -73,6 +73,16 @@ static void workbench_engine_free(void)
        workbench_materials_free();
 }
 
+static void workbench_layer_collection_settings_create(RenderEngine *UNUSED(engine), IDProperty *props)
+{
+       BLI_assert(props &&
+                  props->type == IDP_GROUP &&
+                  props->subtype == IDP_GROUP_SUB_ENGINE_RENDER);
+       float default_object_color[3] = {1.0, 1.0, 1.0};
+       BKE_collection_engine_property_add_float_array(props, "object_color", default_object_color, 3);
+}
+
+
 static const DrawEngineDataSize workbench_data_size = DRW_VIEWPORT_DATA_SIZE(WORKBENCH_Data);
 
 DrawEngineType draw_engine_workbench_type = {
@@ -96,7 +106,7 @@ DrawEngineType draw_engine_workbench_type = {
 RenderEngineType DRW_engine_viewport_workbench_type = {
        NULL, NULL,
        WORKBENCH_ENGINE, N_("Workbench"), RE_INTERNAL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+       NULL, NULL, NULL, NULL, NULL, NULL, NULL, &workbench_layer_collection_settings_create, NULL,
        &draw_engine_workbench_type,
        {NULL, NULL, NULL}
 };
index 3a6d199cecf95af3ca058c3f174ccb834cb9f845..b499a203f18e44611a8c9b1d09997bba9d7e6462 100644 (file)
@@ -77,6 +77,9 @@ void workbench_materials_cache_populate(WORKBENCH_Data* vedata, Object *ob)
 {
        WORKBENCH_PassList *psl = vedata->psl;
        WORKBENCH_StorageList *stl = vedata->stl;
+       
+       IDProperty *props = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_WORKBENCH);
+       const float* color = BKE_collection_engine_property_value_get_float_array(props, "object_color");
 
        if (!DRW_object_is_renderable(ob))
                return;
@@ -89,7 +92,7 @@ void workbench_materials_cache_populate(WORKBENCH_Data* vedata, Object *ob)
                
                /* Silhouette */
                grp = DRW_shgroup_create(e_data.silhouette_sh, psl->silhouette_pass);
-               DRW_shgroup_uniform_vec3(grp, "color", ob->col, 1);
+               DRW_shgroup_uniform_vec3(grp, "color", color, 1);
                DRW_shgroup_call_add(grp, geom, ob->obmat);
        }
 }
index 696918d97a5ae28dec0d8da71a3781e60d7be5bf..3b7875ea5b14e4270ab54a760ee8a739832e9fa0 100644 (file)
@@ -1913,6 +1913,7 @@ extern const char *RE_engine_id_BLENDER_RENDER;
 extern const char *RE_engine_id_BLENDER_GAME;
 extern const char *RE_engine_id_BLENDER_CLAY;
 extern const char *RE_engine_id_BLENDER_EEVEE;
+extern const char *RE_engine_id_BLENDER_WORKBENCH;
 extern const char *RE_engine_id_CYCLES;
 
 /* **************** SCENE ********************* */
index 7d09f30ed6ab34794621a0355fb34745bd1d59e8..36e6afe26d6aa689f005e092b3129710d916ff5b 100644 (file)
@@ -309,6 +309,9 @@ static void rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_set(PointerRNA *ptr,
 #define RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(_NAME_) \
        RNA_LAYER_ENGINE_GET_SET(bool, Eevee, COLLECTION_MODE_NONE, _NAME_)
 
+#define RNA_LAYER_ENGINE_WORKBENCH_GET_SET_FLOAT_ARRAY(_NAME_, _LEN_) \
+       RNA_LAYER_ENGINE_GET_SET_ARRAY(float, Workbench, COLLECTION_MODE_NONE, _NAME_, _LEN_)
+
 /* mode engines */
 
 #define RNA_LAYER_MODE_OBJECT_GET_SET_FLOAT(_NAME_) \
@@ -353,6 +356,10 @@ RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(ssao_attenuation)
 RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(hair_brightness_randomness)
 #endif /* WITH_CLAY_ENGINE */
 
+/* workbench engine */
+/* LayerCollection settings. */
+RNA_LAYER_ENGINE_WORKBENCH_GET_SET_FLOAT_ARRAY(object_color, 3)
+
 /* eevee engine */
 /* ViewLayer settings. */
 RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(gtao_enable)
@@ -578,6 +585,9 @@ static StructRNA *rna_LayerCollectionSettings_refine(PointerRNA *ptr)
                                return &RNA_LayerCollectionEngineSettingsClay;
                        }
 #endif
+                       if (STREQ(props->name, RE_engine_id_BLENDER_WORKBENCH)) {
+                               return &RNA_LayerCollectionEngineSettingsWorkbench;
+                       }
                        if (STREQ(props->name, RE_engine_id_BLENDER_EEVEE)) {
                                /* printf("Mode not fully implemented\n"); */
                                return &RNA_LayerCollectionSettings;
@@ -1736,6 +1746,25 @@ static void rna_def_layer_collection_engine_settings_clay(BlenderRNA *brna)
 }
 #endif /* WITH_CLAY_ENGINE */
 
+static void rna_def_layer_collection_engine_settings_workbench(BlenderRNA *brna)
+{
+       StructRNA *srna;
+       PropertyRNA *prop;
+       
+       srna = RNA_def_struct(brna, "LayerCollectionEngineSettingsWorkbench", "LayerCollectionSettings");
+       RNA_def_struct_ui_text(srna, "Collections Workbench Engine Settings", "Engine specific settings for this collection");
+
+       RNA_define_verify_sdna(0); /* not in sdna */
+
+       prop = RNA_def_property(srna, "object_color", PROP_FLOAT, PROP_COLOR);
+       RNA_def_property_array(prop, 3);
+       RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Workbench_object_color_get",
+                                    "rna_LayerEngineSettings_Workbench_object_color_set", NULL);
+       RNA_def_property_ui_text(prop, "Object Color", "Color for Drawing Objects");
+       RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+       RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
+}
+
 static void rna_def_layer_collection_mode_settings_object(BlenderRNA *brna)
 {
        StructRNA *srna;
@@ -1958,6 +1987,7 @@ static void rna_def_layer_collection_settings(BlenderRNA *brna)
        rna_def_layer_collection_engine_settings_clay(brna);
 #endif
 
+       rna_def_layer_collection_engine_settings_workbench(brna);
        rna_def_layer_collection_mode_settings_object(brna);
        rna_def_layer_collection_mode_settings_edit(brna);
        rna_def_layer_collection_mode_settings_paint_weight(brna);