Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
ToyMaker::ViewportNode Class Reference

A type of node capable of and responsible for interacting sensibly with the engine's RenderSystem and ECSWorlds. More...

#include <scene_system.hpp>

Inheritance diagram for ToyMaker::ViewportNode:
ToyMaker::BaseSceneNode< ViewportNode > ToyMaker::Resource< ViewportNode > ToyMaker::SceneNodeCore ToyMaker::IResource

Classes

struct  RenderConfiguration
 A collection of data that specifies the behaviour and properties of the RenderSystem and target texture associated with this viewport. More...
 
struct  ViewportChildComp_
 Comparator used for determining priority of descendant viewports owned by a RenderSet::RenderType::ADDITION viewport. More...
 

Public Member Functions

void viewNextDebugTexture ()
 Sets the next debug texture listed in this viewport's render set to the texture considered "active" by it.
 
void updateExposure (float newExposure)
 Updates the exposure of this viewport's RenderSet.
 
void updateGamma (float newGamma)
 Updates the gamma value of this viewport's RenderSet.
 
float getExposure ()
 Gets the exposure value used by this viewport's RenderSet.
 
float getGamma ()
 Gets the gamma value used by this viewport's RenderSet.
 
std::shared_ptr< ViewportNodegetLocalViewport () override
 Returns this viewport instead of base class return value.
 
virtual std::shared_ptr< const ViewportNodegetLocalViewport () const override
 Returns this viewport instead of base class return value.
 
std::shared_ptr< TexturefetchRenderResult (float simulationProgress)
 Fetches the render result for the most recently computed render frame.
 
void setActiveCamera (const std::string &cameraPath)
 Sets the active camera for this viewport's RenderSet via path to the camera node.
 
void setActiveCamera (std::shared_ptr< SceneNodeCore > cameraNode)
 Sets the active camera for this viewport's RenderSet via a reference to the camera node.
 
RenderConfiguration getRenderConfiguration () const
 Gets the render configuration for this viewport.
 
void setRenderConfiguration (const RenderConfiguration &renderConfiguration)
 Sets the render configuration for this viewport.
 
void setSkybox (std::shared_ptr< Texture > skybox)
 Sets the skybox texture for this object's RenderSystem.
 
void setResizeType (RenderConfiguration::ResizeType type)
 Sets this viewport's behaviour when request dimensions (or target dimensions) are changed.
 
void setResizeMode (RenderConfiguration::ResizeMode mode)
 When resize is enabled, determines how resized render dimensions are computed.
 
void setRenderScale (float renderScale)
 Sets the scale relative to computed and design dimensions for the render pipeline target.
 
void setUpdateMode (RenderConfiguration::UpdateMode updateMode)
 Sets the behaviour for frequency of render updates w.r.t render requests.
 
void setFPSCap (float fpsCap)
 If an FPS capped update mode is selected, sets what that cap actually is.
 
void requestDimensions (glm::u16vec2 requestedDimensions)
 Target dimensions that another part of the program specifies for this viewport.
 
ActionDispatchgetActionDispatch ()
 Gets the action dispatch object for this viewport, which is the central location from which all actions received by this viewport are distributed to their respective action handlers.
 
bool handleAction (std::pair< ActionDefinition, ActionData > pendingAction)
 Handles an action received by this viewport, generally by dispatching it to subscribed listeners and propagating the action down to descendant viewports and their listeners.
 
bool disallowsHandledActionPropagation () const
 Returns whether an action handled by one of this viewport's (high precedence) child viewports, should be sent to this viewports other children.
 
 ~ViewportNode () override
 Destroys this viewport object.
 
uint32_t getViewportLoadOrdinal () const
 (When this viewport is the immediate descendant of a RenderSet::RenderType::ADDITION viewport) The precedence of this viewport relative to other immediate descendants of its parent viewport.
 
- Public Member Functions inherited from ToyMaker::SceneNodeCore
virtual ~SceneNodeCore ()=default
 Destroys SceneNodeCore.
 
