Page 1 of 1

X file bounding box bug

Posted: Mon Dec 18, 2006 2:53 pm
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)?

Posted: Mon Dec 18, 2006 4:40 pm
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.

Posted: Mon Dec 18, 2006 7:27 pm
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.