Skip to content

Commit

Permalink
Apply correct Actor transform to CesiumSunSky.
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Jul 12, 2023
1 parent 2a2ddb6 commit ec63aca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion Source/CesiumRuntime/Private/CesiumSunSky.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,18 @@ FVector getViewLocation(UWorld* pWorld) {
} // namespace

void ACesiumSunSky::UpdateAtmosphereRadius() {
const FTransform& transform = this->GetActorTransform().Inverse();
// This Actor is located at the center of the Earth (the CesiumGlobeAnchor
// keeps it there), so we ignore this Actor's transform and use only its
// parent transform.
FTransform transform{};
USceneComponent* pRootComponent = this->GetRootComponent();
if (IsValid(pRootComponent)) {
USceneComponent* pParent = pRootComponent->GetAttachParent();
if (IsValid(pParent)) {
transform = pParent->GetComponentToWorld().Inverse();
}
}

FVector location =
transform.TransformPosition(getViewLocation(this->GetWorld()));
glm::dvec3 llh =
Expand Down
4 changes: 2 additions & 2 deletions Source/CesiumRuntime/Public/CesiumSunSky.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ class CESIUMRUNTIME_API ACesiumSunSky : public AActor {
* The height of the atmosphere layer above the ground, in kilometers. This
* value is automatically scaled according to the CesiumGeoreference Scale and
* the Actor scale. However, Unreal Engine's SkyAtmosphere has a hard-coded
* minimum effective value of 0.1, so the atmosphere will look too thick when the globe
* is scaled down drastically.
* minimum effective value of 0.1, so the atmosphere will look too thick when
* the globe is scaled down drastically.
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium|Atmosphere")
double AtmosphereHeight = 60.0;
Expand Down

0 comments on commit ec63aca

Please sign in to comment.