[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13367] branches/cloth/blender/source/ blender: Made GUI even more intuitive with explanations why something is not available etc ., fixed some uninitialized variable.
Daniel Genrich
daniel.genrich at gmx.net
Wed Jan 23 14:24:44 CET 2008
Revision: 13367
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13367
Author: genscher
Date: 2008-01-23 14:24:44 +0100 (Wed, 23 Jan 2008)
Log Message:
-----------
Made GUI even more intuitive with explanations why something is not available etc., fixed some uninitialized variable. NEW: show pinned verts as big red balls in 3dview - please tell me how to improve that visual feedback :)
Modified Paths:
--------------
branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h
branches/cloth/blender/source/blender/blenkernel/intern/cloth.c
branches/cloth/blender/source/blender/makesdna/DNA_cloth_types.h
branches/cloth/blender/source/blender/src/buttons_object.c
branches/cloth/blender/source/blender/src/drawobject.c
Modified: branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h 2008-01-23 11:51:18 UTC (rev 13366)
+++ branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h 2008-01-23 13:24:44 UTC (rev 13367)
@@ -80,6 +80,7 @@
float goal; /* goal, from SB */
float impulse[3]; /* used in collision.c */
unsigned int impulse_count; /* same as above */
+ float avg_spring_len; /* average length of connected springs, UNUSED ATM */
}
ClothVertex;
@@ -156,8 +157,8 @@
} CLOTH_SPRINGS_FLAGS;
/* Bits to or into the ClothVertex.flags. */
-#define CVERT_FLAG_PINNED 1
-#define CVERT_FLAG_COLLISION 2
+#define CLOTH_VERT_FLAG_PINNED 1
+#define CLOTH_VERT_FLAG_COLLISION 2
// needed for buttons_object.c
Modified: branches/cloth/blender/source/blender/blenkernel/intern/cloth.c
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/intern/cloth.c 2008-01-23 11:51:18 UTC (rev 13366)
+++ branches/cloth/blender/source/blender/blenkernel/intern/cloth.c 2008-01-23 13:24:44 UTC (rev 13367)
@@ -124,7 +124,7 @@
static void cloth_to_object ( Object *ob, ClothModifierData *clmd, float ( *vertexCos ) [3], unsigned int numverts );
static void cloth_from_mesh ( Object *ob, ClothModifierData *clmd, DerivedMesh *dm );
static int cloth_from_object ( Object *ob, ClothModifierData *clmd, DerivedMesh *dm, float ( *vertexCos ) [3], unsigned int numverts, float framenr );
-int cloth_build_springs ( Cloth *cloth, DerivedMesh *dm );
+int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm );
static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm, short vgroup );
@@ -502,12 +502,17 @@
Cloth *cloth = clmd->clothObject;
if(!cloth)
+ {
return;
+ }
stack_index = modifiers_indexInObject(ob, (ModifierData *)clmd);
fp = BKE_ptcache_id_fopen((ID *)ob, 'w', framenr, stack_index);
- if(!fp) return;
+ if(!fp)
+ {
+ return;
+ }
for(a = 0; a < cloth->numverts; a++)
{
@@ -554,10 +559,10 @@
}
fclose(fp);
+
+ if(clmd->sim_parms->solver_type == 0)
+ implicit_set_positions(clmd);
}
-
- if(clmd->sim_parms->solver_type == 0)
- implicit_set_positions(clmd);
return ret;
}
@@ -622,6 +627,8 @@
}
}
*/
+
+ // printf("ct: %f, st: %f, r.cfra: %f, dt: %f\n", current_time, clmd->sim_parms->sim_time, ( float ) G.scene->r.cfra, deltaTime);
// unused in the moment, calculated seperately in implicit.c
clmd->sim_parms->dt = 1.0f / clmd->sim_parms->stepsPerFrame;
@@ -681,11 +688,7 @@
cloth_write_cache(ob, clmd, framenr);
}
- else // just retrieve the cached frame
- {
- cloth_read_cache(ob, clmd, framenr);
- }
-
+
// Copy the result back to the object.
cloth_to_object ( ob, clmd, vertexCos, numverts );
@@ -694,12 +697,14 @@
}
}
- else if ( ( deltaTime <= 0.0f ) || ( deltaTime > 1.0f ) )
+ else
{
if ( clmd->clothObject != NULL )
{
if(cloth_read_cache(ob, clmd, framenr))
+ {
cloth_to_object ( ob, clmd, vertexCos, numverts );
+ }
}
else
{
@@ -866,7 +871,7 @@
for ( i = 0; i < numverts; i++, verts++ )
{
VECCOPY ( vertexCos[i], verts->x );
- Mat4MulVecfl ( ob->imat, vertexCos[i] ); /* softbody is in global coords */
+ Mat4MulVecfl ( ob->imat, vertexCos[i] ); /* cloth is in global coords */
}
}
}
@@ -921,9 +926,9 @@
verts->goal = ( float ) pow ( verts->goal , 4.0f );
- if ( dvert->dw [j].weight >=SOFTGOALSNAP )
+ if ( verts->goal >=SOFTGOALSNAP )
{
- verts->flags |= CVERT_FLAG_PINNED;
+ verts->flags |= CLOTH_VERT_FLAG_PINNED;
}
// TODO enable mass painting here, for the moment i let "goals" go first
@@ -1018,7 +1023,7 @@
VECCOPY ( verts->impulse, tnull );
}
- if ( !cloth_build_springs ( clmd->clothObject, dm ) )
+ if ( !cloth_build_springs ( clmd, dm ) )
{
cloth_free_modifier ( ob, clmd );
modifier_setError ( & ( clmd->modifier ), "Can't build springs." );
@@ -1042,11 +1047,11 @@
case OB_LATTICE:
printf ( "Not supported: OB_LATTICE\n" );
// lattice_to_softbody(ob);
- return 1;
+ return 0;
case OB_CURVE:
case OB_SURF:
printf ( "Not supported: OB_SURF| OB_CURVE\n" );
- return 1;
+ return 0;
default: return 0; // TODO - we do not support changing meshes
}
@@ -1123,8 +1128,9 @@
return 0;
}
-int cloth_build_springs ( Cloth *cloth, DerivedMesh *dm )
+int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
{
+ Cloth *cloth = clmd->clothObject;
ClothSpring *spring = NULL, *tspring = NULL, *tspring2 = NULL;
unsigned int struct_springs = 0, shear_springs=0, bend_springs = 0;
unsigned int i = 0;
@@ -1169,6 +1175,7 @@
spring->kl = medge[i].v2;
VECSUB ( temp, cloth->verts[spring->kl].x, cloth->verts[spring->ij].x );
spring->restlen = sqrt ( INPR ( temp, temp ) );
+ clmd->coll_parms->avg_spring_len += spring->restlen;
spring->type = CLOTH_SPRING_TYPE_STRUCTURAL;
spring->flags = 0;
struct_springs++;
@@ -1181,6 +1188,8 @@
}
}
+ clmd->coll_parms->avg_spring_len /= struct_springs;
+
// shear springs
for ( i = 0; i < numfaces; i++ )
{
Modified: branches/cloth/blender/source/blender/makesdna/DNA_cloth_types.h
===================================================================
--- branches/cloth/blender/source/blender/makesdna/DNA_cloth_types.h 2008-01-23 11:51:18 UTC (rev 13366)
+++ branches/cloth/blender/source/blender/makesdna/DNA_cloth_types.h 2008-01-23 13:24:44 UTC (rev 13367)
@@ -89,7 +89,7 @@
short loop_count; /* How many iterations for the collision loop. */
struct LinkNode *collision_list; /* e.g. pointer to temp memory for collisions */
int flags; /* collision flags defined in BKE_cloth.h */
- int pad;
+ float avg_spring_len; /* for selfcollision */
}
CollisionSettings;
Modified: branches/cloth/blender/source/blender/src/buttons_object.c
===================================================================
--- branches/cloth/blender/source/blender/src/buttons_object.c 2008-01-23 11:51:18 UTC (rev 13366)
+++ branches/cloth/blender/source/blender/src/buttons_object.c 2008-01-23 13:24:44 UTC (rev 13367)
@@ -4937,6 +4937,8 @@
block= uiNewBlock(&curarea->uiblocks, "object_cloth", UI_EMBOSS, UI_HELV, curarea->win);
if(uiNewPanel(curarea, block, "Cloth ", "Physics", 640, 0, 318, 204)==0) return;
uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
+
+ val = (clmd ? 1:0);
but = uiDefButI(block, TOG, REDRAWBUTSOBJECT, "Cloth", 10,200,130,20, &val, 0, 0, 0, 0, "Sets object to become cloth");
@@ -4977,12 +4979,10 @@
/* GOAL STUFF */
uiBlockBeginAlign(block);
- if(BLI_countlist (&ob->defbase) > 0)
- {
- uiDefButBitI(block, TOG, CLOTH_SIMSETTINGS_FLAG_GOAL, REDRAWVIEW3D, "Pinning of cloth", 10,70,150,20, &clmd->sim_parms->flags, 0, 0, 0, 0, "Define forces for vertices to stick to animated position");
- }
- if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL)
+ uiDefButBitI(block, TOG, CLOTH_SIMSETTINGS_FLAG_GOAL, REDRAWVIEW3D, "Pinning of cloth", 10,70,150,20, &clmd->sim_parms->flags, 0, 0, 0, 0, "Define forces for vertices to stick to animated position");
+
+ if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (BLI_countlist (&ob->defbase) > 0))
{
if(ob->type==OB_MESH)
{
@@ -5013,13 +5013,9 @@
MEM_freeN (clvg1);
MEM_freeN (clvg2);
}
- else
- {
- uiDefButS(block, TOG, B_CLOTH_RENEW, "W", 140,70,20,20, &clmd->sim_parms->vgroup_mass, 0, 1, 0, 0, "Use control point weight values");
- uiDefButF(block, NUM, B_CLOTH_RENEW, "Goal:", 160,70,150,20, &clmd->sim_parms->defgoal, 0.0, 1.0, 10, 0, "Default Goal (vertex target position) value, when no Vertex Group used");
- }
uiDefButF(block, NUM, B_CLOTH_RENEW, "Pin Stiff:", 10,50,150,20, &clmd->sim_parms->goalspring, 0.0, 500.0, 10, 0, "Pin (vertex target position) spring stiffness");
+ uiDefBut(block, LABEL, 0, " ", 160,50,150,20, NULL, 0.0, 0, 0, 0, "");
/*
// nobody is changing these ones anyway
uiDefButF(block, NUM, B_CLOTH_RENEW, "G Damp:", 160,50,150,20, &clmd->sim_parms->goalfrict , 0.0, 50.0, 10, 0, "Goal (vertex target position) friction");
@@ -5027,6 +5023,12 @@
uiDefButF(block, NUM, B_CLOTH_RENEW, "G Max:", 160,30,150,20, &clmd->sim_parms->maxgoal, 0.0, 1.0, 10, 0, "Goal maximum, vertex group weights are scaled to match this range");
*/
}
+ else if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL)
+ {
+ uiDefBut(block, LABEL, 0, " ", 160,70,150,20, NULL, 0.0, 0, 0, 0, "");
+ uiDefBut(block, LABEL, 0, "No vertex group for pinning available.", 10,50,300,20, NULL, 0.0, 0, 0, 0, "");
+ }
+
uiBlockEndAlign(block);
/*
@@ -5078,18 +5080,26 @@
sprintf (str, "Frame %d cached. [%d in preroll, %d in total]", length-clmd->sim_parms->preroll, clmd->sim_parms->preroll, length);
*/
- uiDefButBitI(block, TOG, CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT, REDRAWVIEW3D, "Protect Cache", 10,120,300,20, &clmd->sim_parms->flags, 0, 0, 0, 0, "Protect cache from automatic freeing when scene changed");
-
- if(!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT))
+ if (!G.relbase_valid)
{
- uiDefBut(block, LABEL, 0, "Clear cache:", 10,100,90,20, NULL, 0.0, 0, 0, 0, "");
- uiDefBut(block, BUT, B_CLOTH_CLEARCACHEALL, "All", 100, 100,100,20, NULL, 0.0, 0.0, 0, 0, "Free ALL cloth cache without preroll");
- uiDefBut(block, BUT, B_CLOTH_CLEARCACHEFRAME, "From next frame", 200, 100,110,20, NULL, 0.0, 0.0, 0, 0, "Free cloth cache starting from next frame");
- uiDefBut(block, LABEL, 0, " ", 10,80,300,20, NULL, 0.0, 0, 0, 0, "");
+ uiDefBut(block, LABEL, 0, "Cache deactivated until file is saved.", 10,120,300,20, NULL, 0.0, 0, 0, 0, "");
+ uiDefBut(block, LABEL, 0, " ", 10,100,300,40, NULL, 0.0, 0, 0, 0, "");
}
else
{
- uiDefBut(block, LABEL, 0, " ", 10,100,300,40, NULL, 0.0, 0, 0, 0, "");
+ uiDefButBitI(block, TOG, CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT, REDRAWVIEW3D, "Protect Cache", 10,120,300,20, &clmd->sim_parms->flags, 0, 0, 0, 0, "Protect cache from automatic freeing when scene changed");
+
+ if(!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT))
+ {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list