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:
-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
-rw-r--r--source/blender/src/editobject.c14
4 files changed, 70 insertions, 24 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;
diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c
index e6edb472fc3..6084ece8c6e 100644
--- a/source/blender/src/editobject.c
+++ b/source/blender/src/editobject.c
@@ -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