Class Voxel
Represents a voxel within a 3D grid, handling spatial positioning, obstacles, occupants, and neighbor relationships.
public class Voxel : IEquatable<Voxel>
- Inheritance
-
Voxel
- Implements
- Inherited Members
Constructors
Voxel()
public Voxel()
Properties
CachedGridVersion
The current version of the grid at the time this voxel was created.
public uint CachedGridVersion { get; }
Property Value
GridIndex
The world-local index of the grid this voxel belongs to.
public ushort GridIndex { get; }
Property Value
HasVacancy
Checks if this voxel has open slots for new occupants.
public bool HasVacancy { get; }
Property Value
Index
The local coordinates of this voxel within its grid.
public VoxelIndex Index { get; }
Property Value
IsAllocated
Indicates whether this voxel is allocated within a grid.
public bool IsAllocated { get; }
Property Value
IsBlockable
Determines if this voxel can accept additional obstacles.
public bool IsBlockable { get; }
Property Value
IsBlocked
Determines whether this voxel is blocked due to obstacles.
public bool IsBlocked { get; }
Property Value
IsBoundaryVoxel
Determines if this voxel is a boundary voxel.
public bool IsBoundaryVoxel { get; }
Property Value
IsOccupied
Determines whether this voxel is occupied by entities.
public bool IsOccupied { get; }
Property Value
IsPartioned
Indicates whether this voxel has any active partitions.
public bool IsPartioned { get; }
Property Value
ObstacleCount
The current number of obstacles on this voxel.
public byte ObstacleCount { get; }
Property Value
ObstacleTracker
Stores the process-unique identity of each obstacle registration added to this voxel.
public SwiftHashSet<ObstacleToken>? ObstacleTracker { get; }
Property Value
- SwiftHashSet<ObstacleToken>
OccupantCount
The current number of occupants on this voxel.
public byte OccupantCount { get; }
Property Value
ScanCellKey
The grid-local key of the scan cell that this voxel belongs to.
public int ScanCellKey { get; }
Property Value
WorldIndex
The world-scoped runtime identity of this voxel within the grid system.
public WorldVoxelIndex WorldIndex { get; set; }
Property Value
WorldPosition
The world-space position of this voxel.
public Vector3d WorldPosition { get; }
Property Value
- Vector3d
Methods
Equals(Voxel?)
public bool Equals(Voxel? other)
Parameters
otherVoxel
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
GetHexNeighborsInto(VoxelGrid, SwiftList<(HexDirection Direction, Voxel Voxel)>)
Clears and fills caller-owned storage with hex-prism neighbors in deterministic direction order.
public void GetHexNeighborsInto(VoxelGrid ownerGrid, SwiftList<(HexDirection Direction, Voxel Voxel)> results)
Parameters
ownerGridVoxelGridThe active grid that owns this voxel.
resultsSwiftList<(HexDirection Direction, Voxel Voxel)>Caller-owned storage cleared and filled with direction-labeled neighbors.
GetNeighborsInto(VoxelGrid, SwiftList<Voxel>, VoxelNeighborScope, Fixed64?)
Clears and fills caller-owned storage with neighboring voxels whose world-space voxel footprints touch this voxel's footprint.
public void GetNeighborsInto(VoxelGrid ownerGrid, SwiftList<Voxel> results, VoxelNeighborScope scope = VoxelNeighborScope.All, Fixed64? tolerance = null)
Parameters
ownerGridVoxelGridThe active grid that owns this voxel.
resultsSwiftList<Voxel>Caller-owned storage cleared and filled with contact neighbors.
scopeVoxelNeighborScopeThe grid groups included by the contact query.
toleranceFixed64?Optional fixed-point tolerance applied to footprint contact checks.
GetPartitionOrDefault<T>()
Retrieves a partition from the voxel by type and returns null if it doesn't exist.
public T? GetPartitionOrDefault<T>() where T : class, IVoxelPartition
Returns
- T
Type Parameters
T
GetRectangularNeighborsInto(VoxelGrid, SwiftList<(RectangularDirection Direction, Voxel Voxel)>)
Clears and fills caller-owned storage with rectangular-prism neighbors in deterministic direction order.
public void GetRectangularNeighborsInto(VoxelGrid ownerGrid, SwiftList<(RectangularDirection Direction, Voxel Voxel)> results)
Parameters
ownerGridVoxelGridThe active grid that owns this voxel.
resultsSwiftList<(RectangularDirection Direction, Voxel Voxel)>Caller-owned storage cleared and filled with direction-labeled neighbors.
HasNeighbor(VoxelGrid, VoxelNeighborScope, Fixed64?)
Determines whether this voxel has at least one footprint-contact neighbor in the requested scope.
public bool HasNeighbor(VoxelGrid ownerGrid, VoxelNeighborScope scope = VoxelNeighborScope.All, Fixed64? tolerance = null)
Parameters
ownerGridVoxelGridThe active grid that owns this voxel.
scopeVoxelNeighborScopeThe grid groups included by the contact query.
toleranceFixed64?Optional fixed-point tolerance applied to footprint contact checks.
Returns
- bool
True when at least one contact exists; otherwise false.
HasPartition<T>()
Checks whether or not this voxel contains a specific partition.
public bool HasPartition<T>() where T : IVoxelPartition
Returns
Type Parameters
T
ToString()
public override string ToString()
Returns
TryAddPartition(IVoxelPartition)
Adds a partition to this voxel, allowing specialized behaviors.
public bool TryAddPartition(IVoxelPartition partition)
Parameters
partitionIVoxelPartition
Returns
TryGetNeighbor(VoxelGrid, HexDirection, out Voxel?)
Retrieves the hex-prism neighbor voxel in the supplied topology-local direction.
public bool TryGetNeighbor(VoxelGrid ownerGrid, HexDirection direction, out Voxel? neighbor)
Parameters
ownerGridVoxelGridThe active grid that owns this voxel.
directionHexDirectionThe hex-prism direction to resolve.
neighborVoxelThe resolved same-topology neighbor when found.
Returns
- bool
True when a same-topology neighbor exists in the supplied direction; otherwise false.
TryGetNeighbor(VoxelGrid, RectangularDirection, out Voxel?)
Retrieves the rectangular-prism neighbor voxel in the supplied topology-local direction.
public bool TryGetNeighbor(VoxelGrid ownerGrid, RectangularDirection direction, out Voxel? neighbor)
Parameters
ownerGridVoxelGridThe active grid that owns this voxel.
directionRectangularDirectionThe rectangular-prism direction to resolve.
neighborVoxelThe resolved same-topology neighbor when found.
Returns
- bool
True when a same-topology neighbor exists in the supplied direction; otherwise false.
TryGetPartition<T>(out T?)
Retrieves a partition from the voxel by type.
public bool TryGetPartition<T>(out T? partition) where T : IVoxelPartition
Parameters
partitionT
Returns
Type Parameters
T
TryRemovePartition<T>()
Removes a partition from this voxel.
public bool TryRemovePartition<T>() where T : IVoxelPartition
Returns
Type Parameters
T
Events
OnObstacleAdded
public event Action<ObstacleEventInfo> OnObstacleAdded
Event Type
OnObstacleRemoved
public event Action<ObstacleEventInfo> OnObstacleRemoved
Event Type
OnObstaclesCleared
public event Action<ObstacleClearEventInfo> OnObstaclesCleared
Event Type
OnOccupantAdded
public event Action<OccupantEventInfo> OnOccupantAdded
Event Type
OnOccupantRemoved
public event Action<OccupantEventInfo> OnOccupantRemoved