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--projectfiles_vc7/blender/blenkernel/BKE_blenkernel.vcproj6
-rw-r--r--source/blender/blenkernel/BKE_bullet.h43
-rw-r--r--source/blender/blenkernel/BKE_object.h3
-rw-r--r--source/blender/blenkernel/intern/bullet.c62
-rw-r--r--source/blender/blenkernel/intern/object.c21
-rw-r--r--source/blender/blenloader/intern/readfile.c2
-rw-r--r--source/blender/blenloader/intern/writefile.c1
-rw-r--r--source/blender/makesdna/DNA_object_force.h10
-rw-r--r--source/blender/makesdna/DNA_object_types.h4
-rw-r--r--source/blender/src/buttons_logic.c38
-rw-r--r--source/blender/src/editobject.c6
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.cpp18
12 files changed, 176 insertions, 38 deletions
diff --git a/projectfiles_vc7/blender/blenkernel/BKE_blenkernel.vcproj b/projectfiles_vc7/blender/blenkernel/BKE_blenkernel.vcproj
index 2151f581d19..15e3680cf8c 100644
--- a/projectfiles_vc7/blender/blenkernel/BKE_blenkernel.vcproj
+++ b/projectfiles_vc7/blender/blenkernel/BKE_blenkernel.vcproj
@@ -366,6 +366,9 @@
RelativePath="..\..\..\source\blender\blenkernel\intern\brush.c">
</File>
<File
+ RelativePath="..\..\..\source\blender\blenkernel\intern\bullet.c">
+ </File>
+ <File
RelativePath="..\..\..\source\blender\blenkernel\intern\bvhutils.c">
</File>
<File
@@ -592,6 +595,9 @@
RelativePath="..\..\..\source\blender\blenkernel\BKE_brush.h">
</File>
<File
+ RelativePath="..\..\..\source\blender\blenkernel\BKE_bullet.h">
+ </File>
+ <File
RelativePath="..\..\..\source\blender\blenkernel\BKE_bvhutils.h">
</File>
<File
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);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 5692627281d..0999c8b0ce3 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -141,6 +141,7 @@
#include "BKE_sca.h" // for init_actuator
#include "BKE_scene.h"
#include "BKE_softbody.h" // sbNew()
+#include "BKE_bullet.h" // bsbNew()
#include "BKE_sculpt.h"
#include "BKE_texture.h" // for open_plugin_tex
#include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND
@@ -3334,6 +3335,7 @@ static void direct_link_object(FileData *fd, Object *ob)
if(sb->pointcache)
direct_link_pointcache(fd, sb->pointcache);
}
+ ob->bsoft= newdataadr(fd, ob->bsoft);
ob->fluidsimSettings= newdataadr(fd, ob->fluidsimSettings); /* NT */
link_list(fd, &ob->particlesystem);
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index e53c725867a..9ca9a3d9287 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -922,6 +922,7 @@ static void write_objects(WriteData *wd, ListBase *idbase)
writestruct(wd, DATA, "PartDeflect", 1, ob->pd);
writestruct(wd, DATA, "SoftBody", 1, ob->soft);
if(ob->soft) writestruct(wd, DATA, "PointCache", 1, ob->soft->pointcache);
+ writestruct(wd, DATA, "BulletSoftBody", 1, ob->bsoft);
write_particlesystems(wd, &ob->particlesystem);
write_modifiers(wd, &ob->modifiers);
diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h
index 5900e16d5e8..081b83c3d02 100644
--- a/source/blender/makesdna/DNA_object_force.h
+++ b/source/blender/makesdna/DNA_object_force.h
@@ -84,6 +84,16 @@ typedef struct SBVertex {
float vec[4];
} SBVertex;
+typedef struct BulletSoftBody {
+ int flag; /* various boolean options */
+ float linStiff; /* linear stiffness 0..1 */
+ float angStiff; /* angular stiffness 0..1 */
+ float volume; /* volume preservation 0..1 */
+} BulletSoftBody;
+
+/* BulletSoftBody.flag */
+#define OB_BSB_SHAPE_MATCHING 2
+
typedef struct SoftBody {
struct ParticleSystem *particles; /* particlesystem softbody */
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index c12da6b0194..fad5c020727 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -193,7 +193,9 @@ typedef struct Object {
* bit 15: Always ignore activity culling
*/
int gameflag2;
- short softflag; /* softboday settings */
+ struct BulletSoftBody *bsoft; /* settings for game engine bullet soft body */
+
+ short softflag; /* softbody settings */
short recalc; /* dependency flag */
float anisotropicFriction[3];
diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c
index db3081070be..cec04910de5 100644
--- a/source/blender/src/buttons_logic.c
+++ b/source/blender/src/buttons_logic.c
@@ -67,6 +67,7 @@
#include "BKE_property.h"
#include "BKE_property.h"
#include "BKE_utildefines.h"
+#include "BKE_bullet.h"
#include "BIF_gl.h"
#include "BIF_resources.h"
@@ -3007,28 +3008,27 @@ static uiBlock *advanced_bullet_menu(void *arg_ob)
"Collision margin");
}
if (ob->gameflag & OB_SOFT_BODY) {
- if (ob->soft)
+ /* create a BulletSoftBody structure if not already existing */
+ if (!ob->bsoft)
+ ob->bsoft = bsbNew();
+ if (ob->bsoft)
{
-
- uiDefButBitS(block, TOG, OB_SB_GOAL, 0, "Shape matching",
- xco+=120, yco, 118, 19, &ob->softflag, 0, 0, 0, 0,
+ uiDefButBitI(block, TOG, OB_BSB_SHAPE_MATCHING, 0, "Shape matching",
+ xco+=120, yco, 118, 19, &ob->bsoft->flag, 0, 0, 0, 0,
"Enable soft body shape matching goal");
yco -= 25;
xco = 0;
uiDefButF(block, NUMSLI, 0, "LinStiff ", xco, yco, 238, 19,
- &ob->soft->inspring, 0.0, 1.0, 1, 0,
+ &ob->bsoft->linStiff, 0.0, 1.0, 1, 0,
"Linear stiffness of the soft body vertex spring");
- /*
yco -= 25;
uiDefButF(block, NUMSLI, 0, "AngStiff ", xco, yco, 238, 19,
- &ob->angularStiffness, 0.0, 1.0, 1, 0,
+ &ob->bsoft->angStiff, 0.0, 1.0, 1, 0,
"Angular stiffness of the soft body vertex spring");
yco -= 25;
uiDefButF(block, NUMSLI, 0, "Volume ", xco, yco, 238, 19,
- &ob->volumePreservation, 0.0, 1.0, 1, 0,
+ &ob->bsoft->volume, 0.0, 1.0, 1, 0,
"Factor of soft body volume preservation");
- */
-
}
}
@@ -3056,20 +3056,10 @@ void buttons_bullet(uiBlock *block, Object *ob)
ob->body_type = OB_BODY_TYPE_SOFT;
//only enable game soft body if Blender Soft Body exists
- if (ob->soft)
- {
- but = uiDefButS(block, MENU, REDRAWVIEW3D,
- "Object type%t|No collision%x0|Static%x1|Dynamic%x2|Rigid body%x3|Soft body%x4",
- 10, 205, 120, 19, &ob->body_type, 0, 0, 0, 0, "Selects the type of physical representation");
- uiButSetFunc(but, check_body_type, but, ob);
- } else
- {
- but = uiDefButS(block, MENU, REDRAWVIEW3D,
- "Object type%t|No collision%x0|Static%x1|Dynamic%x2|Rigid body%x3",
- 10, 205, 120, 19, &ob->body_type, 0, 0, 0, 0, "Selects the type of physical representation");
- uiButSetFunc(but, check_body_type, but, ob);
- }
-
+ but = uiDefButS(block, MENU, REDRAWVIEW3D,
+ "Object type%t|No collision%x0|Static%x1|Dynamic%x2|Rigid body%x3|Soft body%x4",
+ 10, 205, 120, 19, &ob->body_type, 0, 0, 0, 0, "Selects the type of physical representation");
+ uiButSetFunc(but, check_body_type, but, ob);
if (ob->gameflag & OB_COLLISION) {
diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c
index 6f926f7396e..370f116d318 100644
--- a/source/blender/src/editobject.c
+++ b/source/blender/src/editobject.c
@@ -3529,10 +3529,8 @@ void copy_attr(short event)
base->object->boundtype = ob->boundtype;
}
base->object->margin= ob->margin;
- //base->object->linearStiffness= ob->linearStiffness;
- //base->object->angularStiffness= ob->angularStiffness;
- //base->object->volumePreservation= ob->volumePreservation;
- //base->object->gamesoftFlag= ob->gamesoftFlag;
+ base->object->bsoft= copy_bulletsoftbody(ob->bsoft);
+
}
else if(event==17) { /* tex space */
copy_texture_space(base->object, ob);
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index 5b72a10cd0d..784a103f3e3 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -1324,19 +1324,19 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
objprop.m_angular_rigidbody = (blenderobject->gameflag & OB_RIGID_BODY) != 0;
///for game soft bodies
- if (blenderobject->soft)
+ if (blenderobject->bsoft)
{
- objprop.m_linearStiffness = blenderobject->soft->inspring;
- objprop.m_angularStiffness = 1.f;//blenderobject->angularStiffness;
- objprop.m_volumePreservation = 1.f;//blenderobject->volumePreservation;
- objprop.m_gamesoftFlag = blenderobject->softflag;//blenderobject->gamesoftFlag;
+ objprop.m_linearStiffness = blenderobject->bsoft->linStiff;
+ objprop.m_angularStiffness = blenderobject->bsoft->angStiff;
+ objprop.m_volumePreservation = blenderobject->bsoft->volume;
+ objprop.m_gamesoftFlag = blenderobject->bsoft->flag;
} else
{
- objprop.m_linearStiffness = 0.5;//blenderobject->linearStiffness;
- objprop.m_angularStiffness = 1.f;//blenderobject->angularStiffness;
- objprop.m_volumePreservation = 1.f;//blenderobject->volumePreservation;
- objprop.m_gamesoftFlag = 1;//blenderobject->gamesoftFlag;
+ objprop.m_linearStiffness = 0.5;//blenderobject->bsoft->linStiff;
+ objprop.m_angularStiffness = 1.f;//blenderobject->bsoft->angStiff;
+ objprop.m_volumePreservation = 1.f;//blenderobject->bsoft->volume;
+ objprop.m_gamesoftFlag = 1;//blenderobject->bsoft->flag;
}
objprop.m_ghost = (blenderobject->gameflag & OB_GHOST) != 0;