UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
BlockedLayout3.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3
4#pragma once
5#include "IntBoxTypes.h"
6
7
8namespace UE
9{
10namespace Geometry
11{
12// These are 3d grid space layout behaviors shared by the various blocked grids
13// ( c.f. BlockedDenseGrid3.h and other usages in SparseNarrowBandSDFMesh.h )
14
15
16// Consistent translation between a linear array of size BlockSize to a 3d layout.
17template <int32 BlockSize_>
19{
20 static constexpr int32 BlockSize = BlockSize_;
22
27 {
28 //inverse of ToLinear()
29 const int32 i = LocalLinear % BlockSize;
30 const int32 j = (LocalLinear / BlockSize) % BlockSize;
31 const int32 k = LocalLinear / (BlockSize * BlockSize);
32 return FVector3i(i, j, k);
33 }
34
38 static inline int32 ToLinear(const int32& LocalI, const int32& LocalJ, const int32& LocalK)
39 {
40 //inverse of ToLocalIJK
41 return LocalI + BlockSize * (LocalJ + BlockSize * LocalK);
42 }
43};
44
45// Spatial decomposition of a region of 3d ijk space into 3d cubes of size BlockSize (per side).
46// This class gives a consistent translation between locations in 3d lattice space and blocks of a spatial decomposition;
47// it is independent of any sort of data that you might want to associate with those locations. See BlockedDenseGrid3.h for usage.
48template <int32 BlockSize_>
50{
51public:
52 static constexpr int32 BlockSize = BlockSize_; // block is a cube in ijk space of length BlockSize
53 static constexpr int32 BlockElemCount = BlockSize * BlockSize * BlockSize; // no. of ijk coordinates (i.e. lattice points) in each block
54
56
61
66
71
76 {
77 check((int64)DimI * (int64)DimJ * (int64)DimK < INT_MAX); // [todo] want a larger check here.. right now 1290^3 is near the upper lim
78 const int32 BlocksI = (DimI / BlockSize) + ( (DimI % BlockSize != 0) ? 1 : 0 );
79 const int32 BlocksJ = (DimJ / BlockSize) + ( (DimJ % BlockSize != 0) ? 1 : 0 );
80 const int32 BlocksK = (DimK / BlockSize) + ( (DimK % BlockSize != 0) ? 1 : 0 );
81
84 }
85
89 const FVector3i& GetDimensions() const
90 {
91 return Dimensions;
92 }
93
98 {
99 return BlockDimensions;
100 }
101
102 /*
103 * @return an axis aligned box that defines the bounds of this region in terms of cells. This bounds is [inclusive, exclusive)
104 */
106 {
107 return FAxisAlignedBox3i({ 0, 0, 0 }, { Dimensions[0], Dimensions[1], Dimensions[2] });
108 }
109
110 /*
111 * @return an axis aligned box that defines the bounds of this region in terms of cells. This bounds is [inclusive, inclusive]
112 */
114 {
115 return FAxisAlignedBox3i({ 0, 0, 0 }, { Dimensions[0] - 1, Dimensions[1] - 1, Dimensions[2]- 1 });
116 }
117
123 int64 Size() const
124 {
125 return (int64)Dimensions[0] * (int64)Dimensions[1] * (int64)Dimensions[2];
126 }
127
131 bool IsValidIJK(const FVector3i& IJK) const
132 {
133 return IJK[0] >= 0 && IJK[1] >= 0 && IJK[2] >= 0
134 && IJK[0] < Dimensions[0] && IJK[1] < Dimensions[1] && IJK[2] < Dimensions[2];
135 }
136
141 {
142 return BlockIJK[0] >= 0 && BlockIJK[1] >= 0 && BlockIJK[2] >= 0
144 }
145
150 {
153 }
154
171
185
190 {
191 return BlockIJK[0] + BlockDimensions.X * (BlockIJK[1] + BlockDimensions.Y * BlockIJK[2]);
192 }
193
194protected:
195
196 FVector3i BlockDimensions; // dimensions in blocks per axis
197 FVector3i Dimensions; // dimensions in cells per axis
198};
199
200} // end namespace UE::Geometry
201} // end namespace UE
#define check(expr)
Definition AssertionMacros.h:314
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
int BlockIndex
Definition binka_ue_decode_test.cpp:38
Definition BlockedLayout3.h:50
bool IsValidIJK(const FVector3i &IJK) const
Definition BlockedLayout3.h:131
FAxisAlignedBox3i Bounds() const
Definition BlockedLayout3.h:105
TBlockData3Layout< BlockSize_ > FBlockData3Layout
Definition BlockedLayout3.h:55
FVector3i BlockIndexToBlockIJK(const int32 BlockIndex) const
Definition BlockedLayout3.h:176
const FVector3i & GetDimensions() const
Definition BlockedLayout3.h:89
const FVector3i & GetBlockDimensions() const
Definition BlockedLayout3.h:97
int64 Size() const
Definition BlockedLayout3.h:123
void GetBlockAndLocalIndex(int32 I, int32 J, int32 K, int32 &BlockIndexOut, int32 &LocalIndexOut) const
Definition BlockedLayout3.h:167
void GetBlockAndLocalIndex(const FVector3i &IJK, int32 &BlockIndexOut, int32 &LocalIndexOut) const
Definition BlockedLayout3.h:158
FAxisAlignedBox3i BoundsInclusive() const
Definition BlockedLayout3.h:113
void Resize(int32 DimI, int32 DimJ, int32 DimK)
Definition BlockedLayout3.h:75
bool IsValidBlockIJK(const FVector3i &BlockIJK)
Definition BlockedLayout3.h:140
static constexpr int32 BlockElemCount
Definition BlockedLayout3.h:53
static constexpr int32 BlockSize
Definition BlockedLayout3.h:52
FVector3i BlockDimensions
Definition BlockedLayout3.h:196
int32 IJKtoBlockIndex(const FVector3i &IJK) const
Definition BlockedLayout3.h:149
TBlockedGrid3Layout(FVector3i Dims)
Definition BlockedLayout3.h:67
TBlockedGrid3Layout()
Definition BlockedLayout3.h:57
TBlockedGrid3Layout(int32 DimI, int32 DimJ, int32 DimK)
Definition BlockedLayout3.h:62
int32 BlockIJKToBlockIndex(const FVector3i &BlockIJK) const
Definition BlockedLayout3.h:189
FVector3i Dimensions
Definition BlockedLayout3.h:197
Definition AdvancedWidgetsModule.cpp:13
Definition IntBoxTypes.h:184
Definition IntVectorTypes.h:252
int32 X
Definition IntVectorTypes.h:257
int32 Y
Definition IntVectorTypes.h:257
Definition BlockedLayout3.h:19
static FVector3i ToLocalIJK(int32 LocalLinear)
Definition BlockedLayout3.h:26
static constexpr int32 BlockSize
Definition BlockedLayout3.h:20
static int32 ToLinear(const int32 &LocalI, const int32 &LocalJ, const int32 &LocalK)
Definition BlockedLayout3.h:38
static constexpr int32 ElemCount
Definition BlockedLayout3.h:21