I have the following function:
void CGlEngineFunctions::GetBezierOpposite( const POINTFLOAT &a,const POINTFLOAT ¢er, POINTFLOAT &b, float blength )
{
POINTFLOAT v;
v.x = a.x - center.x;
v.y = a.y - center.y;
float alength = GetDistance(a,center);
if(blength == 0)
{
blength = alength;
}
float multiplier = blength / alength;
b.x = center.x - multiplier * v.x;
b.y = center.y - multiplier * v.y;
}
I have narrowed the problem down to the least 2 lines:
b.x = center.x - multiplier * v.x;
b.y = center.y - multiplier * v.y;
Every time I call this repeatedly, memory shots up until it crashes.
I use it like this:
glEngine.functions.GetBezierOpposite(usrpt[0].LeftHandle,
usrpt[0].UserPoint,usrpt[0].RightHandle,0);
I really do not see how this could cause any problems. To test, I changed it to this:
void CGlEngineFunctions::GetBezierOpposite( const POINTFLOAT &a,const POINTFLOAT ¢er, POINTFLOAT &b, float blength )
{
POINTFLOAT v;
v.x = a.x - center.x;
v.y = a.y - center.y;
float alength = GetDistance(a,center);
if(blength == 0)
{
blength = alength;
}
float multiplier = blength / alength;
b.x = 5;
b.y = 5;
}
When I do this it has absolutely no issues. I do not see how doing arithmetic can cause the memory usage to shoot up.
Thanks
could it be cause if alength and blength = 0?
POINTFLOAT:
float x;
float y;