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_lamp.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_lamp.c')
-rw-r--r--source/blender/makesrna/intern/rna_lamp.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c
index b8150ee3c7d..299bd37496b 100644
--- a/source/blender/makesrna/intern/rna_lamp.c
+++ b/source/blender/makesrna/intern/rna_lamp.c
@@ -64,30 +64,33 @@ static void rna_Lamp_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *pt
static PointerRNA rna_Lamp_active_texture_get(PointerRNA *ptr)
{
Lamp *la= (Lamp*)ptr->data;
- return rna_pointer_inherit_refine(ptr, &RNA_TextureSlot, la->mtex[(int)la->texact]);
+ Tex *tex;
+
+ tex= (la->mtex[(int)la->texact])? la->mtex[(int)la->texact]->tex: NULL;
+ return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex);
}
-static void rna_Lamp_active_texture_index_set(PointerRNA *ptr, int value)
+static void rna_Lamp_active_texture_set(PointerRNA *ptr, PointerRNA value)
{
Lamp *la= (Lamp*)ptr->data;
int act= la->texact;
- if(value == act || value < 0 || value >= MAX_MTEX)
- return;
+ if(la->mtex[act] && la->mtex[act]->tex)
+ id_us_min(&la->mtex[act]->tex->id);
- /* auto create/free mtex on activate/deactive, so we can edit
- * the texture pointer in the buttons UI. */
- if(la->mtex[act] && !la->mtex[act]->tex) {
+ if(value.data) {
+ if(!la->mtex[act]) {
+ la->mtex[act]= add_mtex();
+ la->mtex[act]->texco= TEXCO_GLOB;
+ }
+
+ la->mtex[act]->tex= value.data;
+ id_us_plus(&la->mtex[act]->tex->id);
+ }
+ else if(la->mtex[act]) {
MEM_freeN(la->mtex[act]);
la->mtex[act]= NULL;
}
-
- la->texact= value;
-
- if(!la->mtex[value]) {
- la->mtex[value]= add_mtex();
- la->mtex[value]->texco= TEXCO_GLOB;
- }
}
static StructRNA* rna_Lamp_refine(struct PointerRNA *ptr)
@@ -349,7 +352,8 @@ static void rna_def_lamp(BlenderRNA *brna)
RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
/* textures */
- rna_def_mtex_common(srna, "rna_Lamp_mtex_begin", "rna_Lamp_active_texture_get", "rna_Lamp_active_texture_index_set", "LampTextureSlot");
+ rna_def_mtex_common(srna, "rna_Lamp_mtex_begin", "rna_Lamp_active_texture_get",
+ "rna_Lamp_active_texture_set", "LampTextureSlot");
}
static void rna_def_lamp_falloff(StructRNA *srna)