Skip to content

Commit

Permalink
Updates to compile against VSG 1.1.7; remove used code
Browse files Browse the repository at this point in the history
  • Loading branch information
gwaldron committed Aug 2, 2024
1 parent 6c1c9cd commit a22c1bd
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 249 deletions.
2 changes: 0 additions & 2 deletions src/rocky/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const double MERC_MINX = -20037508.34278925;
const double MERC_MINY = -20037508.34278925;
const double MERC_MAXX = 20037508.34278925;
const double MERC_MAXY = 20037508.34278925;
const double MERC_WIDTH = MERC_MAXX - MERC_MINX;
const double MERC_HEIGHT = MERC_MAXY - MERC_MINY;

void
Profile::setup(
Expand Down
7 changes: 7 additions & 0 deletions src/rocky/vsg/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@
#pragma once

#include <rocky/Common.h>
#include <vsg/core/Version.h>

#define ROCKY_VSG_NAMESPACE ROCKY_NAMESPACE

// non-exported classes
#define ROCKY_VSG_INTERNAL

// introduced in VSG 1.1.4
#ifndef VSG_API_VERSION_LESS
#define VSG_API_VERSION_LESS(major, minor, patch) ((VSG_VERSION_MAJOR < major) || ((VSG_VERSION_MAJOR == major) && ((VSG_VERSION_MINOR < minor) || ((VSG_VERSION_MINOR==minor) && VSG_VERSION_PATCH < patch))))
#define VSG_API_VERSION_GREATER_EQUAL(major, minor, patch) ((VSG_VERSION_MAJOR > major) || ((VSG_VERSION_MAJOR == major) && ((VSG_VERSION_MINOR > minor) || ((VSG_VERSION_MINOR==minor) && VSG_VERSION_PATCH >= patch))))
#endif

#if 0
#include <chrono>

Expand Down
9 changes: 9 additions & 0 deletions src/rocky/vsg/FeatureView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,13 @@ FeatureView::dirtyStyles(entt::registry& entities)
line->dirty();
}
}

if (styles.mesh.has_value())
{
if (auto* mesh = entities.try_get<Mesh>(_entity))
{
mesh->style = styles.mesh.value();
mesh->dirty();
}
}
}
9 changes: 7 additions & 2 deletions src/rocky/vsg/SkyNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@
#include <rocky/DateTime.h>
#include <rocky/SRS.h>
#include <vsg/nodes/Group.h>
#include <vsg/core/Version.h>

#if VSG_API_VERSION_GREATER_EQUAL(1,1,3)
#include <vsg/lighting/AmbientLight.h>
#include <vsg/lighting/PointLight.h>
#else
#include <vsg/nodes/Light.h>
#endif

