You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
ToolsFramework: - added new USceneSnappingManager::ExecuteSceneHitQuery API function, as well as accompanying FSceneHitQueryRequest/FSceneHitQueryResult structs - added FSceneQueryVisibilityFilter struct which contains ComponentsToIgnore/InvisibleComponentsToInclude lists for snapping queries and provides shared IsVisible() implementation ModelingComponents: - add FLevelObjectsObserver, tracks Actors added/removed to a Level via various editor events - add FSceneGeometrySpatialCache, maintains spatial data structures for known types of mesh-backed PrimitiveComponents, an octree based on their world-space bounding-boxes, and provides various spatial-query functions - ModelingSceneSnappingManager now maintains a FSceneGeometrySpatialCache for a set of Actors/Components it is notified about, and updates the spatial cache if those components are modified or translated. Currently supports Volumes and DynamicMeshComponents. - add ModelingSceneSnappingManager::ExecuteSceneHitQuery implementation, does raycasts into the world (for static mesh components) and FSceneGeometrySpatialCache for Volumes/DMCs - modified ModelingSceneSnappingManager::ExecuteSceneSnapQuery to also do combined query against StaticMeshComponents via world-linetrace, and FSceneGeometrySpatialCache for Volumes/DMCs - add ToolSceneQueriesUtil::FindNearestVisibleObjectHit variants that take a USceneSnappingManager or UInteractiveTool, and do queries via the SceneSnappingManger, instead of directly linetracing into a UWorld ModleingToolsEditorMode: - add FLevelObjectsObserver instance and use it to drive updates to active ModelingSceneSnappingManager #rnx #jira none #preflight 61a664a09a226d9e823ad4c1 #ROBOMERGE-AUTHOR: ryan.schmidt #ROBOMERGE-SOURCE: CL 18339853 in //UE5/Release-5.0/... via CL 18339869 #ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469) [CL 18339891 by ryan schmidt in ue5-release-engine-test branch]
120 lines
2.3 KiB
C++
120 lines
2.3 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "SceneQueries/SceneSnappingManager.h"
|
|
#include "InteractiveToolManager.h"
|
|
#include "InteractiveGizmoManager.h"
|
|
#include "ContextObjectStore.h"
|
|
#include "GameFramework/Actor.h"
|
|
#include "Components/PrimitiveComponent.h"
|
|
|
|
|
|
|
|
namespace UELocal
|
|
{
|
|
|
|
static bool IsHiddenActor(const AActor* Actor)
|
|
{
|
|
#if WITH_EDITOR
|
|
return ( Actor->IsHiddenEd() );
|
|
#else
|
|
return ( Actor->IsHidden() );
|
|
#endif
|
|
}
|
|
|
|
static bool IsHiddenComponent(const UPrimitiveComponent* Component)
|
|
{
|
|
#if WITH_EDITOR
|
|
return (Component->IsVisibleInEditor() == false);
|
|
#else
|
|
return (Component->IsVisible() == false);
|
|
#endif
|
|
}
|
|
|
|
|
|
static bool IsVisibleObject( const UPrimitiveComponent* Component )
|
|
{
|
|
if (Component == nullptr)
|
|
{
|
|
return false;
|
|
}
|
|
AActor* Actor = Component->GetOwner();
|
|
if (Actor == nullptr)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (IsHiddenActor(Actor))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if ( IsHiddenComponent(Component) )
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FSceneQueryVisibilityFilter::IsVisible(const UPrimitiveComponent* Component) const
|
|
{
|
|
if (Component == nullptr)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool bIsVisible = UELocal::IsVisibleObject(Component);
|
|
if (bIsVisible || (InvisibleComponentsToInclude != nullptr && InvisibleComponentsToInclude->Contains(Component)))
|
|
{
|
|
return (ComponentsToIgnore == nullptr) || (ComponentsToIgnore->Contains(Component) == false);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FSceneHitQueryResult::InitializeHitResult(const FSceneHitQueryRequest& FromRequest)
|
|
{
|
|
HitResult = FHitResult(TargetActor, TargetComponent, (FVector)Position, (FVector)Normal);
|
|
|
|
HitResult.Distance = FromRequest.WorldRay.GetParameter(Position);
|
|
HitResult.FaceIndex = HitTriIndex;
|
|
// initialize .Time? Need start/end for that...
|
|
}
|
|
|
|
|
|
|
|
|
|
USceneSnappingManager* USceneSnappingManager::Find(UInteractiveToolManager* ToolManager)
|
|
{
|
|
if (ensure(ToolManager))
|
|
{
|
|
USceneSnappingManager* Found = ToolManager->GetContextObjectStore()->FindContext<USceneSnappingManager>();
|
|
if (Found != nullptr)
|
|
{
|
|
return Found;
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
|
|
USceneSnappingManager* USceneSnappingManager::Find(UInteractiveGizmoManager* GizmoManager)
|
|
{
|
|
if (ensure(GizmoManager))
|
|
{
|
|
USceneSnappingManager* Found = GizmoManager->GetContextObjectStore()->FindContext<USceneSnappingManager>();
|
|
if (Found != nullptr)
|
|
{
|
|
return Found;
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|