From c7fccc84bf59bed95bdf13207c40f7a1d1711d24 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 5 Mar 2011 10:29:10 +0000 Subject: use NULL rather then 0 for pointer assignments & comparison, modifier, imbuf & editors. --- source/blender/modifiers/intern/MOD_collision.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source/blender/modifiers/intern/MOD_collision.c') diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c index e1371b3b86c..2ed66f2374b 100644 --- a/source/blender/modifiers/intern/MOD_collision.c +++ b/source/blender/modifiers/intern/MOD_collision.c @@ -250,20 +250,20 @@ ModifierTypeInfo modifierType_Collision = { /* flags */ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_Single, - /* copyData */ 0, + /* copyData */ NULL, /* deformVerts */ deformVerts, - /* deformMatrices */ 0, - /* deformVertsEM */ 0, - /* deformMatricesEM */ 0, - /* applyModifier */ 0, - /* applyModifierEM */ 0, + /* deformMatrices */ NULL, + /* deformVertsEM */ NULL, + /* deformMatricesEM */ NULL, + /* applyModifier */ NULL, + /* applyModifierEM */ NULL, /* initData */ initData, - /* requiredDataMask */ 0, + /* requiredDataMask */ NULL, /* freeData */ freeData, - /* isDisabled */ 0, - /* updateDepgraph */ 0, + /* isDisabled */ NULL, + /* updateDepgraph */ NULL, /* dependsOnTime */ dependsOnTime, - /* dependsOnNormals */ 0, - /* foreachObjectLink */ 0, - /* foreachIDLink */ 0, + /* dependsOnNormals */ NULL, + /* foreachObjectLink */ NULL, + /* foreachIDLink */ NULL, }; -- cgit v1.2.3 From 60ce95f5622d3947e30fe960eda22ea305660619 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 18 Mar 2011 15:31:32 +0000 Subject: New particle collisions code: * The old collisions code detected particle collisions by calculating the collision times analytically from the collision mesh faces. This was pretty accurate, but didn't support rotating/deforming faces at all, as the equations for these quickly become quite nasty. * The new code uses a simple "distance to plane/edge/vert" function and iterates this with the Newton-Rhapson method to find the closest particle distance during a simulation step. * The advantage in this is that the collision object can now move, rotate, scale or even deform freely and collisions are still detected reliably. * For some extreme movements the calculation errors could stack up so much that the detection fails, but this can be easily fixed by increasing the particle size or simulation substeps. * As a side note the algorithm doesn't really do point particles anymore, but uses a very small radius as the particle size when "size deflect" isn't selected. * I've also updated the collision response code a bit, so now the particles shouldn't leak even from tight corners. All in all the collisions code is now much cleaner and more robust than before! --- source/blender/modifiers/intern/MOD_collision.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'source/blender/modifiers/intern/MOD_collision.c') diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c index 2ed66f2374b..83ba8a12163 100644 --- a/source/blender/modifiers/intern/MOD_collision.c +++ b/source/blender/modifiers/intern/MOD_collision.c @@ -64,7 +64,7 @@ static void initData(ModifierData *md) collmd->current_x = NULL; collmd->current_xnew = NULL; collmd->current_v = NULL; - collmd->time = -1000; + collmd->time_x = collmd->time_xnew = -1000; collmd->numverts = 0; collmd->bvhtree = NULL; } @@ -95,7 +95,7 @@ static void freeData(ModifierData *md) collmd->current_x = NULL; collmd->current_xnew = NULL; collmd->current_v = NULL; - collmd->time = -1000; + collmd->time_x = collmd->time_xnew = -1000; collmd->numverts = 0; collmd->bvhtree = NULL; collmd->mfaces = NULL; @@ -139,11 +139,11 @@ static void deformVerts(ModifierData *md, Object *ob, current_time = BKE_curframe(md->scene); if(G.rt > 0) - printf("current_time %f, collmd->time %f\n", current_time, collmd->time); + printf("current_time %f, collmd->time_xnew %f\n", current_time, collmd->time_xnew); numverts = dm->getNumVerts ( dm ); - if((current_time > collmd->time)|| (BKE_ptcache_get_continue_physics())) + if((current_time > collmd->time_xnew)|| (BKE_ptcache_get_continue_physics())) { unsigned int i; @@ -151,7 +151,7 @@ static void deformVerts(ModifierData *md, Object *ob, if(collmd->x && (numverts != collmd->numverts)) freeData((ModifierData *)collmd); - if(collmd->time == -1000) // first time + if(collmd->time_xnew == -1000) // first time { collmd->x = dm->dupVertArray(dm); // frame start position @@ -174,7 +174,7 @@ static void deformVerts(ModifierData *md, Object *ob, // create bounding box hierarchy collmd->bvhtree = bvhtree_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->x, numverts, ob->pd->pdef_sboft); - collmd->time = current_time; + collmd->time_x = collmd->time_xnew = current_time; } else if(numverts == collmd->numverts) { @@ -182,6 +182,7 @@ static void deformVerts(ModifierData *md, Object *ob, tempVert = collmd->x; collmd->x = collmd->xnew; collmd->xnew = tempVert; + collmd->time_x = collmd->time_xnew; memcpy(collmd->xnew, dm->getVertArray(dm), numverts*sizeof(MVert)); @@ -216,7 +217,7 @@ static void deformVerts(ModifierData *md, Object *ob, bvhtree_update_from_mvert ( collmd->bvhtree, collmd->mfaces, collmd->numfaces, collmd->current_x, collmd->current_xnew, collmd->numverts, 1 ); } - collmd->time = current_time; + collmd->time_xnew = current_time; } else if(numverts != collmd->numverts) { @@ -224,7 +225,7 @@ static void deformVerts(ModifierData *md, Object *ob, } } - else if(current_time < collmd->time) + else if(current_time < collmd->time_xnew) { freeData((ModifierData *)collmd); } -- cgit v1.2.3