AtlasChunk Class Reference [Atlas Core]

#include <atlasChunk.h>

Inheritance diagram for AtlasChunk:

Inheritance graph
[legend]
List of all members.

Detailed Description

Base class for paged Atlas data.

Atlas is primarily a system for paging data to/from disk. As a result we draw a distinction between stubs (in-core data) and chunks (out-of-core data). Stubs are always present and provide basic information about the data in the chunk. For instance, a geometry stub might store the bounds, while the corresponding geometry chunk might store the vertex and primitive buffers.


Public Types

 MaxChunkSize = 8 * 1024 * 1024
 Maximum size chunk we support reading/writing.
enum  { MaxChunkSize = 8 * 1024 * 1024 }

Public Member Functions

 AtlasChunk ()
virtual ~AtlasChunk ()
virtual void write (Stream *s)
 Serialize this chunk to a stream.
virtual void read (Stream *s)
 Deserialize from a stream.
virtual void process ()
 Once the chunk has been loaded (in another thread), this is called in the main thread to prepare any complex resources.
virtual void generate (AtlasChunk *children[4])
 Given four children, (re)generate the data for this one.
Sentinel Interface
To make sure we don't have read/write mismatches, we write a sentinel value before and after the chunk. This is unique for each type to ensure we don't mis-read a chunk. Chunk sentinel functionality is implemented by writeToFile and readFromStream.

virtual U32 getHeadSentinel ()
virtual U32 getTailSentinel ()

Static Public Member Functions

Static IO Interface
These helper functions allow us to read and write AtlasChunks in a standardized way. They deal with reading headers, comparing sentinels, filling in ADIOs, and so forth.

Most of the time these functions are used for chunk IO, rather than a chunk's read/write.

static U32 writeToStream (AtlasChunk *ac, Stream *s)
 This is not currently used; consider prepareDeferredWrite().
static bool readFromStream (AtlasChunk *ac, Stream *s)
static AtlasDeferredIOprepareDeferredWrite (AtlasChunk *ac)
 Allocate and prepare a new ADIO which contains a serialized version of this chunk.

Public Attributes

U32 mChunkSize
 Size in bytes of this chunk.
U32 mPreviousChunk
 Offset in file to previous chunk, if any.
AtlasTOCmOwningTOC
 The TOC to which we belong.


Member Enumeration Documentation

anonymous enum

Enumerator:
MaxChunkSize  Maximum size chunk we support reading/writing.

This is just so we can have some fixed buffers and avoid some chicken-and-egg stuff.

Note:
You may have to change this if you have large chunks.


Constructor & Destructor Documentation

AtlasChunk::AtlasChunk (  )  [inline]

virtual AtlasChunk::~AtlasChunk (  )  [virtual]


Member Function Documentation

static U32 AtlasChunk::writeToStream ( AtlasChunk ac,
Stream s 
) [static]

This is not currently used; consider prepareDeferredWrite().

static bool AtlasChunk::readFromStream ( AtlasChunk ac,
Stream s 
) [static]

static AtlasDeferredIO* AtlasChunk::prepareDeferredWrite ( AtlasChunk ac  )  [static]

Allocate and prepare a new ADIO which contains a serialized version of this chunk.

virtual void AtlasChunk::write ( Stream s  )  [virtual]

Serialize this chunk to a stream.

See also:
You probably want to use prepareDeferredWrite()

Reimplemented in AtlasConfigChunk, AtlasGeomChunk, and AtlasTexChunk.

virtual void AtlasChunk::read ( Stream s  )  [virtual]

Deserialize from a stream.

See also:
You probably want to use readFromStream()

Reimplemented in AtlasConfigChunk, AtlasGeomChunk, and AtlasTexChunk.

virtual void AtlasChunk::process (  )  [virtual]

Once the chunk has been loaded (in another thread), this is called in the main thread to prepare any complex resources.

(For instance, a texture or VB, that depend on access to GFX to initialize.)

Reimplemented in AtlasConfigChunk, AtlasGeomChunk, and AtlasTexChunk.

virtual void AtlasChunk::generate ( AtlasChunk children[4]  )  [virtual]

Given four children, (re)generate the data for this one.

Their order starts at topleft, clockwise, 0123.

Reimplemented in AtlasConfigChunk, AtlasGeomChunk, and AtlasTexChunk.

virtual U32 AtlasChunk::getHeadSentinel (  )  [virtual]

virtual U32 AtlasChunk::getTailSentinel (  )  [virtual]


Member Data Documentation

Size in bytes of this chunk.

First word written, so we can rapidly load the chunk from disk in a single block, then process from memory.

Offset in file to previous chunk, if any.

Used to backtrack for undo, history analysis, etc.

The TOC to which we belong.