From 30531472d0afccdb3b06b2e8fe8894ef4f9440be Mon Sep 17 00:00:00 2001 From: mwturvey Date: Tue, 11 Apr 2017 11:59:06 -0700 Subject: Improve performance of gradient calculation --- src/poser_turveytori.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/poser_turveytori.c') diff --git a/src/poser_turveytori.c b/src/poser_turveytori.c index 5ad5c1b..c526161 100644 --- a/src/poser_turveytori.c +++ b/src/poser_turveytori.c @@ -436,23 +436,25 @@ Point getGradient(Point pointIn, PointsAndAngle *pna, size_t pnaCount, FLT preci { Point result; + FLT baseFitness = getPointFitness(pointIn, pna, pnaCount, 0); + Point tmpXplus = pointIn; Point tmpXminus = pointIn; tmpXplus.x = pointIn.x + precision; tmpXminus.x = pointIn.x - precision; - result.x = getPointFitness(tmpXplus, pna, pnaCount, 0) - getPointFitness(tmpXminus, pna, pnaCount, 0); + result.x = baseFitness - getPointFitness(tmpXminus, pna, pnaCount, 0); Point tmpYplus = pointIn; Point tmpYminus = pointIn; tmpYplus.y = pointIn.y + precision; tmpYminus.y = pointIn.y - precision; - result.y = getPointFitness(tmpYplus, pna, pnaCount, 0) - getPointFitness(tmpYminus, pna, pnaCount, 0); + result.y = baseFitness - getPointFitness(tmpYminus, pna, pnaCount, 0); Point tmpZplus = pointIn; Point tmpZminus = pointIn; tmpZplus.z = pointIn.z + precision; tmpZminus.z = pointIn.z - precision; - result.z = getPointFitness(tmpZplus, pna, pnaCount, 0) - getPointFitness(tmpZminus, pna, pnaCount, 0); + result.z = baseFitness - getPointFitness(tmpZminus, pna, pnaCount, 0); return result; } @@ -1518,7 +1520,7 @@ int PoserTurveyTori( SurviveObject * so, PoserData * poserData ) counter++; // let's just do this occasionally for now... - if (counter % 2 == 0) + //if (counter % 1 == 0) QuickPose(so, 0); } // axis changed, time to increment the circular buffer index. -- cgit v1.2.3