namespace ROCKY_NAMESPACE
{
//class Runtime;

/**
* Node that renders an atmosphere, stars, sun and moon.
* (Note: this only works with a geocentric world SRS.)
Expand Down
20 changes: 0 additions & 20 deletions src/rocky/vsg/TerrainSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,10 @@ TerrainSettings::from_json(const std::string& JSON)
get_to(j, "min_tile_range_factor", minTileRangeFactor);
get_to(j, "max_level", maxLevelOfDetail);
get_to(j, "min_level", minLevelOfDetail);
get_to(j, "tessellation", gpuTessellation);
get_to(j, "tessellation_level", tessellationLevel);
get_to(j, "tessellation_range", tessellationRange);
get_to(j, "min_seconds_before_unload", minSecondsBeforeUnload);
get_to(j, "min_frames_before_unload", minFramesBeforeUnload);
get_to(j, "min_tiles_before_unload", minResidentTilesBeforeUnload);
get_to(j, "cast_shadows", castShadows);
get_to(j, "screen_space_error", screenSpaceError);
get_to(j, "tile_pixel_size", tilePixelSize);
get_to(j, "skirt_ratio", skirtRatio);
get_to(j, "color", color);
get_to(j, "normalize_edges", normalizeEdges);
get_to(j, "morph_terrain", morphTerrain);
get_to(j, "morph_imagery", morphImagery);
get_to(j, "concurrency", concurrency);

return Status_OK;
Expand All @@ -44,20 +34,10 @@ TerrainSettings::to_json() const
set(j, "min_tile_range_factor", minTileRangeFactor);
set(j, "max_level", maxLevelOfDetail);
set(j, "min_level", minLevelOfDetail);
set(j, "tessellation", gpuTessellation);
set(j, "tessellation_level", tessellationLevel);
set(j, "tessellation_range", tessellationRange);
set(j, "min_seconds_before_unload", minSecondsBeforeUnload);
set(j, "min_frames_before_unload", minFramesBeforeUnload);
set(j, "min_tiles_before_unload", minResidentTilesBeforeUnload);
set(j, "cast_shadows", castShadows);
set(j, "screen_space_error", screenSpaceError);
set(j, "tile_pixel_size", tilePixelSize);
set(j, "skirt_ratio", skirtRatio);
set(j, "color", color);
set(j, "normalize_edges", normalizeEdges);
set(j, "morph_terrain", morphTerrain);
set(j, "morph_imagery", morphImagery);
set(j, "concurrency", concurrency);
return j.dump();
}
43 changes: 0 additions & 43 deletions src/rocky/vsg/TerrainSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,34 +41,6 @@ namespace ROCKY_NAMESPACE
//! The level of detail at which the terrain should begin.
optional<unsigned> minLevelOfDetail = 1;

//! Whether the terrain engine will be using GPU tessellation shaders.
optional<bool> gpuTessellation = false;

//! GPU tessellation level
optional<float> tessellationLevel = 2.5f;

//! Maximum range in meters to apply GPU tessellation
optional<float> tessellationRange = 75.0f;

//! Minimum number of frames before unused terrain data is eligible to expire
optional<unsigned> minFramesBeforeUnload = 0;

//! Minimum time (seconds) before unused terrain data is eligible to expire
optional<double> minSecondsBeforeUnload = 0.0;

//! Minimun range (distance from camera) beyond which unused terrain data
//! is eligible to expire
optional<float> minRangeBeforeUnload = 0.0f;

//! Maximum number of terrain tiles to unload/expire each frame.
optional<unsigned> maxTilesToUnloadPerFrame = ~0;

//! Minimum number of terrain tiles to keep in memory before expiring usused data
optional<unsigned> minResidentTilesBeforeUnload = 0;

//! Whether the terrain should cast shadows on itself
optional<bool> castShadows = false;

//! Size of the tile, in pixels, when using rangeMode = PIXEL_SIZE_ON_SCREEN
optional<float> tilePixelSize = 256.0f;

Expand All @@ -80,21 +52,6 @@ namespace ROCKY_NAMESPACE
//! Color of the untextured globe (where no imagery is displayed)
optional<Color> color = Color::White;

//! Whether to generate normal map textures. Default is true
optional<bool> useNormalMaps = true;

//! Whether to average normal vectors on tile boundaries. Doing so reduces the
//! the appearance of seams when using lighting, but requires extra CPU work.
optional<bool> normalizeEdges = false;

//! Whether to morph terrain data between terrain tile LODs.
//! This feature is not available when using screen-space error LOD
optional<bool> morphTerrain = false;

//! Whether to morph imagery between terrain tile LODs.
//! This feature is not available when using screen-space error LOD
optional<bool> morphImagery = false;

//! Target concurrency of terrain data loading operations.
optional<unsigned> concurrency = 4;

Expand Down
17 changes: 1 addition & 16 deletions src/rocky/vsg/engine/GeometryPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,22 +286,7 @@ GeometryPool::createGeometry(const TileKey& tileKey, const Settings& settings, C
neighborNormals = vsg::vec3Array::create(numVerts);
}

#if 0
if (editor.hasEdits())
{
bool tileHasData = editor.createTileMesh(
geom.get(),
tileSize,
skirtRatio,
mode,
progress);

if (geom->empty())
return nullptr;
}

else // default mesh - no constraints
#endif
if (true) // no mesh constraints
{
glm::dvec3 unit;
glm::dvec3 world;
Expand Down
7 changes: 3 additions & 4 deletions src/rocky/vsg/engine/GeometryPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,13 @@ namespace ROCKY_NAMESPACE
GeometryKey, vsg::ref_ptr<SharedGeometry>>;

struct Settings {
uint32_t tileSize;
float skirtRatio;
bool morphing;
uint32_t tileSize = 17u;
float skirtRatio = 0.0f;
bool morphing = false;
};

//! Gets the Geometry associated with a tile key, creating a new one if
//! necessary and storing it in the pool.
//!
vsg::ref_ptr<SharedGeometry> getPooledGeometry(
const TileKey& tileKey,
const Settings& settings,
Expand Down
18 changes: 0 additions & 18 deletions src/rocky/vsg/engine/TerrainTileNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,12 @@ TerrainTileNode::TerrainTileNode(
const TileKey& in_key,
TerrainTileNode* in_parent,
vsg::ref_ptr<vsg::Node> in_geometry,
const glm::fvec2& in_morphConstants,
float in_childrenVisibilityRange,
const SRS& worldSRS,
const TerrainTileDescriptors& in_initialDescriptors,
TerrainTileHost* in_host,
Runtime& runtime)
{
key = in_key;
morphConstants = in_morphConstants;
childrenVisibilityRange = in_childrenVisibilityRange;
renderModel.descriptors = in_initialDescriptors;
_host = in_host;

Expand Down Expand Up @@ -117,24 +113,10 @@ TerrainTileNode::setElevation(shared_ptr<Image> image, const glm::dmat4& matrix)
bool
TerrainTileNode::shouldSubDivide(vsg::State* state) const
{
// can we subdivide at all?
if (childrenVisibilityRange == FLT_MAX)
return false;

#ifdef USE_SSE

auto& vp = state->_commandBuffer->viewDependentState->viewportData->at(0);
auto min_screen_height_ratio = (_host->settings().tilePixelSize + _host->settings().screenSpaceError) / vp[3];
auto d = state->lodDistance(bound);
return (d > 0.0) && (bound.r > (d * min_screen_height_ratio));

#else

// are the children in range?
// Note - this method prefered when using morphing.
return surface->anyChildBoxWithinRange(childrenVisibilityRange, state);

#endif
}

void
Expand Down
7 changes: 0 additions & 7 deletions src/rocky/vsg/engine/TerrainTileNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ namespace ROCKY_NAMESPACE
std::string name;
shared_ptr<Image> image;
glm::dmat4 matrix{ 1 };
//vsg::ref_ptr<vsg::ImageInfo> texture;
};

enum TextureType
Expand Down Expand Up @@ -98,17 +97,13 @@ namespace ROCKY_NAMESPACE
TileKey key;
bool doNotExpire;
Revision revision;
glm::fvec2 morphConstants;
float childrenVisibilityRange;
unsigned numLODs;
TerrainTileRenderModel renderModel;

vsg::ref_ptr<SurfaceNode> surface;
vsg::ref_ptr<vsg::StateGroup> stategroup;

mutable jobs::future<bool> subtilesLoader;
//mutable jobs::future<TerrainTileModel> elevationLoader;
//mutable jobs::future<bool> elevationMerger;
mutable jobs::future<TerrainTileModel> dataLoader;
mutable jobs::future<bool> dataMerger;
mutable std::atomic<uint64_t> lastTraversalFrame;
Expand All @@ -120,8 +115,6 @@ namespace ROCKY_NAMESPACE
const TileKey& key,
TerrainTileNode* parent,
vsg::ref_ptr<vsg::Node> geometry,
const glm::fvec2& morphConstants,
float childrenVisibilityRange,
const SRS& worldSRS,
const TerrainTileDescriptors& initialDescriptors,
TerrainTileHost* in_host,
Expand Down
Loading

0 comments on commit a22c1bd

Please sign in to comment.