OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
scene.hpp
Go to the documentation of this file.
1 #ifndef GAME_MWWORLD_SCENE_H
2 #define GAME_MWWORLD_SCENE_H
3 
4 #include "ptr.hpp"
5 #include "globals.hpp"
6 
7 #include <set>
8 #include <memory>
9 
10 namespace osg
11 {
12  class Vec3f;
13 }
14 
15 namespace ESM
16 {
17  struct Position;
18 }
19 
20 namespace Files
21 {
22  class Collections;
23 }
24 
25 namespace Loading
26 {
27  class Listener;
28 }
29 
30 namespace MWRender
31 {
32  class SkyManager;
33  class RenderingManager;
34 }
35 
36 namespace MWPhysics
37 {
38  class PhysicsSystem;
39 }
40 
41 namespace MWWorld
42 {
43  class Player;
44  class CellStore;
45  class CellPreloader;
46 
47  class Scene
48  {
49  public:
50 
51  typedef std::set<CellStore *> CellStoreCollection;
52 
53  private:
54 
55  CellStore* mCurrentCell; // the cell the player is in
60  std::auto_ptr<CellPreloader> mPreloader;
66 
70 
71  void insertCell (CellStore &cell, bool rescale, Loading::Listener* loadingListener);
72 
73  // Load and unload cells as necessary to create a cell grid with "X" and "Y" in the center
74  void changeCellGrid (int X, int Y, bool changeEvent = true);
75 
76  void getGridCenter(int& cellX, int& cellY);
77 
78  void preloadCells();
80  void preloadExteriorGrid();
82 
83  void preloadCell(MWWorld::CellStore* cell, bool preloadSurrounding=false);
84 
85  public:
86 
88 
89  ~Scene();
90 
91  void unloadCell (CellStoreCollection::iterator iter);
92 
93  void loadCell (CellStore *cell, Loading::Listener* loadingListener, bool respawn);
94 
95  void playerMoved (const osg::Vec3f& pos);
96 
97  void changePlayerCell (CellStore* newCell, const ESM::Position& position, bool adjustPlayerPos);
98 
100 
101  const CellStoreCollection& getActiveCells () const;
102 
103  bool hasCellChanged() const;
105 
106  void changeToInteriorCell (const std::string& cellName, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent=true);
109 
110  void changeToExteriorCell (const ESM::Position& position, bool adjustPlayerPos, bool changeEvent=true);
113 
114  void changeToVoid();
116 
117  void markCellAsUnchanged();
118 
119  void update (float duration, bool paused);
120 
121  void addObjectToScene (const Ptr& ptr);
123 
124  void removeObjectFromScene (const Ptr& ptr);
126 
127  void updateObjectRotation (const Ptr& ptr, bool inverseRotationOrder);
128  void updateObjectScale(const Ptr& ptr);
129 
130  bool isCellActive(const CellStore &cell);
131 
132  Ptr searchPtrViaActorId (int actorId);
133  };
134 }
135 
136 #endif
const CellStoreCollection & getActiveCells() const
Definition: scene.cpp:493
bool mPreloadDoors
Definition: scene.hpp:68
void preloadCells()
Definition: scene.cpp:645
void markCellAsUnchanged()
Definition: scene.cpp:583
void preloadCell(MWWorld::CellStore *cell, bool preloadSurrounding=false)
Definition: scene.cpp:735
Definition: renderingmanager.hpp:63
std::auto_ptr< CellPreloader > mPreloader
Definition: scene.hpp:60
void addObjectToScene(const Ptr &ptr)
Add an object that already exists in the world model to the scene.
Definition: scene.cpp:599
CellStoreCollection mActiveCells
Definition: scene.hpp:56
void preloadTeleportDoorDestinations()
Definition: scene.cpp:655
bool mCellChanged
Definition: scene.hpp:57
Definition: loadinglistener.hpp:8
Definition: physicssystem.hpp:51
void unloadCell(CellStoreCollection::iterator iter)
Definition: scene.cpp:211
~Scene()
Definition: scene.cpp:484
void getGridCenter(int &cellX, int &cellY)
Definition: scene.cpp:172
Definition: scene.hpp:47
int mHalfGridSize
Definition: scene.hpp:62
void removeObjectFromScene(const Ptr &ptr)
Remove an object from the scene, but not from the world model.
Definition: scene.cpp:613
bool hasCellChanged() const
Has the set of active cells changed, since the last frame?
Definition: scene.cpp:488
void playerMoved(const osg::Vec3f &pos)
Definition: scene.cpp:321
Mutable state of a cell.
Definition: cellstore.hpp:53
bool mPreloadEnabled
Definition: scene.hpp:65
bool mPreloadFastTravel
Definition: scene.hpp:69
void changeCellGrid(int X, int Y, bool changeEvent=true)
Definition: scene.cpp:342
void changeToVoid()
Change into a void.
Definition: scene.cpp:312
float mPreloadTimer
Definition: scene.hpp:61
void changeToInteriorCell(const std::string &cellName, const ESM::Position &position, bool adjustPlayerPos, bool changeEvent=true)
Definition: scene.cpp:498
void insertCell(CellStore &cell, bool rescale, Loading::Listener *loadingListener)
Definition: scene.cpp:588
Scene(MWRender::RenderingManager &rendering, MWPhysics::PhysicsSystem *physics)
Definition: scene.cpp:460
CellStore * mCurrentCell
Definition: scene.hpp:55
void preloadExteriorGrid()
Definition: scene.cpp:700
MWPhysics::PhysicsSystem * mPhysics
Definition: scene.hpp:58
Definition: defs.hpp:38
CellStore * getCurrentCell()
Definition: scene.cpp:578
void update(float duration, bool paused)
Definition: scene.cpp:194
float mCellLoadingThreshold
Definition: scene.hpp:63
void loadCell(CellStore *cell, Loading::Listener *loadingListener, bool respawn)
Definition: scene.cpp:245
void updateObjectScale(const Ptr &ptr)
Definition: scene.cpp:167
bool isCellActive(const CellStore &cell)
Definition: scene.cpp:623
std::set< CellStore * > CellStoreCollection
Definition: scene.hpp:51
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
float mPreloadDistance
Definition: scene.hpp:64
void changeToExteriorCell(const ESM::Position &position, bool adjustPlayerPos, bool changeEvent=true)
Definition: scene.cpp:563
void preloadFastTravelDestinations()
Definition: scene.cpp:786
void updateObjectRotation(const Ptr &ptr, bool inverseRotationOrder)
Definition: scene.cpp:162
MWRender::RenderingManager & mRendering
Definition: scene.hpp:59
Ptr searchPtrViaActorId(int actorId)
Definition: scene.cpp:635
bool mPreloadExteriorGrid
Definition: scene.hpp:67
void changePlayerCell(CellStore *newCell, const ESM::Position &position, bool adjustPlayerPos)
Definition: scene.cpp:428