[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24088] trunk/blender/source/blender/ makesrna/intern: Bugfix #19709: Influence and Mapping param in texture not yet animatable
Joshua Leung
aligorith at gmail.com
Mon Oct 26 12:56:13 CET 2009
Revision: 24088
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24088
Author: aligorith
Date: 2009-10-26 12:56:12 +0100 (Mon, 26 Oct 2009)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/source/blender/makesrna/intern/rna_internal.h
trunk/blender/source/blender/makesrna/intern/rna_texture.c
Modified: trunk/blender/source/blender/makesrna/intern/rna_internal.h
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_internal.h 2009-10-26 11:43:27 UTC (rev 24087)
+++ trunk/blender/source/blender/makesrna/intern/rna_internal.h 2009-10-26 11:56:12 UTC (rev 24088)
@@ -199,6 +199,8 @@
void rna_Mesh_update_draw(struct bContext *C, struct PointerRNA *ptr);
void rna_TextureSlot_update(struct bContext *C, struct PointerRNA *ptr);
+char *rna_TextureSlot_path(struct PointerRNA *ptr);
+
/* API functions */
void RNA_api_action(StructRNA *srna);
Modified: trunk/blender/source/blender/makesrna/intern/rna_texture.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_texture.c 2009-10-26 11:43:27 UTC (rev 24087)
+++ trunk/blender/source/blender/makesrna/intern/rna_texture.c 2009-10-26 11:56:12 UTC (rev 24088)
@@ -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 @@
}
}
+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 @@
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);
More information about the Bf-blender-cvs
mailing list