template<typename TComponent>
void addComponent (const TComponent &component, const bool bypassSceneActivityCheck=false)
 Adds a component of type TComponent to the node.
 
void addComponent (const nlohmann::json &jsonComponent, const bool bypassSceneActivityCheck=false)
 Adds a component to the node.
 
template<typename TComponent>
TComponent getComponent (const float simulationProgress=1.f) const
 Retrieves a component belonging to this node.
 
template<typename TComponent>
bool hasComponent () const
 Tests whether this node has a component of a specific type.
 
bool hasComponent (const std::string &type) const
 Tests whether this node has a component of a specific type.
 
template<typename TComponent>
void updateComponent (const TComponent &component)
 Updates the value of a component of this node (to what it should be at the start of the next simulation step).
 
void updateComponent (const nlohmann::json &component)
 Updates the value of a component of this node (to what it should be at the start of the next simulation step).
 
template<typename TComponent>
void addOrUpdateComponent (const TComponent &component, const bool bypassSceneActivityCheck=false)
 A method for adding a component or updating a component if that component is already present on this node.
 
void addOrUpdateComponent (const nlohmann::json &component, const bool bypassSceneActivityCheck=false)
 A method for adding a component, or updating a component if the same type of component is already present on this node.
 
template<typename TComponent>
void removeComponent ()
 Removes a component present on this node.
 
template<typename TSystem>
void setEnabled (bool state)
 Sets whether or not a given system should be able to influence this scene object.
 
template<typename TSystem>
bool getEnabled () const
 Returns whether a particular system has been enabled for this node.
 
EntityID getEntityID () const
 Returns the entity id associated with these scene node.
 
WorldID getWorldID () const
 Returns the ID of the ECSWorld this node belongs to.
 
UniversalEntityID getUniversalEntityID () const
 Gets the UniversalEntityID aka the world-entity-id pair associated with this node.
 
std::weak_ptr< ECSWorldgetWorld () const
 Gets a reference to the ECSWorld this node belongs to.
 
bool inScene () const
 Returns whether this node is present as part of the SceneSystem's scene tree.
 
bool isActive () const
 Returns whether this node is present as part of the SceneSystem's scene tree, AND is active there as well.
 
bool isAncestorOf (std::shared_ptr< const SceneNodeCore > sceneNode) const
 Tests whether a particular scene node is the ancestor of this one.
 
bool hasNode (const std::string &pathToChild) const
 Tests whether a node specified by some path relative to this node is a real descendant of this node.
 
void addNode (std::shared_ptr< SceneNodeCore > node, const std::string &where)
 Adds a node (or a tree of them) as a child of the node specified by the path in the argument.
 
std::vector< std::shared_ptr< SceneNodeCore > > getChildren ()
 Returns a list of all of this node's immediate children scene nodes.
 
std::vector< std::shared_ptr< const SceneNodeCore > > getChildren () const
 Returns a list of all of this node's immediate children scene nodes.
 
std::vector< std::shared_ptr< SceneNodeCore > > getDescendants ()
 Gets all of the descendant nodes belonging to this scene node.
 
template<typename TObject = std::shared_ptr<SceneNode>>
TObject getByPath (const std::string &where)
 Gets a reference to a node or related object by its path.
 
template<typename TSceneNode = SceneNode>
std::shared_ptr< TSceneNode > getNodeByID (EntityID entityID)
 Gets a pointer to a node by its EntityID, assuming that node and this one belong to the same ECSWorld.
 
std::string getPathFromAncestor (std::shared_ptr< const SceneNodeCore > ancestor) const
 Gets the path from a node (assumed to be an ancestor) to this node.
 
std::shared_ptr< SceneNodeCoregetNode (const std::string &where)
 Gets a reference to a scene node (of any valid type) based on its path relative to this node.
 
std::shared_ptr< SceneNodeCoregetParentNode ()
 Gets the parent node of this node, if one is present.
 
