Files
UnrealEngineUWP/Engine/Plugins/Runtime/SmartObjects/Source/SmartObjectsModule/Private/SmartObjectHashGrid.cpp
yoan stamant 478d81a61b [SmartObject] handles for SmartObject and SmartObjectSlot passed by value
#rnx
#rb trivial
#preflight 62322b8c6e25767a218d46b0

#ROBOMERGE-AUTHOR: yoan.stamant
#ROBOMERGE-SOURCE: CL 19410090 via CL 19412659 via CL 19426193 via CL 19426309
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v930-19419903)

[CL 19429514 by yoan stamant in ue5-main branch]
2022-03-17 19:07:54 -04:00

36 lines
1.2 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "SmartObjectHashGrid.h"
#include "DebugRenderSceneProxy.h"
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, const 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