Skip to content

Commit

Permalink
fix metadata line if height is less than max height
Browse files Browse the repository at this point in the history
  • Loading branch information
flogross89 committed Sep 15, 2024
1 parent e90239d commit 02571d8
Showing 1 changed file with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,30 +311,28 @@ export function renderNavigationDisplay(
let patternValue = 0;

// check the corner cases only for pixels inside the real rendering area
if (this.thread.y < this.constants.maxImageHeight) {
if (this.thread.y < height) {
// find highest elevation in 8x8 patch to simulate the lower resolution of the real system
const patchXStart = pixelX - (pixelX % 8);
const patchXEnd = Math.min(width, patchXStart + 8);
const patchYStart = this.thread.y - (this.thread.y % 8);
const patchYEnd = Math.min(height, patchYStart + 8);

for (let y = patchYStart; y < patchYEnd; ++y) {
for (let x = patchXStart; x < patchXEnd; ++x) {
const currentElevation = elevationGrid[y][x];
if (currentElevation > pixelElevation && currentElevation !== this.constants.invalidElevation) {
pixelElevation = currentElevation;
}
if (this.thread.y < height) {
// find highest elevation in 8x8 patch to simulate the lower resolution of the real system
const patchXStart = pixelX - (pixelX % 8);
const patchXEnd = Math.min(width, patchXStart + 8);
const patchYStart = this.thread.y - (this.thread.y % 8);
const patchYEnd = Math.min(height, patchYStart + 8);

for (let y = patchYStart; y < patchYEnd; ++y) {
for (let x = patchXStart; x < patchXEnd; ++x) {
const currentElevation = elevationGrid[y][x];
if (currentElevation > pixelElevation && currentElevation !== this.constants.invalidElevation) {
pixelElevation = currentElevation;
}
}

patternValue = patternMap[this.thread.y][pixelX];
}

// the pixel is disabled at all or the ROSE mode is active and the areas are clipped
if (patternValue === 0 || this.thread.y >= height) {
return [4, 4, 5, 0][colorChannel];
}
patternValue = patternMap[this.thread.y][pixelX];
}

// the pixel is disabled at all or the areas are clipped. Be sure not to overdraw the metadata line though
if (patternValue === 0 && this.thread.y !== height) {
return [4, 4, 5, 0][colorChannel];
}

if (maxElevation >= referenceAltitude - gearDownAltitudeOffset) {
Expand Down

0 comments on commit 02571d8

Please sign in to comment.