From 85c3b0c3e5605332d60c0acfb2ec7a43954ea807 Mon Sep 17 00:00:00 2001 From: jarmonik Date: Tue, 26 Dec 2023 00:19:59 +0200 Subject: [PATCH 1/4] Addressing issue #277 --- OVP/D3D9Client/VPlanet.cpp | 7 ++----- Src/Celbody/Moon/Config/Moon.cfg | 2 +- Src/Orbiter/elevmgr.cpp | 3 ++- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/OVP/D3D9Client/VPlanet.cpp b/OVP/D3D9Client/VPlanet.cpp index 330ee7516..0f092afb3 100644 --- a/OVP/D3D9Client/VPlanet.cpp +++ b/OVP/D3D9Client/VPlanet.cpp @@ -377,12 +377,9 @@ vPlanet::vPlanet (OBJHANDLE _hObj, const Scene *scene) : physics_patchres = *(DWORD*)oapiGetObjectParam (_hObj, OBJPRM_PLANET_SURFACEMAXLEVEL); physics_patchres = min (physics_patchres, *(DWORD*)gc->GetConfigParam (CFGPRM_SURFACEMAXLEVEL)); + // Push the graphics resolution higher than the one used for physics + // to enable more accurate bilinear interpolation of the terrain. max_patchres = physics_patchres + 4; - //if (elev_mode == 1) max_patchres = physics_patchres + 4; // Push the graphics resolution higher than the one used for physics - //else max_patchres = physics_patchres; // to enable more accurate bilinear interpolation of the terrain. - // Works well on the Moon, not so well on high-res KSC. - - max_patchres = min(max_patchres, *(DWORD*)gc->GetConfigParam(CFGPRM_SURFACEMAXLEVEL)); tilever = *(int*)oapiGetObjectParam (_hObj, OBJPRM_PLANET_TILEENGINE); if (tilever < 2) { diff --git a/Src/Celbody/Moon/Config/Moon.cfg b/Src/Celbody/Moon/Config/Moon.cfg index ae1ab428a..12d75e1bc 100644 --- a/Src/Celbody/Moon/Config/Moon.cfg +++ b/Src/Celbody/Moon/Config/Moon.cfg @@ -35,7 +35,7 @@ SidRotPeriod = 2360588.15 ; === Visualisation Parameters === TileFormat = 2 LabelFormat = 2 -MaxPatchResolution = 16 ; highest sphere patch level +MaxPatchResolution = 19 ; highest sphere patch level ElevationResolution = 0.5 ; target resolution of elevation data [m] HorizonExcess = 0.015 ; prevent mountain tops beyond sphere horizon from disappearing MaxElevation = 10800 diff --git a/Src/Orbiter/elevmgr.cpp b/Src/Orbiter/elevmgr.cpp index ac0bcb2b5..8647361ec 100644 --- a/Src/Orbiter/elevmgr.cpp +++ b/Src/Orbiter/elevmgr.cpp @@ -11,7 +11,7 @@ using std::max; static int elev_grid = 256; static int elev_stride = elev_grid+3; -static int MAXLVL_LIMIT = 11; +static int MAXLVL_LIMIT = 13; extern Orbiter *g_pOrbiter; extern TimeData td; @@ -43,6 +43,7 @@ ElevationManager::ElevationManager (const CelestialBody *_cbody) elev_res = 1.0; if (cbody->Type() == OBJTP_PLANET) { maxlvl = min ((DWORD)maxlvl, ((Planet*)cbody)->MaxPatchLevel()-7); + maxlvl++; // -7: -4 for level offset of quadtree root, -3 for great-grandfather elevation access mode elev_res = ((Planet*)cbody)->ElevationResolution(); } From 4eb26d274af23be968f5de08b3662b8b70df035c Mon Sep 17 00:00:00 2001 From: jarmonik Date: Sun, 31 Dec 2023 04:47:52 +0200 Subject: [PATCH 2/4] Increased maximum terrain resolution level to 21 --- Src/Celbody/Moon/Config/Moon.cfg | 2 +- Src/Celbody/Vsop87/Earth/Config/Earth.cfg | 2 +- Src/Celbody/Vsop87/Mars/Config/Mars.cfg | 2 +- Src/Orbiter/Config.h | 2 +- Src/Orbiter/Orbiter.rc | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Src/Celbody/Moon/Config/Moon.cfg b/Src/Celbody/Moon/Config/Moon.cfg index 12d75e1bc..cbaa1975c 100644 --- a/Src/Celbody/Moon/Config/Moon.cfg +++ b/Src/Celbody/Moon/Config/Moon.cfg @@ -35,7 +35,7 @@ SidRotPeriod = 2360588.15 ; === Visualisation Parameters === TileFormat = 2 LabelFormat = 2 -MaxPatchResolution = 19 ; highest sphere patch level +MaxPatchResolution = 20 ; highest sphere patch level ElevationResolution = 0.5 ; target resolution of elevation data [m] HorizonExcess = 0.015 ; prevent mountain tops beyond sphere horizon from disappearing MaxElevation = 10800 diff --git a/Src/Celbody/Vsop87/Earth/Config/Earth.cfg b/Src/Celbody/Vsop87/Earth/Config/Earth.cfg index a31b933c1..fdc09e577 100644 --- a/Src/Celbody/Vsop87/Earth/Config/Earth.cfg +++ b/Src/Celbody/Vsop87/Earth/Config/Earth.cfg @@ -59,7 +59,7 @@ CloudMicrotextureAlt = 35e3 300e3 TileFormat = 2 CloudFormat = 2 LabelFormat = 2 -MaxPatchResolution = 19 ; surface texture resolution limit (1-19) +MaxPatchResolution = 21 ; surface texture resolution limit (1-19) MinCloudResolution = 1 ; cloud layer from this resolution MaxCloudResolution = 9 ; highest cloud resolution level ElevationResolution = 0.5 ; target resolution of elevation data [m] diff --git a/Src/Celbody/Vsop87/Mars/Config/Mars.cfg b/Src/Celbody/Vsop87/Mars/Config/Mars.cfg index b04ec7218..04fbbfdca 100644 --- a/Src/Celbody/Vsop87/Mars/Config/Mars.cfg +++ b/Src/Celbody/Vsop87/Mars/Config/Mars.cfg @@ -52,7 +52,7 @@ AtmFogColor = 0.5 0.40 0.3 TileFormat = 2 LabelFormat = 2 AlbedoRGB = 0.52 0.36 0.16 -MaxPatchResolution = 16 ; highest sphere patch level +MaxPatchResolution = 20 ; highest sphere patch level ElevationResolution = 1 HorizonExcess = 0.035 ; prevent mountain tops beyond sphere horizon from disappearing MinElevation = -8300 ; min surface elevation relative to mean radius diff --git a/Src/Orbiter/Config.h b/Src/Orbiter/Config.h index bc1a2f22c..d921deb26 100644 --- a/Src/Orbiter/Config.h +++ b/Src/Orbiter/Config.h @@ -35,7 +35,7 @@ #define PROP_SY8 9 #define SURF_MAX_PATCHLEVEL 14 -#define SURF_MAX_PATCHLEVEL2 19 +#define SURF_MAX_PATCHLEVEL2 21 class Mesh; class PlanetarySystem; diff --git a/Src/Orbiter/Orbiter.rc b/Src/Orbiter/Orbiter.rc index d9efc762c..c5424189f 100644 --- a/Src/Orbiter/Orbiter.rc +++ b/Src/Orbiter/Orbiter.rc @@ -591,7 +591,7 @@ BEGIN EDITTEXT IDC_OPT_VIS_LTLEVEL,132,55,46,14,ES_AUTOHSCROLL CONTROL "Surface elevation, using",IDC_OPT_VIS_ELEV,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,74,92,10 COMBOBOX IDC_OPT_VIS_ELEVMODE,132,73,76,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Max. resolution level (1-19)",IDC_STATIC,12,92,85,8 + LTEXT "Max. resolution level (1-21)",IDC_STATIC,12,92,85,8 EDITTEXT IDC_OPT_VIS_MAXLEVEL,132,90,46,14,ES_AUTOHSCROLL GROUPBOX "General effects",IDC_STATIC,6,117,208,73 CONTROL "Vessel shadows",IDC_OPT_VIS_VSHADOW,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,130,67,10 From 4d1ee0f9f4e56323e045acfd8c963480ebf14e06 Mon Sep 17 00:00:00 2001 From: jarmonik Date: Sun, 31 Dec 2023 05:21:19 +0200 Subject: [PATCH 3/4] Fixed elev_mod problem. --- OVP/D3D9Client/Surfmgr2.cpp | 7 ++----- Src/Orbiter/elevmgr.cpp | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/OVP/D3D9Client/Surfmgr2.cpp b/OVP/D3D9Client/Surfmgr2.cpp index 5056100ac..9042552de 100644 --- a/OVP/D3D9Client/Surfmgr2.cpp +++ b/OVP/D3D9Client/Surfmgr2.cpp @@ -282,9 +282,6 @@ INT16 *SurfTile::ReadElevationFile (const char *name, int lvl, int ilat, int iln if (e) { - // - //for (i = 0; i < ndat; i++) elev[i] = (trunc(float(e[i]) * (ehdr.scale / tgt_res)) + trunc(ehdr.offset / tgt_res)) * tgt_res; - if (ehdr.scale != tgt_res) { // rescale the data double rescale = ehdr.scale / tgt_res; for (i = 0; i < ndat; i++) @@ -371,8 +368,8 @@ INT16 *SurfTile::ReadElevationFile (const char *name, int lvl, int ilat, int iln phdr->scale = 1.0; #endif p += phdr->hdrsize; - rescale = (do_rescale = (phdr->scale != 1.0)) ? phdr->scale : 1.0; - offset = (do_shift = (phdr->offset != 0.0)) ? INT16(phdr->offset) : 0; + rescale = (do_rescale = (phdr->scale != tgt_res)) ? phdr->scale/tgt_res : 1.0; + offset = (do_shift = (phdr->offset != 0.0)) ? INT16(phdr->offset/tgt_res) : 0; switch(phdr->dtype) { case 0: diff --git a/Src/Orbiter/elevmgr.cpp b/Src/Orbiter/elevmgr.cpp index 8647361ec..8608e36c7 100644 --- a/Src/Orbiter/elevmgr.cpp +++ b/Src/Orbiter/elevmgr.cpp @@ -11,7 +11,7 @@ using std::max; static int elev_grid = 256; static int elev_stride = elev_grid+3; -static int MAXLVL_LIMIT = 13; +static int MAXLVL_LIMIT = SURF_MAX_PATCHLEVEL2 - 7; extern Orbiter *g_pOrbiter; extern TimeData td; @@ -43,7 +43,6 @@ ElevationManager::ElevationManager (const CelestialBody *_cbody) elev_res = 1.0; if (cbody->Type() == OBJTP_PLANET) { maxlvl = min ((DWORD)maxlvl, ((Planet*)cbody)->MaxPatchLevel()-7); - maxlvl++; // -7: -4 for level offset of quadtree root, -3 for great-grandfather elevation access mode elev_res = ((Planet*)cbody)->ElevationResolution(); } From 6127042a26faa94e3ae68174795b2f123e9487e9 Mon Sep 17 00:00:00 2001 From: jarmonik Date: Fri, 5 Jan 2024 08:39:03 +0200 Subject: [PATCH 4/4] Included with VC 2017 and lower --- Orbitersdk/include/DrawAPI.h | 4 ++++ Orbitersdk/include/OrbiterAPI.h | 4 ++++ Orbitersdk/include/VesselAPI.h | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/Orbitersdk/include/DrawAPI.h b/Orbitersdk/include/DrawAPI.h index 1f7a303dd..e20d81651 100644 --- a/Orbitersdk/include/DrawAPI.h +++ b/Orbitersdk/include/DrawAPI.h @@ -23,6 +23,10 @@ #include #include +#if defined(_MSC_VER) && (_MSC_VER < 1920 ) // Microsoft Visual Studio Version 2017 and lower +#include +#endif + #ifdef D3D9CLIENT_EXPORTS #include "d3dx9.h" #endif diff --git a/Orbitersdk/include/OrbiterAPI.h b/Orbitersdk/include/OrbiterAPI.h index 8f372c420..6a9722848 100644 --- a/Orbitersdk/include/OrbiterAPI.h +++ b/Orbitersdk/include/OrbiterAPI.h @@ -29,6 +29,10 @@ #include #include +#if defined(_MSC_VER) && (_MSC_VER < 1920 ) // Microsoft Visual Studio Version 2017 and lower +#include +#endif + extern "C" { #include "Lua/lua.h" } diff --git a/Orbitersdk/include/VesselAPI.h b/Orbitersdk/include/VesselAPI.h index b5252582b..549c18590 100644 --- a/Orbitersdk/include/VesselAPI.h +++ b/Orbitersdk/include/VesselAPI.h @@ -18,6 +18,10 @@ #ifndef __VESSELAPI_H #define __VESSELAPI_H +#if defined(_MSC_VER) && (_MSC_VER < 1920 ) // Microsoft Visual Studio Version 2017 and lower +#include +#endif + // reference frame flags #define FRAME_ECL 0 #define FRAME_EQU 1