Skip to content

Commit

Permalink
Remove MilStd2525 Placemark aging transparency support.
Browse files Browse the repository at this point in the history
  • Loading branch information
ComBatVision committed Dec 11, 2023
1 parent ba551c9 commit 76150df
Showing 1 changed file with 14 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,13 @@ package earth.worldwind.shape.milstd2525
import earth.worldwind.render.RenderContext
import earth.worldwind.shape.Placemark
import earth.worldwind.shape.PlacemarkAttributes
import kotlinx.datetime.Clock
import kotlinx.datetime.Instant
import kotlin.time.Duration.Companion.days
import kotlin.time.Duration.Companion.hours

/**
* The [MilStd2525LevelOfDetailSelector] determines which set of [PlacemarkAttributes] to use for a [MilStd2525Placemark].
* A [MilStd2525Placemark] creates an instance of this class in its constructor, and calls
* [Placemark.LevelOfDetailSelector.selectLevelOfDetail] in its [Placemark.doRender] method.
*/
open class MilStd2525LevelOfDetailSelector : Placemark.LevelOfDetailSelector {
companion object {
protected const val NORMAL_SCALE = 1.0
protected const val HIGHLIGHTED_SCALE = 1.3
protected const val LOW_LEVEL_OF_DETAIL = 0
protected const val MEDIUM_LEVEL_OF_DETAIL = 1
protected const val HIGH_LEVEL_OF_DETAIL = 2
protected const val HIGHEST_LEVEL_OF_DETAIL = 3

/**
* Controls the symbol modifiers visibility threshold
*/
var modifiersThreshold = 5e4

/**
* Duration after which placemark becomes slightly transparent
*/
var firstAgingThreshold = 1.hours

/**
* Fist level of transparency
*/
var firstAgingAlpha = 0.75f

/**
* Duration after which placemark becomes moderate transparent
*/
var secondAgingThreshold = 1.days

/**
* Second level of transparency
*/
var secondAgingAlpha = 0.5f
}

/**
* Base time to calculate transparency of aging Placemarks
*/
var baseAgingTime = Instant.DISTANT_FUTURE

protected var lastLevelOfDetail = -1
protected var isHighlighted = false
protected var isInvalidateRequested = false
Expand Down Expand Up @@ -119,16 +76,20 @@ open class MilStd2525LevelOfDetailSelector : Placemark.LevelOfDetailSelector {
placemark.attributes.isDrawLeader = lastLevelOfDetail >= MEDIUM_LEVEL_OF_DETAIL
placemark.attributes.imageScale = if (isHighlighted) HIGHLIGHTED_SCALE else NORMAL_SCALE

if (baseAgingTime != Instant.DISTANT_FUTURE) {
val agingTime = Clock.System.now() - baseAgingTime
// Make placemark translucent with time
placemark.attributes.imageColor.alpha = when {
!isHighlighted && agingTime > secondAgingThreshold -> secondAgingAlpha
!isHighlighted && agingTime > firstAgingThreshold -> firstAgingAlpha
else -> 1.0f // Opaque placemark by default
}
}

return true
}

companion object {
protected const val NORMAL_SCALE = 1.0
protected const val HIGHLIGHTED_SCALE = 1.3
protected const val LOW_LEVEL_OF_DETAIL = 0
protected const val MEDIUM_LEVEL_OF_DETAIL = 1
protected const val HIGH_LEVEL_OF_DETAIL = 2
protected const val HIGHEST_LEVEL_OF_DETAIL = 3

/**
* Controls the symbol modifiers visibility threshold
*/
var modifiersThreshold = 5e4
}
}

0 comments on commit 76150df

Please sign in to comment.