载入中...
搜索中...
未找到
eve::pixelworld::PixelWorld类 参考

Sparse, chunked, deterministic 2D falling-material world. 更多...

#include <PixelWorld.h>

类

struct  Impl
 

Public 成员函数

 PixelWorld (std::uint64_t seed=1)
 Construct an empty world with an explicit deterministic seed.
 
 PixelWorld (std::uint64_t seed, MaterialCatalog catalog)
 Construct an empty world owning a validated immutable material catalog.
 
 ~PixelWorld ()
 Pixel world.
 
 PixelWorld (PixelWorld &&) noexcept
 Pixel world.
 
PixelWorld & operator= (PixelWorld &&) noexcept
 Operator =.
 
 PixelWorld (const PixelWorld &)=delete
 
PixelWorld & operator= (const PixelWorld &)=delete
 
PixelCell getCell (int x, int y) const noexcept
 Return the cell at world coordinates; absent chunks read as air.
 
int getMaterial (int x, int y) const noexcept
 Convenience query returning the numeric material id.
 
bool isSolidMaterial (MaterialId material) const noexcept
 Query whether a validated material id participates in structural solid collision.
 
std::uint32_t materialDisplayRgba (MaterialId material) const noexcept
 Query the Catalog-owned preview/render color encoded as 0xRRGGBBAA.
 
eve::Result< PixelCatalogReloadReceipt > reloadMaterialCatalog (MaterialCatalog catalog, std::uint64_t expectedFingerprint)
 Transactionally hot-reload a compatible Catalog while paused.
 
void setCell (int x, int y, PixelCell cell)
 Set one cell and wake its chunk and neighbors. Air never allocates a missing chunk.
 
void setMaterial (int x, int y, std::string_view material)
 Set one cell from a stable built-in material name.
 
eve::Result< void > setMaterialChecked (int x, int y, std::string_view material)
 Canonical checked name-based setter; unknown names leave the world unchanged.
 
std::size_t paintCircle (int centerX, int centerY, int radius, std::string_view material)
 Paint a filled material circle and return the number of changed cells.
 
eve::Result< std::size_t > paintCircleChecked (int centerX, int centerY, int radius, std::string_view material)
 Canonical checked circle edit; unknown names leave the world unchanged.
 
eve::Result< PixelEditReceipt > applyEdit (const PixelEditCommand &command)
 Validate and atomically apply one strictly sequenced edit command.
 
PixelEditReceipt explode (int centerX, int centerY, int radius, int strength, std::int16_t temperatureDelta)
 Script/demo explosion facade that emits the next command sequence.
 
eve::Result< std::vector< PixelFragment > > extractUnsupportedFragments (PixelRegion region, int supportY, std::uint32_t minimumCells=1)
 Atomically detach unsupported solid components inside a finite region.
 
eve::Result< PixelFragmentRasterReceipt > rasterizeFragment (const PixelFragment &fragment, int originX, int originY)
 Transactionally rasterize a detached fragment at a new world-space origin.
 
PixelWorldLink worldLink () const noexcept
 Current runtime link used for stale fragment detection.
 
void clear () noexcept
 Remove all chunks and reset the simulation tick.
 
eve::Result< StepStats > advance (eve::SimulationTick tick)
 Advance exactly one scheduler-owned tick.
 
eve::Result< StepStats > advanceScheduled (eve::SimulationTick tick, PixelWorkScheduler &scheduler)
 Advance one deterministic tick using a synchronous candidate scheduler.
 
StepStats step ()
 Script/demo facade that advances the next integral tick.
 
void setPaused (bool paused) noexcept
 Pause or resume ordinary simulation entry points without changing state.
 
bool isPaused () const noexcept
 Whether ordinary simulation entry points are currently paused.
 
std::uint64_t seed () const noexcept
 Seed.
 
std::uint64_t revision () const noexcept
 Revision.
 
std::uint64_t tickValue () const noexcept
 Tick value.
 
std::uint64_t lastEditSequence () const noexcept
 Last edit sequence.
 
int chunkCount () const noexcept
 Chunk count.
 
int activeChunkCount () const noexcept
 Active chunk count.
 
std::uint64_t materialCatalogFingerprint () const noexcept
 Fingerprint of the immutable catalog that gives cell ids their meaning.
 
std::vector< PixelChunkSnapshot > snapshotChangedChunks (std::uint64_t sinceRevision) const
 Copy chunks changed after sinceRevision in canonical y/x order.
 
