Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::Components::DirectionalLight Class Reference

Runtime directional light component mirrored into ECS for renderer queries. More...

#include <DirectionalLightComponent.h>

Inheritance diagram for Engine::Components::DirectionalLight:
Collaboration diagram for Engine::Components::DirectionalLight:

Public Member Functions

 DirectionalLight (Entities::Scene *owningScene, const glm::vec3 &color=glm::vec3(1.0f), float intensity=1.0f, bool castsShadows=true, float angularDiameterDegrees=0.53f)
 Creates a directional light component.
std::string getComponentName () const override
 Gets the component type name for debugging/UI.
void beginPlay () override
 Called when the component is added to the scene or the game starts.
void endPlay () override
 Called when the component is removed or the game ends.
const glm::vec3 & getColor () const
 Gets the light color multiplier.
float getIntensity () const
 Gets the light intensity.
bool isEnabled () const
 Checks whether this light is enabled for rendering.
bool castsShadows () const
 Checks whether this light casts shadows.
float getAngularDiameterDegrees () const
 Gets the apparent angular diameter used for light softness.
const glm::vec3 & getDirectionOverride () const
 Gets the explicit light direction override.
bool hasDirectionOverride () const
 Checks whether an explicit light direction override is active.
const std::string & getDebugName () const
 Gets the optional debug name appended to the component name.
const std::string & getDisableReason () const
 Gets the reason this light was disabled.
bool hasDisableReason () const
 Checks whether a disable reason is set.
void setColor (const glm::vec3 &color)
 Sets the light color multiplier and syncs ECS data.
void setIntensity (float intensity)
 Sets the light intensity and syncs ECS data.
void setEnabled (bool enabled)
 Enables or disables the light and syncs ECS data.
void setCastsShadows (bool castsShadows)
 Enables or disables shadow casting and syncs ECS data.
void setAngularDiameterDegrees (float angularDiameterDegrees)
 Sets the apparent angular diameter and syncs ECS data.
void setDirectionOverride (const glm::vec3 &direction)
 Sets an explicit normalized light direction and syncs ECS data.
void clearDirectionOverride ()
 Clears the explicit light direction override and syncs ECS data.
void setDebugName (std::string name)
 Sets the debug name appended to the component name.
void setDisableReason (std::string reason)
 Sets the reason this light is disabled.
void clearDisableReason ()
 Clears the stored disable reason.
Public Member Functions inherited from Engine::Components::Logic
 Logic (Entities::Scene *owningScene)
 Constructs a logic component owned by a scene.
 Logic (const Entities::SpawnContext &context)
 Constructs a logic component from spawn context data.
virtual ~Logic ()=default
 Destroys the logic component.
virtual bool drawImGui ()
 Draws component-specific ImGui inspector controls.
virtual bool drawImGuiName ()
 Used to alter the name of the entity in the outliner.
virtual void tick (double deltaTime)
 Called every frame if ticking is enabled.
bool hasBegunPlay () const
 Checks whether beginPlay() has been called without a matching endPlay().
bool canTick () const
 Checks if the component is currently set to tick.
void setCanTick (bool enable)
 Enables or disables ticking for this component.
Entities::Entity * getOwningEntity () const
 Gets the entity this component belongs to.

Static Public Attributes

static constexpr bool IsUnique = true
 Only one directional light may be active per entity.
static constexpr const char * ComponentName = "DirectionalLight"
 Component type name.
Static Public Attributes inherited from Engine::Components::Logic
static constexpr bool IsUnique = false
 Defines whether multiple instances of this component can exist on the same entity. Defaults to false (multiple allowed). Override in derived classes with static constexpr bool IsUnique = true; if needed.
static constexpr const char * ComponentName = "Logic"
 Fallback component type name. Derived classes may override getComponentName() for custom labels.

Private Member Functions

bool hasActiveEnabledConflict () const
void disableIfConflicting ()
void syncEcsData () const

Private Attributes

std::string debugName_
std::string disableReason_
glm::vec3 color_ { 1.0f }
float intensity_ = 1.0f
bool enabled_ = true
bool castsShadows_ = true
bool hasDirectionOverride_ = false
glm::vec3 directionOverride_ { 0.0f, -1.0f, 0.0f }
float angularDiameterDegrees_ = 0.53f

Additional Inherited Members

Protected Member Functions inherited from Engine::Components::Logic
Entities::Scene * getScene () const
 Gets the scene this component belongs to.
Core::SceneManager * getSceneManager () const
 Helper to get the SceneManager from the owning scene.

