cull by distance, to improve performance

This commit is contained in:
Marianne Gagnon
2014-05-10 20:38:10 -04:00
parent e16c6af04a
commit fbd33420c2
2 changed files with 11 additions and 0 deletions

View File

@@ -22,7 +22,9 @@
#include "karts/abstract_kart.hpp"
#include "modes/world.hpp"
#include <ISceneManager.h>
#include <ISceneNode.h>
#include <ICameraSceneNode.h>
IrrDebugDrawer::IrrDebugDrawer()
{
@@ -59,6 +61,10 @@ void IrrDebugDrawer::drawLine(const btVector3& from, const btVector3& to,
video::SColor c(255, (int)(color.getX()*255), (int)(color.getY()*255),
(int)(color.getZ()*255) );
//World::getWorld()->getCa
if (from.distance2(m_camera_pos) > 10000) return;
std::vector<float>& v = m_lines[c];
v.push_back(from.getX());
v.push_back(from.getY());
@@ -77,6 +83,9 @@ void IrrDebugDrawer::beginNextFrame()
{
it->second.clear();
}
scene::ICameraSceneNode* camera = irr_driver->getSceneManager()->getActiveCamera();
m_camera_pos = camera->getPosition();
}
/* EOF */

View File

@@ -44,6 +44,8 @@ public:
std::map<video::SColor, std::vector<float>> m_lines;
Vec3 m_camera_pos;
protected:
virtual void setDebugMode(int debug_mode) {}
/** Callback for bullet: if debug drawing should be done or not.