Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-10-06 19:31:25 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-10-06 19:31:25 +0400
commit8d54982f37cf48d510fa2de0b2b45c635164a7f3 (patch)
treec356e1304bf02a2714cde79ea51ce46340a26c58 /source/blender/makesrna/intern/rna_material.c
parent86307b58c0991472b25bd0c24ba8d2cdbf332bc3 (diff)
Material buttons now view the active node material shading settings.
Selecting a material in the node tree sets this as the active material and the buttons view redraws. Added rna prop material.active_node_material Currently its not clear what settings are used by the node material and the base material (needs some tedious research) so I made most panels use the node material with the exceptions of volumetrics, physics and halo settings. We'll probably need to split the panels up to do this properly.
Diffstat (limited to 'source/blender/makesrna/intern/rna_material.c')
-rw-r--r--source/blender/makesrna/intern/rna_material.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index b05a7e59cc3..efcf4de062e 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -54,6 +54,8 @@ static EnumPropertyItem prop_texture_coordinates_items[] = {
#include "MEM_guardedalloc.h"
+#include "DNA_node_types.h"
+
#include "BKE_depsgraph.h"
#include "BKE_main.h"
#include "BKE_texture.h"
@@ -152,6 +154,31 @@ static void rna_Material_active_texture_set(PointerRNA *ptr, PointerRNA value)
}
}
+static PointerRNA rna_Material_active_node_material_get(PointerRNA *ptr)
+{
+ Material *ma= (Material*)ptr->data;
+ Material *ma_node= NULL;
+
+ /* used in buttons to check context, also checks for edited groups */
+
+ if(ma && ma->use_nodes && ma->nodetree) {
+ bNode *node= nodeGetActiveID(ma->nodetree, ID_MA);
+
+ if(node)
+ ma_node= (Material *)node->id;
+ }
+
+ return rna_pointer_inherit_refine(ptr, &RNA_Material, ma_node);
+}
+
+static void rna_Material_active_node_material_set(PointerRNA *ptr, PointerRNA value)
+{
+ Material *ma= (Material*)ptr->data;
+ Material *ma_act= value.data;
+
+ nodeSetActiveID(ma->nodetree, ID_MA, ma_act);
+}
+
static void rna_MaterialStrand_start_size_range(PointerRNA *ptr, float *min, float *max)
{
Material *ma= (Material*)ptr->id.data;
@@ -1690,6 +1717,13 @@ void RNA_def_material(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the material.");
RNA_def_property_update(prop, NC_MATERIAL, NULL);
+ prop= RNA_def_property(srna, "active_node_material", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "Material");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_pointer_funcs(prop, "rna_Material_active_node_material_get", "rna_Material_active_node_material_set", NULL);
+ RNA_def_property_ui_text(prop, "Material", "Active node material.");
+ RNA_def_property_update(prop, NC_MATERIAL, NULL);
+
/* common */
rna_def_animdata_common(srna);
rna_def_mtex_common(srna, "rna_Material_mtex_begin", "rna_Material_active_texture_get",