From ddf43ec42f00069ac3d5d190a63df00b2517446d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <3397065-ZehMatt@users.noreply.gitlab.com> Date: Mon, 18 Jul 2022 19:11:37 +0300 Subject: [PATCH] Move structs into separate headers, cleanup includes, cleanup forwarders --- apps/openmw/mwworld/cellpreloader.cpp | 1 + components/CMakeLists.txt | 3 +- components/terrain/heightcull.hpp | 62 +++++++++++++++++++++++++++ components/terrain/quadtreeworld.cpp | 1 + components/terrain/quadtreeworld.hpp | 3 +- components/terrain/terraingrid.cpp | 3 ++ components/terrain/terraingrid.hpp | 12 ++++++ components/terrain/view.hpp | 25 +++++++++++ components/terrain/viewdata.hpp | 2 +- components/terrain/world.cpp | 1 + components/terrain/world.hpp | 62 ++------------------------- 11 files changed, 113 insertions(+), 62 deletions(-) create mode 100644 components/terrain/heightcull.hpp create mode 100644 components/terrain/view.hpp diff --git a/apps/openmw/mwworld/cellpreloader.cpp b/apps/openmw/mwworld/cellpreloader.cpp index cdf1986383..ff7869a393 100644 --- a/apps/openmw/mwworld/cellpreloader.cpp +++ b/apps/openmw/mwworld/cellpreloader.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 8a04f91154..8dcb1ce64f 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -234,7 +234,8 @@ add_component_dir (translation ) add_component_dir (terrain - storage world buffercache defs terraingrid material terraindrawable texturemanager chunkmanager compositemaprenderer quadtreeworld quadtreenode viewdata cellborder + storage world buffercache defs terraingrid material terraindrawable texturemanager chunkmanager compositemaprenderer + quadtreeworld quadtreenode viewdata cellborder view heightcull ) add_component_dir (loadinglistener diff --git a/components/terrain/heightcull.hpp b/components/terrain/heightcull.hpp new file mode 100644 index 0000000000..d7db5fbccb --- /dev/null +++ b/components/terrain/heightcull.hpp @@ -0,0 +1,62 @@ +#ifndef COMPONENTS_TERRAIN_HEIGHTCULL_H +#define COMPONENTS_TERRAIN_HEIGHTCULL_H + +#include +#include + +#include + +#include + +namespace osg +{ + class Node; + class NodeVisitor; +} + +namespace Terrain +{ + class HeightCullCallback : public SceneUtil::NodeCallback + { + public: + void setLowZ(float z) + { + mLowZ = z; + } + float getLowZ() const + { + return mLowZ; + } + + void setHighZ(float highZ) + { + mHighZ = highZ; + } + float getHighZ() const + { + return mHighZ; + } + + void setCullMask(unsigned int mask) + { + mMask = mask; + } + unsigned int getCullMask() const + { + return mMask; + } + + void operator()(osg::Node* node, osg::NodeVisitor* nv) + { + if (mLowZ <= mHighZ) + traverse(node, nv); + } + private: + float mLowZ{ -std::numeric_limits::max() }; + float mHighZ{ std::numeric_limits::max() }; + unsigned int mMask{ ~0u }; + }; + +} + +#endif diff --git a/components/terrain/quadtreeworld.cpp b/components/terrain/quadtreeworld.cpp index 1266e440a3..5f39c4fc28 100644 --- a/components/terrain/quadtreeworld.cpp +++ b/components/terrain/quadtreeworld.cpp @@ -18,6 +18,7 @@ #include "chunkmanager.hpp" #include "compositemaprenderer.hpp" #include "terraindrawable.hpp" +#include "heightcull.hpp" namespace { diff --git a/components/terrain/quadtreeworld.hpp b/components/terrain/quadtreeworld.hpp index 3748f7df98..36b2042326 100644 --- a/components/terrain/quadtreeworld.hpp +++ b/components/terrain/quadtreeworld.hpp @@ -1,7 +1,6 @@ #ifndef COMPONENTS_TERRAIN_QUADTREEWORLD_H #define COMPONENTS_TERRAIN_QUADTREEWORLD_H -#include "world.hpp" #include "terraingrid.hpp" #include @@ -10,6 +9,8 @@ namespace osg { class NodeVisitor; + class Group; + class Stats; } namespace Terrain diff --git a/components/terrain/terraingrid.cpp b/components/terrain/terraingrid.cpp index bbd0508ef1..6467b549f1 100644 --- a/components/terrain/terraingrid.cpp +++ b/components/terrain/terraingrid.cpp @@ -8,7 +8,10 @@ #include #include "chunkmanager.hpp" #include "compositemaprenderer.hpp" +#include "view.hpp" #include "storage.hpp" +#include "heightcull.hpp" + namespace Terrain { diff --git a/components/terrain/terraingrid.hpp b/components/terrain/terraingrid.hpp index 3f44b18b08..f09beb0cdc 100644 --- a/components/terrain/terraingrid.hpp +++ b/components/terrain/terraingrid.hpp @@ -7,8 +7,20 @@ #include "world.hpp" +namespace osg +{ + class Group; + class Stats; +} + +namespace Resource +{ + class ResourceSystem; +} + namespace Terrain { + class Storage; /// @brief Simple terrain implementation that loads cells in a grid, with no LOD. Only requested cells are loaded. class TerrainGrid : public Terrain::World diff --git a/components/terrain/view.hpp b/components/terrain/view.hpp new file mode 100644 index 0000000000..1ce0876603 --- /dev/null +++ b/components/terrain/view.hpp @@ -0,0 +1,25 @@ +#ifndef COMPONENTS_TERRAIN_VIEW_H +#define COMPONENTS_TERRAIN_VIEW_H + +#include +#include +#include + +namespace Terrain +{ + /** + * @brief 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. + */ + class View : public osg::Referenced + { + public: + virtual ~View() {} + + /// Reset internal structure so that the next addition to the view will override the previous frame's contents. + virtual void reset() = 0; + }; + +} + +#endif diff --git a/components/terrain/viewdata.hpp b/components/terrain/viewdata.hpp index d51da011a2..125ee7dfc0 100644 --- a/components/terrain/viewdata.hpp +++ b/components/terrain/viewdata.hpp @@ -6,7 +6,7 @@ #include -#include "world.hpp" +#include "view.hpp" namespace Terrain { diff --git a/components/terrain/world.cpp b/components/terrain/world.cpp index 186687b37d..5798784e83 100644 --- a/components/terrain/world.cpp +++ b/components/terrain/world.cpp @@ -10,6 +10,7 @@ #include "texturemanager.hpp" #include "chunkmanager.hpp" #include "compositemaprenderer.hpp" +#include "heightcull.hpp" namespace Terrain { diff --git a/components/terrain/world.hpp b/components/terrain/world.hpp index b9fa7c0160..85114c32d2 100644 --- a/components/terrain/world.hpp +++ b/components/terrain/world.hpp @@ -5,8 +5,6 @@ #include #include -#include -#include #include #include @@ -19,8 +17,6 @@ namespace osg { class Group; class Stats; - class Node; - class Object; } namespace Resource @@ -40,61 +36,9 @@ namespace Terrain class TextureManager; class ChunkManager; class CompositeMapRenderer; - - class HeightCullCallback : public SceneUtil::NodeCallback - { - public: - void setLowZ(float z) - { - mLowZ = z; - } - float getLowZ() const - { - return mLowZ; - } - - void setHighZ(float highZ) - { - mHighZ = highZ; - } - float getHighZ() const - { - return mHighZ; - } - - void setCullMask(unsigned int mask) - { - mMask = mask; - } - unsigned int getCullMask() const - { - return mMask; - } - - void operator()(osg::Node* node, osg::NodeVisitor* nv) - { - if (mLowZ <= mHighZ) - traverse(node, nv); - } - private: - float mLowZ{-std::numeric_limits::max()}; - float mHighZ{std::numeric_limits::max()}; - unsigned int mMask{~0u}; - }; - - /** - * @brief 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. - */ - class View : public osg::Referenced - { - public: - virtual ~View() {} - - /// Reset internal structure so that the next addition to the view will override the previous frame's contents. - virtual void reset() = 0; - }; - + class View; + class HeightCullCallback; + /** * @brief The basic interface for a terrain world. How the terrain chunks are paged and displayed * is up to the implementation.