You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Moved SmartObjects out of restricted folder Moved StateTree out of restricted folder Moved ZoneGraph out of restricted folder Moved ZoneGraphAnnotations out of restricted folder #jira UE-115297 #ROBOMERGE-OWNER: mieszko.zielinski #ROBOMERGE-AUTHOR: mieszko.zielinski #ROBOMERGE-SOURCE: CL 17648223 via CL 17648246 via CL 17648261 via CL 17648385 via CL 17648390 via CL 17648742 #ROBOMERGE-BOT: STARSHIP (Release-Engine-Test -> Main) (v875-17642767) [CL 17648750 by mieszko zielinski in ue5-main branch]
128 lines
3.9 KiB
C++
128 lines
3.9 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "SmartObjectRenderingComponent.h"
|
|
#include "DebugRenderSceneProxy.h"
|
|
#include "SmartObjectComponent.h"
|
|
#include "ObjectEditorUtils.h"
|
|
|
|
//----------------------------------------------------------------------//
|
|
// FSORenderingSceneProxy
|
|
//----------------------------------------------------------------------//
|
|
class FSORenderingSceneProxy final : public FDebugRenderSceneProxy
|
|
{
|
|
typedef TPair<FVector, FVector> FVectorPair;
|
|
public:
|
|
SIZE_T GetTypeHash() const override
|
|
{
|
|
static size_t UniquePointer;
|
|
return reinterpret_cast<size_t>(&UniquePointer);
|
|
}
|
|
|
|
/** Initialization constructor. */
|
|
FSORenderingSceneProxy(const USmartObjectRenderingComponent& InComponent)
|
|
: FDebugRenderSceneProxy(&InComponent)
|
|
{
|
|
AActor* Owner = InComponent.GetOwner();
|
|
if (Owner == nullptr)
|
|
{
|
|
return;
|
|
}
|
|
|
|
USmartObjectComponent* SOComp = Owner->FindComponentByClass<USmartObjectComponent>();
|
|
if (SOComp == nullptr)
|
|
{
|
|
return;
|
|
}
|
|
|
|
const float DebugCylinderRadius = 40.f;
|
|
const float DebugCylinderHalfHeight = 100.f;
|
|
FColor DebugColor = FColor::Yellow;
|
|
|
|
const FTransform OwnerLocalToWorld = SOComp->GetComponentTransform();
|
|
for (int32 i = 0; i < SOComp->GetConfig().GetSlots().Num(); ++i)
|
|
{
|
|
TOptional<FTransform> Transform = SOComp->GetConfig().GetSlotTransform(OwnerLocalToWorld, FSmartObjectSlotIndex(i));
|
|
if (!Transform.IsSet())
|
|
{
|
|
continue;
|
|
}
|
|
#if WITH_EDITORONLY_DATA
|
|
DebugColor = SOComp->GetConfig().GetSlots()[i].DEBUG_DrawColor;
|
|
#endif
|
|
const FVector DebugPosition = Transform.GetValue().GetLocation();
|
|
const FVector Direction = Transform.GetValue().GetRotation().GetForwardVector();
|
|
Cylinders.Emplace(DebugPosition, DebugCylinderRadius, DebugCylinderHalfHeight, DebugColor);
|
|
ArrowLines.Emplace(DebugPosition, DebugPosition + Direction * 2.0f * DebugCylinderRadius, DebugColor);
|
|
}
|
|
}
|
|
|
|
virtual FPrimitiveViewRelevance GetViewRelevance(const FSceneView* View) const override
|
|
{
|
|
FPrimitiveViewRelevance Result;
|
|
Result.bDrawRelevance = IsShown(View) && IsSelected();
|
|
Result.bDynamicRelevance = true;
|
|
// ideally the TranslucencyRelevance should be filled out by the material, here we do it conservative
|
|
Result.bSeparateTranslucency = Result.bNormalTranslucency = IsShown(View);
|
|
return Result;
|
|
}
|
|
};
|
|
|
|
//----------------------------------------------------------------------//
|
|
// USmartObjectRenderingComponent
|
|
//----------------------------------------------------------------------//
|
|
USmartObjectRenderingComponent::USmartObjectRenderingComponent(const FObjectInitializer& ObjectInitializer)
|
|
: Super(ObjectInitializer)
|
|
{
|
|
// Allows updating in game, while optimizing rendering for the case that it is not modified
|
|
Mobility = EComponentMobility::Stationary;
|
|
|
|
BodyInstance.SetCollisionProfileName(UCollisionProfile::NoCollision_ProfileName);
|
|
|
|
bIsEditorOnly = true;
|
|
|
|
SetGenerateOverlapEvents(false);
|
|
}
|
|
|
|
FPrimitiveSceneProxy* USmartObjectRenderingComponent::CreateSceneProxy()
|
|
{
|
|
return new FSORenderingSceneProxy(*this);
|
|
}
|
|
|
|
FBoxSphereBounds USmartObjectRenderingComponent::CalcBounds(const FTransform& LocalToWorld) const
|
|
{
|
|
FBox BoundingBox(EForceInit::ForceInitToZero);
|
|
|
|
if (HasAnyFlags(RF_BeginDestroyed) == false && GetAttachParent() != nullptr)
|
|
{
|
|
USmartObjectComponent* SOComp = nullptr;
|
|
|
|
const AActor* Owner = GetOwner();
|
|
if (Owner)
|
|
{
|
|
BoundingBox += Owner->GetActorLocation();
|
|
SOComp = Owner->FindComponentByClass<USmartObjectComponent>();
|
|
}
|
|
|
|
if (SOComp)
|
|
{
|
|
BoundingBox += SOComp->GetSmartObjectBounds();
|
|
}
|
|
}
|
|
|
|
return FBoxSphereBounds(BoundingBox);
|
|
}
|
|
|
|
#if WITH_EDITOR
|
|
void USmartObjectRenderingComponent::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
|
{
|
|
const FName SmartObjectsName = TEXT("SmartObjects");
|
|
|
|
Super::PostEditChangeProperty(PropertyChangedEvent);
|
|
|
|
if (PropertyChangedEvent.Property
|
|
&& FObjectEditorUtils::GetCategoryFName(PropertyChangedEvent.Property) == SmartObjectsName)
|
|
{
|
|
MarkRenderStateDirty();
|
|
}
|
|
}
|
|
#endif // WITH_EDITOR
|