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:
authorBenoit Bolsee <benoit.bolsee@online.be>2008-09-17 02:52:42 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2008-09-17 02:52:42 +0400
commit9b7d40dbae1be5aa18894ffbc8f97a4a8c4c6fdd (patch)
treeed4cdb49c0afaf07e1b301f9e9d18e8a791b9f4e
parent73c8d76ba406a7753b8b6aaa1e304d9e311f816a (diff)
BGE patch: bullet buttons UI change after discussion with Erwin: use a drop down instead of a series of buttons. Introduction of soft body option.
-rw-r--r--source/blender/blenkernel/intern/object.c2
-rw-r--r--source/blender/blenloader/intern/readfile.c2
-rw-r--r--source/blender/makesdna/DNA_object_types.h13
-rw-r--r--source/blender/python/api2_2x/Object.c6
-rw-r--r--source/blender/src/buttons_logic.c122
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.cpp2
6 files changed, 101 insertions, 46 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index e63d6047cc6..6cbcba65f56 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -960,7 +960,7 @@ Object *add_only_object(int type, char *name)
ob->anisotropicFriction[0] = 1.0f;
ob->anisotropicFriction[1] = 1.0f;
ob->anisotropicFriction[2] = 1.0f;
- ob->gameflag= OB_PROP|OB_PHYSICS;
+ ob->gameflag= OB_PROP|OB_COLLISION;
ob->margin = 0.0;
/* NT fluid sim defaults */
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 6add88284c2..f3f1a99cdbf 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -7794,7 +7794,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 2)){
Object *ob;
for(ob = main->object.first; ob; ob= ob->id.next) {
- ob->gameflag |= OB_PHYSICS;
+ ob->gameflag |= OB_COLLISION;
ob->margin = 0.06;
}
}
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 3708db3fd38..66bdaf2c98b 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -212,7 +212,8 @@ typedef struct Object {
short shapenr, shapeflag; /* current shape key for menu or pinned, flag for pinning */
float smoothresh; /* smoothresh is phong interpolation ray_shadow correction in render */
- short recalco, pad4; /* recalco for temp storage of ob->recalc, bad design warning */
+ short recalco; /* recalco for temp storage of ob->recalc, bad design warning */
+ short body_type; /* for now used to temporarily holds the type of collision object */
struct FluidsimSettings *fluidsimSettings; /* if fluidsim enabled, store additional settings */
@@ -429,13 +430,21 @@ extern Object workob;
#define OB_PROP 16384
#define OB_MAINACTOR 32768
-#define OB_PHYSICS 65536
+#define OB_COLLISION 65536
+#define OB_SOFT_BODY 0x20000
/* ob->gameflag2 */
#define OB_NEVER_DO_ACTIVITY_CULLING 1
#define OB_LIFE (OB_PROP|OB_DYNAMIC|OB_ACTOR|OB_MAINACTOR|OB_CHILD)
+/* ob->body_type */
+#define OB_BODY_TYPE_NO_COLLISION 0
+#define OB_BODY_TYPE_STATIC 1
+#define OB_BODY_TYPE_DYNAMIC 2
+#define OB_BODY_TYPE_RIGID 3
+#define OB_BODY_TYPE_SOFT 4
+
/* ob->scavisflag */
#define OB_VIS_SENS 1
#define OB_VIS_CONT 2
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c
index 45d6bfa3c01..0d5af06377c 100644
--- a/source/blender/python/api2_2x/Object.c
+++ b/source/blender/python/api2_2x/Object.c
@@ -3519,8 +3519,8 @@ static int Object_setRBMass( BPy_Object * self, PyObject * args )
/* this is too low level, possible to add helper methods */
-#define GAMEFLAG_MASK ( OB_DYNAMIC | OB_CHILD | OB_ACTOR | OB_DO_FH | \
- OB_ROT_FH | OB_ANISOTROPIC_FRICTION | OB_GHOST | OB_RIGID_BODY | \
+#define GAMEFLAG_MASK ( OB_COLLISION | OB_DYNAMIC | OB_CHILD | OB_ACTOR | OB_DO_FH | \
+ OB_ROT_FH | OB_ANISOTROPIC_FRICTION | OB_GHOST | OB_RIGID_BODY | OB_SOFT_BODY | \
OB_BOUNDS | OB_COLLISION_RESPONSE | OB_SECTOR | OB_PROP | \
OB_MAINACTOR )
@@ -5497,6 +5497,7 @@ static PyObject *M_Object_RBFlagsDict( void )
if( M ) {
BPy_constant *d = ( BPy_constant * ) M;
+ PyConstant_Insert( d, "COLLISION", PyInt_FromLong( OB_COLLISION ) );
PyConstant_Insert( d, "DYNAMIC", PyInt_FromLong( OB_DYNAMIC ) );
PyConstant_Insert( d, "CHILD", PyInt_FromLong( OB_CHILD ) );
PyConstant_Insert( d, "ACTOR", PyInt_FromLong( OB_ACTOR ) );
@@ -5506,6 +5507,7 @@ static PyObject *M_Object_RBFlagsDict( void )
PyInt_FromLong( OB_ANISOTROPIC_FRICTION ) );
PyConstant_Insert( d, "GHOST", PyInt_FromLong( OB_GHOST ) );
PyConstant_Insert( d, "RIGIDBODY", PyInt_FromLong( OB_RIGID_BODY ) );
+ PyConstant_Insert( d, "SOFTBODY", PyInt_FromLong( OB_SOFT_BODY ) );
PyConstant_Insert( d, "BOUNDS", PyInt_FromLong( OB_BOUNDS ) );
PyConstant_Insert( d, "COLLISION_RESPONSE",
PyInt_FromLong( OB_COLLISION_RESPONSE ) );
diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c
index 5a689050ff0..e16443460a1 100644
--- a/source/blender/src/buttons_logic.c
+++ b/source/blender/src/buttons_logic.c
@@ -2849,10 +2849,10 @@ void buttons_enji(uiBlock *block, Object *ob)
void buttons_ketsji(uiBlock *block, Object *ob)
{
- uiDefButBitI(block, TOG, OB_PHYSICS, B_REDR, "Physics",
+ uiDefButBitI(block, TOG, OB_COLLISION, B_REDR, "Physics",
10,205,70,19, &ob->gameflag, 0, 0, 0, 0,
"Objects that have a physics representation");
- if (ob->gameflag & OB_PHYSICS) {
+ if (ob->gameflag & OB_COLLISION) {
uiBlockBeginAlign(block);
uiDefButBitI(block, TOG, OB_ACTOR, B_REDR, "Actor",
80,205,55,19, &ob->gameflag, 0, 0, 0, 0,
@@ -2933,46 +2933,90 @@ void buttons_ketsji(uiBlock *block, Object *ob)
}
}
+static void check_actor(void *arg1_but, void *arg2_object)
+{
+ int *gameflag = arg2_object;
+ /* force enabled ACTOR for body >= dynamic */
+ if (*gameflag & OB_DYNAMIC)
+ *gameflag |= OB_ACTOR;
+}
+
+static void check_body_type(void *arg1_but, void *arg2_object)
+{
+ Object *ob = arg2_object;
+
+ switch (ob->body_type) {
+ case OB_BODY_TYPE_NO_COLLISION:
+ ob->gameflag &= ~OB_COLLISION;
+ break;
+ case OB_BODY_TYPE_STATIC:
+ ob->gameflag |= OB_COLLISION;
+ ob->gameflag &= ~(OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY);
+ break;
+ case OB_BODY_TYPE_DYNAMIC:
+ ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_ACTOR;
+ ob->gameflag &= ~(OB_RIGID_BODY|OB_SOFT_BODY);
+ break;
+ case OB_BODY_TYPE_RIGID:
+ ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_RIGID_BODY|OB_ACTOR;
+ ob->gameflag &= ~(OB_SOFT_BODY);
+ break;
+ default:
+ case OB_BODY_TYPE_SOFT:
+ ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_SOFT_BODY|OB_ACTOR;
+ ob->gameflag &= ~(OB_RIGID_BODY);
+ break;
+ }
+}
+
void buttons_bullet(uiBlock *block, Object *ob)
{
- uiDefButBitI(block, TOG, OB_PHYSICS, B_REDR, "Physics",
- 10,205,70,19, &ob->gameflag, 0, 0, 0, 0,
- "Objects that have a physics representation");
- if (ob->gameflag & OB_PHYSICS) {
- uiBlockBeginAlign(block);
- uiDefButBitI(block, TOG, OB_ACTOR, B_REDR, "Actor",
- 80,205,55,19, &ob->gameflag, 0, 0, 0, 0,
- "Objects that are detected by the Near and Radar sensor");
- if(ob->gameflag & OB_ACTOR) {
- uiDefButBitI(block, TOG, OB_GHOST, B_REDR, "Ghost", 135,205,55,19,
- &ob->gameflag, 0, 0, 0, 0,
- "Objects that don't restitute collisions (like a ghost)");
- uiDefButBitI(block, TOG, OB_DYNAMIC, B_REDR, "Dynamic", 190,205,75,19,
- &ob->gameflag, 0, 0, 0, 0,
- "Motion defined by laws of physics");
-
- if(ob->gameflag & OB_DYNAMIC) {
- uiDefButBitI(block, TOG, OB_RIGID_BODY, B_REDR, "Rigid Body", 265,205,85,19,
- &ob->gameflag, 0, 0, 0, 0,
- "Enable rolling physics");
+ uiBut *but;
- uiDefButF(block, NUM, B_DIFF, "Mass:", 10, 185, 130, 19,
- &ob->mass, 0.01, 10000.0, 10, 2,
- "The mass of the Object");
- uiDefButF(block, NUM, REDRAWVIEW3D, "Radius:", 140, 185, 130, 19,
- &ob->inertia, 0.01, 10.0, 10, 2,
- "Bounding sphere radius, not used for other bounding shapes");
- uiDefButBitI(block, TOG, OB_COLLISION_RESPONSE, B_REDR, "No sleeping", 270,185,80,19,
- &ob->gameflag, 0, 0, 0, 0,
- "Disable auto (de)activation");
+ /* determine the body_type setting based on flags */
+ if (!(ob->gameflag & OB_COLLISION))
+ ob->body_type = OB_BODY_TYPE_NO_COLLISION;
+ else if (!(ob->gameflag & OB_DYNAMIC) || !(ob->gameflag & OB_DYNAMIC))
+ ob->body_type = OB_BODY_TYPE_STATIC;
+ else if (!(ob->gameflag & (OB_RIGID_BODY|OB_SOFT_BODY)))
+ ob->body_type = OB_BODY_TYPE_DYNAMIC;
+ else if (ob->gameflag & OB_RIGID_BODY)
+ ob->body_type = OB_BODY_TYPE_RIGID;
+ else
+ ob->body_type = OB_BODY_TYPE_SOFT;
- uiDefButF(block, NUMSLI, B_DIFF, "Damp ", 10, 165, 150, 19,
- &ob->damping, 0.0, 1.0, 10, 0,
- "General movement damping");
- uiDefButF(block, NUMSLI, B_DIFF, "RotDamp ", 160, 165, 190, 19,
- &ob->rdamping, 0.0, 1.0, 10, 0,
- "General rotation damping");
- }
+ uiBlockBeginAlign(block);
+ but = uiDefButS(block, MENU, REDRAWVIEW3D,
+ "Object type%t|No collision%x0|Static%x1|Dynamic%x2|Rigid body%x3|Soft body%x4",
+ 10, 205, 150, 19, &ob->body_type, 0, 0, 0, 0, "Selects the type of physical representation of the object");
+ uiButSetFunc(but, check_body_type, but, ob);
+
+ if (ob->gameflag & OB_COLLISION) {
+ but = uiDefButBitI(block, TOG, OB_ACTOR, B_REDR, "Actor",
+ 160,205,55,19, &ob->gameflag, 0, 0, 0, 0,
+ "Objects that are detected by the Near and Radar sensor");
+ uiButSetFunc(but, check_actor, but, &ob->gameflag);
+
+ uiDefButBitI(block, TOG, OB_GHOST, B_REDR, "Ghost", 215,205,55,19,
+ &ob->gameflag, 0, 0, 0, 0,
+ "Objects that don't restitute collisions (like a ghost)");
+ if(ob->gameflag & OB_DYNAMIC) {
+ uiDefButBitI(block, TOG, OB_COLLISION_RESPONSE, B_REDR, "No sleeping", 270,205,80,19,
+ &ob->gameflag, 0, 0, 0, 0,
+ "Disable auto (de)activation");
+ uiDefButF(block, NUM, B_DIFF, "Mass:", 10, 185, 170, 19,
+ &ob->mass, 0.01, 10000.0, 10, 2,
+ "The mass of the Object");
+ uiDefButF(block, NUM, REDRAWVIEW3D, "Radius:", 180, 185, 170, 19,
+ &ob->inertia, 0.01, 10.0, 10, 2,
+ "Bounding sphere radius, not used for other bounding shapes");
+
+ uiDefButF(block, NUMSLI, B_DIFF, "Damp ", 10, 165, 150, 19,
+ &ob->damping, 0.0, 1.0, 10, 0,
+ "General movement damping");
+ uiDefButF(block, NUMSLI, B_DIFF, "RotDamp ", 160, 165, 190, 19,
+ &ob->rdamping, 0.0, 1.0, 10, 0,
+ "General rotation damping");
}
uiBlockEndAlign(block);
@@ -2999,8 +3043,8 @@ void buttons_bullet(uiBlock *block, Object *ob)
&ob->gameflag, 0, 0, 0, 0,
"Add Children");
}
- uiBlockEndAlign(block);
}
+ uiBlockEndAlign(block);
}
static void check_controller_state_mask(void *arg1_but, void *arg2_mask)
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index 8bdec219354..c3992d02eee 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -1280,7 +1280,7 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
//bool bRigidBody = (userigidbody == 0);
// object has physics representation?
- if (!(blenderobject->gameflag & OB_PHYSICS))
+ if (!(blenderobject->gameflag & OB_COLLISION))
return;
// get Root Parent of blenderobject