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
path: root/source
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
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')
-rw-r--r--source/blender/blenkernel/BKE_node.h1
-rw-r--r--source/blender/blenkernel/intern/node.c31
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c8
-rw-r--r--source/blender/editors/space_node/node_select.c17
-rw-r--r--source/blender/makesrna/intern/rna_material.c34
5 files changed, 84 insertions, 7 deletions
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index b1e7dcaff02..66776d086d6 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -181,6 +181,7 @@ int nodeCountSocketLinks(struct bNodeTree *ntree, struct bNodeSocket *sock);
void nodeSetActive(struct bNodeTree *ntree, struct bNode *node);
struct bNode *nodeGetActive(struct bNodeTree *ntree);
struct bNode *nodeGetActiveID(struct bNodeTree *ntree, short idtype);
+int nodeSetActiveID(struct bNodeTree *ntree, short idtype, struct ID *id);
void nodeClearActiveID(struct bNodeTree *ntree, short idtype);
void NodeTagChanged(struct bNodeTree *ntree, struct bNode *node);
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index aa12894feb9..fad866a7201 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -1575,6 +1575,37 @@ bNode *nodeGetActiveID(bNodeTree *ntree, short idtype)
return node;
}
+int nodeSetActiveID(bNodeTree *ntree, short idtype, ID *id)
+{
+ bNode *node;
+ int ok= FALSE;
+
+ if(ntree==NULL) return ok;
+
+ /* check for group edit */
+ for(node= ntree->nodes.first; node; node= node->next)
+ if(node->flag & NODE_GROUP_EDIT)
+ break;
+
+ if(node)
+ ntree= (bNodeTree*)node->id;
+
+ /* now find active node with this id */
+ for(node= ntree->nodes.first; node; node= node->next) {
+ if(node->id && GS(node->id->name)==idtype) {
+ if(id && ok==FALSE && node->id==id) {
+ node->flag |= NODE_ACTIVE_ID;
+ ok= TRUE;
+ } else {
+ node->flag &= ~NODE_ACTIVE_ID;
+ }
+ }
+ }
+
+ return ok;
+}
+
+
/* two active flags, ID nodes have special flag for buttons display */
void nodeClearActiveID(bNodeTree *ntree, short idtype)
{
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 982bd315b99..c9353f697db 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -1100,17 +1100,15 @@ static struct MultiresModifierData *sculpt_multires_active(Object *ob)
for(md= modifiers_getVirtualModifierList(ob); md; md= md->next) {
if(md->type == eModifierType_Multires) {
- MultiresModifierData *mmd;
+ MultiresModifierData *mmd= (MultiresModifierData*)md;
/* Check if any of the modifiers after multires are active
* if not it can use the multires struct */
- ModifierData *md_next;
- for (md_next= md->next; md_next; md_next= md_next->next) {
- if(md_next->mode & eModifierMode_Realtime)
+ for (md= md->next; md; md= md->next) {
+ if(md->mode & eModifierMode_Realtime)
return NULL;
}
- mmd = (MultiresModifierData*)md;
if(mmd->lvl != 1)
return mmd;
}
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index 5e482758c9d..ecbd46b720f 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -38,6 +38,7 @@
#include "BKE_context.h"
#include "BKE_node.h"
#include "BKE_global.h"
+#include "BKE_utildefines.h"
#include "BLI_rect.h"
@@ -55,7 +56,7 @@
#include "node_intern.h"
-static void node_mouse_select(SpaceNode *snode, ARegion *ar, short *mval, short extend)
+static bNode *node_mouse_select(SpaceNode *snode, ARegion *ar, short *mval, short extend)
{
bNode *node;
float mx, my;
@@ -101,7 +102,10 @@ static void node_mouse_select(SpaceNode *snode, ARegion *ar, short *mval, short
;// node_link_viewer(snode, node);
//std_rmouse_transform(node_transform_ext); /* does undo push for select */
+
}
+
+ return node;
}
static int node_select_exec(bContext *C, wmOperator *op)
@@ -112,6 +116,7 @@ static int node_select_exec(bContext *C, wmOperator *op)
int select_type;
short mval[2];
short extend;
+ bNode *node= NULL;
select_type = RNA_enum_get(op->ptr, "select_type");
@@ -120,12 +125,20 @@ static int node_select_exec(bContext *C, wmOperator *op)
mval[0] = RNA_int_get(op->ptr, "mouse_x");
mval[1] = RNA_int_get(op->ptr, "mouse_y");
extend = RNA_boolean_get(op->ptr, "extend");
- node_mouse_select(snode, ar, mval, extend);
+ node= node_mouse_select(snode, ar, mval, extend);
break;
}
/* need refresh/a notifier vs compo notifier */
// XXX WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL); /* Do we need to pass the scene? */
+
+ /* WATCH THIS, there are a few other ways to change the active material */
+ if(node) {
+ if (node->id && GS(node->id->name)== ID_MA) {
+ WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING_DRAW, node->id);
+ }
+ }
+
ED_region_tag_redraw(ar);
/* allow tweak event to work too */
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",