From a44177a4019536871da8c976fd4bbf38a30fd766 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 19 Sep 2008 20:41:38 +0000 Subject: BGE patch: new 'Advanced Settings' button to keep special Bullet options away from main UI. Three features that were on the main UI interface are now moved to the Advanced Settings panel: Margin, Actor (that becomes Sensor Actor) and No sleeping. Sensor Actor is now a feature: it can be turned on and off for all types of objects, and not just static objects. Select the Sensor Actor button to make the object visible to Near and Radar sensor. The button is selected by default for dynamic objects and unselected by default for static objects, to match previous behavior. --- source/blender/blenkernel/BKE_blender.h | 2 +- source/blender/blenloader/intern/readfile.c | 9 ++ source/blender/src/buttons_logic.c | 95 ++++++++++++++-------- source/blender/src/drawobject.c | 2 +- .../Converter/BL_BlenderDataConversion.cpp | 19 ++--- 5 files changed, 79 insertions(+), 48 deletions(-) diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 0591937ea4c..5af8fde99c9 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -41,7 +41,7 @@ struct ListBase; struct MemFile; #define BLENDER_VERSION 247 -#define BLENDER_SUBVERSION 2 +#define BLENDER_SUBVERSION 3 #define BLENDER_MINVERSION 245 #define BLENDER_MINSUBVERSION 15 diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index f3f1a99cdbf..0df965b2cc1 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7799,6 +7799,15 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 3)){ + Object *ob; + for(ob = main->object.first; ob; ob= ob->id.next) { + // Starting from subversion 3, ACTOR is a separate feature. + // Before it was conditioning all the other dynamic flags + if (!(ob->gameflag & OB_ACTOR)) + ob->gameflag &= ~(OB_GHOST|OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_COLLISION_RESPONSE); + } + } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */ diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c index e16443460a1..45974e5704c 100644 --- a/source/blender/src/buttons_logic.c +++ b/source/blender/src/buttons_logic.c @@ -2969,6 +2969,45 @@ static void check_body_type(void *arg1_but, void *arg2_object) } } +static uiBlock *advanced_bullet_menu(void *arg_ob) +{ + uiBlock *block; + Object *ob = arg_ob; + short yco = 65, xco = 0; + + block= uiNewBlock(&curarea->uiblocks, "advanced_bullet_options", UI_EMBOSS, UI_HELV, curarea->win); + /* use this for a fake extra empy space around the buttons */ + uiDefBut(block, LABEL, 0, "", -5, -10, 255, 100, NULL, 0, 0, 0, 0, ""); + + uiDefButBitI(block, TOG, OB_ACTOR, 0, "Sensor actor", + xco, yco, 118, 19, &ob->gameflag, 0, 0, 0, 0, + "Objects that are detected by the Near and Radar sensor"); + + if (ob->gameflag & OB_DYNAMIC) { + uiDefButBitI(block, TOG, OB_COLLISION_RESPONSE, 0, "No sleeping", + xco+=120, yco, 118, 19, &ob->gameflag, 0, 0, 0, 0, + "Disable auto (de)activation"); + } + + yco -= 25; + xco = 0; + if (ob->gameflag & OB_DYNAMIC) { + if (ob->margin < 0.001f) + ob->margin = 0.06f; + uiDefButF(block, NUM, 0, "Margin", + xco, yco, 118, 19, &ob->margin, 0.001, 1.0, 1, 0, + "Collision margin"); + } else { + uiDefButF(block, NUM, 0, "Margin", + xco, yco, 118, 19, &ob->margin, 0.0, 1.0, 1, 0, + "Collision margin"); + } + + uiBlockSetDirection(block, UI_TOP); + + return block; +} + void buttons_bullet(uiBlock *block, Object *ob) { uiBut *but; @@ -2976,7 +3015,7 @@ void buttons_bullet(uiBlock *block, Object *ob) /* 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)) + else if (!(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; @@ -2985,61 +3024,51 @@ void buttons_bullet(uiBlock *block, Object *ob) else ob->body_type = OB_BODY_TYPE_SOFT; - 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"); + 10, 205, 120, 19, &ob->body_type, 0, 0, 0, 0, "Selects the type of physical representation"); 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, + + uiBlockSetCol(block, TH_BUT_SETTING1); + uiDefBlockBut(block, advanced_bullet_menu, ob, + "Advanced Settings", + 200, 205, 150, 20, "Display collision advanced settings"); + 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)"); + if ((ob->gameflag & OB_DYNAMIC) || ((ob->gameflag & OB_BOUNDS) && (ob->boundtype == OB_BOUND_SPHERE))) { + uiDefButF(block, NUM, REDRAWVIEW3D, "Radius:", 70, 182, 140, 19, + &ob->inertia, 0.01, 10.0, 10, 2, + "Bounding sphere radius, not used for other bounding shapes"); + } 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, + uiDefButF(block, NUM, B_DIFF, "Mass:", 210, 182, 140, 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, + uiDefButF(block, NUMSLI, B_DIFF, "Damp ", 10, 162, 150, 19, &ob->damping, 0.0, 1.0, 10, 0, "General movement damping"); - uiDefButF(block, NUMSLI, B_DIFF, "RotDamp ", 160, 165, 190, 19, + uiDefButF(block, NUMSLI, B_DIFF, "RotDamp ", 160, 162, 190, 19, &ob->rdamping, 0.0, 1.0, 10, 0, "General rotation damping"); } uiBlockEndAlign(block); uiBlockBeginAlign(block); - if ((ob->gameflag & (OB_ACTOR|OB_DYNAMIC)) == (OB_ACTOR|OB_DYNAMIC)) { - if (ob->margin < 0.001f) - ob->margin = 0.06f; - uiDefButF(block, NUM, B_DIFF, "Margin", 10, 105, 105, 19, - &ob->margin, 0.001, 1.0, 1, 0, - "Collision margin"); - } else { - uiDefButF(block, NUM, B_DIFF, "Margin", 10, 105, 105, 19, - &ob->margin, 0.0, 1.0, 1, 0, - "Collision margin"); - } - uiDefButBitI(block, TOG, OB_BOUNDS, B_REDR, "Bounds", 115, 105, 55, 19, - &ob->gameflag, 0, 0,0, 0, + uiDefButBitI(block, TOG, OB_BOUNDS, B_REDR, "Bounds", 10, 105, 80, 19, + &ob->gameflag, 0, 0, 0, 0, "Specify a bounds object for physics"); if (ob->gameflag & OB_BOUNDS) { uiDefButS(block, MENU, REDRAWVIEW3D, "Boundary Display%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Convex Hull%x5|Static Mesh%x4", //almost ready to enable this one: uiDefButS(block, MENU, REDRAWVIEW3D, "Boundary Display%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Convex Hull Polytope%x5|Static TriangleMesh %x4|Dynamic Mesh %x5|", - 170, 105, 105, 19, &ob->boundtype, 0, 0, 0, 0, "Selects the collision type"); - uiDefButBitI(block, TOG, OB_CHILD, B_REDR, "Compound", 275,105,75,19, + 90, 105, 150, 19, &ob->boundtype, 0, 0, 0, 0, "Selects the collision type"); + uiDefButBitI(block, TOG, OB_CHILD, B_REDR, "Compound", 240,105,110,19, &ob->gameflag, 0, 0, 0, 0, "Add Children"); } diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index 8a3176e16b2..f5a4ac4556a 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -5187,7 +5187,7 @@ void draw_object(Base *base, int flag) } if(dtgameflag & OB_ACTOR) && (ob->gameflag & OB_DYNAMIC)) { + if(/*(ob->gameflag & OB_ACTOR) &&*/ (ob->gameflag & OB_DYNAMIC)) { float tmat[4][4], imat[4][4], vec[3]; vec[0]= vec[1]= vec[2]= 0.0; diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 425e07a257c..593833742e7 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1315,19 +1315,12 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, objprop.m_isCompoundChild = isCompoundChild; objprop.m_hasCompoundChildren = (blenderobject->gameflag & OB_CHILD) != 0; objprop.m_margin = blenderobject->margin; - - if ((objprop.m_isactor = (blenderobject->gameflag & OB_ACTOR)!=0)) - { - objprop.m_dyna = (blenderobject->gameflag & OB_DYNAMIC) != 0; - objprop.m_angular_rigidbody = (blenderobject->gameflag & OB_RIGID_BODY) != 0; - objprop.m_ghost = (blenderobject->gameflag & OB_GHOST) != 0; - objprop.m_disableSleeping = (blenderobject->gameflag & OB_COLLISION_RESPONSE) != 0;//abuse the OB_COLLISION_RESPONSE flag - } else { - objprop.m_dyna = false; - objprop.m_angular_rigidbody = false; - objprop.m_ghost = false; - objprop.m_disableSleeping = false; - } + // ACTOR is now a separate feature + objprop.m_isactor = (blenderobject->gameflag & OB_ACTOR)!=0; + objprop.m_dyna = (blenderobject->gameflag & OB_DYNAMIC) != 0; + objprop.m_angular_rigidbody = (blenderobject->gameflag & OB_RIGID_BODY) != 0; + objprop.m_ghost = (blenderobject->gameflag & OB_GHOST) != 0; + objprop.m_disableSleeping = (blenderobject->gameflag & OB_COLLISION_RESPONSE) != 0;//abuse the OB_COLLISION_RESPONSE flag //mmm, for now, taks this for the size of the dynamicobject // Blender uses inertia for radius of dynamic object objprop.m_radius = blenderobject->inertia; -- cgit v1.2.3