RealDocs

UKismetMathLibrary::Convert1DTo3D

function Engine Blueprint Since unknown
#include "Kismet/KismetMathLibrary.h"
Access: public Specifiers: staticUFUNCTIONBlueprintPure

Description

Maps a flat 1D array index to its equivalent (X, Y, Z) coordinate in a 3D array of the given width and depth, e.g. for reading a flattened voxel grid array.

Caveats & Gotchas

  • Assumes the array is laid out with X varying fastest, then Y, then Z; a different storage order will produce a mismatched result.
  • No bounds checking is performed — an out-of-range Index1D still returns a computed FIntVector rather than an error.
  • XSize or YSize of 0 will divide by zero internally; guard against it if the dimensions are computed dynamically.

Signature

static FIntVector Convert1DTo3D(int32 Index1D, int32 XSize, int32 YSize)

Parameters

Name Type Description Default
Index1D int32 The flat array index to convert.
XSize int32 Width (X dimension) of the logical 3D array.
YSize int32 Depth (Y dimension) of the logical 3D array.

Return Type

FIntVector

Example

Convert a flat voxel array index to grid coordinates C++
int32 FlatIndex = 1250;
int32 SizeX = 16;
int32 SizeY = 16;
FIntVector VoxelCoord = UKismetMathLibrary::Convert1DTo3D(FlatIndex, SizeX, SizeY);

Version History

Introduced in: unknown

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.