Detailed Description

Runtime directional light component mirrored into ECS for renderer queries.

Definition at line 13 of file DirectionalLightComponent.h.

Constructor & Destructor Documentation

◆ DirectionalLight()

Engine::Components::DirectionalLight::DirectionalLight ( Entities::Scene * owningScene,
const glm::vec3 & color = glm::vec3(1.0f),
float intensity = 1.0f,
bool castsShadows = true,
float angularDiameterDegrees = 0.53f )
explicit

Creates a directional light component.

Parameters
owningSceneScene that owns the component.
colorLight color multiplier.
intensityNon-negative light intensity.
castsShadowsTrue when the light should cast shadows.
angularDiameterDegreesApparent angular diameter used for soft lighting.

References castsShadows().

Here is the call graph for this function:

Member Function Documentation

◆ beginPlay()

void Engine::Components::DirectionalLight::beginPlay ( )
overridevirtual

Called when the component is added to the scene or the game starts.

Reimplemented from Engine::Components::Logic.

◆ castsShadows()

bool Engine::Components::DirectionalLight::castsShadows ( ) const
inlinenodiscard

Checks whether this light casts shadows.

Returns
True when shadow casting is enabled.

Definition at line 62 of file DirectionalLightComponent.h.

References castsShadows_.

Referenced by DirectionalLight(), and setCastsShadows().

Here is the caller graph for this function:

◆ clearDirectionOverride()

void Engine::Components::DirectionalLight::clearDirectionOverride ( )

Clears the explicit light direction override and syncs ECS data.

◆ clearDisableReason()

void Engine::Components::DirectionalLight::clearDisableReason ( )

Clears the stored disable reason.

◆ disableIfConflicting()

void Engine::Components::DirectionalLight::disableIfConflicting ( )
private

◆ endPlay()

void Engine::Components::DirectionalLight::endPlay ( )
overridevirtual

Called when the component is removed or the game ends.

Reimplemented from Engine::Components::Logic.

◆ getAngularDiameterDegrees()

float Engine::Components::DirectionalLight::getAngularDiameterDegrees ( ) const
inlinenodiscard

Gets the apparent angular diameter used for light softness.

Returns
Angular diameter in degrees.

Definition at line 68 of file DirectionalLightComponent.h.

References angularDiameterDegrees_.

◆ getColor()

const glm::vec3 & Engine::Components::DirectionalLight::getColor ( ) const
inlinenodiscard

Gets the light color multiplier.

Returns
Current RGB color.

Definition at line 44 of file DirectionalLightComponent.h.

References color_.

◆ getComponentName()

std::string Engine::Components::DirectionalLight::getComponentName ( ) const
nodiscardoverridevirtual

Gets the component type name for debugging/UI.

Returns
The component display name.

Reimplemented from Engine::Components::Logic.

◆ getDebugName()

const std::string & Engine::Components::DirectionalLight::getDebugName ( ) const
inlinenodiscard

Gets the optional debug name appended to the component name.

Returns
Debug name string.

Definition at line 86 of file DirectionalLightComponent.h.

References debugName_.

◆ getDirectionOverride()

const glm::vec3 & Engine::Components::DirectionalLight::getDirectionOverride ( ) const
inlinenodiscard

Gets the explicit light direction override.

Returns
Normalized direction override.

Definition at line 74 of file DirectionalLightComponent.h.

References directionOverride_.

◆ getDisableReason()

const std::string & Engine::Components::DirectionalLight::getDisableReason ( ) const
inlinenodiscard

Gets the reason this light was disabled.

Returns
Disable reason string, or empty if none is set.

Definition at line 92 of file DirectionalLightComponent.h.

References disableReason_.

◆ getIntensity()

float Engine::Components::DirectionalLight::getIntensity ( ) const
inlinenodiscard

Gets the light intensity.

Returns
Current non-negative intensity.

Definition at line 50 of file DirectionalLightComponent.h.

References intensity_.

◆ hasActiveEnabledConflict()

bool Engine::Components::DirectionalLight::hasActiveEnabledConflict ( ) const
nodiscardprivate

◆ hasDirectionOverride()

bool Engine::Components::DirectionalLight::hasDirectionOverride ( ) const
inlinenodiscard

Checks whether an explicit light direction override is active.

Returns
True when direction override is active.

Definition at line 80 of file DirectionalLightComponent.h.

References hasDirectionOverride_.

◆ hasDisableReason()

bool Engine::Components::DirectionalLight::hasDisableReason ( ) const
inlinenodiscard

Checks whether a disable reason is set.

