[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28980] branches/render25: Render Branch: bring cloth solver code a bit more in line with trunk again
Brecht Van Lommel
brecht at blender.org
Tue May 25 16:14:31 CEST 2010
Revision: 28980
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28980
Author: blendix
Date: 2010-05-25 16:14:31 +0200 (Tue, 25 May 2010)
Log Message:
-----------
Render Branch: bring cloth solver code a bit more in line with trunk again
* goal code using springs is now enabled again by default for cloth, with
an option to use the different goal code available.
* hair collisions now update tv instead of tx, just like cloth does.
* extra collision solve step is only done if necessary again.
Modified Paths:
--------------
branches/render25/release/scripts/ui/properties_particle.py
branches/render25/release/scripts/ui/properties_physics_cloth.py
branches/render25/source/blender/blenkernel/BKE_cloth.h
branches/render25/source/blender/blenkernel/BKE_collision.h
branches/render25/source/blender/blenkernel/intern/cloth.c
branches/render25/source/blender/blenkernel/intern/collision.c
branches/render25/source/blender/blenkernel/intern/implicit.c
branches/render25/source/blender/blenkernel/intern/particle_system.c
branches/render25/source/blender/makesrna/intern/rna_cloth.c
Modified: branches/render25/release/scripts/ui/properties_particle.py
===================================================================
--- branches/render25/release/scripts/ui/properties_particle.py 2010-05-25 13:50:36 UTC (rev 28979)
+++ branches/render25/release/scripts/ui/properties_particle.py 2010-05-25 14:14:31 UTC (rev 28980)
@@ -252,7 +252,6 @@
col = split.column()
col.label(text="Material:")
sub = col.column(align=True)
- sub.prop(cloth, "pin_stiffness", text="Stiffness")
sub.prop(cloth, "mass")
sub.prop(cloth, "structural_stiffness", text="Structural")
sub.prop(cloth, "bending_stiffness", text="Bending")
@@ -270,6 +269,9 @@
col.label(text="Quality:")
col.prop(cloth, "quality", text="Steps", slider=True)
+ col.label(text="Pinning:")
+ col.prop(cloth, "pin_stiffness", text="Stiffness")
+ # col.prop(cloth, "pin_use_springs", text="Use Springs")
class PARTICLE_PT_cache(ParticleButtonsPanel):
bl_label = "Cache"
Modified: branches/render25/release/scripts/ui/properties_physics_cloth.py
===================================================================
--- branches/render25/release/scripts/ui/properties_physics_cloth.py 2010-05-25 13:50:36 UTC (rev 28979)
+++ branches/render25/release/scripts/ui/properties_physics_cloth.py 2010-05-25 14:14:31 UTC (rev 28980)
@@ -112,6 +112,7 @@
sub.active = cloth.pin_cloth
sub.prop_object(cloth, "mass_vertex_group", ob, "vertex_groups", text="")
sub.prop(cloth, "pin_stiffness", text="Stiffness")
+ sub.prop(cloth, "pin_use_springs", text="Use Springs")
col.label(text="Pre roll:")
col.prop(cloth, "pre_roll", text="Frame")
Modified: branches/render25/source/blender/blenkernel/BKE_cloth.h
===================================================================
--- branches/render25/source/blender/blenkernel/BKE_cloth.h 2010-05-25 13:50:36 UTC (rev 28979)
+++ branches/render25/source/blender/blenkernel/BKE_cloth.h 2010-05-25 14:14:31 UTC (rev 28980)
@@ -134,7 +134,7 @@
float bend_stiff;
float shear_stiff;
int spring_count; /* how many springs attached? */
- int isolated; /*does not belon to any *face*, but *may* belong to an edge*/
+ int no_faces; /*does not belon to any *face*, but *may* belong to an edge*/
}
ClothVertex;
@@ -180,7 +180,8 @@
CLOTH_SIMSETTINGS_FLAG_TEARING = ( 1 << 4 ),// true if tearing is enabled
CLOTH_SIMSETTINGS_FLAG_SCALING = ( 1 << 8 ), /* is advanced scaling active? */
CLOTH_SIMSETTINGS_FLAG_CCACHE_EDIT = (1 << 12), /* edit cache in editmode */
- CLOTH_SIMSETTINGS_FLAG_NO_SPRING_COMPRESS = (1 << 13) /* don't allow spring compression */
+ CLOTH_SIMSETTINGS_FLAG_NO_SPRING_COMPRESS = (1 << 13), /* don't allow spring compression */
+ CLOTH_SIMSETTINGS_FLAG_NO_GOAL_SPRING = (1 << 14) /* don't use spring for goal */
} CLOTH_SIMSETTINGS_FLAGS;
/* COLLISION FLAGS */
Modified: branches/render25/source/blender/blenkernel/BKE_collision.h
===================================================================
--- branches/render25/source/blender/blenkernel/BKE_collision.h 2010-05-25 13:50:36 UTC (rev 28979)
+++ branches/render25/source/blender/blenkernel/BKE_collision.h 2010-05-25 14:14:31 UTC (rev 28980)
@@ -131,7 +131,7 @@
// move Collision modifier object inter-frame with step = [0,1]
// defined in collisions.c
-void collision_move_object (CollisionModifierData *collmd, float step, float prevstep, float dt);
+void collision_move_object (CollisionModifierData *collmd, float step, float prevstep);
// interface for collision functions
void collisions_compute_barycentric ( float pv[3], float p1[3], float p2[3], float p3[3], float *w1, float *w2, float *w3 );
Modified: branches/render25/source/blender/blenkernel/intern/cloth.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/cloth.c 2010-05-25 13:50:36 UTC (rev 28979)
+++ branches/render25/source/blender/blenkernel/intern/cloth.c 2010-05-25 14:14:31 UTC (rev 28980)
@@ -249,8 +249,8 @@
BLI_bvhtree_insert(bvhspringtree, i, (float*)co, 1);
- v->isolated = 1;
- } else v->isolated = 0;
+ v->no_faces = 1;
+ } else v->no_faces = 0;
}
BLI_ghash_free(gh, NULL, NULL);
@@ -284,7 +284,7 @@
// update edge vertex positions in spring bvh tree
if (verts && cloth->numverts) {
for (i=0, v=cloth->verts; i<cloth->numverts; i++, v++) {
- if (!v->isolated)
+ if (!v->no_faces)
continue;
VECCOPY(co, v->txold);
@@ -436,7 +436,7 @@
for(i = 0; i < clmd->clothObject->numverts; i++, verts++) {
/* save the previous position. */
VECCOPY(verts->xold, verts->xconst);
- //VECCOPY(verts->txold, verts->x);
+ VECCOPY(verts->txold, verts->x);
/* Get the current position. */
VECCOPY(verts->xconst, mvert[i].co);
@@ -955,16 +955,17 @@
return 0;
}
-#ifdef CLOTH_GOAL_ORIGINAL
- for ( i = 0; i < dm->getNumVerts(dm); i++)
+ if (!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_NO_GOAL_SPRING))
{
- if((!(cloth->verts[i].flags & CLOTH_VERT_FLAG_PINNED)) && (cloth->verts[i].goal > ALMOST_ZERO))
+ for ( i = 0; i < dm->getNumVerts(dm); i++)
{
- cloth_add_spring (clmd, i, i, 0.0, CLOTH_SPRING_TYPE_GOAL);
+ if((!(cloth->verts[i].flags & CLOTH_VERT_FLAG_PINNED)) && (cloth->verts[i].goal > ALMOST_ZERO))
+ {
+ cloth_add_spring (clmd, i, i, 0.0, CLOTH_SPRING_TYPE_GOAL);
+ }
}
}
-#endif
-
+
// init our solver
if ( solvers [clmd->sim_parms->solver_type].init ) {
solvers [clmd->sim_parms->solver_type].init ( ob, clmd );
Modified: branches/render25/source/blender/blenkernel/intern/collision.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/collision.c 2010-05-25 13:50:36 UTC (rev 28979)
+++ branches/render25/source/blender/blenkernel/intern/collision.c 2010-05-25 14:14:31 UTC (rev 28980)
@@ -56,39 +56,23 @@
Collision modifier code start
***********************************/
-/* step is limited from -[time step] (frame start position) to 1 (frame end position) */
-
/* step is limited from 0 (frame start position) to 1 (frame end position) */
-void collision_move_object (CollisionModifierData *collmd, float step, float prevstep, float dt)
+void collision_move_object ( CollisionModifierData *collmd, float step, float prevstep )
{
float tv[3] = {0, 0, 0};
unsigned int i = 0;
- if (prevstep < 0.0) {
- for ( i = 0; i < collmd->numverts; i++ )
- {
- VECSUB ( tv, collmd->xold[i].co, collmd->x[i].co );
- VECADDS( collmd->current_x[i].co, collmd->x[i].co, tv, prevstep );
-
- VECSUB ( tv, collmd->xnew[i].co, collmd->x[i].co );
- VECADDS( collmd->current_x[i].co, collmd->x[i].co, tv, prevstep );
-
- VECSUB ( collmd->current_v[i].co, collmd->current_xnew[i].co, collmd->current_x[i].co );
- }
- } else {
- for ( i = 0; i < collmd->numverts; i++ )
- {
- VECSUB ( tv, collmd->xnew[i].co, collmd->x[i].co );
- VECADDS( collmd->current_x[i].co, collmd->x[i].co, tv, prevstep );
- VECADDS( collmd->current_xnew[i].co, collmd->x[i].co, tv, step );
- VECSUB ( collmd->current_v[i].co, collmd->current_xnew[i].co, collmd->current_x[i].co );
- }
+ for ( i = 0; i < collmd->numverts; i++ )
+ {
+ VECSUB ( tv, collmd->xnew[i].co, collmd->x[i].co );
+ VECADDS ( collmd->current_x[i].co, collmd->x[i].co, tv, prevstep );
+ VECADDS ( collmd->current_xnew[i].co, collmd->x[i].co, tv, step );
+ VECSUB ( collmd->current_v[i].co, collmd->current_xnew[i].co, collmd->current_x[i].co );
}
- bvhtree_update_from_mvert(collmd->bvhtree, collmd->mfaces, collmd->numfaces, collmd->current_x, collmd->current_xnew, collmd->numverts, 1);
+ bvhtree_update_from_mvert ( collmd->bvhtree, collmd->mfaces, collmd->numfaces, collmd->current_x, collmd->current_xnew, collmd->numverts, 1 );
}
-
BVHTree *bvhtree_build_from_mvert ( MFace *mfaces, unsigned int numfaces, MVert *x, unsigned int numverts, float epsilon )
{
BVHTree *tree;
@@ -1399,7 +1383,7 @@
col->ob = ob;
col->collmd = cmd;
/* make sure collider is properly set up */
- collision_move_object(cmd, 1.0, 0.0, 1.0);
+ collision_move_object(cmd, 1.0, 0.0);
BLI_addtail(*objs, col);
}
@@ -1589,7 +1573,7 @@
mul_v3_fl(vec, lambda);
//add_v3_v3(cv->txold, vec);
- add_v3_v3(cv->tx, no);
+ add_v3_v3(cv->tv, no);
}
MEM_freeN(frefs);
@@ -1643,8 +1627,6 @@
return ret;
}
-
-
// cloth - object collisions
int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, float dt )
{
@@ -1698,42 +1680,32 @@
continue;
/* move object to position (step) in time */
- collision_move_object ( collmd, step+dt, step, dt );
+ collision_move_object ( collmd, step + dt, step );
/* search for overlapping collision pairs */
overlap = BLI_bvhtree_overlap ( cloth_bvh, collmd->bvhtree, &result );
// go to next object if no overlap is there
- if(!result || !overlap)
- {
- if ( overlap )
- MEM_freeN ( overlap );
- } else {
-
+ if( result && overlap ) {
/* check if collisions really happen (costly near check) */
cloth_bvh_objcollisions_nearcheck ( clmd, collmd, &collisions[i], &collisions_index[i], result, overlap);
// resolve nearby collisions
ret += cloth_bvh_objcollisions_resolve ( clmd, collmd, collisions[i], collisions_index[i]);
ret2 += ret;
-
- if ( overlap )
- MEM_freeN ( overlap );
}
- if (!cloth->bvhspringtree) continue;
+ // collision detection for isolated edges (hairs)
+ if(cloth->bvhspringtree) {
+ /* search for overlapping collision pairs */
+ overlap = BLI_bvhtree_overlap ( cloth->bvhspringtree, collmd->bvhtree, &result );
- /* search for overlapping collision pairs */
- overlap = BLI_bvhtree_overlap ( cloth->bvhspringtree, collmd->bvhtree, &result );
- if (!overlap || !result) {
- if (overlap) MEM_freeN(overlap);
- continue;
+ if(result && overlap)
+ ret += cloth_bvh_edge_objcollisions_nearcheck ( clmd, collmd, result, overlap, dt);
}
- ret += cloth_bvh_edge_objcollisions_nearcheck ( clmd, collmd, result, overlap, dt);
-
- if (overlap)
- MEM_freeN(overlap);
+ if ( overlap )
+ MEM_freeN ( overlap );
}
rounds++;
@@ -1761,9 +1733,7 @@
}
}
- if (!verts[i].isolated) {
- VECADD ( verts[i].tx, verts[i].txold, verts[i].tv );
- }
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list