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:
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/anim.c47
-rw-r--r--source/blender/blenkernel/intern/effect.c85
-rw-r--r--source/blender/blenkernel/intern/group.c229
-rw-r--r--source/blender/blenkernel/intern/scene.c6
-rw-r--r--source/blender/blenkernel/intern/softbody.c2
5 files changed, 104 insertions, 265 deletions
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index b8178dd98cd..b448816589f 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -40,14 +40,15 @@
#include "BLI_arithb.h"
#include "DNA_listBase.h"
-#include "DNA_object_types.h"
#include "DNA_curve_types.h"
-#include "DNA_key_types.h"
-#include "DNA_view3d_types.h"
#include "DNA_effect_types.h"
+#include "DNA_group_types.h"
+#include "DNA_key_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "DNA_view3d_types.h"
#include "BKE_DerivedMesh.h"
#include "BKE_global.h"
@@ -271,7 +272,7 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir) /* returns OK
return 1;
}
-static Object *new_dupli_object(ListBase *lb, Object *ob, Object *par)
+static Object *new_dupli_object(ListBase *lb, Object *ob, Object *par, int clearpar)
{
Object *newob;
@@ -284,7 +285,7 @@ static Object *new_dupli_object(ListBase *lb, Object *ob, Object *par)
/* only basis-ball gets displist */
if(newob->type==OB_MBALL) newob->disp.first= newob->disp.last= NULL;
- if(ob!=par) { // dupliverts, particle
+ if(clearpar) { // dupliverts, particle
newob->parent= NULL;
newob->track= NULL;
}
@@ -293,7 +294,22 @@ static Object *new_dupli_object(ListBase *lb, Object *ob, Object *par)
return newob;
}
-void frames_duplilist(Object *ob)
+static void group_duplilist(Object *ob)
+{
+ Object *newob;
+ GroupObject *go;
+ float mat[4][4];
+
+ if(ob->dup_group==NULL) return;
+
+ for(go= ob->dup_group->gobject.first; go; go= go->next) {
+ newob= new_dupli_object(&duplilist, go->ob, ob, 0);
+ Mat4CpyMat4(mat, newob->obmat);
+ Mat4MulMat4(newob->obmat, mat, ob->obmat);
+ }
+}
+
+static void frames_duplilist(Object *ob)
{
extern int enable_cu_speed; /* object.c */
Object *newob, copyob;
@@ -315,7 +331,7 @@ void frames_duplilist(Object *ob)
else ok= 0;
}
if(ok) {
- newob= new_dupli_object(&duplilist, ob, ob);
+ newob= new_dupli_object(&duplilist, ob, ob, 0);
do_ob_ipo(newob);
where_is_object_time(newob, (float)G.scene->r.cfra);
@@ -343,7 +359,7 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
VecSubf(vec, vec, vdd->pmat[3]);
VecAddf(vec, vec, vdd->ob->obmat[3]);
- newob= new_dupli_object(&duplilist, vdd->ob, vdd->par);
+ newob= new_dupli_object(&duplilist, vdd->ob, vdd->par, 1);
VECCOPY(newob->obmat[3], vec);
if(vdd->par->transflag & OB_DUPLIROT) {
@@ -359,7 +375,7 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
}
-void vertex_duplilist(Scene *sce, Object *par)
+static void vertex_duplilist(Scene *sce, Object *par)
{
Object *ob;
Base *base;
@@ -420,8 +436,7 @@ void vertex_duplilist(Scene *sce, Object *par)
dm->release(dm);
}
-
-void particle_duplilist(Scene *sce, Object *par, PartEff *paf)
+static void particle_duplilist(Scene *sce, Object *par, PartEff *paf)
{
Object *ob, *newob;
Base *base;
@@ -462,7 +477,7 @@ void particle_duplilist(Scene *sce, Object *par, PartEff *paf)
mtime= pa->time+pa->lifetime;
for(ctime= pa->time; ctime<mtime; ctime+=paf->staticstep) {
- newob= new_dupli_object(&duplilist, ob, par);
+ newob= new_dupli_object(&duplilist, ob, par, 1);
/* make sure hair grows until the end.. */
if(ctime>pa->time+pa->lifetime) ctime= pa->time+pa->lifetime;
@@ -494,7 +509,7 @@ void particle_duplilist(Scene *sce, Object *par, PartEff *paf)
if((paf->flag & PAF_DIED)==0 && ctime > pa->time+pa->lifetime) continue;
//if(ctime < pa->time+pa->lifetime) {
- newob= new_dupli_object(&duplilist, ob, par);
+ newob= new_dupli_object(&duplilist, ob, par, 1);
/* to give ipos in object correct offset */
where_is_object_time(newob, ctime-pa->time);
@@ -523,7 +538,6 @@ void particle_duplilist(Scene *sce, Object *par, PartEff *paf)
}
}
-
void free_duplilist()
{
Object *ob;
@@ -551,7 +565,10 @@ void make_duplilist(Scene *sce, Object *ob)
font_duplilist(ob);
}
}
- else if(ob->transflag & OB_DUPLIFRAMES) frames_duplilist(ob);
+ else if(ob->transflag & OB_DUPLIFRAMES)
+ frames_duplilist(ob);
+ else if(ob->transflag & OB_DUPLIGROUP)
+ group_duplilist(ob);
}
}
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index b2b52cfda06..e2582c5d86c 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -36,19 +36,21 @@
#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);
@@ -1667,7 +1684,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);
diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c
index 65c4ed42e03..7405f16d9c0 100644
--- a/source/blender/blenkernel/intern/group.c
+++ b/source/blender/blenkernel/intern/group.c
@@ -1,19 +1,12 @@
-/* group.c sept 2000
- * - cleaned up mar-01 nzc
- *
- *
- * ton roosendaal
+/*
* $Id$
*
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ * ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -31,7 +24,7 @@
*
* Contributor(s): none yet.
*
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * ***** END GPL LICENSE BLOCK *****
*/
#include <stdio.h>
@@ -57,22 +50,8 @@
#include <config.h>
#endif
-void free_object_key(ObjectKey *ok)
-{
- if(ok->ipo) ok->ipo->id.us--;
-
- MEM_freeN(ok);
-}
-
void free_group_object(GroupObject *go)
{
- ObjectKey *ok;
-
- while(go->okey.first) {
- ok= go->okey.first;
- BLI_remlink(&go->okey, ok);
- free_object_key(ok);
- }
MEM_freeN(go);
}
@@ -82,14 +61,11 @@ void free_group(Group *group)
/* don't free group itself */
GroupObject *go;
- BLI_freelistN(&group->gkey);
-
while(group->gobject.first) {
go= group->gobject.first;
BLI_remlink(&group->gobject, go);
free_group_object(go);
}
-
}
Group *add_group()
@@ -100,97 +76,16 @@ Group *add_group()
return group;
}
-/* assumes 'ok' is unitialized */
-void object_to_obkey(Object *ob, ObjectKey *ok)
-{
- ok->partype= ob->partype;
- ok->par1= ob->par1;
- ok->par2= ob->par2;
- ok->par3= ob->par3;
-
- ok->parent= ob->parent;
- ok->track= ob->track;
-
- ok->ipo= copy_ipo(ob->ipo);
-
- memcpy(ok->loc, ob->loc, 7*3*sizeof(float));
- memcpy(ok->quat, ob->quat, 2*4*sizeof(float));
- memcpy(ok->obmat, ob->obmat, 3*4*4*sizeof(float));
-
- ok->lay= ob->lay;
- ok->transflag= ob->transflag;
- ok->trackflag= ob->transflag;
- ok->upflag= ob->upflag;
- ok->sf= ob->sf;
- ok->ctime= ob->ctime;
-
-
-}
-
-void obkey_to_object(ObjectKey *ok, Object *ob)
-{
- ob->partype= ok->partype;
- ob->par1= ok->par1;
- ob->par2= ok->par2;
- ob->par3= ok->par3;
-
- ob->parent= ok->parent;
- ob->track= ok->track;
-
- /* pretty tricky, this makes ob->ipo blocks with users 'hanging around' */
- if(ob->ipo) {
- free_libblock_us(&G.main->ipo, ob->ipo);
- }
- ob->ipo= copy_ipo(ok->ipo);
-
- memcpy(ob->loc, ok->loc, 7*3*sizeof(float));
- memcpy(ob->quat, ok->quat, 2*4*sizeof(float));
- memcpy(ob->obmat, ok->obmat, 3*4*4*sizeof(float));
-
- ob->lay= ok->lay;
- ob->transflag= ok->transflag;
- ob->trackflag= ok->transflag;
- ob->upflag= ok->upflag;
- ob->sf= ok->sf;
- ob->ctime= ok->ctime;
-}
-
-/* current ob position */
-void add_object_key(GroupObject *go, GroupKey *gk)
-{
- ObjectKey *ok;
-
- /* check if there already is a key */
- ok= go->okey.first;
- while(ok) {
- if(ok->gkey == gk) break;
- ok= ok->next;
- }
-
- if(ok) {
- BLI_remlink(&go->okey, ok);
- free_object_key(ok);
- }
- ok= MEM_mallocN(sizeof(ObjectKey), "objectkey");
- ok->gkey= gk;
-
- object_to_obkey(go->ob, ok);
-
- BLI_addtail(&go->okey, ok);
-
-}
-
/* external */
void add_to_group(Group *group, Object *ob)
{
GroupObject *go;
- GroupKey *gk;
+
+ if(group==NULL || ob==NULL) return;
/* check if the object has been added already */
- go= group->gobject.first;
- while(go) {
+ for(go= group->gobject.first; go; go= go->next) {
if(go->ob==ob) return;
- go= go->next;
}
go= MEM_callocN(sizeof(GroupObject), "groupobject");
@@ -198,18 +93,13 @@ void add_to_group(Group *group, Object *ob)
go->ob= ob;
- /* keys? */
- gk= group->gkey.first;
- while(gk) {
- add_object_key(go, gk);
- gk= gk->next;
- }
}
void rem_from_group(Group *group, Object *ob)
{
GroupObject *go, *gon;
- ObjectKey *ok;
+
+ if(group==NULL || ob==NULL) return;
go= group->gobject.first;
while(go) {
@@ -218,116 +108,31 @@ void rem_from_group(Group *group, Object *ob)
BLI_remlink(&group->gobject, go);
free_group_object(go);
}
- else {
- ok= go->okey.first;
- while(ok) {
- if(ok->parent==ob) ok->parent= NULL;
- if(ok->track==ob) ok->track= NULL;
- ok= ok->next;
- }
- }
go= gon;
}
}
-void add_group_key(Group *group)
+int object_in_group(Object *ob, Group *group)
{
GroupObject *go;
- GroupKey *gk;
- int nr=10;
- extern char colname_array[][20]; /* material.c */
-
- gk= group->gkey.first;
- while(gk) {
- nr++;
- gk= gk->next;
- }
-
- gk= MEM_callocN(sizeof(GroupKey), "groupkey");
- BLI_addtail(&group->gkey, gk);
- strcpy(gk->name, colname_array[ nr % 120 ]);
-
- go= group->gobject.first;
- while(go) {
- add_object_key(go, gk);
- go= go->next;
- }
-
- group->active= gk;
-}
-
-void set_object_key(Object *ob, ObjectKey *ok)
-{
- obkey_to_object(ok, ob);
-}
-
-void set_group_key(Group *group)
-{
- /* sets active */
- GroupObject *go;
- ObjectKey *ok;
- if(group->active==NULL) return;
+ if(group==NULL || ob==NULL) return 0;
- go= group->gobject.first;
- while(go) {
- ok= go->okey.first;
- while(ok) {
- if(ok->gkey==group->active) {
- set_object_key(go->ob, ok);
- break;
- }
- ok= ok->next;
- }
- go= go->next;
+ for(go= group->gobject.first; go; go= go->next) {
+ if(go->ob==ob)
+ return 1;
}
-
+ return 0;
}
Group *find_group(Object *ob)
{
Group *group= G.main->group.first;
- GroupObject *go;
while(group) {
-
- go= group->gobject.first;
- while(go) {
- if(go->ob==ob) return group;
- go= go->next;
- }
+ if(object_in_group(ob, group))
+ return group;
group= group->id.next;
}
return NULL;
}
-
-void set_group_key_name(Group *group, char *name)
-{
- GroupKey *gk;
-
- if(group==NULL) return;
-
- gk= group->gkey.first;
- while(gk) {
- if(strcmp(name, gk->name)==0) break;
- gk= gk->next;
- }
-
- if(gk) {
- group->active= gk;
- set_group_key(group);
- }
-}
-
-void set_group_key_frame(Group *group, float frame)
-{
- GroupObject *go;
-
- if(group==NULL) return;
-
- go= group->gobject.first;
- while(go) {
- where_is_object_time(go->ob, frame);
- go= go->next;
- }
-}
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 53b4a09d89b..2cd387d7d93 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -220,16 +220,16 @@ Scene *add_scene(char *name)
return sce;
}
-int object_in_scene(Object *ob, Scene *sce)
+Base *object_in_scene(Object *ob, Scene *sce)
{
Base *base;
base= sce->base.first;
while(base) {
- if(base->object == ob) return 1;
+ if(base->object == ob) return base;
base= base->next;
}
- return 0;
+ return NULL;
}
void set_scene_bg(Scene *sce)
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 5b98a3bf794..d81c0e94944 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -546,7 +546,7 @@ static void softbody_calc_forces(Object *ob, float forcetime)
/* check! */
do_deflector= is_there_deflection(ob->lay);
- do_effector= pdInitEffectors(ob);
+ do_effector= pdInitEffectors(ob, NULL);
iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */
bproot= sb->bpoint; /* need this for proper spring addressing */