[Bf-blender-cvs] [003c64757d] clay-engine: Clay Engine per-collection settings

Dalai Felinto noreply at git.blender.org
Thu Feb 2 11:28:46 CET 2017


Commit: 003c64757d19ec42d8f66cb2c0bf216c82abca34
Author: Dalai Felinto
Date:   Thu Feb 2 11:08:21 2017 +0100
Branches: clay-engine
https://developer.blender.org/rB003c64757d19ec42d8f66cb2c0bf216c82abca34

Clay Engine per-collection settings

Note: this is still not used by rendering

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

M	release/scripts/startup/bl_ui/properties_collection.py
M	source/blender/draw/engines/clay/clay.c
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/properties_collection.py b/release/scripts/startup/bl_ui/properties_collection.py
index d67d694aec..018a720737 100644
--- a/release/scripts/startup/bl_ui/properties_collection.py
+++ b/release/scripts/startup/bl_ui/properties_collection.py
@@ -75,5 +75,33 @@ class COLLECTION_PT_objects(CollectionButtonsPanel, Panel):
         row.operator("collections.objects_deselect", text="Deselect")
 
 
+class COLLECTION_PT_clay_settings(CollectionButtonsPanel, Panel):
+    bl_label = "Render Settings"
+    COMPAT_ENGINES = {'BLENDER_CLAY'}
+
+    @classmethod
+    def poll(cls, context):
+        scene = context.scene
+        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+
+    def draw(self, context):
+        layout = self.layout
+
+        collection = context.layer_collection
+        settings = collection.get_engine_settings()
+
+        col = layout.column()
+        col.template_icon_view(settings, "matcap_icon")
+        col.prop(settings, "type")
+        col.prop(settings, "matcap_rotation")
+        col.prop(settings, "matcap_hue")
+        col.prop(settings, "matcap_saturation")
+        col.prop(settings, "matcap_value")
+        col.prop(settings, "ssao_factor_cavity")
+        col.prop(settings, "ssao_factor_edge")
+        col.prop(settings, "ssao_distance")
+        col.prop(settings, "ssao_attenuation")
+
+
 if __name__ == "__main__":  # only for live edit.
     bpy.utils.register_module(__name__)
diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c
index 0ea81146ed..e1b38926a0 100644
--- a/source/blender/draw/engines/clay/clay.c
+++ b/source/blender/draw/engines/clay/clay.c
@@ -659,6 +659,21 @@ static void CLAY_view_draw(RenderEngine *UNUSED(engine), const struct bContext *
 	DRW_state_reset();
 }
 
