Revision: 16726
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16726
Author:   erwin
Date:     2008-09-25 18:48:25 +0200 (Thu, 25 Sep 2008)

Log Message:
-----------
re-use some Blender soft body settings for Bullet game soft bodies

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/object.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/makesdna/DNA_object_types.h
    trunk/blender/source/blender/src/buttons_logic.c
    trunk/blender/source/blender/src/editobject.c
    trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
    trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp

Modified: trunk/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c     2008-09-25 
16:35:53 UTC (rev 16725)
+++ trunk/blender/source/blender/blenkernel/intern/object.c     2008-09-25 
16:48:25 UTC (rev 16726)
@@ -964,11 +964,7 @@
        ob->anisotropicFriction[2] = 1.0f;
        ob->gameflag= OB_PROP|OB_COLLISION;
        ob->margin = 0.0;
-       ob->linearStiffness = 1.0f;
-       ob->angularStiffness = 1.0f;
-       ob->volumePreservation = 1.0f;
-       ob->gamesoftFlag = OB_SOFT_SHAPE_MATCHING;
-
+       
        /* NT fluid sim defaults */
        ob->fluidsimFlag = 0;
        ob->fluidsimSettings = NULL;

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c   2008-09-25 
16:35:53 UTC (rev 16725)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c   2008-09-25 
16:48:25 UTC (rev 16726)
@@ -7850,10 +7850,6 @@
                        if (!(ob->gameflag & OB_ACTOR))
                                ob->gameflag &= 
~(OB_GHOST|OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_COLLISION_RESPONSE);
                        /* suitable default for older files */
-                       ob->linearStiffness = 1.0f;
-                       ob->angularStiffness = 1.0f;
-                       ob->volumePreservation = 1.0f;
-                       ob->softflag = OB_SOFT_SHAPE_MATCHING;
                }
        }
 

Modified: trunk/blender/source/blender/makesdna/DNA_object_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_object_types.h    2008-09-25 
16:35:53 UTC (rev 16725)
+++ trunk/blender/source/blender/makesdna/DNA_object_types.h    2008-09-25 
16:48:25 UTC (rev 16726)
@@ -157,15 +157,8 @@
        float formfactor;
        float rdamping, sizefac;
        float margin;
-       /* for game engine soft body */
-       float linearStiffness;
-       float angularStiffness;
-       float volumePreservation;
-       int   gamesoftFlag;
        int   pad3;
 
-
-
        char dt, dtx;
        char totcol;    /* copy of mesh or curve or meta */
        char actcol;    /* currently selected material in the user interface */
@@ -418,8 +411,6 @@
 #define OB_RECALC_TIME         4
 #define OB_RECALC                      7
 
-/* ob->gamesoftFlag */
-#define OB_SOFT_SHAPE_MATCHING 1
 
 /* ob->gameflag */
 #define OB_DYNAMIC             1

Modified: trunk/blender/source/blender/src/buttons_logic.c
===================================================================
--- trunk/blender/source/blender/src/buttons_logic.c    2008-09-25 16:35:53 UTC 
(rev 16725)
+++ trunk/blender/source/blender/src/buttons_logic.c    2008-09-25 16:48:25 UTC 
(rev 16726)
@@ -49,6 +49,7 @@
 #include "DNA_controller_types.h"
 #include "DNA_property_types.h"
 #include "DNA_object_types.h"
+#include "DNA_object_force.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
 #include "DNA_scene_types.h"
