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:
authorOmarSquircleArt <omar.squircleart@gmail.com>2019-09-05 00:17:13 +0300
committerOmarSquircleArt <omar.squircleart@gmail.com>2019-09-05 00:17:13 +0300
commitbaaa89a0bc54a659f9ddbc34cce21d6920c0f6a6 (patch)
treef5337407abc1e1e832612cc7643d508ed021eb37 /source/blender/makesrna/intern/rna_nodetree.c
parentf098f6df767aa62ffe0a7db6635ead058770d92f (diff)
Shading: Rewrite Mapping node with dynamic inputs.
This patch rewrites the Mapping node to support dynamic inputs. The Max and Min options have been removed. They can be added as Min and Max Vector Math nodes manually. Texture nodes still use the old matrix-based mapping. A new SVM node `NODE_TEXTURE_MAPPING` has been added to preserve this functionality. Similarly, in GLSL, a `mapping_mat4` function has been added. Reviewers: brecht, JacquesLucke
Diffstat (limited to 'source/blender/makesrna/intern/rna_nodetree.c')
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c88
1 files changed, 23 insertions, 65 deletions
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 988533e0f0e..6a4d59bd883 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -102,6 +102,26 @@ static const EnumPropertyItem node_chunksize_items[] = {
};
#endif
+const EnumPropertyItem rna_enum_mapping_type_items[] = {
+ {NODE_MAPPING_TYPE_POINT, "POINT", 0, "Point", "Transform a point"},
+ {NODE_MAPPING_TYPE_TEXTURE,
+ "TEXTURE",
+ 0,
+ "Texture",
+ "Transform a texture by inverse mapping the texture coordinate"},
+ {NODE_MAPPING_TYPE_VECTOR,
+ "VECTOR",
+ 0,
+ "Vector",
+ "Transform a direction vector. Location is ignored"},
+ {NODE_MAPPING_TYPE_NORMAL,
+ "NORMAL",
+ 0,
+ "Normal",
+ "Transform a unit normal vector. Location is ignored"},
+ {0, NULL, 0, NULL, NULL},
+};
+
const EnumPropertyItem rna_enum_node_math_items[] = {
{NODE_MATH_ADD, "ADD", 0, "Add", "A + B"},
{NODE_MATH_SUBTRACT, "SUBTRACT", 0, "Subtract", "A - B"},
@@ -3213,13 +3233,6 @@ static void rna_Image_Node_update_id(Main *UNUSED(bmain), Scene *UNUSED(scene),
nodeUpdate(ntree, node); /* to update image node sockets */
}
-static void rna_Mapping_Node_update(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
- bNode *node = ptr->data;
- BKE_texture_mapping_init(node->storage);
- rna_Node_update(bmain, scene, ptr);
-}
-
static void rna_NodeOutputFile_slots_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
bNode *node = ptr->data;
@@ -4034,68 +4047,13 @@ static void def_sh_output_linestyle(StructRNA *srna)
static void def_sh_mapping(StructRNA *srna)
{
- static const EnumPropertyItem prop_vect_type_items[] = {
- {TEXMAP_TYPE_TEXTURE,
- "TEXTURE",
- 0,
- "Texture",
- "Transform a texture by inverse mapping the texture coordinate"},
- {TEXMAP_TYPE_POINT, "POINT", 0, "Point", "Transform a point"},
- {TEXMAP_TYPE_VECTOR, "VECTOR", 0, "Vector", "Transform a direction vector"},
- {TEXMAP_TYPE_NORMAL, "NORMAL", 0, "Normal", "Transform a normal vector with unit length"},
- {0, NULL, 0, NULL, NULL},
- };
-
- static float default_1[3] = {1.f, 1.f, 1.f};
-
PropertyRNA *prop;
- RNA_def_struct_sdna_from(srna, "TexMapping", "storage");
-
prop = RNA_def_property(srna, "vector_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, prop_vect_type_items);
+ RNA_def_property_enum_sdna(prop, NULL, "custom1");
+ RNA_def_property_enum_items(prop, rna_enum_mapping_type_items);
RNA_def_property_ui_text(prop, "Type", "Type of vector that the mapping transforms");
- RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
-
- prop = RNA_def_property(srna, "translation", PROP_FLOAT, PROP_TRANSLATION);
- RNA_def_property_float_sdna(prop, NULL, "loc");
- RNA_def_property_ui_text(prop, "Location", "");
- RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
-
- /* Not PROP_XYZ, this is now in radians, no more degrees */
- prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_EULER);
- RNA_def_property_float_sdna(prop, NULL, "rot");
- RNA_def_property_ui_text(prop, "Rotation", "");
- RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
-
- prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
- RNA_def_property_float_sdna(prop, NULL, "size");
- RNA_def_property_float_array_default(prop, default_1);
- RNA_def_property_flag(prop, PROP_PROPORTIONAL);
- RNA_def_property_ui_text(prop, "Scale", "");
- RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
-
- prop = RNA_def_property(srna, "min", PROP_FLOAT, PROP_XYZ);
- RNA_def_property_float_sdna(prop, NULL, "min");
- RNA_def_property_ui_text(prop, "Minimum", "Minimum value for clipping");
- RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
-
- prop = RNA_def_property(srna, "max", PROP_FLOAT, PROP_XYZ);
- RNA_def_property_float_sdna(prop, NULL, "max");
- RNA_def_property_float_array_default(prop, default_1);
- RNA_def_property_ui_text(prop, "Maximum", "Maximum value for clipping");
- RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
-
- prop = RNA_def_property(srna, "use_min", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MIN);
- RNA_def_property_ui_text(prop, "Has Minimum", "Whether to use minimum clipping value");
- RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
-
- prop = RNA_def_property(srna, "use_max", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MAX);
- RNA_def_property_ui_text(prop, "Has Maximum", "Whether to use maximum clipping value");
- RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNode_socket_update");
}
static void def_sh_attribute(StructRNA *srna)