|
Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
|
An Actor is similar to an Engine::Entities::Entity. An actor is an Entity with a transform. More...
#include <Actor.h>
Public Member Functions | |
| Actor (const SpawnContext &context) | |
| Creates an actor from a scene spawn context. | |
| ~Actor () override=default | |
| Destroys the actor. | |
| template<typename T, typename... Args> requires detail::ConstructibleWithActorContext<T, Args...> | |
| T * | addComponent (Args &&... args) |
| Adds a component using this actor's scene, ECS entity and scene node where supported. | |
| virtual void | beginPlay () |
| Gets executed when the actor is spawned into the world. | |
| void | tick (double deltaTime) override |
| Executed every frame. | |
| virtual void | endPlay () |
| Gets executed when an actor is getting removed from the scene. | |
| virtual std::string | getActorName () const |
| Returns the display name for this actor. | |
| void | destroyActor () |
| Queues this actor for destruction after the current tick finishes. | |
| void | destroyActorImmediate () |
| Destroys this actor immediately. Prefer destroyActor() during gameplay/tick code. | |
| void | attachTo (Actor &parent, AttachmentTransformRule rule=AttachmentTransformRule::KeepWorld) |
| Attaches this actor to another actor. | |
| void | attachTo (const std::shared_ptr< SceneNode > &parentNode, AttachmentTransformRule rule=AttachmentTransformRule::KeepWorld) |
| Attaches this actor to a scene node. | |
| void | detach (AttachmentTransformRule rule=AttachmentTransformRule::KeepWorld) |
| Detaches this actor from its parent node. | |
| glm::vec3 | getActorLocation () const |
| Gets the actors location in the world. | |
| glm::vec3 | getActorRotation () const |
| Gets the actors rotation in the world. | |
| glm::quat | getActorRotationQuat () const |
| Gets the actors world rotation. | |
| glm::vec3 | getActorScale () const |
| Scales the actor to world scale. | |
| void | setActorLocation (glm::vec3 newLocation) const |
| Set the new world location for this actor. | |
| void | setActorRotation (glm::vec3 newRotation) const |
| Sets the world rotation. | |
| void | rotateActor (glm::vec3 deltaRotation) const |
| Applies an incremental rotation to the actor using quaternion multiplication. Use this instead of getActorRotation() + setActorRotation() for continuous rotation to avoid euler angle instability/jiggling. | |
| void | setActorScale (glm::vec3 newScale) const |
| sets the world scale for this actor | |
| glm::vec3 | getForwardVector () const |
| Gets the forward world vector. | |
| glm::vec3 | getRightVector () const |
| Gets the right. | |
| glm::vec3 | getUpVector () const |
| Gets the up world vector. | |
| glm::mat4 | getWorldTransform () const |
| Gets the model matrix. | |
| virtual bool | drawImGui () const |
| Allows drawing custom Imgui panels for the editor. | |
| Scene * | getOwningScene () const |
| Get the pointer to the scene this entity is a part of. | |
| std::shared_ptr< SceneNode > | getSceneNode () const |
| Getter for the scene graph node for this object. | |
| Public Member Functions inherited from Engine::Entities::Entity | |
| Entity () | |
| Creates an entity in the constructed lifecycle state. | |
| ~Entity () override | |
| Destroys the entity and owned logic components. | |
| void | enableTick (bool enable) |
| Enables or disables ticking for this entity. | |
| void | setTickPriority (int32_t priority) |
| Sets the tick ordering priority for this entity. | |
| int32_t | getTickPriority () const |
| Returns the tick ordering priority for this entity. | |
| void | tick (double deltaTime) override |
| Executes every frame if tick is enabled. | |
| void | destroy () |
| Tells the scene to destroy this Entity. | |
| void | destroyImmediate () |
| Destroys this entity immediately through its owning container. | |
| EntityContainer * | getOwningContainer () const |
| Returns the container that owns this entity. | |
| bool | isPendingDestroy () const |
| Returns whether this entity has been queued for destruction. | |
| bool | isPlaying () const |
| Returns whether this entity has begun play and has not ended play. | |
| template<typename T, typename... Args> requires std::is_base_of_v<Components::Logic, T> && std::is_constructible_v<T, Args...> | |
| T * | addComponent (Args &&... args) |
| Adds a component to the entity. Checks for uniqueness if the component defines 'static constexpr bool IsUnique = true;'. | |
| template<typename T> requires std::is_base_of_v<Components::Logic, T> | |
| T * | getComponent () const |
| Returns the first component of type T found. | |
| template<typename T> requires std::is_base_of_v<Components::Logic, T> | |
| std::vector< T * > | getComponents () const |
| Returns all components of type T. | |
| void | removeComponent (Components::Logic *component) |
| Removes a specific component instance. | |
| template<typename T> requires std::is_base_of_v<Components::Logic, T> | |
| bool | removeFirstComponent () |
| Removes the first component of type T found. | |
| template<typename T> requires std::is_base_of_v<Components::Logic, T> | |
| bool | hasComponent () const |
| Checks if a component of type T exists. | |
| const std::vector< std::unique_ptr< Components::Logic > > & | getAllComponents () const |
| Gets all components on this entity. | |
| bool | canTick () const |
| Tells you if the entity can execute its tick function. | |
| bool | canEverTick () const |
| Tells if this entity can ever tick. | |
| entt::entity | getEcsEntity () const |
| Gets the ECS entity handle for this Entity. | |
| Public Member Functions inherited from Engine::Core::ITickable | |
| virtual | ~ITickable ()=default |
| Destroys a tickable object. | |
| virtual void | preTick () |
| Function which executes immediately before the execution of ITickable::preTick() | |
| virtual void | postTick () |
| Function which executes immediately after the execution of ITickable::postTick() | |
Static Public Member Functions | |
| static EngineKern * | getEngine () |
| Gets the engine this actor belongs to. | |
Protected Member Functions | |
| void | onEngineBeginPlay () override |
| Bridges the entity begin-play lifecycle to Actor::beginPlay(). | |
| void | onEngineEndPlay () override |
| Bridges the entity end-play lifecycle to Actor::endPlay(). | |
| void | onEngineDestroyed () override |
| Handles actor cleanup when the entity is destroyed. | |
Protected Attributes | |
| std::optional< std::shared_ptr< SceneNode > > | sceneNode |
| Scene graph node owned by this actor. | |
| Protected Attributes inherited from Engine::Entities::Entity | |
| std::vector< std::unique_ptr< Components::Logic > > | components_ |
| List of all logical components. | |
| entt::entity | data_ = entt::null |
| ECS entity handle associated with this entity. | |
| bool | allowTicking_ = false |
| Whether ticking is currently enabled. | |
| int32_t | tickPriority_ = 0 |
| Priority used to order entity ticks. | |
Private Member Functions | |
| template<typename T, typename First, typename... Rest> | |
| T * | addComponentWithSceneEntityFirstNodeRest (First &&first, Rest &&... rest) |
Private Attributes | |
| Scene * | owningScene_ = nullptr |
| std::weak_ptr< Components::Scene > | rootComponent_ |
| bool | hasEndedPlay_ = false |
An Actor is similar to an Engine::Entities::Entity. An actor is an Entity with a transform.
|
explicit |
Creates an actor from a scene spawn context.
| context | Spawn context containing the owning scene and scene node. |
Referenced by attachTo().
|
overridedefault |
Destroys the actor.
References Engine::Entities::Entity::addComponent().
|
inline |
Adds a component using this actor's scene, ECS entity and scene node where supported.
Common actor-owned components can be spawned as addComponent<T>(args...) without manually passing getOwningScene(), getEcsEntity()/data_ or getSceneNode(). Explicit constructor calls still resolve to Entity::addComponent when this overload is not constructible.
Definition at line 97 of file Actor.h.
References Engine::Entities::Entity::addComponent(), addComponentWithSceneEntityFirstNodeRest(), Engine::Entities::Entity::data_, getOwningScene(), getSceneNode(), and Scene.
|
inlineprivate |
Definition at line 315 of file Actor.h.
References Engine::Entities::Entity::addComponent(), Engine::Entities::Entity::data_, getOwningScene(), and getSceneNode().
Referenced by addComponent().
| void Engine::Entities::Actor::attachTo | ( | Actor & | parent, |
| AttachmentTransformRule | rule = AttachmentTransformRule::KeepWorld ) |
Attaches this actor to another actor.
| parent | Parent actor to attach to. |
| rule | Transform rule applied during attachment. |
References Actor(), and Engine::Entities::KeepWorld.
| void Engine::Entities::Actor::attachTo | ( | const std::shared_ptr< SceneNode > & | parentNode, |
| AttachmentTransformRule | rule = AttachmentTransformRule::KeepWorld ) |
Attaches this actor to a scene node.
| parentNode | Parent scene node to attach to. |
| rule | Transform rule applied during attachment. |
References Engine::Entities::KeepWorld.
|
virtual |
Gets executed when the actor is spawned into the world.
Reimplemented in Engine::Entities::DebugCameraActor.
| void Engine::Entities::Actor::destroyActor | ( | ) |
Queues this actor for destruction after the current tick finishes.
| void Engine::Entities::Actor::destroyActorImmediate | ( | ) |
Destroys this actor immediately. Prefer destroyActor() during gameplay/tick code.
| void Engine::Entities::Actor::detach | ( | AttachmentTransformRule | rule = AttachmentTransformRule::KeepWorld | ) |
Detaches this actor from its parent node.
| rule | Transform rule applied during detachment. |
References Engine::Entities::KeepWorld.
|
virtual |
Allows drawing custom Imgui panels for the editor.
|
virtual |
Gets executed when an actor is getting removed from the scene.
| glm::vec3 Engine::Entities::Actor::getActorLocation | ( | ) | const |
Gets the actors location in the world.
|
nodiscardvirtual |
Returns the display name for this actor.
| glm::vec3 Engine::Entities::Actor::getActorRotation | ( | ) | const |
Gets the actors rotation in the world.
| glm::quat Engine::Entities::Actor::getActorRotationQuat | ( | ) | const |
Gets the actors world rotation.
| glm::vec3 Engine::Entities::Actor::getActorScale | ( | ) | const |
Scales the actor to world scale.
|
staticnodiscard |
Gets the engine this actor belongs to.
| glm::vec3 Engine::Entities::Actor::getForwardVector | ( | ) | const |
Gets the forward world vector.
| Scene * Engine::Entities::Actor::getOwningScene | ( | ) | const |
Get the pointer to the scene this entity is a part of.
References Scene.
Referenced by addComponent(), and addComponentWithSceneEntityFirstNodeRest().
| glm::vec3 Engine::Entities::Actor::getRightVector | ( | ) | const |
Gets the right.
| std::shared_ptr< SceneNode > Engine::Entities::Actor::getSceneNode | ( | ) | const |
Getter for the scene graph node for this object.
Referenced by addComponent(), addComponentWithSceneEntityFirstNodeRest(), and Engine::Entities::Scene::spawnActorAttached().
| glm::vec3 Engine::Entities::Actor::getUpVector | ( | ) | const |
Gets the up world vector.
| glm::mat4 Engine::Entities::Actor::getWorldTransform | ( | ) | const |
Gets the model matrix.
|
overrideprotectedvirtual |
Bridges the entity begin-play lifecycle to Actor::beginPlay().
Reimplemented from Engine::Entities::Entity.
|
overrideprotectedvirtual |
Handles actor cleanup when the entity is destroyed.
Reimplemented from Engine::Entities::Entity.
|
overrideprotectedvirtual |
Bridges the entity end-play lifecycle to Actor::endPlay().
Reimplemented from Engine::Entities::Entity.
| void Engine::Entities::Actor::rotateActor | ( | glm::vec3 | deltaRotation | ) | const |
Applies an incremental rotation to the actor using quaternion multiplication. Use this instead of getActorRotation() + setActorRotation() for continuous rotation to avoid euler angle instability/jiggling.
| deltaRotation | euler angles (degrees) to rotate by |
| void Engine::Entities::Actor::setActorLocation | ( | glm::vec3 | newLocation | ) | const |
Set the new world location for this actor.
| newLocation | xyz |
| void Engine::Entities::Actor::setActorRotation | ( | glm::vec3 | newRotation | ) | const |
Sets the world rotation.
| newRotation | euler (yaw | pitch | roll) |
| void Engine::Entities::Actor::setActorScale | ( | glm::vec3 | newScale | ) | const |
sets the world scale for this actor
| newScale | xyz |
|
overridevirtual |
Executed every frame.
| deltaTime | time between this frame and the last frame |
Reimplemented from Engine::Core::ITickable.
|
private |
|
private |
|
protected |