Returns
True when a disable reason is available.

Definition at line 98 of file DirectionalLightComponent.h.

References disableReason_.

◆ isEnabled()

bool Engine::Components::DirectionalLight::isEnabled ( ) const
inlinenodiscard

Checks whether this light is enabled for rendering.

Returns
True when enabled.

Definition at line 56 of file DirectionalLightComponent.h.

References enabled_.

◆ setAngularDiameterDegrees()

void Engine::Components::DirectionalLight::setAngularDiameterDegrees ( float angularDiameterDegrees)

Sets the apparent angular diameter and syncs ECS data.

Parameters
angularDiameterDegreesNew angular diameter in degrees, clamped to a non-negative value.

◆ setCastsShadows()

void Engine::Components::DirectionalLight::setCastsShadows ( bool castsShadows)

Enables or disables shadow casting and syncs ECS data.

Parameters
castsShadowsTrue to cast shadows.

References castsShadows().

Here is the call graph for this function:

◆ setColor()

void Engine::Components::DirectionalLight::setColor ( const glm::vec3 & color)

Sets the light color multiplier and syncs ECS data.

Parameters
colorNew RGB color.

◆ setDebugName()

void Engine::Components::DirectionalLight::setDebugName ( std::string name)

Sets the debug name appended to the component name.

Parameters
nameNew debug name.

◆ setDirectionOverride()

void Engine::Components::DirectionalLight::setDirectionOverride ( const glm::vec3 & direction)

Sets an explicit normalized light direction and syncs ECS data.

Parameters
directionDirection to use instead of the owning node direction.

◆ setDisableReason()

void Engine::Components::DirectionalLight::setDisableReason ( std::string reason)

Sets the reason this light is disabled.

Parameters
reasonNew disable reason.

◆ setEnabled()

void Engine::Components::DirectionalLight::setEnabled ( bool enabled)

Enables or disables the light and syncs ECS data.

Parameters
enabledTrue to enable the light.

◆ setIntensity()

void Engine::Components::DirectionalLight::setIntensity ( float intensity)

Sets the light intensity and syncs ECS data.

Parameters
intensityNew intensity, clamped to a non-negative value.

◆ syncEcsData()

void Engine::Components::DirectionalLight::syncEcsData ( ) const
private

Member Data Documentation

◆ angularDiameterDegrees_

float Engine::Components::DirectionalLight::angularDiameterDegrees_ = 0.53f
private

Definition at line 171 of file DirectionalLightComponent.h.

Referenced by getAngularDiameterDegrees().

◆ castsShadows_

bool Engine::Components::DirectionalLight::castsShadows_ = true
private

Definition at line 168 of file DirectionalLightComponent.h.

Referenced by castsShadows().

◆ color_

glm::vec3 Engine::Components::DirectionalLight::color_ { 1.0f }
private

Definition at line 165 of file DirectionalLightComponent.h.

Referenced by getColor().

◆ ComponentName

const char* Engine::Components::DirectionalLight::ComponentName = "DirectionalLight"
staticconstexpr

Component type name.

Definition at line 17 of file DirectionalLightComponent.h.

◆ debugName_

std::string Engine::Components::DirectionalLight::debugName_
private

Definition at line 163 of file DirectionalLightComponent.h.

Referenced by getDebugName().

◆ directionOverride_

glm::vec3 Engine::Components::DirectionalLight::directionOverride_ { 0.0f, -1.0f, 0.0f }
private

Definition at line 170 of file DirectionalLightComponent.h.

Referenced by getDirectionOverride().

◆ disableReason_

std::string Engine::Components::DirectionalLight::disableReason_
private

Definition at line 164 of file DirectionalLightComponent.h.

Referenced by getDisableReason(), and hasDisableReason().

◆ enabled_

bool Engine::Components::DirectionalLight::enabled_ = true
private

Definition at line 167 of file DirectionalLightComponent.h.

Referenced by isEnabled().

◆ hasDirectionOverride_

bool Engine::Components::DirectionalLight::hasDirectionOverride_ = false
private

Definition at line 169 of file DirectionalLightComponent.h.

Referenced by hasDirectionOverride().

◆ intensity_

float Engine::Components::DirectionalLight::intensity_ = 1.0f
private

Definition at line 166 of file DirectionalLightComponent.h.

Referenced by getIntensity().

◆ IsUnique

bool Engine::Components::DirectionalLight::IsUnique = true
staticconstexpr

Only one directional light may be active per entity.

Definition at line 16 of file DirectionalLightComponent.h.


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