std::shared_ptr< const SceneNodeCoregetParentNode () const
 Gets (a constant reference to) the parent node of this node, if one is present.
 
std::shared_ptr< SceneNodeCoreremoveNode (const std::string &where)
 Removes a node from the tree present at the path specified.
 
std::vector< std::shared_ptr< SceneNodeCore > > removeChildren ()
 Disconnects and removes all the child nodes attached to this node.
 
std::string getName () const
 Returns the name string for this node.
 
void setName (const std::string &name)
 Sets the name of this node.
 
std::string getViewportLocalPath () const
 Gets the path of this node relative to its local viewport node.
 
void setPrototype_ (std::shared_ptr< SceneNodeCore > prototype)
 A reference to the node which was used in order to construct this one.
 
template<>
void setEnabled (bool state)
 
template<>
void removeComponent ()
 
template<>
void removeComponent ()
 
template<>
void removeComponent ()
 
template<>
void setEnabled (bool)
 
template<>
void updateComponent (const AxisAlignedBounds &axisAlignedBoxBounds)
 
template<>
void updateComponent (const ObjectBounds &objectBounds)
 
template<>
void removeComponent ()
 
template<>
void removeComponent ()
 
- Public Member Functions inherited from ToyMaker::Resource< ViewportNode >
std::string getResourceTypeName_ () const override
 Get the resource type string for this resource.
 
- Public Member Functions inherited from ToyMaker::IResource
virtual ~IResource ()=default
 Destroy the IResource object.
 

Static Public Member Functions

static std::shared_ptr< ViewportNodecreate (const std::string &name, bool inheritsWorld, bool allowActionFlowThrough, const RenderConfiguration &renderConfiguration, std::shared_ptr< Texture > skybox)
 Creates a viewport node with components essential to it.
 
static std::shared_ptr< ViewportNodecreate (const nlohmann::json &sceneNodeDescription)
 Creates a viewport node based on its JSON description.
 
static std::shared_ptr< ViewportNodecopy (const std::shared_ptr< const ViewportNode > other)
 Copies the properties and components of another viewport and uses them to construct a new one.
 
static std::string getResourceTypeName ()
 Gets the resource type string associated with the ViewportNode.
 
- Static Public Member Functions inherited from ToyMaker::SceneNodeCore
static void SceneNodeCore_del_ (SceneNodeCore *sceneNode)
 Deleter for a managed pointer to a scene node which ensures its onDestroyed virtual function gets called.
 

Protected Member Functions

 ViewportNode (const Placement &placement, const std::string &name)
 
 ViewportNode (const nlohmann::json &jsonSceneNode)
 
 ViewportNode (const ViewportNode &sceneObject)
 
void onActivated () override
 Override which for a viewport sets its active camera, and initializes the ECSWorld owned by this viewport.
 
void onDeactivated () override
 Deactivates this viewports ECSWorld (if there is one) when this ViewportNode is retired.
 
void joinWorld (ECSWorld &world) override
 Joins this node's entity to a world (either its own or its parent viewport's).
 
- Protected Member Functions inherited from ToyMaker::BaseSceneNode< ViewportNode >
 BaseSceneNode (const Key &key, const Placement &placement, const std::string &name, TComponents...components)
 Constructor for a single node of a subclass.
 
 BaseSceneNode (const Placement &placement, const std::string &name, TComponents...components)
 General constructor for a single node of a subclass.
 
 BaseSceneNode (const nlohmann::json &nodeDescription)
 Constructs a new node of a certain type based on its json description.
 
 BaseSceneNode (const SceneNodeCore &other)
 Constructs a new node of a certain type as a copy of another node.
 
- Protected Member Functions inherited from ToyMaker::SceneNodeCore
template<typename ... TComponents>
 SceneNodeCore (const Placement &placement, const std::string &name, TComponents...components)
 Constructs a scene node object from essential and extra components.
 
 SceneNodeCore (const nlohmann::json &jsonSceneNode)
 Constructs a node based on its description of JSON, later verifying that essential components are present.
 
 SceneNodeCore (const SceneNodeCore &sceneObject)
 Constructs a new node as a copy of another node.
 
