Revision: 17561 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17561 Author: theeth Date: 2008-11-24 20:24:49 +0100 (Mon, 24 Nov 2008)
Log Message: ----------- Second step out of three for merging sketching subdivision methods with graph subdivision methods. Graph subdivision uses graph arc iterators. Modified Paths: -------------- branches/etch-a-ton/source/blender/blenlib/BLI_graph.h branches/etch-a-ton/source/blender/include/reeb.h branches/etch-a-ton/source/blender/src/editarmature.c branches/etch-a-ton/source/blender/src/editarmature_retarget.c branches/etch-a-ton/source/blender/src/reeb.c Modified: branches/etch-a-ton/source/blender/blenlib/BLI_graph.h =================================================================== --- branches/etch-a-ton/source/blender/blenlib/BLI_graph.h 2008-11-24 18:59:59 UTC (rev 17560) +++ branches/etch-a-ton/source/blender/blenlib/BLI_graph.h 2008-11-24 19:24:49 UTC (rev 17561) @@ -62,20 +62,23 @@ struct BArcIterator; -typedef float* (*PeekPointFct)(struct BArcIterator* iter, int n); -typedef float* (*NextPointFct)(struct BArcIterator* iter); -typedef float* (*CurrentPointFct)(struct BArcIterator* iter); -typedef float* (*PreviousPointFct)(struct BArcIterator* iter); -typedef int (*StoppedFct)(struct BArcIterator* iter); +typedef void* (*PeekFct)(void* iter, int n); +typedef void* (*NextFct)(void* iter); +typedef void* (*NextNFct)(void* iter, int n); +typedef void* (*PreviousFct)(void* iter); +typedef int (*StoppedFct)(void* iter); typedef struct BArcIterator { - PeekPointFct peek; - NextPointFct next; - CurrentPointFct current; - PreviousPointFct previous; - StoppedFct stopped; + PeekFct peek; + NextFct next; + NextNFct nextN; + PreviousFct previous; + StoppedFct stopped; + float *p, *no; + int length; + int index; } BArcIterator; /* Helper structure for radial symmetry */ Modified: branches/etch-a-ton/source/blender/include/reeb.h =================================================================== --- branches/etch-a-ton/source/blender/include/reeb.h 2008-11-24 18:59:59 UTC (rev 17560) +++ branches/etch-a-ton/source/blender/include/reeb.h 2008-11-24 19:24:49 UTC (rev 17561) @@ -28,7 +28,7 @@ #ifndef REEB_H_ #define REEB_H_ -//#define WITH_BF_REEB +#define WITH_BF_REEB #include "DNA_listBase.h" @@ -120,12 +120,21 @@ } ReebArc; typedef struct ReebArcIterator { + PeekFct peek; + NextFct next; + NextNFct nextN; + PreviousFct previous; + StoppedFct stopped; + + float *p, *no; + + int length; + int index; + /*********************************/ struct ReebArc *arc; - int index; int start; int end; - int stride; - int length; + int stride; } ReebArcIterator; struct EditMesh; @@ -145,12 +154,6 @@ void initArcIterator(struct ReebArcIterator *iter, struct ReebArc *arc, struct ReebNode *head); void initArcIterator2(struct ReebArcIterator *iter, struct ReebArc *arc, int start, int end); void initArcIteratorStart(struct ReebArcIterator *iter, struct ReebArc *arc, struct ReebNode *head, int start); -struct EmbedBucket * nextBucket(struct ReebArcIterator *iter); -struct EmbedBucket * nextNBucket(ReebArcIterator *iter, int n); -struct EmbedBucket * peekBucket(ReebArcIterator *iter, int n); -struct EmbedBucket * currentBucket(struct ReebArcIterator *iter); -struct EmbedBucket * previousBucket(struct ReebArcIterator *iter); -int iteratorStopped(struct ReebArcIterator *iter); /* Filtering */ void filterNullReebGraph(ReebGraph *rg); Modified: branches/etch-a-ton/source/blender/src/editarmature.c =================================================================== --- branches/etch-a-ton/source/blender/src/editarmature.c 2008-11-24 18:59:59 UTC (rev 17560) +++ branches/etch-a-ton/source/blender/src/editarmature.c 2008-11-24 19:24:49 UTC (rev 17561) @@ -4656,8 +4656,7 @@ if (G.scene->toolsettings->skgen_options & SKGEN_CUT_ANGLE) { ReebArcIterator iter; - EmbedBucket *current = NULL; - EmbedBucket *previous = NULL; + float *previous = NULL, *current = NULL; EditBone *child = NULL; EditBone *parent = NULL; EditBone *root = NULL; @@ -4669,22 +4668,28 @@ root = parent; - for (initArcIterator(&iter, arc, head), previous = nextBucket(&iter), current = nextBucket(&iter); - current; - previous = current, current = nextBucket(&iter)) + initArcIterator(&iter, arc, head); + iter.next(&iter); + previous = iter.p; + + for (iter.next(&iter); + iter.stopped(&iter) == 0; + previous = iter.p, iter.next(&iter)) { float vec1[3], vec2[3]; float len1, len2; + + current = iter.p; - VecSubf(vec1, previous->p, parent->head); - VecSubf(vec2, current->p, previous->p); + VecSubf(vec1, previous, parent->head); + VecSubf(vec2, current, previous); len1 = Normalize(vec1); len2 = Normalize(vec2); if (len1 > 0.0f && len2 > 0.0f && Inpf(vec1, vec2) < angleLimit) { - VECCOPY(parent->tail, previous->p); + VECCOPY(parent->tail, previous); child = add_editbone("Bone"); VECCOPY(child->head, parent->tail); @@ -4718,19 +4723,18 @@ if (len > 2) { ReebArcIterator iter; - EmbedBucket *bucket = NULL; float avg_t = 0.0f; float s_t = 0.0f; float s_xyz = 0.0f; /* First pass, calculate average */ - for (initArcIterator2(&iter, arc, start, end), bucket = nextBucket(&iter); - bucket; - bucket = nextBucket(&iter)) + for (initArcIterator2(&iter, arc, start, end), iter.next(&iter); + iter.stopped(&iter) == 0; + iter.next(&iter)) { float v[3]; - VecSubf(v, bucket->p, v0); + VecSubf(v, iter.p, v0); avg_t += Inpf(v, n); } @@ -4739,14 +4743,14 @@ avg_t /= len; /* Second pass, calculate s_xyz and s_t */ - for (initArcIterator2(&iter, arc, start, end), bucket = nextBucket(&iter); - bucket; - bucket = nextBucket(&iter)) + for (initArcIterator2(&iter, arc, start, end), iter.next(&iter); + iter.stopped(&iter) == 0; + iter.next(&iter)) { float v[3], d[3]; float dt; - VecSubf(v, bucket->p, v0); + VecSubf(v, iter.p, v0); Projf(d, v, n); VecSubf(v, v, d); @@ -4770,19 +4774,18 @@ float calcDistance(ReebArc *arc, int start, int end, float head[3], float tail[3]) { ReebArcIterator iter; - EmbedBucket *bucket = NULL; float max_dist = 0; /* calculate maximum distance */ - for (initArcIterator2(&iter, arc, start, end), bucket = nextBucket(&iter); - bucket; - bucket = nextBucket(&iter)) + for (initArcIterator2(&iter, arc, start, end), iter.next(&iter); + iter.stopped(&iter) == 0; + iter.next(&iter)) { float v1[3], v2[3], c[3]; float dist; VecSubf(v1, head, tail); - VecSubf(v2, bucket->p, tail); + VecSubf(v2, iter.p, tail); Crossf(c, v1, v2); @@ -4810,8 +4813,6 @@ if (G.scene->toolsettings->skgen_options & SKGEN_CUT_CORRELATION) { - EmbedBucket *bucket = NULL; - EmbedBucket *previous = NULL; EditBone *child = NULL; EditBone *parent = NULL; float normal[3] = {0, 0, 0}; @@ -4823,23 +4824,21 @@ parent->flag = BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; VECCOPY(parent->head, head->p); - for (previous = nextBucket(&iter), bucket = nextBucket(&iter); - bucket; - previous = bucket, bucket = nextBucket(&iter)) + while(iter.next(&iter)) { float btail[3]; float value = 0; if (G.scene->toolsettings->skgen_options & SKGEN_STICK_TO_EMBEDDING) { - VECCOPY(btail, bucket->p); + VECCOPY(btail, iter.p); } else { float length; /* Calculate normal */ - VecSubf(n, bucket->p, parent->head); + VecSubf(n, iter.p, parent->head); length = Normalize(n); total += 1; @@ -4923,8 +4922,7 @@ arcLengthRatio(arc) >= G.scene->toolsettings->skgen_length_ratio) { ReebArcIterator iter; - EmbedBucket *bucket = NULL; - EmbedBucket *previous = NULL; + float *previous = NULL; EditBone *child = NULL; EditBone *parent = NULL; float lengthLimit = G.scene->toolsettings->skgen_length_limit; @@ -4936,12 +4934,12 @@ initArcIterator(&iter, arc, head); - bucket = nextBucket(&iter); + iter.next(&iter); - while (bucket != NULL) + while (iter.stopped(&iter) == 0) { float *vec0 = NULL; - float *vec1 = bucket->p; + float *vec1 = iter.p; /* first bucket. Previous is head */ if (previous == NULL) @@ -4951,7 +4949,7 @@ /* Previous is a valid bucket */ else { - vec0 = previous->p; + vec0 = previous; } /* If lengthLimit hits the current segment */ @@ -5009,8 +5007,8 @@ } else { - previous = bucket; - bucket = nextBucket(&iter); + previous = iter.p; + iter.next(&iter); same = 0; // Reset same } } Modified: branches/etch-a-ton/source/blender/src/editarmature_retarget.c =================================================================== --- branches/etch-a-ton/source/blender/src/editarmature_retarget.c 2008-11-24 18:59:59 UTC (rev 17560) +++ branches/etch-a-ton/source/blender/src/editarmature_retarget.c 2008-11-24 19:24:49 UTC (rev 17561) @@ -1683,9 +1683,9 @@ parent->flag = BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; VECCOPY(parent->head, head->p); - for (previous = nextBucket(&iter), bucket = nextBucket(&iter); + for (previous = iter.next(&iter), bucket = iter.next(&iter); bucket; - previous = bucket, bucket = nextBucket(&iter)) + previous = bucket, bucket = iter.next(&iter)) { float btail[3]; float value = 0; @@ -2068,7 +2068,7 @@ { float dist; - bucket = peekBucket(iter, j); + bucket = iter->peek(iter, j); VecSubf(v2, bucket->p, vec1); @@ -2336,7 +2336,7 @@ for (i = 1; i <= nb_positions; i++) { - EmbedBucket *bucket = peekBucket(&iter, i); + EmbedBucket *bucket = iter.peek(&iter, i); positions_cache[i] = bucket->p; } @@ -2443,7 +2443,7 @@ if (i < nb_joints) { i2 = positions[i]; - bucket = peekBucket(&iter, positions[i]); + bucket = iter.peek(&iter, positions[i]); vec2 = bucket->p; vec_cache[i + 1] = vec2; /* update cache for updated position */ } @@ -2535,7 +2535,7 @@ float *no = NULL; if (i < nb_joints) { - bucket = peekBucket(&iter, best_positions[i]); + bucket = iter.peek(&iter, best_positions[i]); vec1 = bucket->p; no = bucket->no; } @@ -2582,7 +2582,7 @@ initArcIterator(&iter, earc, node_start); - bucket = nextBucket(&iter); + bucket = iter.next(&iter); vec0 = node_start->p; @@ -2593,7 +2593,7 @@ embedding_length += VecLenf(vec0, vec1); vec0 = vec1; - bucket = nextBucket(&iter); + bucket = iter.next(&iter); } embedding_length += VecLenf(node_end->p, vec1); @@ -2601,7 +2601,7 @@ /* fit bones */ initArcIterator(&iter, earc, node_start); - bucket = nextBucket(&iter); + bucket = iter.next(&iter); vec0 = node_start->p; previous_vec = vec0; @@ -2616,7 +2616,7 @@ while (bucket && new_bone_length > length) { length += VecLenf(previous_vec, vec1); - bucket = nextBucket(&iter); + bucket = iter.next(&iter); previous_vec = vec1; vec1 = bucket->p; no = bucket->no; Modified: branches/etch-a-ton/source/blender/src/reeb.c @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs