Skip to content

Commit 5837a6d

Browse files
committed
Addressing PR feedback. Updated changelog.
1 parent 59540e3 commit 5837a6d

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
### ? - ?
44

5+
##### Additions :tada:
6+
7+
- `ACesiumCartographicPolygon`s created via the Cesium editor panel are sized and transformed to be visible in the active editor viewport.
8+
59
##### Fixes :wrench:
610

711
- Fixed an access violation that could occur if `ACesium3DTileset::RefreshTileset` was invoked in a callback for asynchronous actions.

Source/CesiumEditor/Private/CesiumEditor.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -748,12 +748,12 @@ AActor* FCesiumEditorModule::SpawnBlankTileset() {
748748
}
749749

750750
AActor* FCesiumEditorModule::SpawnCartographicPolygon() {
751-
ACesiumCartographicPolygon* actor = static_cast<ACesiumCartographicPolygon*>(
751+
ACesiumCartographicPolygon* pActor = static_cast<ACesiumCartographicPolygon*>(
752752
SpawnActorWithClass(ACesiumCartographicPolygon::StaticClass()));
753-
if (actor) {
754-
actor->ResetSplineAndCenterInEditorViewport();
753+
if (pActor) {
754+
pActor->ResetSplineAndCenterInEditorViewport();
755755
}
756-
return actor;
756+
return pActor;
757757
}
758758

759759
UClass* FCesiumEditorModule::GetDynamicPawnBlueprintClass() {

Source/CesiumRuntime/Private/CesiumCartographicPolygon.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
#include "CesiumActors.h"
55
#include "Components/SceneComponent.h"
66
#include "StaticMeshResources.h"
7+
#if WITH_EDITOR
78
#include "Subsystems/UnrealEditorSubsystem.h"
9+
#endif
810
#include <glm/glm.hpp>
911

1012
using namespace CesiumGeospatial;
@@ -14,20 +16,20 @@ bool ACesiumCartographicPolygon::ResetSplineAndCenterInEditorViewport() {
1416
if (!GEditor)
1517
return false;
1618

17-
UUnrealEditorSubsystem* editorSubsystem =
19+
UUnrealEditorSubsystem* pEditorSubsystem =
1820
GEditor->GetEditorSubsystem<UUnrealEditorSubsystem>();
19-
if (!editorSubsystem)
21+
if (!pEditorSubsystem)
2022
return false;
2123

2224
FVector viewPosition{};
2325
FRotator viewRotation{};
2426

25-
editorSubsystem->GetLevelViewportCameraInfo(viewPosition, viewRotation);
26-
FVector viewDirection = viewRotation.Vector();
27+
pEditorSubsystem->GetLevelViewportCameraInfo(viewPosition, viewRotation);
28+
const FVector viewDirection = viewRotation.Vector();
2729

2830
// Check if the ray and plane are parallel first to avoid division by zero
2931
if (FMath::Abs(FVector::DotProduct(viewDirection, FVector::UpVector)) <
30-
DBL_EPSILON) {
32+
KINDA_SMALL_NUMBER) {
3133
// Ray is parallel to the plane, no single intersection point.
3234
return false;
3335
}
@@ -38,7 +40,7 @@ bool ACesiumCartographicPolygon::ResetSplineAndCenterInEditorViewport() {
3840
viewDirection,
3941
groundPlane);
4042

41-
if (distance <= DBL_EPSILON) {
43+
if (distance < KINDA_SMALL_NUMBER) {
4244
// no intersection found in front of the camera.
4345
return false;
4446
}
@@ -56,10 +58,9 @@ bool ACesiumCartographicPolygon::ResetSplineAndCenterInEditorViewport() {
5658

5759
this->MakeLinear();
5860
this->SetActorLocation(spawnPosition);
61+
#endif
5962

6063
return true;
61-
62-
#endif
6364
}
6465

6566
ACesiumCartographicPolygon::ACesiumCartographicPolygon() : AActor() {
@@ -78,12 +79,6 @@ ACesiumCartographicPolygon::ACesiumCartographicPolygon() : AActor() {
7879
};
7980

8081
this->Polygon->SetSplinePoints(points, ESplineCoordinateSpace::Local);
81-
82-
#if WITH_EDITOR
83-
if (GEditor)
84-
GEditor->RedrawAllViewports(true);
85-
#endif
86-
8782
this->MakeLinear();
8883
#if WITH_EDITOR
8984
this->SetIsSpatiallyLoaded(false);

Source/CesiumRuntime/Public/CesiumCartographicPolygon.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ class CESIUMRUNTIME_API ACesiumCartographicPolygon : public AActor {
8383

8484
/**
8585
* Set the spline points to a square centered where the editor camera view ray
86-
* intersects the ground and sized to fit within thee viewport.
87-
* @returns boolean indicating whether the spline points and transform were
88-
* successfully recomputed.
86+
* intersects the ground and sized to fit within the viewport.
87+
* @returns Whether the spline points and transform were successfully
88+
* recomputed.
8989
*/
9090
bool ResetSplineAndCenterInEditorViewport();
9191

0 commit comments

Comments
 (0)