diff options
author | Daniel Genrich <daniel.genrich@gmx.net> | 2008-02-11 16:30:52 +0300 |
---|---|---|
committer | Daniel Genrich <daniel.genrich@gmx.net> | 2008-02-11 16:30:52 +0300 |
commit | 69e6a6cbc9cfdae6804d538cb4810672c5318d48 (patch) | |
tree | fba0fd9d8cd075d85e0548dc8c69aad7f2078fdc /source | |
parent | fdbfd7e3a8df163fd8773d86c9344ddff30c14ed (diff) |
Pointcache: Fixed non-availability when blend file was loaded from command line and also another case where you startet from an unsaved blend and switched to a saved one; Cloth: Fixid mass init, little speedup for collisions; Collision Modifier: More generalized it
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_cloth.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_collision.h | 16 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/cloth.c | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/collision.c | 9 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/kdop.c | 13 | ||||
-rw-r--r-- | source/blender/src/header_info.c | 9 | ||||
-rw-r--r-- | source/creator/creator.c | 6 |
7 files changed, 52 insertions, 18 deletions
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index 7342b3aa24a..19fd0ef4105 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -172,18 +172,13 @@ typedef enum CLOTH_SPRING_FLAG_NEEDED = ( 1 << 2 ), // springs has values to be applied } CLOTH_SPRINGS_FLAGS; -typedef void ( *CM_COLLISION_RESPONSE ) ( ClothModifierData *clmd, CollisionModifierData *collmd, CollisionTree *tree1, CollisionTree *tree2 ); - - ///////////////////////////////////////////////// // collision.c //////////////////////////////////////////////// // needed for implicit.c -void bvh_collision_response ( ClothModifierData *clmd, ClothModifierData *coll_clmd, CollisionTree * tree1, CollisionTree * tree2 ); int cloth_bvh_objcollision ( ClothModifierData * clmd, float step, float dt ); -int bvh_traverse ( ClothModifierData * clmd, CollisionModifierData * collmd, CollisionTree * tree1, CollisionTree * tree2, float step, CM_COLLISION_RESPONSE collision_response ); //////////////////////////////////////////////// diff --git a/source/blender/blenkernel/BKE_collision.h b/source/blender/blenkernel/BKE_collision.h index aa46bc625e1..05c8d390ea6 100644 --- a/source/blender/blenkernel/BKE_collision.h +++ b/source/blender/blenkernel/BKE_collision.h @@ -94,6 +94,20 @@ BVH; //////////////////////////////////////// + +//////////////////////////////////////// +// kdop.c +//////////////////////////////////////// + +// needed for collision.c +typedef void ( *CM_COLLISION_RESPONSE ) ( ModifierData *md1, ModifierData *md2, CollisionTree *tree1, CollisionTree *tree2 ); + +// needed for collision.c +int bvh_traverse ( ModifierData * md1, ModifierData * md2, CollisionTree * tree1, CollisionTree * tree2, float step, CM_COLLISION_RESPONSE collision_response); +int bvh_traverse_mt ( ModifierData * md1, ModifierData * md2, CollisionTree * tree1, CollisionTree * tree2, float step, CM_COLLISION_RESPONSE collision_response); +//////////////////////////////////////////////// +//////////////////////////////////////// + //////////////////////////////////////// // used for collisions in kdop.c and also collision.c //////////////////////////////////////// @@ -108,7 +122,7 @@ typedef struct CollPair float pa[3], pb[3]; // collision point p1 on face1, p2 on face2 int lastsign; // indicates if the distance sign has changed, unused itm float time; // collision time, from 0 up to 1 - unsigned int ap1, ap2, ap3, bp1, bp2, bp3, bp4; + unsigned int ap1, ap2, ap3, bp1, bp2, bp3; unsigned int pointsb[4]; } CollPair; diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index d75c4ecbfac..407a7cfd8be 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -171,6 +171,7 @@ void cloth_init ( ClothModifierData *clmd ) clmd->coll_parms->loop_count = 3; clmd->coll_parms->epsilon = 0.015f; clmd->coll_parms->flags = CLOTH_COLLSETTINGS_FLAG_ENABLED; + clmd->coll_parms->collision_list = NULL; /* These defaults are copied from softbody.c's * softbody_calc_forces() function. @@ -698,6 +699,9 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd,Object *ob, DerivedMesh *d /* only force free the cache if we have a different number of verts */ if(clmd->clothObject && (numverts != clmd->clothObject->numverts )) { + if(G.rt > 0) + printf("Force Freeing: numverts != clmd->clothObject->numverts\n"); + clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_CCACHE_FFREE; cloth_free_modifier ( ob, clmd ); } @@ -742,12 +746,17 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd,Object *ob, DerivedMesh *d // that's "first frame" and "last frame" on GUI if ( current_time < clmd->sim_parms->firstframe ) { + if(G.rt > 0) + printf("current_time < clmd->sim_parms->firstframe\n"); return result; } else if ( current_time > clmd->sim_parms->lastframe ) { int stack_index = modifiers_indexInObject(ob, (ModifierData *)clmd); + if(G.rt > 0) + printf("current_time > clmd->sim_parms->lastframe\n"); + if(BKE_ptcache_id_exist((ID *)ob, clmd->sim_parms->lastcachedframe, stack_index)) { if(cloth_read_cache(ob, clmd, clmd->sim_parms->lastcachedframe)) @@ -1171,7 +1180,8 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d Mat4MulVecfl ( ob->obmat, verts->x ); } - verts->mass = clmd->sim_parms->mass; + /* no GUI interface yet */ + verts->mass = clmd->sim_parms->mass = 1.0f; if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) verts->goal= clmd->sim_parms->defgoal; diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 4ce0cc79502..da9312b01ab 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -557,8 +557,10 @@ int cloth_collision_response_moving_edges(ClothModifierData *clmd, ClothModifier return 1; } -void cloth_collision_static(ClothModifierData *clmd, CollisionModifierData *collmd, CollisionTree *tree1, CollisionTree *tree2) +void cloth_collision_static(ModifierData *md1, ModifierData *md2, CollisionTree *tree1, CollisionTree *tree2) { + ClothModifierData *clmd = (ClothModifierData *)md1; + CollisionModifierData *collmd = (CollisionModifierData *)md2; CollPair *collpair = NULL; Cloth *cloth1=NULL; MFace *face1=NULL, *face2=NULL; @@ -1004,7 +1006,7 @@ int cloth_bvh_objcollision(ClothModifierData * clmd, float step, float dt) collision_move_object(collmd, step + dt, step); - bvh_traverse(clmd, collmd, cloth_bvh->root, coll_bvh->root, step, cloth_collision_static); + bvh_traverse((ModifierData *)clmd, (ModifierData *)collmd, cloth_bvh->root, coll_bvh->root, step, cloth_collision_static); } else printf ("cloth_bvh_objcollision: found a collision object with clothObject or collData NULL.\n"); @@ -1012,13 +1014,12 @@ int cloth_bvh_objcollision(ClothModifierData * clmd, float step, float dt) // process all collisions (calculate impulses, TODO: also repulses if distance too short) result = 1; - for(j = 0; j < 10; j++) // 10 is just a value that ensures convergence + for(j = 0; j < 5; j++) // 5 is just a value that ensures convergence { result = 0; if (collmd->tree) result += cloth_collision_response_static(clmd, collmd); - // apply impulses in parallel ic=0; diff --git a/source/blender/blenkernel/intern/kdop.c b/source/blender/blenkernel/intern/kdop.c index 8d2b48144be..b5eafdf9c70 100644 --- a/source/blender/blenkernel/intern/kdop.c +++ b/source/blender/blenkernel/intern/kdop.c @@ -72,6 +72,11 @@ #include "mydevice.h" +#ifdef _OPENMP +#include <omp.h> +#endif + + //////////////////////////////////////////////////////////////////////// // Additional fastened appending function // It uses the link to the last inserted node as start value @@ -670,7 +675,7 @@ DO_INLINE int bvh_overlap(float *bv1, float *bv2) * every other triangle that doesn't require any realloc, but uses * much memory */ -int bvh_traverse ( ClothModifierData * clmd, CollisionModifierData * collmd, CollisionTree * tree1, CollisionTree * tree2, float step, CM_COLLISION_RESPONSE collision_response) +int bvh_traverse ( ModifierData * md1, ModifierData * md2, CollisionTree * tree1, CollisionTree * tree2, float step, CM_COLLISION_RESPONSE collision_response) { int i = 0, ret=0; @@ -693,7 +698,7 @@ int bvh_traverse ( ClothModifierData * clmd, CollisionModifierData * collmd, Col // Provide the collision response. if(collision_response) - collision_response (clmd, collmd, tree1, tree2); + collision_response (md1, md2, tree1, tree2); return 1; } else @@ -702,7 +707,7 @@ int bvh_traverse ( ClothModifierData * clmd, CollisionModifierData * collmd, Col for (i = 0; i < 4; i++) { // Only traverse nodes that exist. - if (tree2->nodes[i] && bvh_traverse (clmd, collmd, tree1, tree2->nodes[i], step, collision_response)) + if (tree2->nodes[i] && bvh_traverse (md1, md2, tree1, tree2->nodes[i], step, collision_response)) ret = 1; } } @@ -713,7 +718,7 @@ int bvh_traverse ( ClothModifierData * clmd, CollisionModifierData * collmd, Col for (i = 0; i < 4; i++) { // Only traverse nodes that exist. - if (tree1->nodes [i] && bvh_traverse (clmd, collmd, tree1->nodes[i], tree2, step, collision_response)) + if (tree1->nodes [i] && bvh_traverse (md1, md2, tree1->nodes[i], tree2, step, collision_response)) ret = 1; } } diff --git a/source/blender/src/header_info.c b/source/blender/src/header_info.c index 4559d5c460b..be89b15a615 100644 --- a/source/blender/src/header_info.c +++ b/source/blender/src/header_info.c @@ -861,14 +861,19 @@ static void do_info_filemenu(void *arg, int event) case 15: /* recover previous session */ { extern short winqueue_break; /* editscreen.c */ - int save_over; + int save_over, retval = 0; char str[FILE_MAXDIR+FILE_MAXFILE]; char scestr[FILE_MAXDIR+FILE_MAXFILE]; strcpy(scestr, G.sce); /* temporal store */ save_over = G.save_over; BLI_make_file_string("/", str, U.tempdir, "quit.blend"); - BKE_read_file(str, NULL); + retval = BKE_read_file(str, NULL); + + /*we successfully loaded a blend file, get sure that + pointcache works */ + if (retval!=0) G.relbase_valid = 1; + G.save_over = save_over; strcpy(G.sce, scestr); diff --git a/source/creator/creator.c b/source/creator/creator.c index 4dd1350ea48..3918e29b9bf 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -759,8 +759,12 @@ int main(int argc, char **argv) } if (G.background) { - BKE_read_file(filename, NULL); + int retval = BKE_read_file(filename, NULL); sound_initialize_sounds(); + + /*we successfully loaded a blend file, get sure that + pointcache works */ + if (retval!=0) G.relbase_valid = 1; /* happens for the UI on file reading too */ BKE_reset_undo(); |