Skip to main content

RenderableComponent Class

Component that holds a shared pointer to a Renderable resource. More...

Declaration

class helios::engine::modules::rendering::renderable::components::RenderableComponent { ... }

Base class

classCloneableComponent<Derived>

CRTP base class for components that support cloning. More...

Public Constructors Index

RenderableComponent (std::shared_ptr< helios::rendering::Renderable > renderable)

Constructs a RenderableComponent. More...

RenderableComponent (const RenderableComponent &other)

Copy Constructor. More...

Public Member Functions Index

voidonAttach (helios::engine::ecs::GameObject *gameObject) noexcept override

Called when the component is attached to a GameObject. More...

std::shared_ptr< helios::rendering::Renderable >renderable () const noexcept

Retrieves the stored Renderable. More...

Private Member Attributes Index

std::shared_ptr< helios::rendering::Renderable >renderable_

Shared pointer to the renderable resource. More...

helios::math::aabbfaabb_ {}

The initial AABB of the model associated with the renderable. More...

Description

Component that holds a shared pointer to a Renderable resource.

This component links a GameObject to a visual representation (Renderable). When attached, it automatically extracts the AABB from the renderable's mesh and populates a ModelAabbComponent on the same GameObject.

Definition at line 30 of file RenderableComponent.ixx.

Public Constructors

RenderableComponent()

helios::engine::modules::rendering::renderable::components::RenderableComponent::RenderableComponent (std::shared_ptr< helios::rendering::Renderable > renderable)
inline explicit

Constructs a RenderableComponent.

Parameters
renderable

Shared pointer to the Renderable. Must not be nullptr.

Definition at line 49 of file RenderableComponent.ixx.

49 explicit RenderableComponent(std::shared_ptr<helios::rendering::Renderable> renderable) :
50 renderable_(std::move(renderable)) {
51
52 assert(renderable_ != nullptr && "renderable must not be nullptr");
53 aabb_ = renderable_->renderPrototype()
54 ? renderable_->renderPrototype()->mesh().aabb()
56
57 }

Reference renderable.

Referenced by RenderableComponent.

RenderableComponent()

helios::engine::modules::rendering::renderable::components::RenderableComponent::RenderableComponent (const RenderableComponent & other)
inline explicit

Copy Constructor.

Definition at line 62 of file RenderableComponent.ixx.

62 explicit RenderableComponent(const RenderableComponent& other) :
63 renderable_(std::move(other.renderable_)), aabb_(other.aabb_) {}

Reference RenderableComponent.

Public Member Functions

onAttach()

void helios::engine::modules::rendering::renderable::components::RenderableComponent::onAttach (helios::engine::ecs::GameObject * gameObject)
inline noexcept virtual

Called when the component is attached to a GameObject.

Automatically adds or retrieves a ModelAabbComponent on the GameObject and initializes it with the captured AABB from the Renderable.

Parameters
gameObject

Pointer to the parent GameObject.

Definition at line 75 of file RenderableComponent.ixx.

76 Component::onAttach(gameObject);
77
79
80 msc.setAabb(aabb_);
81 }

References helios::engine::ecs::Component::gameObject and helios::engine::modules::rendering::model::components::ModelAabbComponent::setAabb.

renderable()

std::shared_ptr< helios::rendering::Renderable > helios::engine::modules::rendering::renderable::components::RenderableComponent::renderable ()
inline nodiscard noexcept

Retrieves the stored Renderable.

Returns

Shared pointer to the Renderable.

Definition at line 88 of file RenderableComponent.ixx.

88 [[nodiscard]] std::shared_ptr<helios::rendering::Renderable> renderable() const noexcept {
89 return renderable_;
90 }

Referenced by RenderableComponent.

Private Member Attributes

aabb_

helios::math::aabbf helios::engine::modules::rendering::renderable::components::RenderableComponent::aabb_ {}

The initial AABB of the model associated with the renderable.

Definition at line 40 of file RenderableComponent.ixx.

renderable_

std::shared_ptr<helios::rendering::Renderable> helios::engine::modules::rendering::renderable::components::RenderableComponent::renderable_

Shared pointer to the renderable resource.

Definition at line 35 of file RenderableComponent.ixx.

35 std::shared_ptr<helios::rendering::Renderable> renderable_;

The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.