GCC Code Coverage Report


ernie/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
17 / 17
100.0%
Branches:
-
-%
Functions:
17 / 17
100.0%

scene/schema/planet.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2 /// @file planet.h
3 /// @brief Ernie's planetary prims: terrains on bodies or planes, atmospheres around bodies, star
4 /// fields and ground planes. A body is any Sphere, an ellipsoid when scaled unevenly.
5 #pragma once
6
7 #include "ernie/physics/astronomy.h"
8 #include "ernie/scene/schema/lux.h"
9
10 // clang-format off
11 #define ERNIE_TERRAIN_ATTRIBUTES(X) \
12 X(Path, Body, "ernie:terrain:body", Path(), \
13 "The Sphere whose surface the heights displace, along its geodetic normals; unset, a plane " \
14 "in the terrain's xy plane.", \
15 .group = "Terrain", .dirty = Dirty::Topology) \
16 X(Tensor, Heights, "ernie:terrain:heights", Tensor(), \
17 "float32 (rows, columns) heights in metres, the first row the northern; on a body, " \
18 "(6, n + 1, n + 1) cube faces.", \
19 .group = "Terrain", .ranks = {2, 3}, .dirty = Dirty::Points) \
20 X(std::string, HeightsFile, "ernie:terrain:heights:file", "", \
21 "Heights as a raster (TIFF, PDS3, PNG or JPEG) in place of the array, paged as views need " \
22 "them.", \
23 .group = "Terrain", .asset = true, .dirty = Dirty::Points) \
24 X(double, HeightsUnit, "ernie:terrain:heights:unit", 1.0, \
25 "Metres in a unit of the file's values: 1000 for kilometres.", .group = "Terrain", \
26 .lower = Above(0.0), .dirty = Dirty::Points) \
27 X(double, HeightsReference, "ernie:terrain:heights:reference", 0.0, \
28 "Metres subtracted from the file's values: the radius, for files of radii.", \
29 .group = "Terrain", .finite = true, .dirty = Dirty::Points) \
30 X(double, NoData, "ernie:terrain:noData", 0.0, \
31 "The height marking missing cells; unauthored, every cell is a height.", .group = "Terrain") \
32 X(glm::dvec2, Origin, "ernie:terrain:origin", glm::dvec2(0.0), \
33 "A plane's north-west corner in its x and y, metres.", .group = "Terrain", .finite = true) \
34 X(double, CellSize, "ernie:terrain:cellSize", 1.0, "Metres between a plane's heights.", \
35 .group = "Terrain", .lower = Above(0.0), .finite = true) \
36 X(double, Exaggeration, "ernie:terrain:exaggeration", 1.0, "Scales the heights as drawn.", \
37 ERNIE_NONNEGATIVE("Terrain")) \
38 X(double, FinestCell, "ernie:terrain:finestCell", 1.0, \
39 "Metres: a body's LOD refines below its heights, bilinearly, to quads this size; 0 stops at " \
40 "the heights'.", \
41 .group = "Terrain", .lower = AtLeast(0.0)) \
42 X(std::string, ColorMode, "ernie:terrain:colorMode", "shaded", \
43 "shaded: its material, lit; colormap: a height ramp, unlit; shadedColormap: both; " \
44 "hillshade: a GIS hillshade, grey and unlit.", \
45 .group = "Display", .options = {"shaded", "colormap", "shadedColormap", "hillshade"}) \
46 X(double, HillshadeAzimuth, "ernie:terrain:hillshade:azimuth", 315.0, \
47 "Degrees clockwise from north of the hillshade's light; GIS's 315, from the north-west.", \
48 .group = "Display", .lower = AtLeast(0.0), .upper = AtMost(360.0)) \
49 X(double, HillshadeAltitude, "ernie:terrain:hillshade:altitude", 45.0, \
50 "Degrees above the horizon of the hillshade's light.", .group = "Display", \
51 .lower = AtLeast(0.0), .upper = AtMost(90.0))
52
53 #define ERNIE_ATMOSPHERE_COLUMN(X, Name, usdName, fallback, text) \
54 X(double, Name, usdName, fallback, text, ERNIE_NONNEGATIVE("Atmosphere"))
55
56 #define ERNIE_ATMOSPHERE_ATTRIBUTES(X) \
57 X(Path, Body, "ernie:atmosphere:body", Path(), "The Sphere it surrounds.", \
58 .group = "Atmosphere", .dirty = Dirty::Topology) \
59 X(std::string, Preset, "ernie:atmosphere:preset", "earth", \
60 "Its physical model: Earth's air, ozone and haze, or Mars's carbon dioxide and dust.", \
61 .group = "Atmosphere", .options = {"earth", "mars"}) \
62 ERNIE_ATMOSPHERE_COLUMN(X, Top, "ernie:atmosphere:top", 100000.0, \
63 "Metres above the surface it reaches; Earth's 100 km.") \
64 X(double, GroundAlbedo, "ernie:atmosphere:groundAlbedo", 0.3, \
65 "The ground's reflectance for light scattered in the air.", ERNIE_FRACTION("Atmosphere")) \
66 ERNIE_ATMOSPHERE_COLUMN(X, HazeOpticalDepth, "ernie:atmosphere:hazeOpticalDepth", 0.1, \
67 "Earth: the haze's vertical optical depth at 550 nm.") \
68 ERNIE_ATMOSPHERE_COLUMN(X, OzoneColumn, "ernie:atmosphere:ozoneColumn", 300.0, \
69 "Earth: total column ozone, Dobson units.") \
70 ERNIE_ATMOSPHERE_COLUMN(X, SodiumColumn, "ernie:atmosphere:sodiumColumn", 4e13, \
71 "Earth: mesospheric sodium atoms per square metre, lit 92 km up by a " \
72 "589 nm laser as a guide star.") \
73 ERNIE_ATMOSPHERE_COLUMN(X, DustOpticalDepth, "ernie:atmosphere:dustOpticalDepth", 0.5, \
74 "Mars: the dust's vertical optical depth at 880 nm.") \
75 ERNIE_ATMOSPHERE_COLUMN(X, CloudTop, "ernie:atmosphere:cloudTop", 0.0, \
76 "Metres below which clouds block light grazing the limb, darkening " \
77 "its shadow as in a lunar eclipse; 0 clear.") \
78 X(double, CloudCover, "ernie:atmosphere:cloudCover", 0.5, \
79 "The fraction of the limb the clouds cover.", ERNIE_FRACTION("Atmosphere")) \
80 X(double, PolarizationDegree, "ernie:polarization:degree", 0.75, \
81 "The sky's greatest degree of linear polarization, 90 degrees from the sun.", \
82 .label = "Sky polarization", ERNIE_FRACTION("Atmosphere"))
83
84 #define ERNIE_STAR_FIELD_ATTRIBUTES(X) \
85 X(double, MagnitudeLimit, "ernie:stars:magnitudeLimit", 99.0, \
86 "Stars fainter than this are left out.", .group = "Stars", .finite = true) \
87 X(double, ZeroPoint, "ernie:stars:zeroPoint", kMagnitudeZeroLux, \
88 "Lux of a magnitude 0 star (Allen's Astrophysical Quantities).", .group = "Stars", \
89 .lower = Above(0.0)) \
90 X(Tensor, Magnitude, "ernie:stars:magnitude", Tensor(), \
91 "float32 (stars): apparent visual (Johnson V) magnitudes.", .group = "Stars") \
92 X(Tensor, RightAscension, "ernie:stars:rightAscension", Tensor(), \
93 "float32 (stars), degrees, in the catalogue's frame.", .group = "Stars") \
94 X(Tensor, Declination, "ernie:stars:declination", Tensor(), \
95 "float32 (stars), degrees, in the catalogue's frame.", .group = "Stars") \
96 X(Tensor, Direction, "ernie:stars:direction", Tensor(), \
97 "float32 (stars, 3) unit directions in its own space, in place of right ascension and " \
98 "declination.", \
99 .group = "Stars", .components = 3) \
100 X(Tensor, ColorIndex, "ernie:stars:colorIndex", Tensor(), \
101 "float32 (stars): B-V colour indices, giving each star's temperature.", .group = "Stars") \
102 X(Tensor, Temperature, "ernie:stars:temperature", Tensor(), \
103 "float32 (stars) kelvin, in place of the colour indices; without either, the Sun's 5772 K.", \
104 .group = "Stars")
105
106 #define ERNIE_GROUND_PLANE_ATTRIBUTES(X) \
107 X(bool, Checker, "ernie:checker", false, "Multiplies its material's albedo by checker squares.", \
108 .group = "Ground") \
109 X(double, CheckerSize, "ernie:checker:size", 1.0, "Metres along a square's edge.", \
110 .group = "Ground", .lower = Above(0.0), .finite = true) \
111 X(glm::dvec3, CheckerColor0, "ernie:checker:color0", glm::dvec3(1.0), "Linear RGB.", \
112 .group = "Ground", .lower = AtLeast(0.0), .color = true) \
113 X(glm::dvec3, CheckerColor1, "ernie:checker:color1", glm::dvec3(0.5), "Linear RGB.", \
114 .group = "Ground", .lower = AtLeast(0.0), .color = true)
115 // clang-format on
116
117 namespace ernie {
118
119 10 ERNIE_CONCRETE_SCHEMA(Terrain, Gprim, ERNIE_TERRAIN_ATTRIBUTES,
120 "Heights displacing a body's surface, or a plane.");
121 10 ERNIE_CONCRETE_SCHEMA(Atmosphere, Xformable, ERNIE_ATMOSPHERE_ATTRIBUTES,
122 "The air around a body: its constituents, haze and clouds.");
123 4 ERNIE_CONCRETE_SCHEMA(StarField, NonboundableLightBase, ERNIE_STAR_FIELD_ATTRIBUTES,
124 "The stars, from a catalogue or arrays, at infinity: a light, unbounded.");
125 4 ERNIE_CONCRETE_SCHEMA(GroundPlane, Gprim, ERNIE_GROUND_PLANE_ATTRIBUTES,
126 "An infinite plane in its xy plane, facing +z.");
127
128 } // namespace ernie
129