matrix4::transformBox broken

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
RoCKdaFrogg
Posts: 3
Joined: Wed Jun 29, 2005 6:10 pm
Contact:

matrix4::transformBox broken

Post by RoCKdaFrogg »

I can't really believe nobody noticed this before...

matrix4::transformBox consists of the following code:

Code: Select all

	//! Transforms a axis aligned bounding box
	inline void matrix4::transformBox( core::aabbox3d<f32> &box) const
	{
		transformVect(box.MinEdge);
		transformVect(box.MaxEdge);
		box.repair();
	}
This code is wrong and, for example, sometimes culls nodes when no culling should be done. A simple replacement would be:

Code: Select all

	//! Transforms a axis aligned bounding box
	inline void matrix4::transformBox( core::aabbox3d<f32> &box) const
	{
		vector3df min, max, vec;
		int i;

		min = box.MinEdge;
		max = box.MaxEdge;

		transformVect(box.MinEdge);
		transformVect(box.MaxEdge);
		box.repair();

		for(i = 0; i < 6; i++)
		{
			vec.X = ((i == 0 || i == 1 || i == 2) ? min : max).X;
			vec.Y = ((i == 0 || i == 3 || i == 5) ? min : max).Y;
			vec.Z = ((i == 1 || i == 4 || i == 5) ? min : max).Z;
			transformVect(vec);

			box.addInternalPoint(vec);
		}
	}
Comments appreciated.
puh
Posts: 356
Joined: Tue Aug 26, 2003 3:53 pm

Post by puh »

Wow, you right. It's a long time i try to find what's wrong with occlusion mechanism. Thank you RoCKdaFrogg, it's a seriouse bug, IMHO!
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Hm, that's right. I think you'll also get some performance boosts out of that, did you try it out?
puh
Posts: 356
Joined: Tue Aug 26, 2003 3:53 pm

Post by puh »

Yes, I have tried. Didn't check performance boost though...
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

which file should be modified? I got no search in project-files ability :(
bal
Posts: 829
Joined: Fri Jun 18, 2004 5:19 pm
Location: Geluwe, Belgium

Post by bal »

I guess it's "matrix4.h"
General Tools List
General FAQ
System: AMD Barton 2600+, 512MB, 9600XT 256MB, WinXP + FC3
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

loooooooool!!! :oops: :oops: :oops:

me and my big mouth :oops:

edited: forgot to look in the "include" folder; was only looking at the "source" one.
Last edited by afecelis on Sun Jul 03, 2005 2:10 pm, edited 1 time in total.
RoCKdaFrogg
Posts: 3
Joined: Wed Jun 29, 2005 6:10 pm
Contact:

Post by RoCKdaFrogg »

You won't get a performance boost.

Bounding boxes will now always be bigger (as they should be), as all I added in transformBox is that all 8 corners of the old bounding box are included in the new bounding box. So occlusion will be done in less cases.
Post Reply