From 4b38b33e18d7fbad5d025a64738f08854de8050e Mon Sep 17 00:00:00 2001 From: Emil Axelsson Date: Tue, 18 Apr 2017 09:58:27 +0200 Subject: [PATCH] Clean up code for planet radius and bounding sphere calculation (#289) - Remove some power scaled coordaintes. - Remove spice dependency from sphere geometry. - Remove dead code. --- .../scene/atmosphereearth/atmosphereearth.mod | 12 +-- data/scene/earth/earth.mod | 4 +- data/scene/jupiter/callisto/callisto.mod | 2 +- data/scene/jupiter/europa/europa.mod | 2 +- data/scene/jupiter/ganymede/ganymede.mod | 2 +- data/scene/jupiter/io/io.mod | 2 +- data/scene/jupiter/jupiter/jupiter.mod | 2 +- data/scene/mars/mars.mod | 2 +- data/scene/mercury/mercury.mod | 4 +- data/scene/missions/dawn/ceres/ceres.mod | 2 +- .../newhorizons/jupiter/callisto/callisto.mod | 4 +- .../newhorizons/jupiter/europa/europa.mod | 4 +- .../newhorizons/jupiter/ganymede/ganymede.mod | 4 +- .../missions/newhorizons/jupiter/io/io.mod | 2 +- .../newhorizons/jupiter/jupiter/jupiter.mod | 4 +- .../newhorizons/pluto/charon/charon.mod | 4 +- .../newhorizons/pluto/hydra/hydra.mod | 2 +- .../newhorizons/pluto/kerberos/kerberos.mod | 2 +- .../missions/newhorizons/pluto/nix/nix.mod | 4 +- .../newhorizons/pluto/pluto/pluto.mod | 6 +- .../missions/newhorizons/pluto/styx/styx.mod | 4 +- data/scene/moon/moon.mod | 6 +- data/scene/neptune/neptune.mod | 2 +- data/scene/pluto/pluto.mod | 4 +- data/scene/saturn/dione/dione.mod | 2 +- data/scene/saturn/enceladus/enceladus.mod | 2 +- data/scene/saturn/iapetus/iapetus.mod | 2 +- data/scene/saturn/mimas/mimas.mod | 2 +- data/scene/saturn/rhea/rhea.mod | 2 +- data/scene/saturn/saturn/saturn.mod | 5 +- data/scene/saturn/tethys/tethys.mod | 2 +- data/scene/saturn/titan/titan.mod | 2 +- data/scene/sun/sun.mod | 7 +- data/scene/uranus/uranus.mod | 2 +- data/scene/venus/venus.mod | 2 +- include/openspace/rendering/renderable.h | 7 +- include/openspace/scene/scene.h | 5 -- include/openspace/scene/scenegraphnode.h | 8 +- include/openspace/util/powerscaledsphere.h | 4 +- modules/base/rendering/modelgeometry.cpp | 2 +- modules/base/rendering/renderableplane.cpp | 23 +++-- modules/base/rendering/renderableplane.h | 3 +- .../rendering/renderablesphericalgrid.cpp | 9 +- .../base/rendering/renderablesphericalgrid.h | 1 - .../rendering/renderabledebugplane.cpp | 24 +++--- .../rendering/renderabledebugplane.h | 3 +- .../globebrowsing/globes/renderableglobe.cpp | 2 +- .../globebrowsing/other/distanceswitch.cpp | 4 +- .../rendering/renderablemodelprojection.cpp | 6 +- .../rendering/renderableplaneprojection.cpp | 13 --- .../rendering/renderableplaneprojection.h | 1 - .../rendering/renderableplanetprojection.cpp | 4 +- modules/space/rendering/renderableplanet.cpp | 44 +++++++--- modules/space/rendering/renderablerings.cpp | 2 +- .../space/rendering/simplespheregeometry.cpp | 70 +++++++-------- .../space/rendering/simplespheregeometry.h | 10 +-- src/interaction/interactionmode.cpp | 2 +- src/rendering/renderable.cpp | 8 +- src/rendering/renderengine.cpp | 2 - src/scene/scene.cpp | 13 --- src/scene/scenegraphnode.cpp | 86 ++----------------- src/util/powerscaledsphere.cpp | 48 ++--------- 62 files changed, 178 insertions(+), 342 deletions(-) diff --git a/data/scene/atmosphereearth/atmosphereearth.mod b/data/scene/atmosphereearth/atmosphereearth.mod index f5c98aaf3f..b019c71241 100644 --- a/data/scene/atmosphereearth/atmosphereearth.mod +++ b/data/scene/atmosphereearth/atmosphereearth.mod @@ -30,15 +30,15 @@ return { Source1 = { Name = "Sun", -- All radius in meters - Radius = {696.3, 6} + Radius = 696.3E6 }, - --Source2 = { Name = "Monolith", Radius = {0.01, 6} }, + --Source2 = { Name = "Monolith", Radius = 0.01E6 }, Caster1 = { Name = "Moon", -- All radius in meters - Radius = {1.737, 6} + Radius = 1.737E6 }, - --Caster2 = { Name = "Independency Day Ship", Radius = {0.0, 0.0} } + --Caster2 = { Name = "Independency Day Ship", Radius = 0 } }, Textures = { Type = "simple", @@ -127,7 +127,7 @@ return { Parent = "Earth", Renderable = { Type = "RenderablePlane", - Size = {3.0, 11.0}, + Size = 3.0E11.0, Origin = "Center", Billboard = true, Texture = "textures/marker.png", @@ -145,7 +145,7 @@ return { -- Renderable = { -- Type = "RenderablePlane", -- Billboard = true, - -- Size = { 6.371, 6 }, + -- Size = 6.371E6, -- Texture = "textures/graph.jpg", -- Atmosphere = { -- Type = "Nishita", -- for example, values missing etc etc diff --git a/data/scene/earth/earth.mod b/data/scene/earth/earth.mod index b0350ef340..3e293f6f3d 100644 --- a/data/scene/earth/earth.mod +++ b/data/scene/earth/earth.mod @@ -34,7 +34,7 @@ return { Body = "EARTH", Geometry = { Type = "SimpleSphere", - Radius = { 6.371, 6 }, + Radius = 6.371E6, Segments = 100 }, Textures = { @@ -90,7 +90,7 @@ return { Parent = "Earth", Renderable = { Type = "RenderablePlane", - Size = {3.0, 11.0}, + Size = 3.0E11, Origin = "Center", Billboard = true, Texture = "textures/marker.png", diff --git a/data/scene/jupiter/callisto/callisto.mod b/data/scene/jupiter/callisto/callisto.mod index 74c3360adf..aa6122bd47 100644 --- a/data/scene/jupiter/callisto/callisto.mod +++ b/data/scene/jupiter/callisto/callisto.mod @@ -9,7 +9,7 @@ return { Body = "CALLISTO", Geometry = { Type = "SimpleSphere", - Radius = { 2.631, 6}, + Radius = 2.631E6, Segments = 100 }, Textures = { diff --git a/data/scene/jupiter/europa/europa.mod b/data/scene/jupiter/europa/europa.mod index 54df372720..fea16b4627 100644 --- a/data/scene/jupiter/europa/europa.mod +++ b/data/scene/jupiter/europa/europa.mod @@ -9,7 +9,7 @@ return { Body = "EUROPA", Geometry = { Type = "SimpleSphere", - Radius = { 1.561, 6}, + Radius = 1.561E6, Segments = 100 }, Textures = { diff --git a/data/scene/jupiter/ganymede/ganymede.mod b/data/scene/jupiter/ganymede/ganymede.mod index c2c9fdca08..16aa1c175a 100644 --- a/data/scene/jupiter/ganymede/ganymede.mod +++ b/data/scene/jupiter/ganymede/ganymede.mod @@ -9,7 +9,7 @@ return { Body = "JUPITER BARYCENTER", Geometry = { Type = "SimpleSphere", - Radius = { 2.631, 6}, + Radius = 2.631E6, Segments = 100 }, Textures = { diff --git a/data/scene/jupiter/io/io.mod b/data/scene/jupiter/io/io.mod index 03d28e60d1..98e5e88e7f 100644 --- a/data/scene/jupiter/io/io.mod +++ b/data/scene/jupiter/io/io.mod @@ -9,7 +9,7 @@ return { Body = "IO", Geometry = { Type = "SimpleSphere", - Radius = { 1.8213, 6 }, + Radius = 1.8213E6, Segments = 100 }, Textures = { diff --git a/data/scene/jupiter/jupiter/jupiter.mod b/data/scene/jupiter/jupiter/jupiter.mod index 087eef55c5..f9030b25f1 100644 --- a/data/scene/jupiter/jupiter/jupiter.mod +++ b/data/scene/jupiter/jupiter/jupiter.mod @@ -22,7 +22,7 @@ return { Body = "JUPITER BARYCENTER", Geometry = { Type = "SimpleSphere", - Radius = { 0.71492, 8 }, + Radius = 0.71492E8, Segments = 200 }, Textures = { diff --git a/data/scene/mars/mars.mod b/data/scene/mars/mars.mod index 0388c18eda..301f510e5f 100644 --- a/data/scene/mars/mars.mod +++ b/data/scene/mars/mars.mod @@ -22,7 +22,7 @@ return { Body = "MARS BARYCENTER", Geometry = { Type = "SimpleSphere", - Radius = { 6.390, 6 }, + Radius = 6.390E6, Segments = 100 }, Textures = { diff --git a/data/scene/mercury/mercury.mod b/data/scene/mercury/mercury.mod index 26666120e0..61d5c6ff8b 100644 --- a/data/scene/mercury/mercury.mod +++ b/data/scene/mercury/mercury.mod @@ -1,5 +1,3 @@ -MercuryRadius = 2.4397E6; - return { -- Mercury barycenter module { @@ -24,7 +22,7 @@ return { Body = "MERCURY", Geometry = { Type = "SimpleSphere", - Radius = {MercuryRadius, 1.0}, + Radius = 2.4397E6, Segments = 100 }, Textures = { diff --git a/data/scene/missions/dawn/ceres/ceres.mod b/data/scene/missions/dawn/ceres/ceres.mod index ff9c413a2a..0c29ae852b 100644 --- a/data/scene/missions/dawn/ceres/ceres.mod +++ b/data/scene/missions/dawn/ceres/ceres.mod @@ -10,7 +10,7 @@ return { Body = "CERES", Geometry = { Type = "SimpleSphere", - Radius = { 6.390, 5 }, + Radius = 6.390E5, Segments = 100 }, Textures = { diff --git a/data/scene/missions/newhorizons/jupiter/callisto/callisto.mod b/data/scene/missions/newhorizons/jupiter/callisto/callisto.mod index acf03fd873..8ebe7a4081 100644 --- a/data/scene/missions/newhorizons/jupiter/callisto/callisto.mod +++ b/data/scene/missions/newhorizons/jupiter/callisto/callisto.mod @@ -9,7 +9,7 @@ return { Body = "CALLISTO", Geometry = { Type = "SimpleSphere", - Radius = { 1.8213, 6 }, + Radius = 1.8213E6, Segments = 100 }, Textures = { @@ -58,7 +58,7 @@ return { Parent = "Callisto", Renderable = { Type = "RenderablePlane", - Size = {1.0, 7.4}, + Size = 1.0E7.4, Origin = "Center", Billboard = true, Texture = "textures/Callisto-Text.png", diff --git a/data/scene/missions/newhorizons/jupiter/europa/europa.mod b/data/scene/missions/newhorizons/jupiter/europa/europa.mod index 1bec7e5c9b..5f806496e9 100644 --- a/data/scene/missions/newhorizons/jupiter/europa/europa.mod +++ b/data/scene/missions/newhorizons/jupiter/europa/europa.mod @@ -9,7 +9,7 @@ return { Body = "EUROPA", Geometry = { Type = "SimpleSphere", - Radius = { 1.8213, 6 }, + Radius = 1.8213E6, Segments = 100 }, Textures = { @@ -58,7 +58,7 @@ return { Parent = "Europa", Renderable = { Type = "RenderablePlane", - Size = {1.0, 7.4}, + Size = 1.0E7.4, Origin = "Center", Billboard = true, Texture = "textures/Europa-Text.png", diff --git a/data/scene/missions/newhorizons/jupiter/ganymede/ganymede.mod b/data/scene/missions/newhorizons/jupiter/ganymede/ganymede.mod index 401babcca6..a7881254eb 100644 --- a/data/scene/missions/newhorizons/jupiter/ganymede/ganymede.mod +++ b/data/scene/missions/newhorizons/jupiter/ganymede/ganymede.mod @@ -9,7 +9,7 @@ return { Body = "GANYMEDE", Geometry = { Type = "SimpleSphere", - Radius = { 1.8213, 6 }, + Radius = 1.8213E6, Segments = 100 }, Textures = { @@ -58,7 +58,7 @@ return { Parent = "Ganymede", Renderable = { Type = "RenderablePlane", - Size = {1.0, 7.4}, + Size = 1.0E7.4, Origin = "Center", Billboard = true, Texture = "textures/Ganymede-Text.png", diff --git a/data/scene/missions/newhorizons/jupiter/io/io.mod b/data/scene/missions/newhorizons/jupiter/io/io.mod index c41b45f29b..d4e5260cbd 100644 --- a/data/scene/missions/newhorizons/jupiter/io/io.mod +++ b/data/scene/missions/newhorizons/jupiter/io/io.mod @@ -9,7 +9,7 @@ return { Body = "IO", Geometry = { Type = "SimpleSphere", - Radius = { 1.8213, 6 }, + Radius = 1.8213E6, Segments = 100 }, Textures = { diff --git a/data/scene/missions/newhorizons/jupiter/jupiter/jupiter.mod b/data/scene/missions/newhorizons/jupiter/jupiter/jupiter.mod index 079357b2ad..82762acf21 100644 --- a/data/scene/missions/newhorizons/jupiter/jupiter/jupiter.mod +++ b/data/scene/missions/newhorizons/jupiter/jupiter/jupiter.mod @@ -22,7 +22,7 @@ return { Body = "JUPITER", Geometry = { Type = "SimpleSphere", - Radius = { 0.71492, 8 }, + Radius = 0.71492E8, Segments = 200, }, Textures = { @@ -101,7 +101,7 @@ return { Parent = "JupiterProjection", Renderable = { Type = "RenderablePlane", - Size = {1.0, 7.5}, + Size = 1.0E7.5, Origin = "Center", Billboard = true, Texture = "textures/Jupiter-text.png", diff --git a/data/scene/missions/newhorizons/pluto/charon/charon.mod b/data/scene/missions/newhorizons/pluto/charon/charon.mod index 4cfff1d131..2d50c40e44 100644 --- a/data/scene/missions/newhorizons/pluto/charon/charon.mod +++ b/data/scene/missions/newhorizons/pluto/charon/charon.mod @@ -24,7 +24,7 @@ return { Type = "RenderablePlanetProjection", Geometry = { Type = "SimpleSphere", - Radius = { 6.035 , 5 }, + Radius = 6.035E5, Segments = 100 }, Textures = { @@ -72,7 +72,7 @@ return { Parent = "Charon", Renderable = { Type = "RenderablePlane", - Size = {1.0, 6.3}, + Size = 1.0E6.3, Origin = "Center", Billboard = true, Texture = "textures/Charon-Text.png", diff --git a/data/scene/missions/newhorizons/pluto/hydra/hydra.mod b/data/scene/missions/newhorizons/pluto/hydra/hydra.mod index 8dcf6d2d0f..09950fc602 100644 --- a/data/scene/missions/newhorizons/pluto/hydra/hydra.mod +++ b/data/scene/missions/newhorizons/pluto/hydra/hydra.mod @@ -46,7 +46,7 @@ return { Parent = "Hydra", Renderable = { Type = "RenderablePlane", - Size = {1.0, 6.3}, + Size = 1.0E6.3, Origin = "Center", Billboard = true, Texture = "textures/Hydra-Text.png" diff --git a/data/scene/missions/newhorizons/pluto/kerberos/kerberos.mod b/data/scene/missions/newhorizons/pluto/kerberos/kerberos.mod index 595baf13e8..e415ce3cbd 100644 --- a/data/scene/missions/newhorizons/pluto/kerberos/kerberos.mod +++ b/data/scene/missions/newhorizons/pluto/kerberos/kerberos.mod @@ -46,7 +46,7 @@ return { Parent = "Kerberos", Renderable = { Type = "RenderablePlane", - Size = {1.0, 6.3}, + Size = 1.0E6.3, Origin = "Center", Billboard = true, Texture = "textures/Kerberos-Text.png" diff --git a/data/scene/missions/newhorizons/pluto/nix/nix.mod b/data/scene/missions/newhorizons/pluto/nix/nix.mod index da05401b4e..1ef3484e3b 100644 --- a/data/scene/missions/newhorizons/pluto/nix/nix.mod +++ b/data/scene/missions/newhorizons/pluto/nix/nix.mod @@ -19,7 +19,7 @@ return { Body = "NIX", Geometry = { Type = "SimpleSphere", - Radius = { 0.45 , 5 }, + Radius = 0.45E5, Segments = 100 }, Textures = { @@ -46,7 +46,7 @@ return { Parent = "Nix", Renderable = { Type = "RenderablePlane", - Size = {1.0, 6.3}, + Size = 1.0E6.3, Origin = "Center", Billboard = true, Texture = "textures/Nix-Text.png" diff --git a/data/scene/missions/newhorizons/pluto/pluto/pluto.mod b/data/scene/missions/newhorizons/pluto/pluto/pluto.mod index 53118f9e84..53f1773f3e 100644 --- a/data/scene/missions/newhorizons/pluto/pluto/pluto.mod +++ b/data/scene/missions/newhorizons/pluto/pluto/pluto.mod @@ -38,7 +38,7 @@ return { Type = "RenderablePlanetProjection", Geometry = { Type = "SimpleSphere", - Radius = { 1.173 , 6 }, + Radius = 1.173E6, Segments = 100 }, Textures = { @@ -173,7 +173,7 @@ return { Renderable = { Type = "RenderablePlane", Billboard = true, - Size = { 5, 4 }, + Size = 5E4, Texture = "textures/barycenter.png", Atmosphere = { Type = "Nishita", -- for example, values missing etc etc @@ -187,7 +187,7 @@ return { Parent = "Pluto", Renderable = { Type = "RenderablePlane", - Size = {1.0, 6.3}, + Size = 1.0E6.3, Origin = "Center", Billboard = true, Texture = "textures/Pluto-Text.png", diff --git a/data/scene/missions/newhorizons/pluto/styx/styx.mod b/data/scene/missions/newhorizons/pluto/styx/styx.mod index 559062be97..ab914cddb9 100644 --- a/data/scene/missions/newhorizons/pluto/styx/styx.mod +++ b/data/scene/missions/newhorizons/pluto/styx/styx.mod @@ -19,7 +19,7 @@ return { Body = "STYX", Geometry = { Type = "SimpleSphere", - Radius = { 0.75 , 4 }, + Radius = 0.75E4, Segments = 100 }, Textures = { @@ -46,7 +46,7 @@ return { Parent = "Styx", Renderable = { Type = "RenderablePlane", - Size = {1.0, 6.3}, + Size = 1.0E6.3, Origin = "Center", Billboard = true, Texture = "textures/Styx-Text.png", diff --git a/data/scene/moon/moon.mod b/data/scene/moon/moon.mod index b58b056dcb..534adf617c 100644 --- a/data/scene/moon/moon.mod +++ b/data/scene/moon/moon.mod @@ -9,17 +9,17 @@ return { Body = "MOON", Geometry = { Type = "SimpleSphere", - Radius = { 1.737, 6}, + Radius = 1.737E6, Segments = 100 }, Shadow_Group = { Source1 = { Name = "Sun", - Radius = {696.3, 6} + Radius = 696.3E6 }, Caster1 = { Name = "Earth", - Radius = {6.371, 6} + Radius = 6.371E6 }, }, Textures = { diff --git a/data/scene/neptune/neptune.mod b/data/scene/neptune/neptune.mod index b02dd189b2..38e698c9ea 100644 --- a/data/scene/neptune/neptune.mod +++ b/data/scene/neptune/neptune.mod @@ -23,7 +23,7 @@ return { Body = "NEPTUNE BARYCENTER", Geometry = { Type = "SimpleSphere", - Radius = { 2.4622 , 7 }, + Radius = 2.4622E7, Segments = 100 }, Textures = { diff --git a/data/scene/pluto/pluto.mod b/data/scene/pluto/pluto.mod index 88346771ef..27f540d731 100644 --- a/data/scene/pluto/pluto.mod +++ b/data/scene/pluto/pluto.mod @@ -25,7 +25,7 @@ return { Body = "PLUTO", Geometry = { Type = "SimpleSphere", - Radius = { 1.173 , 6 }, + Radius = 1.173E6, Segments = 100 }, Textures = { @@ -61,7 +61,7 @@ return { Body = "CHARON", Geometry = { Type = "SimpleSphere", - Radius = { 6.035 , 5 }, + Radius = 6.035E5, Segments = 100 }, Textures = { diff --git a/data/scene/saturn/dione/dione.mod b/data/scene/saturn/dione/dione.mod index d132bea897..477705ea2b 100644 --- a/data/scene/saturn/dione/dione.mod +++ b/data/scene/saturn/dione/dione.mod @@ -8,7 +8,7 @@ return { Body = "DIONE", Geometry = { Type = "SimpleSphere", - Radius = { 0.563, 3 }, + Radius = 0.563E3, Segments = 50 }, Textures = { diff --git a/data/scene/saturn/enceladus/enceladus.mod b/data/scene/saturn/enceladus/enceladus.mod index 1d3011e4c8..f49104d3ca 100644 --- a/data/scene/saturn/enceladus/enceladus.mod +++ b/data/scene/saturn/enceladus/enceladus.mod @@ -8,7 +8,7 @@ return { Body = "ENCELADUS", Geometry = { Type = "SimpleSphere", - Radius = { 0.257, 3 }, + Radius = 0.257E3, Segments = 50 }, Textures = { diff --git a/data/scene/saturn/iapetus/iapetus.mod b/data/scene/saturn/iapetus/iapetus.mod index a390af3ec4..0bcc6b8c38 100644 --- a/data/scene/saturn/iapetus/iapetus.mod +++ b/data/scene/saturn/iapetus/iapetus.mod @@ -8,7 +8,7 @@ return { Body = "IAPETUS", Geometry = { Type = "SimpleSphere", - Radius = { 0.746, 3 }, + Radius = 0.746E3, Segments = 50 }, Textures = { diff --git a/data/scene/saturn/mimas/mimas.mod b/data/scene/saturn/mimas/mimas.mod index bf7b451d83..9f8e5242e6 100644 --- a/data/scene/saturn/mimas/mimas.mod +++ b/data/scene/saturn/mimas/mimas.mod @@ -8,7 +8,7 @@ return { Body = "MIMAS", Geometry = { Type = "SimpleSphere", - Radius = { 0.28, 3 }, + Radius = 0.28E3, Segments = 50 }, Textures = { diff --git a/data/scene/saturn/rhea/rhea.mod b/data/scene/saturn/rhea/rhea.mod index 623dd479a6..8bb6c61393 100644 --- a/data/scene/saturn/rhea/rhea.mod +++ b/data/scene/saturn/rhea/rhea.mod @@ -8,7 +8,7 @@ return { Body = "RHEA", Geometry = { Type = "SimpleSphere", - Radius = { 0.765, 3 }, + Radius = 0.765E3, Segments = 50 }, Textures = { diff --git a/data/scene/saturn/saturn/saturn.mod b/data/scene/saturn/saturn/saturn.mod index fe85224aca..675910faab 100644 --- a/data/scene/saturn/saturn/saturn.mod +++ b/data/scene/saturn/saturn/saturn.mod @@ -1,6 +1,3 @@ -SaturnRadius = 5.8232E7; - - return { -- Saturn barycenter module { @@ -26,7 +23,7 @@ return { Body = "SATURN BARYCENTER", Geometry = { Type = "SimpleSphere", - Radius = {SaturnRadius, 0}, + Radius = 5.8232E7, Segments = 100 }, Textures = { diff --git a/data/scene/saturn/tethys/tethys.mod b/data/scene/saturn/tethys/tethys.mod index eb2a84b3f9..8fe16fa3cd 100644 --- a/data/scene/saturn/tethys/tethys.mod +++ b/data/scene/saturn/tethys/tethys.mod @@ -8,7 +8,7 @@ return { Body = "TETHYS", Geometry = { Type = "SimpleSphere", - Radius = { 0.538, 3 }, + Radius = 0.538E3, Segments = 50 }, Textures = { diff --git a/data/scene/saturn/titan/titan.mod b/data/scene/saturn/titan/titan.mod index 83e366c7ba..12cc0d6034 100644 --- a/data/scene/saturn/titan/titan.mod +++ b/data/scene/saturn/titan/titan.mod @@ -8,7 +8,7 @@ return { Body = "TITAN", Geometry = { Type = "SimpleSphere", - Radius = { 0.2575, 4 }, + Radius = 0.2575E4, Segments = 50 }, Textures = { diff --git a/data/scene/sun/sun.mod b/data/scene/sun/sun.mod index abe0f87cb9..6905d9de89 100644 --- a/data/scene/sun/sun.mod +++ b/data/scene/sun/sun.mod @@ -20,7 +20,8 @@ return { Body = "SUN", Geometry = { Type = "SimpleSphere", - Radius = { 2.783200, 9 }, + --Radius = 2.783200E9, + Radius = 6.957E8, Segments = 100 }, Textures = { @@ -49,7 +50,7 @@ return { Parent = "SolarSystemBarycenter", Renderable = { Type = "RenderablePlane", - Size = {1.3, 10.5}, + Size = 1.3*10^10.5, Origin = "Center", Billboard = true, Texture = "textures/sun-glare.png", @@ -70,7 +71,7 @@ return { Parent = "Sun", Renderable = { Type = "RenderablePlane", - Size = {3.0, 11.0}, + Size = 3.0E11, Origin = "Center", Billboard = true, Texture = "textures/marker.png", diff --git a/data/scene/uranus/uranus.mod b/data/scene/uranus/uranus.mod index 43de1dd2ab..28e4568118 100644 --- a/data/scene/uranus/uranus.mod +++ b/data/scene/uranus/uranus.mod @@ -23,7 +23,7 @@ return { Body = "URANUS BARYCENTER", Geometry = { Type = "SimpleSphere", - Radius = { 2.5362 , 7 }, + Radius = 2.5362E7, Segments = 100 }, Textures = { diff --git a/data/scene/venus/venus.mod b/data/scene/venus/venus.mod index eccce1786f..7badb32f9c 100644 --- a/data/scene/venus/venus.mod +++ b/data/scene/venus/venus.mod @@ -23,7 +23,7 @@ return { Body = "VENUS", Geometry = { Type = "SimpleSphere", - Radius = { 3.760, 6 }, + Radius = 3.760E6, Segments = 100 }, Textures = { diff --git a/include/openspace/rendering/renderable.h b/include/openspace/rendering/renderable.h index c4b1e731c2..b2abbb7710 100644 --- a/include/openspace/rendering/renderable.h +++ b/include/openspace/rendering/renderable.h @@ -28,7 +28,6 @@ #include #include -#include #include #include @@ -72,8 +71,8 @@ public: virtual bool isReady() const = 0; bool isEnabled() const; - void setBoundingSphere(PowerScaledScalar boundingSphere); - PowerScaledScalar getBoundingSphere(); + void setBoundingSphere(float boundingSphere); + float boundingSphere() const; virtual void render(const RenderData& data); virtual void render(const RenderData& data, RendererTasks& rendererTask); @@ -99,7 +98,7 @@ protected: private: RenderBin _renderBin; - PowerScaledScalar boundingSphere_; + float _boundingSphere; std::string _startTime; std::string _endTime; bool _hasTimeInterval; diff --git a/include/openspace/scene/scene.h b/include/openspace/scene/scene.h index 2b45a9c8d8..76f87a3e41 100644 --- a/include/openspace/scene/scene.h +++ b/include/openspace/scene/scene.h @@ -94,11 +94,6 @@ public: */ void update(const UpdateData& data); - /** - * Evaluate if the SceneGraphNodes are visible to the provided camera. - */ - void evaluate(Camera* camera); - /** * Render visible SceneGraphNodes using the provided camera. */ diff --git a/include/openspace/scene/scenegraphnode.h b/include/openspace/scene/scenegraphnode.h index 66ffd8738b..9298e670ae 100644 --- a/include/openspace/scene/scenegraphnode.h +++ b/include/openspace/scene/scenegraphnode.h @@ -74,7 +74,6 @@ public: void traversePreOrder(std::function fn); void traversePostOrder(std::function fn); void update(const UpdateData& data); - void evaluate(const Camera* camera, const psc& parentPosition = psc()); void render(const RenderData& data, RendererTasks& tasks); void updateCamera(Camera* camera) const; @@ -106,8 +105,7 @@ public: SceneGraphNode* parent() const; std::vector children() const; - PowerScaledScalar calculateBoundingSphere(); - PowerScaledScalar boundingSphere() const; + float boundingSphere() const; SceneGraphNode* childNode(const std::string& name); @@ -133,10 +131,6 @@ private: PerformanceRecord _performanceRecord; std::unique_ptr _renderable; - bool _renderableVisible; - - bool _boundingSphereVisible; - PowerScaledScalar _boundingSphere; // Transformation defined by ephemeris, rotation and scale struct { diff --git a/include/openspace/util/powerscaledsphere.h b/include/openspace/util/powerscaledsphere.h index 0e51bb4364..7c18782b8c 100644 --- a/include/openspace/util/powerscaledsphere.h +++ b/include/openspace/util/powerscaledsphere.h @@ -38,8 +38,8 @@ public: // initializers PowerScaledSphere(const PowerScaledScalar& radius, int segments = 8); - PowerScaledSphere(properties::Vec4Property &radius, - int segments, std::string planetName); + + PowerScaledSphere(glm::vec3 radius, int segments); ~PowerScaledSphere(); PowerScaledSphere(const PowerScaledSphere& cpy); diff --git a/modules/base/rendering/modelgeometry.cpp b/modules/base/rendering/modelgeometry.cpp index 82e3ee0074..b89461a54e 100644 --- a/modules/base/rendering/modelgeometry.cpp +++ b/modules/base/rendering/modelgeometry.cpp @@ -144,7 +144,7 @@ bool ModelGeometry::initialize(Renderable* parent) { glm::pow(v.location[1], 2.f) + glm::pow(v.location[2], 2.f), maximumDistanceSquared); } - _parent->setBoundingSphere(PowerScaledScalar(glm::sqrt(maximumDistanceSquared), 0.0)); + _parent->setBoundingSphere(glm::sqrt(maximumDistanceSquared)); if (_vertices.empty()) return false; diff --git a/modules/base/rendering/renderableplane.cpp b/modules/base/rendering/renderableplane.cpp index 965ffd0307..b6b362ed7f 100644 --- a/modules/base/rendering/renderableplane.cpp +++ b/modules/base/rendering/renderableplane.cpp @@ -55,7 +55,7 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary) , _texturePath("texture", "Texture") , _billboard("billboard", "Billboard", false) , _projectionListener("projectionListener", "DisplayProjections", false) - , _size("size", "Size", glm::vec2(1,1), glm::vec2(0.f), glm::vec2(1.f, 25.f)) + , _size("size", "Size", 10, 0, std::pow(10, 25)) , _origin(Origin::Center) , _shader(nullptr) , _textureIsDirty(false) @@ -64,9 +64,7 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary) , _quad(0) , _vertexPositionBuffer(0) { - glm::vec2 size; - dictionary.getValue("Size", size); - _size = size; + dictionary.getValue("Size", _size); if (dictionary.hasKey("Name")) { dictionary.getValue("Name", _nodeName); @@ -127,7 +125,7 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary) //_size.onChange(std::bind(&RenderablePlane::createPlane, this)); _size.onChange([this](){ _planeIsDirty = true; }); - setBoundingSphere(_size.value()); + setBoundingSphere(_size); } RenderablePlane::~RenderablePlane() { @@ -299,16 +297,15 @@ void RenderablePlane::createPlane() { // ============================ // GEOMETRY (quad) // ============================ - const GLfloat size = _size.value()[0]; - const GLfloat w = _size.value()[1]; + const GLfloat size = _size; const GLfloat vertex_data[] = { // x y z w s t - -size, -size, 0.f, w, 0.f, 0.f, - size, size, 0.f, w, 1.f, 1.f, - -size, size, 0.f, w, 0.f, 1.f, - -size, -size, 0.f, w, 0.f, 0.f, - size, -size, 0.f, w, 1.f, 0.f, - size, size, 0.f, w, 1.f, 1.f, + -size, -size, 0.f, 0.f, 0.f, 0.f, + size, size, 0.f, 0.f, 1.f, 1.f, + -size, size, 0.f, 0.f, 0.f, 1.f, + -size, -size, 0.f, 0.f, 0.f, 0.f, + size, -size, 0.f, 0.f, 1.f, 0.f, + size, size, 0.f, 0.f, 1.f, 1.f, }; glBindVertexArray(_quad); // bind array diff --git a/modules/base/rendering/renderableplane.h b/modules/base/rendering/renderableplane.h index 3c26807882..a14e340f9e 100644 --- a/modules/base/rendering/renderableplane.h +++ b/modules/base/rendering/renderableplane.h @@ -29,7 +29,6 @@ #include #include -#include #include namespace ghoul { @@ -75,7 +74,7 @@ private: properties::StringProperty _texturePath; properties::BoolProperty _billboard; properties::BoolProperty _projectionListener; - properties::Vec2Property _size; + properties::FloatProperty _size; Origin _origin; std::string _nodeName; diff --git a/modules/base/rendering/renderablesphericalgrid.cpp b/modules/base/rendering/renderablesphericalgrid.cpp index da602a2c5f..83a7c7c76f 100644 --- a/modules/base/rendering/renderablesphericalgrid.cpp +++ b/modules/base/rendering/renderablesphericalgrid.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #define _USE_MATH_DEFINES #include @@ -39,12 +40,10 @@ namespace { const char* KeyGridSegments = "GridSegments"; const char* KeyGridRadius = "GridRadius"; const char* KeyGridParentsRotation = "ParentsRotation"; + const glm::vec2 GridRadius = { 1.f, 20.f }; } namespace openspace { -// needs to be set from dictionary - REMEMBER -const PowerScaledScalar radius = PowerScaledScalar(1.f, 20.f); - RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _gridProgram(nullptr) @@ -78,7 +77,7 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio int nr = 0; const float fsegments = static_cast(_segments); - const float r = static_cast(radius[0]); + const float r = static_cast(GridRadius[0]); //int nr2 = 0; @@ -117,7 +116,7 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio _varray[nr].location[i] = tmp[i]; _varray[nr].normal[i] = normal[i]; } - _varray[nr].location[3] = static_cast(radius[1]); + _varray[nr].location[3] = static_cast(GridRadius[1]); ++nr; } } diff --git a/modules/base/rendering/renderablesphericalgrid.h b/modules/base/rendering/renderablesphericalgrid.h index 1980018c48..f5290bc1d5 100644 --- a/modules/base/rendering/renderablesphericalgrid.h +++ b/modules/base/rendering/renderablesphericalgrid.h @@ -62,7 +62,6 @@ protected: bool staticGrid; std::string _parentsRotation; glm::dmat3 _parentMatrix; - PowerScaledScalar _radius; GLuint _vaoID = 3; GLuint _vBufferID = 4; diff --git a/modules/debugging/rendering/renderabledebugplane.cpp b/modules/debugging/rendering/renderabledebugplane.cpp index e40dd68cd5..53278c1c42 100644 --- a/modules/debugging/rendering/renderabledebugplane.cpp +++ b/modules/debugging/rendering/renderabledebugplane.cpp @@ -49,15 +49,13 @@ RenderableDebugPlane::RenderableDebugPlane(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _texture("texture", "Texture", -1, -1, 255) , _billboard("billboard", "Billboard", false) - , _size("size", "Size", glm::vec2(1,1), glm::vec2(0.f), glm::vec2(1.f, 25.f)) + , _size("size", "Size", 10, 0, std::pow(10, 25)) , _origin(Origin::Center) , _shader(nullptr) , _quad(0) , _vertexPositionBuffer(0) { - glm::vec2 size; - dictionary.getValue("Size", size); - _size = size; + dictionary.getValue("Size", _size); if (dictionary.hasKey("Name")){ dictionary.getValue("Name", _nodeName); @@ -104,7 +102,7 @@ RenderableDebugPlane::RenderableDebugPlane(const ghoul::Dictionary& dictionary) addProperty(_size); _size.onChange([this](){ _planeIsDirty = true; }); - setBoundingSphere(_size.value()); + setBoundingSphere(_size); } RenderableDebugPlane::~RenderableDebugPlane() { @@ -189,16 +187,16 @@ void RenderableDebugPlane::createPlane() { // ============================ // GEOMETRY (quad) // ============================ - const GLfloat size = _size.value()[0]; - const GLfloat w = _size.value()[1]; + const GLfloat size = _size; + const GLfloat vertex_data[] = { // x y z w s t - -size, -size, 0.f, w, 0.f, 0.f, - size, size, 0.f, w, 1.f, 1.f, - -size, size, 0.f, w, 0.f, 1.f, - -size, -size, 0.f, w, 0.f, 0.f, - size, -size, 0.f, w, 1.f, 0.f, - size, size, 0.f, w, 1.f, 1.f, + -size, -size, 0.f, 0.f, 0.f, 0.f, + size, size, 0.f, 0.f, 1.f, 1.f, + -size, size, 0.f, 0.f, 0.f, 1.f, + -size, -size, 0.f, 0.f, 0.f, 0.f, + size, -size, 0.f, 0.f, 1.f, 0.f, + size, size, 0.f, 0.f, 1.f, 1.f, }; glBindVertexArray(_quad); // bind array diff --git a/modules/debugging/rendering/renderabledebugplane.h b/modules/debugging/rendering/renderabledebugplane.h index 96df652354..b007cef5dd 100644 --- a/modules/debugging/rendering/renderabledebugplane.h +++ b/modules/debugging/rendering/renderabledebugplane.h @@ -28,7 +28,6 @@ #include #include -#include #include namespace ghoul { @@ -67,7 +66,7 @@ private: properties::IntProperty _texture; properties::BoolProperty _billboard; - properties::Vec2Property _size; + properties::FloatProperty _size; Origin _origin; std::string _nodeName; diff --git a/modules/globebrowsing/globes/renderableglobe.cpp b/modules/globebrowsing/globes/renderableglobe.cpp index 3b2038a056..3426c33330 100644 --- a/modules/globebrowsing/globes/renderableglobe.cpp +++ b/modules/globebrowsing/globes/renderableglobe.cpp @@ -78,7 +78,7 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) glm::dvec3 radii; dictionary.getValue(keyRadii, radii); _ellipsoid = Ellipsoid(radii); - setBoundingSphere(pss(_ellipsoid.averageRadius(), 0.0)); + setBoundingSphere(_ellipsoid.averageRadius()); // Ghoul can't read ints from lua dictionaries... double patchSegmentsd; diff --git a/modules/globebrowsing/other/distanceswitch.cpp b/modules/globebrowsing/other/distanceswitch.cpp index 9bb93cfa96..18f4644643 100644 --- a/modules/globebrowsing/other/distanceswitch.cpp +++ b/modules/globebrowsing/other/distanceswitch.cpp @@ -23,7 +23,6 @@ ****************************************************************************************/ #include - #include namespace openspace { @@ -52,8 +51,7 @@ void DistanceSwitch::render(const RenderData& data) { return; } - pss pssDistanceToCamera = (data.camera.position() - data.position).length(); - double distanceToCamera = pssDistanceToCamera.lengthd(); + double distanceToCamera = (data.camera.positionVec3() - data.position.dvec3()).length(); if (distanceToCamera > _maxDistances.back() * _objectScale) { return; diff --git a/modules/newhorizons/rendering/renderablemodelprojection.cpp b/modules/newhorizons/rendering/renderablemodelprojection.cpp index 36f448f5bc..188e9b915d 100644 --- a/modules/newhorizons/rendering/renderablemodelprojection.cpp +++ b/modules/newhorizons/rendering/renderablemodelprojection.cpp @@ -143,7 +143,7 @@ RenderableModelProjection::RenderableModelProjection(const ghoul::Dictionary& di float boundingSphereRadius = 1.0e9; dictionary.getValue(keyBoundingSphereRadius, boundingSphereRadius); - setBoundingSphere(PowerScaledScalar::CreatePSS(boundingSphereRadius)); + setBoundingSphere(boundingSphereRadius); Renderable::addProperty(_performShading); Renderable::addProperty(_rotation); @@ -187,7 +187,7 @@ bool RenderableModelProjection::initialize() { completeSuccess &= loadTextures(); completeSuccess &= _projectionComponent.initializeGL(); - auto bs = getBoundingSphere(); + float bs = boundingSphere(); completeSuccess &= _geometry->initialize(this); setBoundingSphere(bs); // ignore bounding sphere set by geometry. @@ -397,7 +397,7 @@ void RenderableModelProjection::attitudeParameters(double time) { glm::vec3 cpos = position.vec3(); float distance = glm::length(cpos); - float radius = getBoundingSphere().lengthf(); + float radius = boundingSphere(); _projectorMatrix = _projectionComponent.computeProjectorMatrix( cpos, boresight, _up, _instrumentMatrix, diff --git a/modules/newhorizons/rendering/renderableplaneprojection.cpp b/modules/newhorizons/rendering/renderableplaneprojection.cpp index ecf419ce60..e06104368d 100644 --- a/modules/newhorizons/rendering/renderableplaneprojection.cpp +++ b/modules/newhorizons/rendering/renderableplaneprojection.cpp @@ -318,17 +318,4 @@ void RenderablePlaneProjection::setTarget(std::string body) { _target.frame = openspace::SpiceManager::ref().frameFromBody(body); } -std::string RenderablePlaneProjection::findClosestTarget(double currentTime) { - - std::vector targets; - - std::vector nodes = OsEng.renderEngine().scene()->allSceneGraphNodes(); - std::string targetBody; - - PowerScaledScalar min = PowerScaledScalar::CreatePSS(REALLY_FAR); - PowerScaledScalar distance = PowerScaledScalar::CreatePSS(0.0); - - return targetBody; -} - } // namespace openspace diff --git a/modules/newhorizons/rendering/renderableplaneprojection.h b/modules/newhorizons/rendering/renderableplaneprojection.h index 72a5413e5b..d1963b18e6 100644 --- a/modules/newhorizons/rendering/renderableplaneprojection.h +++ b/modules/newhorizons/rendering/renderableplaneprojection.h @@ -68,7 +68,6 @@ public: private: void loadTexture(); void updatePlane(const Image& img, double currentTime); - std::string findClosestTarget(double currentTime); void setTarget(std::string body); std::string _texturePath; diff --git a/modules/newhorizons/rendering/renderableplanetprojection.cpp b/modules/newhorizons/rendering/renderableplanetprojection.cpp index fa495b901c..6e81de5e49 100644 --- a/modules/newhorizons/rendering/renderableplanetprojection.cpp +++ b/modules/newhorizons/rendering/renderableplanetprojection.cpp @@ -177,7 +177,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& glm::vec2 radius = glm::vec2(1.0, 9.0); dictionary.getValue(keyRadius, radius); - setBoundingSphere(pss(radius)); + setBoundingSphere(radius[0] * std::pow(10, radius[1])); addPropertySubOwner(_geometry.get()); addPropertySubOwner(_projectionComponent); @@ -356,7 +356,7 @@ void RenderablePlanetProjection::attitudeParameters(double time) { glm::vec3 cpos = position.vec3(); float distance = glm::length(cpos); - float radius = getBoundingSphere().lengthf(); + float radius = boundingSphere(); _projectorMatrix = _projectionComponent.computeProjectorMatrix( cpos, diff --git a/modules/space/rendering/renderableplanet.cpp b/modules/space/rendering/renderableplanet.cpp index cd77cff9a9..3ff86bc49d 100644 --- a/modules/space/rendering/renderableplanet.cpp +++ b/modules/space/rendering/renderableplanet.cpp @@ -91,19 +91,35 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary) ghoul::Dictionary geometryDictionary; success = dictionary.getValue(keyGeometry, geometryDictionary); - if (success) { - geometryDictionary.setValue(SceneGraphNode::KeyName, name); - _geometry = planetgeometry::PlanetGeometry::createFromDictionary(geometryDictionary); - glm::vec2 planetRadiusVec; - success = geometryDictionary.getValue(keyRadius, planetRadiusVec); - if (success) { - _planetRadius = static_cast( - planetRadiusVec[0] * glm::pow(10, planetRadiusVec[1]) - ); + + glm::dvec3 radius; + bool accutareRadius = false; + try { + SpiceManager::ref().getValue(name, "RADII", radius); + accutareRadius = true; + } catch (const SpiceManager::SpiceException& e) { + accutareRadius = false; + } + + if (accutareRadius) { + radius *= 1000.0; // Spice gives radii in KM. + std::swap(radius[1], radius[2]); // z is equivalent to y in our coordinate system + geometryDictionary.setValue(keyRadius, radius); + } + + if (success) { + //geometryDictionary.setValue(SceneGraphNode::KeyName, name); + _geometry = planetgeometry::PlanetGeometry::createFromDictionary(geometryDictionary); + + float planetRadius; + if (accutareRadius) { + _planetRadius = (radius[0] + radius[1] + radius[2]) / 3.0; + } else if (geometryDictionary.getValue(keyRadius, planetRadius)) { + _planetRadius = planetRadius; } else { - LWARNING("No Radius value expecified for " << name << " planet."); + LWARNING("No Radius value specified for " << name << " planet."); } } @@ -168,13 +184,13 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary) ss << keyShadowSource << sourceCounter << ".Name"; success = shadowDictionary.getValue(ss.str(), sourceName); if (success) { - glm::vec2 sourceRadius; + float sourceRadius; ss.str(std::string()); ss << keyShadowSource << sourceCounter << ".Radius"; success = shadowDictionary.getValue(ss.str(), sourceRadius); if (success) { sourceArray.push_back(std::pair< std::string, float>( - sourceName, sourceRadius[0] * pow(10.f, sourceRadius[1]))); + sourceName, sourceRadius)); } else { LWARNING("No Radius value expecified for Shadow Source Name " @@ -197,13 +213,13 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary) ss << keyShadowCaster << casterCounter << ".Name"; success = shadowDictionary.getValue(ss.str(), casterName); if (success) { - glm::vec2 casterRadius; + float casterRadius; ss.str(std::string()); ss << keyShadowCaster << casterCounter << ".Radius"; success = shadowDictionary.getValue(ss.str(), casterRadius); if (success) { casterArray.push_back(std::pair< std::string, float>( - casterName, casterRadius[0] * pow(10.f, casterRadius[1]))); + casterName, casterRadius)); } else { LWARNING("No Radius value expecified for Shadow Caster Name " diff --git a/modules/space/rendering/renderablerings.cpp b/modules/space/rendering/renderablerings.cpp index 1e16d2d838..ba24a5a556 100644 --- a/modules/space/rendering/renderablerings.cpp +++ b/modules/space/rendering/renderablerings.cpp @@ -106,7 +106,7 @@ RenderableRings::RenderableRings(const ghoul::Dictionary& dictionary) ); _size = static_cast(dictionary.value(KeySize)); - setBoundingSphere(PowerScaledScalar::CreatePSS(_size)); + setBoundingSphere(_size); addProperty(_size); _size.onChange([&]() { _planeIsDirty = true; }); diff --git a/modules/space/rendering/simplespheregeometry.cpp b/modules/space/rendering/simplespheregeometry.cpp index 03d5aefbb8..4b4eef96ec 100644 --- a/modules/space/rendering/simplespheregeometry.cpp +++ b/modules/space/rendering/simplespheregeometry.cpp @@ -43,51 +43,47 @@ namespace planetgeometry { SimpleSphereGeometry::SimpleSphereGeometry(const ghoul::Dictionary& dictionary) : PlanetGeometry() - , _realRadius("radius", "Radius", glm::vec4(1.f, 1.f, 1.f, 0.f), glm::vec4(-10.f, -10.f, -10.f, -20.f), - glm::vec4(10.f, 10.f, 10.f, 20.f)) + , _radius( + "radius", + "Radius", + glm::vec3(1.f, 1.f, 1.f), + glm::vec3(0.f, 0.f, 0.f), + glm::vec3(std::pow(10.f, 20.f), std::pow(10.f, 20.f), std::pow(10.f, 20.f))) , _segments("segments", "Segments", 20, 1, 5000) , _sphere(nullptr) { using constants::simplespheregeometry::keyRadius; using constants::simplespheregeometry::keySegments; - // The name is passed down from the SceneGraphNode - bool success = dictionary.getValue(SceneGraphNode::KeyName, _name); - assert(success); - - glm::vec4 radius; - success = dictionary.getValue(keyRadius, _modRadius); - if (!success) { - LERROR("SimpleSphereGeometry of '" << _name << "' did not provide a key '" - << keyRadius << "'"); - } - else { - radius[0] = _modRadius[0]; - radius[1] = _modRadius[0]; - radius[2] = _modRadius[0]; - radius[3] = _modRadius[1]; - _realRadius = radius; // In case the kernels does not supply a real + float sphereRadius = 0.f; + glm::vec3 ellipsoidRadius; + if (dictionary.getValue(keyRadius, sphereRadius)) { + _radius = { sphereRadius, sphereRadius, sphereRadius }; + } else if (dictionary.getValue(keyRadius, ellipsoidRadius)) { + _radius = ellipsoidRadius; + } else { + LERROR("SimpleSphereGeometry did not provide a key '" + << keyRadius << "'"); } - double segments; - success = dictionary.getValue(keySegments, segments); - if (!success) { - LERROR("SimpleSphereGeometry of '" << _name << "' did not provide a key '" - << keySegments << "'"); - } - else + double segments = 0; + if (dictionary.getValue(keySegments, segments)) { _segments = static_cast(segments); + } else { + LERROR("SimpleSphereGeometry did not provide a key '" + << keySegments << "'"); + } + // The shader need the radii values but they are not changeable runtime // TODO: Possibly add a scaling property @AA - addProperty(_realRadius); + addProperty(_radius); // Changing the radius/scaling should affect the shader but not the geometry? @AA - //_radius.onChange(std::bind(&SimpleSphereGeometry::createSphere, this)); + _radius.onChange(std::bind(&SimpleSphereGeometry::createSphere, this)); addProperty(_segments); _segments.onChange(std::bind(&SimpleSphereGeometry::createSphere, this)); } -SimpleSphereGeometry::~SimpleSphereGeometry() -{ +SimpleSphereGeometry::~SimpleSphereGeometry() { } bool SimpleSphereGeometry::initialize(Renderable* parent) @@ -97,28 +93,24 @@ bool SimpleSphereGeometry::initialize(Renderable* parent) return success; } -void SimpleSphereGeometry::deinitialize() -{ +void SimpleSphereGeometry::deinitialize() { if (_sphere) delete _sphere; _sphere = nullptr; } -void SimpleSphereGeometry::render() -{ +void SimpleSphereGeometry::render() { _sphere->render(); } void SimpleSphereGeometry::createSphere(){ - //create the power scaled scalar - - PowerScaledScalar planetSize(_modRadius); - _parent->setBoundingSphere(planetSize); + const glm::vec3 radius = _radius.value(); + _parent->setBoundingSphere(std::max(std::max(radius[0], radius[1]), radius[2])); if(_sphere) delete _sphere; - //_sphere = new PowerScaledSphere(planetSize, _segments); - _sphere = new PowerScaledSphere(_realRadius, _segments, _name); + + _sphere = new PowerScaledSphere(glm::vec4(radius, 0.0), _segments); _sphere->initialize(); } diff --git a/modules/space/rendering/simplespheregeometry.h b/modules/space/rendering/simplespheregeometry.h index 3604050944..b0525a8ad3 100644 --- a/modules/space/rendering/simplespheregeometry.h +++ b/modules/space/rendering/simplespheregeometry.h @@ -28,7 +28,7 @@ #include #include -#include +#include namespace openspace { @@ -42,19 +42,15 @@ public: SimpleSphereGeometry(const ghoul::Dictionary& dictionary); ~SimpleSphereGeometry(); - bool initialize(Renderable* parent) override; void deinitialize() override; void render() override; - private: void createSphere(); - glm::vec2 _modRadius; - properties::Vec4Property _realRadius; + float _modRadius; + properties::Vec3Property _radius; properties::IntProperty _segments; - std::string _name; - PowerScaledSphere* _sphere; }; diff --git a/src/interaction/interactionmode.cpp b/src/interaction/interactionmode.cpp index 37015985eb..719193fb3f 100644 --- a/src/interaction/interactionmode.cpp +++ b/src/interaction/interactionmode.cpp @@ -435,7 +435,7 @@ void OrbitalInteractionMode::updateCameraStateFromMouseStates(Camera& camera, do dquat totalRotation = camera.rotationQuaternion(); dvec3 directionToCenter = normalize(centerPos - camPos); dvec3 lookUp = camera.lookUpVectorWorldSpace(); - double boundingSphere = _focusNode->boundingSphere().lengthf(); + double boundingSphere = _focusNode->boundingSphere(); dvec3 camDirection = camera.viewDirectionWorldSpace(); // Declare other variables used in interaction calculations diff --git a/src/rendering/renderable.cpp b/src/rendering/renderable.cpp index 2d63892119..101a409c5e 100644 --- a/src/rendering/renderable.cpp +++ b/src/rendering/renderable.cpp @@ -137,12 +137,12 @@ Renderable::Renderable(const ghoul::Dictionary& dictionary) Renderable::~Renderable() {} -void Renderable::setBoundingSphere(PowerScaledScalar boundingSphere) { - boundingSphere_ = std::move(boundingSphere); +void Renderable::setBoundingSphere(float boundingSphere) { + _boundingSphere = boundingSphere; } -PowerScaledScalar Renderable::getBoundingSphere() { - return boundingSphere_; +float Renderable::boundingSphere() const { + return _boundingSphere; } void Renderable::update(const UpdateData&) {} diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index c8fda8c90e..43da6f39e6 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -290,8 +290,6 @@ void RenderEngine::updateScene() { Time::ref().timeJumped(), _performanceManager != nullptr }); - - _scene->evaluate(_camera); LTRACE("RenderEngine::updateSceneGraph(end)"); } diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index 7020ba5892..4778aee872 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -228,19 +228,6 @@ void Scene::update(const UpdateData& data) { } } -void Scene::evaluate(Camera* camera) { - for (SceneGraphNode* node : _topologicallySortedNodes) { - try { - LTRACE("Scene::evaluate(begin '" + node->name() + "')"); - node->evaluate(camera); - LTRACE("Scene::evaluate(end '" + node->name() + "')"); - } - catch (const ghoul::RuntimeError& e) { - LERRORC(e.component, e.what()); - } - } -} - void Scene::render(const RenderData& data, RendererTasks& tasks) { for (SceneGraphNode* node : _topologicallySortedNodes) { try { diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 863bb961dd..55abd04631 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -171,8 +171,6 @@ SceneGraphNode::SceneGraphNode() } , _performanceRecord({0, 0, 0}) , _renderable(nullptr) - , _renderableVisible(false) - , _boundingSphereVisible(false) { } @@ -210,9 +208,6 @@ bool SceneGraphNode::deinitialize() { // reset variables _parent = nullptr; - _renderableVisible = false; - _boundingSphereVisible = false; - _boundingSphere = PowerScaledScalar(0.0, 0.0); return true; } @@ -316,46 +311,6 @@ void SceneGraphNode::update(const UpdateData& data) { } } -void SceneGraphNode::evaluate(const Camera* camera, const psc& parentPosition) { - //const psc thisPosition = parentPosition + _ephemeris->position(); - //const psc camPos = camera->position(); - //const psc toCamera = thisPosition - camPos; - - // init as not visible - //_boundingSphereVisible = false; - _renderableVisible = false; - -#ifndef OPENSPACE_VIDEO_EXPORT - // check if camera is outside the node boundingsphere - /* if (toCamera.length() > _boundingSphere) { - // check if the boudningsphere is visible before avaluating children - if (!sphereInsideFrustum(thisPosition, _boundingSphere, camera)) { - // the node is completely outside of the camera view, stop evaluating this - // node - //LFATAL(_nodeName << " is outside of frustum"); - return; - } - } - */ -#endif - - // inside boudningsphere or parts of the sphere is visible, individual - // children needs to be evaluated - _boundingSphereVisible = true; - - // this node has an renderable - if (_renderable) { - // check if the renderable boundingsphere is visible - // _renderableVisible = sphereInsideFrustum( - // thisPosition, _renderable->getBoundingSphere(), camera); - _renderableVisible = true; - } - - // evaluate all the children, tail-recursive function(?) - //for (SceneGraphNode* child : _children) - // child->evaluate(camera, psc()); -} - void SceneGraphNode::render(const RenderData& data, RendererTasks& tasks) { const psc thisPositionPSC = psc::CreatePowerScaledCoordinate(_worldPositionCached.x, _worldPositionCached.y, _worldPositionCached.z); @@ -370,7 +325,7 @@ void SceneGraphNode::render(const RenderData& data, RendererTasks& tasks) { //_performanceRecord.renderTime = 0; - bool visible = _renderableVisible && + bool visible = _renderable && _renderable->isVisible() && _renderable->isReady() && _renderable->isEnabled() && @@ -620,42 +575,11 @@ std::vector SceneGraphNode::children() const { return nodes; } -PowerScaledScalar SceneGraphNode::calculateBoundingSphere(){ - // set the bounding sphere to 0.0 - _boundingSphere = 0.0; - /* - This is not how to calculate a bounding sphere, better to leave it at 0 if not a - renderable. --KB - if (!_children.empty()) { // node - PowerScaledScalar maxChild; - - // loop though all children and find the one furthest away/with the largest - // bounding sphere - for (size_t i = 0; i < _children.size(); ++i) { - // when positions is dynamic, change this part to fins the most distant - // position - //PowerScaledScalar child = _children.at(i)->position().length() - // + _children.at(i)->calculateBoundingSphere(); - PowerScaledScalar child = _children.at(i)->calculateBoundingSphere(); - if (child > maxChild) { - maxChild = child; - } - } - _boundingSphere += maxChild; - } - */ - // if has a renderable, use that boundingsphere - if (_renderable ) { - PowerScaledScalar renderableBS = _renderable->getBoundingSphere(); - if(renderableBS > _boundingSphere) - _boundingSphere = renderableBS; +float SceneGraphNode::boundingSphere() const{ + if (_renderable) { + return _renderable->boundingSphere(); } - - return _boundingSphere; -} - -PowerScaledScalar SceneGraphNode::boundingSphere() const{ - return _boundingSphere; + return 0.0; } // renderable diff --git a/src/util/powerscaledsphere.cpp b/src/util/powerscaledsphere.cpp index 9d646a78ec..3f3c96904c 100644 --- a/src/util/powerscaledsphere.cpp +++ b/src/util/powerscaledsphere.cpp @@ -24,7 +24,6 @@ // open space includes #include -#include #include #define _USE_MATH_DEFINES @@ -126,7 +125,7 @@ PowerScaledSphere::PowerScaledSphere(const PowerScaledScalar& radius, int segmen } // Alternative Constructor for using accurate triaxial ellipsoid -PowerScaledSphere::PowerScaledSphere(properties::Vec4Property &radius, int segments, std::string planetName) +PowerScaledSphere::PowerScaledSphere(glm::vec3 radius, int segments) : _vaoID(0) , _vBufferID(0) , _iBufferID(0) @@ -137,42 +136,7 @@ PowerScaledSphere::PowerScaledSphere(properties::Vec4Property &radius, int segme { static_assert(sizeof(Vertex) == 64, "The size of the Vertex needs to be 64 for performance"); - - float a, b, c, powerscale; - bool accutareRadius; - try { - glm::dvec3 radii; - SpiceManager::ref().getValue(planetName, "RADII", radii); - a = radii.x; - b = radii.y; - c = radii.z; - accutareRadius = true; - } - catch (const SpiceManager::SpiceException& e) { - //LINFO("Could not find radius for body " << planetName); - accutareRadius = false; - } - - if (accutareRadius) { - PowerScaledCoordinate powerScaledRadii = psc::CreatePowerScaledCoordinate(a, b, c); - powerScaledRadii[3] += 3; // SPICE returns radii in km - - std::swap(powerScaledRadii[1], powerScaledRadii[2]); // c is equivalent to y in our coordinate system - radius.set(powerScaledRadii.vec4()); - a = powerScaledRadii[0]; - b = powerScaledRadii[1]; - c = powerScaledRadii[2]; - powerscale = powerScaledRadii[3]; - } - else { - ghoul::any r = radius.get(); - glm::vec4 modRadius = ghoul::any_cast(r); - a = modRadius[0]; - b = modRadius[1]; - c = modRadius[2]; - powerscale = modRadius[3]; - } - + int nr = 0; const float fsegments = static_cast(segments); @@ -186,14 +150,14 @@ PowerScaledSphere::PowerScaledSphere(properties::Vec4Property &radius, int segme // azimuth angle (east to west) const float phi = fj * float(M_PI) * 2.0f / fsegments; // 0 -> 2*PI - const float x = a * sin(phi) * sin(theta); // - const float y = b * cos(theta); // up - const float z = c * cos(phi) * sin(theta); // + const float x = radius[0] * sin(phi) * sin(theta); // + const float y = radius[1] * cos(theta); // up + const float z = radius[2] * cos(phi) * sin(theta); // _varray[nr].location[0] = x; _varray[nr].location[1] = y; _varray[nr].location[2] = z; - _varray[nr].location[3] = powerscale; + _varray[nr].location[3] = 0.0; glm::vec3 normal = glm::vec3(x, y, z); if (!(x == 0.f && y == 0.f && z == 0.f))