// Copyright 2020 Phyronnaz #pragma once #include "CoreMinimal.h" #include "PhysicsEngine/BodySetup.h" // Can't forward decl anything with uobjects generated constructors... #include "Components/PrimitiveComponent.h" #include "VoxelWorldRootComponent.generated.h" UCLASS(editinlinenew) class VOXEL_API UVoxelWorldRootComponent : public UPrimitiveComponent { GENERATED_BODY() public: UVoxelWorldRootComponent(); ~UVoxelWorldRootComponent(); ECollisionTraceFlag CollisionTraceFlag = {}; //~ Begin UPrimitiveComponent Interface virtual UBodySetup* GetBodySetup() override final; virtual FPrimitiveSceneProxy* CreateSceneProxy() override final; virtual FBoxSphereBounds CalcBounds(const FTransform& LocalToWorld) const override; //~ End UPrimitiveComponent Interface // Only need to tick when created void TickWorldRoot(); public: #if WITH_PHYSX && PHYSICS_INTERFACE_PHYSX void UpdateConvexCollision(uint64 Id, const FBox& Bounds, TArray&& ConvexElements, TArray&& ConvexMeshes); void SetCookedTriMeshes(const TArray& TriMeshes); #endif private: UPROPERTY(Transient) TObjectPtr BodySetup; FBoxSphereBounds LocalBounds; // For debug draw FCriticalSection BodySetupLock; #if WITH_PHYSX && PHYSICS_INTERFACE_PHYSX struct FConvexElements { const FBox Bounds; const TArray ConvexElements; const TArray ConvexMeshes; FConvexElements(const FBox& InBounds, TArray&& InConvexElements, TArray&& InConvexMeshes); ~FConvexElements(); }; TMap> Elements; bool bRebuildQueued = false; void RebuildConvexCollision(); #endif friend class FVoxelRenderSimpleCollisionSceneProxy; };