From 5c3fd163caaf7de11976ce67a78435d31f5dcba4 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sun, 4 Jul 2010 20:56:54 +0100 Subject: [PATCH] Shift cube used for frustum culling --- include/IQuadTree.hpp | 8 +++++--- src/QuadTree.cpp | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/IQuadTree.hpp b/include/IQuadTree.hpp index 22e0204..6d5e582 100644 --- a/include/IQuadTree.hpp +++ b/include/IQuadTree.hpp @@ -27,9 +27,11 @@ struct ISectorRenderable { virtual ~ISectorRenderable() {} virtual void render_sector(IGraphicsPtr a_context, int id, - Point bot_left, Point top_right) = 0; + Point bot_left, + Point top_right) = 0; virtual void post_render_sector(IGraphicsPtr a_context, int id, - Point bot_left, Point top_right) = 0; + Point bot_left, + Point top_right) = 0; }; typedef shared_ptr ISectorRenderablePtr; @@ -46,6 +48,6 @@ typedef shared_ptr IQuadTreePtr; // Produce a quad tree of given square dimension IQuadTreePtr make_quad_tree(ISectorRenderablePtr a_renderable, - int width, int height); + int width, int height); #endif diff --git a/src/QuadTree.cpp b/src/QuadTree.cpp index efd6d92..c92bec1 100644 --- a/src/QuadTree.cpp +++ b/src/QuadTree.cpp @@ -197,9 +197,9 @@ void QuadTree::visible_sectors(IGraphicsPtr a_context, list& a_list, int y = child->bot_left.y + h/2; if (a_context->cube_in_view_frustum( - static_cast(x), + static_cast(x) - 0.5f, 0.0f, - static_cast(y), + static_cast(y) - 0.5f, static_cast(w) / 2.0f)) visible_sectors(a_context, a_list, childID); else @@ -208,7 +208,8 @@ void QuadTree::visible_sectors(IGraphicsPtr a_context, list& a_list, } } -IQuadTreePtr make_quad_tree(ISectorRenderablePtr a_renderer, int width, int height) +IQuadTreePtr make_quad_tree(ISectorRenderablePtr a_renderer, + int width, int height) { auto_ptr ptr(new QuadTree(a_renderer)); ptr->build_tree(width, height); -- 2.39.2