Code: Select all
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
int main()
{
IrrlichtDevice* device = createDevice(EDT_DIRECT3D9);
ISceneManager* smgr = device->getSceneManager();
IVideoDriver* driver = device->getVideoDriver();
ISceneNode* node = smgr->addSphereSceneNode(1.0);
node->setScale(vector3df(300, 300, 300));
node->setAutomaticCulling(EAC_FRUSTUM_BOX);
ICameraSceneNode* cam = smgr->addCameraSceneNodeFPS();
cam->setPosition(vector3df(0, 500, -500));
cam->setTarget(vector3df(0,0,0));
while(device->run())
{
stringw windowCaption = "Primitive Count Drawn: ";
windowCaption += driver->getPrimitiveCountDrawn();
windowCaption += " Plane relation: ";
windowCaption += node->getTransformedBoundingBox().classifyPlaneRelation(cam->getViewFrustum()->planes[SViewFrustum::VF_RIGHT_PLANE]);
device->setWindowCaption(windowCaption.c_str());
driver->beginScene(true, true, SColor(0xffaaaaff));
smgr->drawAll();
driver->endScene();
}
device->drop();
device = 0;
return 0;
}
So anyway, I look at the isCulled function, it's overly complicated and outdated, doing things that have their own helper functions already, so I replace the EAC_FRUSTUM_BOX with this:
Code: Select all
case scene::EAC_FRUSTUM_BOX:
{
SViewFrustum frust = *cam->getViewFrustum();
const core::aabbox3df& nodeBox = node->getTransformedBoundingBox();
for (s32 i=0; i<scene::SViewFrustum::VF_PLANE_COUNT; ++i)
if(nodeBox.classifyPlaneRelation(frust.planes[i]) == core::ISREL3D_FRONT)
return true;
}
break;
I also demand you change the default culling mode for scene nodes to EAC_FRUSTUM_BOX, as EAC_BOX does jack ****.
Thank you.