OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
viewdata.hpp
Go to the documentation of this file.
1 #ifndef OPENMW_COMPONENTS_TERRAIN_VIEWDATA_H
2 #define OPENMW_COMPONENTS_TERRAIN_VIEWDATA_H
3 
4 #include <vector>
5 #include <deque>
6 
7 #include <osg/Node>
8 
9 #include "world.hpp"
10 
11 namespace Terrain
12 {
13 
14  class QuadTreeNode;
15 
16  class ViewData : public View
17  {
18  public:
19  ViewData();
20  ~ViewData();
21 
22  void add(QuadTreeNode* node, bool visible);
23 
24  void reset(unsigned int frame);
25 
26  void clear();
27 
28  bool contains(QuadTreeNode* node);
29 
30  struct Entry
31  {
32  Entry();
33 
34  bool set(QuadTreeNode* node, bool visible);
35 
37  bool mVisible;
38 
39  unsigned int mLodFlags;
40  osg::ref_ptr<osg::Node> mRenderingNode;
41  };
42 
43  unsigned int getNumEntries() const;
44 
45  Entry& getEntry(unsigned int i);
46 
47  osg::Object* getViewer() const { return mViewer.get(); }
48  void setViewer(osg::Object* viewer) { mViewer = viewer; }
49 
50  unsigned int getFrameLastUsed() const { return mFrameLastUsed; }
51 
53  bool hasChanged() const;
54 
55  bool hasEyePoint() const;
56 
57  void setEyePoint(const osg::Vec3f& eye);
58  const osg::Vec3f& getEyePoint() const;
59 
60  private:
61  std::vector<Entry> mEntries;
62  unsigned int mNumEntries;
63  unsigned int mFrameLastUsed;
64  bool mChanged;
65  osg::ref_ptr<osg::Object> mViewer;
66  osg::Vec3f mEyePoint;
68  };
69 
70  class ViewDataMap : public osg::Referenced
71  {
72  public:
73  ViewData* getViewData(osg::Object* viewer);
74 
76 
77  void clearUnusedViews(unsigned int frame);
78 
79  void clear();
80 
81  void setDefaultViewer(osg::Object* viewer);
82 
84 
85  private:
86  std::list<ViewData> mViewVector;
87 
88  typedef std::map<osg::Object*, ViewData*> Map;
90 
91  std::deque<ViewData*> mUnusedViews;
92 
93  osg::ref_ptr<osg::Object> mDefaultViewer;
94  };
95 
96 }
97 
98 #endif
~ViewData()
Definition: viewdata.cpp:15
bool hasEyePoint() const
Definition: viewdata.cpp:47
osg::Object * getViewer() const
Definition: viewdata.hpp:47
void setEyePoint(const osg::Vec3f &eye)
Definition: viewdata.cpp:52
bool hasChanged() const
Definition: viewdata.cpp:42
osg::Vec3f mEyePoint
Definition: viewdata.hpp:66
QuadTreeNode * mNode
Definition: viewdata.hpp:36
bool mVisible
Definition: viewdata.hpp:37
std::vector< Entry > mEntries
Definition: viewdata.hpp:61
bool set(QuadTreeNode *node, bool visible)
Definition: viewdata.cpp:101
unsigned int mFrameLastUsed
Definition: viewdata.hpp:63
bool mHasEyePoint
Definition: viewdata.hpp:67
osg::ref_ptr< osg::Object > mViewer
Definition: viewdata.hpp:65
void add(QuadTreeNode *node, bool visible)
Definition: viewdata.cpp:20
bool mChanged
Definition: viewdata.hpp:64
Entry()
Definition: viewdata.cpp:93
const osg::Vec3f & getEyePoint() const
Definition: viewdata.cpp:58
Definition: viewdata.hpp:16
osg::ref_ptr< osg::Object > mDefaultViewer
Definition: viewdata.hpp:93
osg::ref_ptr< osg::Node > mRenderingNode
Definition: viewdata.hpp:40
Definition: viewdata.hpp:70
void clearUnusedViews(unsigned int frame)
Definition: viewdata.cpp:144
bool contains(QuadTreeNode *node)
Definition: viewdata.cpp:85
unsigned int mLodFlags
Definition: viewdata.hpp:39
void reset(unsigned int frame)
Reset internal structure so that the next addition to the view will override the previous frame's con...
Definition: viewdata.cpp:63
unsigned int mNumEntries
Definition: viewdata.hpp:62
void setDefaultViewer(osg::Object *viewer)
Definition: viewdata.cpp:168
ViewData * getDefaultView()
Definition: viewdata.cpp:173
Entry & getEntry(unsigned int i)
Definition: viewdata.cpp:37
A View is a collection of rendering objects that are visible from a given camera/intersection. The base View class is part of the interface for usage in conjunction with preload feature.
Definition: world.hpp:39
void clear()
Definition: viewdata.cpp:161
Definition: viewdata.hpp:30
ViewData()
Definition: viewdata.cpp:6
Definition: quadtreenode.hpp:32
ViewData * getViewData(osg::Object *viewer)
Definition: viewdata.cpp:115
std::list< ViewData > mViewVector
Definition: viewdata.hpp:86
void clear()
Definition: viewdata.cpp:76
std::deque< ViewData * > mUnusedViews
Definition: viewdata.hpp:91
ViewData * createOrReuseView()
Definition: viewdata.cpp:129
unsigned int getNumEntries() const
Definition: viewdata.cpp:32
void setViewer(osg::Object *viewer)
Definition: viewdata.hpp:48
std::map< osg::Object *, ViewData * > Map
Definition: viewdata.hpp:88
Map mViews
Definition: viewdata.hpp:89
unsigned int getFrameLastUsed() const
Definition: viewdata.hpp:50