eve::Result< std::vector< PixelChunkSnapshot > > snapshotChunksInRegion (PixelChunkRegion region, std::uint64_t sinceRevision=0) const
 Copy present Chunks and retained tombstones in one finite Chunk-coordinate region.
 
eve::Result< std::vector< PixelChunkDiagnostic > > chunkDiagnostics (PixelChunkRegion region) const
 Query allocated Chunk diagnostics in a bounded inclusive region.
 
eve::Result< PixelChunkApplyReceipt > applyChunkBatch (const PixelChunkBatch &batch, std::uint64_t expectedRevision)
 Transactionally apply a canonical authoritative Chunk correction batch.
 
eve::Result< std::vector< std::byte > > saveSnapshot () const
 Serialize schema eve.pixelworld, version 3, in canonical Chunk order.
 
eve::Result< void > restoreSnapshot (std::span< const std::byte > bytes)
 Transactionally restore a version 1, 2 or 3 PixelWorld snapshot.
 

友元

class PixelWorldControlService
 

详细描述

Sparse, chunked, deterministic 2D falling-material world.

PixelWorld is the sole authority for material state. It is simulation-thread affine and invokes no callbacks. Rendering and physics consume snapshots or queries through adapters; neither owns a mutable copy of the world.

在文件 PixelWorld.h 第 224 行定义.

构造及析构函数说明

◆ PixelWorld() [1/4]

eve::pixelworld::PixelWorld::PixelWorld ( std::uint64_t  seed = 1)
explicit

Construct an empty world with an explicit deterministic seed.

在文件 PixelWorld.cpp 第 384 行定义.

引用了 eve::pixelworld::pixelWorldControlService() , 以及 seed().

◆ PixelWorld() [2/4]

eve::pixelworld::PixelWorld::PixelWorld ( std::uint64_t  seed,
MaterialCatalog  catalog 
)

Construct an empty world owning a validated immutable material catalog.

在文件 PixelWorld.cpp 第 388 行定义.

引用了 eve::pixelworld::pixelWorldControlService() , 以及 seed().

◆ ~PixelWorld()

eve::pixelworld::PixelWorld::~PixelWorld ( )

Pixel world.

在文件 PixelWorld.cpp 第 393 行定义.

引用了 eve::pixelworld::pixelWorldControlService().

◆ PixelWorld() [3/4]

eve::pixelworld::PixelWorld::PixelWorld ( PixelWorld &&  other)
noexcept

Pixel world.

在文件 PixelWorld.cpp 第 396 行定义.

引用了 eve::pixelworld::pixelWorldControlService().

◆ PixelWorld() [4/4]

eve::pixelworld::PixelWorld::PixelWorld ( const PixelWorld &  )
delete

成员函数说明

◆ activeChunkCount()

int eve::pixelworld::PixelWorld::activeChunkCount ( ) const
noexcept

Active chunk count.

在文件 PixelWorld.cpp 第 1328 行定义.

◆ advance()

eve::Result< StepStats > eve::pixelworld::PixelWorld::advance ( eve::SimulationTick  tick)

Advance exactly one scheduler-owned tick.

返回
Deterministic counters for the completed step.

在文件 PixelWorld.cpp 第 761 行定义.

引用了 eve::Result< T >::success() , 以及 tick.

被这些函数引用 step().

◆ advanceScheduled()

eve::Result< StepStats > eve::pixelworld::PixelWorld::advanceScheduled ( eve::SimulationTick  tick,
PixelWorkScheduler &  scheduler 
)

Advance one deterministic tick using a synchronous candidate scheduler.

备注
Simulation-thread affine. Worker callbacks receive owning output slots, never mutate chunks, and are joined before canonical commit.

在文件 PixelWorld.cpp 第 766 行定义.

引用了 eve::Result< T >::success() , 以及 tick.

◆ applyChunkBatch()

eve::Result< PixelChunkApplyReceipt > eve::pixelworld::PixelWorld::applyChunkBatch ( const PixelChunkBatch &  batch,
std::uint64_t  expectedRevision 
)

Transactionally apply a canonical authoritative Chunk correction batch.

参数
batchOwning source metadata and unique y/x-ordered Chunk snapshots.
expectedRevisionCurrent local revision used to reject stale writers.
返回
Commit receipt; any validation failure leaves all world state unchanged.
备注
The source revision, Tick and edit sequence may advance but never rewind. A successful correction invalidates outstanding fragment links by advancing epoch.

