Skip to main content

ScaleSystem Class

System that applies scaling to entities based on their ScaleStateComponent. More...

Declaration

class helios::engine::modules::spatial::transform::systems::ScaleSystem { ... }

Public Member Typedefs Index

usingEngineRoleTag = helios::engine::common::tags::SystemRole

Public Member Functions Index

voidupdate (helios::engine::runtime::world::UpdateContext &updateContext) noexcept

Updates scale for all entities with dirty ScaleComponents. More...

Description

System that applies scaling to entities based on their ScaleStateComponent.

This system converts the desired world-space dimensions from ScaleStateComponent into scale factors relative to the model's original AABB. It handles unit conversion (e.g., centimeters to meters) based on the ScaleStateComponent's unit.

Required components:

  • ScaleStateComponent (desired dimensions and unit)
  • ModelAabbComponent (original model bounds)
  • ComposeTransformComponent (receives scale updates)

Definition at line 44 of file ScaleSystem.ixx.

Public Member Typedefs

EngineRoleTag

using helios::engine::modules::spatial::transform::systems::ScaleSystem::EngineRoleTag = helios::engine::common::tags::SystemRole

Public Member Functions

update()

void helios::engine::modules::spatial::transform::systems::ScaleSystem::update (helios::engine::runtime::world::UpdateContext & updateContext)
inline noexcept

Updates scale for all entities with dirty ScaleComponents.

For each entity with the required components, calculates the scale factor needed to resize the model from its original dimensions to the desired world-space dimensions.

Parameters
updateContext

Context containing deltaTime and other frame data.

Definition at line 59 of file ScaleSystem.ixx.

60
61 for (auto [entity, mab, sc, tc, active] : updateContext.view<
66 >().whereEnabled()) {
67
68 if (!sc->isDirty()) {
69 continue;
70 }
71
72 // Get current model size and desired size
73 auto cscale = mab->aabb().size();
74 auto wscale = sc->scaling();
75
76 auto currentScale = tc->localScaling();
77
78 auto unit = sc->unit();
79
80 // Calculate scale factors: desired_size / current_size
81 // Convert desired size to engine units (meters)
82 auto scale = helios::math::vec3f{
83 wscale[0] != 0 && cscale[0] != 0 ? helios::core::units::from(wscale[0], unit) / cscale[0] : currentScale[0],
84 wscale[1] != 0 && cscale[1] != 0 ? helios::core::units::from(wscale[1], unit) / cscale[1] : currentScale[1],
85 wscale[2] != 0 && cscale[2] != 0 ? helios::core::units::from(wscale[2], unit) / cscale[2] : currentScale[2]
86 };
87
88 tc->setLocalScale(scale);
89 }
90 }

Reference helios::core::units::from.


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.