mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-23 12:39:24 -05:00
Solve merge conflict.
This commit is contained in:
@@ -30,7 +30,7 @@ set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/globes/globemesh.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/globes/clipmapglobe.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/globes/clipmappyramid.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/globes/chunklodglobe.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/globes/chunkedlodglobe.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/globes/chunknode.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/globes/chunkindex.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/globes/chunk.h
|
||||
@@ -64,7 +64,7 @@ set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/globes/globemesh.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/globes/clipmapglobe.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/globes/clipmappyramid.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/globes/chunklodglobe.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/globes/chunkedlodglobe.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/globes/chunknode.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/globes/chunkindex.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/globes/chunk.cpp
|
||||
|
||||
@@ -64,7 +64,6 @@ void GlobeBrowsingModule::internalInitialize() {
|
||||
|
||||
fRenderable->registerClass<RenderableGlobe>("RenderableGlobe");
|
||||
fRenderable->registerClass<GlobeMesh>("GlobeMesh");
|
||||
fRenderable->registerClass<DistanceSwitch>("DistanceSwitch");
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
|
||||
#include <modules/globebrowsing/globes/chunk.h>
|
||||
#include <modules/globebrowsing/globes/chunklodglobe.h>
|
||||
#include <modules/globebrowsing/globes/chunkedlodglobe.h>
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
Chunk::Chunk(ChunkLodGlobe* owner, const ChunkIndex& chunkIndex)
|
||||
Chunk::Chunk(ChunkedLodGlobe* owner, const ChunkIndex& chunkIndex)
|
||||
: _owner(owner)
|
||||
, _surfacePatch(chunkIndex)
|
||||
, _index(chunkIndex)
|
||||
@@ -51,7 +51,7 @@ namespace openspace {
|
||||
return _surfacePatch;
|
||||
}
|
||||
|
||||
ChunkLodGlobe* const Chunk::owner() const {
|
||||
ChunkedLodGlobe* const Chunk::owner() const {
|
||||
return _owner;
|
||||
}
|
||||
|
||||
@@ -68,40 +68,49 @@ namespace openspace {
|
||||
_surfacePatch = GeodeticPatch(index);
|
||||
}
|
||||
|
||||
void Chunk::setOwner(ChunkLodGlobe* newOwner) {
|
||||
void Chunk::setOwner(ChunkedLodGlobe* newOwner) {
|
||||
_owner = newOwner;
|
||||
}
|
||||
|
||||
Chunk::Status Chunk::update(const RenderData& data) {
|
||||
Camera* savedCamera = _owner->getSavedCamera();
|
||||
const Camera& camRef = savedCamera != nullptr ? *savedCamera : data.camera;
|
||||
RenderData myRenderData = { camRef, data.position, data.doPerformanceMeasurement };
|
||||
|
||||
//In the current implementation of the horizon culling and the distance to the
|
||||
//camera, the closer the ellipsoid is to a
|
||||
//sphere, the better this will make the splitting. Using the minimum radius to
|
||||
//be safe. This means that if the ellipsoid has high difference between radii,
|
||||
//splitting might accur even though it is not needed.
|
||||
|
||||
|
||||
|
||||
_isVisible = true;
|
||||
|
||||
const Ellipsoid& ellipsoid = _owner->ellipsoid();
|
||||
|
||||
|
||||
|
||||
// Do horizon culling
|
||||
const int maxHeight = 8700; // should be read from gdal dataset or mod file
|
||||
_isVisible = HorizonCuller::isVisible(data, _surfacePatch, ellipsoid, maxHeight);
|
||||
_isVisible = HorizonCuller::isVisible(myRenderData, _surfacePatch, ellipsoid, maxHeight);
|
||||
if (!_isVisible) {
|
||||
return WANT_MERGE;
|
||||
}
|
||||
|
||||
|
||||
// Do frustum culling
|
||||
_isVisible = FrustumCuller::isVisible(data, _surfacePatch, ellipsoid);
|
||||
_isVisible = FrustumCuller::isVisible(myRenderData, _surfacePatch, ellipsoid);
|
||||
if (!_isVisible) {
|
||||
return WANT_MERGE;
|
||||
}
|
||||
|
||||
Vec3 cameraPosition = data.camera.position().dvec3();
|
||||
Vec3 cameraPosition = myRenderData.camera.position().dvec3();
|
||||
Geodetic2 pointOnPatch = _surfacePatch.closestPoint(
|
||||
ellipsoid.cartesianToGeodetic2(cameraPosition));
|
||||
Vec3 globePosition = data.position.dvec3();
|
||||
Vec3 globePosition = myRenderData.position.dvec3();
|
||||
Vec3 patchPosition = globePosition + ellipsoid.geodetic2ToCartesian(pointOnPatch);
|
||||
|
||||
Vec3 cameraToChunk = patchPosition - cameraPosition;
|
||||
Scalar minimumGlobeRadius = ellipsoid.minimumRadius();
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class ChunkLodGlobe;
|
||||
class ChunkedLodGlobe;
|
||||
|
||||
|
||||
class Chunk {
|
||||
@@ -50,22 +50,22 @@ namespace openspace {
|
||||
WANT_SPLIT,
|
||||
};
|
||||
|
||||
Chunk(ChunkLodGlobe* owner, const ChunkIndex& chunkIndex);
|
||||
Chunk(ChunkedLodGlobe* owner, const ChunkIndex& chunkIndex);
|
||||
|
||||
/// Updates chunk internally and returns a desired level
|
||||
Status update(const RenderData& data);
|
||||
|
||||
const GeodeticPatch& surfacePatch() const;
|
||||
ChunkLodGlobe* const owner() const;
|
||||
ChunkedLodGlobe* const owner() const;
|
||||
const ChunkIndex index() const;
|
||||
bool isVisible() const;
|
||||
|
||||
void setIndex(const ChunkIndex& index);
|
||||
void setOwner(ChunkLodGlobe* newOwner);
|
||||
void setOwner(ChunkedLodGlobe* newOwner);
|
||||
|
||||
|
||||
private:
|
||||
ChunkLodGlobe* _owner;
|
||||
ChunkedLodGlobe* _owner;
|
||||
ChunkIndex _index;
|
||||
bool _isVisible;
|
||||
GeodeticPatch _surfacePatch;
|
||||
|
||||
+16
-16
@@ -22,7 +22,7 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/globebrowsing/globes/chunklodglobe.h>
|
||||
#include <modules/globebrowsing/globes/chunkedlodglobe.h>
|
||||
|
||||
#include <modules/globebrowsing/meshes/basicgrid.h>
|
||||
|
||||
@@ -44,14 +44,14 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
const GeodeticPatch ChunkLodGlobe::LEFT_HEMISPHERE = GeodeticPatch(0, -M_PI/2, M_PI/2, M_PI/2);
|
||||
const GeodeticPatch ChunkLodGlobe::RIGHT_HEMISPHERE = GeodeticPatch(0, M_PI/2, M_PI/2, M_PI/2);
|
||||
const GeodeticPatch ChunkedLodGlobe::LEFT_HEMISPHERE = GeodeticPatch(0, -M_PI/2, M_PI/2, M_PI/2);
|
||||
const GeodeticPatch ChunkedLodGlobe::RIGHT_HEMISPHERE = GeodeticPatch(0, M_PI/2, M_PI/2, M_PI/2);
|
||||
|
||||
const ChunkIndex ChunkLodGlobe::LEFT_HEMISPHERE_INDEX = ChunkIndex(0, 0, 1);
|
||||
const ChunkIndex ChunkLodGlobe::RIGHT_HEMISPHERE_INDEX = ChunkIndex(1, 0, 1);
|
||||
const ChunkIndex ChunkedLodGlobe::LEFT_HEMISPHERE_INDEX = ChunkIndex(0, 0, 1);
|
||||
const ChunkIndex ChunkedLodGlobe::RIGHT_HEMISPHERE_INDEX = ChunkIndex(1, 0, 1);
|
||||
|
||||
|
||||
ChunkLodGlobe::ChunkLodGlobe(
|
||||
ChunkedLodGlobe::ChunkedLodGlobe(
|
||||
const Ellipsoid& ellipsoid,
|
||||
std::shared_ptr<TileProviderManager> tileProviderManager)
|
||||
: _ellipsoid(ellipsoid)
|
||||
@@ -59,7 +59,9 @@ namespace openspace {
|
||||
, _rightRoot(new ChunkNode(Chunk(this, RIGHT_HEMISPHERE_INDEX)))
|
||||
, minSplitDepth(2)
|
||||
, maxSplitDepth(22)
|
||||
, _savedCamera(nullptr)
|
||||
{
|
||||
|
||||
auto geometry = std::shared_ptr<BasicGrid>(new BasicGrid(
|
||||
100,
|
||||
100,
|
||||
@@ -70,33 +72,31 @@ namespace openspace {
|
||||
_patchRenderer.reset(new ChunkRenderer(geometry, tileProviderManager));
|
||||
}
|
||||
|
||||
ChunkLodGlobe::~ChunkLodGlobe() {
|
||||
ChunkedLodGlobe::~ChunkedLodGlobe() {
|
||||
|
||||
}
|
||||
|
||||
bool ChunkLodGlobe::initialize() {
|
||||
bool ChunkedLodGlobe::initialize() {
|
||||
return isReady();
|
||||
}
|
||||
|
||||
bool ChunkLodGlobe::deinitialize() {
|
||||
bool ChunkedLodGlobe::deinitialize() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChunkLodGlobe::isReady() const {
|
||||
bool ChunkedLodGlobe::isReady() const {
|
||||
bool ready = true;
|
||||
return ready;
|
||||
}
|
||||
|
||||
ChunkRenderer& ChunkLodGlobe::getPatchRenderer() const{
|
||||
ChunkRenderer& ChunkedLodGlobe::getPatchRenderer() const{
|
||||
return *_patchRenderer;
|
||||
}
|
||||
|
||||
void ChunkLodGlobe::render(const RenderData& data){
|
||||
void ChunkedLodGlobe::render(const RenderData& data){
|
||||
minDistToCamera = INFINITY;
|
||||
ChunkNode::renderedPatches = 0;
|
||||
|
||||
|
||||
|
||||
_leftRoot->render(data);
|
||||
_rightRoot->render(data);
|
||||
|
||||
@@ -110,11 +110,11 @@ namespace openspace {
|
||||
//LDEBUG(ChunkNode::renderedPatches << " / " << ChunkNode::instanceCount << " chunks rendered");
|
||||
}
|
||||
|
||||
void ChunkLodGlobe::update(const UpdateData& data) {
|
||||
void ChunkedLodGlobe::update(const UpdateData& data) {
|
||||
_patchRenderer->update();
|
||||
}
|
||||
|
||||
const Ellipsoid& ChunkLodGlobe::ellipsoid() const
|
||||
const Ellipsoid& ChunkedLodGlobe::ellipsoid() const
|
||||
{
|
||||
return _ellipsoid;
|
||||
}
|
||||
+17
-5
@@ -51,13 +51,13 @@ namespace ghoul {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class ChunkLodGlobe :
|
||||
public Renderable, public std::enable_shared_from_this<ChunkLodGlobe>{
|
||||
class ChunkedLodGlobe :
|
||||
public Renderable, public std::enable_shared_from_this<ChunkedLodGlobe>{
|
||||
public:
|
||||
ChunkLodGlobe(
|
||||
ChunkedLodGlobe(
|
||||
const Ellipsoid& ellipsoid,
|
||||
std::shared_ptr<TileProviderManager> tileProviderManager);
|
||||
~ChunkLodGlobe();
|
||||
virtual ~ChunkedLodGlobe();
|
||||
|
||||
ChunkRenderer& getPatchRenderer() const;
|
||||
|
||||
@@ -76,7 +76,16 @@ namespace openspace {
|
||||
const int minSplitDepth;
|
||||
const int maxSplitDepth;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Camera* getSavedCamera() const { return _savedCamera; }
|
||||
void setSaveCamera(Camera* c) {
|
||||
if (_savedCamera != nullptr) delete _savedCamera;
|
||||
_savedCamera = c;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Covers all negative longitudes
|
||||
std::unique_ptr<ChunkNode> _leftRoot;
|
||||
@@ -94,6 +103,9 @@ namespace openspace {
|
||||
static const ChunkIndex RIGHT_HEMISPHERE_INDEX;
|
||||
|
||||
const Ellipsoid& _ellipsoid;
|
||||
|
||||
Camera* _savedCamera;
|
||||
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <openspace/engine/wrapper/windowwrapper.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
|
||||
#include <modules/globebrowsing/globes/chunklodglobe.h>
|
||||
#include <modules/globebrowsing/globes/chunkedlodglobe.h>
|
||||
#include <modules/globebrowsing/rendering/culling.h>
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
// forward declaration
|
||||
namespace openspace {
|
||||
class ChunkLodGlobe;
|
||||
class ChunkedLodGlobe;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace openspace {
|
||||
class GlobeMesh : public Renderable {
|
||||
public:
|
||||
GlobeMesh();
|
||||
~GlobeMesh();
|
||||
virtual ~GlobeMesh();
|
||||
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include <modules/globebrowsing/globes/globemesh.h>
|
||||
#include <modules/globebrowsing/globes/clipmapglobe.h>
|
||||
#include <modules/globebrowsing/globes/chunklodglobe.h>
|
||||
|
||||
// open space includes
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
@@ -51,9 +50,16 @@ namespace openspace {
|
||||
|
||||
|
||||
RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
|
||||
: DistanceSwitch()
|
||||
, _tileProviderManager(std::shared_ptr<TileProviderManager>(new TileProviderManager))
|
||||
: _tileProviderManager(std::shared_ptr<TileProviderManager>(new TileProviderManager))
|
||||
, _saveOrThrowCamera(properties::BoolProperty("saveOrThrowCamera", "saveOrThrowCamera"))
|
||||
{
|
||||
|
||||
setName("RenderableGlobe");
|
||||
addProperty(_saveOrThrowCamera);
|
||||
|
||||
|
||||
|
||||
|
||||
// Read the radii in to its own dictionary
|
||||
Vec3 radii;
|
||||
dictionary.getValue(keyRadii, radii);
|
||||
@@ -99,17 +105,49 @@ namespace openspace {
|
||||
|
||||
//addSwitchValue(std::shared_ptr<ClipMapGlobe>(
|
||||
// new ClipMapGlobe(_ellipsoid, _tileProviderManager)), 1e8);
|
||||
addSwitchValue(std::shared_ptr<ChunkLodGlobe>(
|
||||
new ChunkLodGlobe(_ellipsoid, _tileProviderManager)), 1e9);
|
||||
addSwitchValue(std::shared_ptr<GlobeMesh>(new GlobeMesh()), 1e10);
|
||||
|
||||
_chunkedLodGlobe = std::shared_ptr<ChunkedLodGlobe>(
|
||||
new ChunkedLodGlobe(_ellipsoid, _tileProviderManager));
|
||||
|
||||
_distanceSwitch.addSwitchValue(_chunkedLodGlobe, 1e9);
|
||||
_distanceSwitch.addSwitchValue(std::shared_ptr<GlobeMesh>(new GlobeMesh()), 1e10);
|
||||
}
|
||||
|
||||
RenderableGlobe::~RenderableGlobe() {
|
||||
|
||||
}
|
||||
|
||||
bool RenderableGlobe::initialize() {
|
||||
return _distanceSwitch.initialize();
|
||||
}
|
||||
|
||||
bool RenderableGlobe::deinitialize() {
|
||||
return _distanceSwitch.deinitialize();
|
||||
}
|
||||
|
||||
bool RenderableGlobe::isReady() const {
|
||||
return _distanceSwitch.isReady();
|
||||
}
|
||||
|
||||
void RenderableGlobe::render(const RenderData& data) {
|
||||
if (_saveOrThrowCamera.value()) {
|
||||
_saveOrThrowCamera.setValue(false);
|
||||
|
||||
if (_chunkedLodGlobe->getSavedCamera() == nullptr) { // save camera
|
||||
LDEBUG("Saving snapshot of camera!");
|
||||
_chunkedLodGlobe->setSaveCamera(new Camera(data.camera));
|
||||
}
|
||||
else { // throw camera
|
||||
LDEBUG("Throwing away saved camera!");
|
||||
_chunkedLodGlobe->setSaveCamera(nullptr);
|
||||
}
|
||||
}
|
||||
_distanceSwitch.render(data);
|
||||
}
|
||||
|
||||
void RenderableGlobe::update(const UpdateData& data) {
|
||||
_time = data.time;
|
||||
DistanceSwitch::update(data);
|
||||
_distanceSwitch.update(data);
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -36,8 +36,9 @@
|
||||
#include <modules/globebrowsing/meshes/trianglesoup.h>
|
||||
#include <modules/globebrowsing/other/distanceswitch.h>
|
||||
#include <modules/globebrowsing/globes/globemesh.h>
|
||||
#include <modules/globebrowsing/geodetics/ellipsoid.h>
|
||||
#include <modules/globebrowsing/globes/chunkedlodglobe.h>
|
||||
|
||||
#include <modules/globebrowsing/geodetics/ellipsoid.h>
|
||||
#include <modules/globebrowsing/other/tileprovidermanager.h>
|
||||
|
||||
namespace ghoul {
|
||||
@@ -49,13 +50,19 @@ namespace opengl {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class RenderableGlobe : public DistanceSwitch {
|
||||
class RenderableGlobe : public Renderable {
|
||||
public:
|
||||
RenderableGlobe(const ghoul::Dictionary& dictionary);
|
||||
~RenderableGlobe();
|
||||
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
bool isReady() const override;
|
||||
|
||||
void render(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
double _time;
|
||||
@@ -65,7 +72,13 @@ private:
|
||||
//std::vector<std::string> _heightMapKeys;
|
||||
//std::vector<std::string> _colorTextureKeys;
|
||||
|
||||
|
||||
std::shared_ptr<TileProviderManager> _tileProviderManager;
|
||||
std::shared_ptr<ChunkedLodGlobe> _chunkedLodGlobe;
|
||||
|
||||
properties::BoolProperty _saveOrThrowCamera;
|
||||
|
||||
DistanceSwitch _distanceSwitch;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -41,21 +41,21 @@ namespace openspace {
|
||||
Selects a specific Renderable to be used for rendering, based on distance to the
|
||||
camera
|
||||
*/
|
||||
class DistanceSwitch : public Renderable {
|
||||
class DistanceSwitch {
|
||||
public:
|
||||
DistanceSwitch();
|
||||
virtual ~DistanceSwitch();
|
||||
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
bool isReady() const override;
|
||||
bool initialize();
|
||||
bool deinitialize();
|
||||
bool isReady() const;
|
||||
|
||||
/**
|
||||
Picks the first Renderable with the associated maxDistance greater than the
|
||||
current distance to the camera
|
||||
*/
|
||||
void render(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
void render(const RenderData& data);
|
||||
void update(const UpdateData& data);
|
||||
|
||||
/**
|
||||
Adds a new renderable (first argument) which may be rendered only if the distance
|
||||
@@ -67,7 +67,7 @@ private:
|
||||
|
||||
|
||||
std::vector<std::shared_ptr<Renderable>> _renderables;
|
||||
std::vector <double> _maxDistances;
|
||||
std::vector<double> _maxDistances;
|
||||
|
||||
};
|
||||
} // openspace
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace openspace {
|
||||
|
||||
LRUCache<HashKey, std::shared_ptr<Texture>> _tileCache;
|
||||
|
||||
const std::string _filePath;
|
||||
const std::string _filePath;
|
||||
|
||||
static bool hasInitializedGDAL;
|
||||
GDALDataset* _gdalDataSet;
|
||||
|
||||
@@ -38,13 +38,27 @@
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class LonLatPatch;
|
||||
using namespace glm;
|
||||
|
||||
|
||||
|
||||
|
||||
class FrustumCuller {
|
||||
public:
|
||||
|
||||
enum PointTestResult : int {
|
||||
Inside = 0,
|
||||
Above,
|
||||
AboveRight,
|
||||
Right,
|
||||
BelowRight,
|
||||
Below,
|
||||
BelowLeft,
|
||||
Left,
|
||||
AboveLeft
|
||||
};
|
||||
|
||||
|
||||
FrustumCuller();
|
||||
~FrustumCuller();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user