Integration stage of Softbody project

User level notes are in Wiki here;
http://wiki.blender.org/bin/view.pl/Blenderdev/Softbodies
And will be added in blender3d.org CMS later.

Tech level notes are still pending, but here's the most relevant ones;

- made ob->soft struct SoftBody to hold all settings, and read/save in
  files
- added (temporal!) conversion for the old settings. So: read old files
  with softbody experiments now, and save over!
- cleaned API calls for softbody, which are only 5 of them now:
  sbNew()
  sbFree()
  sbObjectStep()          (animation steps)
  sbObjectToSoftbody()    (full re-initialize data)
  sbObjectReset()         (only reset motion)
- API calls accepts time in frames now, within softbody.c it converts

Further, internally code was cleaned some (missing tabs etc). Also tried
to keep a well defined structure with hints how to add support for more
objects. Can write notes about that...
This commit is contained in:
2005-04-02 13:57:23 +00:00
parent 02d3ad0b34
commit bdb86d7c67
13 changed files with 559 additions and 496 deletions

View File

@@ -47,6 +47,7 @@
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_library.h"
#include "BKE_softbody.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
@@ -1439,34 +1440,6 @@ static void object_panel_deflectors(Object *ob)
}
uiBlockEndAlign(block);
}
/*
if(strncmp(ob->id.name+2, "soft", 4)==0) {
int ypos = 220;
uiBlockBeginAlign(block);
uiDefButS(block, TOG|BIT|0, B_DIFF, "Soft Body", 220,ypos,200,20, &ob->softflag, 0, 0, 0, 0, "Sets object to become soft body");
uiDefButS(block, TOG|BIT|1, B_DIFF, "Stiff Quads", 220,ypos -= 20,100,20, &ob->softflag, 0, 0, 0, 0, "Sets object to have diagonal springs on 4-gons");
uiDefButS(block, TOG|BIT|2, B_DIFF, "R sol 1", 320,ypos,100,20, &ob->softflag, 0, 0, 0, 0, "Use Robust 2nd order solver");
uiDefButF(block, NUMSLI, B_DIFF, "GSpring:", 220,ypos -= 20,200,20, &ob->sb_goalspring, 0.0, 0.999, 10, 0, "Goal Spring Constant");
uiDefButF(block, NUM, B_DIFF, "GFrict:", 220,ypos -= 20,200,20, &ob->sb_goalfrict , 0.0, 10.0, 10, 0, "Goal Friction Constant");
uiDefButF(block, NUMSLI, B_DIFF, "ISpring:", 220,ypos -= 20,200,20, &ob->sb_inspring, 0.0, 0.999, 10, 0, "Inner Spring Constant");
uiDefButF(block, NUM, B_DIFF, "IFrict:", 220,ypos -= 20,200,20, &ob->sb_infrict, 0.0, 10.0, 10, 0, "Inner Friction Constant");
uiDefButF(block, NUM, B_DIFF, "MFrict:", 220,ypos -= 20,200,20, &ob->sb_mediafrict, 0.0, 10.0, 10, 0, "Friction in media");
if (ob->softflag & 0x4)
uiDefButF(block, NUMSLI, B_DIFF, "RKL:", 220,ypos -= 20,200,20, &ob->softtime , 0.01, 1.0, 10, 0, "ODE solver error limit");
else
uiDefButF(block, NUM, B_DIFF, "Steps:", 220,ypos -= 20,200,20, &ob->softtime , 1.0, 500.0, 10, 0, "Softbody time");
uiDefButF(block, NUM, B_DIFF, "NMass:", 220,ypos -= 20,200,20, &ob->sb_nodemass , 0.001, 50.0, 10, 0, "Node Mass");
uiDefButF(block, NUM, B_DIFF, "Grav:", 220,ypos -= 20,200,20, &ob->sb_grav , 0.0, 10.0, 10, 0, "Gravitation");
uiDefButF(block, NUMSLI, B_DIFF, "GMin:", 220,ypos -= 20,200,20, &ob->sb_mingoal, 0.0, 1.0, 10, 0, "Min Goal bound");
uiDefButF(block, NUMSLI, B_DIFF, "GMax:", 220,ypos -= 20,200,20, &ob->sb_maxgoal, 0.0, 1.0, 10, 0, "Max Goal bound");
uiDefButS(block, TOG|BIT|3, B_DIFF, "PostDef",220,ypos-= 20,100,20, &ob->softflag, 0, 0, 0, 0, "Apply Soft AFTER Deform");
uiBlockEndAlign(block);
}
*/
}
/* Panel for softbodies */
@@ -1474,36 +1447,50 @@ static void object_panel_deflectors(Object *ob)
static void object_softbodies(Object *ob)
{
uiBlock *block;
int ypos = 220;
if(strncmp(ob->id.name+2, "soft", 4)!=0) {return;}
block= uiNewBlock(&curarea->uiblocks, "object_softbodies", UI_EMBOSS, UI_HELV, curarea->win);
uiNewPanelTabbed("Constraints", "Object");
if(uiNewPanel(curarea, block, "Softbodies", "Object", 640, 0, 318, 204)==0) return;
if(uiNewPanel(curarea, block, "Softbody", "Object", 640, 0, 318, 204)==0) return;
uiBlockBeginAlign(block);
uiDefButS(block, TOG|BIT|0, REDRAWBUTSOBJECT, "Soft Body", 220,ypos,200,20, &ob->softflag, 0, 0, 0, 0, "Sets object to become soft body");
if ( ob->softflag & 0x01) {
uiDefButS(block, TOG|BIT|1, B_DIFF, "Stiff Quads", 220,ypos -= 20,100,20, &ob->softflag, 0, 0, 0, 0, "Sets object to have diagonal springs on 4-gons");
uiDefButS(block, TOG|BIT|2, B_DIFF, "R sol 1", 320,ypos,100,20, &ob->softflag, 0, 0, 0, 0, "Use Robust 2nd order solver");
uiDefButBitS(block, TOG, OB_SB_ENABLE, REDRAWBUTSOBJECT, "Enable Soft Body", 10,200,150,20, &ob->softflag, 0, 0, 0, 0, "Sets object to become soft body");
uiDefBut(block, LABEL, 0, "", 160, 200,150,20, NULL, 0.0, 0.0, 0, 0, ""); // alignment reason
if(ob->softflag & OB_SB_ENABLE) {
SoftBody *sb= ob->soft;
uiDefButF(block, NUMSLI, B_DIFF, "GSpring:", 220,ypos -= 20,200,20, &ob->sb_goalspring, 0.0, 0.999, 10, 0, "Goal Spring Constant");
uiDefButF(block, NUM, B_DIFF, "GFrict:", 220,ypos -= 20,200,20, &ob->sb_goalfrict , 0.0, 10.0, 10, 0, "Goal Friction Constant");
uiDefButF(block, NUMSLI, B_DIFF, "ISpring:", 220,ypos -= 20,200,20, &ob->sb_inspring, 0.0, 0.999, 10, 0, "Inner Spring Constant");
uiDefButF(block, NUM, B_DIFF, "IFrict:", 220,ypos -= 20,200,20, &ob->sb_infrict, 0.0, 10.0, 10, 0, "Inner Friction Constant");
uiDefButF(block, NUM, B_DIFF, "MFrict:", 220,ypos -= 20,200,20, &ob->sb_mediafrict, 0.0, 10.0, 10, 0, "Friction in media");
if (ob->softflag & 0x4)
uiDefButF(block, NUMSLI, B_DIFF, "RKL:", 220,ypos -= 20,200,20, &ob->softtime , 0.01, 1.0, 10, 0, "ODE solver error limit");
else
uiDefButF(block, NUM, B_DIFF, "Steps:", 220,ypos -= 20,200,20, &ob->softtime , 1.0, 500.0, 10, 0, "Softbody time");
uiDefButF(block, NUM, B_DIFF, "NMass:", 220,ypos -= 20,200,20, &ob->sb_nodemass , 0.001, 50.0, 10, 0, "Node Mass");
uiDefButF(block, NUM, B_DIFF, "Grav:", 220,ypos -= 20,200,20, &ob->sb_grav , 0.0, 10.0, 10, 0, "Gravitation");
uiDefButF(block, NUMSLI, B_DIFF, "GMin:", 220,ypos -= 20,200,20, &ob->sb_mingoal, 0.0, 1.0, 10, 0, "Min Goal bound");
uiDefButF(block, NUMSLI, B_DIFF, "GMax:", 220,ypos -= 20,200,20, &ob->sb_maxgoal, 0.0, 1.0, 10, 0, "Max Goal bound");
uiDefButS(block, TOG|BIT|3, B_DIFF, "PostDef",220,ypos-= 20,100,20, &ob->softflag, 0, 0, 0, 0, "Apply Soft AFTER Deform");
if(sb==NULL) {
sb= ob->soft= sbNew();
ob->softflag |= OB_SB_GOAL|OB_SB_EDGES;
}
/* GENERAL STUFF */
uiBlockBeginAlign(block);
uiDefButF(block, NUM, B_DIFF, "Friction:", 10, 170,150,20, &sb->mediafrict, 0.0, 10.0, 10, 0, "General Friction for point movements");
uiDefButF(block, NUM, B_DIFF, "Mass:", 160, 170,150,20, &sb->nodemass , 0.001, 50.0, 10, 0, "Point Mass, the heavier the slower");
uiDefButF(block, NUM, B_DIFF, "Grav:", 10,150,150,20, &sb->grav , 0.0, 10.0, 10, 0, "Apply gravitation to point movement");
uiDefButF(block, NUM, B_DIFF, "RKL:", 160,150,150,20, &sb->rklimit , 0.01, 1.0, 10, 0, "Runge-Kutta ODE solver error limit");
uiDefButBitS(block, TOG, OB_SB_POSTDEF, B_DIFF, "PostDef", 10,130,300,20, &ob->softflag, 0, 0, 0, 0, "Apply Soft AFTER Deform");
uiBlockEndAlign(block);
/* GOAL STUFF */
uiBlockBeginAlign(block);
uiDefButBitS(block, TOG, OB_SB_GOAL, B_DIFF, "Use Goal", 10,100,150,20, &ob->softflag, 0, 0, 0, 0, "Define forces for vertices to stick to animated position");
uiDefButF(block, NUM, B_DIFF, "GSpring:", 10,80,150,20, &sb->goalspring, 0.0, 0.999, 10, 0, "Goal (vertex target position) Spring Constant");
uiDefButF(block, NUM, B_DIFF, "GFrict:", 160,80,150,20, &sb->goalfrict , 0.0, 10.0, 10, 0, "Goal (vertex target position) Friction Constant");
uiDefButF(block, NUM, B_DIFF, "GMin:", 10,60,150,20, &sb->mingoal, 0.0, 1.0, 10, 0, "Min Goal bound");
uiDefButF(block, NUM, B_DIFF, "GMax:", 160,60,150,20, &sb->maxgoal, 0.0, 1.0, 10, 0, "Max Goal bound");
uiBlockEndAlign(block);
/* EDGE SPRING STUFF */
uiBlockBeginAlign(block);
uiDefButBitS(block, TOG, OB_SB_EDGES, B_DIFF, "Use Edges", 10,30,150,20, &ob->softflag, 0, 0, 0, 0, "Use Robust 2nd order solver");
uiDefButBitS(block, TOG, OB_SB_QUADS, B_DIFF, "Stiff Quads", 160,30,150,20, &ob->softflag, 0, 0, 0, 0, "Sets object to have diagonal springs on 4-gons");
uiDefButF(block, NUM, B_DIFF, "ESpring:", 10,10,150,20, &sb->inspring, 0.0, 0.999, 10, 0, "Edge Spring Constant");
uiDefButF(block, NUM, B_DIFF, "EFrict:", 160,10,150,20, &sb->infrict, 0.0, 10.0, 10, 0, "Edge Friction Constant");
uiBlockEndAlign(block);
}
uiBlockEndAlign(block);
}