@@ -2926,9 +2927,9 @@
                        uiBlockBeginAlign(block);
                        uiDefButBitI(block, TOG, OB_BOUNDS, B_REDR, "Bounds", 
10, 105, 75, 19,
                                        &ob->gameflag, 0, 0,0, 0,
-                                       "Specify a bounds object for physics");
+                                       "Specify a collision shape bounds 
type");
                        if (ob->gameflag & OB_BOUNDS) {
-                               uiDefButS(block, MENU, REDRAWVIEW3D, "Boundary 
Display%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Convex Hull%x5|Static 
TriangleMesh %x4",
+                               uiDefButS(block, MENU, REDRAWVIEW3D, "Collision 
Type%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Convex Hull%x5|Concave TriangleMesh 
%x4",
                                        85, 105, 160, 19, &ob->boundtype, 0, 0, 
0, 0, "Selects the collision type");
                                uiDefButBitI(block, TOG, OB_CHILD, B_REDR, 
"Compound", 250,105,100,19, 
                                                &ob->gameflag, 0, 0, 0, 0, 
@@ -3009,22 +3010,30 @@
                                "Collision margin");
        }
        if (ob->gameflag & OB_SOFT_BODY) {
-               uiDefButBitI(block, TOG, OB_SOFT_SHAPE_MATCHING, 0, "Shape 
matching", 
-                                       xco+=120, yco, 118, 19, 
&ob->gamesoftFlag, 0, 0, 0, 0, 
-                                       "Enable soft body shape matching");
-               yco -= 25;
-               xco = 0;
-               uiDefButF(block, NUMSLI, 0, "LinStiff ", xco, yco, 238, 19, 
-                               &ob->linearStiffness, 0.0, 1.0, 1, 0, 
-                               "Linear stiffness of the soft body vertex 
spring");
-               yco -= 25;
-               uiDefButF(block, NUMSLI, 0, "AngStiff ", xco, yco, 238, 19, 
-                               &ob->angularStiffness, 0.0, 1.0, 1, 0, 
-                               "Angular stiffness of the soft body vertex 
spring");
-               yco -= 25;
-               uiDefButF(block, NUMSLI, 0, "Volume ", xco, yco, 238, 19, 
-                               &ob->volumePreservation, 0.0, 1.0, 1, 0, 
-                               "Factor of soft body volume preservation");
+               if (ob->soft)
+               {
+                       
+                       uiDefButBitI(block, TOG, OB_SB_GOAL, 0, "Shape 
matching", 
+                                               xco+=120, yco, 118, 19, 
&ob->softflag, 0, 0, 0, 0, 
+                                               "Enable soft body shape 
matching goal");
+                       yco -= 25;
+                       xco = 0;
+                       uiDefButF(block, NUMSLI, 0, "LinStiff ", xco, yco, 238, 
19, 
+                                       &ob->soft->inspring, 0.0, 1.0, 1, 0,
+                                       "Linear stiffness of the soft body 
vertex spring");
+                       /*
+                       yco -= 25;
+                       uiDefButF(block, NUMSLI, 0, "AngStiff ", xco, yco, 238, 
19, 
+                                       &ob->angularStiffness, 0.0, 1.0, 1, 0, 
+                                       "Angular stiffness of the soft body 
vertex spring");
+                       yco -= 25;
+                       uiDefButF(block, NUMSLI, 0, "Volume ", xco, yco, 238, 
19, 
+                                       &ob->volumePreservation, 0.0, 1.0, 1, 
0, 
+                                       "Factor of soft body volume 
preservation");
+                                       */
+
+               }
+
        }
 
                        
@@ -3049,10 +3058,21 @@
        else
                ob->body_type = OB_BODY_TYPE_SOFT;
 
-       but = uiDefButS(block, MENU, REDRAWVIEW3D, 
-                       "Object type%t|No 
collision%x0|Static%x1|Dynamic%x2|Rigid body%x3|Soft body%x4", 
-                       10, 205, 120, 19, &ob->body_type, 0, 0, 0, 0, "Selects 
the type of physical representation");
-       uiButSetFunc(but, check_body_type, but, ob);
+       //only enable game soft body if Blender Soft Body exists
+       if (ob->soft)
+       {
+               but = uiDefButS(block, MENU, REDRAWVIEW3D, 
+                               "Object type%t|No 
collision%x0|Static%x1|Dynamic%x2|Rigid body%x3|Soft body%x4", 
+                               10, 205, 120, 19, &ob->body_type, 0, 0, 0, 0, 
"Selects the type of physical representation");
+               uiButSetFunc(but, check_body_type, but, ob);
+       } else
+       {
+               but = uiDefButS(block, MENU, REDRAWVIEW3D, 
+                               "Object type%t|No 
collision%x0|Static%x1|Dynamic%x2|Rigid body%x3", 
+                               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) {
 
@@ -3088,9 +3108,9 @@
                uiBlockBeginAlign(block);
                uiDefButBitI(block, TOG, OB_BOUNDS, B_REDR, "Bounds", 10, 105, 
80, 19,
                                &ob->gameflag, 0, 0, 0, 0,
-                               "Specify a bounds object for physics");
+                               "Specify a collision bounds type");
                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",
+                       uiDefButS(block, MENU, REDRAWVIEW3D, "Collision 
Bounds%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Convex Hull%x5|Triangle 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|",
                                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, 

Modified: trunk/blender/source/blender/src/editobject.c
===================================================================
--- trunk/blender/source/blender/src/editobject.c       2008-09-25 16:35:53 UTC 
(rev 16725)
+++ trunk/blender/source/blender/src/editobject.c       2008-09-25 16:48:25 UTC 
(rev 16726)
@@ -3529,10 +3529,10 @@
                                                base->object->boundtype = 
ob->boundtype;
                                        }
                                        base->object->margin= ob->margin;
-                                       base->object->linearStiffness= 
ob->linearStiffness;
-                                       base->object->angularStiffness= 
ob->angularStiffness;
-                                       base->object->volumePreservation= 
ob->volumePreservation;
-                                       base->object->gamesoftFlag= 
ob->gamesoftFlag;
+                                       //base->object->linearStiffness= 
ob->linearStiffness;
+                                       //base->object->angularStiffness= 
ob->angularStiffness;
+                                       //base->object->volumePreservation= 
ob->volumePreservation;
+                                       //base->object->gamesoftFlag= 
ob->gamesoftFlag;
                                }
                                else if(event==17) {    /* tex space */
                                        copy_texture_space(base->object, ob);

Modified: trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp      
2008-09-25 16:35:53 UTC (rev 16725)
+++ trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp      
2008-09-25 16:48:25 UTC (rev 16726)
@@ -129,6 +129,7 @@
 #include "DNA_sound_types.h"
 #include "DNA_key_types.h"
 #include "DNA_armature_types.h"
+#include "DNA_object_force.h"
 
 #include "MEM_guardedalloc.h"
 #include "BKE_utildefines.h"
@@ -1323,10 +1324,20 @@
        objprop.m_angular_rigidbody = (blenderobject->gameflag & OB_RIGID_BODY) 
!= 0;
        
        ///for game soft bodies
-       objprop.m_linearStiffness = blenderobject->linearStiffness;
-       objprop.m_angularStiffness = blenderobject->angularStiffness;
-       objprop.m_volumePreservation = blenderobject->volumePreservation;
-       objprop.m_gamesoftFlag = blenderobject->gamesoftFlag;
+       if (blenderobject->soft)
+       {
+               objprop.m_linearStiffness = blenderobject->soft->inspring;
+               objprop.m_angularStiffness = 
1.f;//blenderobject->angularStiffness;
+               objprop.m_volumePreservation = 
1.f;//blenderobject->volumePreservation;
+               objprop.m_gamesoftFlag = 
blenderobject->softflag;//blenderobject->gamesoftFlag;
+               
+       } else
+       {
+               objprop.m_linearStiffness = 
0.5;//blenderobject->linearStiffness;
+               objprop.m_angularStiffness = 
1.f;//blenderobject->angularStiffness;
+               objprop.m_volumePreservation = 
1.f;//blenderobject->volumePreservation;
+               objprop.m_gamesoftFlag = 1;//blenderobject->gamesoftFlag;
+       }
 
        objprop.m_ghost = (blenderobject->gameflag & OB_GHOST) != 0;
        objprop.m_disableSleeping = (blenderobject->gameflag & 
OB_COLLISION_RESPONSE) != 0;//abuse the OB_COLLISION_RESPONSE flag

Modified: 
trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
===================================================================
--- trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp     
2008-09-25 16:35:53 UTC (rev 16725)
+++ trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp     
2008-09-25 16:48:25 UTC (rev 16726)
@@ -346,7 +346,6 @@
                
 
                
-
                //pm->m_kAST = 0.01f;
                //pm->m_kVST = 0.001f;
                psb->generateBendingConstraints(2,pm);
@@ -354,7 +353,7 @@
                //psb->m_cfg.viterations                =       4;
                //psb->m_cfg.diterations = 4;
                //psb->m_cfg.citerations = 4;

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to