Small Bug in Box3I (and fix)
by William Todd Scott · in Torque Game Engine Advanced · 04/20/2007 (11:57 pm) · 7 replies
Hi,
Box3I::getCenter reads as follows:
but should be:
Box3I::getCenter reads as follows:
center->x = (min.x + max.x) / 0.5; center->y = (min.y + max.y) / 0.5; center->z = (min.z + max.z) / 0.5;
but should be:
inline void Box3I::getCenter(Point3I* center) const
{
center->x = (min.x + max.x) / 2;
center->y = (min.y + max.y) / 2;
center->z = (min.z + max.z) / 2;
}
#2
04/21/2007 (4:23 pm)
center->x = (min.x + max.x) * 0.5; center->y = (min.y + max.y) * 0.5; center->z = (min.z + max.z) * 0.5;
#3
@Andy: The getCenter function for Box3I currently returns the wrong value.
@Jacobin: This is also a perfectly valid solution. However, I was concerned that multiplying by 0.5f would cause a float to int conversion causing the math coprocessor to stall. But, I did not check the assembly, so I am not sure....
Todd
04/21/2007 (6:25 pm)
Hi guys,@Andy: The getCenter function for Box3I currently returns the wrong value.
@Jacobin: This is also a perfectly valid solution. However, I was concerned that multiplying by 0.5f would cause a float to int conversion causing the math coprocessor to stall. But, I did not check the assembly, so I am not sure....
Todd
#4
04/21/2007 (7:50 pm)
How about:center->x = (min.x + max.x) >> 1; center->y = (min.y + max.y) >> 1; center->z = (min.z + max.z) >> 1;
#6
04/22/2007 (5:49 am)
I do not have the source with me, but I think I recall using this very function and that it is used in ShapeBase ConsoleMethods quite a bit. Odd how no one has noticed.
#7
http://www.garagegames.com/mg/forums/result.thread.php?qt=61063
It is something that I can't locate. I've checked the code and can't determine what's causing it.
Any help on this is greatly appreciated.
04/22/2007 (1:57 pm)
Hey guys, excellent work on this. I was wondering if you have time, could you find out what might be causing this bug?http://www.garagegames.com/mg/forums/result.thread.php?qt=61063
It is something that I can't locate. I've checked the code and can't determine what's causing it.
Any help on this is greatly appreciated.
Torque Owner Andy Hodges