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>2012-05-29 01:36:29 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2012-05-29 01:36:29 +0400
commitdfc19a1ff7968e547c33ef3304849f69ddf76f4f (patch)
tree62764fb4d5ebf37785a1d34dcda7e01d4392bc18 /source/blender
parent4e0492e3bc59a4adca8ea5075a96bc78cd6bb67a (diff)
BGE patch #28476: Character object physics type
=============================================== This patch adds a new "Character" BGE physics type which uses Bullet's btKinematicCharacter for simulation instead of full-blown dynamics. It is appropiate for (player-controlled) characters, for which the other physics types often result unexpected results (bouncing off walls, sliding etc.) and for which simple kinematics offers much more precision. "Character" can be chosen like any other physics type in the "Physics" section of the properties window. Current settings for tweaking are "Step Height" (to make the object automatically climb small steps if it collides with them), "Fall Speed" (the maximum speed that the object can have when falling) and "Jump Speed", which is currently not used. See http://projects.blender.org/tracker/?func=detail&atid=127&aid=28476&group_id=9 for sample blends and a discussion on the patch: how to use it and what influences the behavior of the character object. Known problem: there is a crash if the "compound" option is set in the physics panel of the Character object.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/object.c3
-rw-r--r--source/blender/makesdna/DNA_object_types.h8
-rw-r--r--source/blender/makesrna/intern/rna_object.c41
-rw-r--r--source/blender/python/generic/py_capi_utils.c2
4 files changed, 45 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 098d702a7e2..04631729d7a 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -835,6 +835,9 @@ Object *BKE_object_add_only_object(int type, const char *name)
/* ob->pad3 == Contact Processing Threshold */
ob->m_contactProcessingThreshold = 1.0f;
ob->obstacleRad = 1.0f;
+ ob->step_height = 0.15f;
+ ob->jump_speed = 10.0f;
+ ob->fall_speed = 55.0f;
/* NT fluid sim defaults */
ob->fluidsimSettings = NULL;
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 1ea50ec9c1a..11ca1f1fa8e 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -204,6 +204,12 @@ typedef struct Object {
float min_vel; /* clamp the maximum velocity 0.0 is disabled */
float m_contactProcessingThreshold;
float obstacleRad;
+
+ /* "Character" physics properties */
+ float step_height;
+ float jump_speed;
+ float fall_speed;
+ char pad1[4];
short rotmode; /* rotation mode - uses defines set out in DNA_action_types.h for PoseChannel rotations... */
@@ -483,6 +489,7 @@ typedef struct DupliObject {
#define OB_SENSOR 0x80000
#define OB_NAVMESH 0x100000
#define OB_HASOBSTACLE 0x200000
+#define OB_CHARACTER 0x400000
/* ob->gameflag2 */
#define OB_NEVER_DO_ACTIVITY_CULLING 1
@@ -504,6 +511,7 @@ typedef struct DupliObject {
#define OB_BODY_TYPE_OCCLUDER 5
#define OB_BODY_TYPE_SENSOR 6
#define OB_BODY_TYPE_NAVMESH 7
+#define OB_BODY_TYPE_CHARACTER 8
/* ob->scavisflag */
#define OB_VIS_SENS 1
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 21c9187cbb8..7e3b368aa64 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -891,6 +891,9 @@ static int rna_GameObjectSettings_physics_type_get(PointerRNA *ptr)
ob->body_type = OB_BODY_TYPE_NO_COLLISION;
}
}
+ else if (ob->gameflag & OB_CHARACTER) {
+ ob->body_type = OB_BODY_TYPE_CHARACTER;
+ }
else if (ob->gameflag & OB_SENSOR) {
ob->body_type = OB_BODY_TYPE_SENSOR;
}
@@ -922,16 +925,16 @@ static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value)
switch (ob->body_type) {
case OB_BODY_TYPE_SENSOR:
ob->gameflag |= OB_SENSOR | OB_COLLISION | OB_GHOST;
- ob->gameflag &= ~(OB_OCCLUDER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR |
+ ob->gameflag &= ~(OB_OCCLUDER | OB_CHARACTER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR |
OB_ANISOTROPIC_FRICTION | OB_DO_FH | OB_ROT_FH | OB_COLLISION_RESPONSE | OB_NAVMESH);
break;
case OB_BODY_TYPE_OCCLUDER:
ob->gameflag |= OB_OCCLUDER;
- ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_DYNAMIC | OB_NAVMESH);
+ ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_DYNAMIC | OB_NAVMESH);
break;
case OB_BODY_TYPE_NAVMESH:
ob->gameflag |= OB_NAVMESH;
- ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_DYNAMIC | OB_OCCLUDER);
+ ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_DYNAMIC | OB_OCCLUDER);
if (ob->type == OB_MESH) {
/* could be moved into mesh UI but for now ensure mesh data layer */
@@ -940,24 +943,29 @@ static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value)
break;
case OB_BODY_TYPE_NO_COLLISION:
- ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_OCCLUDER | OB_DYNAMIC | OB_NAVMESH);
+ ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_OCCLUDER | OB_DYNAMIC | OB_NAVMESH);
break;
+ case OB_BODY_TYPE_CHARACTER:
+ ob->gameflag |= OB_COLLISION | OB_GHOST | OB_CHARACTER;
+ ob->gameflag &= ~(OB_SENSOR | OB_OCCLUDER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR
+ | OB_ANISOTROPIC_FRICTION | OB_DO_FH | OB_ROT_FH | OB_COLLISION_RESPONSE | OB_NAVMESH);
+ break;
case OB_BODY_TYPE_STATIC:
ob->gameflag |= OB_COLLISION;
- ob->gameflag &= ~(OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_OCCLUDER | OB_SENSOR | OB_NAVMESH);
+ ob->gameflag &= ~(OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH);
break;
case OB_BODY_TYPE_DYNAMIC:
ob->gameflag |= OB_COLLISION | OB_DYNAMIC | OB_ACTOR;
- ob->gameflag &= ~(OB_RIGID_BODY | OB_SOFT_BODY | OB_OCCLUDER | OB_SENSOR | OB_NAVMESH);
+ ob->gameflag &= ~(OB_RIGID_BODY | OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH);
break;
case OB_BODY_TYPE_RIGID:
ob->gameflag |= OB_COLLISION | OB_DYNAMIC | OB_RIGID_BODY | OB_ACTOR;
- ob->gameflag &= ~(OB_SOFT_BODY | OB_OCCLUDER | OB_SENSOR | OB_NAVMESH);
+ ob->gameflag &= ~(OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH);
break;
default:
case OB_BODY_TYPE_SOFT:
ob->gameflag |= OB_COLLISION | OB_DYNAMIC | OB_SOFT_BODY | OB_ACTOR;
- ob->gameflag &= ~(OB_RIGID_BODY | OB_OCCLUDER | OB_SENSOR | OB_NAVMESH);
+ ob->gameflag &= ~(OB_RIGID_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH);
/* assume triangle mesh, if no bounds chosen for soft body */
if ((ob->gameflag & OB_BOUNDS) && (ob->boundtype < OB_BOUND_TRIANGLE_MESH)) {
@@ -1436,6 +1444,7 @@ static void rna_def_object_game_settings(BlenderRNA *brna)
"Collision Sensor, detects static and dynamic objects but not the other "
"collision sensor objects"},
{OB_BODY_TYPE_NAVMESH, "NAVMESH", 0, "Navigation Mesh", "Navigation mesh"},
+ {OB_BODY_TYPE_CHARACTER, "CHARACTER", 0, "Character", "Simple kinematic physics appropiate for game characters"},
{0, NULL, 0, NULL, NULL}
};
@@ -1529,6 +1538,22 @@ static void rna_def_object_game_settings(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "max_vel");
RNA_def_property_range(prop, 0.0, 1000.0);
RNA_def_property_ui_text(prop, "Velocity Max", "Clamp velocity to this maximum speed");
+
+ prop= RNA_def_property(srna, "step_height", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "step_height");
+ RNA_def_property_range(prop, 0.0, 1.0);
+ RNA_def_property_ui_text(prop, "Step Height", "Maximum height of steps the character can run over");
+
+ prop= RNA_def_property(srna, "jump_speed", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "jump_speed");
+ RNA_def_property_range(prop, 0.0, 1000.0);
+ RNA_def_property_ui_text(prop, "Jump Force", "Upward velocity applied to the character when jumping (with the Motion actuator)");
+
+ prop= RNA_def_property(srna, "fall_speed", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "fall_speed");
+ RNA_def_property_range(prop, 0.0, 1000.0);
+ RNA_def_property_ui_text(prop, "Fall Speed Max", "Maximum speed at which the character will fall");
+
/* lock position */
prop = RNA_def_property(srna, "lock_location_x", PROP_BOOLEAN, PROP_NONE);
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index 3a405575926..fd12f7f483d 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -489,7 +489,7 @@ void PyC_SetHomePath(const char *py_path_bundle)
/* cmake/MSVC debug build crashes without this, why only
* in this case is unknown.. */
{
- BLI_setenv("PYTHONPATH", py_path_bundle);
+ /*BLI_setenv("PYTHONPATH", py_path_bundle)*/;
}
#endif
#endif