在文件 PixelWorld.cpp 第 1440 行定义.

引用了 capacity, eve::pixelworld::PixelChunkBatch::catalogFingerprint, cell, eve::pixelworld::PixelWorld::Impl::chunks, eve::pixelworld::PixelChunkBatch::chunks, eve::pixelworld::PixelChunkApplyReceipt::chunksRemoved, eve::pixelworld::PixelChunkApplyReceipt::chunksReplaced, code, eve::Conflict, eve::pixelworld::PixelWorld::Impl::epoch, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::pixelworld::PixelChunkBatch::fullResync, index, eve::InvalidArgument, eve::pixelworld::kPixelChunkSize, eve::pixelworld::PixelWorld::Impl::lastEditSequence, message, eve::pixelworld::PixelWorld::Impl::nextFragmentId, path, eve::pixelworld::PixelWorld::Impl::paused, previous, eve::pixelworld::PixelWorld::Impl::rebuildActivity(), eve::pixelworld::PixelWorld::Impl::removedChunks, eve::pixelworld::PixelWorld::Impl::revision, eve::pixelworld::PixelChunkApplyReceipt::revisionAfter, eve::pixelworld::PixelChunkApplyReceipt::revisionBefore, eve::pixelworld::PixelChunkBatch::sourceLastEditSequence, eve::pixelworld::PixelChunkBatch::sourceRevision, eve::pixelworld::PixelChunkBatch::sourceSeed, eve::pixelworld::PixelChunkBatch::sourceTick, eve::Result< T >::success(), eve::pixelworld::PixelWorld::Impl::tick, eve::detail::StrongUint64< Tag >::value(), eve::pixelworld::PixelChunkApplyReceipt::worldEpoch , 以及 eve::pixelworld::PixelWorld::Impl::worldId.

被这些函数引用 eve::pixelworld_streaming::ReliablePixelChunkReceiver::receive().

◆ applyEdit()

◆ chunkCount()

int eve::pixelworld::PixelWorld::chunkCount ( ) const
noexcept

Chunk count.

在文件 PixelWorld.cpp 第 1327 行定义.

◆ chunkDiagnostics()

eve::Result< std::vector< PixelChunkDiagnostic > > eve::pixelworld::PixelWorld::chunkDiagnostics ( PixelChunkRegion  region) const

◆ clear()

void eve::pixelworld::PixelWorld::clear ( )
noexcept

Remove all chunks and reset the simulation tick.

在文件 PixelWorld.cpp 第 752 行定义.

◆ explode()

PixelEditReceipt eve::pixelworld::PixelWorld::explode ( int  centerX,
int  centerY,
int  radius,
int  strength,
std::int16_t  temperatureDelta 
)

◆ extractUnsupportedFragments()

eve::Result< std::vector< PixelFragment > > eve::pixelworld::PixelWorld::extractUnsupportedFragments ( PixelRegion  region,
int  supportY,
std::uint32_t  minimumCells = 1 
)

Atomically detach unsupported solid components inside a finite region.

参数
regionInclusive scan bounds; area is limited to prevent accidental unbounded work.
supportYComponents touching this y coordinate or below remain authoritative terrain.
minimumCellsComponents smaller than this remain terrain.
返回
Owning fragments in canonical top-left order. A component touching solid terrain outside region is treated as supported. Failure leaves the world unchanged.

在文件 PixelWorld.cpp 第 618 行定义.

引用了 eve::pixelworld::Air, cell, eve::pixelworld::PixelFragment::cells, code, cx, cy, dx, dy, eve::Diagnostic::error(), height, eve::pixelworld::PixelFragment::height, eve::pixelworld::PixelFragment::id, inside, eve::InvalidArgument, eve::pixelworld::PixelRegion::maxX, eve::pixelworld::PixelRegion::maxY, message, eve::pixelworld::PixelRegion::minX, eve::pixelworld::PixelRegion::minY, nx, ny, eve::pixelworld::PixelFragment::originX, eve::pixelworld::PixelFragment::originY, path, pending, eve::pixelworld::Solid, eve::pixelworld::PixelFragment::solidCellCount, eve::pixelworld::PixelFragment::source, state, width, eve::pixelworld::PixelFragment::width, worldLink(), x , 以及 y.

◆ getCell()

PixelCell eve::pixelworld::PixelWorld::getCell ( int  x,
int  y 
) const
noexcept

Return the cell at world coordinates; absent chunks read as air.

在文件 PixelWorld.cpp 第 407 行定义.

