Files
stephen holmes 97766341ea Refactored FSructView and FConstStructView as per recent meetings. Both are now const correct in the same way TArrayView and TArrayConstView are (ie const FStructView and const FConstStructView) the view can not point at another view.
Also removed the Mutable named functions and replaced with the constness being part of the template.

#preflight 63ea4fbaec50523134d85665

[CL 24197313 by stephen holmes in ue5-main branch]
2023-02-13 20:06:02 -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.Get<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