2021-10-21 16:57:00 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "SceneQueries/SceneSnappingManager.h"
|
|
|
|
|
#include "InteractiveToolManager.h"
|
|
|
|
|
#include "InteractiveGizmoManager.h"
|
|
|
|
|
#include "ContextObjectStore.h"
|
Added support for world-space hit-testing and snapping to Volume and DynamicMeshComponent mesh vertices/edges/faces, by having Modeling Mode maintain a persistent set of spatial data structures for these scene meshes. With this change, new ToolSceneQueriesUtil functions can be used to provide more general scene mesh-element hit-testing/snapping via ModelingSceneSnappingManager. Updates to existing Tools/Mechanics to use these new query functions will be done in later CLs.
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]
2021-12-01 11:15:01 -05:00
|
|
|
#include "GameFramework/Actor.h"
|
|
|
|
|
#include "Components/PrimitiveComponent.h"
|
|
|
|
|
|
2022-09-24 13:57:58 -04:00
|
|
|
#include UE_INLINE_GENERATED_CPP_BY_NAME(SceneSnappingManager)
|
|
|
|
|
|
Added support for world-space hit-testing and snapping to Volume and DynamicMeshComponent mesh vertices/edges/faces, by having Modeling Mode maintain a persistent set of spatial data structures for these scene meshes. With this change, new ToolSceneQueriesUtil functions can be used to provide more general scene mesh-element hit-testing/snapping via ModelingSceneSnappingManager. Updates to existing Tools/Mechanics to use these new query functions will be done in later CLs.
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]
2021-12-01 11:15:01 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
2022-09-30 00:43:06 -04:00
|
|
|
HitResult.Distance = static_cast<float>( FromRequest.WorldRay.GetParameter(Position) );
|
Added support for world-space hit-testing and snapping to Volume and DynamicMeshComponent mesh vertices/edges/faces, by having Modeling Mode maintain a persistent set of spatial data structures for these scene meshes. With this change, new ToolSceneQueriesUtil functions can be used to provide more general scene mesh-element hit-testing/snapping via ModelingSceneSnappingManager. Updates to existing Tools/Mechanics to use these new query functions will be done in later CLs.
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]
2021-12-01 11:15:01 -05:00
|
|
|
HitResult.FaceIndex = HitTriIndex;
|
|
|
|
|
// initialize .Time? Need start/end for that...
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-10-21 16:57:00 -04:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2022-09-24 13:57:58 -04:00
|
|
|
|