X file bounding box bug

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
nomad
Posts: 53
Joined: Thu Jan 05, 2006 12:35 pm
Location: Wales

X file bounding box bug

Post by nomad »

The X files I am exporting from MAX 7 are loading with a zero-sized bounding box. Really messes up the physics :?

This patch fixes it:

Code: Select all

Index: source/Irrlicht/CXAnimationPlayer.cpp
===================================================================
--- source/Irrlicht/CXAnimationPlayer.cpp	(revision 335)
+++ source/Irrlicht/CXAnimationPlayer.cpp	(working copy)
@@ -801,9 +801,7 @@
 			core::vector3df p(0,0,0);
 			Joints[i].AnimatedMatrix.transformVect(p);
 
-			if (first)
-				Box.reset(p);
-			else
+	//  Bounding boxes can have zero size, since this code was resetting the existing box
 				Box.addInternalPoint(p);
 
 			first = false;
I don't see why you would want to reset the bounding box to zero size in the first place, but my X files now load correctly.
Incidentally, should I do anything else with this patch (like commit it)?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I don't think that you could commit it, but you could give an example file such that those things could be checked. It might be your mesh as well, and you never know what else breaks.
nomad
Posts: 53
Joined: Thu Jan 05, 2006 12:35 pm
Location: Wales

Post by nomad »

This is pretty trivial, but it shows the problem, when used to load this mesh:
http://www.sideshoot.com/downloads.rock.X
(same problem with earth.X, one of the Irrlicht sample meshes so I guess this is not a mesh problem)

Code: Select all

#include "irrlicht.h"

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace gui;

	IrrlichtDevice *device = createDevice(EDT_DIRECT3D9);
	IAnimatedMesh* mesh = device->getSceneManager()->getMesh("rock.X");
	aabbox3d<f32> extent = device->getSceneManager()->addAnimatedMeshSceneNode(mesh)->getBoundingBox();
	stringw s = stringw("Bounding box -  X:")+stringw(extent.getExtent().X)+stringw(", Y:")+stringw(extent.getExtent().Y)+stringw(", Z:")+stringw(extent.getExtent().Z);
		
	device->getGUIEnvironment()->addMessageBox(L"Bounding Box: ", s.c_str());
	while(device->run()) {
		device->getVideoDriver()->beginScene(true, true, SColor(255,100,101,140));
		device->getGUIEnvironment()->drawAll();
		device->getVideoDriver()->endScene();
	}
Hope this is helpful.
Post Reply