Skip to content

VoxelReady

Namespace Nfty.Core.Editing in assembly Nfty.Core.

public static class VoxelReady

Makes a book's art voxel-ready: every partially transparent pixel snaps at 50% to solid or clear, through AlphaSnap<TPixel>, so there is one snap rule. Depth maps are untouched — a pixel turning solid has no stored depth, so it rises at paper; one turning clear never had any.

Fields

Threshold

public const byte Threshold = 128;

Alpha at or above this snaps solid; below it snaps clear.

Methods

Apply(LoadedCookBook)

public static VoxelReadyResult Apply(LoadedCookBook book);

Snaps every partial variant, returning a new graph. Clean variants and depth maps are shared with book, which is not disposed or modified.

Parameters

  • book (LoadedCookBook) - The book to make voxel-ready.

Returns. The snapped book plus what is needed to undo.

Plan(LoadedCookBook)

public static IReadOnlyList<VoxelReadyChange> Plan(LoadedCookBook book);

Lists what VoxelReady.Apply() would change. Writes nothing.

Parameters

  • book (LoadedCookBook) - The book to inspect.

Returns. One row per variant with partial alpha, ordinal by recipe, layer, variant.

Snap(Image<Rgba32>)

public static Image<Rgba32> Snap(Image<Rgba32> art);

Snaps an image. The command's rule, applied to a copy.

Parameters

  • art (Image<Rgba32>) - The image to snap; left untouched.

Returns. A new image the caller owns.

Undo(LoadedCookBook, VoxelReadyResult)

public static LoadedCookBook Undo(LoadedCookBook current, VoxelReadyResult applied);

Puts the pre-snap pixels back.

Parameters

  • current (LoadedCookBook) - The book as it stands now.
  • applied (VoxelReadyResult) - What VoxelReady.Apply() returned.

Returns. A new graph with the original pixels restored (as clones; applied stays disposable).

Exceptions

  • InvalidOperationException - A snapped variant's pixels have changed since VoxelReady.Apply(); the message names each, and nothing is restored.