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-07-28 22:54:02 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-28 22:54:02 +0400
commit801d44a09efd98a2345dd8b5938b4d811bbf68fc (patch)
treec2b1330c44c790df0147ee73275bf818cec4930a /source/blender/makesrna/intern/rna_world.c
parent9a874da36c2e9eb5a4d48c8c7bbce3db48f882a9 (diff)
2.5: Materials and textures can now be assigned again
even if not slot for them is available.
Diffstat (limited to 'source/blender/makesrna/intern/rna_world.c')
-rw-r--r--source/blender/makesrna/intern/rna_world.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c
index 8beaa855201..f23b893539d 100644
--- a/source/blender/makesrna/intern/rna_world.c
+++ b/source/blender/makesrna/intern/rna_world.c
@@ -66,31 +66,33 @@ static void rna_World_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *p
static PointerRNA rna_World_active_texture_get(PointerRNA *ptr)
{
World *wo= (World*)ptr->data;
+ Tex *tex;
- return rna_pointer_inherit_refine(ptr, &RNA_TextureSlot, wo->mtex[(int)wo->texact]);
+ tex= (wo->mtex[(int)wo->texact])? wo->mtex[(int)wo->texact]->tex: NULL;
+ return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex);
}
-static void rna_World_active_texture_index_set(PointerRNA *ptr, int value)
+static void rna_World_active_texture_set(PointerRNA *ptr, PointerRNA value)
{
World *wo= (World*)ptr->data;
int act= wo->texact;
- if(value == act || value < 0 || value >= MAX_MTEX)
- return;
-
- /* auto create/free mtex on activate/deactive, so we can edit
- * the texture pointer in the buttons UI. */
- if(wo->mtex[act] && !wo->mtex[act]->tex) {
+ if(wo->mtex[act] && wo->mtex[act]->tex)
+ id_us_min(&wo->mtex[act]->tex->id);
+
+ if(value.data) {
+ if(!wo->mtex[act]) {
+ wo->mtex[act]= add_mtex();
+ wo->mtex[act]->texco= TEXCO_VIEW;
+ }
+
+ wo->mtex[act]->tex= value.data;
+ id_us_plus(&wo->mtex[act]->tex->id);
+ }
+ else if(wo->mtex[act]) {
MEM_freeN(wo->mtex[act]);
wo->mtex[act]= NULL;
}
-
- wo->texact= value;
-
- if(!wo->mtex[value]) {
- wo->mtex[value]= add_mtex();
- wo->mtex[value]->texco= TEXCO_VIEW;
- }
}
#else
@@ -407,7 +409,8 @@ void RNA_def_world(BlenderRNA *brna)
RNA_def_struct_ui_icon(srna, ICON_WORLD_DATA);
rna_def_animdata_common(srna);
- rna_def_mtex_common(srna, "rna_World_mtex_begin", "rna_World_active_texture_get", "rna_World_active_texture_index_set", "WorldTextureSlot");
+ rna_def_mtex_common(srna, "rna_World_mtex_begin", "rna_World_active_texture_get",
+ "rna_World_active_texture_set", "WorldTextureSlot");
/* colors */
prop= RNA_def_property(srna, "horizon_color", PROP_FLOAT, PROP_COLOR);