virtual void onCreated ()
 Copy assignment operator.
 
virtual void onDestroyed ()
 Scene node lifecycle hook for when a node (and possibly its descendants) are about to be destroyed.
 
- Protected Member Functions inherited from ToyMaker::Resource< ViewportNode >
 Resource (int explicitlyInitializeMe)
 Construct a new resource object.
 
- Protected Member Functions inherited from ToyMaker::IResource
 IResource ()=default
 Construct a new IResource object.
 

Protected Attributes

std::shared_ptr< ECSWorldmOwnWorld { nullptr }
 The ECS world owned by this viewport (if any), as well as the world this node is a member of.
 

Private Member Functions

 ViewportNode (const Key &key, const Placement &placement, const std::string &name)
 Constructs a new ViewportNode using a simplified constructor.
 
std::shared_ptr< SceneNodeCoreclone () const override
 Creates a new ViewportNode using itself as a template.
 
void createAndJoinWorld ()
 Creates and joins its own ECSWorld.
 
void registerDomainCamera (std::shared_ptr< SceneNodeCore > cameraNode)
 Registers a camera that belongs to this viewport, which is a descendant of it and not a descendant of any of its child viewports.
 
void unregisterDomainCamera (std::shared_ptr< SceneNodeCore > cameraNode)
 Removes a camera from this viewport's domain.
 
std::shared_ptr< SceneNodeCorefindFallbackCamera ()
 
std::vector< std::shared_ptr< ViewportNode > > getActiveDescendantViewports ()
 Gets active descendant viewports (in DFS order) under this Viewport.
 
std::vector< std::weak_ptr< ECSWorld > > getActiveDescendantWorlds ()
 Gets weak references to ECSWorlds belonging to descendant viewports.
 
uint32_t render (float simulationProgress, uint32_t variableStep)
 Requests execution of the render pipeline.
 
void render_ (float simulationProgress)
 Implementation responsible for actually computing a new render frame.
 
SDL_Rect getCenteredViewportCoordinates () const
 Gets the region of this viewport's target texture that the rendered texture should be mapped to.
 

Static Private Member Functions

static std::shared_ptr< ViewportNodecreate (const Key &key, const std::string &name, bool inheritsWorld, const RenderConfiguration &renderConfiguration, std::shared_ptr< Texture > skybox)
 Identical to the other create() method, but a private version for use in coupled classes.
 

Private Attributes

uint32_t mViewportLoadOrdinal { std::numeric_limits<uint32_t>::max() }
 Number dictating when this viewport should be computed relative to other viewports, especially when it is used by a RenderSet::RenderType::ADDITION viewport parent.
 
uint32_t mNLifetimeChildrenAdded { 0 }
 A number that is incremented whenever a child viewport is added to this viewport, guaranteeing uniqueness in child viewport values.
 
ActionDispatch mActionDispatch {}
 Dispatcher for received actions to their action handlers within the domain of this viewport.
 
bool mActionFlowthrough { false }
 Whether or not handled actions are propagated to this viewport's descendant viewports.
 
bool mPreventHandledActionPropagation { true }
 When a child viewport handles an action, determines whether the action is sent along to this viewports other children.
 
std::set< std::shared_ptr< ViewportNode >, ViewportChildComp_mChildViewports {}
 This viewports children viewport, in the order they were added to this viewport.
 
std::shared_ptr< SceneNodeCoremActiveCamera { nullptr }
 The active camera node associated with this viewport.
 
std::set< std::shared_ptr< SceneNodeCore >, std::owner_less< std::shared_ptr< SceneNodeCore > > > mDomainCameras {}
 The set of all active cameras that belong to the domain owned by this viewport.
 
RenderSetID mRenderSet
 The ID of the RenderSet registered with this viewport's RenderSystem corresponding to this ViewportNode.
 
