diff options
author | Erwin Coumans <blender@erwincoumans.com> | 2008-09-29 07:09:03 +0400 |
---|---|---|
committer | Erwin Coumans <blender@erwincoumans.com> | 2008-09-29 07:09:03 +0400 |
commit | 0b622fc07f1a19c4fbc72782f6000814b66b2088 (patch) | |
tree | a0cc270ca6238e42acb5845e1f735e07d9c55be8 /source | |
parent | 25fc47aaf2a7898b81eb4617a1cd877832d675c2 (diff) |
added anisotropic friction support for Bullet. Both for static and dynamic objects
Diffstat (limited to 'source')
4 files changed, 41 insertions, 1 deletions
diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c index 58fb2d456b9..3d6a82aef57 100644 --- a/source/blender/src/buttons_logic.c +++ b/source/blender/src/buttons_logic.c @@ -3072,6 +3072,25 @@ static uiBlock *advanced_bullet_menu(void *arg_ob) xco, yco, 118, 19, &ob->margin, 0.0, 1.0, 1, 0, "Collision margin"); } + uiDefButBitI(block, TOG, OB_ANISOTROPIC_FRICTION, B_REDR, "Anisotropic", + xco+120, yco, 120, 19, + &ob->gameflag, 0.0, 1.0, 10, 0, + "Enable anisotropic friction"); + + yco-=25; + + if (ob->gameflag & OB_ANISOTROPIC_FRICTION) { + uiDefButF(block, NUM, 0, "X:", + xco, yco, 80, 19,&ob->anisotropicFriction[0], 0.0, 1.0, 10, 0, + "Relative friction coefficient in the x-direction."); + uiDefButF(block, NUM, 0, "Y:", + xco+80, yco, 80, 19,&ob->anisotropicFriction[1], 0.0, 1.0, 10, 0, + "Relative friction coefficient in the y-direction."); + uiDefButF(block, NUM, 0, "Z:", + xco+160, yco, 80, 19,&ob->anisotropicFriction[2], 0.0, 1.0, 10, 0, + "Relative friction coefficient in the z-direction."); + } + } uiBlockSetDirection(block, UI_TOP); @@ -3110,6 +3129,9 @@ void buttons_bullet(uiBlock *block, Object *ob) uiBlockSetCol(block, TH_BUT_SETTING2); uiBlockBeginAlign(block); + + + uiDefButBitI(block, TOG, OB_GHOST, 0, "Ghost", 10, 182, 60, 19, &ob->gameflag, 0, 0, 0, 0, "Objects that don't restitute collisions (like a ghost)"); diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index e4c7e7f9317..68e0997aec0 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -1025,6 +1025,14 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, //need a bit of damping, else system doesn't behave well ci.m_inertiaFactor = shapeprops->m_inertia/0.4f;//defaults to 0.4, don't want to change behaviour + ci.m_do_anisotropic = shapeprops->m_do_anisotropic; + ci.m_anisotropicFriction.setValue(shapeprops->m_friction_scaling[0],shapeprops->m_friction_scaling[1],shapeprops->m_friction_scaling[2]); + + //smprop->m_do_fh = kxshapeprops->m_do_fh; + //smprop->m_do_rot_fh = kxshapeprops->m_do_rot_fh ; + + + /////////////////// ci.m_gamesoftFlag = objprop->m_gamesoftFlag; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 166731459e7..8ec040e89ee 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -500,6 +500,11 @@ void CcdPhysicsController::CreateRigidbody() body->setAngularFactor(0.f); } } + if (m_object && m_cci.m_do_anisotropic) + { + m_object->setAnisotropicFriction(m_cci.m_anisotropicFriction); + } + } static void DeleteBulletShape(btCollisionShape* shape) diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 1366764eb63..f001d6043cb 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -186,7 +186,9 @@ struct CcdConstructionInfo m_MotionState(0), m_shapeInfo(0), m_physicsEnv(0), - m_inertiaFactor(1.f) + m_inertiaFactor(1.f), + m_do_anisotropic(false), + m_anisotropicFriction(1.f,1.f,1.f) { } @@ -259,6 +261,9 @@ struct CcdConstructionInfo CcdPhysicsEnvironment* m_physicsEnv; //needed for self-replication float m_inertiaFactor;//tweak the inertia (hooked up to Blender 'formfactor' + bool m_do_anisotropic; + btVector3 m_anisotropicFriction; + }; |