Skip to main content

MeshRenderable Class

Represents a renderable object that combines a shared prototype with instance-specific overrides. More...

Declaration

class helios::rendering::mesh::MeshRenderable { ... }

Base class

classRenderable

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...

boolhasMaterialOverride () 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...

voidwriteUniformValues (helios::rendering::shader::UniformValueMap &uniformValueMap) const noexcept override

Writes uniform values into the given map. More...

voidemit (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

renderPrototype()

info

For text rendering, use `TextRenderable` instead.

See Also

RenderPrototype

See Also

RenderCommand

See Also

MaterialShaderPropertiesOverride

Definition at line 73 of file MeshRenderable.ixx.

Public Constructors

MeshRenderable()

helios::rendering::mesh::MeshRenderable::MeshRenderable ()
delete

Deleted default constructor.

Definition at line 97 of file MeshRenderable.ixx.

Referenced by MeshRenderable, MeshRenderable, MeshRenderable, operator= and operator=.

MeshRenderable()

helios::rendering::mesh::MeshRenderable::MeshRenderable (const MeshRenderable &)
delete

Deleted copy constructor.

Definition at line 102 of file MeshRenderable.ixx.

Reference MeshRenderable.

MeshRenderable()

helios::rendering::mesh::MeshRenderable::MeshRenderable (MeshRenderable &&)
noexcept default

Defaulted move constructor.

Definition at line 112 of file MeshRenderable.ixx.

Reference MeshRenderable.

MeshRenderable()

helios::rendering::mesh::MeshRenderable::MeshRenderable (std::shared_ptr< const helios::rendering::RenderPrototype > renderPrototype, const std::optional< helios::rendering::material::MaterialShaderPropertiesOverride > & materialOverride=std::nullopt)
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.

129 std::shared_ptr<const helios::rendering::RenderPrototype> renderPrototype,
130 const std::optional<helios::rendering::material::MaterialShaderPropertiesOverride>& materialOverride = std::nullopt
131 ) :
134 {
135
136 if (!renderPrototype_) {
137 const std::string msg = "MeshRenderable constructor received a null shared pointer.";
138 logger_.error(msg);
139 throw std::invalid_argument(msg);
140 }
141
142 }

References logger_, materialOverride, materialOverride_, MeshRenderable, renderPrototype and renderPrototype_.

Public Operators

operator=()

MeshRenderable & helios::rendering::mesh::MeshRenderable::operator= (const MeshRenderable &)
delete

Deleted copy assignment operator.

Definition at line 107 of file MeshRenderable.ixx.

Reference MeshRenderable.

operator=()

MeshRenderable & helios::rendering::mesh::MeshRenderable::operator= (MeshRenderable &&)
noexcept default

Defaulted move assignment operator.

Definition at line 117 of file MeshRenderable.ixx.

Reference MeshRenderable.

Public Member Functions

emit()

void helios::rendering::mesh::MeshRenderable::emit (helios::rendering::RenderQueue & renderQueue, helios::rendering::shader::UniformValueMap & objectUniformValues, helios::rendering::shader::UniformValueMap & materialUniformValues)
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.

237 void emit(
240 helios::rendering::shader::UniformValueMap& materialUniformValues) const override {
241
242 writeUniformValues(materialUniformValues);
243
245 renderPrototype_.get(),
246 objectUniformValues,
247 materialUniformValues
248 ));
249 };

References helios::rendering::RenderQueue::add, renderPrototype_ and writeUniformValues.

hasMaterialOverride()

bool helios::rendering::mesh::MeshRenderable::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.

196 [[nodiscard]] bool hasMaterialOverride() const noexcept {
197 return materialOverride_.has_value();
198 }

Reference materialOverride_.

localAABB()

const helios::math::aabbf & helios::rendering::mesh::MeshRenderable::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.

207 [[nodiscard]] const helios::math::aabbf& localAABB() const noexcept override {
208 return renderPrototype_->mesh().aabb();
209 }

Reference renderPrototype_.

materialOverride()

const std::optional< helios::rendering::material::MaterialShaderPropertiesOverride > & helios::rendering::mesh::MeshRenderable::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.

175 [[nodiscard]] const std::optional<helios::rendering::material::MaterialShaderPropertiesOverride>& materialOverride() const noexcept {
176 return materialOverride_;
177 }

Reference materialOverride_.

Referenced by MeshRenderable.

materialOverride()

std::optional< helios::rendering::material::MaterialShaderPropertiesOverride > & helios::rendering::mesh::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.

187 [[nodiscard]] std::optional<helios::rendering::material::MaterialShaderPropertiesOverride>& materialOverride() noexcept {
188 return materialOverride_;
189 }

Reference materialOverride_.

renderPrototype()

const helios::rendering::RenderPrototype * helios::rendering::mesh::MeshRenderable::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.

162 [[nodiscard]] const helios::rendering::RenderPrototype* renderPrototype() const noexcept {
163 return renderPrototype_.get();
164 }

Reference renderPrototype_.

Referenced by MeshRenderable.

shareRenderPrototype()

std::shared_ptr< const helios::rendering::RenderPrototype > helios::rendering::mesh::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.

150 [[nodiscard]] std::shared_ptr<const helios::rendering::RenderPrototype> shareRenderPrototype() const noexcept {
151 return renderPrototype_;
152 }

Reference renderPrototype_.

writeUniformValues()

void helios::rendering::mesh::MeshRenderable::writeUniformValues (helios::rendering::shader::UniformValueMap & uniformValueMap)
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.

219 void writeUniformValues(helios::rendering::shader::UniformValueMap& uniformValueMap) const noexcept override {
220 renderPrototype_->material().writeUniformValues(uniformValueMap);
221
223 materialOverride_->writeUniformValues(uniformValueMap);
224 }
225 }

References materialOverride_ and renderPrototype_.

Referenced by emit.

Protected Member Attributes

materialOverride_

std::optional<helios::rendering::material::MaterialShaderPropertiesOverride> helios::rendering::mesh::MeshRenderable::materialOverride_
protected

The MaterialShaderPropertiesOverride owned by this class. This will be std::nullopt if not available.

Definition at line 86 of file MeshRenderable.ixx.

86 std::optional<helios::rendering::material::MaterialShaderPropertiesOverride> materialOverride_;

Referenced by hasMaterialOverride, materialOverride, materialOverride, MeshRenderable and writeUniformValues.

renderPrototype_

std::shared_ptr<const helios::rendering::RenderPrototype> helios::rendering::mesh::MeshRenderable::renderPrototype_ = nullptr
protected

Shared pointer to the immutable RenderPrototype definition.

Definition at line 80 of file MeshRenderable.ixx.

80 std::shared_ptr<const helios::rendering::RenderPrototype> renderPrototype_ = nullptr;

Referenced by emit, localAABB, MeshRenderable, renderPrototype, shareRenderPrototype and writeUniformValues.

Protected Static Attributes

logger_

const helios::util::log::Logger& helios::rendering::mesh::MeshRenderable::logger_ = helios::util::log::LogManager::loggerForScope(HELIOS_LOG_SCOPE)
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.