Some more fixes for particle textures:

* Moving a texture slot didn't keep the moved slot active.
* Copy & paste for particle textures didn't work.
* New textures weren't freed properly.
This commit is contained in:
2011-02-13 12:35:26 +00:00
parent fed5393043
commit 7eb51a012b
3 changed files with 45 additions and 0 deletions

View File

@@ -366,6 +366,8 @@ static void fluid_free_settings(SPHFluidSettings *fluid)
void psys_free_settings(ParticleSettings *part)
{
MTex *mtex;
int a;
BKE_free_animdata(&part->id);
free_partdeflect(part->pd);
free_partdeflect(part->pd2);
@@ -377,6 +379,12 @@ void psys_free_settings(ParticleSettings *part)
boid_free_settings(part->boids);
fluid_free_settings(part->fluid);
for(a=0; a<MAX_MTEX; a++) {
mtex= part->mtex[a];
if(mtex && mtex->tex) mtex->tex->id.us--;
if(mtex) MEM_freeN(mtex);
}
}
void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int dynamics)

View File

@@ -779,6 +779,7 @@ void make_local_texture(Tex *tex)
World *wrld;
Lamp *la;
Brush *br;
ParticleSettings *pa;
int a, local=0, lib=0;
/* - only lib users: do nothing
@@ -841,6 +842,16 @@ void make_local_texture(Tex *tex)
}
br= br->id.next;
}
pa= bmain->particle.first;
while(pa) {
for(a=0; a<MAX_MTEX; a++) {
if(pa->mtex[a] && pa->mtex[a]->tex==tex) {
if(pa->id.lib) lib= 1;
else local= 1;
}
}
pa= pa->id.next;
}
if(local && lib==0) {
tex->id.lib= NULL;
@@ -901,6 +912,19 @@ void make_local_texture(Tex *tex)
}
br= br->id.next;
}
pa= bmain->particle.first;
while(pa) {
for(a=0; a<MAX_MTEX; a++) {
if(pa->mtex[a] && pa->mtex[a]->tex==tex) {
if(pa->id.lib==NULL) {
pa->mtex[a]->tex= texn;
texn->id.us++;
tex->id.us--;
}
}
}
pa= pa->id.next;
}
}
}
@@ -1079,6 +1103,9 @@ void set_active_mtex(ID *id, short act)
case ID_LA:
((Lamp *)id)->texact= act;
break;
case ID_PA:
((ParticleSettings *)id)->texact= act;
break;
}
}

View File

@@ -34,6 +34,7 @@
#include "DNA_material_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_particle_types.h"
#include "DNA_scene_types.h"
#include "DNA_space_types.h"
#include "DNA_world_types.h"
@@ -1110,6 +1111,9 @@ void copy_mtex_copybuf(ID *id)
mtex= &(((World *)id)->mtex[(int)((World *)id)->texact]);
// mtex= wrld->mtex[(int)wrld->texact]; // TODO
break;
case ID_PA:
mtex= &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
break;
}
if(mtex && *mtex) {
@@ -1140,6 +1144,9 @@ void paste_mtex_copybuf(ID *id)
mtex= &(((World *)id)->mtex[(int)((World *)id)->texact]);
// mtex= wrld->mtex[(int)wrld->texact]; // TODO
break;
case ID_PA:
mtex= &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
break;
}
if(mtex) {
@@ -1204,6 +1211,7 @@ static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op))
Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
Lamp *la= CTX_data_pointer_get_type(C, "lamp", &RNA_Lamp).data;
World *wo= CTX_data_pointer_get_type(C, "world", &RNA_World).data;
ParticleSystem *psys= CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data;
if (ma)
id = &ma->id;
@@ -1211,6 +1219,8 @@ static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op))
id = &la->id;
else if (wo)
id = &wo->id;
else if (psys)
id = &psys->part->id;
if (id==NULL)
return OPERATOR_CANCELLED;