MeshRenderable Class
Represents a renderable object that combines a shared prototype with instance-specific overrides. More...
Declaration
Base class
| class | Renderable |
|
Abstract base class for objects that can be rendered by the rendering system. More... | |
Public Constructors Index
| MeshRenderable ()=delete | |
|
Deleted default constructor. More... | |
| MeshRenderable (const MeshRenderable &)=delete | |
|
Deleted copy constructor. More... | |
| MeshRenderable (MeshRenderable &&) noexcept=default | |
|
Defaulted move constructor. More... | |
| MeshRenderable (std::shared_ptr< const helios::rendering::RenderPrototype > renderPrototype, const std::optional< helios::rendering::material::MaterialShaderPropertiesOverride > &materialOverride=std::nullopt) | |
|
Creates a new MeshRenderable instance. More... | |
Public Operators Index
| MeshRenderable & | operator= (const MeshRenderable &)=delete |
|
Deleted copy assignment operator. More... | |
| MeshRenderable & | operator= (MeshRenderable &&) noexcept=default |
|
Defaulted move assignment operator. More... | |
Public Member Functions Index
| std::shared_ptr< const helios::rendering::RenderPrototype > | shareRenderPrototype () const noexcept |
|
Returns a shared pointer to the RenderPrototype used by this MeshRenderable. More... | |
| const helios::rendering::RenderPrototype * | renderPrototype () const noexcept |
|
Returns a raw pointer to the RenderPrototype used by this MeshRenderable. More... | |
| const std::optional< helios::rendering::material::MaterialShaderPropertiesOverride > & | materialOverride () const noexcept |
|
Returns a const reference to the optional instance-specific MaterialShaderPropertiesOverride. More... | |
| std::optional< helios::rendering::material::MaterialShaderPropertiesOverride > & | materialOverride () noexcept |
|
Returns a non-const reference to the optional instance-specific MaterialShaderPropertiesOverride. More... | |
| bool | hasMaterialOverride () const noexcept |
|
Returns true if this MeshRenderable was configured with a MaterialShaderPropertiesOverride. More... | |
| const helios::math::aabbf & | localAABB () const noexcept override |
|
Returns the local-space axis-aligned bounding box. More... | |
| void | writeUniformValues (helios::rendering::shader::UniformValueMap &uniformValueMap) const noexcept override |
|
Writes uniform values into the given map. More... | |
| void | emit (helios::rendering::RenderQueue &renderQueue, helios::rendering::shader::UniformValueMap &objectUniformValues, helios::rendering::shader::UniformValueMap &materialUniformValues) const override |
|
Emits a mesh render command to the render queue. More... | |
Protected Member Attributes Index
| std::shared_ptr< const helios::rendering::RenderPrototype > | renderPrototype_ = nullptr |
|
Shared pointer to the immutable RenderPrototype definition. More... | |
| std::optional< helios::rendering::material::MaterialShaderPropertiesOverride > | materialOverride_ |
|
The MaterialShaderPropertiesOverride owned by this class. This will be std::nullopt if not available. More... | |
Protected Static Attributes Index
| static const helios::util::log::Logger & | logger_ = helios::util::log::LogManager::loggerForScope(HELIOS_LOG_SCOPE) |
|
Shared logger instance for all MeshRenderable objects. More... | |
Description
Represents a renderable object that combines a shared prototype with instance-specific overrides.
A `MeshRenderable` aggregates an immutable `RenderPrototype` (shared asset definition) with optional instance-specific `MaterialShaderPropertiesOverride`. This separation enables efficient batching of shared prototypes while allowing per-instance visual adjustments.
## Design
- **Shared Prototype:** Multiple `MeshRenderable` instances can reference the same `RenderPrototype`.
- **Per-Instance Overrides:** Each instance can customize material properties.
- **Move-Only:** Prevents accidental duplication during render queue processing.
## Data Flow
``` RenderPrototype (shared) │ ├── MeshRenderable A (override: red color) ├── MeshRenderable B (override: blue color) └── MeshRenderable C (no override) ```
## Performance Considerations
**PERF-NOTE: shared_ptr overhead**
The `renderPrototype_` member uses `std::shared_ptr`, which incurs atomic reference counting overhead on every copy. In the hot rendering path, consider:
- Returning `const RenderPrototype&` instead of `std::shared_ptr` from getters when ownership transfer is not required.
- Using `std::shared_ptr<T>::get()` for temporary access instead of copying the shared_ptr.
- Evaluating whether `std::unique_ptr` with raw pointer access would suffice if the prototype lifetime is well-defined (e.g., asset manager ownership).
- See Also
For text rendering, use `TextRenderable` instead.
- See Also
- See Also
RenderCommand
- See Also
MaterialShaderPropertiesOverride
Definition at line 73 of file MeshRenderable.ixx.
Public Constructors
MeshRenderable()
| delete |
Deleted default constructor.
Definition at line 97 of file MeshRenderable.ixx.
Referenced by MeshRenderable, MeshRenderable, MeshRenderable, operator= and operator=.
MeshRenderable()
| delete |
Deleted copy constructor.
Definition at line 102 of file MeshRenderable.ixx.
Reference MeshRenderable.
MeshRenderable()
| noexcept default |
Defaulted move constructor.
Definition at line 112 of file MeshRenderable.ixx.
Reference MeshRenderable.
MeshRenderable()
| inline explicit |
Creates a new MeshRenderable instance.
- Parameters
-
renderPrototype A shared pointer to the immutable RenderPrototype definition. Must not be nullptr.
materialOverride An optional set of instance-specific material property overrides. If std::nullopt, the MeshRenderable uses only the default properties from the RenderPrototype's Material.
- Exceptions
-
std::invalid_argument if `renderPrototype` is a nullptr.
Definition at line 128 of file MeshRenderable.ixx.
References logger_, materialOverride, materialOverride_, MeshRenderable, renderPrototype and renderPrototype_.
Public Operators
operator=()
| delete |
Deleted copy assignment operator.
Definition at line 107 of file MeshRenderable.ixx.
Reference MeshRenderable.
operator=()
| noexcept default |
Defaulted move assignment operator.
Definition at line 117 of file MeshRenderable.ixx.
Reference MeshRenderable.
Public Member Functions
emit()
| inline virtual |
Emits a mesh render command to the render queue.
Creates a `MeshRenderCommand` with the render prototype and uniform values, then adds it to the render queue for processing by the rendering device.
- Parameters
-
renderQueue The render queue to emit the command to.
objectUniformValues Object-specific uniform values (e.g., model matrix).
materialUniformValues Material uniform values (will be merged with material properties).
Definition at line 237 of file MeshRenderable.ixx.
References helios::rendering::RenderQueue::add, renderPrototype_ and writeUniformValues.
hasMaterialOverride()
| inline nodiscard noexcept |
Returns true if this MeshRenderable was configured with a MaterialShaderPropertiesOverride.
- Returns
True if this MeshRenderable was configured with a MaterialShaderPropertiesOverride instance, otherwise false.
Definition at line 196 of file MeshRenderable.ixx.
Reference materialOverride_.
localAABB()
| inline nodiscard noexcept virtual |
Returns the local-space axis-aligned bounding box.
Delegates to the underlying mesh's AABB from the render prototype.
- Returns
A const reference to the local-space AABB.
Definition at line 207 of file MeshRenderable.ixx.
Reference renderPrototype_.
materialOverride()
| inline nodiscard noexcept |
Returns a const reference to the optional instance-specific MaterialShaderPropertiesOverride.
This allows read-only access to the overrides. Use `.has_value()` to check for existence and `.value()` or `->` to safely access the override data.
- Returns
A const reference to the std::optional<MaterialShaderPropertiesOverride>.
Definition at line 175 of file MeshRenderable.ixx.
Reference materialOverride_.
Referenced by MeshRenderable.
materialOverride()
| inline nodiscard noexcept |
Returns a non-const reference to the optional instance-specific MaterialShaderPropertiesOverride.
This allows modification of the overrides. If the optional currently has no value, it can be assigned to or `.emplace()` can be used to create a new MaterialShaderPropertiesOverride.
- Returns
A non-const reference to the std::optional<MaterialShaderPropertiesOverride>.
Definition at line 187 of file MeshRenderable.ixx.
Reference materialOverride_.
renderPrototype()
| inline nodiscard noexcept |
Returns a raw pointer to the RenderPrototype used by this MeshRenderable.
This method provides direct access to the prototype without incrementing the reference count, making it suitable for use in hot rendering paths.
- Returns
A raw pointer to the RenderPrototype (never null after construction).
Definition at line 162 of file MeshRenderable.ixx.
Reference renderPrototype_.
Referenced by MeshRenderable.
shareRenderPrototype()
| inline nodiscard noexcept |
Returns a shared pointer to the RenderPrototype used by this MeshRenderable.
- Returns
A shared pointer to the RenderPrototype.
Definition at line 150 of file MeshRenderable.ixx.
Reference renderPrototype_.
writeUniformValues()
| inline noexcept virtual |
Writes uniform values into the given map.
This method first applies the default uniform values from the base Material definition and then overlays any specific overrides provided by this instance's MaterialShaderPropertiesOverride.
- Parameters
-
uniformValueMap Target map receiving the uniform values.
Definition at line 219 of file MeshRenderable.ixx.
References materialOverride_ and renderPrototype_.
Referenced by emit.
Protected Member Attributes
materialOverride_
| protected |
The MaterialShaderPropertiesOverride owned by this class. This will be std::nullopt if not available.
Definition at line 86 of file MeshRenderable.ixx.
Referenced by hasMaterialOverride, materialOverride, materialOverride, MeshRenderable and writeUniformValues.
renderPrototype_
| protected |
Shared pointer to the immutable RenderPrototype definition.
Definition at line 80 of file MeshRenderable.ixx.
Referenced by emit, localAABB, MeshRenderable, renderPrototype, shareRenderPrototype and writeUniformValues.
Protected Static Attributes
logger_
| protected static |
Shared logger instance for all MeshRenderable objects.
Definition at line 91 of file MeshRenderable.ixx.
Referenced by MeshRenderable.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.