00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #if !defined(_XRB_ENGINE2_VISIBILITYQUADTREE_HPP_)
00012 #define _XRB_ENGINE2_VISIBILITYQUADTREE_HPP_
00013
00014 #include "xrb.hpp"
00015
00016 #include <set>
00017
00018 #include "xrb_color.hpp"
00019 #include "xrb_engine2_quadtree.hpp"
00020 #include "xrb_engine2_types.hpp"
00021 #include "xrb_math.hpp"
00022 #include "xrb_matrix2.hpp"
00023
00024 namespace Xrb
00025 {
00026
00027 class RenderContext;
00028 class Screen;
00029 class Serializer;
00030
00031 namespace Engine2
00032 {
00033
00034
00035
00036
00037
00038
00039
00040 class VisibilityQuadTree : public QuadTree
00041 {
00042 public:
00043
00044 VisibilityQuadTree (
00045 FloatVector2 const ¢er,
00046 Float half_side_length,
00047 Uint8 depth);
00048 virtual ~VisibilityQuadTree () { }
00049
00050 static VisibilityQuadTree *Create (Serializer &serializer);
00051
00052 virtual void ReadStructure (Serializer &serializer);
00053 void WriteStructure (Serializer &serializer) const;
00054 virtual void ReadObjects (
00055 Serializer &serializer,
00056 ObjectLayer *object_layer);
00057 Uint32 WriteObjects (Serializer &serializer) const;
00058
00059 Uint32 Draw (
00060 RenderContext const &render_context,
00061 FloatMatrix2 const &world_to_screen,
00062 Float pixels_in_view_radius,
00063 FloatVector2 const &view_center,
00064 Float view_radius,
00065 TransparentObjectVector *transparent_object_vector);
00066 Uint32 DrawWrapped (
00067 RenderContext const &render_context,
00068 FloatMatrix2 const &world_to_screen,
00069 Float pixels_in_view_radius,
00070 FloatVector2 const &view_center,
00071 Float view_radius,
00072 TransparentObjectVector *transparent_object_vector);
00073
00074
00075 void DrawBounds (
00076 RenderContext const &render_context,
00077 Color const &color);
00078
00079 void DrawTreeBounds (
00080 RenderContext const &render_context,
00081 Color const &color);
00082
00083 protected:
00084
00085
00086 VisibilityQuadTree (VisibilityQuadTree *parent) : QuadTree(parent) { }
00087
00088 private:
00089
00090 void Draw (Object::DrawLoopFunctor const &draw_data);
00091 void DrawWrapped (Object::DrawLoopFunctor draw_data);
00092 };
00093
00094 }
00095
00096 }
00097
00098 #endif // !defined(_XRB_ENGINE2_VISIBILITYQUADTREE_HPP_)