Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Commit

Permalink
Remove obsolete lighting and apply formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
erikogenvik committed Oct 31, 2020
1 parent 3e9e393 commit b67853d
Show file tree
Hide file tree
Showing 58 changed files with 542 additions and 695 deletions.
1 change: 0 additions & 1 deletion src/components/ogre/World.cpp
Expand Up @@ -116,7 +116,6 @@ World::World(Eris::View& view,

mScene->addRenderingTechnique("forest", std::make_unique<ForestRenderingTechnique>(*mEnvironment->getForest()));
mScene->addRenderingTechnique("projectile", std::make_unique<ProjectileRenderingTechnique>(mScene->getSceneManager()));
mTerrainManager->getHandler().setLightning(mEnvironment.get());

//set the background colour to black
mViewport->setBackgroundColour(Ogre::ColourValue(0, 0, 0));
Expand Down
8 changes: 3 additions & 5 deletions src/components/ogre/terrain/GeometryUpdateTask.cpp
Expand Up @@ -38,15 +38,13 @@ GeometryUpdateTask::GeometryUpdateTask(BridgeBoundGeometryPtrVector pages,
TerrainHandler& handler,
std::vector<const Terrain::TerrainShader*> shaders,
HeightMapBufferProvider& heightMapBufferProvider,
HeightMap& heightMap,
const WFMath::Vector<3>& lightDirection) :
HeightMap& heightMap) :
mGeometry(std::move(pages)),
mAreas(std::move(areas)),
mHandler(handler),
mShaders(std::move(shaders)),
mHeightMapBufferProvider(heightMapBufferProvider),
mHeightMap(heightMap),
mLightDirection(lightDirection) {
mHeightMap(heightMap) {

}

Expand All @@ -64,7 +62,7 @@ void GeometryUpdateTask::executeTaskInBackgroundThread(Tasks::TaskExecutionConte
GeometryPtrVector geometries;
geometries.push_back(geometry);

context.executeTask(std::make_unique<TerrainShaderUpdateTask>(geometries, mShaders, mAreas, mHandler.EventLayerUpdated, mHandler.EventTerrainMaterialRecompiled, mLightDirection));
context.executeTask(std::make_unique<TerrainShaderUpdateTask>(geometries, mShaders, mAreas, mHandler.EventLayerUpdated, mHandler.EventTerrainMaterialRecompiled));
}
context.executeTask(std::make_unique<HeightMapUpdateTask>(mHeightMapBufferProvider, mHeightMap, segments));

Expand Down
4 changes: 1 addition & 3 deletions src/components/ogre/terrain/GeometryUpdateTask.h
Expand Up @@ -44,8 +44,7 @@ class GeometryUpdateTask : public Tasks::TemplateNamedTask<GeometryUpdateTask> {
TerrainHandler& handler,
std::vector<const Terrain::TerrainShader*> shaders,
HeightMapBufferProvider& heightMapBufferProvider,
HeightMap& heightMap,
const WFMath::Vector<3>& lightDirection);
HeightMap& heightMap);

~GeometryUpdateTask() override = default;

Expand All @@ -63,7 +62,6 @@ class GeometryUpdateTask : public Tasks::TemplateNamedTask<GeometryUpdateTask> {
HeightMap& mHeightMap;
std::set<TerrainPage*> mPages;
std::set<ITerrainPageBridgePtr> mBridgesToNotify;
const WFMath::Vector<3> mLightDirection;


};
Expand Down
84 changes: 40 additions & 44 deletions src/components/ogre/terrain/HeightMap.h
Expand Up @@ -23,18 +23,15 @@
#include <memory>
#include <unordered_map>

