Files
UnrealEngineUWP/Engine/Plugins/Runtime/SmartObjects/Source/SmartObjectsModule/Private/SmartObjectHashGrid.cpp
henrik karlsson 9183978e29 [Engine/Plugins]
* Removed includes (using IWYU) in private files

#preflight 63c79978ac35a0e9dabbe408
#rb none

[CL 23770038 by henrik karlsson in ue5-main branch]
2023-01-19 00:48:07 -05:00

40 lines
1.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "SmartObjectHashGrid.h"
#include "DebugRenderSceneProxy.h"
#include "Math/ColorList.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(SmartObjectHashGrid)
FInstancedStruct USmartObjectHashGrid::Add(const FSmartObjectHandle Handle, const FBox& Bounds)
{
FSmartObjectHashGridEntryData GridEntryData;
GridEntryData.CellLoc = HashGrid.Add(Handle, Bounds);
return FInstancedStruct::Make(GridEntryData);
}
void USmartObjectHashGrid::Remove(const FSmartObjectHandle Handle, FStructView EntryData)
{
FSmartObjectHashGridEntryData& GridEntryData = EntryData.GetMutable<FSmartObjectHashGridEntryData>();
HashGrid.Remove(Handle, GridEntryData.CellLoc);
GridEntryData.CellLoc = {};
}
void USmartObjectHashGrid::Find(const FBox& QueryBox, TArray<FSmartObjectHandle>& OutResults)
{
HashGrid.QuerySmall(QueryBox, OutResults);
}
#if UE_ENABLE_DEBUG_DRAWING
void USmartObjectHashGrid::Draw(FDebugRenderSceneProxy* DebugProxy)
{
const TSet<FSmartObjectHashGrid2D::FCell>& AllCells = HashGrid.GetCells();
for (auto It(AllCells.CreateConstIterator()); It; ++It)
{
FBox CellBounds = HashGrid.CalcCellBounds(FSmartObjectHashGrid2D::FCellLocation(It->X, It->Y, It->Level));
DebugProxy->Boxes.Emplace(CellBounds, GColorList.GetFColorByIndex(It->Level));
}
}
#endif //UE_ENABLE_DEBUG_DRAWING