[Bf-blender-cvs] [7195e8a] soc-2014-bge: gameengine physics: adding vehicle controller to the UI

Ines Almeida noreply at git.blender.org
Tue Aug 19 05:00:10 CEST 2014


Commit: 7195e8a4bc97cde78994d0a809598f52a2baea22
Author: Ines Almeida
Date:   Sun Aug 17 20:29:33 2014 +0200
Branches: soc-2014-bge
https://developer.blender.org/rB7195e8a4bc97cde78994d0a809598f52a2baea22

gameengine physics: adding vehicle controller to the UI

===================================================================

M	release/scripts/startup/bl_ui/properties_game.py
M	source/blender/editors/object/object_add.c
M	source/blender/makesdna/DNA_object_types.h
M	source/blender/makesrna/intern/rna_object.c
M	source/gameengine/Physics/Bullet/CcdPhysicsController.h
M	source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
M	source/gameengine/Physics/common/PHY_ICharacter.h
M	source/gameengine/Physics/common/PHY_IVehicle.h

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_game.py b/release/scripts/startup/bl_ui/properties_game.py
index 37bfea5..cefddae 100644
--- a/release/scripts/startup/bl_ui/properties_game.py
+++ b/release/scripts/startup/bl_ui/properties_game.py
@@ -56,7 +56,7 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel, Panel):
             layout.prop(game, "jump_speed")
             layout.prop(game, "fall_speed")
 
-        elif physics_type in {'DYNAMIC', 'RIGID_BODY'}:
+        elif physics_type in {'DYNAMIC', 'RIGID_BODY', 'VEHICLE'}:
             split = layout.split()
 
             col = split.column()
@@ -209,7 +209,7 @@ class PHYSICS_PT_game_collision_bounds(PhysicsButtonsPanel, Panel):
     def poll(cls, context):
         game = context.object.game
         rd = context.scene.render
-        return (game.physics_type in {'DYNAMIC', 'RIGID_BODY', 'SENSOR', 'SOFT_BODY', 'STATIC', 'CHARACTER'}) and (rd.engine in cls.COMPAT_ENGINES)
+        return (game.physics_type in {'DYNAMIC', 'RIGID_BODY', 'SENSOR', 'SOFT_BODY', 'STATIC', 'CHARACTER', 'VEHICLE'}) and (rd.engine in cls.COMPAT_ENGINES)
 
     def draw_header(self, context):
         game = context.active_object.game
@@ -227,7 +227,7 @@ class PHYSICS_PT_game_collision_bounds(PhysicsButtonsPanel, Panel):
         row = layout.row()
         row.prop(game, "collision_margin", text="Margin", slider=True)
         sub = row.row()
-        sub.active = game.physics_type  not in {'SOFT_BODY', 'CHARACTER'}
+        sub.active = game.physics_type  not in {'SOFT_BODY', 'CHARACTER', 'VEHICLE'}
         sub.prop(game, "use_collision_compound", text="Compound")
 
 class PHYSICS_PT_game_obstacles(PhysicsButtonsPanel, Panel):
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 34b4ca2..205f111 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -426,7 +426,7 @@ Object *ED_object_add_type(bContext *C, int type, const float loc[3], const floa
 	/* Ignore collisions by default for non-mesh objects */
 	if (type != OB_MESH) {
 		ob->body_type = OB_BODY_TYPE_NO_COLLISION;
-		ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_OCCLUDER | OB_DYNAMIC | OB_NAVMESH); /* copied from rna_object.c */
+		ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_VEHICLE | OB_OCCLUDER | OB_DYNAMIC | OB_NAVMESH); /* copied from rna_object.c */
 	}
 
 	DAG_id_type_tag(bmain, ID_OB);
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index e576cbc..f653e90 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -559,6 +559,8 @@ enum {
 	OB_CHARACTER             = 1 << 22,
 
 	OB_RECORD_ANIMATION      = 1 << 23,
+
+	OB_VEHICLE               = 1 << 24,
 };
 
 /* ob->gameflag2 */
@@ -585,6 +587,7 @@ enum {
 	OB_BODY_TYPE_SENSOR         = 6,
 	OB_BODY_TYPE_NAVMESH        = 7,
 	OB_BODY_TYPE_CHARACTER      = 8,
+	OB_BODY_TYPE_VEHICLE        = 9,
 };
 
 /* ob->depsflag */
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index b50b28e..03bd85f 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -500,7 +500,7 @@ static EnumPropertyItem *rna_Object_collision_bounds_itemf(bContext *UNUSED(C),
 	EnumPropertyItem *item = NULL;
 	int totitem = 0;
 
-	if (ob->body_type != OB_BODY_TYPE_CHARACTER) {
+	if (ob->body_type != OB_BODY_TYPE_CHARACTER && ob->body_type != OB_BODY_TYPE_VEHICLE) {
 		RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_TRIANGLE_MESH);
 	}
 	RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CONVEX_HULL);
