Orange: tuesday sync with bf-blender
[blender.git] / source / blender / blenkernel / intern / effect.c
index acff6d80024622a20bd3c5fa08f634ad5437093a..17dbae4c0af2904f1e3bfaed1022e9cf4c6814df 100644 (file)
 #include <stdlib.h>
 
 #include "MEM_guardedalloc.h"
-#include "DNA_listBase.h"
+
+#include "DNA_curve_types.h"
 #include "DNA_effect_types.h"
-#include "DNA_object_types.h"
-#include "DNA_object_force.h"
+#include "DNA_group_types.h"
+#include "DNA_ipo_types.h"
+#include "DNA_key_types.h"
+#include "DNA_lattice_types.h"
+#include "DNA_listBase.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_material_types.h"
-#include "DNA_curve_types.h"
-#include "DNA_key_types.h"
+#include "DNA_object_types.h"
+#include "DNA_object_force.h"
 #include "DNA_texture_types.h"
 #include "DNA_scene_types.h"
-#include "DNA_lattice_types.h"
-#include "DNA_ipo_types.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_arithb.h"
@@ -326,42 +328,57 @@ typedef struct pEffectorCache {
        Object obcopy;  /* for restoring transformation data */
 } pEffectorCache;
 
+static void add_to_effectorcache(ListBase *lb, Object *ob, Object *obsrc)
+{
+       pEffectorCache *ec;
+       PartDeflect *pd= ob->pd;
+                       
+       if(pd->forcefield == PFIELD_GUIDE) {
+               if(ob->type==OB_CURVE && obsrc->type==OB_MESH) {        /* guides only do mesh particles */
+                       Curve *cu= ob->data;
+                       if(cu->flag & CU_PATH) {
+                               if(cu->path==NULL || cu->path->data==NULL)
+                                       makeDispListCurveTypes(ob, 0);
+                               if(cu->path && cu->path->data) {
+                                       ec= MEM_callocN(sizeof(pEffectorCache), "effector cache");
+                                       ec->ob= ob;
+                                       BLI_addtail(lb, ec);
+                               }
+                       }
+               }
+       }
+       else if(pd->forcefield) {
+               ec= MEM_callocN(sizeof(pEffectorCache), "effector cache");
+               ec->ob= ob;
+               BLI_addtail(lb, ec);
+       }
+}
 
 /* returns ListBase handle with objects taking part in the effecting */
-ListBase *pdInitEffectors(Object *obsrc)
+ListBase *pdInitEffectors(Object *obsrc, Group *group)
 {
        static ListBase listb={NULL, NULL};
        pEffectorCache *ec;
-       unsigned int layer= obsrc->lay;
        Base *base;
-
-       for(base = G.scene->base.first; base; base= base->next) {
-               if( (base->lay & layer) && base->object->pd && base->object!=obsrc) {
-                       Object *ob= base->object;
-                       PartDeflect *pd= ob->pd;
-                       
-                       if(pd->forcefield == PFIELD_GUIDE) {
-                               if(ob->type==OB_CURVE && obsrc->type==OB_MESH) {        /* guides only do mesh particles */
-                                       Curve *cu= ob->data;
-                                       if(cu->flag & CU_PATH) {
-                                               if(cu->path==NULL || cu->path->data==NULL)
-                                                       makeDispListCurveTypes(ob, 0);
-                                               if(cu->path && cu->path->data) {
-                                                       ec= MEM_callocN(sizeof(pEffectorCache), "effector cache");
-                                                       ec->ob= ob;
-                                                       BLI_addtail(&listb, ec);
-                                               }
-                                       }
-                               }
+       unsigned int layer= obsrc->lay;
+       
+       if(group) {
+               GroupObject *go;
+               
+               for(go= group->gobject.first; go; go= go->next) {
+                       if( (go->ob->lay & layer) && go->ob->pd && go->ob!=obsrc) {
+                               add_to_effectorcache(&listb, go->ob, obsrc);
                        }
-                       else if(pd->forcefield) {
-                               ec= MEM_callocN(sizeof(pEffectorCache), "effector cache");
-                               ec->ob= ob;
-                               BLI_addtail(&listb, ec);
+               }
+       }
+       else {
+               for(base = G.scene->base.first; base; base= base->next) {
+                       if( (base->lay & layer) && base->object->pd && base->object!=obsrc) {
+                               add_to_effectorcache(&listb, base->object, obsrc);
                        }
                }
        }
-
+       
        /* make a full copy */
        for(ec= listb.first; ec; ec= ec->next) {
                ec->obcopy= *(ec->ob);
@@ -1663,7 +1680,7 @@ void build_particle_system(Object *ob)
        }
        
        /* get the effectors */
-       effectorbase= pdInitEffectors(ob);
+       effectorbase= pdInitEffectors(ob, paf->group);
        
        /* init geometry, return is 6 x float * me->totvert in size */
        vertexcosnos= (VeNoCo *)mesh_get_mapped_verts_nors(ob);