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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-06-04 03:22:43 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-06-04 03:22:43 +0400
commit4df00c670ef2e03d3dc55b67594e96cc49766831 (patch)
tree0ea3b4f66d5cac7952e36704fedf3c5ac7bbe81b /source/blender/makesrna/intern/rna_texture.c
parenta8f69a7f5cf59943b244126f428d1c12ca7e61af (diff)
RNA:
* Added a MaterialSlot collection in Object rather than giving the list of materials immediately. This should more correctly reflect how this data is organized, even though there is no equivalent C struct. * Added name properties to MaterialSlot/TextureSlot/ParticleSystem.
Diffstat (limited to 'source/blender/makesrna/intern/rna_texture.c')
-rw-r--r--source/blender/makesrna/intern/rna_texture.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c
index be97fd863f5..1d8a63bf83a 100644
--- a/source/blender/makesrna/intern/rna_texture.c
+++ b/source/blender/makesrna/intern/rna_texture.c
@@ -23,6 +23,7 @@
*/
#include <float.h>
+#include <stdio.h>
#include <stdlib.h>
#include "RNA_define.h"
@@ -30,8 +31,11 @@
#include "rna_internal.h"
+#include "DNA_brush_types.h"
+#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
#include "DNA_texture_types.h"
+#include "DNA_world_types.h"
#ifdef RNA_RUNTIME
@@ -71,6 +75,50 @@ StructRNA *rna_Texture_refine(struct PointerRNA *ptr)
}
}
+static int rna_texture_slot_index(PointerRNA *ptr)
+{
+ ID *id= ptr->id.data;
+ MTex **mtex;
+ int a;
+
+ if(id) {
+ switch(GS(id->name)) {
+ case ID_MA: mtex= ((Material*)id)->mtex; break;
+ case ID_WO: mtex= ((World*)id)->mtex; break;
+ case ID_LA: mtex= ((Lamp*)id)->mtex; break;
+ case ID_BR: mtex= ((Brush*)id)->mtex; break;
+ default: return 0;
+ }
+
+ for(a=0; a<MAX_MTEX; a++)
+ if(mtex[a] == ptr->data)
+ return a;
+ }
+
+ return 0;
+}
+
+static int rna_TextureSlot_name_length(PointerRNA *ptr)
+{
+ MTex *mtex= ptr->data;
+
+ if(mtex->tex)
+ return strlen(mtex->tex->id.name+2) + 10;
+
+ return 10;
+}
+
+static void rna_TextureSlot_name_get(PointerRNA *ptr, char *str)
+{
+ MTex *mtex= ptr->data;
+ int index= rna_texture_slot_index(ptr);
+
+ sprintf(str, "%d: ", index+1);
+
+ if(mtex->tex)
+ strcat(str, mtex->tex->id.name+2);
+}
+
#else
static void rna_def_color_ramp_element(BlenderRNA *brna)
@@ -190,6 +238,12 @@ static void rna_def_mtex(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Texture", "Texture datablock used by this texture slot.");
+ prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_funcs(prop, "rna_TextureSlot_name_get", "rna_TextureSlot_name_length", NULL);
+ RNA_def_property_ui_text(prop, "Name", "Texture slot name.");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_struct_name_property(srna, prop);
+
/* mapping */
prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_VECTOR);
RNA_def_property_float_sdna(prop, NULL, "ofs");