Skip to content

Commit 2500007

Browse files
committed
Add configurable draw order for surface renderables.
1 parent 6889e35 commit 2500007

File tree

12 files changed

+20
-13
lines changed

12 files changed

+20
-13
lines changed

worldwind/src/commonMain/kotlin/earth/worldwind/formats/kml/KmlToRenderableConverter.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ internal class KmlToRenderableConverter {
120120
val surfaceImage = SurfaceImage(
121121
sector = groundOverlay.latLonBox?.toSector() ?: return emptyList(),
122122
imageSource = groundOverlay.icon?.toImageSource() ?: return emptyList(),
123-
)
123+
).apply {
124+
zOrder = groundOverlay.drawOrder.toDouble()
125+
}
124126
return listOf(surfaceImage)
125127
}
126128

@@ -166,6 +168,7 @@ internal class KmlToRenderableConverter {
166168
isFollowTerrain = lineString.tessellate == true
167169
pathType = getPathTypeBy(altitudeMode, isFollowTerrain)
168170
maximumIntermediatePoints = 0 // Disable intermediate point for performance reasons
171+
zOrder = lineString.drawOrder.toDouble()
169172

170173
name?.let { displayName = it }
171174

worldwind/src/commonMain/kotlin/earth/worldwind/layer/ShowTessellationLayer.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import earth.worldwind.render.program.BasicShaderProgram
77

88
class ShowTessellationLayer: AbstractLayer("Terrain Tessellation") {
99
override var isPickEnabled = false
10+
var zOrder = 1.0 // z-order after surface textures
1011
var color = Color()
1112
set(value) {
1213
field.copy(value)
@@ -19,6 +20,6 @@ class ShowTessellationLayer: AbstractLayer("Terrain Tessellation") {
1920
val program = rc.getShaderProgram(BasicShaderProgram.KEY) { BasicShaderProgram() }
2021
val pool = rc.getDrawablePool(DrawableTessellation.KEY)
2122
val drawable = DrawableTessellation.obtain(pool).set(program, color, opacity)
22-
rc.offerSurfaceDrawable(drawable, 1.0 /*z-order after surface textures*/)
23+
rc.offerSurfaceDrawable(drawable, zOrder)
2324
}
2425
}

worldwind/src/commonMain/kotlin/earth/worldwind/layer/heatmap/ElevationHeatmapLayer.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import earth.worldwind.render.RenderContext
88
open class ElevationHeatmapLayer: AbstractLayer("Elevation Heatmap") {
99
override var isPickEnabled = false // Elevation Heatmap is not pickable
1010
override var opacity = 0.5f // Elevation Heatmap is semi-transparent by default
11+
var zOrder = 0.0
1112
/**
1213
* RGB colors for five thresholds of heatmap
1314
*/
@@ -41,6 +42,6 @@ open class ElevationHeatmapLayer: AbstractLayer("Elevation Heatmap") {
4142
drawable.opacity = opacity
4243
drawable.offset = rc.globe.offset
4344
drawable.program = rc.getShaderProgram(ElevationHeatmapProgram.KEY) { ElevationHeatmapProgram() }
44-
rc.offerSurfaceDrawable(drawable, 0.0)
45+
rc.offerSurfaceDrawable(drawable, zOrder)
4546
}
4647
}

worldwind/src/commonMain/kotlin/earth/worldwind/render/AbstractRenderable.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ abstract class AbstractRenderable @JvmOverloads constructor(override var display
66
override var isEnabled = true
77
override var isPickEnabled = true
88
override var pickDelegate: Any? = null
9+
override var zOrder = 0.0
910
private var userProperties: MutableMap<Any, Any>? = null
1011

1112
@Suppress("UNCHECKED_CAST")

worldwind/src/commonMain/kotlin/earth/worldwind/render/Renderable.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ interface Renderable {
55
var isEnabled: Boolean
66
var isPickEnabled: Boolean
77
var pickDelegate: Any?
8+
var zOrder: Double
89
fun <T> getUserProperty(key: Any): T?
910
fun putUserProperty(key: Any, value: Any): Any?
1011
fun removeUserProperty(key: Any): Any?

worldwind/src/commonMain/kotlin/earth/worldwind/shape/DirectionalSightline.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,6 @@ open class DirectionalSightline @JvmOverloads constructor(
243243
drawable.program = rc.getShaderProgram(SightlineProgram.KEY) { SightlineProgram() }
244244

245245
// Enqueue a drawable for processing on the OpenGL thread.
246-
rc.offerSurfaceDrawable(drawable, 0.0 /*z-order*/)
246+
rc.offerSurfaceDrawable(drawable, zOrder)
247247
}
248248
}

worldwind/src/commonMain/kotlin/earth/worldwind/shape/Ellipse.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ open class Ellipse @JvmOverloads constructor(
367367

368368
// Enqueue the drawable for processing on the OpenGL thread.
369369
if (isSurfaceShape) {
370-
rc.offerSurfaceDrawable(drawable, zOrder = 0.0)
371-
rc.offerSurfaceDrawable(drawableLines, zOrder = 0.0)
370+
rc.offerSurfaceDrawable(drawable, zOrder)
371+
rc.offerSurfaceDrawable(drawableLines, zOrder)
372372
} else {
373373
rc.offerShapeDrawable(drawableLines, cameraDistance)
374374
rc.offerShapeDrawable(drawable, cameraDistance)

worldwind/src/commonMain/kotlin/earth/worldwind/shape/OmnidirectionalSightline.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,6 @@ open class OmnidirectionalSightline @JvmOverloads constructor(
187187
drawable.program = rc.getShaderProgram(SightlineProgram.KEY) { SightlineProgram() }
188188

189189
// Enqueue a drawable for processing on the OpenGL thread.
190-
rc.offerSurfaceDrawable(drawable, 0.0 /*z-order*/)
190+
rc.offerSurfaceDrawable(drawable, zOrder)
191191
}
192192
}

worldwind/src/commonMain/kotlin/earth/worldwind/shape/Path.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ open class Path @JvmOverloads constructor(
181181
drawState.enableDepthWrite = activeAttributes.isDepthWrite
182182

183183
// Enqueue the drawable for processing on the OpenGL thread.
184-
if (isSurfaceShape) rc.offerSurfaceDrawable(drawable, zOrder = 0.0)
184+
if (isSurfaceShape) rc.offerSurfaceDrawable(drawable, zOrder)
185185
else rc.offerShapeDrawable(drawable, cameraDistance)
186186

187187
// Configure the drawable to display the shape's extruded interior.

worldwind/src/commonMain/kotlin/earth/worldwind/shape/Polygon.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ open class Polygon @JvmOverloads constructor(
275275

276276
// Enqueue the drawable for processing on the OpenGL thread.
277277
if (isSurfaceShape|| activeAttributes.interiorColor.alpha >= 1.0) {
278-
rc.offerSurfaceDrawable(drawable, zOrder = 0.0)
279-
rc.offerSurfaceDrawable(drawableLines, zOrder = 0.0)
278+
rc.offerSurfaceDrawable(drawable, zOrder)
279+
rc.offerSurfaceDrawable(drawableLines, zOrder)
280280
} else {
281281
rc.offerShapeDrawable(drawableLines, cameraDistance)
282282
rc.offerShapeDrawable(drawable, cameraDistance)

0 commit comments

Comments
 (0)