public void ForceDirection(Direction dir, Axis axis) { for (var i = 0; i < State.Count; i++) { if (!_bitField.GetBit(i)) { continue; } var state = State.NewEncoded(i); var connectivity = ModuleRegistry .GetConnectivity(state.Index).GetRotated(state.Pose); if (connectivity[dir] != axis) { _bitField.UnsetBit(i); } } }
void Propagate(int x, int y, int z) { // Retrieve the wave state. var state = RefWave(x, y, z).ObservedState; var conn = ModuleRegistry.GetConnectivity(state.Index); conn = conn.GetRotated(state.Pose); // Boundary check var coord = math.int3(x, y, z); var bl = coord > 0; var bh = coord < _dims - 1; if (bl.x) { RefWave(x - 1, y, z).ForceDirection(Direction.XP, conn[Direction.XN]); } if (bh.x) { RefWave(x + 1, y, z).ForceDirection(Direction.XN, conn[Direction.XP]); } if (bl.y) { RefWave(x, y - 1, z).ForceDirection(Direction.YP, conn[Direction.YN]); } if (bh.y) { RefWave(x, y + 1, z).ForceDirection(Direction.YN, conn[Direction.YP]); } if (bl.z) { RefWave(x, y, z - 1).ForceDirection(Direction.ZP, conn[Direction.ZN]); } if (bh.z) { RefWave(x, y, z + 1).ForceDirection(Direction.ZN, conn[Direction.ZP]); } }