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>2008-02-27 20:04:58 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-02-27 20:04:58 +0300
commitfc9a6642270fdc36b2e72fadec53cb13c4d01e99 (patch)
treed4480cfdce8bf3e9ae59bdcffaad91a669d0a542 /source/blender/blenkernel
parent9620bccf5b1146e5cc660260a2a4574669644941 (diff)
Bugfix: Copy Modifiers with particle systems crashed, it didn't copy
the particle systems.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_object.h4
-rw-r--r--source/blender/blenkernel/intern/modifier.c1
-rw-r--r--source/blender/blenkernel/intern/object.c75
3 files changed, 57 insertions, 23 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 0a4c9a04815..903ca7a66aa 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -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);
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index f67dd7c81fe..cc54ced4b4d 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -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 */
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 16934783a07..3f1515f146a 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -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;
-
- BLI_remlink(&ob->particlesystem,psys);
+ object_free_particlesystems(ob);
- 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;