namespace WFMath
{
template<int> class Vector;
namespace WFMath {
template<int>
class Vector;
}

namespace Ember
{
namespace OgreView
{
namespace Ember {
namespace OgreView {

namespace Terrain
{
namespace Terrain {

struct IHeightMapSegment;

Expand All @@ -44,25 +41,24 @@ struct IHeightMapSegment;
* This class is safe for threading, in contrast to the Mercator::Terrain class which primarily provides height map features.
* The whole reason for this class existing is basically Mercator not being thread safe. We want to be able to update the Mercator terrain in a background thread, but at the same time be able to provide real time height checking functionality for other subsystems in Ember which are running in the main thread.
*/
class HeightMap
{
class HeightMap {
public:

/**
* @brief STL map to store sparse array of Segment pointers.
*/
typedef std::unordered_map<int, std::shared_ptr<IHeightMapSegment>> Segmentcolumn;

/**
* @brief STL map to store sparse array of Segment pointer columns.
*/
typedef std::unordered_map<int, Segmentcolumn > Segmentstore;

/**
* @Ctor.
* @param defaultLevel The default level of the terrain, if no valid segment can be found for a requested location.
* @param segmentResolution The resolution of one segment, in world units.
*/
/**
* @brief STL map to store sparse array of Segment pointers.
*/
typedef std::unordered_map<int, std::shared_ptr<IHeightMapSegment>> Segmentcolumn;

/**
* @brief STL map to store sparse array of Segment pointer columns.
*/
typedef std::unordered_map<int, Segmentcolumn> Segmentstore;

/**
* @Ctor.
* @param defaultLevel The default level of the terrain, if no valid segment can be found for a requested location.
* @param segmentResolution The resolution of one segment, in world units.
*/
explicit HeightMap(float defaultLevel, int segmentResolution = 64);

/**
Expand Down Expand Up @@ -96,35 +92,35 @@ class HeightMap
* @param y The y location, in world units.
* @returns The height at the location.
*/
float getHeight(float x, float y) const;
float getHeight(float x, float y) const;

/**
* @brief Gets the height and normal at the location.
* This calculates slopes and provides a precise height. It's therefore more time consuming than getHeight().
/**
* @brief Gets the height and normal at the location.
* This calculates slopes and provides a precise height. It's therefore more time consuming than getHeight().
* @param x The x location, in world units.
* @param y The y location, in world units.
* @param height The height will be stored here.
* @param normal The normal will be stored here.
* @returns True if a segment was found.
*/
bool getHeightAndNormal(float x, float y, float& height, WFMath::Vector<3>& normal) const;
*/
bool getHeightAndNormal(float x, float y, float& height, WFMath::Vector<3>& normal) const;

/**
* @brief Performs a fast copy of the raw height data for the supplied area.
* @param xMin Minimum x coord of the area.
* @param xMax Maximum x coord of the area.
* @param yMin Minimum y coord of the area.
* @param yMax Maximum y coord of the area.
* @param heights A vector into which heigh data will be placed. This should preferably already have a capacity reserved.
*/
void blitHeights(int xMin, int xMax, int yMin, int yMax, std::vector<float>& heights) const;
/**
* @brief Performs a fast copy of the raw height data for the supplied area.
* @param xMin Minimum x coord of the area.
* @param xMax Maximum x coord of the area.
* @param yMin Minimum y coord of the area.
* @param yMax Maximum y coord of the area.
* @param heights A vector into which heigh data will be placed. This should preferably already have a capacity reserved.
*/
void blitHeights(int xMin, int xMax, int yMin, int yMax, std::vector<float>& heights) const;


private:

/**
* @brief A sparse map of height map segments.
*/
/**
* @brief A sparse map of height map segments.
*/
Segmentstore mSegments;

/**
Expand Down
21 changes: 9 additions & 12 deletions src/components/ogre/terrain/HeightMapFlatSegment.h
Expand Up @@ -21,23 +21,20 @@

#include "IHeightMapSegment.h"

namespace Ember
{
namespace OgreView
{
namespace Ember {
namespace OgreView {

namespace Terrain
{
namespace Terrain {

/**
* @author Erik Ogenvik <erik@ogenvik.org>
* @brief Represents one segment (mapped to a Mercator::Segment) in the height map which is completely flat.
* To save space we only need one single height, and don't need to allocate memory for a height map buffer.
*/
class HeightMapFlatSegment : public IHeightMapSegment
{
class HeightMapFlatSegment : public IHeightMapSegment {
public:
explicit HeightMapFlatSegment(float height);

~HeightMapFlatSegment() override;

/**
Expand All @@ -50,14 +47,14 @@ class HeightMapFlatSegment : public IHeightMapSegment
*/
float getHeight(int x, int y) const override;

/**
* @brief Gets the height and normal at the location.
* This calculates slopes and provides a precise height. It's therefore more time consuming than getHeight().
/**
* @brief Gets the height and normal at the location.
* This calculates slopes and provides a precise height. It's therefore more time consuming than getHeight().
* @param x The x location, in world units.
* @param y The y location, in world units.
* @param height The height will be stored here.
* @param normal The normal will be stored here.
*/
*/
void getHeightAndNormal(float x, float y, float& height, WFMath::Vector<3>& normal) const override;


Expand Down
14 changes: 7 additions & 7 deletions src/components/ogre/terrain/IHeightMapSegment.h
Expand Up @@ -21,9 +21,9 @@

#include "Types.h"

namespace WFMath
{
template<int> class Vector;
namespace WFMath {
template<int>
class Vector;
}

namespace Ember {
Expand All @@ -48,14 +48,14 @@ struct IHeightMapSegment {
*/
virtual float getHeight(int x, int y) const = 0;

/**
* @brief Gets the height and normal at the location.
* This calculates slopes and provides a precise height. It's therefore more time consuming than getHeight().
/**
* @brief Gets the height and normal at the location.
* This calculates slopes and provides a precise height. It's therefore more time consuming than getHeight().
* @param x The x location, in world units.
* @param y The y location, in world units.
* @param height The height will be stored here.
* @param normal The normal will be stored here.
*/
*/
virtual void getHeightAndNormal(float x, float y, float& height, WFMath::Vector<3>& normal) const = 0;
};
}
Expand Down
7 changes: 4 additions & 3 deletions src/components/ogre/terrain/ITerrainAdapter.h
Expand Up @@ -39,6 +39,7 @@ struct IPageDataProvider;
namespace Terrain {

class TerrainManager;

struct ITerrainObserver;


Expand All @@ -49,8 +50,7 @@ Thus, if you have a feature which requires some kind of interfacing with the ter
@author Erik Ogenvik
*/
struct ITerrainAdapter
{
struct ITerrainAdapter {

virtual ~ITerrainAdapter() = default;

Expand Down Expand Up @@ -81,6 +81,7 @@ struct ITerrainAdapter
* @return True if terrain exists at the position.
*/
virtual bool getHeightAt(Ogre::Real x, Ogre::Real z, float& height) = 0;

/**
* @brief Sets the main camera used.
*
Expand All @@ -95,7 +96,7 @@ struct ITerrainAdapter
* Call this when the terrain has been set up and you want to show it.
*/
virtual void loadScene() = 0;

/**
* @brief Resets the whole terrain, removing any loaded pages.
*/
Expand Down
16 changes: 6 additions & 10 deletions src/components/ogre/terrain/ITerrainObserver.h
Expand Up @@ -31,27 +31,23 @@ template<typename>
struct TRect;
}

namespace WFMath
{
namespace WFMath {
template<int>
class AxisBox;
}

namespace Ember
{
namespace OgreView
{
namespace Terrain
{
namespace Ember {
namespace OgreView {
namespace Terrain {

/**
* Listener interface for an terrain observer, which is observes a particular terrain area.
* @author Erik Ogenvik
*/
struct ITerrainObserver
{
struct ITerrainObserver {

virtual ~ITerrainObserver() = default;

/**
* @brief Instructs the observer to observe a certain area.
* @param area The area to observe.
Expand Down

0 comments on commit b67853d

Please sign in to comment.