std::shared_ptr< TexturemTextureResult { nullptr }
 The result of rendering from running the rendering pipeline associated with this viewport.
 
RenderConfiguration mRenderConfiguration {}
 The render configuration associated with this viewport.
 
uint32_t mTimeSinceLastRender { static_cast<uint32_t>(1000/mRenderConfiguration.mFPSCap) }
 The time, in milliseconds, since the last time a render request was honoured by this viewport.
 

Friends

class BaseSceneNode< ViewportNode >
 
class SceneNodeCore
 
class SceneSystem
 

Additional Inherited Members

- Static Protected Member Functions inherited from ToyMaker::BaseSceneNode< ViewportNode >
static std::shared_ptr< ViewportNodecreate (const Key &, const Placement &placement, const std::string &name, TComponents...components)
 A (private) method for the creation of a new scene node for a particular type.
 
static std::shared_ptr< ViewportNodecreate (const Placement &placement, const std::string &name, TComponents...components)
 A method for creating a scene node of a specific type (TSceneNode)
 
static std::shared_ptr< ViewportNodecreate (const nlohmann::json &sceneNodeDescription)
 Creates a scene node of a type based on its description in JSON.
 
static std::shared_ptr< ViewportNodecopy (const std::shared_ptr< const ViewportNode > sceneNode)
 Creates a scene node of a specific type based on another node of that type.
 
- Static Protected Member Functions inherited from ToyMaker::SceneNodeCore
static std::shared_ptr< SceneNodeCorecopy (const std::shared_ptr< const SceneNodeCore > other)
 Creates a new scene tree by copying another scene node and its descendants.
 
static void validateName (const std::string &nodeName)
 Tests whether a given name is actually valid, throwing an error when it is not.
 
- Static Protected Member Functions inherited from ToyMaker::IResource
template<typename TResource>
static void RegisterResource ()
 Registers this resource as a Resource type with the ResourceDatabase.
 

Detailed Description

A type of node capable of and responsible for interacting sensibly with the engine's RenderSystem and ECSWorlds.

It is the only type of node (at present) to be able to create an ECSWorld of its own. Any ECSWorld thus made will have its Entitys, Systems, and ComponentArrays isolated from those of any other ECSWorld.

It also provides an interface for modifying the behaviour and properties of the RenderSystem and target texture associated with this viewport. Should serve as the primary interface between a game/application developer and the render system.

Remarks
The root node of the SceneSystem is a ViewportNode.
See also
ViewportNodeFromDescription

Constructor & Destructor Documentation

◆ ~ViewportNode()

ViewportNode::~ViewportNode ( )
override

Destroys this viewport object.

NOTE: This works under the assumption that only this place has references to its descendant nodes. If the children are referenced elsewhere, they will be in an invalid state

TODO: Make a more involved deletion that takes into account the possibility that a descendant viewport shares a world with this node, or that one of this node's children is being used elsewhere.

◆ ViewportNode()

ToyMaker::ViewportNode::ViewportNode ( const Key & key,
const Placement & placement,
const std::string & name )
inlineprivate

Constructs a new ViewportNode using a simplified constructor.

Parameters
keyPrivate struct available to only the SceneSystem and closely coupled classes.
placementThe position of the ViewportNode, as far as that goes.
nameThe name of this viewport.

Member Function Documentation

◆ clone()

std::shared_ptr< SceneNodeCore > ViewportNode::clone ( ) const
overrideprivatevirtual

Creates a new ViewportNode using itself as a template.

Returns
std::shared_ptr<SceneNodeCore> The newly constructed ViewportNode

Reimplemented from ToyMaker::SceneNodeCore.

◆ copy()

std::shared_ptr< ViewportNode > ViewportNode::copy ( const std::shared_ptr< const ViewportNode > other)
static

Copies the properties and components of another viewport and uses them to construct a new one.

Parameters
otherThe viewport being used as the basis for a new viewport.
Returns
std::shared_ptr<ViewportNode> The new viewport created.

