[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12323] branches/cloth/blender/source/ blender: Disabled Cloth collision detection because of almost complete rewrite/ seperation of the collision system like we discussed on the sprint.
Daniel Genrich
daniel.genrich at gmx.net
Sun Oct 21 18:38:13 CEST 2007
Revision: 12323
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12323
Author: genscher
Date: 2007-10-21 18:38:13 +0200 (Sun, 21 Oct 2007)
Log Message:
-----------
Disabled Cloth collision detection because of almost complete rewrite/seperation of the collision system like we discussed on the sprint. You can enable position caching/collision object now then enableing it as an deflection object. Problem: Some GUI glitch in the modifier stack, please help :)
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/blenkernel/intern/collision.c
branches/cloth/blender/source/blender/blenkernel/intern/implicit.c
branches/cloth/blender/source/blender/blenkernel/intern/kdop.c
branches/cloth/blender/source/blender/blenkernel/intern/modifier.c
branches/cloth/blender/source/blender/makesdna/DNA_cloth_types.h
branches/cloth/blender/source/blender/makesdna/DNA_modifier_types.h
branches/cloth/blender/source/blender/src/buttons_editing.c
branches/cloth/blender/source/blender/src/buttons_object.c
branches/cloth/blender/source/blender/src/transform_generics.c
Modified: branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h 2007-10-21 16:17:33 UTC (rev 12322)
+++ branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h 2007-10-21 16:38:13 UTC (rev 12323)
@@ -124,70 +124,10 @@
// from cloth.c, needed for modifier.c
void clothModifier_do ( ClothModifierData *clmd, Object *ob, DerivedMesh *dm, float ( *vertexCos ) [3], int numverts );
-// used in collision.c
-typedef struct Tree
-{
- struct Tree *nodes[4]; // 4 children --> quad-tree
- struct Tree *parent;
- struct Tree *nextLeaf;
- struct Tree *prevLeaf;
- float bv[26]; // Bounding volume of all nodes / we have 7 axes on a 14-DOP
- unsigned int tri_index; // this saves the index of the face
- int count_nodes; // how many nodes are used
- int traversed; // how many nodes already traversed until this level?
- int isleaf;
-}
-Tree;
-
-typedef struct Tree TreeNode;
-
-typedef struct BVH
-{
- unsigned int numfaces;
- unsigned int numverts;
- ClothVertex *verts; // just a pointer to the original datastructure
- MFace *mfaces; // just a pointer to the original datastructure
- struct LinkNode *tree;
- TreeNode *root; // TODO: saving the root --> is this really needed? YES!
- TreeNode *leaf_tree; /* Tail of the leaf linked list. */
- TreeNode *leaf_root; /* Head of the leaf linked list. */
- float epsilon; /* epslion is used for inflation of the k-dop */
- int flags; /* bvhFlags */
-}
-BVH;
-
-typedef void ( *CM_COLLISION_RESPONSE ) ( ClothModifierData *clmd, ClothModifierData *coll_clmd, Tree * tree1, Tree * tree2 );
-
-
-/////////////////////////////////////////////////
-// collision.c
////////////////////////////////////////////////
-// needed for implicit.c
-void bvh_collision_response ( ClothModifierData *clmd, ClothModifierData *coll_clmd, Tree * tree1, Tree * tree2 );
-int cloth_bvh_objcollision ( ClothModifierData * clmd, float step, float dt );
-////////////////////////////////////////////////
-
-
/////////////////////////////////////////////////
-// kdop.c
-////////////////////////////////////////////////
-
-// needed for cloth.c
-void bvh_free ( BVH * bvh );
-BVH *bvh_build ( ClothModifierData *clmd, float epsilon );
-LinkNode *BLI_linklist_append_fast ( LinkNode **listp, void *ptr );
-
-// needed for collision.c
-int bvh_traverse ( ClothModifierData * clmd, ClothModifierData * coll_clmd, Tree * tree1, Tree * tree2, float step, CM_COLLISION_RESPONSE collision_response );
-void bvh_update ( ClothModifierData * clmd, BVH * bvh, int moving );
-
-////////////////////////////////////////////////
-
-
-
-/////////////////////////////////////////////////
// cloth.c
////////////////////////////////////////////////
void cloth_free_modifier ( ClothModifierData *clmd );
@@ -200,7 +140,7 @@
/* Typedefs for function pointers we need for solvers and collision detection. */
typedef void ( *CM_COLLISION_SELF ) ( ClothModifierData *clmd, int step );
-typedef void ( *CM_COLLISION_OBJ ) ( ClothModifierData *clmd, int step, CM_COLLISION_RESPONSE collision_response );
+// typedef void ( *CM_COLLISION_OBJ ) ( ClothModifierData *clmd, int step, CM_COLLISION_RESPONSE collision_response );
/* This enum provides the IDs for our solvers. */
@@ -239,6 +179,7 @@
Frame;
/* used for collisions in collision.c */
+/*
typedef struct CollPair
{
unsigned int face1; // cloth face
@@ -253,6 +194,7 @@
unsigned int pointsb[4];
}
CollPair;
+*/
/* used for collisions in collision.c */
typedef struct EdgeCollPair
Modified: branches/cloth/blender/source/blender/blenkernel/intern/cloth.c
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/intern/cloth.c 2007-10-21 16:17:33 UTC (rev 12322)
+++ branches/cloth/blender/source/blender/blenkernel/intern/cloth.c 2007-10-21 16:38:13 UTC (rev 12323)
@@ -65,6 +65,7 @@
#include "BKE_mesh.h"
#include "BKE_object.h"
#include "BKE_cloth.h"
+#include "BKE_collisions.h"
#include "BKE_modifier.h"
#include "BKE_utildefines.h"
#include "BKE_DerivedMesh.h"
@@ -845,11 +846,11 @@
cloth->springs = NULL;
cloth->numsprings = 0;
-
+/*
// free BVH collision tree
if ( cloth->tree )
bvh_free ( ( BVH * ) cloth->tree );
-
+*/
// we save our faces for collision objects
if ( cloth->mfaces )
MEM_freeN ( cloth->mfaces );
@@ -1011,7 +1012,7 @@
verts->impulse_count = 0;
VECCOPY ( verts->impulse, tnull );
}
- clmd->clothObject->tree = bvh_build ( clmd,clmd->coll_parms.epsilon );
+ // clmd->clothObject->tree = bvh_build ( dm, clmd->coll_parms.epsilon );
}
@@ -1020,20 +1021,6 @@
}
}
-/*
-helper function to get proper spring length
-when object is rescaled
-*/
-float cloth_globallen ( float *v1,float *v2,Object *ob )
-{
- float p1[3],p2[3];
- VECCOPY ( p1,v1 );
- Mat4MulVecfl ( ob->obmat, p1 );
- VECCOPY ( p2,v2 );
- Mat4MulVecfl ( ob->obmat, p2 );
- return VecLenf ( p1,p2 );
-}
-
// only meshes supported at the moment
static int cloth_from_object ( Object *ob, ClothModifierData *clmd, DerivedMesh *dm, float ( *vertexCos ) [3], unsigned int numverts )
{
@@ -1082,7 +1069,7 @@
return 0;
}
- mvert = CDDM_get_verts ( dm );
+ mvert = dm->getVertArray ( dm ); // CDDM_get_verts ( dm );
verts = clmd->clothObject->verts;
/* set initial values */
@@ -1116,7 +1103,7 @@
if ( solvers [clmd->sim_parms.solver_type].init )
solvers [clmd->sim_parms.solver_type].init ( ob, clmd );
- clmd->clothObject->tree = bvh_build ( clmd, clmd->coll_parms.epsilon );
+ // clmd->clothObject->tree = bvh_build ( dm, clmd->coll_parms.epsilon );
cloth_cache_set_frame ( clmd, 1 );
}
Modified: branches/cloth/blender/source/blender/blenkernel/intern/collision.c
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/intern/collision.c 2007-10-21 16:17:33 UTC (rev 12322)
+++ branches/cloth/blender/source/blender/blenkernel/intern/collision.c 2007-10-21 16:38:13 UTC (rev 12323)
@@ -49,6 +49,7 @@
#include "BLI_arithb.h"
#include "BLI_edgehash.h"
#include "BLI_linklist.h"
+#include "BKE_collisions.h"
#include "BKE_curve.h"
#include "BKE_deform.h"
#include "BKE_DerivedMesh.h"
@@ -217,7 +218,7 @@
* page 4, left column
*/
-int cloth_get_collision_time(float a[3], float b[3], float c[3], float d[3], float e[3], float f[3], float solution[3])
+int collisions_get_collision_time(float a[3], float b[3], float c[3], float d[3], float e[3], float f[3], float solution[3])
{
int num_sols = 0;
@@ -318,7 +319,7 @@
}
// w3 is not perfect
-void cloth_compute_barycentric (float pv[3], float p1[3], float p2[3], float p3[3], float *w1, float *w2, float *w3)
+void collisions_compute_barycentric (float pv[3], float p1[3], float p2[3], float p3[3], float *w1, float *w2, float *w3)
{
double tempV1[3], tempV2[3], tempV4[3];
double a,b,c,d,e,f;
@@ -372,8 +373,9 @@
VecMulf(to, MAX2(1.0f - frictionConstant * delta_V_n / INPR(vrel_t_pre,vrel_t_pre), 0.0f));
}
-int cloth_collision_response_static(ClothModifierData *clmd, ClothModifierData *coll_clmd)
+int collisions_collision_response_static(ClothModifierData *clmd, ClothModifierData *coll_clmd)
{
+ /*
unsigned int i = 0;
int result = 0;
LinkNode *search = NULL;
@@ -386,20 +388,20 @@
cloth1 = clmd->clothObject;
cloth2 = coll_clmd->clothObject;
- search = clmd->coll_parms.collision_list;
+ // search = clmd->coll_parms.collision_list;
while(search)
{
collpair = search->link;
// compute barycentric coordinates for both collision points
- cloth_compute_barycentric(collpair->pa,
+ collisions_compute_barycentric(collpair->pa,
cloth1->verts[collpair->ap1].txold,
cloth1->verts[collpair->ap2].txold,
cloth1->verts[collpair->ap3].txold,
&w1, &w2, &w3);
- cloth_compute_barycentric(collpair->pb,
+ collisions_compute_barycentric(collpair->pb,
cloth2->verts[collpair->bp1].txold,
cloth2->verts[collpair->bp2].txold,
cloth2->verts[collpair->bp3].txold,
@@ -442,12 +444,6 @@
// printf("friction applied: %f\n", magtangent);
// TODO check original code
- /*
- VECSUB(cloth1->verts[face1->v1].tv, cloth1->verts[face1->v1].tv,tangential);
- VECSUB(cloth1->verts[face1->v1].tv, cloth1->verts[face1->v2].tv,tangential);
- VECSUB(cloth1->verts[face1->v1].tv, cloth1->verts[face1->v3].tv,tangential);
- VECSUB(cloth1->verts[face1->v1].tv, cloth1->verts[face1->v4].tv,tangential);
- */
}
@@ -455,6 +451,7 @@
// printf("impulse: %f\n", impulse);
+ // face A
VECADDMUL(cloth1->verts[collpair->ap1].impulse, collpair->normal, w1 * impulse);
cloth1->verts[collpair->ap1].impulse_count++;
@@ -464,63 +461,50 @@
VECADDMUL(cloth1->verts[collpair->ap3].impulse, collpair->normal, w3 * impulse);
cloth1->verts[collpair->ap3].impulse_count++;
- result = 1;
+ // face B
+ VECADDMUL(cloth2->verts[collpair->bp1].impulse, collpair->normal, u1 * impulse);
+ cloth2->verts[collpair->bp1].impulse_count++;
- /*
- if (overlap > ALMOST_ZERO) {
- double I_mag = overlap * 0.1;
-
- impulse = -I_mag / ( 1.0 + w1*w1 + w2*w2 + w3*w3);
-
- VECADDMUL(cloth1->verts[collpair->ap1].impulse, collpair->normal, w1 * impulse);
- cloth1->verts[collpair->ap1].impulse_count++;
-
- VECADDMUL(cloth1->verts[collpair->ap2].impulse, collpair->normal, w2 * impulse);
- cloth1->verts[collpair->ap2].impulse_count++;
+ VECADDMUL(cloth2->verts[collpair->bp2].impulse, collpair->normal, u2 * impulse);
+ cloth2->verts[collpair->bp2].impulse_count++;
- VECADDMUL(cloth1->verts[collpair->ap3].impulse, collpair->normal, w3 * impulse);
- cloth1->verts[collpair->ap3].impulse_count++;
- }
- */
+ VECADDMUL(cloth2->verts[collpair->bp3].impulse, collpair->normal, u3 * impulse);
+ cloth2->verts[collpair->bp3].impulse_count++;
+
+
+ result = 1;
// printf("magnitude_i: %f\n", magnitude_i); // negative before collision in my case
// Apply the impulse and increase impulse counters.
-
- /*
- // calculateFrictionImpulse(tangential, collvel, collpair->normal, magtangent, clmd->coll_parms.friction*0.01, magtangent);
- VECSUBS(vrel_t_pre, collvel, collpair->normal, magnormal);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list