@@ -975,6 +975,9 @@ static int rna_GameObjectSettings_physics_type_get(PointerRNA *ptr)
 	else if (ob->gameflag & OB_CHARACTER) {
 		ob->body_type = OB_BODY_TYPE_CHARACTER;
 	}
+	else if (ob->gameflag & OB_VEHICLE) {
+		ob->body_type = OB_BODY_TYPE_VEHICLE;
+	}
 	else if (ob->gameflag & OB_SENSOR) {
 		ob->body_type = OB_BODY_TYPE_SENSOR;
 	}
@@ -1006,16 +1009,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->gameflag &= ~(OB_OCCLUDER | OB_CHARACTER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR |
+			ob->gameflag &= ~(OB_OCCLUDER | OB_CHARACTER | OB_VEHICLE | 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_CHARACTER | OB_DYNAMIC | OB_NAVMESH);
+			ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_VEHICLE | 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_CHARACTER | OB_DYNAMIC | OB_OCCLUDER);
+			ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_VEHICLE | OB_DYNAMIC | OB_OCCLUDER);
 
 			if (ob->type == OB_MESH) {
 				/* could be moved into mesh UI but for now ensure mesh data layer */
@@ -1024,29 +1027,34 @@ 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_CHARACTER | OB_OCCLUDER | OB_DYNAMIC | OB_NAVMESH);
+			ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_VEHICLE | OB_OCCLUDER | OB_DYNAMIC | OB_NAVMESH);
 			break;
 		case OB_BODY_TYPE_CHARACTER:
 			ob->gameflag |= OB_COLLISION | OB_CHARACTER;
-			ob->gameflag &= ~(OB_SENSOR | OB_OCCLUDER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR |
+			ob->gameflag &= ~(OB_SENSOR | OB_OCCLUDER | OB_DYNAMIC | OB_VEHICLE | 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_VEHICLE:
+			ob->gameflag |= OB_COLLISION | OB_VEHICLE;
+			ob->gameflag &= ~(OB_SENSOR | OB_OCCLUDER | OB_DYNAMIC | OB_CHARACTER | 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_CHARACTER | OB_SENSOR | OB_NAVMESH);
+			ob->gameflag &= ~(OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_VEHICLE | 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_CHARACTER | OB_SENSOR | OB_NAVMESH);
+			ob->gameflag &= ~(OB_RIGID_BODY | OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_VEHICLE | 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_CHARACTER | OB_SENSOR | OB_NAVMESH);
+			ob->gameflag &= ~(OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_VEHICLE | 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_CHARACTER | OB_SENSOR | OB_NAVMESH);
+			ob->gameflag &= ~(OB_RIGID_BODY | OB_OCCLUDER | OB_CHARACTER | OB_VEHICLE | 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)) {
@@ -1631,6 +1639,8 @@ static void rna_def_object_game_settings(BlenderRNA *brna)
 		{OB_BODY_TYPE_NAVMESH, "NAVMESH", 0, "Navigation Mesh", "Navigation mesh"},
 		{OB_BODY_TYPE_CHARACTER, "CHARACTER", 0, "Character",
 		                         "Simple kinematic physics appropriate for game characters"},
+		{OB_BODY_TYPE_VEHICLE, "VEHICLE", 0, "Vehicle",
+		                         "Simple kinematic physics appropriate for vehicles"},
 		{0, NULL, 0, NULL, NULL}
 	};
 
@@ -1728,7 +1738,9 @@ 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");
-	
+
+	/* Vehicle physics */
+
 	/* Character physics */
 	prop = RNA_def_property(srna, "step_height", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "step_height");
@@ -1745,6 +1757,8 @@ static void rna_def_object_game_settings(BlenderRNA *brna)
 	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");
 
+
+
 	/* Collision Masks */
 	prop = RNA_def_property(srna, "collision_group", PROP_BOOLEAN, PROP_LAYER_MEMBER);
 	RNA_def_property_boolean_sdna(prop, NULL, "col_group", 1);
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
index 4d0d96e..5d3ffac 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
@@ -272,6 +272,7 @@ struct CcdConstructionInfo
 		m_bSoft(false),
 		m_bSensor(false),
 		m_bCharacter(false),
+		m_bVehicle(false),
 		m_bGimpact(false),
 		m_collisionFilterGroup(DefaultFilter),
 		m_collisionFilterMask(AllFilter),
@@ -299,8 +300,8 @@ struct CcdConstructionInfo
 	btVector3	m_linearFactor;
 	btVector3	m_angularFactor;
 	btScalar	m_mass;
-	btScalar	m_clamp_vel_min;  
-	btScalar	m_clamp_vel_max;  
+	btScalar	m_clamp_vel_min;
+	btScalar	m_clamp_vel_max;
 	btScalar	m_restitution;
 	btScalar	m_friction;


@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list