Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2008-11-14 18:46:51 +0300
committerMartin Poirier <theeth@yahoo.com>2008-11-14 18:46:51 +0300
commit59ac45dd12ca5a177318815f9396cd6b97cea766 (patch)
treecf2b837ef9030bf1ddb628dd1b3824793ba13e0e /source
parent9c30c74bd5d7922e9d4e849cc0c87779b2e69ecc (diff)
Reset max cost to FLT_MAX (this fixes a bug with early culling)
Optimization when number of buckets == number of joints
Diffstat (limited to 'source')
-rw-r--r--source/blender/src/editarmature_retarget.c66
1 files changed, 39 insertions, 27 deletions
diff --git a/source/blender/src/editarmature_retarget.c b/source/blender/src/editarmature_retarget.c
index fdc409dd85b..2ac62d89143 100644
--- a/source/blender/src/editarmature_retarget.c
+++ b/source/blender/src/editarmature_retarget.c
@@ -1936,7 +1936,7 @@ static void printPositions(int *positions, int nb_positions)
}
#endif
-#define MAX_COST 100 /* FIX ME */
+#define MAX_COST FLT_MAX /* FIX ME */
static float costDistance(ReebArcIterator *iter, float *vec0, float *vec1, int i0, int i1)
{
@@ -2174,10 +2174,7 @@ static void retargetArctoArcAggresive(RigGraph *rigg, RigArc *iarc, RigNode *ino
ReebArc *earc = iarc->link_mesh;
float min_cost = FLT_MAX;
float *vec0, *vec1, *vec2;
- float **vec_cache;
- float *cost_cache;
int *best_positions;
- int *positions;
int nb_edges = BLI_countlist(&iarc->edges);
int nb_joints = nb_edges - 1;
RetargetMethod method = METHOD_MEMOIZE;
@@ -2189,10 +2186,7 @@ static void retargetArctoArcAggresive(RigGraph *rigg, RigArc *iarc, RigNode *ino
return;
}
- positions = MEM_callocN(sizeof(int) * nb_joints, "Aggresive positions");
- best_positions = MEM_callocN(sizeof(int) * nb_joints, "Best Aggresive positions");
- cost_cache = MEM_callocN(sizeof(float) * nb_edges, "Cost cache");
- vec_cache = MEM_callocN(sizeof(float*) * (nb_edges + 1), "Vec cache");
+ best_positions = MEM_callocN(sizeof(int) * nb_joints, "Best positions");
if (testFlipArc(iarc, inode_start))
{
@@ -2204,23 +2198,18 @@ static void retargetArctoArcAggresive(RigGraph *rigg, RigArc *iarc, RigNode *ino
node_start = earc->head;
node_end = earc->tail;
}
-
- /* init with first values */
- for (i = 0; i < nb_joints; i++)
- {
- positions[i] = i + 1;
- //positions[i] = (earc->bcount / nb_edges) * (i + 1);
- }
-
- /* init cost cache */
- for (i = 0; i < nb_edges; i++)
+
+ /* equal number of joints and potential position, just fill them in */
+ if (nb_joints == earc->bcount)
{
- cost_cache[i] = 0;
+ int i;
+
+ /* init with first values */
+ for (i = 0; i < nb_joints; i++)
+ {
+ best_positions[i] = i + 1;
+ }
}
-
- vec_cache[0] = node_start->p;
- vec_cache[nb_edges] = node_end->p;
-
if (method == METHOD_MEMOIZE)
{
int nb_positions = earc->bcount;
@@ -2252,10 +2241,32 @@ static void retargetArctoArcAggresive(RigGraph *rigg, RigArc *iarc, RigNode *ino
/* BRUTE FORCE */
else if (method == METHOD_BRUTE_FORCE)
{
+ float **vec_cache;
+ float *cost_cache;
+ int *positions;
int last_index = 0;
int first_pass = 1;
int must_move = nb_joints - 1;
+ positions = MEM_callocN(sizeof(int) * nb_joints, "Aggresive positions");
+ cost_cache = MEM_callocN(sizeof(float) * nb_edges, "Cost cache");
+ vec_cache = MEM_callocN(sizeof(float*) * (nb_edges + 1), "Vec cache");
+
+ /* init with first values */
+ for (i = 0; i < nb_joints; i++)
+ {
+ positions[i] = i + 1;
+ }
+
+ /* init cost cache */
+ for (i = 0; i < nb_edges; i++)
+ {
+ cost_cache[i] = 0;
+ }
+
+ vec_cache[0] = node_start->p;
+ vec_cache[nb_edges] = node_end->p;
+
while(1)
{
float cost = 0;
@@ -2390,6 +2401,10 @@ static void retargetArctoArcAggresive(RigGraph *rigg, RigArc *iarc, RigNode *ino
memcpy(best_positions, positions, sizeof(int) * nb_joints);
}
}
+
+ MEM_freeN(positions);
+ MEM_freeN(cost_cache);
+ MEM_freeN(vec_cache);
}
vec0 = node_start->p;
@@ -2427,11 +2442,8 @@ static void retargetArctoArcAggresive(RigGraph *rigg, RigArc *iarc, RigNode *ino
vec0 = vec1;
}
-
- MEM_freeN(positions);
+
MEM_freeN(best_positions);
- MEM_freeN(cost_cache);
- MEM_freeN(vec_cache);
}
static void retargetArctoArcLength(RigGraph *rigg, RigArc *iarc, RigNode *inode_start)