diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_bullet.h | 43 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/bullet.c | 62 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 21 |
4 files changed, 129 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_bullet.h b/source/blender/blenkernel/BKE_bullet.h new file mode 100644 index 00000000000..1c3bb175d66 --- /dev/null +++ b/source/blender/blenkernel/BKE_bullet.h @@ -0,0 +1,43 @@ +/** + * + * $Id$ + * + * ***** 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ +#ifndef BKE_BULLET_H +#define BKE_BULLET_H + +struct BulletSoftBody; + + +/* allocates and initializes general main data */ +extern struct BulletSoftBody *bsbNew(void); + +/* frees internal data and softbody itself */ +extern void bsbFree(struct BulletSoftBody *sb); + +#endif + diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 116a59fa97e..ab76fc922ea 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -41,6 +41,7 @@ struct Camera; struct BoundBox; struct View3D; struct SoftBody; +struct BulletSoftBody; struct Group; struct bAction; @@ -48,10 +49,12 @@ void clear_workob(void); void copy_baseflags(void); void copy_objectflags(void); struct SoftBody *copy_softbody(struct SoftBody *sb); +struct BulletSoftBody *copy_bulletsoftbody(struct BulletSoftBody *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 object_free_bulletsoftbody(struct Object *ob); void update_base_layer(struct Object *ob); void free_object(struct Object *ob); diff --git a/source/blender/blenkernel/intern/bullet.c b/source/blender/blenkernel/intern/bullet.c new file mode 100644 index 00000000000..8e075669819 --- /dev/null +++ b/source/blender/blenkernel/intern/bullet.c @@ -0,0 +1,62 @@ +/* + * + * $Id$ + * + * ***** 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) Blender Foundation + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "MEM_guardedalloc.h" + +/* types */ +#include "DNA_object_force.h" /* here is the softbody struct */ + +#include "BKE_bullet.h" + + +/* ************ Object level, exported functions *************** */ + +/* allocates and initializes general main data */ +BulletSoftBody *bsbNew(void) +{ + BulletSoftBody *bsb; + + bsb= MEM_callocN(sizeof(BulletSoftBody), "bulletsoftbody"); + + bsb->flag = OB_BSB_SHAPE_MATCHING; + bsb->linStiff = 0.5f; + bsb->angStiff = 1.0f; + bsb->volume = 1.0f; + return bsb; +} + +/* frees all */ +void bsbFree(BulletSoftBody *bsb) +{ + /* no internal data yet */ + MEM_freeN(bsb); +} + + diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 7b53d770861..2dfa849fc43 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -179,6 +179,14 @@ void object_free_softbody(Object *ob) } } +void object_free_bulletsoftbody(Object *ob) +{ + if(ob->bsoft) { + sbFree(ob->bsoft); + ob->bsoft= NULL; + } +} + void object_free_modifiers(Object *ob) { while (ob->modifiers.first) { @@ -269,6 +277,7 @@ void free_object(Object *ob) MEM_freeN(ob->pd); } if(ob->soft) sbFree(ob->soft); + if(ob->bsoft) bsbFree(ob->bsoft); if(ob->gpulamp.first) GPU_lamp_free(ob); } @@ -1047,6 +1056,17 @@ SoftBody *copy_softbody(SoftBody *sb) return sbn; } +BulletSoftBody *copy_bulletsoftbody(BulletSoftBody *bsb) +{ + BulletSoftBody *bsbn; + + if (bsb == NULL) + return NULL; + bsbn = MEM_dupallocN(bsb); + /* no pointer in this structure yet */ + return bsbn; +} + ParticleSystem *copy_particlesystem(ParticleSystem *psys) { ParticleSystem *psysn; @@ -1217,6 +1237,7 @@ Object *copy_object(Object *ob) id_us_plus(&(obn->pd->tex->id)); } obn->soft= copy_softbody(ob->soft); + obn->bsoft = copy_bulletsoftbody(ob->bsoft); copy_object_particlesystems(obn, ob); |