Method WorldToVoxelIndex
| Edit this page View SourceWorldToVoxelIndex(Vector3, Vector3)
Converts world position to voxel grid index. Use for normal coordinate conversion.
Declaration
public static (int x, int y, int z) WorldToVoxelIndex(Vector3 worldPosition, Vector3 voxelSize)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | worldPosition | The world position to convert |
| Vector3 | voxelSize | The size of each voxel in world units |
Returns
| Type | Description |
|---|---|
| (int x, int y, int z) | The (x, y, z) grid indices of the containing voxel |
WorldToVoxelIndex(Vector3, Vector3, Vector3)
Converts world position to voxel grid index with custom grid origin. Use for normal coordinate conversion.
Declaration
public static (int x, int y, int z) WorldToVoxelIndex(Vector3 worldPosition, Vector3 voxelSize, Vector3 gridOrigin)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | worldPosition | The world position to convert |
| Vector3 | voxelSize | The size of each voxel in world units |
| Vector3 | gridOrigin | The world position of the grid's origin (minimum corner of voxel (0,0,0)) |
Returns
| Type | Description |
|---|---|
| (int x, int y, int z) | The (x, y, z) grid indices of the containing voxel |
WorldToVoxelIndex(float, float, float, in Vector3)
Converts world position to voxel grid index. Use for normal coordinate conversion.
Declaration
public static (int x, int y, int z) WorldToVoxelIndex(float x, float y, float z, in Vector3 voxelSize)
Parameters
| Type | Name | Description |
|---|---|---|
| float | x | The X world coordinate |
| float | y | The Y world coordinate |
| float | z | The Z world coordinate |
| Vector3 | voxelSize | The size of each voxel in world units |
Returns
| Type | Description |
|---|---|
| (int x, int y, int z) | The (x, y, z) grid indices of the containing voxel |
Remarks
This overload is provided for performance in tight loops to avoid Vector3 construction.