引用了 x , 以及 y.

被这些函数引用 eve::pixelworld_physics::extractTerrainContours(), eve::pixelworld_physics::probeTerrainCircle() , 以及 eve::pixelworld_physics::sweepTerrainCircle().

◆ getMaterial()

int eve::pixelworld::PixelWorld::getMaterial ( int  x,
int  y 
) const
noexcept

Convenience query returning the numeric material id.

在文件 PixelWorld.cpp 第 408 行定义.

引用了 x , 以及 y.

◆ isPaused()

bool eve::pixelworld::PixelWorld::isPaused ( ) const
noexcept

Whether ordinary simulation entry points are currently paused.

在文件 PixelWorld.cpp 第 1321 行定义.

◆ isSolidMaterial()

bool eve::pixelworld::PixelWorld::isSolidMaterial ( MaterialId  material) const
noexcept

Query whether a validated material id participates in structural solid collision.

在文件 PixelWorld.cpp 第 409 行定义.

引用了 material , 以及 eve::pixelworld::Solid.

被这些函数引用 eve::pixelworld_physics::extractTerrainContours(), eve::pixelworld_physics::probeTerrainCircle() , 以及 eve::pixelworld_physics::sweepTerrainCircle().

◆ lastEditSequence()

std::uint64_t eve::pixelworld::PixelWorld::lastEditSequence ( ) const
noexcept

Last edit sequence.

在文件 PixelWorld.cpp 第 1326 行定义.

◆ materialCatalogFingerprint()

std::uint64_t eve::pixelworld::PixelWorld::materialCatalogFingerprint ( ) const
noexcept

Fingerprint of the immutable catalog that gives cell ids their meaning.

在文件 PixelWorld.cpp 第 1333 行定义.

◆ materialDisplayRgba()

std::uint32_t eve::pixelworld::PixelWorld::materialDisplayRgba ( MaterialId  material) const
noexcept

Query the Catalog-owned preview/render color encoded as 0xRRGGBBAA.

在文件 PixelWorld.cpp 第 412 行定义.

引用了 material.

◆ operator=() [1/2]

PixelWorld & eve::pixelworld::PixelWorld::operator= ( const PixelWorld &  )
delete

◆ operator=() [2/2]

PixelWorld & eve::pixelworld::PixelWorld::operator= ( PixelWorld &&  other)
noexcept

Operator =.

在文件 PixelWorld.cpp 第 399 行定义.

引用了 eve::pixelworld::pixelWorldControlService().

◆ paintCircle()

std::size_t eve::pixelworld::PixelWorld::paintCircle ( int  centerX,
int  centerY,
int  radius,
std::string_view  material 
)

Paint a filled material circle and return the number of changed cells.

在文件 PixelWorld.cpp 第 492 行定义.

引用了 material, paintCircleChecked() , 以及 radius.

◆ paintCircleChecked()

eve::Result< std::size_t > eve::pixelworld::PixelWorld::paintCircleChecked ( int  centerX,
int  centerY,
int  radius,
std::string_view  material 
)

Canonical checked circle edit; unknown names leave the world unchanged.

在文件 PixelWorld.cpp 第 497 行定义.

引用了 cell, dx, dy, eve::Result< T >::failure(), id, material, eve::pixelworld::PixelCell::material, radius, setCell(), eve::Result< T >::success(), x , 以及 y.

被这些函数引用 paintCircle().

◆ rasterizeFragment()

◆ reloadMaterialCatalog()

eve::Result< PixelCatalogReloadReceipt > eve::pixelworld::PixelWorld::reloadMaterialCatalog ( MaterialCatalog  catalog,
std::uint64_t  expectedFingerprint 
)

◆ restoreSnapshot()

◆ revision()

std::uint64_t eve::pixelworld::PixelWorld::revision ( ) const
noexcept

Revision.

在文件 PixelWorld.cpp 第 1324 行定义.

被这些函数引用 eve::pixelworld_streaming::ReliablePixelChunkReceiver::receive() , 以及 snapshotChangedChunks().

◆ saveSnapshot()

eve::Result< std::vector< std::byte > > eve::pixelworld::PixelWorld::saveSnapshot ( ) const

Serialize schema eve.pixelworld, version 3, in canonical Chunk order.

在文件 PixelWorld.cpp 第 1532 行定义.

引用了 order.

◆ seed()

std::uint64_t eve::pixelworld::PixelWorld::seed ( ) const
noexcept

Seed.

