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:
authorJoshua Leung <aligorith@gmail.com>2009-10-26 14:56:12 +0300
committerJoshua Leung <aligorith@gmail.com>2009-10-26 14:56:12 +0300
commit3f7f2b869c2da50df8d3a6399a357b3c3b668a70 (patch)
tree012009641cfd765c5197a935f156982488085339 /source/blender/makesrna/intern/rna_texture.c
parent32dd928ed6df59f1d0fb91b1f8942a799cada880 (diff)
Bugfix #19709: Influence and Mapping param in texture not yet animatable
Coded a 'path' getter for Texture Slots. This was a bit more involved than for other paths, since texture slots used the names of the textures assigned, which would be troublesome when a texture got used twice or more.
Diffstat (limited to 'source/blender/makesrna/intern/rna_texture.c')
-rw-r--r--source/blender/makesrna/intern/rna_texture.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c
index f49eb4122c5..f3e74bdd43a 100644
--- a/source/blender/makesrna/intern/rna_texture.c
+++ b/source/blender/makesrna/intern/rna_texture.c
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_types.h"
@@ -155,6 +156,47 @@ void rna_TextureSlot_update(bContext *C, PointerRNA *ptr)
}
}
+char *rna_TextureSlot_path(PointerRNA *ptr)
+{
+ MTex *mtex= ptr->data;
+
+ /* if there is ID-data, resolve the path using the index instead of by name,
+ * since the name used is the name of the texture assigned, but the texture
+ * may be used multiple times in the same stack
+ */
+ if (ptr->id.data) {
+ PointerRNA id_ptr;
+ PropertyRNA *prop;
+
+ /* find the 'textures' property of the ID-struct */
+ RNA_id_pointer_create(ptr->id.data, &id_ptr);
+ prop= RNA_struct_find_property(&id_ptr, "textures");
+
+ /* get an iterator for this property, and try to find the relevant index */
+ if (prop) {
+ CollectionPropertyIterator iter;
+ int index= 0;
+
+ RNA_property_collection_begin(ptr, prop, &iter);
+ for(index=0; iter.valid; RNA_property_collection_next(&iter), index++) {
+ if (iter.ptr.data == ptr->id.data)
+ break;
+ }
+ RNA_property_collection_end(&iter);
+
+ /* did we find it? */
+ if (iter.valid)
+ return BLI_sprintfN("textures[%d]", index);
+ }
+ }
+
+ /* this is a compromise for the remaining cases... */
+ if (mtex->tex)
+ return BLI_sprintfN("textures[\"%s\"]", mtex->tex->id.name+2);
+ else
+ return BLI_strdup("textures[0]");
+}
+
static int rna_TextureSlot_name_length(PointerRNA *ptr)
{
MTex *mtex= ptr->data;
@@ -414,6 +456,7 @@ static void rna_def_mtex(BlenderRNA *brna)
srna= RNA_def_struct(brna, "TextureSlot", NULL);
RNA_def_struct_sdna(srna, "MTex");
RNA_def_struct_ui_text(srna, "Texture Slot", "Texture slot defining the mapping and influence of a texture.");
+ RNA_def_struct_path_func(srna, "rna_TextureSlot_path");
RNA_def_struct_ui_icon(srna, ICON_TEXTURE_DATA);
prop= RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE);