From: Daniel Genrich Date: Wed, 30 Jan 2008 14:01:05 +0000 (+0000) Subject: New: Collision Modifier and Cloth can be at any position on the modifier stack. BUT... X-Git-Tag: v2.46~1204 X-Git-Url: https://git.blender.org/gitweb/gitweb.cgi/blender.git/commitdiff_plain/fd877543d1b06665666b55c0f2dc666065639fc3 New: Collision Modifier and Cloth can be at any position on the modifier stack. BUT everytime the vertices count change, they will free themselves and internal build new (they rely on vertex count). Should be no problem anymore with e.g. subsurf modifier before collision modifier (tested). Fix: applied a patch from schlaile to get my bullet additions compiled with gcc 3.3 --- diff --git a/extern/bullet2/src/BulletDynamics/Dynamics/Bullet-C-API.cpp b/extern/bullet2/src/BulletDynamics/Dynamics/Bullet-C-API.cpp index d4f376128fc..248c582dcd8 100644 --- a/extern/bullet2/src/BulletDynamics/Dynamics/Bullet-C-API.cpp +++ b/extern/bullet2/src/BulletDynamics/Dynamics/Bullet-C-API.cpp @@ -53,10 +53,15 @@ subject to the following restrictions: extern "C" double plNearestPoints(float p1[3], float p2[3], float p3[3], float q1[3], float q2[3], float q3[3], float *pa, float *pb, float normal[3]) { - btTriangleShape trishapeA(btVector3(p1[0], p1[1], p1[2]), btVector3(p2[0], p2[1], p2[2]), btVector3(p3[0], p3[1], p3[2])); + btVector3 vp(p1[0], p1[1], p1[2]); + btTriangleShape trishapeA(vp, + btVector3(p2[0], p2[1], p2[2]), + btVector3(p3[0], p3[1], p3[2])); trishapeA.setMargin(0.000001f); - - btTriangleShape trishapeB(btVector3(q1[0], q1[1], q1[2]), btVector3(q2[0], q2[1], q2[2]), btVector3(q3[0], q3[1], q3[2])); + btVector3 vq(q1[0], q1[1], q1[2]); + btTriangleShape trishapeB(vq, + btVector3(q2[0], q2[1], q2[2]), + btVector3(q3[0], q3[1], q3[2])); trishapeB.setMargin(0.000001f); // btVoronoiSimplexSolver sGjkSimplexSolver; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 2008291e510..88123098b98 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -5178,6 +5178,8 @@ static void collisionModifier_deformVerts( // TODO: epsilon // create bounding box hierarchy collmd->tree = bvh_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->x, numverts, ob->pd->pdef_sbift); + + collmd->time = current_time; } else if(numverts == collmd->numverts) { @@ -5207,9 +5209,14 @@ static void collisionModifier_deformVerts( // recalc static bounding boxes bvh_update_from_mvert(collmd->tree, collmd->current_x, numverts, NULL, 0); } + + collmd->time = current_time; + } + else if(numverts != collmd->numverts) + { + collisionModifier_freeData((ModifierData *)collmd); } - collmd->time = current_time; } else { @@ -7050,10 +7057,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti->type = eModifierTypeType_Nonconstructive; mti->initData = clothModifier_initData; mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_RequiresOriginalData; - // | eModifierTypeFlag_SupportsMapping - // | eModifierTypeFlag_SupportsEditmode - // | eModifierTypeFlag_EnableInEditmode; + | eModifierTypeFlag_UsesPointCache; mti->dependsOnTime = clothModifier_dependsOnTime; mti->freeData = clothModifier_freeData; mti->requiredDataMask = clothModifier_requiredDataMask; @@ -7064,8 +7068,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti = INIT_TYPE(Collision); mti->type = eModifierTypeType_OnlyDeform; mti->initData = collisionModifier_initData; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_RequiresOriginalData; + mti->flags = eModifierTypeFlag_AcceptsMesh; mti->dependsOnTime = collisionModifier_dependsOnTime; mti->freeData = collisionModifier_freeData; mti->deformVerts = collisionModifier_deformVerts;