Skip to content

Commit

Permalink
Fixed elev_mod problem.
Browse files Browse the repository at this point in the history
  • Loading branch information
jarmonik committed Dec 31, 2023
1 parent 4eb26d2 commit 4d1ee0f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
7 changes: 2 additions & 5 deletions OVP/D3D9Client/Surfmgr2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions Src/Orbiter/elevmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 4d1ee0f

Please sign in to comment.