UKismetMathLibrary::Convert3DTo1D
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Maps a 3D array index to the equivalent flat 1D array index, using the formula X + Y*XSize + Z*XSize*YSize.
Caveats & Gotchas
- • Bounds-checks Index3D against XSize/YSize (and rejects negative components); on failure it logs a Blueprint execution warning and returns 0 rather than an out-of-range index.
- • The flattening order must match whatever function built the 3D array (or Convert1DTo3D) — mixing X/Y/Z axis order between producer and consumer silently scrambles data even though no error is raised.
Signature
static int32 Convert3DTo1D(const FIntVector& Index3D, int32 XSize, int32 YSize) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Index3D | const FIntVector& | The 3D array index to flatten. | — |
| XSize | int32 | X dimension of the 3D array. | — |
| YSize | int32 | Y dimension of the 3D array. | — |
Return Type
int32 Example
Flatten a voxel index C++
FIntVector VoxelIndex(3, 2, 1);
int32 XSize = 8, YSize = 8;
int32 FlatIndex = UKismetMathLibrary::Convert3DTo1D(VoxelIndex, XSize, YSize);
// FlatIndex indexes into a TArray<T> sized XSize*YSize*ZSize Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?