+static void CLAY_collection_settings_create(RenderEngine *UNUSED(engine), CollectionEngineSettings *ces)
+{
+	BLI_assert(ces);
+	BKE_collection_engine_property_add_int(ces, "matcap_icon", ICON_MATCAP_01);
+	BKE_collection_engine_property_add_int(ces, "type", CLAY_MATCAP_NONE);
+	BKE_collection_engine_property_add_float(ces, "matcap_rotation", 0.0f);
+	BKE_collection_engine_property_add_float(ces, "matcap_hue", 0.5f);
+	BKE_collection_engine_property_add_float(ces, "matcap_saturation", 0.5f);
+	BKE_collection_engine_property_add_float(ces, "matcap_value", 0.5f);
+	BKE_collection_engine_property_add_float(ces, "ssao_distance", 0.2f);
+	BKE_collection_engine_property_add_float(ces, "ssao_attenuation", 1.0f);
+	BKE_collection_engine_property_add_float(ces, "ssao_factor_cavity", 1.0f);
+	BKE_collection_engine_property_add_float(ces, "ssao_factor_edge", 1.0f);
+}
+
 void clay_engine_free(void)
 {
 	/* data.depth_sh Is builtin so it's automaticaly freed */
@@ -686,6 +701,6 @@ void clay_engine_free(void)
 RenderEngineType viewport_clay_type = {
 	NULL, NULL,
 	"BLENDER_CLAY", N_("Clay"), RE_INTERNAL | RE_USE_OGL_PIPELINE,
-	NULL, NULL, NULL, NULL, &CLAY_view_draw, NULL, NULL,
+	NULL, NULL, NULL, NULL, &CLAY_view_draw, NULL, &CLAY_collection_settings_create,
 	{NULL, NULL, NULL}
 };
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 189ea7135f..318d465bf7 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2360,13 +2360,64 @@ static StructRNA *rna_CollectionEngineSettings_refine(struct PointerRNA *ptr)
 {
 	CollectionEngineSettings *ces = (CollectionEngineSettings *)ptr->data;
 
-	/* TODO - handle engines */
+	if (STREQ(ces->name, "BLENDER_CLAY")) {
+		return &RNA_CollectionEngineSettingsClay;
+	}
+
+	/* TODO - handle other engines */
 	TODO_LAYER;
 	(void) ces;
 
 	return &RNA_CollectionEngineSettings;
 }
 
+/****** clay engine settings *******/
+
+#define RNA_LAYER_ENGINE_GET_SET(_TYPE_, _CLASS_, _NAME_)                          \
+static _TYPE_ rna_LayerEngineSettings_##_NAME_##_get(PointerRNA *ptr)              \
+{                                                                                  \
+	CollectionEngineSettings *ces = (CollectionEngineSettings *)ptr->data;         \
+	                                                                               \
+	_CLASS_ *prop = (_CLASS_ *)BKE_collection_engine_property_get(ces, #_NAME_);   \
+	BLI_assert(prop);                                                              \
+	                                                                               \
+	return prop->value;                                                            \
+}                                                                                  \
+	                                                                               \
+static void rna_LayerEngineSettings_##_NAME_##_set(PointerRNA *ptr, _TYPE_ value)  \
+{                                                                                  \
+	CollectionEngineSettings *ces = (CollectionEngineSettings *)ptr->data;         \
+	                                                                               \
+	_CLASS_ *prop = (_CLASS_ *)BKE_collection_engine_property_get(ces,  #_NAME_);  \
+	BLI_assert(prop);                                                              \
+	                                                                               \
+	prop->value = value;                                                           \
+}
+
+#define RNA_LAYER_ENGINE_GET_SET_FLOAT(_NAME_) \
+	RNA_LAYER_ENGINE_GET_SET(float, CollectionEnginePropertyFloat, _NAME_)
+
+#define RNA_LAYER_ENGINE_GET_SET_INT(_NAME_) \
+	RNA_LAYER_ENGINE_GET_SET(int, CollectionEnginePropertyInt, _NAME_)
+
+
+RNA_LAYER_ENGINE_GET_SET_INT(type)
+RNA_LAYER_ENGINE_GET_SET_INT(matcap_icon)
+RNA_LAYER_ENGINE_GET_SET_FLOAT(matcap_rotation)
+RNA_LAYER_ENGINE_GET_SET_FLOAT(matcap_hue)
+RNA_LAYER_ENGINE_GET_SET_FLOAT(matcap_saturation)
+RNA_LAYER_ENGINE_GET_SET_FLOAT(matcap_value)
+RNA_LAYER_ENGINE_GET_SET_FLOAT(ssao_factor_cavity)
+RNA_LAYER_ENGINE_GET_SET_FLOAT(ssao_factor_edge)
+RNA_LAYER_ENGINE_GET_SET_FLOAT(ssao_distance)
+RNA_LAYER_ENGINE_GET_SET_FLOAT(ssao_attenuation)
+
+#undef RNA_LAYER_ENGINE_GET_SET_INT
+#undef RNA_LAYER_ENGINE_GET_SET_FLOAT
+#undef RNA_LAYER_ENGINE_GET_SET
+
+/***********************************/
+
 static void rna_LayerCollection_name_get(PointerRNA *ptr, char *value)
 {
 	SceneCollection *sc = ((LayerCollection *)ptr->data)->scene_collection;
@@ -5677,6 +5728,120 @@ static void rna_def_layer_collection_override(BlenderRNA *brna)
 	RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
 }
 
+static void rna_def_layer_collection_engine_settings_clay(BlenderRNA *brna)
+{
+	StructRNA *srna;
+	PropertyRNA *prop;
+
+	static EnumPropertyItem clay_matcap_items[] = {
+	    {ICON_MATCAP_01, "01", ICON_MATCAP_01, "", ""},
+	    {ICON_MATCAP_02, "02", ICON_MATCAP_02, "", ""},
+	    {ICON_MATCAP_03, "03", ICON_MATCAP_03, "", ""},
+	    {ICON_MATCAP_04, "04", ICON_MATCAP_04, "", ""},
+	    {ICON_MATCAP_05, "05", ICON_MATCAP_05, "", ""},
+	    {ICON_MATCAP_06, "06", ICON_MATCAP_06, "", ""},
+	    {ICON_MATCAP_07, "07", ICON_MATCAP_07, "", ""},
+	    {ICON_MATCAP_08, "08", ICON_MATCAP_08, "", ""},
+	    {ICON_MATCAP_09, "09", ICON_MATCAP_09, "", ""},
+	    {ICON_MATCAP_10, "10", ICON_MATCAP_10, "", ""},
+	    {ICON_MATCAP_11, "11", ICON_MATCAP_11, "", ""},
+	    {ICON_MATCAP_12, "12", ICON_MATCAP_12, "", ""},
+	    {ICON_MATCAP_13, "13", ICON_MATCAP_13, "", ""},
+	    {ICON_MATCAP_14, "14", ICON_MATCAP_14, "", ""},
+	    {ICON_MATCAP_15, "15", ICON_MATCAP_15, "", ""},
+	    {ICON_MATCAP_16, "16", ICON_MATCAP_16, "", ""},
+	    {ICON_MATCAP_17, "17", ICON_MATCAP_17, "", ""},
+	    {ICON_MATCAP_18, "18", ICON_MATCAP_18, "", ""},
+	    {ICON_MATCAP_19, "19", ICON_MATCAP_19, "", ""},
+	    {ICON_MATCAP_20, "20", ICON_MATCAP_20, "", ""},
+	    {ICON_MATCAP_21, "21", ICON_MATCAP_21, "", ""},
+	    {ICON_MATCAP_22, "22", ICON_MATCAP_22, "", ""},
+	    {ICON_MATCAP_23, "23", ICON_MATCAP_23, "", ""},
+	    {ICON_MATCAP_24, "24", ICON_MATCAP_24, "", ""},
+	    {0, NULL, 0, NULL, NULL}
+	};
+
+	static EnumPropertyItem clay_matcap_type[] = {
+	    {CLAY_MATCAP_NONE, "NONE", 0, "Scene", "Use default scene matcap"},
+	    {CLAY_MATCAP_SIMPLE, "SIMPLE", 0, "Simple", "Let you choose the texture to use with the default settings"},
+	    {CLAY_MATCAP_COMPLETE, "COMPLETE", 0, "Complete", "Expose all settings"},
+	    {0, NULL, 0, NULL, NULL}
+	};
+
+	srna = RNA_def_struct(brna, "CollectionEngineSettingsClay", NULL);
+	RNA_def_struct_sdna(srna, "CollectionEngineSettings");
+	RNA_def_struct_ui_text(srna, "Collections Clay Engine Settings", "Engine specific settings for this collection");
+
+	prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+	RNA_def_property_ui_text(prop, "Name", "Engine name");
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+	RNA_def_struct_name_property(srna, prop);
+
+	/* see RNA_LAYER_ENGINE_GET_SET macro */
+
+	prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_type_get", "rna_LayerEngineSettings_type_set", NULL);
+	RNA_def_property_enum_items(prop, clay_matcap_type);
+	RNA_def_property_ui_text(prop, "Settings Type", "What settings to use for this material");
+	RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
+
+	prop = RNA_def_property(srna, "matcap_icon", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_matcap_icon_get", "rna_LayerEngineSettings_matcap_icon_set", NULL);
+	RNA_def_property_enum_items(prop, clay_matcap_items);
+	RNA_def_property_ui_text(prop, "Matcap", "Image to use for Material Capture by this material");
+	RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
+
+	prop = RNA_def_property(srna, "matcap_rotation", PROP_FLOAT, PROP_FACTOR);
+	RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_matcap_rotation_get", "rna_LayerEngineSettings_matcap_rotation_set", NULL);
+	RNA_def_property_range(prop, 0.0f, 1.0f);
+	RNA_def_property_ui_text(prop, "Matcap Rotation", "Orientation of the matcap on the model");
+	RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
+
+	prop = RNA_def_property(

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list