diff options
author | Daniel Genrich <daniel.genrich@gmx.net> | 2009-08-25 22:41:36 +0400 |
---|---|---|
committer | Daniel Genrich <daniel.genrich@gmx.net> | 2009-08-25 22:41:36 +0400 |
commit | 1d1e8595f23579e940ca403023305f2499c39a54 (patch) | |
tree | 5de682ad2c8c45b67626287b0f07fdf721f207aa /source/blender | |
parent | 0ff90bb2586e9e50e962106b6bcafa97484c31ca (diff) |
Pointcache:
*introducing unique ID's following brechts hint from ML
Enhancements resulting from this:
* multiple caches per modifier stack position
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 65 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pointcache.c | 25 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 1 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawvolume.c | 3 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_extensions.c | 3 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_object_types.h | 1 |
7 files changed, 84 insertions, 19 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index a57529ccf75..68173a1b5c4 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -115,6 +115,11 @@ void object_handle_update(struct Scene *scene, struct Object *ob); float give_timeoffset(struct Object *ob); int give_obdata_texspace(struct Object *ob, int **texflag, float **loc, float **size, float **rot); + +int object_insert_pc(struct Object *ob); +// void object_delete_pc(struct Object *ob, int index); + + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 0e45aedc3ed..8f5ff988745 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -307,6 +307,8 @@ void free_object(Object *ob) if(ob->gpulamp.first) GPU_lamp_free(ob); free_sculptsession(&ob->sculpt); + + if(ob->pc_ids.first) BLI_freelistN(&ob->pc_ids); } static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Object **obpoin) @@ -1016,6 +1018,8 @@ Object *add_only_object(int type, char *name) ob->fluidsimFlag = 0; ob->fluidsimSettings = NULL; + ob->pc_ids.first = ob->pc_ids.last = NULL; + return ob; } @@ -1268,7 +1272,8 @@ Object *copy_object(Object *ob) obn->derivedFinal = NULL; obn->gpulamp.first = obn->gpulamp.last = NULL; - + obn->pc_ids.first = obn->pc_ids.last = NULL; + return obn; } @@ -2535,3 +2540,61 @@ int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3 return result; } + +static int pc_cmp(void *a, void *b) +{ + LinkData *ad = a, *bd = b; + if((int)ad->data > (int)bd->data) + return 1; + else return 0; +} + +int object_insert_pc(Object *ob) +{ + LinkData *link = NULL; + int i = 0; + + BLI_sortlist(&ob->pc_ids, pc_cmp); + + for(link=ob->pc_ids.first, i = 0; link; link=link->next, i++) + { + int index =(int)link->data; + + if(i < index) + break; + } + + link = MEM_callocN(sizeof(LinkData), "PCLink"); + link->data = (void *)i; + BLI_addtail(&ob->pc_ids, link); + + return i; +} + +static int pc_findindex(ListBase *listbase, int index) +{ + LinkData *link= NULL; + int number= 0; + + if (listbase == NULL) return -1; + + link= listbase->first; + while (link) { + if ((int)link->data == index) + return number; + + number++; + link= link->next; + } + + return -1; +} + +#if 0 +void object_delete_pc(Object *ob, int index) +{ + int list_index = pc_findindex(&ob->pc_ids, index); + LinkData *link = BLI_findlink(&ob->pc_ids, list_index); + BLI_freelinkN(&ob->pc_ids, link); +} +#endif
\ No newline at end of file diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index ca27bde039b..75b49817812 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -391,8 +391,6 @@ static int ptcache_totpoint_cloth(void *cloth_v) void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb) { ParticleSystemModifierData *psmd; - ModifierData *md; - int a; memset(pid, 0, sizeof(PTCacheID)); @@ -418,16 +416,10 @@ void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb) if(sb->particles) { psmd= psys_get_modifier(ob, sb->particles); - pid->stack_index= modifiers_indexInObject(ob, (ModifierData*)psmd); - } - else { - for(a=0, md=ob->modifiers.first; md; md=md->next, a++) { - if(md->type == eModifierType_Softbody) { - pid->stack_index = a; - break; - } - } + // pid->stack_index= modifiers_indexInObject(ob, (ModifierData*)psmd); XXX TODO - get other index DG } + else + pid->stack_index = pid->cache->index; } void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *psys) @@ -439,7 +431,7 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p pid->ob= ob; pid->calldata= psys; pid->type= PTCACHE_TYPE_PARTICLES; - pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)psmd); + pid->stack_index= psys->pointcache->index; pid->cache= psys->pointcache; pid->cache_ptr= &psys->pointcache; pid->ptcaches= &psys->ptcaches; @@ -728,7 +720,7 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo pid->calldata= smd; pid->type= PTCACHE_TYPE_SMOKE_DOMAIN; - pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)smd); + pid->stack_index= sds->point_cache->index; pid->cache= sds->point_cache; pid->cache_ptr= &sds->point_cache; @@ -758,7 +750,7 @@ void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *cl pid->ob= ob; pid->calldata= clmd; pid->type= PTCACHE_TYPE_CLOTH; - pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)clmd); + pid->stack_index= clmd->point_cache->index; pid->cache= clmd->point_cache; pid->cache_ptr= &clmd->point_cache; pid->ptcaches= &clmd->ptcaches; @@ -901,6 +893,10 @@ static int BKE_ptcache_id_filename(PTCacheID *pid, char *filename, int cfra, sho } if (do_ext) { + + if(pid->cache->index < 0) + pid->cache->index = pid->stack_index = object_insert_pc(pid->ob); + if(pid->cache->flag & PTCACHE_EXTERNAL) { if(pid->cache->index >= 0) snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02d"PTCACHE_EXT, cfra, pid->stack_index); /* always 6 chars */ @@ -1952,6 +1948,7 @@ PointCache *BKE_ptcache_add(ListBase *ptcaches) cache->startframe= 1; cache->endframe= 250; cache->step= 10; + cache->index = -1; BLI_addtail(ptcaches, cache); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 920e202520e..26e3d5bf6f1 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3993,6 +3993,7 @@ static void direct_link_object(FileData *fd, Object *ob) ob->derivedDeform= NULL; ob->derivedFinal= NULL; ob->gpulamp.first= ob->gpulamp.last= NULL; + link_list(fd, &ob->pc_ids); if(ob->sculpt) ob->sculpt= MEM_callocN(sizeof(SculptSession), "reload sculpt session"); diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c index 5e0ffb9ba48..f4242c70139 100644 --- a/source/blender/editors/space_view3d/drawvolume.c +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -236,8 +236,7 @@ void draw_volume(Scene *scene, ARegion *ar, View3D *v3d, Base *base, GPUTexture GPU_texture_bind(tex, 0); - if (!GLEW_ARB_texture_non_power_of_two) - { + if (!GLEW_ARB_texture_non_power_of_two) { cor[0] = (float)res[0]/(float)larger_pow2(res[0]); cor[1] = (float)res[1]/(float)larger_pow2(res[1]); cor[2] = (float)res[2]/(float)larger_pow2(res[2]); diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 36936a9fcb0..850b46dc28c 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -337,8 +337,7 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, float *fpixels) return NULL; } - if (!GLEW_ARB_texture_non_power_of_two) - { + if (!GLEW_ARB_texture_non_power_of_two) { tex->w = larger_pow2(tex->w); tex->h = larger_pow2(tex->h); tex->depth = larger_pow2(tex->depth); diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index be43ae7f99d..25fdf615adb 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -237,6 +237,7 @@ typedef struct Object { int pad2; ListBase gpulamp; /* runtime, for lamps only */ + ListBase pc_ids; } Object; /* Warning, this is not used anymore because hooks are now modifiers */ |