A Nurbs Optimization Part 2

I did a second test this morning with a curve with two spans and the new method still appears to be 2x faster than the Maya API method. I'll probably do one more test involving an arbitrary number of spans, and then do some tests regarding the speed of tangent calculation.


//calculate the extra points we need

points.insert((points[1] + points[2]) / 2.0, 2);

points.insert((points[3] + points[4]) / 2.0, 4);

points[3] = (points[2] + points[4]) / 2.0;


//calculate the basis function for each CV//

MPoint res_point;


if (useCache_val)

{

for (unsigned k = 0; k < 100000; k++)

{

if (param_val < 1)

{

res_point = points[0] * pow(1.0 - param_val, 3);

res_point += points[1] * (3 * param_val * pow(1.0 - param_val, 2));

res_point += points[2] * (3 * pow(param_val, 2) * (1.0 - param_val));

res_point += points[3] * pow(param_val, 3);

}

else

{

res_point = points[3] * pow(1.0 - param_val, 3);

res_point += points[4] * (3 * param_val * pow(1.0 - param_val, 2));

res_point += points[5] * (3 * pow(param_val, 2) * (1.0 - param_val));

res_point += points[6] * pow(param_val, 3);

}

}

}

else

{

for (unsigned k = 0; k < 100000; k++)

mFnCurve.getPointAtParam(param_val, res_point);

}


Featured Posts
Recent Posts
Archive
Search By Tags