◆ create() [1/3]

std::shared_ptr< ViewportNode > ViewportNode::create ( const Key & key,
const std::string & name,
bool inheritsWorld,
const RenderConfiguration & renderConfiguration,
std::shared_ptr< Texture > skybox )
staticprivate

Identical to the other create() method, but a private version for use in coupled classes.

Parameters
keyA reference to a private struct available only to the scene system and related classes and functions.
nameThe name of this viewport.
inheritsWorldWhether this viewport joins its parent's ECSWorld or creates its own.
renderConfigurationThe render configuration for this viewport.
skyboxThe skybox to be rendered in the background of this Viewport.
Returns
std::shared_ptr<ViewportNode> The newly constructed ViewportNode.

◆ create() [2/3]

std::shared_ptr< ViewportNode > ViewportNode::create ( const nlohmann::json & sceneNodeDescription)
static

Creates a viewport node based on its JSON description.

Parameters
sceneNodeDescriptionA description of the viewport's parameters and components in JSON.
Returns
std::shared_ptr<ViewportNode> The newly created viewport.
See also
ViewportNodeFromDescription
create()

◆ create() [3/3]

std::shared_ptr< ViewportNode > ViewportNode::create ( const std::string & name,
bool inheritsWorld,
bool allowActionFlowThrough,
const RenderConfiguration & renderConfiguration,
std::shared_ptr< Texture > skybox )
static

Creates a viewport node with components essential to it.

Parameters
nameThe name of the viewport.
inheritsWorldWhether it ought to use the same world as its parent viewport or create its own.
allowActionFlowThroughWhether actions generated by the InputManager are propagated to descendant viewports.
renderConfigurationThe render configuration for this viewport.
skyboxA skybox, if any, used as the background for this viewport's geometry.
Returns
std::shared_ptr<ViewportNode> The newly created viewport.

◆ disallowsHandledActionPropagation()

bool ToyMaker::ViewportNode::disallowsHandledActionPropagation ( ) const
inline

Returns whether an action handled by one of this viewport's (high precedence) child viewports, should be sent to this viewports other children.

Return values
truePropagation to further children is disallowed;
falsePropagation to further children is allowed;

◆ fetchRenderResult()

std::shared_ptr< Texture > ViewportNode::fetchRenderResult ( float simulationProgress)

Fetches the render result for the most recently computed render frame.

Parameters
simulationProgressProgress towards the next simulation state after the previous one, as a number between 0 and 1.
Returns
std::shared_ptr<Texture> The texture value returned by this function.

◆ getActionDispatch()

ActionDispatch & ViewportNode::getActionDispatch ( )

Gets the action dispatch object for this viewport, which is the central location from which all actions received by this viewport are distributed to their respective action handlers.

Returns
ActionDispatch& A reference to this viewport's action dispatch member.

◆ getActiveDescendantViewports()

std::vector< std::shared_ptr< ViewportNode > > ViewportNode::getActiveDescendantViewports ( )
private

Gets active descendant viewports (in DFS order) under this Viewport.

Returns
std::vector<std::shared_ptr<ViewportNode>> A list of descendant viewports, in DFS order.

◆ getActiveDescendantWorlds()

std::vector< std::weak_ptr< ECSWorld > > ViewportNode::getActiveDescendantWorlds ( )
private

Gets weak references to ECSWorlds belonging to descendant viewports.

Returns
std::vector<std::weak_ptr<ECSWorld>> A list of ECSWorlds belonging to this node and its descendant viewports (in DFS order).

◆ getCenteredViewportCoordinates()

SDL_Rect ToyMaker::ViewportNode::getCenteredViewportCoordinates ( ) const
inlineprivate

Gets the region of this viewport's target texture that the rendered texture should be mapped to.

Returns
SDL_Rect The rendered-to sub-region of this viewport's target texture.

◆ getExposure()

float ViewportNode::getExposure ( )

Gets the exposure value used by this viewport's RenderSet.

Returns
float This viewport's exposure value.

