You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- don't allow delete when an Accept-style tool is active. This prevents most problems but is very hard-line from UX perspective. - add FPrimitiveComponentTarget::IsValid(), use in various ComponentTarget functions to avoid trying to access a Component that has been deleted. Still returns null in many places which callers will need to handle. #rb michael.daum #rnx #jira UE-86277 #ROBOMERGE-SOURCE: CL 11960881 in //UE4/Release-4.25/... via CL 11960906 #ROBOMERGE-BOT: RELEASE (Release-4.25Plus -> Main) (v656-11643781) [CL 11960972 by ryan schmidt in Main branch]
135 lines
2.8 KiB
C++
135 lines
2.8 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "ComponentSourceInterfaces.h"
|
|
|
|
#include "Components/PrimitiveComponent.h"
|
|
#include "Containers/Array.h"
|
|
|
|
namespace
|
|
{
|
|
TArray<TUniquePtr<FComponentTargetFactory>> Factories;
|
|
}
|
|
|
|
|
|
void AddComponentTargetFactory( TUniquePtr<FComponentTargetFactory> Factory )
|
|
{
|
|
Factories.Push( MoveTemp(Factory) );
|
|
}
|
|
|
|
bool CanMakeComponentTarget(UActorComponent* Component)
|
|
{
|
|
for ( const auto& Factory : Factories )
|
|
{
|
|
if ( Factory->CanBuild(Component) )
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
TUniquePtr<FPrimitiveComponentTarget> MakeComponentTarget(UPrimitiveComponent* Component)
|
|
{
|
|
for ( const auto& Factory : Factories )
|
|
{
|
|
if ( Factory->CanBuild( Component ) )
|
|
{
|
|
return Factory->Build( Component );
|
|
}
|
|
}
|
|
return {};
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FComponentMaterialSet::operator!=(const FComponentMaterialSet& Other) const
|
|
{
|
|
int32 Num = Materials.Num();
|
|
if (Other.Materials.Num() != Num)
|
|
{
|
|
return true;
|
|
}
|
|
for (int32 j = 0; j < Num; ++j)
|
|
{
|
|
if (Other.Materials[j] != Materials[j])
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
bool FPrimitiveComponentTarget::IsValid() const
|
|
{
|
|
return (Component->IsPendingKillOrUnreachable() == false) && Component->IsValidLowLevel();
|
|
}
|
|
|
|
AActor* FPrimitiveComponentTarget::GetOwnerActor() const
|
|
{
|
|
return IsValid() ? Component->GetOwner() : nullptr;
|
|
}
|
|
|
|
UPrimitiveComponent* FPrimitiveComponentTarget::GetOwnerComponent() const
|
|
{
|
|
return IsValid() ? Component : nullptr;
|
|
}
|
|
|
|
|
|
void FPrimitiveComponentTarget::SetOwnerVisibility(bool bVisible) const
|
|
{
|
|
if (IsValid())
|
|
{
|
|
Component->SetVisibility(bVisible);
|
|
}
|
|
}
|
|
|
|
|
|
int32 FPrimitiveComponentTarget::GetNumMaterials() const
|
|
{
|
|
return IsValid() ? Component->GetNumMaterials() : 0;
|
|
}
|
|
|
|
UMaterialInterface* FPrimitiveComponentTarget::GetMaterial(int32 MaterialIndex) const
|
|
{
|
|
return IsValid() ? Component->GetMaterial(MaterialIndex) : nullptr;
|
|
}
|
|
|
|
void FPrimitiveComponentTarget::GetMaterialSet(FComponentMaterialSet& MaterialSetOut, bool bAssetMaterials) const
|
|
{
|
|
if (IsValid())
|
|
{
|
|
int32 NumMaterials = Component->GetNumMaterials();
|
|
MaterialSetOut.Materials.SetNum(NumMaterials);
|
|
for (int32 k = 0; k < NumMaterials; ++k)
|
|
{
|
|
MaterialSetOut.Materials[k] = Component->GetMaterial(k);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void FPrimitiveComponentTarget::CommitMaterialSetUpdate(const FComponentMaterialSet& MaterialSet, bool bApplyToAsset)
|
|
{
|
|
check(false); // not implemented
|
|
}
|
|
|
|
|
|
|
|
|
|
FTransform FPrimitiveComponentTarget::GetWorldTransform() const
|
|
{
|
|
return IsValid() ? Component->GetComponentTransform() : FTransform::Identity;
|
|
}
|
|
|
|
bool FPrimitiveComponentTarget::HitTest(const FRay& WorldRay, FHitResult& OutHit) const
|
|
{
|
|
FVector End = WorldRay.PointAt(HALF_WORLD_MAX);
|
|
if (IsValid() && Component->LineTraceComponent(OutHit, WorldRay.Origin, End, FCollisionQueryParams(SCENE_QUERY_STAT(HitTest), true)))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|