You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb none #ROBOMERGE-SOURCE: CL 12943955 via CL 12943960 via CL 12943974 #ROBOMERGE-BOT: RELEASE (Release-Engine-Staging -> Main) (v682-12900288) [CL 12943977 by steven barnett in Main branch]
164 lines
5.1 KiB
C++
164 lines
5.1 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "UObject/ObjectMacros.h"
|
|
#include "PhysicsEngine/ConvexElem.h"
|
|
#include "PhysicsEngine/BoxElem.h"
|
|
#include "PhysicsEngine/SphereElem.h"
|
|
#include "PhysicsEngine/SphylElem.h"
|
|
#include "PhysicsEngine/TaperedCapsuleElem.h"
|
|
#include "AggregateGeom.generated.h"
|
|
|
|
class FMaterialRenderProxy;
|
|
|
|
/** Container for an aggregate of collision shapes */
|
|
USTRUCT()
|
|
struct ENGINE_API FKAggregateGeom
|
|
{
|
|
GENERATED_USTRUCT_BODY()
|
|
|
|
UPROPERTY(EditAnywhere, editfixedsize, Category = "Aggregate Geometry", meta = (DisplayName = "Spheres"))
|
|
TArray<FKSphereElem> SphereElems;
|
|
|
|
UPROPERTY(EditAnywhere, editfixedsize, Category = "Aggregate Geometry", meta = (DisplayName = "Boxes"))
|
|
TArray<FKBoxElem> BoxElems;
|
|
|
|
UPROPERTY(EditAnywhere, editfixedsize, Category = "Aggregate Geometry", meta = (DisplayName = "Capsules"))
|
|
TArray<FKSphylElem> SphylElems;
|
|
|
|
UPROPERTY(EditAnywhere, editfixedsize, Category = "Aggregate Geometry", meta = (DisplayName = "Convex Elements"))
|
|
TArray<FKConvexElem> ConvexElems;
|
|
|
|
UPROPERTY(EditAnywhere, editfixedsize, Category = "Aggregate Geometry", meta = (DisplayName = "Tapered Capsules"))
|
|
TArray<FKTaperedCapsuleElem> TaperedCapsuleElems;
|
|
|
|
class FKConvexGeomRenderInfo* RenderInfo;
|
|
|
|
FKAggregateGeom()
|
|
: RenderInfo(NULL)
|
|
{
|
|
}
|
|
|
|
FKAggregateGeom(const FKAggregateGeom& Other)
|
|
: RenderInfo(nullptr)
|
|
{
|
|
CloneAgg(Other);
|
|
}
|
|
|
|
const FKAggregateGeom& operator=(const FKAggregateGeom& Other)
|
|
{
|
|
FreeRenderInfo();
|
|
CloneAgg(Other);
|
|
return *this;
|
|
}
|
|
|
|
int32 GetElementCount() const
|
|
{
|
|
return SphereElems.Num() + SphylElems.Num() + BoxElems.Num() + ConvexElems.Num() + TaperedCapsuleElems.Num();
|
|
}
|
|
|
|
int32 GetElementCount(EAggCollisionShape::Type Type) const;
|
|
|
|
FKShapeElem* GetElement(const EAggCollisionShape::Type Type, const int32 Index)
|
|
{
|
|
switch (Type)
|
|
{
|
|
case EAggCollisionShape::Sphere:
|
|
if (ensure(SphereElems.IsValidIndex(Index))) { return &SphereElems[Index]; }
|
|
case EAggCollisionShape::Box:
|
|
if (ensure(BoxElems.IsValidIndex(Index))) { return &BoxElems[Index]; }
|
|
case EAggCollisionShape::Sphyl:
|
|
if (ensure(SphylElems.IsValidIndex(Index))) { return &SphylElems[Index]; }
|
|
case EAggCollisionShape::Convex:
|
|
if (ensure(ConvexElems.IsValidIndex(Index))) { return &ConvexElems[Index]; }
|
|
case EAggCollisionShape::TaperedCapsule:
|
|
if (ensure(TaperedCapsuleElems.IsValidIndex(Index))) { return &TaperedCapsuleElems[Index]; }
|
|
default:
|
|
ensure(false);
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
FKShapeElem* GetElement(const int32 InIndex)
|
|
{
|
|
int Index = InIndex;
|
|
if (Index < SphereElems.Num()) { return &SphereElems[Index]; }
|
|
Index -= SphereElems.Num();
|
|
if (Index < BoxElems.Num()) { return &BoxElems[Index]; }
|
|
Index -= BoxElems.Num();
|
|
if (Index < SphylElems.Num()) { return &SphylElems[Index]; }
|
|
Index -= SphylElems.Num();
|
|
if (Index < ConvexElems.Num()) { return &ConvexElems[Index]; }
|
|
Index -= ConvexElems.Num();
|
|
if (Index < TaperedCapsuleElems.Num()) { return &TaperedCapsuleElems[Index]; }
|
|
ensure(false);
|
|
return nullptr;
|
|
}
|
|
|
|
const FKShapeElem* GetElement(const int32 InIndex) const
|
|
{
|
|
int Index = InIndex;
|
|
if (Index < SphereElems.Num()) { return &SphereElems[Index]; }
|
|
Index -= SphereElems.Num();
|
|
if (Index < BoxElems.Num()) { return &BoxElems[Index]; }
|
|
Index -= BoxElems.Num();
|
|
if (Index < SphylElems.Num()) { return &SphylElems[Index]; }
|
|
Index -= SphylElems.Num();
|
|
if (Index < ConvexElems.Num()) { return &ConvexElems[Index]; }
|
|
Index -= ConvexElems.Num();
|
|
if (Index < TaperedCapsuleElems.Num()) { return &TaperedCapsuleElems[Index]; }
|
|
ensure(false);
|
|
return nullptr;
|
|
}
|
|
|
|
void EmptyElements()
|
|
{
|
|
BoxElems.Empty();
|
|
ConvexElems.Empty();
|
|
SphylElems.Empty();
|
|
SphereElems.Empty();
|
|
TaperedCapsuleElems.Empty();
|
|
|
|
FreeRenderInfo();
|
|
}
|
|
|
|
#if WITH_EDITORONLY_DATA
|
|
void FixupDeprecated(FArchive& Ar);
|
|
#endif
|
|
|
|
void GetAggGeom(const FTransform& Transform, const FColor Color, const FMaterialRenderProxy* MatInst, bool bPerHullColor, bool bDrawSolid, bool bDrawsVelocity, int32 ViewIndex, class FMeshElementCollector& Collector) const;
|
|
|
|
/** Release the RenderInfo (if its there) and safely clean up any resources. Call on the game thread. */
|
|
void FreeRenderInfo();
|
|
|
|
FBox CalcAABB(const FTransform& Transform) const;
|
|
|
|
/**
|
|
* Calculates a tight box-sphere bounds for the aggregate geometry; this is more expensive than CalcAABB
|
|
* (tight meaning the sphere may be smaller than would be required to encompass the AABB, but all individual components lie within both the box and the sphere)
|
|
*
|
|
* @param Output The output box-sphere bounds calculated for this set of aggregate geometry
|
|
* @param LocalToWorld Transform
|
|
*/
|
|
void CalcBoxSphereBounds(FBoxSphereBounds& Output, const FTransform& LocalToWorld) const;
|
|
|
|
/** Returns the volume of this element */
|
|
float GetVolume(const FVector& Scale3D) const;
|
|
|
|
FGuid MakeDDCKey() const;
|
|
|
|
private:
|
|
|
|
/** Helper function for safely copying instances */
|
|
void CloneAgg(const FKAggregateGeom& Other)
|
|
{
|
|
SphereElems = Other.SphereElems;
|
|
BoxElems = Other.BoxElems;
|
|
SphylElems = Other.SphylElems;
|
|
ConvexElems = Other.ConvexElems;
|
|
TaperedCapsuleElems = Other.TaperedCapsuleElems;
|
|
}
|
|
};
|