[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15908] branches/harmonic-skeleton/source/ blender/src/reeb.c: Fix problem with long stretches without embedding between head/ tail nodes and the actual start and end of embedding bucket.
Martin Poirier
theeth at yahoo.com
Fri Aug 1 22:29:48 CEST 2008
Revision: 15908
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15908
Author: theeth
Date: 2008-08-01 22:29:42 +0200 (Fri, 01 Aug 2008)
Log Message:
-----------
Fix problem with long stretches without embedding between head/tail nodes and the actual start and end of embedding bucket.
Instead of having to muck around in the generating and retargetting code to deal with those cases, just fill dummy buckets with interpolations.
Modified Paths:
--------------
branches/harmonic-skeleton/source/blender/src/reeb.c
Modified: branches/harmonic-skeleton/source/blender/src/reeb.c
===================================================================
--- branches/harmonic-skeleton/source/blender/src/reeb.c 2008-08-01 20:01:01 UTC (rev 15907)
+++ branches/harmonic-skeleton/source/blender/src/reeb.c 2008-08-01 20:29:42 UTC (rev 15908)
@@ -737,6 +737,71 @@
}
}
+static void ExtendArcBuckets(ReebArc *arc)
+{
+ ReebArcIterator iter;
+ EmbedBucket *previous, *bucket, *last_bucket, *first_bucket;
+ float average_length = 0, length;
+ int padding_head = 0, padding_tail = 0;
+
+ initArcIterator(&iter, arc, arc->head);
+
+ for ( previous = nextBucket(&iter), bucket = nextBucket(&iter);
+ bucket;
+ previous = bucket, bucket = nextBucket(&iter)
+ )
+ {
+ average_length += VecLenf(previous->p, bucket->p);
+ }
+ average_length /= (arc->bcount - 1);
+
+ first_bucket = arc->buckets;
+ last_bucket = arc->buckets + (arc->bcount - 1);
+
+ length = VecLenf(first_bucket->p, arc->head->p);
+ if (length > 2 * average_length)
+ {
+ padding_head = (int)floor(length / average_length);
+ }
+
+ length = VecLenf(last_bucket->p, arc->tail->p);
+ if (length > 2 * average_length)
+ {
+ padding_tail = (int)floor(length / average_length);
+ }
+
+ if (padding_head + padding_tail > 0)
+ {
+ EmbedBucket *old_buckets = arc->buckets;
+
+ arc->buckets = MEM_callocN(sizeof(EmbedBucket) * (padding_head + arc->bcount + padding_tail), "embed bucket");
+ memcpy(arc->buckets + padding_head, old_buckets, arc->bcount * sizeof(EmbedBucket));
+
+ arc->bcount = padding_head + arc->bcount + padding_tail;
+ }
+
+ if (padding_head > 0)
+ {
+ interpolateBuckets(arc, arc->head->p, first_bucket->p, 0, padding_head);
+ }
+
+ if (padding_tail > 0)
+ {
+ interpolateBuckets(arc, last_bucket->p, arc->tail->p, arc->bcount - padding_tail, arc->bcount - 1);
+ }
+}
+
+/* CALL THIS ONLY AFTER FILTERING, SINCE IT MESSES UP WEIGHT DISTRIBUTION */
+void extendGraphBuckets(ReebGraph *rg)
+{
+ ReebArc *arc;
+
+ for (arc = rg->arcs.first; arc; arc = arc->next)
+ {
+ ExtendArcBuckets(arc);
+ }
+}
+
/**************************************** LENGTH CALCULATIONS ****************************************/
void calculateArcLength(ReebArc *arc)
@@ -1749,6 +1814,8 @@
{
postprocessGraph(rg, method);
}
+
+ extendGraphBuckets(rg);
}
/************************************** WEIGHT SPREADING ***********************************************/
More information about the Bf-blender-cvs
mailing list