Fix #29249: mapping node not keyable anymore, restore RNA to what it was before

Cycles change, generating RNA paths for this is a bit complicated.
This commit is contained in:
2011-11-14 20:39:53 +00:00
parent bc98d4e383
commit 3442c16c09
3 changed files with 59 additions and 15 deletions

View File

@@ -100,7 +100,7 @@ static float get_node_output_value(BL::Node b_node, const string& name)
static void get_tex_mapping(TextureMapping *mapping, BL::TexMapping b_mapping)
{
mapping->translation = get_float3(b_mapping.location());
mapping->rotation = get_float3(b_mapping.rotation())*(M_PI/180.0f); /* in degrees! */
mapping->rotation = get_float3(b_mapping.rotation());
mapping->scale = get_float3(b_mapping.scale());
mapping->x_mapping = (TextureMapping::Mapping)b_mapping.mapping_x();
@@ -108,6 +108,13 @@ static void get_tex_mapping(TextureMapping *mapping, BL::TexMapping b_mapping)
mapping->z_mapping = (TextureMapping::Mapping)b_mapping.mapping_z();
}
static void get_tex_mapping(TextureMapping *mapping, BL::ShaderNodeMapping b_mapping)
{
mapping->translation = get_float3(b_mapping.location());
mapping->rotation = get_float3(b_mapping.rotation());
mapping->scale = get_float3(b_mapping.scale());
}
static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *b_group_node, BL::ShaderNode b_node)
{
ShaderNode *node = NULL;
@@ -174,7 +181,7 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
BL::ShaderNodeMapping b_mapping_node(b_node);
MappingNode *mapping = new MappingNode();
get_tex_mapping(&mapping->tex_mapping, b_mapping_node.mapping());
get_tex_mapping(&mapping->tex_mapping, b_mapping_node);
node = mapping;
break;

View File

@@ -947,28 +947,27 @@ static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA
static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
PointerRNA mappingptr = RNA_pointer_get(ptr, "mapping");
uiLayout *row;
uiItemL(layout, "Location:", ICON_NONE);
row= uiLayoutRow(layout, 1);
uiItemR(row, &mappingptr, "location", 0, "", ICON_NONE);
uiItemR(row, ptr, "location", 0, "", ICON_NONE);
uiItemL(layout, "Rotation:", ICON_NONE);
row= uiLayoutRow(layout, 1);
uiItemR(row, &mappingptr, "rotation", 0, "", ICON_NONE);
uiItemR(row, ptr, "rotation", 0, "", ICON_NONE);
uiItemL(layout, "Scale:", ICON_NONE);
row= uiLayoutRow(layout, 1);
uiItemR(row, &mappingptr, "scale", 0, "", ICON_NONE);
uiItemR(row, ptr, "scale", 0, "", ICON_NONE);
row= uiLayoutRow(layout, 1);
uiItemR(row, &mappingptr, "use_min", 0, "Min", ICON_NONE);
uiItemR(row, &mappingptr, "min", 0, "", ICON_NONE);
uiItemR(row, ptr, "use_min", 0, "Min", ICON_NONE);
uiItemR(row, ptr, "min", 0, "", ICON_NONE);
row= uiLayoutRow(layout, 1);
uiItemR(row, &mappingptr, "use_max", 0, "Max", ICON_NONE);
uiItemR(row, &mappingptr, "max", 0, "", ICON_NONE);
uiItemR(row, ptr, "use_max", 0, "Max", ICON_NONE);
uiItemR(row, ptr, "max", 0, "", ICON_NONE);
}
static void node_shader_buts_vect_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)

View File

@@ -757,6 +757,13 @@ static bNodeSocket *rna_NodeTree_output_expose(bNodeTree *ntree, ReportList *rep
return NULL;
}
static void rna_Mapping_Node_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
bNode *node = ptr->data;
init_tex_mapping(node->storage);
rna_Node_update(bmain, scene, ptr);
}
#else
static EnumPropertyItem prop_image_layer_items[] = {
@@ -1097,12 +1104,43 @@ static void def_sh_material(StructRNA *srna)
static void def_sh_mapping(StructRNA *srna)
{
PropertyRNA *prop;
RNA_def_struct_sdna_from(srna, "TexMapping", "storage");
prop= RNA_def_property(srna, "mapping", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "storage");
RNA_def_property_struct_type(prop, "TexMapping");
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Mapping", "Texture coordinate mapping settings");
prop= RNA_def_property(srna, "location", 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");
prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_EULER); /* Not PROP_XYZ, this is now in radians, no more degrees */
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_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_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");
}
static void def_sh_geometry(StructRNA *srna)