Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(a380x): TERR on ND for A380X #92

Merged
merged 49 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
2ad9b57
change the naming convention
svengcz Aug 1, 2023
510c6e6
introduce the scanline pattern
svengcz Aug 1, 2023
2a03d7d
introduce the scanline pattern
svengcz Aug 1, 2023
d6c6bd3
make the error message more self-explaining
svengcz Aug 1, 2023
8846e80
rename the transition variable names
svengcz Aug 1, 2023
c09a88e
extend the start point calculation
svengcz Aug 1, 2023
ce16dd0
fix a typo
svengcz Aug 1, 2023
6b38f48
use the rendering function to define the end of the cycle
svengcz Aug 1, 2023
b657bd3
introduce the scanline rendering mode
svengcz Aug 1, 2023
53ac42a
add a flag to request the VD
svengcz Aug 1, 2023
1b65425
move the constant to the global constant file
svengcz Aug 1, 2023
59aff5d
introduce the vertical display renderer
svengcz Aug 1, 2023
da57cc5
define the display configuration for VD
svengcz Aug 2, 2023
b821d0f
rename the configuration variable
svengcz Aug 2, 2023
5139a16
publish the display configuration data
svengcz Aug 2, 2023
83888d0
integrate VD rendering
svengcz Aug 2, 2023
6e86d34
handle different display sizes
svengcz Aug 2, 2023
64b11c0
prepare VD integration to main frame
svengcz Aug 2, 2023
881bd72
render VD and check if a renderer is already done
svengcz Aug 2, 2023
36371af
define the VD offsets
svengcz Aug 2, 2023
3ebb9a2
copy over the VD to the main frame
svengcz Aug 2, 2023
e07e92b
update also VD
svengcz Aug 2, 2023
19358c4
handle the new bitmask
svengcz Aug 2, 2023
889d2f2
validate inputs
svengcz Aug 2, 2023
c298500
start a new cycle if needed
svengcz Aug 2, 2023
0a2b066
check if the profile is created
svengcz Aug 2, 2023
a90403f
fix the bitmask handling
svengcz Aug 2, 2023
d0d7f35
fix a race condition at zero
svengcz Aug 2, 2023
6872941
change the validation logic
svengcz Aug 2, 2023
c2b8735
use the global time to have a consistent rendering
svengcz Aug 2, 2023
674571a
fix the transition border check
svengcz Aug 2, 2023
e9ce35b
adapt the threshold for better debugging
svengcz Aug 2, 2023
270363d
add a function to update the path for the rendering
svengcz Aug 2, 2023
59f4f06
handle ranges of 0 for the zoom mode
svengcz Aug 3, 2023
f19fe3c
reset the renderer if required
svengcz Aug 3, 2023
2e9415d
render also water
svengcz Aug 3, 2023
ba7f6ac
add some developer workaround to generate the VD
svengcz Aug 3, 2023
942ef26
handle different update times for different aircrafts
svengcz Aug 3, 2023
96f8ca1
lint
flogross89 Jul 25, 2024
6e31983
Merge branch 'main' into feature/terronnd_a380
flogross89 Jul 26, 2024
7427fca
post lint fix
flogross89 Jul 26, 2024
7384599
restore changes
flogross89 Jul 26, 2024
6bab834
fix NaN error, adapt VD colors
flogross89 Jul 26, 2024
e90239d
make SimBridge image BG transparent instead of black/grey (to circumv…
flogross89 Sep 14, 2024
02571d8
fix metadata line if height is less than max height
flogross89 Sep 15, 2024
1531b9e
add Sven's scanpattern py tool, update scanlinemode texture
flogross89 Sep 17, 2024
1168d26
fix vertical offset for A380X TERR (due to aircraft not being at the …
flogross89 Sep 17, 2024
3231c40
only cut out ARC shape for A32NX in arc mode
flogross89 Sep 17, 2024
aa565fa
fix a380x vertical offset bug
flogross89 Sep 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,4 @@ lerna-debug.log*

# Secrets
/secrets
tools/output/
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"editor.formatOnSave": true
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"source.fixAll.eslint": "explicit"
},
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
Expand Down
29 changes: 23 additions & 6 deletions apps/server/src/terrain/processing/generic/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,31 @@ export const DefaultTileSize = 300;
// navigation display parameters
export const NavigationDisplayMapStartOffsetY = 128;
export const NavigationDisplayMaxPixelWidth = 768;
export const NavigationDisplayArcModePixelHeight = 492;
export const NavigationDisplayRoseModePixelHeight = 250;
export const NavigationDisplayArcModePixelHeightA32NX = 492;
export const NavigationDisplayRoseModePixelHeightA32NX = 250;
export const NavigationDisplayArcModePixelHeightA380X = 592;
export const NavigationDisplayRoseModePixelHeightA380X = 592;
export const NavigationDisplayMaxPixelHeight = Math.max(
NavigationDisplayArcModePixelHeight,
NavigationDisplayRoseModePixelHeight,
NavigationDisplayArcModePixelHeightA32NX,
NavigationDisplayRoseModePixelHeightA32NX,
NavigationDisplayArcModePixelHeightA380X,
NavigationDisplayRoseModePixelHeightA380X,
);
export const NavigationDisplayCenterOffsetYA32NX = 0;
export const NavigationDisplayArcModeCenterOffsetYA380X = 100;
export const NavigationDisplayRoseModeCenterOffsetYA380X = 342;

// vertical display parameters
export const VerticalDisplayMapStartOffsetY = 800;
export const VerticalDisplayMapStartOffsetX = 150;

// rendering parameters
export const RenderingMapTransitionDeltaTime = 40;
export const RenderingMapTransitionDuration = 1000;
export const RenderingMapUpdateTimeout = 1500;
export const RenderingMapTransitionDurationArcMode = 1500;
export const RenderingMapUpdateTimeoutArcMode = 1000;
export const RenderingMapTransitionDurationScanlineMode = 600;
export const RenderingMapUpdateTimeoutScanlineMode = 500;
export const RenderingMapFrameValidityTimeArcMode =
RenderingMapTransitionDurationArcMode + RenderingMapUpdateTimeoutArcMode;
export const RenderingMapFrameValidityTimeScanlineMode =
RenderingMapTransitionDurationScanlineMode + RenderingMapUpdateTimeoutScanlineMode;
6 changes: 4 additions & 2 deletions apps/server/src/terrain/processing/gpu/elevationmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ export function createLocalElevationMap(
ndHeight: number,
meterPerPixel: number,
arcMode: boolean,
centerOffsetY: number,
): number {
const centerX = ndWidth / 2.0;
const delta = [this.thread.x - centerX, ndHeight - this.thread.y];
const delta = [this.thread.x - centerX, ndHeight - this.thread.y - centerOffsetY];
if (this.thread.x >= ndWidth || this.thread.y >= ndHeight) return this.constants.invalidElevation;

// calculate distance and bearing for the projection
const distancePixels = Math.sqrt(delta[0] ** 2 + delta[1] ** 2);
if (arcMode === true && distancePixels > ndHeight) return this.constants.invalidElevation;
// Cut off ARC shape when in A32NX and arc mode
if (centerOffsetY === 0 && arcMode === true && distancePixels > ndHeight) return this.constants.invalidElevation;

const distance = distancePixels * (meterPerPixel / 2.0);
const angle = rad2deg(Math.acos(delta[1] / distancePixels));
Expand Down
2 changes: 2 additions & 0 deletions apps/server/src/terrain/processing/gpu/patterns/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './arcmode';
export * from './scanlinemode';
9,066 changes: 9,066 additions & 0 deletions apps/server/src/terrain/processing/gpu/patterns/scanlinemode.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function drawDensityPixel(
if (Math.round(patternValue % patternIndex) === 0) {
return color;
}
return [4, 4, 5, 255];
return [4, 4, 5, 0];
}

export function renderNormalMode(
Expand Down Expand Up @@ -163,7 +163,7 @@ export function renderNormalMode(
return drawDensityPixel(patternMapValue, 5, [255, 148, 255, 255]);
}

return [4, 4, 5, 255];
return [4, 4, 5, 0];
}

export function renderPeaksMode(
Expand Down Expand Up @@ -227,7 +227,7 @@ export function renderPeaksMode(
return drawDensityPixel(patternMapValue, 5, [255, 148, 255, 255]);
}

return [4, 4, 5, 255];
return [4, 4, 5, 0];
}

export function renderNavigationDisplay(
Expand Down 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, 255][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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function renderVerticalDisplay(
const colorChannel = this.thread.x % 4;

if (pixelX >= this.constants.elevationProfileEntryCount) {
return [4, 4, 5, 255][colorChannel];
return [0, 0, 0, 0][colorChannel];
}

const elevation = elevationProfile[pixelX];
Expand All @@ -23,17 +23,17 @@ export function renderVerticalDisplay(

// altitude is above the elevation -> draw the background
if (altitude > elevation) {
return [4, 4, 5, 255][colorChannel];
return [0, 0, 0, 0][colorChannel];
}

// elevation is water -> check if we draw the water until 0
if (elevation === this.constants.waterElevation) {
if (altitude <= 0) {
return [0, 255, 255, 255][colorChannel];
}
return [4, 4, 5, 255][colorChannel];
return [0, 0, 0, 0][colorChannel];
}

// draw the obstacle
return [59, 21, 0, 255][colorChannel];
return [160, 83, 34, 255][colorChannel];
}
10 changes: 9 additions & 1 deletion apps/server/src/terrain/processing/maphandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export class MapHandler {
mapOffsetX: 0,
mapWidth: NavigationDisplayMaxPixelWidth,
mapHeight: NavigationDisplayMaxPixelHeight,
centerOffsetY: 0,
};
const startupStatus: AircraftStatus = {
adiruDataValid: true,
Expand Down Expand Up @@ -379,7 +380,7 @@ export class MapHandler {
this.extractLocalElevationMap = this.extractLocalElevationMap.setOutput([config.mapWidth, config.mapHeight]);
}

let metresPerPixel = Math.round((config.range * NauticalMilesToMetres) / config.mapHeight);
let metresPerPixel = Math.round((config.range * NauticalMilesToMetres) / (config.mapHeight - config.centerOffsetY));
if (config.arcMode) metresPerPixel *= 2.0;

// create the local elevation map
Expand All @@ -402,6 +403,7 @@ export class MapHandler {
config.mapHeight,
metresPerPixel,
config.arcMode,
config.centerOffsetY,
) as Texture;

// some GPU drivers require the flush call to release internal memory
Expand All @@ -412,6 +414,12 @@ export class MapHandler {

public createElevationProfile(profile: ElevationProfile, profileWidth: number): Texture {
if (this.cachedElevationData.gpuData === null) return null;
if (profile.waypointsLatitudes === undefined || profile.waypointsLongitudes === undefined) return null;
if (
profile.waypointsLatitudes.length === 0 ||
profile.waypointsLatitudes.length !== profile.waypointsLongitudes.length
)
return null;

if (this.extractElevationProfile.output === null || this.extractElevationProfile.output[0] !== profileWidth) {
this.extractElevationProfile = this.extractElevationProfile.setOutput([profileWidth]);
Expand Down
Loading
Loading