◆ getGamma()

float ViewportNode::getGamma ( )

Gets the gamma value used by this viewport's RenderSet.

Returns
float This viewport's gamma value.

◆ getLocalViewport() [1/2]

std::shared_ptr< const ViewportNode > ViewportNode::getLocalViewport ( ) const
overridevirtual

Returns this viewport instead of base class return value.

Returns
std::shared_ptr<ViewportNode> A reference to this viewport.

Reimplemented from ToyMaker::SceneNodeCore.

◆ getLocalViewport() [2/2]

std::shared_ptr< ViewportNode > ViewportNode::getLocalViewport ( )
overridevirtual

Returns this viewport instead of base class return value.

Returns
std::shared_ptr<ViewportNode> A reference to this viewport.

Reimplemented from ToyMaker::SceneNodeCore.

◆ getRenderConfiguration()

ViewportNode::RenderConfiguration ViewportNode::getRenderConfiguration ( ) const

Gets the render configuration for this viewport.

Returns
RenderConfiguration Object representing this viewport's render configuration.

◆ getResourceTypeName()

static std::string ToyMaker::ViewportNode::getResourceTypeName ( )
inlinestatic

Gets the resource type string associated with the ViewportNode.

Returns
std::string This node's resource type string.

◆ getViewportLoadOrdinal()

uint32_t ToyMaker::ViewportNode::getViewportLoadOrdinal ( ) const
inline

(When this viewport is the immediate descendant of a RenderSet::RenderType::ADDITION viewport) The precedence of this viewport relative to other immediate descendants of its parent viewport.

Child viewports that are loaded first presently render over viewports that are loaded later on.

Returns
uint32_t The precedence of this viewport relative to other viewports.

◆ handleAction()

bool ViewportNode::handleAction ( std::pair< ActionDefinition, ActionData > pendingAction)

Handles an action received by this viewport, generally by dispatching it to subscribed listeners and propagating the action down to descendant viewports and their listeners.

Parameters
pendingActionThe action definition-data pair describing the action.
Return values
trueThe action was handled by a listener on this viewport;
falseThe action was not handled by any listener on this viewport;

◆ joinWorld()

void ViewportNode::joinWorld ( ECSWorld & world)
overrideprotectedvirtual

Joins this node's entity to a world (either its own or its parent viewport's).

Parameters
worldThe world this node's entity should join.

Reimplemented from ToyMaker::SceneNodeCore.

◆ onActivated()

void ViewportNode::onActivated ( )
overrideprotectedvirtual

Override which for a viewport sets its active camera, and initializes the ECSWorld owned by this viewport.

Reimplemented from ToyMaker::SceneNodeCore.

◆ onDeactivated()

void ViewportNode::onDeactivated ( )
overrideprotectedvirtual

Deactivates this viewports ECSWorld (if there is one) when this ViewportNode is retired.

Reimplemented from ToyMaker::SceneNodeCore.

◆ registerDomainCamera()

void ViewportNode::registerDomainCamera ( std::shared_ptr< SceneNodeCore > cameraNode)
private

Registers a camera that belongs to this viewport, which is a descendant of it and not a descendant of any of its child viewports.

Parameters
cameraNodeThe camera being registered as belonging to this viewport's domain.

◆ render()

uint32_t ViewportNode::render ( float simulationProgress,
uint32_t variableStep )
private

Requests execution of the render pipeline.

The request will be met according to the prerequisites outlined by this viewport's RenderConfiguration::mUpdateMode and RenderConfiguration::mFPSCap taken together.

Parameters
simulationProgressThe progress to the next simulation update from the end of the previous one as a number between 0 and 1.
variableStepThe time since the last render request was made.
Returns
uint32_t Time until the next render frame can be computed, per this viewport's update configuration.

◆ render_()

void ViewportNode::render_ ( float simulationProgress)
private

Implementation responsible for actually computing a new render frame.

Parameters
simulationProgressThe progress to the next simulation update from the end of theprevious one as a number between 0 and 1.