在文件 PixelWorld.cpp 第 1323 行定义.

被这些函数引用 PixelWorld() , 以及 PixelWorld().

◆ setCell()

void eve::pixelworld::PixelWorld::setCell ( int  x,
int  y,
PixelCell  cell 
)

Set one cell and wake its chunk and neighbors. Air never allocates a missing chunk.

在文件 PixelWorld.cpp 第 469 行定义.

引用了 eve::pixelworld::Air, cell, x , 以及 y.

被这些函数引用 paintCircleChecked() , 以及 setMaterialChecked().

◆ setMaterial()

void eve::pixelworld::PixelWorld::setMaterial ( int  x,
int  y,
std::string_view  material 
)

Set one cell from a stable built-in material name.

在文件 PixelWorld.cpp 第 476 行定义.

引用了 eve::Result< void >::expect(), material, setMaterialChecked(), x , 以及 y.

◆ setMaterialChecked()

eve::Result< void > eve::pixelworld::PixelWorld::setMaterialChecked ( int  x,
int  y,
std::string_view  material 
)

Canonical checked name-based setter; unknown names leave the world unchanged.

在文件 PixelWorld.cpp 第 480 行定义.

引用了 cell, eve::Result< T >::failure(), material, eve::pixelworld::PixelCell::material, setCell(), eve::Result< T >::success(), x , 以及 y.

被这些函数引用 setMaterial().

◆ setPaused()

void eve::pixelworld::PixelWorld::setPaused ( bool  paused)
noexcept

Pause or resume ordinary simulation entry points without changing state.

在文件 PixelWorld.cpp 第 1320 行定义.

◆ snapshotChangedChunks()

std::vector< PixelChunkSnapshot > eve::pixelworld::PixelWorld::snapshotChangedChunks ( std::uint64_t  sinceRevision) const

Copy chunks changed after sinceRevision in canonical y/x order.

备注
Simulation-thread affine. Returned snapshots own their cells and remain valid after mutation, restore, or destruction of this world.

在文件 PixelWorld.cpp 第 1335 行定义.

引用了 eve::pixelworld::PixelChunkSnapshot::cells, order, eve::pixelworld::PixelChunkSnapshot::removed, eve::pixelworld::PixelChunkSnapshot::revision, revision(), eve::pixelworld::PixelChunkSnapshot::x , 以及 eve::pixelworld::PixelChunkSnapshot::y.

◆ snapshotChunksInRegion()

eve::Result< std::vector< PixelChunkSnapshot > > eve::pixelworld::PixelWorld::snapshotChunksInRegion ( PixelChunkRegion  region,
std::uint64_t  sinceRevision = 0 
) const

Copy present Chunks and retained tombstones in one finite Chunk-coordinate region.

参数
regionInclusive bounds limited to 65536 Chunk coordinates.
sinceRevisionOnly projections newer than this revision are returned.
返回
Canonical y/x-ordered owning projections, or bounded-input failure.

在文件 PixelWorld.cpp 第 1363 行定义.

引用了 eve::pixelworld::PixelChunkSnapshot::cells, eve::Diagnostic::error(), height, eve::InvalidArgument, eve::pixelworld::PixelChunkRegion::maxX, eve::pixelworld::PixelChunkRegion::maxY, eve::pixelworld::PixelChunkRegion::minX, eve::pixelworld::PixelChunkRegion::minY, removed, eve::pixelworld::PixelChunkSnapshot::revision, width, x, eve::pixelworld::PixelChunkSnapshot::x, y , 以及 eve::pixelworld::PixelChunkSnapshot::y.

◆ step()

StepStats eve::pixelworld::PixelWorld::step ( )

Script/demo facade that advances the next integral tick.

在文件 PixelWorld.cpp 第 1315 行定义.

引用了 advance().

◆ tickValue()

std::uint64_t eve::pixelworld::PixelWorld::tickValue ( ) const
noexcept

Tick value.

在文件 PixelWorld.cpp 第 1325 行定义.

◆ worldLink()

PixelWorldLink eve::pixelworld::PixelWorld::worldLink ( ) const
noexcept

Current runtime link used for stale fragment detection.

在文件 PixelWorld.cpp 第 750 行定义.

被这些函数引用 extractUnsupportedFragments() , 以及 rasterizeFragment().

友元及相关函数文档

◆ PixelWorldControlService

friend class PixelWorldControlService
friend

在文件 PixelWorld.h 第 373 行定义.


该类的文档由以下文件生成: