Two-dimensional array container for grid-based data in procedural generation.
More...
|
| | Array2D () |
| | Default constructor.
|
| |
| | Array2D (size_t width, size_t height) |
| | Constructs a 2D array with specified dimensions.
|
| |
| | Array2D (size_t width, size_t height, Array< T > data) |
| | Constructs a 2D array from existing Array data with specified dimensions.
|
| |
| | Array2D (size_t width, size_t height, T *data) |
| | Constructs a 2D array by copying from a raw data pointer.
|
| |
| | Array2D (size_t colStride, const std::vector< T > &data) |
| | Constructs a 2D array from a 1D vector with column stride.
|
| |
| virtual | ~Array2D () |
| | Destructor.
|
| |
| std::unique_ptr< Core::Base > | clone () const override |
| |
| const Infinity::Types::TypeID & | typeId () const override |
| | Gets the TypeID for this Array2D type.
|
| |
| size_t | width () const noexcept |
| | Gets the width (number of columns) of the 2D array.
|
| |
| size_t | height () const noexcept |
| | Gets the height (number of rows) of the 2D array.
|
| |
| T & | at (size_t x, size_t y) |
| | Accesses element at 2D coordinates.
|
| |
| const T & | at (size_t x, size_t y) const |
| | Accesses element at 2D coordinates (const).
|
| |
| virtual size_t | dimensions () const noexcept override |
| | Gets the number of dimensions in this container.
|
| |
| void | resize (size_t width, size_t height) |
| | Resizes the 2D array to new dimensions.
|
| |
| | Array () |
| | Default constructor.
|
| |
| | Array (size_t size) |
| | Constructs an array with specified size.
|
| |
| | Array (const T *data, size_t size) |
| | Constructs an array by copying data from a raw pointer.
|
| |
| | Array (const std::vector< T > &data) |
| | Constructs an array from a std::vector.
|
| |
| | Array (Core::span< T > data) |
| | Constructs an array from a span.
|
| |
| | Array (const Array &other) |
| | Copy constructor.
|
| |
| | Array (Array &&other) noexcept |
| | Move constructor.
|
| |
| virtual | ~Array () |
| | Destructor.
|
| |
| Array & | operator= (const Array &rhs) |
| | Copy assignment operator.
|
| |
| Array & | operator= (Array &&rhs) noexcept |
| | Move assignment operator.
|
| |
| virtual const Infinity::Types::TypeID & | elementTypeId () override |
| | Gets the TypeID for the element type.
|
| |
| void | copy (const T *data, size_t count) |
| | Replaces array contents by copying from raw data.
|
| |
| T & | operator[] (size_t index) |
| | Accesses element at specified index (unchecked).
|
| |
| const T & | operator[] (size_t index) const |
| | Accesses element at specified index (unchecked, const).
|
| |
| T & | at (size_t index) |
| | Accesses element at specified index (checked).
|
| |
| const T & | at (size_t index) const |
| | Accesses element at specified index (checked, const).
|
| |
| void | push_back (const T &value) |
| | Appends an element to the end of the array.
|
| |
| template<typename... Args> |
| void | emplace_back (Args &&... args) |
| | Constructs and appends an element in-place.
|
| |
| void | insert (size_t index, const T &value) |
| | Inserts an element at the specified position.
|
| |
| void | erase (size_t index) |
| | Removes the element at the specified position.
|
| |
| void | reserve (size_t capacity) |
| | Reserves capacity for at least the specified number of elements.
|
| |
| virtual void | resize (size_t newSize) override |
| | Resizes the array to contain the specified number of elements.
|
| |
| void | shrink_to_fit () |
| | Reduces capacity to match the current size.
|
| |
| void | clear () noexcept |
| | Removes all elements from the array.
|
| |
| virtual bool | containsData () const override |
| | Checks if the array contains Core::Data-derived types.
|
| |
| virtual bool | containsValues () const override |
| | Checks if the array contains plain value types.
|
| |
| virtual std::shared_ptr< Core::Data > | dataAt (size_t index) override |
| | Gets a type-erased Data pointer to the element at the specified index.
|
| |
| virtual std::shared_ptr< const Core::Data > | dataAt (size_t index) const override |
| | Gets a const type-erased Data pointer to the element at the specified index.
|
| |
| virtual void | setData (size_t index, const Core::Data &data) override |
| | Sets an element from type-erased Data.
|
| |
| T * | data () |
| | Gets a pointer to the underlying data array.
|
| |
| const T * | data () const |
| | Gets a const pointer to the underlying data array.
|
| |
| T * | releaseData () |
| | Releases ownership of the underlying data array.
|
| |
| T & | front () |
| | Accesses the first element.
|
| |
| const T & | front () const |
| | Accesses the first element (const).
|
| |
| T & | back () |
| | Accesses the last element.
|
| |
| const T & | back () const |
| | Accesses the last element (const).
|
| |
| size_t | size () const noexcept override |
| | Gets the number of elements in the array.
|
| |
| size_t | capacity () const noexcept |
| | Gets the current capacity.
|
| |
| bool | empty () const noexcept |
| | Checks if the array is empty.
|
| |
| virtual void * | pointer (size_t index) override |
| | Gets a void pointer to the element at the specified index.
|
| |
| virtual const void * | pointer (size_t index) const override |
| | Gets a const void pointer to the element at the specified index.
|
| |
| iterator | begin () noexcept |
| | Returns an iterator to the beginning.
|
| |
| iterator | end () noexcept |
| | Returns an iterator to the end.
|
| |
| const_iterator | begin () const noexcept |
| | Returns a const iterator to the beginning.
|
| |
| const_iterator | end () const noexcept |
| | Returns a const iterator to the end.
|
| |
| reverse_iterator | rbegin () noexcept |
| | Returns a reverse iterator to the beginning.
|
| |
| reverse_iterator | rend () noexcept |
| | Returns a reverse iterator to the end.
|
| |
| const_reverse_iterator | rbegin () const noexcept |
| | Returns a const reverse iterator to the beginning.
|
| |
| const_reverse_iterator | rend () const noexcept |
| | Returns a const reverse iterator to the end.
|
| |
| | ArrayBase () |
| |
| | ArrayBase (const ArrayBase &other) |
| |
| virtual | ~ArrayBase ()=default |
| | Virtual destructor.
|
| |
| | Data () |
| |
| | Data (const Data &other) |
| |
| | Data (Data &&other) |
| |
| Data & | operator= (const Data &other) |
| |
| Data & | operator= (Data &&other) |
| |
| std::unique_ptr< Base > | clone () const override |
| |
| virtual | ~Data () |
| | Virtual destructor.
|
| |
| bool | hasProperty (const std::string &key) const |
| |
| template<typename T > |
| void | setProperty (const std::string &key, T &&value) |
| | Sets a typed property value.
|
| |
| template<typename T > |
| void | setProperty (const std::string &key, const T &value) |
| | Sets a typed property value.
|
| |
| void | setProperty (const std::string &key, PropertyValue &&value) |
| | Sets a typed property value.
|
| |
| const PropertyValue & | getProperty (const std::string &key) const |
| | Gets a property value without type checking.
|
| |
| template<typename T > |
| const T & | getProperty (const std::string &key) const |
| | Gets a typed property value.
|
| |
| void | removeProperty (const std::string &key) |
| |
| virtual | ~Base () |
| | Virtual destructor.
|
| |
| virtual std::istream & | legibleDataRead (std::istream &in) override |
| | Deserializes the object from a single-line text representation.
|
| |
| virtual std::ostream & | legibleDataWrite (std::ostream &out) const override |
| | Serializes the object to a single-line text representation.
|
| |
template<typename T>
class Infinity::Types::Containers::Array2D< T >
Two-dimensional array container for grid-based data in procedural generation.
Array2D<T> extends Array<T> to provide a 2D grid abstraction with row-major storage. It is the fundamental container for image-like data in the Infinity Engine, including textures, heightmaps, masks, and other spatially-organized data structures.
The class stores elements in row-major order (rows are contiguous in memory), making it cache-friendly for row-wise traversal. All underlying memory management, alignment, and type system integration is inherited from Array<T>.
Key features:
- 2D indexing with at(x, y) for intuitive spatial access
- Type aliases for common procedural generation data (Texture, Heightmap, Mask, etc.)
- Inherits all Array<T> capabilities (serialization, iteration, SIMD alignment)
- Seamless integration with ProceduralSystem input/output ports
- Support for both scalar and vector element types
Common use cases in procedural generation:
- Heightmaps for terrain generation
- Texture synthesis and manipulation
- Masks for spatial blending and selection
- Splatmaps for multi-material terrain
- Noise field storage
- Per-pixel procedural effects
- Template Parameters
-
| T | Element type (typically scalar or vector types) |
- Note
- Storage is row-major: element at (x, y) is at index y * width + x
-
All memory is 64-byte aligned (inherited from Array<T>)
Example usage:
for (size_t y = 0; y < heightmap.height(); ++y) {
for (size_t x = 0; x < heightmap.width(); ++x) {
heightmap.at(x, y) = generateHeight(x, y);
}
}
system->setIn("terrain_heightmap", std::move(heightmap));
Array2D<Math::Vector4ub> texture(1024, 1024);
Mask blendMask(512, 512);
Two-dimensional array container for grid-based data in procedural generation.
Definition Array2D.hpp:82
Array2D< float > Mask
Single-channel float mask for spatial blending and selection.
Definition Array2D.hpp:354
Array2D< float > Heightmap
Single-channel float heightmap for terrain generation.
Definition Array2D.hpp:336
Array2D< uint8_t > Splatmap
8-bit splatmap for terrain material blending.
Definition Array2D.hpp:285
Array2D< Math::Vector4ub > Texture
Default texture type (RGBA, 8-bit per channel).
Definition Array2D.hpp:327
Template structure representing a 4-component vector.
Definition Vector4.hpp:85