Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2004-10-01 18:04:17 +0400
committerTon Roosendaal <ton@blender.org>2004-10-01 18:04:17 +0400
commit04f5baee3a8ccfbe21c3f9eed49809f24fd7fddf (patch)
tree944e6e6b5b7dbc9711d9d1a87f3c158c6a3fd137 /source
parentd818141744bff49c8c7ae6befd7ba901bd2d869f (diff)
OK. Here's the long awaited first step (V0.01!) of SoftBody. It is called
from within mesh_modifiers (kernel deform.c). It copies vertices to a temporal particle system (struct SoftBody with BodyPoint structs) to do physics tricks with it. For each frame change the delta movements (based on standard ipo anim or even other deforms (later) are applied to the physics system. How to apply and calculate satisfying results is not my thing... so here I'll commu- nicate with others for. Since it's in the modifier stack, the SoftBody code can run entirely on original data (no displists!). Right now I've implemented 2 things; - "Goal" which is a per vertex value for how much the current position should take into account (goal=1 is without physics). This is a powerful method for artists to get control over what moves and not. Right now i read the vertex color for it. - And some spring stuff, which now only works based on force moving it to the originial location. This doesnt work with 'goal'... erhm. - You can re-use physics vars from engine, used right now is (in Object) - damping - springf (spring factor) - softflag (to set types, or activate softbody for it - The SoftBody pointer in struct Object is only runtime, nothing saved in file To prevent all users going to complain it doesn't work, I've hidden the functionality. :) The buttons to set softbody 'on' only show now (psst psst) when the object has name "soft" as first 4 characters. You can find the buttons in the F7 Particle Interaction Panel (which should be renamed 'physics properties' later or so. Demo file: http://www.blender.org/bf/softbody.blend
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/deform.c15
-rw-r--r--source/blender/blenkernel/intern/displist.c3
-rw-r--r--source/blender/blenkernel/intern/object.c3
-rw-r--r--source/blender/blenloader/intern/readfile.c3
-rw-r--r--source/blender/makesdna/DNA_object_types.h8
-rw-r--r--source/blender/src/buttons_object.c7
-rw-r--r--source/blender/src/drawobject.c1
-rw-r--r--source/blender/src/editobject.c3
8 files changed, 36 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index 8149d4540d8..fbf13cba810 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -45,12 +45,16 @@
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
#include "BKE_curve.h"
#include "BKE_deform.h"
#include "BKE_displist.h"
#include "BKE_effect.h"
+#include "BKE_global.h"
#include "BKE_lattice.h"
+#include "BKE_object.h"
+#include "BKE_softbody.h"
#include "BKE_utildefines.h"
#include "BLI_blenlib.h"
@@ -214,6 +218,7 @@ int mesh_modifier(Object *ob, char mode)
else if(ob->effect.first); // weak... particles too
else if(ob->parent && ob->parent->type==OB_LATTICE);
else if(ob->parent && ob->partype==PARSKEL);
+ else if(ob->softflag);
else return 0;
if(me->totvert==0) return 0;
@@ -235,8 +240,14 @@ int mesh_modifier(Object *ob, char mode)
}
if(ob->effect.first) done |= object_wave(ob);
-
- /* deform: input mesh, output ob dl_verts. is used by subsurf */
+
+ if(ob->softflag) {
+ float ctime= bsystem_time(ob, NULL, (float)G.scene->r.cfra, 0.0);
+ done= 1;
+ object_softbody_step(ob, ctime);
+ }
+
+ /* deform: input mesh, output ob dl_verts. is used by subsurf (output should be in mesh ton!) */
done |= object_deform(ob);
/* put deformed vertices in dl->verts, optional subsurf will replace that */
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index d1542165686..d7b58f65aa9 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -2371,7 +2371,8 @@ void test_all_displists(void)
break;
}
}
-
+
+ if(ob->softflag) freedisplist_object(ob);
/* warn, ob pointer changed in case of OB_MALL */
if ELEM(ob->type, OB_CURVE, OB_SURF) {
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index b4b8203355b..40cc3b1fa61 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -101,6 +101,7 @@
#include "BKE_lattice.h"
#include "BKE_constraint.h"
#include "BKE_scene.h"
+#include "BKE_softbody.h"
#include "BPY_extern.h"
@@ -211,6 +212,7 @@ void free_object(Object *ob)
BPY_free_scriptlink(&ob->scriptlink);
if(ob->pd) MEM_freeN(ob->pd);
+ if(ob->soft) free_softbody(ob->soft);
}
void unlink_object(Object *ob)
@@ -770,6 +772,7 @@ Object *copy_object(Object *ob)
obn->disp.first= obn->disp.last= NULL;
obn->hooks.first= obn->hooks.last= NULL;
+ obn->soft= NULL;
return obn;
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 406e52a1919..25147dff5e9 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2304,7 +2304,8 @@ static void direct_link_object(FileData *fd, Object *ob)
}
ob->pd= newdataadr(fd, ob->pd);
-
+ ob->soft= NULL;
+
link_list(fd, &ob->prop);
prop= ob->prop.first;
while(prop) {
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 2905b2eeb09..923e76f4153 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -51,6 +51,7 @@ struct BoundBox;
struct Path;
struct Material;
struct bConstraintChannel;
+struct SoftBody;
typedef struct bDeformGroup {
struct bDeformGroup *next, *prev;
@@ -149,7 +150,7 @@ typedef struct Object {
* For a Sphere, the form factor is by default = 0.4
*/
- float formfactor, dummy_1;
+ float formfactor, springf; /* springf temp for softbody */
float rdamping, sizefac;
char dt, dtx;
@@ -185,14 +186,15 @@ typedef struct Object {
* bit 15: Always ignore activity culling
*/
int gameflag2;
- int pad;
+ short softflag, pad; /* temporal stuff softbody experiment */
float anisotropicFriction[3];
ListBase constraints;
ListBase nlastrips;
ListBase hooks;
- PartDeflect *pd; /* particle deflector/attractor/collision data */
+ PartDeflect *pd; /* particle deflector/attractor/collision data */
+ struct SoftBody *soft; /* only runtime, not saved in file! */
struct Life *life;
LBuf lbuf;
diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c
index e57f8ee911a..d6a4aab311f 100644
--- a/source/blender/src/buttons_object.c
+++ b/source/blender/src/buttons_object.c
@@ -1413,6 +1413,13 @@ static void object_panel_deflectors(Object *ob)
uiDefButF(block, NUM, B_DIFF, "Rnd Damping: ", 10,10,200,20, &ob->pd->pdef_rdamp, 0.0, 1.0, 10, 0, "Random variation of damping");
uiDefButF(block, NUM, B_DIFF, "Permeability: ", 10,-10,200,20, &ob->pd->pdef_perm, 0.0, 1.0, 10, 0, "Chance that the particle will pass through the mesh");
}
+ uiBlockEndAlign(block);
+ }
+
+ if(strncmp(ob->id.name+2, "soft", 4)==0) {
+ uiDefButS(block, TOG|BIT|0, B_DIFF, "Soft Body", 220,160,200,20, &ob->softflag, 0, 0, 0, 0, "Sets object to become soft body");
+ uiDefButF(block, NUM, B_DIFF, "Spring: ", 220,140,200,20, &ob->springf, 0.0, 1.0, 10, 0, "Spring constant");
+ uiDefButF(block, NUM, B_DIFF, "Damp: ", 220,120,200,20, &ob->damping, 0.0, 1.0, 10, 0, "General damping in softbody on point movements");
}
}
diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c
index dc2c5fce456..c4a0dc92f56 100644
--- a/source/blender/src/drawobject.c
+++ b/source/blender/src/drawobject.c
@@ -4105,6 +4105,7 @@ void draw_object(Base *base)
if(ob->parent && ob->partype==PARSKEL) makeDispList(ob);
else if(ob->hooks.first) makeDispList(ob);
else if(ob->effect.first) makeDispList(ob);
+ else if(ob->softflag) makeDispList(ob);
else if(me->disp.first==NULL && mesh_uses_displist(me)) makeDispList(ob);
}
}
diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c
index 6b58e260e2d..7617660ec15 100644
--- a/source/blender/src/editobject.c
+++ b/source/blender/src/editobject.c
@@ -113,6 +113,7 @@
#include "BKE_property.h"
#include "BKE_sca.h"
#include "BKE_scene.h"
+#include "BKE_softbody.h"
#include "BKE_subsurf.h"
#include "BKE_texture.h"
#include "BKE_utildefines.h"
@@ -1547,6 +1548,8 @@ void exit_editmode(int freedata) /* freedata==0 at render, 1= freedata, 2= do un
}
scrarea_queue_headredraw(curarea);
+ if(ob->softflag) object_to_softbody(ob);
+
if(G.obedit==NULL && freedata==2)
BIF_undo_push("Editmode");
}