Commit: 3dd83b533a032fe4e5e39a275e7f2fcff2beaf15
Author: Thomas Szepe
Date:   Sun Oct 11 18:28:43 2015 +0200
Branches: master
https://developer.blender.org/rB3dd83b533a032fe4e5e39a275e7f2fcff2beaf15

BGE: Adding a Max Jumps value to the character physic window

Actually we only have a Python API that allows to change the max jumps value.
The patch also allows non programmers to change the maximum numbers of jumps.

Reviewers: panzergame, sybren, campbellbarton, lordloki, moguri, agoose77

Reviewed By: lordloki, moguri

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1302

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

M       release/scripts/startup/bl_ui/properties_game.py
M       source/blender/blenkernel/intern/object.c
M       source/blender/makesdna/DNA_object_types.h
M       source/blender/makesrna/intern/rna_object.c
M       source/gameengine/Converter/BL_BlenderDataConversion.cpp
M       source/gameengine/Ketsji/KX_CharacterWrapper.cpp
M       source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
M       source/gameengine/Physics/Bullet/CcdPhysicsController.h
M       source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
M       source/gameengine/Physics/common/PHY_Pro.h

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

diff --git a/release/scripts/startup/bl_ui/properties_game.py 
b/release/scripts/startup/bl_ui/properties_game.py
index 56cd4d0..9673d8c 100644
--- a/release/scripts/startup/bl_ui/properties_game.py
+++ b/release/scripts/startup/bl_ui/properties_game.py
@@ -55,6 +55,7 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel, Panel):
             layout.prop(game, "step_height", slider=True)
             layout.prop(game, "jump_speed")
             layout.prop(game, "fall_speed")
+            layout.prop(game, "max_jumps")
 
         elif physics_type in {'DYNAMIC', 'RIGID_BODY'}:
             split = layout.split()
diff --git a/source/blender/blenkernel/intern/object.c 
b/source/blender/blenkernel/intern/object.c
index ed84177..e5f826f 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1041,6 +1041,7 @@ Object *BKE_object_add_only_object(Main *bmain, int type, 
const char *name)
        ob->step_height = 0.15f;
        ob->jump_speed = 10.0f;
        ob->fall_speed = 55.0f;
+       ob->max_jumps = 1;
        ob->col_group = 0x01;
        ob->col_mask = 0xffff;
        ob->preview = NULL;
diff --git a/source/blender/makesdna/DNA_object_types.h 
b/source/blender/makesdna/DNA_object_types.h
index faae78a..cb39655 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -189,7 +189,7 @@ typedef struct Object {
 
        /* did last modifier stack generation need mapping support? */
        char lastNeedMapping;  /* bool */
-       char pad[5];
+       char pad;
 
        /* dupli-frame settings */
        int dupon, dupoff, dupsta, dupend;
@@ -222,6 +222,8 @@ typedef struct Object {
        float step_height;
        float jump_speed;
        float fall_speed;
+       unsigned char max_jumps;
+       char pad2[3];
 
        /** Collision mask settings */
        unsigned short col_group, col_mask;
diff --git a/source/blender/makesrna/intern/rna_object.c 
b/source/blender/makesrna/intern/rna_object.c
index e2d3db2..99af8c0 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -1771,6 +1771,14 @@ static void rna_def_object_game_settings(BlenderRNA 
*brna)
        RNA_def_property_float_default(prop, 55.0f);
        RNA_def_property_ui_text(prop, "Fall Speed Max", "Maximum speed at 
which the character will fall");
 
+       prop = RNA_def_property(srna, "max_jumps", PROP_INT, PROP_NONE);
+       RNA_def_property_int_sdna(prop, NULL, "max_jumps");
+       RNA_def_property_range(prop, 1, CHAR_MAX);
+       RNA_def_property_ui_range(prop, 1, 10, 1, 1);
+       RNA_def_property_int_default(prop, 1);
+       RNA_def_property_ui_text(prop, "Max Jumps",
+                                "The maximum number of jumps the character can 
make before it hits the ground.");
+
        /* 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/Converter/BL_BlenderDataConversion.cpp 
b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index c74fd82..928005a 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -1215,7 +1215,8 @@ static PHY_ShapeProps 
*CreateShapePropsFromBlenderObject(struct Object* blendero
        shapeProps->m_step_height = blenderobject->step_height;
        shapeProps->m_jump_speed = blenderobject->jump_speed;
        shapeProps->m_fall_speed = blenderobject->fall_speed;
-       
+       shapeProps->m_max_jumps = blenderobject->max_jumps;
+
        return shapeProps;
 }
 
diff --git a/source/gameengine/Ketsji/KX_CharacterWrapper.cpp 
b/source/gameengine/Ketsji/KX_CharacterWrapper.cpp
index d777ae7..44f06a9 100644
--- a/source/gameengine/Ketsji/KX_CharacterWrapper.cpp
+++ b/source/gameengine/Ketsji/KX_CharacterWrapper.cpp
@@ -119,7 +119,7 @@ int KX_CharacterWrapper::pyattr_set_max_jumps(void *self_v, 
const KX_PYATTRIBUTE
 
        CLAMP(param, 0, 255);
 
-       self->m_character->SetMaxJumps((unsigned char)param);
+       self->m_character->SetMaxJumps(param);
        return PY_SET_ATTR_SUCCESS;
 }
 
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp 
b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
index 6a1e52c..f11d7ac 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
@@ -533,6 +533,7 @@ bool CcdPhysicsController::CreateCharacterController()
 
        m_characterController->setJumpSpeed(m_cci.m_jumpSpeed);
        m_characterController->setFallSpeed(m_cci.m_fallSpeed);
+       m_characterController->setMaxJumps(m_cci.m_maxJumps);
 
        return true;
 }
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h 
b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
index 2ae1ff8..a0b0473 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
@@ -316,7 +316,8 @@ struct CcdConstructionInfo
        float   m_stepHeight;
        float   m_jumpSpeed;
        float   m_fallSpeed;
-       
+       unsigned char m_maxJumps;
+
        int             m_gamesoftFlag;
        float   m_soft_linStiff;                        /* linear stiffness 
0..1 */
        float   m_soft_angStiff;                /* angular stiffness 0..1 */
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp 
b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index eec5791..1b7267b 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -3162,6 +3162,7 @@ void CcdPhysicsEnvironment::ConvertObject(KX_GameObject 
*gameobj, RAS_MeshObject
        ci.m_stepHeight = isbulletchar ? shapeprops->m_step_height : 0.f;
        ci.m_jumpSpeed = isbulletchar ? shapeprops->m_jump_speed : 0.f;
        ci.m_fallSpeed = isbulletchar ? shapeprops->m_fall_speed : 0.f;
+       ci.m_maxJumps = isbulletchar ? shapeprops->m_max_jumps : 0;
 
        //mmm, for now, take this for the size of the dynamicobject
        // Blender uses inertia for radius of dynamic object
diff --git a/source/gameengine/Physics/common/PHY_Pro.h 
b/source/gameengine/Physics/common/PHY_Pro.h
index c9b91b0..bfe574e 100644
--- a/source/gameengine/Physics/common/PHY_Pro.h
+++ b/source/gameengine/Physics/common/PHY_Pro.h
@@ -51,6 +51,7 @@ struct PHY_ShapeProps {
        MT_Scalar  m_step_height;                       // Max height of 
climbable steps (Character)
        MT_Scalar  m_jump_speed;                        // Velocity of jumps 
(Character)
        MT_Scalar  m_fall_speed;                        // Max velocity of 
falling (Character)
+       unsigned char m_max_jumps;          // Max ammount of jumps (Character)
 };

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to