diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_material_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_material_api.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/source/blender/makesrna/intern/rna_material_api.c b/source/blender/makesrna/intern/rna_material_api.c index aa28b6b923c..8511df208cf 100644 --- a/source/blender/makesrna/intern/rna_material_api.c +++ b/source/blender/makesrna/intern/rna_material_api.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2009 Blender Foundation. * All rights reserved. @@ -55,10 +55,10 @@ static void rna_Material_add_texture(Material *ma, Tex *tex, int mapto, int texc break; } } - + if (slot == -1) slot= 0; - + if (ma->mtex[slot]) { ma->mtex[slot]->tex->id.us--; } @@ -69,8 +69,9 @@ static void rna_Material_add_texture(Material *ma, Tex *tex, int mapto, int texc mtex= ma->mtex[slot]; mtex->tex= tex; - id_us_plus(&tex->id); - + if (tex) + id_us_plus(&tex->id); + mtex->texco= mapto; mtex->mapto= texco; } @@ -84,17 +85,17 @@ void RNA_api_material(StructRNA *srna) /* copied from rna_def_material_mtex (rna_material.c) */ static EnumPropertyItem prop_texture_coordinates_items[] = { - {TEXCO_GLOB, "GLOBAL", 0, "Global", "Uses global coordinates for the texture coordinates."}, - {TEXCO_OBJECT, "OBJECT", 0, "Object", "Uses linked object's coordinates for texture coordinates."}, - {TEXCO_UV, "UV", 0, "UV", "Uses UV coordinates for texture coordinates."}, - {TEXCO_ORCO, "ORCO", 0, "Generated", "Uses the original undeformed coordinates of the object."}, - {TEXCO_STRAND, "STRAND", 0, "Strand", "Uses normalized strand texture coordinate (1D)."}, - {TEXCO_STICKY, "STICKY", 0, "Sticky", "Uses mesh's sticky coordinates for the texture coordinates."}, - {TEXCO_WINDOW, "WINDOW", 0, "Window", "Uses screen coordinates as texture coordinates."}, - {TEXCO_NORM, "NORMAL", 0, "Normal", "Uses normal vector as texture coordinates."}, - {TEXCO_REFL, "REFLECTION", 0, "Reflection", "Uses reflection vector as texture coordinates."}, - {TEXCO_STRESS, "STRESS", 0, "Stress", "Uses the difference of edge lengths compared to original coordinates of the mesh."}, - {TEXCO_TANGENT, "TANGENT", 0, "Tangent", "Uses the optional tangent vector as texture coordinates."}, + {TEXCO_GLOB, "GLOBAL", 0, "Global", "Uses global coordinates for the texture coordinates"}, + {TEXCO_OBJECT, "OBJECT", 0, "Object", "Uses linked object's coordinates for texture coordinates"}, + {TEXCO_UV, "UV", 0, "UV", "Uses UV coordinates for texture coordinates"}, + {TEXCO_ORCO, "ORCO", 0, "Generated", "Uses the original undeformed coordinates of the object"}, + {TEXCO_STRAND, "STRAND", 0, "Strand", "Uses normalized strand texture coordinate (1D)"}, + {TEXCO_STICKY, "STICKY", 0, "Sticky", "Uses mesh's sticky coordinates for the texture coordinates"}, + {TEXCO_WINDOW, "WINDOW", 0, "Window", "Uses screen coordinates as texture coordinates"}, + {TEXCO_NORM, "NORMAL", 0, "Normal", "Uses normal vector as texture coordinates"}, + {TEXCO_REFL, "REFLECTION", 0, "Reflection", "Uses reflection vector as texture coordinates"}, + {TEXCO_STRESS, "STRESS", 0, "Stress", "Uses the difference of edge lengths compared to original coordinates of the mesh"}, + {TEXCO_TANGENT, "TANGENT", 0, "Tangent", "Uses the optional tangent vector as texture coordinates"}, {0, NULL, 0, NULL, NULL}}; @@ -117,7 +118,8 @@ void RNA_api_material(StructRNA *srna) func= RNA_def_function(srna, "add_texture", "rna_Material_add_texture"); RNA_def_function_ui_description(func, "Add a texture to material's free texture slot."); - parm= RNA_def_pointer(func, "texture", "Texture", "", "Texture to add."); + parm= RNA_def_pointer(func, "texture", "Texture", "Texture", "Texture to add."); + RNA_def_property_flag(parm, PROP_REQUIRED); parm= RNA_def_enum(func, "texture_coordinates", prop_texture_coordinates_items, TEXCO_UV, "", "Source of texture coordinate information."); /* optional */ parm= RNA_def_enum(func, "map_to", prop_texture_mapto_items, MAP_COL, "", "Controls which material property the texture affects."); /* optional */ } |