NOTE: context change might have occurred because of fetchRenderResult. Make our own render set active once again

◆ requestDimensions()

void ViewportNode::requestDimensions ( glm::u16vec2 requestedDimensions)

Target dimensions that another part of the program specifies for this viewport.

The target texture produced by this viewport is exactly the same as the dimensions specified in the request.

Parameters
requestedDimensionsThe dimensions for this viewport's target texture.

◆ setActiveCamera() [1/2]

void ViewportNode::setActiveCamera ( const std::string & cameraPath)

Sets the active camera for this viewport's RenderSet via path to the camera node.

Parameters
cameraPathPath to an active scene node with a CameraProperties component in the same ECSWorld as this viewport.

◆ setActiveCamera() [2/2]

void ViewportNode::setActiveCamera ( std::shared_ptr< SceneNodeCore > cameraNode)

Sets the active camera for this viewport's RenderSet via a reference to the camera node.

Parameters
cameraNodeActive scene node with a CameraProperties component in the same ECSWorld as this viewport.

◆ setFPSCap()

void ViewportNode::setFPSCap ( float fpsCap)

If an FPS capped update mode is selected, sets what that cap actually is.

Parameters
fpsCapThe new FPS cap for render updates to this viewport's render system.

◆ setRenderConfiguration()

void ViewportNode::setRenderConfiguration ( const RenderConfiguration & renderConfiguration)

Sets the render configuration for this viewport.

Parameters
renderConfigurationThis viewport's new render configuration.

◆ setRenderScale()

void ViewportNode::setRenderScale ( float renderScale)

Sets the scale relative to computed and design dimensions for the render pipeline target.

Parameters
renderScaleMultiplier for the render pipeline target (and not the viewport target.)

◆ setResizeMode()

void ViewportNode::setResizeMode ( RenderConfiguration::ResizeMode mode)

When resize is enabled, determines how resized render dimensions are computed.

Parameters
modeThe new way for render resize dimensions to be computed.

◆ setResizeType()

void ViewportNode::setResizeType ( RenderConfiguration::ResizeType type)

Sets this viewport's behaviour when request dimensions (or target dimensions) are changed.

Parameters
typeThe new type of behaviour to display on resize.

◆ setSkybox()

void ViewportNode::setSkybox ( std::shared_ptr< Texture > skybox)

Sets the skybox texture for this object's RenderSystem.

Parameters
skyboxThe new skybox texture for this viewport's render system.
See also
RenderSet
RenderSystem

◆ setUpdateMode()

void ViewportNode::setUpdateMode ( RenderConfiguration::UpdateMode updateMode)

Sets the behaviour for frequency of render updates w.r.t render requests.

Parameters
updateModeThe render update behaviour.

◆ unregisterDomainCamera()

void ViewportNode::unregisterDomainCamera ( std::shared_ptr< SceneNodeCore > cameraNode)
private

Removes a camera from this viewport's domain.

Parameters
cameraNodeThe camera being removed from this viewport's domain.

◆ updateExposure()

void ViewportNode::updateExposure ( float newExposure)

Updates the exposure of this viewport's RenderSet.

Parameters
newExposureThe new exposure value used by this viewport.
See also
RenderSystem

◆ updateGamma()

void ViewportNode::updateGamma ( float newGamma)

Updates the gamma value of this viewport's RenderSet.

Parameters
newGammaThe new gamma value used by this viewport.
See also
RenderSystem

◆ viewNextDebugTexture()

void ViewportNode::viewNextDebugTexture ( )

Sets the next debug texture listed in this viewport's render set to the texture considered "active" by it.

See also
RenderSystem

Member Data Documentation

◆ mTextureResult

std::shared_ptr<Texture> ToyMaker::ViewportNode::mTextureResult { nullptr }
private

The result of rendering from running the rendering pipeline associated with this viewport.

Warning
Will be an empty pointer initially, and will be a new texture pointer every time this viewport's render configuration is changed.

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