Bugfix: Copy Modifiers with particle systems crashed, it didn't copy
the particle systems.
This commit is contained in:
@@ -51,6 +51,10 @@ void clear_workob(void);
|
||||
void copy_baseflags(void);
|
||||
void copy_objectflags(void);
|
||||
struct SoftBody *copy_softbody(struct SoftBody *sb);
|
||||
void copy_object_particlesystems(struct Object *obn, struct Object *ob);
|
||||
void copy_object_softbody(struct Object *obn, struct Object *ob);
|
||||
void object_free_particlesystems(struct Object *ob);
|
||||
void object_free_softbody(struct Object *ob);
|
||||
void update_base_layer(struct Object *ob);
|
||||
|
||||
void free_object(struct Object *ob);
|
||||
|
||||
@@ -5412,6 +5412,7 @@ static void particleSystemModifier_copyData(ModifierData *md, ModifierData *targ
|
||||
ParticleSystemModifierData *tpsmd= (ParticleSystemModifierData*) target;
|
||||
|
||||
tpsmd->dm = 0;
|
||||
tpsmd->totdmvert = tpsmd->totdmedge = tpsmd->totdmface = 0;
|
||||
//tpsmd->facepa = 0;
|
||||
tpsmd->flag = psmd->flag;
|
||||
/* need to keep this to recognise a bit later in copy_object */
|
||||
|
||||
@@ -157,6 +157,25 @@ void update_base_layer(Object *ob)
|
||||
}
|
||||
}
|
||||
|
||||
void object_free_particlesystems(Object *ob)
|
||||
{
|
||||
while(ob->particlesystem.first){
|
||||
ParticleSystem *psys = ob->particlesystem.first;
|
||||
|
||||
BLI_remlink(&ob->particlesystem,psys);
|
||||
|
||||
psys_free(ob,psys);
|
||||
}
|
||||
}
|
||||
|
||||
void object_free_softbody(Object *ob)
|
||||
{
|
||||
if(ob->soft) {
|
||||
sbFree(ob->soft);
|
||||
ob->soft= NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void object_free_modifiers(Object *ob)
|
||||
{
|
||||
while (ob->modifiers.first) {
|
||||
@@ -168,13 +187,10 @@ void object_free_modifiers(Object *ob)
|
||||
}
|
||||
|
||||
/* particle modifiers were freed, so free the particlesystems as well */
|
||||
while(ob->particlesystem.first){
|
||||
ParticleSystem *psys = ob->particlesystem.first;
|
||||
object_free_particlesystems(ob);
|
||||
|
||||
BLI_remlink(&ob->particlesystem,psys);
|
||||
|
||||
psys_free(ob,psys);
|
||||
}
|
||||
/* same for softbody */
|
||||
object_free_softbody(ob);
|
||||
}
|
||||
|
||||
/* here we will collect all local displist stuff */
|
||||
@@ -1034,6 +1050,35 @@ ParticleSystem *copy_particlesystem(ParticleSystem *psys)
|
||||
return psysn;
|
||||
}
|
||||
|
||||
void copy_object_particlesystems(Object *obn, Object *ob)
|
||||
{
|
||||
ParticleSystemModifierData *psmd;
|
||||
ParticleSystem *psys, *npsys;
|
||||
ModifierData *md;
|
||||
|
||||
obn->particlesystem.first= obn->particlesystem.last= NULL;
|
||||
for(psys=ob->particlesystem.first; psys; psys=psys->next) {
|
||||
npsys= copy_particlesystem(psys);
|
||||
|
||||
BLI_addtail(&obn->particlesystem, npsys);
|
||||
|
||||
/* need to update particle modifiers too */
|
||||
for(md=obn->modifiers.first; md; md=md->next) {
|
||||
if(md->type==eModifierType_ParticleSystem) {
|
||||
psmd= (ParticleSystemModifierData*)md;
|
||||
if(psmd->psys==psys)
|
||||
psmd->psys= npsys;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void copy_object_softbody(Object *obn, Object *ob)
|
||||
{
|
||||
if(ob->soft)
|
||||
obn->soft= copy_softbody(ob->soft);
|
||||
}
|
||||
|
||||
static void copy_object_pose(Object *obn, Object *ob)
|
||||
{
|
||||
bPoseChannel *chan;
|
||||
@@ -1077,7 +1122,6 @@ Object *copy_object(Object *ob)
|
||||
{
|
||||
Object *obn;
|
||||
ModifierData *md;
|
||||
ParticleSystem *psys;
|
||||
int a;
|
||||
|
||||
obn= copy_libblock(ob);
|
||||
@@ -1144,22 +1188,7 @@ Object *copy_object(Object *ob)
|
||||
}
|
||||
}
|
||||
|
||||
obn->particlesystem.first= obn->particlesystem.last= NULL;
|
||||
for(psys=ob->particlesystem.first; psys; psys=psys->next) {
|
||||
ParticleSystemModifierData *psmd;
|
||||
ParticleSystem *npsys= copy_particlesystem(psys);
|
||||
|
||||
BLI_addtail(&obn->particlesystem, npsys);
|
||||
|
||||
/* need to update particle modifiers too */
|
||||
for(md=obn->modifiers.first; md; md=md->next) {
|
||||
if(md->type==eModifierType_ParticleSystem) {
|
||||
psmd= (ParticleSystemModifierData*)md;
|
||||
if(psmd->psys==psys)
|
||||
psmd->psys= npsys;
|
||||
}
|
||||
}
|
||||
}
|
||||
copy_object_particlesystems(obn, ob);
|
||||
|
||||
obn->derivedDeform = NULL;
|
||||
obn->derivedFinal = NULL;
|
||||
|
||||
@@ -3079,7 +3079,7 @@ static void copymenu_modifiers(Object *ob)
|
||||
for (i=eModifierType_None+1; i<NUM_MODIFIER_TYPES; i++) {
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(i);
|
||||
|
||||
if (ELEM(i, eModifierType_Hook, eModifierType_Softbody)) continue;
|
||||
if(ELEM3(i, eModifierType_Hook, eModifierType_Softbody, eModifierType_ParticleInstance)) continue;
|
||||
|
||||
if ( (mti->flags&eModifierTypeFlag_AcceptsCVs) ||
|
||||
(ob->type==OB_MESH && (mti->flags&eModifierTypeFlag_AcceptsMesh))) {
|
||||
@@ -3109,6 +3109,9 @@ static void copymenu_modifiers(Object *ob)
|
||||
BLI_addtail(&base->object->modifiers, nmd);
|
||||
}
|
||||
}
|
||||
|
||||
copy_object_particlesystems(base->object, ob);
|
||||
copy_object_softbody(base->object, ob);
|
||||
} else {
|
||||
/* copy specific types */
|
||||
ModifierData *md, *mdn;
|
||||
@@ -3132,6 +3135,15 @@ static void copymenu_modifiers(Object *ob)
|
||||
modifier_copyData(md, mdn);
|
||||
}
|
||||
}
|
||||
|
||||
if(event == eModifierType_ParticleSystem) {
|
||||
object_free_particlesystems(base->object);
|
||||
copy_object_particlesystems(base->object, ob);
|
||||
}
|
||||
else if(event == eModifierType_Softbody) {
|
||||
object_free_softbody(base->object);
|
||||
copy_object_softbody(base->object, ob);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user