diff --git a/docs-preview/pr-880/access_8hpp.html b/docs-preview/pr-880/access_8hpp.html index 3a71d36ed..e5db60758 100644 --- a/docs-preview/pr-880/access_8hpp.html +++ b/docs-preview/pr-880/access_8hpp.html @@ -2,7 +2,7 @@ - core/ecs/query/access.hpp file | CUBOS. Docs + core/ecs/system/access.hpp file | CUBOS. Docs @@ -46,9 +46,9 @@

- core/ecs/query/access.hpp file + core/ecs/system/access.hpp file

-

Struct cubos::core::ecs::QueryAccess.

+

Struct cubos::core::ecs::SystemAccess.

diff --git a/docs-preview/pr-880/annotated.html b/docs-preview/pr-880/annotated.html index 36637743f..008a74a3f 100644 --- a/docs-preview/pr-880/annotated.html +++ b/docs-preview/pr-880/annotated.html @@ -100,15 +100,7 @@

Classes

-
  • struct Gravity Resouce which holds the global value of gravity.
  • +
  • struct Gravity Resource which holds the global value of gravity.
  • struct Impulse Component which holds impulses applied on a particle.
  • class Input final Resource which stores the input bindings for multiple players.
  • class InputAction final Stores the state of a single input action, such as "jump" or "attack".
  • @@ -444,6 +434,7 @@

    Classes

  • class PostProcessingCopy A simple post processing pass that copies the input texture to the output.
  • class PostProcessingManager final Responsible for managing the post processing passes.
  • class PostProcessingPass A generic post processing pass.
  • +
  • struct PotentiallyCollidingWith Component which represents a potential collisions.
  • struct PreviousPosition Component which holds the previous position of the entity. Used for the integrator on the update velocity step.
  • struct RenderableGrid Component which makes a voxel grid be rendered by the renderer plugin.
  • struct RendererEnvironment Resource which stores the renderer's ambient light and sky colors.
  • @@ -459,11 +450,8 @@

    Classes

  • class SceneBridge Bridge which loads and saves Scene assets.
  • class ScreenPicker final Resource which provides a texture to store entity/gizmo ids, for selection with a mouse.
  • class Settings final Stores settings as key-value pairs and provides methods to retrieve them.
  • -
  • struct ShouldQuit Resource used as a flag to indicate whether the main loop should stop running.
  • struct SpotLight Component which makes an entity emit a spot light.
  • -
  • struct Substeps Resouce which holds the amount of substeps for the physics update.
  • -
  • class SystemBuilder Used to chain configurations related to systems.
  • -
  • class TagBuilder Used to chain configurations related to tags.
  • +
  • struct Substeps Resource which holds the amount of substeps for the physics update.
  • struct Velocity Component which holds velocity and forces applied on a particle.
  • struct Viewport Component which defines parameters of a viewport, the actual screen space that will be used by the camera it is attached to. Useful for having multiple camera views shown on screen.
  • class VoxelGrid final Represents a voxel object using a 3D grid.
  • diff --git a/docs-preview/pr-880/blueprint_8hpp.html b/docs-preview/pr-880/blueprint_8hpp.html index 8aba2abdd..41e1c0531 100644 --- a/docs-preview/pr-880/blueprint_8hpp.html +++ b/docs-preview/pr-880/blueprint_8hpp.html @@ -78,7 +78,7 @@

    Classes

    class cubos::core::ecs::Blueprint
    -
    Collection of entities and their respective components.
    +
    Collection of entities and their respective components and relations.
    diff --git a/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1Blueprint.html b/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1Blueprint.html index 555aa756c..c968c7a8e 100644 --- a/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1Blueprint.html +++ b/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1Blueprint.html @@ -49,7 +49,7 @@

    cubos::core::ecs::Blueprint class final
    #include <core/ecs/blueprint.hpp>

    -

    Collection of entities and their respective components.

    +

    Collection of entities and their respective components and relations.

    -

    Blueprints are in a way the 'Prefab' of CUBOS. They act as a tiny World which can then be spawned into an actual World, as many times as needed.

    When a blueprint is spawned, all of its components are scanned using the Reflection system for any references to other entities in the blueprint. These references are then replaced with the actual spawned entities. This has the side effect that if you do not expose an Entity field to the Reflection system, it will not be replaced and thus continue referencing the original entity in the blueprint.

    +

    Blueprints are in a way the 'Prefab' of CUBOS. They act as a tiny World which can then be spawned into an actual World, as many times as needed.

    When a blueprint is spawned, all of its components and relations are scanned using the Reflection system for any references to other entities in the blueprint. These references are then replaced with the actual spawned entities. This has the side effect that if you do not expose an Entity field to the Reflection system, it will not be replaced and thus continue referencing the original entity in the blueprint.

    Public types

    using Create = Entity(*)(void*userData, std::string name)
    -
    Function used by instantiate to create entities.
    +
    Function used by instantiate to create entities.
    using Add = void(*)(void*userData, Entity entity, memory::AnyValue component)
    -
    Function used by instantiate to add components to entities.
    +
    Function used by instantiate to add components to entities.
    +
    + using Relate = void(*)(void*userData, Entity fromEntity, Entity toEntity, memory::AnyValue relation) +
    +
    Function used by instantiate to add relations to entities.
    @@ -118,6 +122,19 @@

    Public functions

    Ts... components)
    Adds components to an entity. Overwrites the existing components, if there's any.
    +
    + void relate(Entity fromEntity, + Entity toEntity, + memory::AnyValue relation) +
    +
    Adds a relation between two entities. Overwrites the existing relation, if there's any.
    +
    + + void relate(Entity fromEntity, + Entity toEntity, + T relation) +
    +
    Adds a relation between two entities. Overwrites the existing relation, if there's any.
    void merge(const std::string& prefix, const Blueprint& other) @@ -132,15 +149,17 @@

    Public functions

    Returns a bimap which maps entities to their names.
    - void instantiate(void* userData, + void instantiate(void* userData, Create create, - Add add) const + Add add, + Relate relate) const
    Instantiates the blueprint by calling the given functions.
    -
    template<typename C, typename A>
    - void instantiate(C create, - A add) const +
    template<typename C, typename A, typename R>
    + void instantiate(C create, + A add, + R relate) const
    Instantiates the blueprint by calling the given functors.
    @@ -259,6 +278,72 @@

    +
    +

    + void cubos::core::ecs::Blueprint::relate(Entity fromEntity, + Entity toEntity, + memory::AnyValue relation) +

    +

    Adds a relation between two entities. Overwrites the existing relation, if there's any.

    + + + + + + + + + + + + + + + + + + +
    Parameters
    fromEntityFrom entity.
    toEntityTo entity.
    relationRelation to move.
    +
    +
    +

    +
    + template<reflection::Reflectable T> +
    + void cubos::core::ecs::Blueprint::relate(Entity fromEntity, + Entity toEntity, + T relation) +

    +

    Adds a relation between two entities. Overwrites the existing relation, if there's any.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Template parameters
    TRelation type.
    Parameters
    fromEntityFrom entity.
    toEntityTo entity.
    relationRelation to move.
    +

    void cubos::core::ecs::Blueprint::merge(const std::string& prefix, @@ -296,11 +381,12 @@

    -
    +

    - void cubos::core::ecs::Blueprint::instantiate(void* userData, + void cubos::core::ecs::Blueprint::instantiate(void* userData, Create create, - Add add) const + Add add, + Relate relate) const

    Instantiates the blueprint by calling the given functions.

    @@ -320,16 +406,21 @@

    + + + +
    add Function used to add components to entities.
    relateFunction used to add relations to entities.
    -
    +

    - template<typename C, typename A> + template<typename C, typename A, typename R>
    - void cubos::core::ecs::Blueprint::instantiate(C create, - A add) const + void cubos::core::ecs::Blueprint::instantiate(C create, + A add, + R relate) const

    Instantiates the blueprint by calling the given functors.

    @@ -345,6 +436,10 @@

    + + + + @@ -358,6 +453,10 @@

    + + + +
    A Add functor type.
    RRelate functor type.
    Parameters
    add Functor used to add components to entities.
    relateFunctor used to add relations to entities.
    diff --git a/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1Commands.html b/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1Commands.html index 470245636..14728cfc0 100644 --- a/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1Commands.html +++ b/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1Commands.html @@ -47,9 +47,9 @@

    cubos::core::ecs::Commands class final - +

    -

    System argument used to write ECS commands and execute them at a later time.

    +

    System argument used to write ECS commands and execute them at a later time.

    +
    +

    Public static functions

    +
    +
    + static auto make(World& world, + auto function, + const std::vector<SystemOptions>& options = {}) -> System +
    +
    Creates a new system for the given world with the given function and options.
    +
    +

    Constructors, destructors, conversion operators

    - AnySystemWrapper(SystemInfo&& info) + System(System&& system) defaulted noexcept
    -
    Constructs.
    +
    Move constructs.

    Public functions

    - void prepare(World& world) pure virtual -
    -
    Prepares the system for being executed on the given world.
    -
    - auto call(World& world, - CommandBuffer& commands) -> R pure virtual + auto run(CommandBuffer& cmdBuffer) -> T
    -
    Calls the wrapped system with parameters taken from the given world.
    +
    Runs the system.
    - auto info() const -> const SystemInfo& + auto access() const -> const SystemAccess&
    -
    Gets information about the requirements of the system.
    +
    Gets a reference to the access patterns of the system.

    Function documentation

    -
    +

    - template<typename R> + template<typename T>
    - cubos::core::ecs::AnySystemWrapper<R>::AnySystemWrapper(SystemInfo&& info) + static System cubos::core::ecs::System<T>::make(World& world, + auto function, + const std::vector<SystemOptions>& options = {})

    -

    Constructs.

    +

    Creates a new system for the given world with the given function and options.

    - - + + + + + + + + + +
    Parameters
    infoInformation about the wrapped system.worldWorld the system will access.
    functionSystem function, which should return T.
    optionsOptions for the system arguments.
    +

    The first option is applied to the first argument which requests it, and the same for subsequent options. If there are more options than arguments which request them, aborts. Otherwise, if there are more arguments requesting options than supplied options, the remaining arguments are assigned default-value options.

    -
    +

    - template<typename R> + template<typename T>
    - void cubos::core::ecs::AnySystemWrapper<R>::prepare(World& world) pure virtual + cubos::core::ecs::System<T>::System(System&& system) defaulted noexcept

    -

    Prepares the system for being executed on the given world.

    +

    Move constructs.

    - - + +
    Parameters
    worldWorld to prepare the system for.systemOther system.
    -

    Requires exclusive access to the world and must be called before calling the system.

    -
    +

    - template<typename R> + template<typename T>
    - R cubos::core::ecs::AnySystemWrapper<R>::call(World& world, - CommandBuffer& commands) pure virtual + T cubos::core::ecs::System<T>::run(CommandBuffer& cmdBuffer)

    -

    Calls the wrapped system with parameters taken from the given world.

    +

    Runs the system.

    - - - - - - + + - +
    Parameters
    worldWorld used by the system.
    commandsBuffer where commands can be submitted to.cmdBufferCommand buffer.
    ReturnsReturn value of the system.Return value.
    -

    Can only be called after calling prepare() on the same world.

    -
    +

    - template<typename R> + template<typename T>
    - const SystemInfo& cubos::core::ecs::AnySystemWrapper<R>::info() const + const SystemAccess& cubos::core::ecs::System<T>::access() const

    -

    Gets information about the requirements of the system.

    +

    Gets a reference to the access patterns of the system.

    - +
    ReturnsInformation about the system.Access patterns.
    diff --git a/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1SystemWrapper.html b/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1SystemFetcher.html similarity index 62% rename from docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1SystemWrapper.html rename to docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1SystemFetcher.html index c3bb9c045..9bc53bb69 100644 --- a/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1SystemWrapper.html +++ b/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1SystemFetcher.html @@ -2,7 +2,7 @@ - cubos::core::ecs::SystemWrapper class | CUBOS. Docs + cubos::core::ecs::SystemFetcher class | CUBOS. Docs @@ -46,19 +46,19 @@

    - -
    template<typename F>
    - cubos::core::ecs::SystemWrapper class final + +
    template<typename T>
    + cubos::core::ecs::SystemFetcher class

    -

    Wrapper for a system of type F.

    +

    Type meant to be specialized which implements for each argument type the necessary logic to extract it from the world.

    - - + +
    Template parameters
    FType of the system function/method/lambda.TArgument type.
    @@ -68,120 +68,111 @@

    Contents

  • Reference
  • -
    -

    Base classes

    +
    +

    Public static variables

    -
    -
    template<typename R>
    - class AnySystemWrapper<impl::SystemTraits<F>::Return> +
    + static bool ConsumesOptions constexpr
    -
    Base class for system wrappers.
    +
    Indicates whether this argument type consumes system options.

    Constructors, destructors, conversion operators

    - SystemWrapper(F system) + SystemFetcher(World& world, + const SystemOptions& options)
    -
    Constructs.
    +
    Called when a system is constructed for the first time.

    Public functions

    - void prepare(World& world) override + void analyze(SystemAccess& access) const
    -
    Prepares the system for being executed on the given world.
    +
    Called to determine the access patterns of the argument.
    - auto call(World& world, - CommandBuffer& commands) -> impl::SystemTraits<F>::Return override + auto fetch(CommandBuffer& cmdBuffer) -> T
    -
    Calls the wrapped system with parameters taken from the given world.
    +
    Called each system run to fetch the data from the world.

    Function documentation

    -
    +

    - template<typename F> + template<typename T>
    - cubos::core::ecs::SystemWrapper<F>::SystemWrapper(F system) + cubos::core::ecs::SystemFetcher<T>::SystemFetcher(World& world, + const SystemOptions& options)

    -

    Constructs.

    +

    Called when a system is constructed for the first time.

    - - + + + + + +
    Parameters
    systemSystem to wrap.worldWorld to extract data from.
    optionsArgument options.
    -
    +

    - template<typename F> + template<typename T>
    - void cubos::core::ecs::SystemWrapper<F>::prepare(World& world) override + void cubos::core::ecs::SystemFetcher<T>::analyze(SystemAccess& access) const

    -

    Prepares the system for being executed on the given world.

    +

    Called to determine the access patterns of the argument.

    - - + +
    Parameters
    worldWorld to prepare the system for.access outAccess patterns to add info to.
    -

    Requires exclusive access to the world and must be called before calling the system.

    -
    +

    - template<typename F> + template<typename T>
    - impl::SystemTraits<F>::Return cubos::core::ecs::SystemWrapper<F>::call(World& world, - CommandBuffer& commands) override + T cubos::core::ecs::SystemFetcher<T>::fetch(CommandBuffer& cmdBuffer)

    -

    Calls the wrapped system with parameters taken from the given world.

    +

    Called each system run to fetch the data from the world.

    - - - - - - + + - - - - - -
    Parameters
    worldWorld used by the system.
    commandsBuffer where commands can be submitted to.cmdBufferCommand buffer.
    ReturnsReturn value of the system.
    -

    Can only be called after calling prepare() on the same world.

    diff --git a/docs-preview/pr-880/classcubos_1_1engine_1_1TagBuilder.html b/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1TagBuilder.html similarity index 74% rename from docs-preview/pr-880/classcubos_1_1engine_1_1TagBuilder.html rename to docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1TagBuilder.html index 4d0c9efdc..8b05feb94 100644 --- a/docs-preview/pr-880/classcubos_1_1engine_1_1TagBuilder.html +++ b/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1TagBuilder.html @@ -2,7 +2,7 @@ - cubos::engine::TagBuilder class | CUBOS. Docs + cubos::core::ecs::TagBuilder class | CUBOS. Docs @@ -46,8 +46,8 @@

    - cubos::engine::TagBuilder class - + cubos::core::ecs::TagBuilder class +

    Used to chain configurations related to tags.

    Function documentation

    -
    +

    - cubos::engine::TagBuilder::TagBuilder(core::ecs::Dispatcher& dispatcher, + cubos::core::ecs::TagBuilder::TagBuilder(World& world, + core::ecs::Dispatcher& dispatcher, std::vector<std::string>& tags)

    Construct.

    @@ -104,8 +106,12 @@

    - dispatcher - Dispatcher being configured + world + World. + + + dispatcher + Dispatcher being configured. tags @@ -120,9 +126,9 @@

    -
    +

    - TagBuilder& cubos::engine::TagBuilder::before(const std::string& tag) + TagBuilder& cubos::core::ecs::TagBuilder::before(const std::string& tag)

    Sets the current tag to be executed before another tag.

    @@ -143,9 +149,9 @@

    -
    +

    - TagBuilder& cubos::engine::TagBuilder::after(const std::string& tag) + TagBuilder& cubos::core::ecs::TagBuilder::after(const std::string& tag)

    Sets the current tag to be executed after another tag.

    @@ -166,12 +172,12 @@

    -
    +

    template<typename F>
    - TagBuilder& cubos::engine::TagBuilder::runIf(F func) + TagBuilder& cubos::core::ecs::TagBuilder::runIf(F func)

    Adds a condition to the current tag. If this condition returns false, systems with this tag will not be executed. For the tagged systems to run, all conditions must return true.

    diff --git a/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1TypeBuilder.html b/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1TypeBuilder.html index 96a58d669..e5b4fe9ff 100644 --- a/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1TypeBuilder.html +++ b/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1TypeBuilder.html @@ -87,6 +87,14 @@

    Constructors, destructors, conversion operators<

    Public functions

    +
    + auto symmetric() && -> TypeBuilder&& +
    +
    Makes the type symmetric. Only used by relation types.
    +
    + auto tree() && -> TypeBuilder&& +
    +
    Makes the type a tree relation. Only used by relation types.
    template<typename F>
    auto withField(std::string name, @@ -121,6 +129,40 @@

    +
    +

    +
    + template<typename T> +
    + TypeBuilder&& cubos::core::ecs::TypeBuilder<T>::symmetric() && +

    +

    Makes the type symmetric. Only used by relation types.

    + + + + + + + +
    ReturnsBuilder.
    +
    +
    +

    +
    + template<typename T> +
    + TypeBuilder&& cubos::core::ecs::TypeBuilder<T>::tree() && +

    +

    Makes the type a tree relation. Only used by relation types.

    + + + + + + + +
    ReturnsBuilder.
    +

    diff --git a/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1Types.html b/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1Types.html index d419b3e6e..507190522 100644 --- a/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1Types.html +++ b/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1Types.html @@ -84,6 +84,10 @@

    Public functions

    auto type(DataTypeId id) const -> const reflection::Type&
    Gets a data type from its identifier.
    +
    + auto contains(const reflection::Type& type) const -> bool +
    +
    Checks if a data type is registered.
    auto contains(const std::string& name) const -> bool
    @@ -96,10 +100,22 @@

    Public functions

    auto isRelation(DataTypeId id) const -> bool
    Checks if the given data type is a relation.
    +
    + auto isSymmetricRelation(DataTypeId id) const -> bool +
    +
    Checks if the given data type is a symmetric relation.
    +
    + auto isTreeRelation(DataTypeId id) const -> bool +
    +
    Checks if the given data type is a tree relation.
    auto components() const -> reflection::TypeRegistry
    Gets a type registry with only the component types.
    +
    + auto relations() const -> reflection::TypeRegistry +
    +
    Gets a type registry with only the relation types.

    @@ -209,6 +225,20 @@

    +
    +

    + bool cubos::core::ecs::Types::contains(const reflection::Type& type) const +

    +

    Checks if a data type is registered.

    + + + + + + + +
    ReturnsWhether the data type is registered.
    +

    bool cubos::core::ecs::Types::contains(const std::string& name) const @@ -278,6 +308,52 @@

    +
    +

    + bool cubos::core::ecs::Types::isSymmetricRelation(DataTypeId id) const +

    +

    Checks if the given data type is a symmetric relation.

    + + + + + + + + + + + + + + + + +
    Parameters
    idData type identifier.
    ReturnsWhether the identifier refers to a symmetric relation.
    +
    +
    +

    + bool cubos::core::ecs::Types::isTreeRelation(DataTypeId id) const +

    +

    Checks if the given data type is a tree relation.

    + + + + + + + + + + + + + + + + +
    Parameters
    idData type identifier.
    ReturnsWhether the identifier refers to a tree relation.
    +

    reflection::TypeRegistry cubos::core::ecs::Types::components() const @@ -292,6 +368,20 @@

    +
    +

    + reflection::TypeRegistry cubos::core::ecs::Types::relations() const +

    +

    Gets a type registry with only the relation types.

    + + + + + + + +
    ReturnsRelation type registry.
    +
    diff --git a/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1World.html b/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1World.html index 38b88a14c..9c940aa90 100644 --- a/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1World.html +++ b/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1World.html @@ -61,7 +61,7 @@

    Contents

    - +

    Public functions

    @@ -196,6 +196,30 @@

    Public functions

    Entity to) const -> bool
    Checks if there's a relation of the given type between the two given entities.
    +
    + auto relation(Entity from, + Entity to, + const reflection::Type& type) -> void* +
    +
    Gets a pointer to the relation value between the two given entities.
    +
    + auto relation(Entity from, + Entity to, + const reflection::Type& type) const -> const void* +
    +
    Gets a pointer to the relation value between the two given entities.
    +
    +
    template<typename T>
    + auto relation(Entity from, + Entity to) -> T& +
    +
    Gets a reference to the relation value between the two given entities.
    +
    +
    template<typename T>
    + auto relation(Entity from, + Entity to) const -> const T& +
    +
    Gets a reference to the relation value between the two given entities.
    @@ -228,7 +252,7 @@

    args - Arguments of the constructor of the resource. + Arguments of the constructor of the resource. @@ -840,6 +864,156 @@

    +
    +

    + void* cubos::core::ecs::World::relation(Entity from, + Entity to, + const reflection::Type& type) +

    +

    Gets a pointer to the relation value between the two given entities.

    + + + + + + + + + + + + + + + + + + + + + + + + +
    Parameters
    fromFrom entity.
    toTo entity.
    typeRelation type.
    ReturnsPointer to relation value.
    +

    The relation must exist.

    +
    +
    +

    + const void* cubos::core::ecs::World::relation(Entity from, + Entity to, + const reflection::Type& type) const +

    +

    Gets a pointer to the relation value between the two given entities.

    + + + + + + + + + + + + + + + + + + + + + + + + +
    Parameters
    fromFrom entity.
    toTo entity.
    typeRelation type.
    ReturnsPointer to relation value.
    +

    The relation must exist.

    +
    +
    +

    +
    + template<typename T> +
    + T& cubos::core::ecs::World::relation(Entity from, + Entity to) +

    +

    Gets a reference to the relation value between the two given entities.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Template parameters
    TRelation type.
    Parameters
    fromFrom entity.
    toTo entity.
    ReturnsReference to relation value.
    +

    The relation must exist.

    +
    +
    +

    +
    + template<typename T> +
    + const T& cubos::core::ecs::World::relation(Entity from, + Entity to) const +

    +

    Gets a reference to the relation value between the two given entities.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Template parameters
    TRelation type.
    Parameters
    fromFrom entity.
    toTo entity.
    ReturnsReference to relation value.
    +

    The relation must exist.

    +
    diff --git a/docs-preview/pr-880/classcubos_1_1engine_1_1BaseRenderer.html b/docs-preview/pr-880/classcubos_1_1engine_1_1BaseRenderer.html index d74e4627b..fa15305b4 100644 --- a/docs-preview/pr-880/classcubos_1_1engine_1_1BaseRenderer.html +++ b/docs-preview/pr-880/classcubos_1_1engine_1_1BaseRenderer.html @@ -66,7 +66,7 @@

    Contents

    -

    This abstraction allows us to, for example, switch between a raytracing and a deferred rendering method as we need to, without changing the API. This is useful since not all computers support realtime raytracing.

    +

    This abstraction allows us to, for example, switch between a raytracing and a deferred rendering method as we need to, without changing the API. This is useful since not all computers support realtime raytracing.

    Derived classes

    @@ -119,10 +119,11 @@

    Public functions

    Gets the current size of the renderer's framebuffers.
    - void render(const glm::mat4& view, + void render(const glm::mat4& view, const Viewport& viewport, const engine::Camera& camera, const RendererFrame& frame, + const core::gl::Framebuffer& pickingBuffer = nullptr, bool usePostProcessing = true, const core::gl::Framebuffer& target = nullptr)
    @@ -141,13 +142,14 @@

    Protected functions

    Called when resize() is called.
    - void onRender(const glm::mat4& view, + void onRender(const glm::mat4& view, const Viewport& viewport, const Camera& camera, const RendererFrame& frame, - core::gl::Framebuffer target) pure virtual + core::gl::Framebuffer target, + core::gl::Framebuffer pickingBuffer) pure virtual
    -
    Called when render() is called, before applying post processing effects.
    +
    Called when render() is called, before applying post processing effects.
    @@ -255,12 +257,13 @@

    -
    +

    - void cubos::engine::BaseRenderer::render(const glm::mat4& view, + void cubos::engine::BaseRenderer::render(const glm::mat4& view, const Viewport& viewport, const engine::Camera& camera, const RendererFrame& frame, + const core::gl::Framebuffer& pickingBuffer = nullptr, bool usePostProcessing = true, const core::gl::Framebuffer& target = nullptr)

    @@ -286,6 +289,10 @@

    frame Frame to draw. + + pickingBuffer + Screen picking framebuffer. + usePostProcessing Whether to use post processing. @@ -329,15 +336,16 @@

    Renderer implementations should override this function to resize their framebuffers.

    -
    +

    - void cubos::engine::BaseRenderer::onRender(const glm::mat4& view, + void cubos::engine::BaseRenderer::onRender(const glm::mat4& view, const Viewport& viewport, const Camera& camera, const RendererFrame& frame, - core::gl::Framebuffer target) pure virtual protected + core::gl::Framebuffer target, + core::gl::Framebuffer pickingBuffer) pure virtual protected

    -

    Called when render() is called, before applying post processing effects.

    +

    Called when render() is called, before applying post processing effects.

    @@ -363,6 +371,10 @@

    + + + +
    Parameters
    target Target framebuffer.
    pickingBufferScreen picking framebuffer.

    Renderer implementations should implement this function to draw the frame. When post processing is enabled, the target framebuffer will be the internal texture which will be used for post processing.

    diff --git a/docs-preview/pr-880/classcubos_1_1engine_1_1DeferredRenderer.html b/docs-preview/pr-880/classcubos_1_1engine_1_1DeferredRenderer.html index 8dc14dd66..3c68c7ae6 100644 --- a/docs-preview/pr-880/classcubos_1_1engine_1_1DeferredRenderer.html +++ b/docs-preview/pr-880/classcubos_1_1engine_1_1DeferredRenderer.html @@ -106,13 +106,14 @@

    Protected functions

    Called when resize() is called.
    - void onRender(const glm::mat4& view, + void onRender(const glm::mat4& view, const Viewport& viewport, const Camera& camera, const RendererFrame& frame, - core::gl::Framebuffer target) override + core::gl::Framebuffer target, + core::gl::Framebuffer pickingBuffer) override
    -
    Called when render() is called, before applying post processing effects.
    +
    Called when render() is called, before applying post processing effects.
    @@ -202,15 +203,16 @@

    Renderer implementations should override this function to resize their framebuffers.

    -
    +

    - void cubos::engine::DeferredRenderer::onRender(const glm::mat4& view, + void cubos::engine::DeferredRenderer::onRender(const glm::mat4& view, const Viewport& viewport, const Camera& camera, const RendererFrame& frame, - core::gl::Framebuffer target) override protected + core::gl::Framebuffer target, + core::gl::Framebuffer pickingBuffer) override protected

    -

    Called when render() is called, before applying post processing effects.

    +

    Called when render() is called, before applying post processing effects.

    @@ -236,6 +238,10 @@

    + + + +
    Parameters
    target Target framebuffer.
    pickingBufferScreen picking framebuffer.

    Renderer implementations should implement this function to draw the frame. When post processing is enabled, the target framebuffer will be the internal texture which will be used for post processing.

    diff --git a/docs-preview/pr-880/classcubos_1_1engine_1_1FileBridge.html b/docs-preview/pr-880/classcubos_1_1engine_1_1FileBridge.html index 942230331..043270055 100644 --- a/docs-preview/pr-880/classcubos_1_1engine_1_1FileBridge.html +++ b/docs-preview/pr-880/classcubos_1_1engine_1_1FileBridge.html @@ -92,6 +92,11 @@

    Derived classes

    class SceneBridge
    Bridge which loads and saves Scene assets.
    +
    +
    template<typename T>
    + class JSONBridge +
    +
    Bridge for loading and saving assets which are serialized to and from a JSON file.
    diff --git a/docs-preview/pr-880/classcubos_1_1engine_1_1Gizmos.html b/docs-preview/pr-880/classcubos_1_1engine_1_1Gizmos.html index 0075b8abe..c5e4572d3 100644 --- a/docs-preview/pr-880/classcubos_1_1engine_1_1Gizmos.html +++ b/docs-preview/pr-880/classcubos_1_1engine_1_1Gizmos.html @@ -111,6 +111,16 @@

    Public functions

    Space space = Space::World)
    Draws a cut cone gizmo.
    +
    + void drawRing(const std::string& id, + glm::vec3 firstBasePosition, + glm::vec3 secondBasePosition, + float outerRadius, + float innerRadius, + float lifespan = 0.0F, + Space space = Space::World) +
    +
    Draws a ring gizmo.
    void drawArrow(const std::string& id, glm::vec3 origin, @@ -346,6 +356,53 @@

    +
    +

    + void cubos::engine::Gizmos::drawRing(const std::string& id, + glm::vec3 firstBasePosition, + glm::vec3 secondBasePosition, + float outerRadius, + float innerRadius, + float lifespan = 0.0F, + Space space = Space::World) +

    +

    Draws a ring gizmo.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Parameters
    idIdentifier of the gizmo.
    firstBasePositionCenter of one of the bases.
    secondBasePositionCenter of the second base.
    outerRadiusRadius of one of the ring.
    innerRadiusRadius of the of the hole.
    lifespanHow long the line will be on screen for, in seconds. Defaults to 0, which means a single frame.
    spaceSpace to draw the gizmo in.
    +

    void cubos::engine::Gizmos::drawArrow(const std::string& id, diff --git a/docs-preview/pr-880/classcubos_1_1engine_1_1JSONBridge.html b/docs-preview/pr-880/classcubos_1_1engine_1_1JSONBridge.html index 30bc414f8..9eaaa5779 100644 --- a/docs-preview/pr-880/classcubos_1_1engine_1_1JSONBridge.html +++ b/docs-preview/pr-880/classcubos_1_1engine_1_1JSONBridge.html @@ -88,8 +88,8 @@

    Base classes

    Constructors, destructors, conversion operators

    -
    - JSONBridge(int indentation = 4) +
    + JSONBridge()
    Constructs a bridge.
    @@ -113,27 +113,6 @@

    Protected functions

    Function documentation

    -
    -

    -
    - template<typename T> -
    - cubos::engine::JSONBridge<T>::JSONBridge(int indentation = 4) -

    -

    Constructs a bridge.

    - - - - - - - - - - -
    Parameters
    indentationIndentation level to use when saving the JSON file.
    -

    If the indentation level is set to -1, all whitespace is removed.

    -

    diff --git a/docs-preview/pr-880/classcubos_1_1engine_1_1RendererFrame.html b/docs-preview/pr-880/classcubos_1_1engine_1_1RendererFrame.html index 3687540a7..89a627958 100644 --- a/docs-preview/pr-880/classcubos_1_1engine_1_1RendererFrame.html +++ b/docs-preview/pr-880/classcubos_1_1engine_1_1RendererFrame.html @@ -76,8 +76,9 @@

    Public types

    Public functions

    - void draw(RendererGrid grid, - glm::mat4 modelMat) + void draw(RendererGrid grid, + glm::mat4 modelMat, + uint32_t entityIndex)
    Submits a draw command.
    @@ -136,10 +137,11 @@

    Public functions

    Function documentation

    -
    +

    - void cubos::engine::RendererFrame::draw(RendererGrid grid, - glm::mat4 modelMat) + void cubos::engine::RendererFrame::draw(RendererGrid grid, + glm::mat4 modelMat, + uint32_t entityIndex)

    Submits a draw command.

    @@ -155,6 +157,10 @@

    + + + +
    modelMat Model matrix of the grid, used for applying transformations.
    entityIndexIdentifier of the entity being drawn.
    diff --git a/docs-preview/pr-880/classcubos_1_1engine_1_1SceneBridge.html b/docs-preview/pr-880/classcubos_1_1engine_1_1SceneBridge.html index 75d846c3e..87462feca 100644 --- a/docs-preview/pr-880/classcubos_1_1engine_1_1SceneBridge.html +++ b/docs-preview/pr-880/classcubos_1_1engine_1_1SceneBridge.html @@ -92,7 +92,8 @@

    Base classes

    Constructors, destructors, conversion operators

    - SceneBridge(core::reflection::TypeRegistry components) + SceneBridge(core::reflection::TypeRegistry components, + core::reflection::TypeRegistry relations)
    Constructs a bridge.
    @@ -104,6 +105,10 @@

    Public functions

    auto components() -> core::reflection::TypeRegistry&
    Returns the type registry used to deserialize components.
    +
    + auto relations() -> core::reflection::TypeRegistry& +
    +
    Returns the type registry used to deserialize relations.
    @@ -125,9 +130,10 @@

    Protected functions

    Function documentation

    -
    +

    - cubos::engine::SceneBridge::SceneBridge(core::reflection::TypeRegistry components) + cubos::engine::SceneBridge::SceneBridge(core::reflection::TypeRegistry components, + core::reflection::TypeRegistry relations)

    Constructs a bridge.

    @@ -139,6 +145,10 @@

    + + + +
    components Component type registry.
    relationsRelation type registry.
    @@ -156,6 +166,20 @@

    +
    +

    + core::reflection::TypeRegistry& cubos::engine::SceneBridge::relations() +

    +

    Returns the type registry used to deserialize relations.

    + + + + + + + +
    ReturnsRelations type registry.
    +

    bool cubos::engine::SceneBridge::loadFromFile(Assets& assets, diff --git a/docs-preview/pr-880/classcubos_1_1engine_1_1ScreenPicker.html b/docs-preview/pr-880/classcubos_1_1engine_1_1ScreenPicker.html index 75cb4e1d5..d95e11cd9 100644 --- a/docs-preview/pr-880/classcubos_1_1engine_1_1ScreenPicker.html +++ b/docs-preview/pr-880/classcubos_1_1engine_1_1ScreenPicker.html @@ -47,7 +47,7 @@

    cubos::engine::ScreenPicker class final - +

    Resource which provides a texture to store entity/gizmo ids, for selection with a mouse.

    -
    -

    Public types

    +

    This bridge automatically serializes and deserializes assets of type T to and from a JSON file. Thus, T must be serializable and deserializable. No additional context is given to the serializer or deserializer.

    +
    +

    Base classes

    -
    - using Type = char +
    + class cubos::engine::FileBridge
    -
    Type of the fetched data.
    +
    Abstract bridge type defined to reduce boilerplate code in bridge implementations which open a single file to load and save assets.
    -
    -

    Public static functions

    +
    +

    Constructors, destructors, conversion operators

    - static void add(SystemInfo& info) -
    -
    Adds the argument T to the given info.
    -
    - static auto prepare(World& world) -> State + JSONBridge(int indentation = 4)
    -
    Prepares the argument for being executed on the given world.
    +
    Constructs a bridge.
    +
    +
    +
    +

    Protected functions

    +
    - static auto fetch(World& world, - CommandBuffer& commands, - State& state) -> Type + auto loadFromFile(Assets& assets, + const AnyAsset& handle, + core::memory::Stream& stream) -> bool override
    -
    Fetches the data from the given world.
    +
    Loads an asset from a file stream.
    - static auto arg(Type&& fetched) -> T + auto saveToFile(const Assets& assets, + const AnyAsset& handle, + core::memory::Stream& stream) -> bool override
    -
    Converts the fetched data into the actual desired argument.
    +
    Saves an asset to a file stream.

    Function documentation

    -
    -

    -
    - template<typename T> -
    - static void cubos::core::ecs::impl::SystemFetcher<T>::add(SystemInfo& info) -

    -

    Adds the argument T to the given info.

    - - - - - - - - - - -
    Parameters
    info outSystem information.
    -
    -
    +

    template<typename T>
    - static State cubos::core::ecs::impl::SystemFetcher<T>::prepare(World& world) + cubos::engine::old::JSONBridge<T>::JSONBridge(int indentation = 4)

    -

    Prepares the argument for being executed on the given world.

    +

    Constructs a bridge.

    - - + + - - - - - -
    Parameters
    worldWorld to prepare the argument for.indentationIndentation level to use when saving the JSON file.
    ReturnsState of the argument.
    +

    If the indentation level is set to -1, all whitespace is removed.

    -
    +

    template<typename T>
    - static Type cubos::core::ecs::impl::SystemFetcher<T>::fetch(World& world, - CommandBuffer& commands, - State& state) + bool cubos::engine::old::JSONBridge<T>::loadFromFile(Assets& assets, + const AnyAsset& handle, + core::memory::Stream& stream) override protected

    -

    Fetches the data from the given world.

    +

    Loads an asset from a file stream.

    - - + + - - + + - - + + - +
    Parameters
    worldWorld to fetch the data from.assetsManager to write into.
    commandsBuffer where commands can be submitted to.handleHandle of the asset being loaded.
    stateState of the argument.streamFile stream.
    ReturnsFetched data.Whether the asset was successfully loaded.
    -
    +

    template<typename T>
    - static T cubos::core::ecs::impl::SystemFetcher<T>::arg(Type&& fetched) + bool cubos::engine::old::JSONBridge<T>::saveToFile(const Assets& assets, + const AnyAsset& handle, + core::memory::Stream& stream) override protected

    -

    Converts the fetched data into the actual desired argument.

    +

    Saves an asset to a file stream.

    - - + + + + + + + + + + - +
    Parameters
    fetchedFetched data.assetsManager to read from.
    handleHandle of the asset being saved.
    streamFile stream.
    ReturnsActual argument.Whether the asset was successfully saved.
    diff --git a/docs-preview/pr-880/commands_8hpp.html b/docs-preview/pr-880/commands_8hpp.html index 3b3e74472..6b0bfdd3e 100644 --- a/docs-preview/pr-880/commands_8hpp.html +++ b/docs-preview/pr-880/commands_8hpp.html @@ -2,7 +2,7 @@ - core/ecs/system/commands.hpp file | CUBOS. Docs + core/ecs/system/arguments/commands.hpp file | CUBOS. Docs @@ -46,7 +46,7 @@

    - core/ecs/system/commands.hpp file + core/ecs/system/arguments/commands.hpp file

    Class cubos::core::ecs::Commands.

    diff --git a/docs-preview/pr-880/cubos_8hpp.html b/docs-preview/pr-880/cubos_8hpp.html index aaeac5659..797524138 100644 --- a/docs-preview/pr-880/cubos_8hpp.html +++ b/docs-preview/pr-880/cubos_8hpp.html @@ -2,7 +2,7 @@ - engine/cubos.hpp file | CUBOS. Docs + core/ecs/cubos.hpp file | CUBOS. Docs @@ -46,9 +46,9 @@

    - engine/cubos.hpp file + core/ecs/cubos.hpp file

    -

    Class cubos::engine::Cubos.

    +

    Class cubos::engine::Cubos.

    Classes

    - struct cubos::engine::DeltaTime + struct cubos::core::ecs::DeltaTime
    Resource which stores the time since the last iteration of the main loop started.
    - struct cubos::engine::ShouldQuit + struct cubos::core::ecs::ShouldQuit
    Resource used as a flag to indicate whether the main loop should stop running.
    - struct cubos::engine::Arguments + struct cubos::core::ecs::Arguments
    Resource which stores the command-line arguments.
    - class cubos::engine::TagBuilder + class cubos::core::ecs::TagBuilder
    Used to chain configurations related to tags.
    - class cubos::engine::SystemBuilder -
    -
    Used to chain configurations related to systems.
    -
    - class cubos::engine::Cubos + class cubos::core::ecs::Cubos
    Represents the engine itself, and exposes the interface with which the game developer interacts with. Ties up all the different parts of the engine together.
    diff --git a/docs-preview/pr-880/dir_1849b6590c20a7c40f18c0337f505edf.html b/docs-preview/pr-880/dir_1849b6590c20a7c40f18c0337f505edf.html index 0e3bdc045..2f5a1912a 100644 --- a/docs-preview/pr-880/dir_1849b6590c20a7c40f18c0337f505edf.html +++ b/docs-preview/pr-880/dir_1849b6590c20a7c40f18c0337f505edf.html @@ -64,21 +64,23 @@

    Contents

    Directories

    -
    directory event/
    -
    Event system arguments directory.
    +
    directory arguments/
    +
    System arguments directory.

    Files

    -
    file commands.hpp
    -
    Class cubos::core::ecs::Commands.
    +
    file access.hpp
    +
    Struct cubos::core::ecs::SystemAccess.
    file dispatcher.hpp
    Class cubos::core::ecs::Dispatcher.
    -
    file query.hpp
    -
    Class cubos::core::ecs::Query.
    +
    file fetcher.hpp
    +
    Class cubos::core::ecs::SystemFetcher.
    +
    file options.hpp
    +
    Struct cubos::core::ecs::SystemOptions.
    file system.hpp
    -
    Class cubos::core::ecs::SystemWrapper and related types.
    +
    Class cubos::core::ecs::System.
    diff --git a/docs-preview/pr-880/dir_26a5878ebb5e9988b6ffa6f152301254.html b/docs-preview/pr-880/dir_26a5878ebb5e9988b6ffa6f152301254.html index 0d4997d7b..8714db36a 100644 --- a/docs-preview/pr-880/dir_26a5878ebb5e9988b6ffa6f152301254.html +++ b/docs-preview/pr-880/dir_26a5878ebb5e9988b6ffa6f152301254.html @@ -63,11 +63,9 @@

    Contents

    Files

    -
    file access.hpp
    -
    Struct cubos::core::ecs::QueryAccess.
    file data.hpp
    Class cubos::core::ecs::QueryData.
    -
    file fetcher.hpp
    +
    file fetcher.hpp
    Class cubos::core::ecs::QueryFetcher.
    file filter.hpp
    Class cubos::core::ecs::QueryFilter.
    diff --git a/docs-preview/pr-880/dir_3764e76d8ec4e739fc24b5bb90adc3af.html b/docs-preview/pr-880/dir_3764e76d8ec4e739fc24b5bb90adc3af.html index 3e8fef415..505b7290b 100644 --- a/docs-preview/pr-880/dir_3764e76d8ec4e739fc24b5bb90adc3af.html +++ b/docs-preview/pr-880/dir_3764e76d8ec4e739fc24b5bb90adc3af.html @@ -71,8 +71,6 @@

    Files

    Struct cubos::core::ecs::Entity.
    file hash.hpp
    Struct cubos::core::ecs::EntityHash.
    -
    file manager.hpp
    -
    Class cubos::core::ecs::EntityManager.
    file pool.hpp
    Class cubos::core::ecs::EntityPool.
    diff --git a/docs-preview/pr-880/dir_cae59223029cd41c022c5f7665ca4fec.html b/docs-preview/pr-880/dir_57aff98960b24114775613a58ec786ad.html similarity index 92% rename from docs-preview/pr-880/dir_cae59223029cd41c022c5f7665ca4fec.html rename to docs-preview/pr-880/dir_57aff98960b24114775613a58ec786ad.html index 7b81f3f1f..c4424bb49 100644 --- a/docs-preview/pr-880/dir_cae59223029cd41c022c5f7665ca4fec.html +++ b/docs-preview/pr-880/dir_57aff98960b24114775613a58ec786ad.html @@ -2,7 +2,7 @@ - engine/screenpicker/ directory | CUBOS. Docs + engine/screen_picker/ directory | CUBOS. Docs @@ -46,9 +46,9 @@

    - engine/screenpicker/ directory + engine/screen_picker/ directory

    -

    ScreenPicker plugin directory.

    +

    ScreenPicker plugin directory.

    -
    -

    Files

    -
    -
    file cubos.hpp
    -
    Class cubos::engine::Cubos.
    -
    -

    diff --git a/docs-preview/pr-880/engine_2include_2cubos_2engine_2assets_2bridges_2old_2json_8hpp.html b/docs-preview/pr-880/engine_2include_2cubos_2engine_2assets_2bridges_2old_2json_8hpp.html new file mode 100644 index 000000000..889f43d3b --- /dev/null +++ b/docs-preview/pr-880/engine_2include_2cubos_2engine_2assets_2bridges_2old_2json_8hpp.html @@ -0,0 +1,133 @@ + + + + + engine/assets/bridges/old/json.hpp file | CUBOS. Docs + + + + + + + +
    +
    + + + +
    + + diff --git a/docs-preview/pr-880/engine_2include_2cubos_2engine_2screenpicker_2plugin_8hpp.html b/docs-preview/pr-880/engine_2include_2cubos_2engine_2screen__picker_2plugin_8hpp.html similarity index 94% rename from docs-preview/pr-880/engine_2include_2cubos_2engine_2screenpicker_2plugin_8hpp.html rename to docs-preview/pr-880/engine_2include_2cubos_2engine_2screen__picker_2plugin_8hpp.html index a332a7917..2cad6b62c 100644 --- a/docs-preview/pr-880/engine_2include_2cubos_2engine_2screenpicker_2plugin_8hpp.html +++ b/docs-preview/pr-880/engine_2include_2cubos_2engine_2screen__picker_2plugin_8hpp.html @@ -2,7 +2,7 @@ - engine/screenpicker/plugin.hpp file | CUBOS. Docs + engine/screen_picker/plugin.hpp file | CUBOS. Docs @@ -46,7 +46,7 @@

    - engine/screenpicker/plugin.hpp file + engine/screen_picker/plugin.hpp file

    Plugin entry point.

    diff --git a/docs-preview/pr-880/examples-engine-assets-json.html b/docs-preview/pr-880/examples-engine-assets-json.html index 82a5280fa..a8e390e15 100644 --- a/docs-preview/pr-880/examples-engine-assets-json.html +++ b/docs-preview/pr-880/examples-engine-assets-json.html @@ -2,7 +2,7 @@ - Examples » Engine » Assets » Loading Serializable Assets | CUBOS. Docs + Examples » Engine » Assets » Loading Reflectable Assets | CUBOS. Docs @@ -49,9 +49,9 @@

    Examples » Engine » Assets » - Loading Serializable Assets + Loading Reflectable Assets

    -

    Loading serializable assets from JSON.

    +

    Loading reflectable assets from JSON.

    We'll use the following type as an example:

    struct Strings
     {
         CUBOS_REFLECT;
    @@ -61,35 +61,17 @@ 

    CUBOS_REFLECT_IMPL(Strings) { return Type::create("Strings").with(FieldsTrait{}.withField("strings", &Strings::strings)); -}

    We can make it serializable by implementing the following specializations:

    template <>
    -void cubos::core::data::old::serialize<Strings>(Serializer& ser, const Strings& obj, const char* name)
    -{
    -    ser.beginObject(name);
    -    ser.write(obj.strings, "strings");
    -    ser.endObject();
    -}
    +}

    Then, we must register a bridge for this type. We provide JSONBridge for easily loading and saving reflectable assets as JSON.

        cubos.startupSystem("setup bridge to load .strings files").tagged("cubos.assets.bridge").call([](Assets& assets) {
    +        assets.registerBridge(".strings", std::make_unique<JSONBridge<Strings>>());
    +    });

    With the bridge registered, we can just load it from its handle:

        static const Asset<Strings> SampleAsset = AnyAsset("6f42ae5a-59d1-5df3-8720-83b8df6dd536");
     
    -template <>
    -void cubos::core::data::old::deserialize<Strings>(Deserializer& des, Strings& obj)
    -{
    -    des.beginObject();
    -    des.read(obj.strings);
    -    des.endObject();
    -}

    Then, we must register a bridge for this type. We provide JSONBridge for easily loading and saving serializable assets as JSON.

    static void bridgeSystem(Assets& assets)
    -{
    -    assets.registerBridge(".strings", std::make_unique<JSONBridge<Strings>>());
    -}

    With the bridge registered, we can just load it from its handle:

    static const Asset<Strings> SampleAsset = AnyAsset("6f42ae5a-59d1-5df3-8720-83b8df6dd536");
    -
    -static void loadSystem(Assets& assets)
    -{
    -    auto read = assets.read(SampleAsset);
    -    for (const auto& str : read->strings)
    -    {
    -        Stream::stdOut.printf("String: {}\n", str);
    -    }
    -}

    These sytems are configured the usual way, as explained in Introduction and Custom Bridges.

        cubos.addPlugin(assetsPlugin);
    -    cubos.startupSystem(bridgeSystem).tagged("cubos.assets.bridge");
    -    cubos.startupSystem(loadSystem).tagged("cubos.assets");
    + cubos.startupSystem("access .strings asset").tagged("cubos.assets").call([](Assets& assets) { + auto read = assets.read(SampleAsset); + for (const auto& str : read->strings) + { + Stream::stdOut.printf("String: {}\n", str); + } + });

    These sytems are configured the usual way, as explained in Introduction and Custom Bridges.

    diff --git a/docs-preview/pr-880/examples-engine-assets-saving.html b/docs-preview/pr-880/examples-engine-assets-saving.html index 7c45a44df..46e4b8954 100644 --- a/docs-preview/pr-880/examples-engine-assets-saving.html +++ b/docs-preview/pr-880/examples-engine-assets-saving.html @@ -52,10 +52,9 @@

    Creating and Saving

    Creating and saving assets.

    -

    This example demonstrates how a new asset be created programatically and how it can be saved to the assets directory, which is useful while working on tools such as TESSERATOS.

    Before we go any further, if we want to save assets to the filesystem, we must allow assets to be modified. This is done through the following setting:

    static void configSystem(Settings& settings)
    -{
    -    // If we want to save assets, we must set this to false.
    -    settings.setBool("assets.io.readOnly", false);

    We'll use the following asset type as an example, with a JSONBridge registered for it with the extension .int.

    struct IntegerAsset
    +

    This example demonstrates how a new asset can be created programatically and how it can be saved to the assets directory, which is useful while working on tools such as TESSERATOS

    Before we go any further, if we want to save assets to the filesystem, we must allow assets to be modified. This is done through the following setting:

        cubos.startupSystem("configure Assets plugin").tagged("cubos.settings").call([](Settings& settings) {
    +        // If we want to save assets, we must set this to false.
    +        settings.setBool("assets.io.readOnly", false);

    We'll use the following asset type as an example, with a JSONBridge registered for it with the extension .int.

    struct IntegerAsset
     {
         CUBOS_REFLECT;
         int value;
    @@ -64,12 +63,10 @@ 

    CUBOS_REFLECT_IMPL(IntegerAsset) { return Type::create("IntegerAsset").with(FieldsTrait{}.withField("value", &IntegerAsset::value)); -}

    First, we'll create an asset of this type:

    static void saveSystem(Assets& assets)
    -{
    -    // Create a new asset (with a random UUID).
    -    auto handle = assets.create(IntegerAsset{1337});

    Then, we'll assign it a path and save it. Its important that the path ends with the correct extension, so that Assets knows which bridge to use when loading it.

        assets.writeMeta(handle)->set("path", "/assets/sample/sample.int");
    -    assets.save(handle);

    With this, the files sample/sample.int and sample/sample.int.meta should have appeared on the assets/ directory. The .meta file contains the UUID of the asset, which is used by the engine to identify it.

    Finally, the engine is configured the following way:

        cubos.addPlugin(assetsPlugin);
    -    cubos.startupSystem(saveSystem).tagged("cubos.assets");

    Try running the sample yourself to see the files being created!

    +}

    First, we'll create an asset of this type:

        cubos.startupSystem("create and save asset").tagged("cubos.assets").call([](Assets& assets) {
    +        // Create a new asset (with a random UUID).
    +        auto handle = assets.create(IntegerAsset{1337});

    Then, we'll assign it a path and save it. It's important that the path ends with the correct extension, so that Assets knows which bridge to use when loading it.

            assets.writeMeta(handle)->set("path", "/assets/sample/sample.int");
    +        assets.save(handle);

    With this, the files sample/sample.int and sample/sample.int.meta should have appeared on the assets/ directory. The .meta file contains the UUID of the asset, which is used by the engine to identify it.

    Try running the sample yourself to see the files being created!

    diff --git a/docs-preview/pr-880/examples-engine-assets.html b/docs-preview/pr-880/examples-engine-assets.html index 5bdfe7c4b..338f3b9eb 100644 --- a/docs-preview/pr-880/examples-engine-assets.html +++ b/docs-preview/pr-880/examples-engine-assets.html @@ -51,7 +51,7 @@

    Assets

    How to use the Assets plugin.

    -

    +

    diff --git a/docs-preview/pr-880/examples-engine-events.html b/docs-preview/pr-880/examples-engine-events.html index 9d78ba174..8b825c061 100644 --- a/docs-preview/pr-880/examples-engine-events.html +++ b/docs-preview/pr-880/examples-engine-events.html @@ -54,34 +54,24 @@

    This example shows how the EventReader and the EventWriter system arguments can be used to communicate from one system to another.

    Firstly, we need to create and register the event we want to emit. Here, our event is a simple struct with a single field, however, you can use any type you want.

    struct MyEvent
     {
         int value;
    -};
        cubos.addEvent<MyEvent>();

    To receive these events, we can make a simple system which takes the EventReader system argument and iterates through all the events it has. This will be the layout of all our reader systems (A, C, D).

    static void firstSystem(EventReader<MyEvent> reader)
    -{
    -    for (const auto& event : reader)
    -    {
    -        CUBOS_INFO("A read {}", event.value);
    -    }
    -}

    Now, to emit these events, we will use the EventWriter system argument. This system will emit 3 events on the first frame and another 3 on the second frame. By setting the value of the ShouldQuit resource to true on the second frame, the engine stops before reaching the third frame.

    static void secondSystem(EventWriter<MyEvent> writer, State& state, ShouldQuit& quit)
    -{
    -    state.step += 1;
    -    if (state.step == 1) // Write 1 2 3 on first run.
    -    {
    -        writer.push({1});
    -        writer.push({2});
    -        writer.push({3});
    -        CUBOS_INFO("B wrote 1 2 3");
    -    }
    -    else if (state.step == 2)
    -    {
    -        quit.value = true; // Stop the loop.
    -        writer.push({4});
    -        writer.push({5});
    -        writer.push({6});
    -        CUBOS_INFO("B wrote 4 5 6");
    -    }
    -}

    Lastly, let's set the order we want these system to execute in.

        cubos.system(firstSystem).tagged("A").before("B");
    -    cubos.system(secondSystem).tagged("B");
    -    cubos.system(thirdSystem).tagged("C").after("B");
    -    cubos.system(fourthSystem).tagged("D").after("C");

    These are the expected results with this order.

        // Should print:
    +};
        cubos.addEvent<MyEvent>();

    To receive these events, we can make a simple system which takes the EventReader system argument and iterates through all the events it has. This will be the layout of all our reader systems (A, C, D).

    Now, to emit these events, we will use the EventWriter system argument. This system will emit 3 events on the first frame and another 3 on the second frame. By setting the value of the ShouldQuit resource to true on the second frame, the engine stops before reaching the third frame.

        cubos.system("B").tagged("b").call([](EventWriter<MyEvent> writer, State& state, ShouldQuit& quit) {
    +        state.step += 1;
    +        if (state.step == 1) // Write 1 2 3 on first run.
    +        {
    +            writer.push({1});
    +            writer.push({2});
    +            writer.push({3});
    +            CUBOS_INFO("B wrote 1 2 3");
    +        }
    +        else if (state.step == 2)
    +        {
    +            quit.value = true; // Stop the loop.
    +            writer.push({4});
    +            writer.push({5});
    +            writer.push({6});
    +            CUBOS_INFO("B wrote 4 5 6");
    +        }
    +    });

    These are the expected results with this order.

        // Should print:
         // B wrote 1 2 3
         // C read 1
         // C read 2
    diff --git a/docs-preview/pr-880/examples-engine-gizmos.html b/docs-preview/pr-880/examples-engine-gizmos.html
    index 1db9fe91d..421fbb3a1 100644
    --- a/docs-preview/pr-880/examples-engine-gizmos.html
    +++ b/docs-preview/pr-880/examples-engine-gizmos.html
    @@ -52,55 +52,56 @@ 

    Using the Gizmos plugin.

    This example shows the Gizmos plugin, which allows drawing simple primitives. These are not intended for use in the final product, only in developer tools and for debugging.

    The plugin function is included from the engine/gizmos/plugin.hpp header.

        Cubos cubos{argc, argv};
    -    cubos.addPlugin(gizmosPlugin);

    To draw a gizmo, all you need to do is to get a reference to the cubos::engine::Gizmos resource, and then call the draw function on it for the gizmo you want to draw. Additionally, you can also call the cubos::engine::Gizmos::color function to set the color for future gizmos. So, for example if you want to draw an arrow in a given system, all you need to do is the following:

    static void drawStartingLineSystem(Gizmos& gizmos)
    -{
    -    gizmos.color({1, 0, 1});
    -    gizmos.drawArrow("arrow", {0.6F, 0.6F, 0.0F}, {-0.1F, -0.1F, 0.0F}, 0.003F, 0.009F, 0.7F, 10.0F,
    -                     Gizmos::Space::Screen);
    -}

    This code will draw an arrow poiting at the center of the screen, and it will stay there for 10 seconds.

    In this other example, we draw lines, a box, and a wire box. Unlike the one in the previous example, this system is not a start-up system, so the draw functions get called every single frame. When this happens, you should set the lifetime of a gizmo to 0, which means it will be drawn for a single frame only. This way we avoid drawing gizmos on top of identical ones that were already there, or in the case of moving gizmos, leaving a trail of old version behind them.

    Let's start with the lines. We are using four cameras in our scene, so let's add two lines to separate each camera. These lines will be in Screen space, as we want them to be just drawn once, indepently of the number of cameras; and we want them to use screen coordinates, as they should be drawn in the middle of the screen.

        gizmos.color({1.0F, 1.0F, 1.0F});
    -    gizmos.drawLine("separator line", {1.0F, 0.5F, 0.5F}, {0.0F, 0.5F, 0.5F}, 0, Gizmos::Space::Screen);
    -    gizmos.drawLine("separator line", {0.5F, 1.0F, 0.5F}, {0.5F, 0.0F, 0.5F}, 0, Gizmos::Space::Screen);

    Let's now add a wireboxe. We want to know were exactly is the centre of each camera, so let's add a reticule. This box will be in View space, as we want it to be drawn once per camera and we want it to use view coordinates, as it should be drawn in the middle of each viewport.

        gizmos.color({1.0F, 0.5F, 1.0F});
    -    gizmos.drawBox("box", {0.4, 0.4, 0}, {0.55, 0.55, 0}, 0, Gizmos::Space::View);

    Let's add a box. This box will be in World space, as it's the last space left to cover. It will be drawn by any camera that is looking at it, much like if it was an object in the world.

        gizmos.color({0.2F, 0.2F, 1.0F});
    -    gizmos.drawWireBox("wire box", {-5, -5, -5}, {-7, -7, -7}, 0, Gizmos::Space::World);

    Finally let's add a cut cone. A cut cone is cylinder with faces that can have different radiuses. If you set one of the bases to have a radius of 0, you'll have a simple cone. If you set them both to have the same radius, you'll have a cylinder. Our cut cone will have different radiuses:

        if (gizmos.hovered("cut cone"))
    -    {
    -        gizmos.color({0.25F, 0.15F, 0.5F});
    -    }
    -    else if (gizmos.pressed("cut cone"))
    -    {
    -        gizmos.color({0.5F, 0.3F, 1});
    -    }
    -    else
    -    {
    -        gizmos.color({0.1F, 0.05F, 0.25F});
    -    }
    +    cubos.addPlugin(gizmosPlugin);

    To draw a gizmo, all you need to do is to get a reference to the cubos::engine::Gizmos resource, and then call the draw function on it for the gizmo you want to draw. Additionally, you can also call the cubos::engine::Gizmos::color function to set the color for future gizmos. So, for example if you want to draw an arrow in a given system, all you need to do is the following:

        cubos.startupSystem("draw line at startup")
    +        .tagged("sample.init")
    +        .after("cubos.gizmos.init")
    +        .call([](Gizmos& gizmos) {
    +            gizmos.color({1, 0, 1});
    +            gizmos.drawArrow("arrow", {0.6F, 0.6F, 0.0F}, {-0.1F, -0.1F, 0.0F}, 0.003F, 0.009F, 0.7F, 10.0F,
    +                             Gizmos::Space::Screen);
    +        });

    This code will draw an arrow poiting at the center of the screen, and it will stay there for 10 seconds.

    In this other example, we draw lines, a box, and a wire box. Unlike the one in the previous example, this system is not a start-up system, so the draw functions get called every single frame. When this happens, you should set the lifetime of a gizmo to 0, which means it will be drawn for a single frame only. This way we avoid drawing gizmos on top of identical ones that were already there, or in the case of moving gizmos, leaving a trail of old version behind them.

    Let's start with the lines. We are using four cameras in our scene, so let's add two lines to separate each camera. These lines will be in Screen space, as we want them to be just drawn once, indepently of the number of cameras; and we want them to use screen coordinates, as they should be drawn in the middle of the screen.

            gizmos.color({1.0F, 1.0F, 1.0F});
    +        gizmos.drawLine("separator line", {1.0F, 0.5F, 0.5F}, {0.0F, 0.5F, 0.5F}, 0, Gizmos::Space::Screen);
    +        gizmos.drawLine("separator line", {0.5F, 1.0F, 0.5F}, {0.5F, 0.0F, 0.5F}, 0, Gizmos::Space::Screen);

    Let's now add a wireboxe. We want to know were exactly is the centre of each camera, so let's add a reticule. This box will be in View space, as we want it to be drawn once per camera and we want it to use view coordinates, as it should be drawn in the middle of each viewport.

            gizmos.color({1.0F, 0.5F, 1.0F});
    +        gizmos.drawBox("box", {0.4, 0.4, 0}, {0.55, 0.55, 0}, 0, Gizmos::Space::View);

    Let's add a box. This box will be in World space, as it's the last space left to cover. It will be drawn by any camera that is looking at it, much like if it was an object in the world.

            gizmos.color({0.2F, 0.2F, 1.0F});
    +        gizmos.drawWireBox("wire box", {-5, -5, -5}, {-7, -7, -7}, 0, Gizmos::Space::World);

    Finally let's add a cut cone. A cut cone is cylinder with faces that can have different radiuses. If you set one of the bases to have a radius of 0, you'll have a simple cone. If you set them both to have the same radius, you'll have a cylinder. Our cut cone will have different radiuses:

            if (gizmos.hovered("cut cone"))
    +        {
    +            gizmos.color({0.25F, 0.15F, 0.5F});
    +        }
    +        else if (gizmos.pressed("cut cone"))
    +        {
    +            gizmos.color({0.5F, 0.3F, 1});
    +        }
    +        else
    +        {
    +            gizmos.color({0.1F, 0.05F, 0.25F});
    +        }
     
    -    gizmos.drawCutCone("cut cone", {0.7F, 0.7F, 0.7F}, 5.0F, {-3, -3, -3}, 3.0F, 0, Gizmos::Space::World);

    For the cut cone, we'll set the color a bit differently: We'll make it so the color of the cone changes depending on whether you are pressing the cone, or have your mouse over it. We'll make it a bit darker while the mouse is not over the cone, a bit lighter when it is, and even lighter when the cone is pressed.

    The whole system looks like this:

    static void drawSystem(Gizmos& gizmos)
    -{
    -    gizmos.color({1.0F, 1.0F, 1.0F});
    -    gizmos.drawLine("separator line", {1.0F, 0.5F, 0.5F}, {0.0F, 0.5F, 0.5F}, 0, Gizmos::Space::Screen);
    -    gizmos.drawLine("separator line", {0.5F, 1.0F, 0.5F}, {0.5F, 0.0F, 0.5F}, 0, Gizmos::Space::Screen);
    +        gizmos.drawCutCone("cut cone", {0.7F, 0.7F, 0.7F}, 5.0F, {-3, -3, -3}, 3.0F, 0, Gizmos::Space::World);

    For the cut cone, we'll set the color a bit differently: We'll make it so the color of the cone changes depending on whether you are pressing the cone, or have your mouse over it. We'll make it a bit darker while the mouse is not over the cone, a bit lighter when it is, and even lighter when the cone is pressed.

    The whole system looks like this:

        cubos.system("draw gizmos").call([](Gizmos& gizmos) {
    +        gizmos.color({1.0F, 1.0F, 1.0F});
    +        gizmos.drawLine("separator line", {1.0F, 0.5F, 0.5F}, {0.0F, 0.5F, 0.5F}, 0, Gizmos::Space::Screen);
    +        gizmos.drawLine("separator line", {0.5F, 1.0F, 0.5F}, {0.5F, 0.0F, 0.5F}, 0, Gizmos::Space::Screen);
     
    -    gizmos.color({1.0F, 0.5F, 1.0F});
    -    gizmos.drawBox("box", {0.4, 0.4, 0}, {0.55, 0.55, 0}, 0, Gizmos::Space::View);
    +        gizmos.color({1.0F, 0.5F, 1.0F});
    +        gizmos.drawBox("box", {0.4, 0.4, 0}, {0.55, 0.55, 0}, 0, Gizmos::Space::View);
     
    -    gizmos.color({0.2F, 0.2F, 1.0F});
    -    gizmos.drawWireBox("wire box", {-5, -5, -5}, {-7, -7, -7}, 0, Gizmos::Space::World);
    +        gizmos.color({0.2F, 0.2F, 1.0F});
    +        gizmos.drawWireBox("wire box", {-5, -5, -5}, {-7, -7, -7}, 0, Gizmos::Space::World);
     
    -    if (gizmos.hovered("cut cone"))
    -    {
    -        gizmos.color({0.25F, 0.15F, 0.5F});
    -    }
    -    else if (gizmos.pressed("cut cone"))
    -    {
    -        gizmos.color({0.5F, 0.3F, 1});
    -    }
    -    else
    -    {
    -        gizmos.color({0.1F, 0.05F, 0.25F});
    -    }
    +        if (gizmos.hovered("cut cone"))
    +        {
    +            gizmos.color({0.25F, 0.15F, 0.5F});
    +        }
    +        else if (gizmos.pressed("cut cone"))
    +        {
    +            gizmos.color({0.5F, 0.3F, 1});
    +        }
    +        else
    +        {
    +            gizmos.color({0.1F, 0.05F, 0.25F});
    +        }
     
    -    gizmos.drawCutCone("cut cone", {0.7F, 0.7F, 0.7F}, 5.0F, {-3, -3, -3}, 3.0F, 0, Gizmos::Space::World);
    -}
    + gizmos.drawCutCone("cut cone", {0.7F, 0.7F, 0.7F}, 5.0F, {-3, -3, -3}, 3.0F, 0, Gizmos::Space::World); + });
    diff --git a/docs-preview/pr-880/examples-engine-hello-cubos.html b/docs-preview/pr-880/examples-engine-hello-cubos.html index 1ae4f22fe..ee0159ded 100644 --- a/docs-preview/pr-880/examples-engine-hello-cubos.html +++ b/docs-preview/pr-880/examples-engine-hello-cubos.html @@ -50,53 +50,41 @@

    Engine » Hello CUBOS.

    -

    Using Cubos to create a simple program.

    -

    This example shows the basics of how cubos::engine::Cubos is used, by making a simple "Hello World" program.

    #include <cubos/engine/cubos.hpp>
    +        

    Using Cubos to create a simple program.

    +

    This example shows the basics of how cubos::engine::Cubos is used, by making a simple "Hello World" program.

    #include <cubos/engine/prelude.hpp>
     
    -using cubos::engine::Cubos;

    First we'll need to get a Cubos object.

    int main()
    +using namespace cubos::engine;

    First we'll need to get a Cubos object.

    int main()
     {
    -    Cubos cubos{};

    The Cubos class represents the engine. We'll need it to add functionality to our program.

    Let's start by defining what functionality we want to add.

    static void sayHelloCubosSystem()
    -{
    -    CUBOS_INFO("Hello CUBOS");
    -}

    This function simply prints Hello CUBOS to the console. It uses one of CUBOS.'s logging macros. You can find more about them here. However, this function is not currently called, so we'll need to tell CUBOS. that we want it to run.

        cubos.startupSystem(sayHelloCubosSystem);

    Startup systems run only once when the engine is loaded. Now let's make things more interesting. Let's print Hello World, but split it over two different systems.

    static void sayHelloSystem()
    -{
    -    CUBOS_INFO("Hello");
    -}
    -
    -static void sayWorldSystem()
    -{
    -    CUBOS_INFO("World");
    -}

    Instead of using startupSystem, we'll use Cubos::system. This means the systems will be called after the startup systems and repeat every cycle, instead of just once at startup.

    However, we can't just do as we did for sayHelloCubos and call it a day. We want sayHello to come before sayWorld, so we'll have to explicitly tell that to the engine, or else we risk having them in the wrong order. To do that we use tags. Let's create two tags, one for each system.

        cubos.tag("helloTag").before("worldTag");

    Cubos::tag creates a new tag, and before makes any systems tagged with it come before systems tagged with the one given as parameter. There's also an after that has the inverse effect. Now all we have to do is to assign these tags to our systems.

        cubos.system(sayHelloSystem).tagged("helloTag");
    -    cubos.system(sayWorldSystem).tagged("worldTag");

    Now let's see a bit about entities, components and resources. First we are going to need to use a few more things. We'll go over what each does as it comes up.

    Entities have components, so let's create one to give our entities. Because of how the engine works, we cannot declare a component on our main.cpp file. We'll need to create a components.hpp for that.

    #pragma once
    -
    -#include <cubos/core/ecs/world.hpp>
    -#include <cubos/core/reflection/reflect.hpp>
    +    Cubos cubos{};

    The Cubos class represents the engine. We'll need it to add functionality to our program.

    Let's start by defining what functionality we want to add, by adding our first system.

        cubos.startupSystem("say Hello CUBOS").call([]() { CUBOS_INFO("Hello CUBOS"); });

    This startup system simply prints Hello CUBOS to the console, using one of CUBOS's logging macros. You can find more about them here. Startup systems run only once when the engine is loaded.

    Now let's make things more interesting. Let's print Hello World, but split it over two different systems.

        cubos.system("say Hello").tagged("helloTag").call([]() { CUBOS_INFO("Hello"); });
    +    cubos.system("say World").tagged("worldTag").call([]() { CUBOS_INFO("World"); });

    Instead of using startupSystem, we'll use Cubos::system. This means the systems will be called after the startup systems and repeat every cycle, instead of just once at startup.

    Notice that we can't just do as we did for Hello CUBOS and call it a day. We want Hello to come before World, so we'll have to explicitly tell that to the engine, or else we risk having them in the wrong order. To do that we use tags.

        cubos.tag("helloTag").before("worldTag");

    Cubos::tag can be used to apply properties to all systems with a given tag, and before makes any systems tagged with it come before systems tagged with the one given as parameter. There's also an after that has the inverse effect.

    Now let's see a bit about entities, components and resources. First we are going to need to use a few more things. We'll go over what each does as it comes up.

    Lets define a new component type, which stores a single integer, which we can use to identify the entity.

    #include <cubos/core/ecs/reflection.hpp>
    +#include <cubos/core/reflection/external/primitives.hpp>
     
     struct Num
     {
         CUBOS_REFLECT;
     
         int value;
    -};

    Here we create a component called "num" that stores a single integer. We'll use it as the id of the entity it is attached to. Back on our main.cpp file we'll need to include our new file.

    #include "components.hpp"

    And the component needs to be registered.

        cubos.addComponent<Num>();

    Let's create a resource now. Unlike components, resources can be declared on the main.cpp file, so let's do that.

    struct Pop
    -{
    -    int count;
    -};

    This resource will store the total number of spawned entities, a population counter of sorts. It too needs to be registered.

        cubos.addResource<Pop>();

    Now let's create a startup system that spawns some entities.

    static void spawnEntitiesSystem(Commands cmds, Pop& pop)
    +};
    +
    +CUBOS_REFLECT_IMPL(Num)
     {
    -    for (int i = 0; i < 10; i++)
    -    {
    -        cmds.create().add(Num{i});
    -        pop.count += 1;
    -    }
    -}

    Commands is a system argument that allows us to interact with the world, in this case, by creating entities that have a Num component.

    Write is a system argument that allows us to modify a resource, in this case Pop.

    Finally, we'll want a system that prints our entities.

    static void checkEntitiesSystem(Query<const Num&> query, const Pop& pop)
    +    return cubos::core::ecs::TypeBuilder<Num>("Num").withField("value", &Num::value).build();
    +}

    Notice that not only we define the type, but we also define reflection for it. This is a way to let CUBOS know what our data type is made of, making it compatible with serialization, UI debug tools and others automatically.

    We also need to register the component type with the Cubos object.

        cubos.addComponent<Num>();

    Now, lets create our own resource.

    struct Pop
     {
    -    for (auto [num] : query)
    -    {
    -        CUBOS_INFO("Entity '{}' of '{}'", num.value, pop.count);
    -    }
    -}

    Read is similar to Write, only it just gives us permission to read data from resources and components, we cannot alter them.

    Query allows us to access all entities with a given configuration of components. In this case, it will give us all entities with the Num component.

    To finish configuring our program, we just need to register these two new systems. We'll also have the entities be printed after our Hello World message.

        cubos.startupSystem(spawnEntitiesSystem);
    -
    -    cubos.system(checkEntitiesSystem);

    With everything properly set up, all that remains is to run the engine.

        cubos.run();
    -}
    + int count; +};

    This resource will store the total number of spawned entities, a population counter of sorts. It too needs to be registered.

        cubos.addResource<Pop>();

    Now let's create a startup system that spawns some entities.

        cubos.startupSystem("spawn entities").call([](Commands cmds, Pop& pop) {
    +        for (int i = 0; i < 10; i++)
    +        {
    +            cmds.create().add(Num{i});
    +            pop.count += 1;
    +        }
    +    });

    Commands is a system argument that allows us to interact with the world, in this case, by creating entities that have a Num component.

    To access the resource Pop, we just add a reference to it as a system argument (Pop&).

    Finally, we'll want a system that prints our entities.

        cubos.system("check entities").call([](Query<const Num&> query, const Pop& pop) {
    +        for (auto [num] : query)
    +        {
    +            CUBOS_INFO("Entity '{}' of '{}'", num.value, pop.count);
    +        }
    +    });

    In this case, we don't change Pop, and only read its value. Thus, we use const Pop&. This allows CUBOS to make some optimizations behind the scenes.

    Query allows us to access all entities with a given configuration of components. In this case, it will give us all entities with the Num component.

    With everything properly set up, all that remains is to run the engine.

        cubos.run();
    +}

    Try running the sample yourself, and you should see both the hello world messages and the list of entities we spawned!

    diff --git a/docs-preview/pr-880/examples-engine-imgui.html b/docs-preview/pr-880/examples-engine-imgui.html index a920183ee..cfd192c28 100644 --- a/docs-preview/pr-880/examples-engine-imgui.html +++ b/docs-preview/pr-880/examples-engine-imgui.html @@ -67,14 +67,13 @@

    #include <cubos/core/reflection/traits/nullable.hpp> #include <cubos/engine/imgui/data_inspector.hpp> -#include <cubos/engine/imgui/plugin.hpp>

    Then, make sure to add the plugin.

        cubos.addPlugin(imguiPlugin);

    Once the ImGui plugin is added, you can create systems to display ImGui windows and widgets. Here's an example of how to create an ImGui window.

    static void exampleWindowSystem()
    -{
    -    ImGui::Begin("Dear ImGui + CUBOS.");
    -    ImGui::Text("Hello world!");
    -    ImGui::End();
    +#include <cubos/engine/imgui/plugin.hpp>

    Then, make sure to add the plugin.

        cubos.addPlugin(imguiPlugin);

    Once the ImGui plugin is added, you can create systems to display ImGui windows and widgets. Here's a system which opens an ImGui window, and its demo.

        cubos.system("show ImGui demo").tagged("cubos.imgui").call([]() {
    +        ImGui::Begin("Dear ImGui + CUBOS.");
    +        ImGui::Text("Hello world!");
    +        ImGui::End();
     
    -    ImGui::ShowDemoWindow();
    -}

    Ensure that you add your system with the cubos.imgui tag; otherwise, the ImGui elements from that system won't be be visible.

        cubos.system(exampleWindowSystem).tagged("cubos.imgui");

    Pretty simple right? You're now equipped to craft and utilize ImGui's functions to design your cool user interface.

    Now, we'll also show you how you can use the cubos::engine::DataInspector resource in combination with ImGui integration plugin to inspect/modify data in real time.

    To start off, we'll need to have some sort of dummy data shared across our application, so we can inspect/modify later. Let's create a DummyResource with some fields and fill it with random data.

    struct Person
    +        ImGui::ShowDemoWindow();
    +    });

    Ensure that you add your system with the cubos.imgui tag; otherwise, the ImGui elements from that system won't be be visible.

    Pretty simple right? You're now equipped to craft and utilize ImGui's functions to design your cool user interface.

    Now, we'll also show you how you can use the cubos::engine::DataInspector resource in combination with ImGui integration plugin to inspect/modify data in real time.

    To start off, we'll need to have some sort of dummy data shared across our application, so we can inspect/modify later. Let's create a DummyResource with some fields and fill it with random data.

    struct Person
     {
         CUBOS_REFLECT;
         std::string name;
    @@ -119,20 +118,21 @@ 

    {2, 4}, {3, 6}, {4, 8}, - }});

    Well now, using the cubos::engine::DataInspector is pretty easy, all you have to do is, obviously, access the resource on your system, and use the functions DataInspector::edit and DataInspector::edit.

    static void exampleDataInspectorSystem(DataInspector& inspector, DummyResource& data)
    -{
    -    ImGui::Begin("Data Inspector");
    -    ImGui::BeginTable("id1", 2);
    +                      }});

    Well now, using the cubos::engine::DataInspector is pretty easy, all you have to do is access the resource on your system, and use the functions DataInspector::edit and DataInspector::edit.

        cubos.system("data inspector example")
    +        .tagged("cubos.imgui")
    +        .call([](DataInspector& inspector, DummyResource& data) {
    +            ImGui::Begin("Data Inspector");
    +            ImGui::BeginTable("id1", 2);
     
    -    inspector.show("data.integer", data.integer);
    -    inspector.edit("data.person", data.person);
    -    inspector.edit("data.persons", data.persons);
    -    inspector.edit("data.vec", data.vec);
    -    inspector.edit("data.map", data.map);
    +            inspector.show("data.integer", data.integer);
    +            inspector.edit("data.person", data.person);
    +            inspector.edit("data.persons", data.persons);
    +            inspector.edit("data.vec", data.vec);
    +            inspector.edit("data.map", data.map);
     
    -    ImGui::EndTable();
    -    ImGui::End();
    -}
    Image

    You can find more about how to use Dear ImGui stuff here.

    + ImGui::EndTable(); + ImGui::End(); + });Image

    You can find more about how to use Dear ImGui stuff here.

    diff --git a/docs-preview/pr-880/examples-engine-input.html b/docs-preview/pr-880/examples-engine-input.html index 0d794de5e..34ccb642b 100644 --- a/docs-preview/pr-880/examples-engine-input.html +++ b/docs-preview/pr-880/examples-engine-input.html @@ -153,30 +153,26 @@

    "gamepad": [] } } -}

    There are two types of bindings: actions and axes. An action is an input that only has two states: pressed or not pressed. This would be most keys on a keyboard. An axe is an input that has a numeric value. For example, the joysticks on a controller can go from -1 to 1, depending on how much they are tilt in which direction. Using axes can also be useful for keys with symetric behaviour. For example, in this sample, w sets the vertical axe to 1, while s sets it to -1.

    To define an action or an axe, you simply have to add it to the respective list, giving it a name. The very first action in the file is called next-showcase. Then, if it's an action, you simply have to define which keys trigger it. You can also define key combinations by using a -. To check which strings map to which keys, you check the keyToString function implementation on this file.

    Now that we have our bindings file, let's get our application to do something with it. The first thing we're going to need is a reference to the bindings asset. For the purposes of this sample we can simply use an hardcoded reference to the asset.

    static const Asset<InputBindings> BindingsAsset = AnyAsset("bf49ba61-5103-41bc-92e0-8a442d7842c3");

    To utilize the bindings, loading them is essential. This can be accomplished by establishing two startup systems: one to configure the assets.io.path path and the other to read from the asset and establish the required bindings.

        cubos.startupSystem(config).tagged("cubos.settings");
    -    cubos.startupSystem(init).tagged("cubos.assets");
    static void config(Settings& settings)
    -{
    -    settings.setString("assets.io.path", SAMPLE_ASSETS_FOLDER);
    -}
    -
    -static void init(const Assets& assets, Input& input)
    -{
    -    auto bindings = assets.read<InputBindings>(BindingsAsset);
    -    input.bind(*bindings);
    -    CUBOS_INFO("Loaded bindings: {}", input.bindings().at(0));
    -}

    Getting the input is done through the cubos::engine::Input resource. What this sample does is show in order, a series of prompt to showcase the different functionalities of the Input plugin. For this, it keeps a state integer that indicates the current prompt. Whenever the action next-showcase is triggered, it advances to the next prompt. However, as the plugin currently does not have events, we have to manually check whether the key has just been pressed, is being pressed continuously, or was just released.

    static void update(const Input& input, const Window& window, State& state, ShouldQuit& shouldQuit)
    -{
    -    // FIXME: This is an hack to have one-shot actions while we don't have input events.
    -    if (input.pressed("next-showcase"))
    -    {
    -        state.nextPressed = true;
    -    }
    -    else if (state.nextPressed)
    -    {
    -        state.nextPressed = false;
    -        state.explained = false;
    -        state.showcase++;
    -    }

    What this does is only advance the state when the return key is released. This avoids the state advancing more than once if the user presses it for more than one frame.

    Now let's see each of the prompt, to understand the full breadth of the plugin's functionalities.

    static void showcaseXZ(const Input& input, bool& explained)
    +}

    There are two types of bindings: actions and axes. An action is an input that only has two states: pressed or not pressed. This would be most keys on a keyboard. An axe is an input that has a numeric value. For example, the joysticks on a controller can go from -1 to 1, depending on how much they are tilt in which direction. Using axes can also be useful for keys with symetric behaviour. For example, in this sample, w sets the vertical axe to 1, while s sets it to -1.

    To define an action or an axe, you simply have to add it to the respective list, giving it a name. The very first action in the file is called next-showcase. Then, if it's an action, you simply have to define which keys trigger it. You can also define key combinations by using a -. To check which strings map to which keys, you check the keyToString function implementation on this file.

    Now that we have our bindings file, let's get our application to do something with it. The first thing we're going to need is a reference to the bindings asset. For the purposes of this sample we can simply use an hardcoded reference to the asset.

    static const Asset<InputBindings> BindingsAsset = AnyAsset("bf49ba61-5103-41bc-92e0-8a442d7842c3");

    To utilize the bindings, loading them is essential. This can be accomplished by establishing a startup systems which reads from the asset and sets the required bindings.

        cubos.startupSystem("load and set the Input Bindings")
    +        .tagged("cubos.assets")
    +        .call([](const Assets& assets, Input& input) {
    +            auto bindings = assets.read<InputBindings>(BindingsAsset);
    +            input.bind(*bindings);
    +            CUBOS_INFO("Loaded bindings: {}", input.bindings().at(0));
    +        });

    Getting the input is done through the cubos::engine::Input resource. What this sample does is show in order, a series of prompt to showcase the different functionalities of the Input plugin. For this, it keeps a state integer that indicates the current prompt. Whenever the action next-showcase is triggered, it advances to the next prompt. However, as the plugin currently does not have events, we have to manually check whether the key has just been pressed, is being pressed continuously, or was just released.

        cubos.system("detect input")
    +        .after("cubos.input.update")
    +        .call([](const Input& input, const Window& window, State& state, ShouldQuit& shouldQuit) {
    +            // FIXME: This is an hack to have one-shot actions while we don't have input events.
    +            if (input.pressed("next-showcase"))
    +            {
    +                state.nextPressed = true;
    +            }
    +            else if (state.nextPressed)
    +            {
    +                state.nextPressed = false;
    +                state.explained = false;
    +                state.showcase++;
    +            }

    What this does is only advance the state when the return key is released. This avoids the state advancing more than once if the user presses it for more than one frame.

    Now let's see each of the prompt, to understand the full breadth of the plugin's functionalities.

    static void showcaseXZ(const Input& input, bool& explained)
     {
         if (!explained)
         {
    diff --git a/docs-preview/pr-880/examples-engine-renderer.html b/docs-preview/pr-880/examples-engine-renderer.html
    index 108aa49af..b718bcde6 100644
    --- a/docs-preview/pr-880/examples-engine-renderer.html
    +++ b/docs-preview/pr-880/examples-engine-renderer.html
    @@ -51,61 +51,52 @@ 

    Renderer

    Using the Renderer plugin.

    -

    This example shows how the Renderer plugin can be used and configured with a simple scene, lighting and split-screen rendering.

    Image

    The plugin function is included from the engine/renderer/plugin.hpp header. You may need to include other headers, depending on what you want to access.

        cubos.addPlugin(splitscreenPlugin);
    -    cubos.addPlugin(rendererPlugin);

    The first thing we're going to worry about is setting the VoxelPalette the renderer will use. This palette would usually be loaded from a file, but for this example we'll just create it manually.

    static void setPaletteSystem(Renderer& renderer)
    -{
    -    // Create a simple palette with 3 materials (red, green and blue).
    -    renderer->setPalette(VoxelPalette{{
    -        {{1, 0, 0, 1}},
    -        {{0, 1, 0, 1}},
    -        {{0, 0, 1, 1}},
    -    }});
    -}

    We should also spawn a voxel grid, so we have something to render.

    static void spawnVoxelGridSystem(Commands commands, Assets& assets)
    -{
    -    // Create a 2x2x2 grid whose voxels alternate between the materials defined in the palette.
    -    auto gridAsset = assets.create(VoxelGrid{{2, 2, 2}, {1, 2, 3, 1, 2, 3, 1, 2}});
    +

    This example shows how the Renderer plugin can be used and configured with a simple scene, lighting and split-screen rendering.

    Image

    The plugin function is included from the engine/renderer/plugin.hpp header. You may need to include other headers, depending on what you want to access.

    In this sample we also use the split-screen plugin which automatically sets the viewport of each camera to achieve split-screen.

        cubos.addPlugin(splitscreenPlugin);
    +    cubos.addPlugin(rendererPlugin);

    The first thing we're going to worry about is setting the VoxelPalette the renderer will use. This palette would usually be loaded from a file, but for this example we'll just create it manually.

    Since this system accesses the Renderer resource, which is only initialized on the tag cubos.renderer.init, we should specify that it must run after it.

        cubos.startupSystem("set the palette").after("cubos.renderer.init").call([](Renderer& renderer) {
    +        // Create a simple palette with 3 materials (red, green and blue).
    +        renderer->setPalette(VoxelPalette{{
    +            {{1, 0, 0, 1}},
    +            {{0, 1, 0, 1}},
    +            {{0, 0, 1, 1}},
    +        }});
    +    });

    We should also spawn a voxel grid, so we have something to render.

        cubos.startupSystem("create a voxel grid").call([](Commands commands, Assets& assets) {
    +        // Create a 2x2x2 grid whose voxels alternate between the materials defined in the palette.
    +        auto gridAsset = assets.create(VoxelGrid{{2, 2, 2}, {1, 2, 3, 1, 2, 3, 1, 2}});
     
    -    // Spawn an entity with a renderable grid component and a identity transform.
    -    commands.create().add(RenderableGrid{gridAsset, {-1.0F, 0.0F, -1.0F}}).add(LocalToWorld{});
    -}

    If we don't add any lights, the scene will be completely dark. Lets add a simple PointLight.

    static void spawnLightSystem(Commands commands)
    -{
    -    // Spawn a point light.
    -    commands.create()
    -        .add(PointLight{.color = {1.0F, 1.0F, 1.0F}, .intensity = 1.0F, .range = 10.0F})
    -        .add(Position{{1.0F, 3.0F, -2.0F}});
    -}

    We can also add some ambient lighting, and even add a sky gradient, through the RendererEnvironment resource.

    static void setEnvironmentSystem(RendererEnvironment& env)
    -{
    -    env.ambient = {0.2F, 0.2F, 0.2F};
    -    env.skyGradient[0] = {0.1F, 0.2F, 0.4F};
    -    env.skyGradient[1] = {0.6F, 0.6F, 0.8F};
    -}

    Lastly, without a camera, we won't be able to see anything. Cameras can be set using the ActiveCameras resource.

    static void spawnCamerasSystem(Commands commands, ActiveCameras& camera)
    -{
    -    // Spawn the a camera entity for the first viewport.
    -    camera.entities[0] =
    +        // Spawn an entity with a renderable grid component and a identity transform.
    +        commands.create().add(RenderableGrid{gridAsset, {-1.0F, 0.0F, -1.0F}}).add(LocalToWorld{});
    +    });

    If we don't add any lights, the scene will be completely dark. Lets add a simple PointLight.

        cubos.startupSystem("create a point light").call([](Commands commands) {
    +        // Spawn a point light.
             commands.create()
    -            .add(Camera{.fovY = 60.0F, .zNear = 0.1F, .zFar = 100.0F})
    -            .add(Position{{-3.0, 1.0F, -3.0F}})
    -            .add(Rotation{glm::quatLookAt(glm::normalize(glm::vec3{1.0F, 0.0F, 1.0F}), glm::vec3{0.0F, 1.0F, 0.0F})})
    -            .entity();
    +            .add(PointLight{.color = {1.0F, 1.0F, 1.0F}, .intensity = 1.0F, .range = 10.0F})
    +            .add(Position{{1.0F, 3.0F, -2.0F}});
    +    });

    We can also add some ambient lighting, and even add a sky gradient, through the RendererEnvironment resource.

        cubos.startupSystem("set the environment").call([](RendererEnvironment& env) {
    +        env.ambient = {0.2F, 0.2F, 0.2F};
    +        env.skyGradient[0] = {0.1F, 0.2F, 0.4F};
    +        env.skyGradient[1] = {0.6F, 0.6F, 0.8F};
    +    });

    Lastly, without a camera, we won't be able to see anything. Cameras can be set using the ActiveCameras resource.

        cubos.startupSystem("create cameras").call([](Commands commands, ActiveCameras& camera) {
    +        // Spawn the a camera entity for the first viewport.
    +        camera.entities[0] = commands.create()
    +                                 .add(Camera{.fovY = 60.0F, .zNear = 0.1F, .zFar = 100.0F})
    +                                 .add(Position{{-3.0, 1.0F, -3.0F}})
    +                                 .add(Rotation{glm::quatLookAt(glm::normalize(glm::vec3{1.0F, 0.0F, 1.0F}),
    +                                                               glm::vec3{0.0F, 1.0F, 0.0F})})
    +                                 .entity();
     
    -    camera.entities[1] =
    -        commands.create()
    -            .add(Camera{.fovY = 60.0F, .zNear = 0.1F, .zFar = 100.0F})
    -            .add(Position{{-3.0, 1.0F, -3.0F}})
    -            .add(Rotation{glm::quatLookAt(glm::normalize(glm::vec3{1.0F, 0.0F, 1.0F}), glm::vec3{0.0F, 1.0F, 0.0F})})
    -            .entity();
    +        camera.entities[1] = commands.create()
    +                                 .add(Camera{.fovY = 60.0F, .zNear = 0.1F, .zFar = 100.0F})
    +                                 .add(Position{{-3.0, 1.0F, -3.0F}})
    +                                 .add(Rotation{glm::quatLookAt(glm::normalize(glm::vec3{1.0F, 0.0F, 1.0F}),
    +                                                               glm::vec3{0.0F, 1.0F, 0.0F})})
    +                                 .entity();
     
    -    camera.entities[2] =
    -        commands.create()
    -            .add(Camera{.fovY = 60.0F, .zNear = 0.1F, .zFar = 100.0F})
    -            .add(Position{{-3.0, 1.0F, -3.0F}})
    -            .add(Rotation{glm::quatLookAt(glm::normalize(glm::vec3{1.0F, 0.0F, 1.0F}), glm::vec3{0.0F, 1.0F, 0.0F})})
    -            .entity();
    -}

    Then, its just a matter of adding these systems to the engine. The only one which requires special attention is the setPaletteSystem. This system accesses the Renderer resource, which is only initialized on the tag cubos.renderer.init.

        cubos.startupSystem(setPaletteSystem).after("cubos.renderer.init");
    -    cubos.startupSystem(spawnVoxelGridSystem);
    -    cubos.startupSystem(spawnLightSystem);
    -    cubos.startupSystem(setEnvironmentSystem);
    -    cubos.startupSystem(spawnCamerasSystem);
    + camera.entities[2] = commands.create() + .add(Camera{.fovY = 60.0F, .zNear = 0.1F, .zFar = 100.0F}) + .add(Position{{-3.0, 1.0F, -3.0F}}) + .add(Rotation{glm::quatLookAt(glm::normalize(glm::vec3{1.0F, 0.0F, 1.0F}), + glm::vec3{0.0F, 1.0F, 0.0F})}) + .entity(); + });
    diff --git a/docs-preview/pr-880/examples-engine-scene.html b/docs-preview/pr-880/examples-engine-scene.html index ed443f4e9..a4d1bbc70 100644 --- a/docs-preview/pr-880/examples-engine-scene.html +++ b/docs-preview/pr-880/examples-engine-scene.html @@ -52,34 +52,72 @@

    Using the Scene plugin.

    This example shows how the Scene plugin can be used to create scene assets and spawn them on the world.

    The plugin function is included from the engine/scene/plugin.hpp header.

        cubos.addPlugin(scenePlugin);

    Let's start by taking a look at a scene file.

    {
    -    "imports": {},
    -    "entities": {
    -        "main": {
    -            "cubos::engine::Position": {
    -                "x": 2,
    -                "y": 2,
    -                "z": 2
    -            }
    -        }
    +  "imports": {},
    +  "entities": {
    +    "root": {
    +      "Num": 1
    +    },
    +    "child": {
    +      "Num": 2,
    +      "OwnedBy": "root"
         }
    -}

    Scene files are JSON files with the extension .cubos. They must have two fields: imports and entities. The entities field is an object where each field identifies and describes the components of an entity. In this scene we have two entities, root and child. root has a single component, num, with a value of 1. child has two components, a parent and a num. In this sample, num is used so we can later identify the entities.

    Let's look at a different scene file now, this time with imports. Imports allows us to instantiate scenes within other scenes.

    {
    +  }
    +}

    Scene files are JSON files with the extension .cubos. They must have two fields: imports and entities. The entities field is an object where each field identifies and describes the components and relations of an entity. In this scene we have two entities, root and child. root has a single component, Num, with a value of 1. child too has a component Num, but also has a relation OwnedBy with root as target. In this sample, Num is used so we can later identify the entities.

    Let's look at a different scene file now, this time with imports. Imports allows us to instantiate scenes within other scenes.

    {
       "imports": {
    -    "sub1": "00d86ba8-5f34-440f-a180-d9d12c8e8b91"
    +    "sub1": "cd007ba2-ee0d-44fd-bf36-85c829dbe66f",
    +    "sub2": "cd007ba2-ee0d-44fd-bf36-85c829dbe66f"
       },
       "entities": {
         "main": {
    -      "cubos::engine::Position": {
    -        "x": 1,
    -        "y": 1,
    -        "z": 1
    +      "Num": 0
    +    },
    +    "sub1.root": {
    +      "OwnedBy": "main",
    +      "DistanceTo": {
    +        "entity": "sub2.root",
    +        "value": 5
           }
    +    },
    +    "sub2.root": {
    +      "OwnedBy": "main"
         }
       }
    -}

    This file imports the asset with id cd007ba2-ee0d-44fd-bf36-85c829dbe66f, which is the scene we looked at in the previous file, under the name sub1. It then imports the very same scene again, but this time with the name sub2 instead. This effectively instantiates the entities of the previous scene twice in this new scene, each with their names prefixed with either sub1. or sub2.

    Under entities, we can override the entities in the sub-scenes to edit components or add new ones. For example, by referencing sub1.root we are making local changes to the root entity of that instance of the subscene. The result of the changes we make to both sub1.root and sub2.root is that the parent of these entities will be set to be the main entity.

    Now that we have our scene file, let's get our application to load it. The first thing we're going to need is a reference to the scene asset. For the purposes of this sample we can simply use an hardcoded reference to the asset.

    static const Asset<Scene> SceneAsset = AnyAsset("f0d86ba8-5f34-440f-a180-d9d12c8e8b91");

    Then we'll need a system that spawns that scene. To do this we simply get the Scene object from the asset, and then spawn its entities. Commands::spawn will create in the world a copy of every entity defined in the scene's blueprint. It won't remove the entities already there, so if you want to close a scene, you'll have to do it yourself.

    static void spawnScene(Commands commands, const Assets& assets)
    -{
    -    auto sceneRead = assets.read(SceneAsset);
    -    commands.spawn(sceneRead->blueprint);
    -}

    In this case, we'll run this system at startup, since we want to spawn it a single time. Since it's a startup system, we'll have to tag it with cubos.assets to make sure it runs only after the scene bridge has been registered. On a real game, you could have, for example, a scene for an enemy which you spawn multiple times, instead of just once at startup.

        cubos.startupSystem(spawnScene).tagged("spawn").tagged("cubos.assets");

    This sample will output the list of every entity in the scene, so you can check that everything is working as expected. If you run it, it should give you a list that has:

    • an entity with num set to 0, with no parent. This is the main entity.
    • two entities with num set to 1, with same parent, who has num set to 0. These are the root entities of each instance of the subscene.
    • two entities with num set to 2, with different parents, but both of them having num set to 1. These are the child entities of each instance of the subscene.
    +}

    This file imports the asset with id cd007ba2-ee0d-44fd-bf36-85c829dbe66f, which is the scene we looked at in the previous file, under the name sub1. It then imports the very same scene again, but this time with the name sub2 instead. This effectively instantiates the entities of the previous scene twice in this new scene, each with their names prefixed with either sub1. or sub2.

    Also take a look at the DistanceTo relation: it is a symmetric relation, so it doesn't make a different whether wwe put it in sub.root or sub2.root. Since DistanceTo is a relation which holds data, instead of only specifying the target, as we do with OwnedBy, we write a JSON object with two keys, "entity" and "value".

    Under entities, we can override the entities in the sub-scenes to edit components or add new ones. For example, by referencing sub1.root we are making local changes to the root entity of that instance of the subscene. The result of the changes we make to both sub1.root and sub2.root is that the owner of these entities will be set to be the main entity.

    Now that we have our scene file, let's get our application to load it. The first thing we're going to need is a reference to the scene asset. For the purposes of this sample we can simply use an hardcoded reference to the asset.

    static const Asset<Scene> SceneAsset = AnyAsset("f0d86ba8-5f34-440f-a180-d9d12c8e8b91");

    Then we'll need a system that spawns that scene. To do this we simply get the Scene object from the asset, and then spawn its entities. Commands::spawn will create in the world a copy of every entity defined in the scene's blueprint. It won't remove the entities already there, so if you want to close a scene, you'll have to do it yourself.

        cubos.startupSystem("spawn the scene")
    +        .tagged("spawn")
    +        .tagged("cubos.assets")
    +        .call([](Commands commands, const Assets& assets) {
    +            auto sceneRead = assets.read(SceneAsset);
    +            commands.spawn(sceneRead->blueprint);
    +        });

    In this case, we'll run this system at startup, since we want to spawn it a single time. Since it's a startup system, we'll have to tag it with cubos.assets to make sure it runs only after the scene bridge has been registered. On a real game, you could have, for example, a scene for an enemy which you spawn multiple times, instead of just once at startup.

        cubos.startupSystem("print the scene")
    +        .after("spawn")
    +        .call([](Query<Entity, const Num&> numQuery, Query<const OwnedBy&, Entity> ownedByQuery,
    +                 Query<const DistanceTo&, Entity> distanceToQuery) {
    +            using cubos::core::data::DebugSerializer;
    +            using cubos::core::memory::Stream;
    +
    +            DebugSerializer ser{Stream::stdOut};
    +
    +            for (auto [entity, num] : numQuery)
    +            {
    +                Stream::stdOut.print("Entity ");
    +                ser.write(entity);
    +                Stream::stdOut.printf(":\n- Num = {}\n", num.value);
    +
    +                for (auto [distanceTo, what] : distanceToQuery.pin(0, entity))
    +                {
    +                    Stream::stdOut.print("- DistanceTo(");
    +                    ser.write(what);
    +                    Stream::stdOut.printf(") = {}\n", distanceTo.value);
    +                }
    +
    +                for (auto [ownedBy, owner] : ownedByQuery.pin(0, entity))
    +                {
    +                    Stream::stdOut.print("- OwnedBy(");
    +                    ser.write(owner);
    +                    Stream::stdOut.print(")\n");
    +                }
    +            }
    +        });

    This sample also contains a system which prints the components and relations of the spawned entities. If you run it, it should give you a list that has:

    diff --git a/docs-preview/pr-880/examples-engine-settings.html b/docs-preview/pr-880/examples-engine-settings.html index 2a726c1d8..3cef3ce3e 100644 --- a/docs-preview/pr-880/examples-engine-settings.html +++ b/docs-preview/pr-880/examples-engine-settings.html @@ -51,16 +51,18 @@

    Settings

    Using the Settings plugin.

    -

    This example shows how the Settings plugin can be used to load settings from a file and command-line arguments.

    Accesing the settings is straightforward:

    static void checkSettings(Settings& settings)
    -{
    -    CUBOS_INFO("{}", settings.getString("greeting", "Hello!"));
    -}

    If the setting greetings has been set on the settings.json file next to the sample's executable, or if it has been passed as a command-line argument (e.g. ./engine-sample.settings --greetings "Hello, world!"), the sample will output that value. Otherwise, it will output Hello!, which we set as a default.

    We want this system to run after the settings have been loaded, so we run it after the tag cubos.settings. Notice that if we want the command-line arguments to be loaded as settings, we need to pass argc and argv to the Cubos::Cubos(int, char**) constructor.

    int main(int argc, char** argv)
    +

    This example shows how the Settings plugin can be used to load settings from a file and command-line arguments.

    int main(int argc, char** argv)
     {
         Cubos cubos{argc, argv};
    +
         cubos.addPlugin(settingsPlugin);
    -    cubos.startupSystem(checkSettings).after("cubos.settings");
    +
    +    cubos.startupSystem("print setting value").after("cubos.settings").call([](Settings& settings) {
    +        CUBOS_INFO("{}", settings.getString("greeting", "Hello!"));
    +    });
    +
         cubos.run();
    -}
    +}

    We add a system which prints the value of the setting greetings. Notice that we make it run after the tag cubos.settings, so that the settings have already been loaded.

    If the setting greetings has been set on the settings.json file next to the sample's executable, or if it has been passed as a command-line argument (e.g. ./engine-sample.settings --greetings "Hello, world!"), the sample will output that value. Otherwise, it will output Hello!, which we set as a default.

    Notice that if we want the command-line arguments to be loaded as settings, we need to pass argc and argv to the Cubos::Cubos(int, char**) constructor.

    diff --git a/docs-preview/pr-880/examples-engine-voxels.html b/docs-preview/pr-880/examples-engine-voxels.html index de99de8e1..0b19a2668 100644 --- a/docs-preview/pr-880/examples-engine-voxels.html +++ b/docs-preview/pr-880/examples-engine-voxels.html @@ -52,21 +52,20 @@

    Using the Voxels plugin.

    This example shows the Voxels plugin, which registers asset bridges used to load voxel grids (.grid) and palettes (.pal). Check out the Introduction and Custom Bridges sample for an introduction on the Assets plugin.

    It is very similar to the Renderer, differing only in the fact that in this sample the grid and palette are loaded from files.

    Image

    The plugin function is included from the engine/voxels/plugin.hpp header. To see the asset, you'll also need to perform a basic configuration of the Renderer plugin like shown in the Renderer sample.

        cubos.addPlugin(voxelsPlugin);

    Lets start by defining the handles of the assets we want to use, as done in the Assets sample.

    static const Asset<VoxelGrid> CarAsset = AnyAsset("059c16e7-a439-44c7-9bdc-6e069dba0c75");
    -static const Asset<VoxelPalette> PaletteAsset = AnyAsset("1aa5e234-28cb-4386-99b4-39386b0fc215");

    In this sample, instead of creating a new palette, we just read the data from the asset identified from the PaletteAsset handle we defined previously. Internally, the assets manager will automatically load the palette asset if it hasn't been loaded before.

    static void setPaletteSystem(const Assets& assets, Renderer& renderer)
    -{
    -    // Read the palette's data and pass it to the renderer.
    -    auto palette = assets.read(PaletteAsset);
    -    renderer->setPalette(*palette);
    -}

    Now, we can create an entity with our car asset.

    static void spawnCarSystem(Commands cmds, const Assets& assets)
    -{
    -    // Calculate the necessary offset to center the model on (0, 0, 0).
    -    auto car = assets.read(CarAsset);
    -    glm::vec3 offset = glm::vec3(car->size().x, 0.0F, car->size().z) / -2.0F;
    +static const Asset<VoxelPalette> PaletteAsset = AnyAsset("1aa5e234-28cb-4386-99b4-39386b0fc215");

    In this sample, instead of creating a new palette, we just read the data from the asset identified from the PaletteAsset handle we defined previously. Internally, the assets manager will automatically load the palette asset if it hasn't been loaded before.

        cubos.startupSystem("load and set pallete")
    +        .after("cubos.renderer.init")
    +        .call([](const Assets& assets, Renderer& renderer) {
    +            // Read the palette's data and pass it to the renderer.
    +            auto palette = assets.read(PaletteAsset);
    +            renderer->setPalette(*palette);
    +        });

    Now, we can create an entity with our car asset.

        cubos.startupSystem("create a car").tagged("cubos.assets").call([](Commands cmds, const Assets& assets) {
    +        // Calculate the necessary offset to center the model on (0, 0, 0).
    +        auto car = assets.read(CarAsset);
    +        glm::vec3 offset = glm::vec3(car->size().x, 0.0F, car->size().z) / -2.0F;
     
    -    // Create the car entity
    -    cmds.create().add(RenderableGrid{CarAsset, offset}).add(LocalToWorld{});
    -}

    Finally, we just add these systems.

        cubos.startupSystem(setPaletteSystem).after("cubos.renderer.init");
    -    cubos.startupSystem(spawnCarSystem).tagged("cubos.assets");

    And voilá, you now have a car floating in space.

    + // Create the car entity + cmds.create().add(RenderableGrid{CarAsset, offset}).add(LocalToWorld{}); + });

    And voilá, you now have a car floating in space.

    diff --git a/docs-preview/pr-880/examples-engine.html b/docs-preview/pr-880/examples-engine.html index 13ada811b..f6bca8a07 100644 --- a/docs-preview/pr-880/examples-engine.html +++ b/docs-preview/pr-880/examples-engine.html @@ -50,7 +50,7 @@

    Engine

    Showcases features of the Engine library.

    -

    The following examples have fully documented tutorials on how to use the multiple plugins of the engine:

    +

    The following examples have fully documented tutorials on how to use the multiple plugins of the engine:

    diff --git a/docs-preview/pr-880/features-ecs.html b/docs-preview/pr-880/features-ecs.html index 82182e981..0797139ad 100644 --- a/docs-preview/pr-880/features-ecs.html +++ b/docs-preview/pr-880/features-ecs.html @@ -51,7 +51,7 @@

    ECS

    What is an ECS and how it's used in CUBOS.

    -

    Wikipedia defines ECS as:

    Entity Component System (ECS) is a software architectural pattern mostly used in video game development for the representation of game world objects. An ECS comprises entities composed from components of data, with systems which operate on entities' components.

    ECS follows the principle of composition over inheritance, meaning that every entity is defined not by a type hierarchy, but by the components that are associated with it. Systems act globally over all entities which have the required components.

    The ECS thus is a vital part of the engine, since all of the rest is structured around it in some way. This sets the engine apart from other engines which follow a more traditional model, like Unity, Unreal and Godot.

    A primer on ECS

    Why are we using this?

    ECS is a powerful pattern which has been becoming more popular over the years, and even Unity has started integrating it into its engine. The main advantages are flexibility and performance: it avoids a lot of the problems that come with traditional object-oriented programming, and regarding performance, it excels in situations where the number of entities is high, since it makes use of cache locality. Its also easier to parallelize the systems, since they have clearly defined dependencies.

    Our implementation

    CUBOS. ECS contains the following concepts:

    • World - the main object that holds all of the ECS state.
    • Entities - represent objects in the game world (e.g. a car, a player, a tree).
    • Components - data associated with an entity (e.g. Position, Rotation).
    • Resources - singleton-like objects which are stored per world and which do not belong to a specific entity (e.g. DeltaTime, Input).
    • Systems - functions which operate on resources and entities' components. This is where the logic is implemented.
    • Dispatcher - decides when each system is called and knows which systems are independent from each other so they can be called at the same time (parallel computing).

    On the engine side, the Dispatcher is not exposed. Instead, the Cubos class is used to add systems and specify when they should be called.

    One important thing to note is that in an ECS the data is completely decoupled from the logic. What this means is that entities and components do not and should not possess any functionality other than storing data. All of the logic is relegated to the systems.

    How do we use it?

    Lets say we want to have multiple objects with positions and velocities, and every frame we want to add their velocities to their positions.

    In a traditional object-oriented approach, we would have something along the lines of:

    class MyObject : public GameObject
    +

    Wikipedia defines ECS as:

    Entity Component System (ECS) is a software architectural pattern mostly used in video game development for the representation of game world objects. An ECS comprises entities composed from components of data, with systems which operate on entities' components.

    ECS follows the principle of composition over inheritance, meaning that every entity is defined not by a type hierarchy, but by the components that are associated with it. Systems act globally over all entities which have the required components.

    The ECS thus is a vital part of the engine, since all of the rest is structured around it in some way. This sets the engine apart from other engines which follow a more traditional model, like Unity, Unreal and Godot.

    A primer on ECS

    Why are we using this?

    ECS is a powerful pattern which has been becoming more popular over the years, and even Unity has started integrating it into its engine. The main advantages are flexibility and performance: it avoids a lot of the problems that come with traditional object-oriented programming, and regarding performance, it excels in situations where the number of entities is high, since it makes use of cache locality. Its also easier to parallelize the systems, since they have clearly defined dependencies.

    Our implementation

    CUBOS. ECS contains the following concepts:

    • Cubos - used to configure and run an ECS world and systems.
    • World - the main object that holds all of the ECS state.
    • Entities - represent objects in the game world (e.g. a car, a player, a tree).
    • Components - data associated with an entity (e.g. Position, Rotation).
    • Resources - singleton-like objects which are stored per world and which do not belong to a specific entity (e.g. DeltaTime, Input).
    • Systems - functions which operate on resources and entities' components. This is where the logic is implemented.

    One important thing to note is that in an ECS the data is completely decoupled from the logic. What this means is that entities and components do not and should not possess any functionality other than storing data. All of the logic is relegated to the systems.

    How do we use it?

    Lets say we want to have multiple objects with positions and velocities, and every frame we want to add their velocities to their positions.

    In a traditional object-oriented approach, we would have something along the lines of:

    class MyObject : public GameObject
     {
     public:
         // ...
    @@ -89,12 +89,12 @@ 

    { position->vec += velocity->vec * dt->value; } -}

    We can then iterate over all queried entities and update their positions using their velocities and the delta time.

    Going further

    Registering resources and components

    Before components and resources are used in a World, they must be registered on it. This should be done once, at the start of the program. For example, using the CUBOS. main class, for the previous example we would write:

    cubos.addComponent<Position>();
    +}

    We can then iterate over all queried entities and update their positions using their velocities and the delta time.

    Going further

    Registering resources and components

    Before components and resources are used in a World, they must be registered on it. This should be done once, at the start of the program. For example, using the CUBOS. main class, for the previous example we would write:

    cubos.addComponent<Position>();
     cubos.addComponent<Velocity>();
     cubos.addResource<DeltaTime>();

    Commands

    When you have direct access to the World, you can manipulate entities directly:

    auto entity = world.create(Position {}, Velocity {});
     world.removeComponent<Velocity>(entity);
     world.addComponent(entity, Dead {});
    -world.destroy(entity);

    If necessary, you can access the world in a system through the arguments const World& or World&. However, this is not recommended, since it becomes impossible for the dispatcher to know what the system is accessing, and thus it cannot parallelize it.

    Instead, you should use the Commands argument. Through it you can queue operations to be executed at a later time, when its safe to do so.

    Imagine we want to have spawners which create new entities on their position and then destroy themselves. We can implement this with a system like this:

    void spawnerSystem(
    +world.destroy(entity);

    If necessary, you can access the world in a system through the arguments const World& or World&. However, this is not recommended, since it becomes impossible to know what the system is accessing, and thus we cannot parallelize it.

    Instead, you should use the Commands argument. Through it you can queue operations to be executed at a later time, when its safe to do so.

    Imagine we want to have spawners which create new entities on their position and then destroy themselves. We can implement this with a system like this:

    void spawnerSystem(
         Commands commands,
         Query<const Spawner&, const Position&> spawners)
     {
    diff --git a/docs-preview/pr-880/features-plugins.html b/docs-preview/pr-880/features-plugins.html
    index 67b86d723..06e9a033c 100644
    --- a/docs-preview/pr-880/features-plugins.html
    +++ b/docs-preview/pr-880/features-plugins.html
    @@ -52,11 +52,11 @@ 

    Plugins

    What are plugins and how they can be used to organize your code.

    -

    Configuring the engine

    Plugins are a feature of the cubos::engine::Cubos class. This class is the main thing you'll be interacting with when developing a game with CUBOS.. It is used to configure the engine and run the game loop. Through it, you can register new components, resources and configure systems to be run on specific conditions.

    An application which just prints "Hello World!" and which does absolutely nothing else - not even open a window - would look like this:

    #include <cubos/engine/cubos.hpp>
    +

    Configuring the engine

    Plugins are a feature of the cubos::core::ecs::Cubos class. This class is the main thing you'll be interacting with when developing a game with CUBOS.. It is used to configure the engine and run the game loop. Through it, you can register new components, resources and configure systems to be run on specific conditions.

    An application which just prints "Hello World!" and which does absolutely nothing else - not even open a window - would look like this:

    #include <cubos/engine/prelude.hpp>
     
     #include <iostream>
     
    -using Cubos = cubos::engine::Cubos;
    +using cubos::engine::Cubos;
     
     void helloWorld()
     {
    @@ -68,11 +68,11 @@ 

    Cubos cubos; cubos.startupSystem(helloWorld); cubos.run(); -}

    What are plugins?

    If you had to add every system, component and resource to your game's main source file, it would quickly become a mess. Plugins are just functions which receive a reference to the Cubos class. Nothing more.

    The idiomatic way to use plugins is through the Cubos::addPlugin method. It receives a plugin function, and executes it only if it hasn't been executed before. This property is useful for solving dependency issues between plugins. For example, if B and C adds A and D adds B and C, you would be adding A twice.

    If we were to put the hello world functionality on a plugin, the previous example would look like this:

    #include <cubos/engine/cubos.hpp>
    +}

    What are plugins?

    If you had to add every system, component and resource to your game's main source file, it would quickly become a mess. Plugins are just functions which receive a reference to the Cubos class. Nothing more.

    The idiomatic way to use plugins is through the Cubos::addPlugin method. It receives a plugin function, and executes it only if it hasn't been executed before. This property is useful for solving dependency issues between plugins. For example, if B and C adds A and D adds B and C, you would be adding A twice.

    If we were to put the hello world functionality on a plugin, the previous example would look like this:

    #include <cubos/engine/prelude.hpp>
     
     #include <iostream>
     
    -using Cubos = cubos::engine::Cubos;
    +using cubos::engine::Cubos;
     
     void helloWorld()
     {
    diff --git a/docs-preview/pr-880/files.html b/docs-preview/pr-880/files.html
    index db075c230..681398869 100644
    --- a/docs-preview/pr-880/files.html
    +++ b/docs-preview/pr-880/files.html
    @@ -90,17 +90,9 @@ 

    Files

    -
  • file cubos.hpp Class cubos::engine::Cubos.
  • +
  • dir events Event arguments.
  • dir tesseratos Tesseratos module.
      diff --git a/docs-preview/pr-880/fixed__delta__time_8hpp.html b/docs-preview/pr-880/fixed__delta__time_8hpp.html index 41aff7490..821237180 100644 --- a/docs-preview/pr-880/fixed__delta__time_8hpp.html +++ b/docs-preview/pr-880/fixed__delta__time_8hpp.html @@ -76,7 +76,7 @@

      Classes

      struct cubos::engine::FixedDeltaTime
      -
      Resouce which holds the value of the fixed delta for the physics update.
      +
      Resource which holds the value of the fixed delta for the physics update.
  • diff --git a/docs-preview/pr-880/group__assets-plugin.html b/docs-preview/pr-880/group__assets-plugin.html index b3858c4cc..1dd5d9be6 100644 --- a/docs-preview/pr-880/group__assets-plugin.html +++ b/docs-preview/pr-880/group__assets-plugin.html @@ -85,6 +85,8 @@

    Files

    Class cubos::engine::FileBridge.
    file json.hpp
    Class cubos::engine::JSONBridge.
    +
    file json.hpp
    +
    Class cubos::engine::JSONBridge.
    file meta.hpp
    Class cubos::engine::AssetMeta.
    file plugin.hpp
    @@ -125,6 +127,11 @@

    Classes

    class cubos::engine::JSONBridge
    Bridge for loading and saving assets which are serialized to and from a JSON file.
    +
    +
    template<typename T>
    + class cubos::engine::old::JSONBridge +
    +
    Bridge for loading and saving assets which are serialized to and from a JSON file.
    class cubos::engine::AssetMeta
    diff --git a/docs-preview/pr-880/group__collisions-plugin.html b/docs-preview/pr-880/group__collisions-plugin.html index 132acc371..29d7be3d3 100644 --- a/docs-preview/pr-880/group__collisions-plugin.html +++ b/docs-preview/pr-880/group__collisions-plugin.html @@ -70,6 +70,8 @@

    Contents

    Files

    +
    file potentially_colliding_with.hpp
    +
    Component cubos::engine::PotentiallyCollidingWith.
    file collider.hpp
    Component cubos::engine::Collider.
    file collision_event.hpp
    @@ -85,6 +87,10 @@

    Files

    Classes

    +
    + struct cubos::engine::PotentiallyCollidingWith +
    +
    Component which represents a potential collisions.
    struct cubos::engine::Collider
    diff --git a/docs-preview/pr-880/group__core-ecs-entity.html b/docs-preview/pr-880/group__core-ecs-entity.html index 3d523b511..75d8ccfc1 100644 --- a/docs-preview/pr-880/group__core-ecs-entity.html +++ b/docs-preview/pr-880/group__core-ecs-entity.html @@ -73,8 +73,6 @@

    Files

    Struct cubos::core::ecs::Entity.
    file hash.hpp
    Struct cubos::core::ecs::EntityHash.
    -
    file manager.hpp
    -
    Class cubos::core::ecs::EntityManager.
    file pool.hpp
    Class cubos::core::ecs::EntityPool.
    @@ -98,10 +96,6 @@

    Classes

    struct cubos::core::ecs::EntityHash
    Used to hash Entity objects.
    -
    - class cubos::core::ecs::EntityManager -
    -
    Internal type which holds and manages entities and their component masks.
    class cubos::core::ecs::EntityPool
    diff --git a/docs-preview/pr-880/group__core-ecs-query.html b/docs-preview/pr-880/group__core-ecs-query.html index fde17cea3..e635c5ee5 100644 --- a/docs-preview/pr-880/group__core-ecs-query.html +++ b/docs-preview/pr-880/group__core-ecs-query.html @@ -65,11 +65,9 @@

    Contents

    Files

    -
    file access.hpp
    -
    Struct cubos::core::ecs::QueryAccess.
    file data.hpp
    Class cubos::core::ecs::QueryData.
    -
    file fetcher.hpp
    +
    file fetcher.hpp
    Class cubos::core::ecs::QueryFetcher.
    file filter.hpp
    Class cubos::core::ecs::QueryFilter.
    @@ -82,10 +80,6 @@

    Files

    Classes

    -
    - struct cubos::core::ecs::QueryAccess -
    -
    Describes the types of data a query accesses.
    template<typename... Ts>
    class cubos::core::ecs::QueryData diff --git a/docs-preview/pr-880/group__core-ecs-component.html b/docs-preview/pr-880/group__core-ecs-system-arguments.html similarity index 61% rename from docs-preview/pr-880/group__core-ecs-component.html rename to docs-preview/pr-880/group__core-ecs-system-arguments.html index 0c0efc06f..6e60dd731 100644 --- a/docs-preview/pr-880/group__core-ecs-component.html +++ b/docs-preview/pr-880/group__core-ecs-system-arguments.html @@ -2,7 +2,7 @@ - Core » ECS » Component module | CUBOS. Docs + Core » ECS » System » System arguments module | CUBOS. Docs @@ -48,8 +48,9 @@

    Core » ECS » - Component module

    -

    Component part of the ECS.

    + System » + System arguments module +

    Contains types and fetcher specializations for system argument types.

    Asserts that a condition is true, aborting the program if it is not.
    +
    + #define CUBOS_ASSERT_IMP(cond, + cons, + ...) +
    +
    Asserts that an implication is true, aborting the program if it is not.
    #define CUBOS_DEBUG_ASSERT(cond, ...) @@ -475,6 +481,34 @@

    +
    +

    + #define CUBOS_ASSERT_IMP(cond, + cons, + ...) + +

    +

    Asserts that an implication is true, aborting the program if it is not.

    + + + + + + + + + + + + + + + + + + +
    Parameters
    condImplication condition.
    consImplication consequence.
    ...Optional format string and arguments.
    +

    #define CUBOS_DEBUG_ASSERT(cond, diff --git a/docs-preview/pr-880/group__engine.html b/docs-preview/pr-880/group__engine.html index d9b2e6f87..44b758558 100644 --- a/docs-preview/pr-880/group__engine.html +++ b/docs-preview/pr-880/group__engine.html @@ -61,7 +61,7 @@

    Contents

    -

    The engine library is built on top of the core library and contains code exclusive to game execution. This includes the main loop, asset management, rendering and physics. It is built around the Cubos class and designed to be as modular as possible. Each sub-module corresponds to a plugin, or a set of plugins.

    The library re-exports some of the core library functionality for convenience such that the user doesn't have to use the cubos::core namespace directly very often.

    +

    The engine library is built on top of the core library and contains code exclusive to game execution. This includes asset management, rendering and physics. It is built around the Cubos class and designed to be as modular as possible. Each sub-module corresponds to a plugin, or a set of plugins.

    The library re-exports some of the core library functionality for convenience such that the user doesn't have to use the cubos::core namespace directly very often.

    Modules

    @@ -81,7 +81,7 @@

    Modules

    Creates and handles the lifecycle of a renderer.
    module Scene
    Adds scenes to CUBOS.
    -
    module ScreenPicker
    +
    module ScreenPicker
    Used to select entities and gizmos by clicking them.
    module Settings
    Adds and manages settings.
    @@ -101,7 +101,7 @@

    Modules

    Files

    file cubos.hpp
    -
    Class cubos::engine::Cubos.
    +
    Class cubos::engine::Cubos.
    file settings.hpp
    Class cubos::engine::Settings.
    @@ -109,30 +109,6 @@

    Files

    Classes

    -
    - struct cubos::engine::DeltaTime -
    -
    Resource which stores the time since the last iteration of the main loop started.
    -
    - struct cubos::engine::ShouldQuit -
    -
    Resource used as a flag to indicate whether the main loop should stop running.
    -
    - struct cubos::engine::Arguments -
    -
    Resource which stores the command-line arguments.
    -
    - class cubos::engine::TagBuilder -
    -
    Used to chain configurations related to tags.
    -
    - class cubos::engine::SystemBuilder -
    -
    Used to chain configurations related to systems.
    -
    - class cubos::engine::Cubos -
    -
    Represents the engine itself, and exposes the interface with which the game developer interacts with. Ties up all the different parts of the engine together.
    class cubos::engine::Settings
    diff --git a/docs-preview/pr-880/group__physics-plugin.html b/docs-preview/pr-880/group__physics-plugin.html index d40577db9..dc0bae628 100644 --- a/docs-preview/pr-880/group__physics-plugin.html +++ b/docs-preview/pr-880/group__physics-plugin.html @@ -136,15 +136,15 @@

    Classes

    struct cubos::engine::FixedDeltaTime
    -
    Resouce which holds the value of the fixed delta for the physics update.
    +
    Resource which holds the value of the fixed delta for the physics update.
    struct cubos::engine::Gravity
    -
    Resouce which holds the global value of gravity.
    +
    Resource which holds the global value of gravity.
    struct cubos::engine::Substeps
    -
    Resouce which holds the amount of substeps for the physics update.
    +
    Resource which holds the amount of substeps for the physics update.
    diff --git a/docs-preview/pr-880/group__screenpicker-plugin.html b/docs-preview/pr-880/group__screen-picker-plugin.html similarity index 94% rename from docs-preview/pr-880/group__screenpicker-plugin.html rename to docs-preview/pr-880/group__screen-picker-plugin.html index 99c82599a..d689c5415 100644 --- a/docs-preview/pr-880/group__screenpicker-plugin.html +++ b/docs-preview/pr-880/group__screen-picker-plugin.html @@ -66,13 +66,13 @@

    Contents

    -

    Resources

    • ScreenPicker - provides a texture to store entity and gizmo ids.

    Startup tags

    • cubos.screenpicker.init - the ScreenPicker resource is initialized, after cubos.window.init

    Tags

    • cubos.screenpicker.clear - the picking texture is cleared
    • cubos.screenpicker.resize - window resize events are handled and the ScreenPicker texture is resized, after cubos.window.poll and before cubos.screenpicker.clear.

    Dependencies

    +

    Resources

    • ScreenPicker - provides a texture to store entity and gizmo ids.

    Startup tags

    • cubos.screenPicker.init - the ScreenPicker resource is initialized, after cubos.window.init

    Tags

    • cubos.screenPicker.clear - the picking texture is cleared
    • cubos.screenPicker.resize - window resize events are handled and the ScreenPicker texture is resized, after cubos.window.poll and before cubos.screenPicker.clear.

    Dependencies

    Files

    -
    file plugin.hpp
    +
    file plugin.hpp
    Plugin entry point.
    -
    file screenpicker.hpp
    +
    file screen_picker.hpp
    Resource cubos::engine::ScreenPicker.
    @@ -99,7 +99,7 @@

    Function documentation

    void screenPickerPlugin(Cubos& cubos) - +

    Plugin entry function.

    diff --git a/docs-preview/pr-880/group__settings-plugin.html b/docs-preview/pr-880/group__settings-plugin.html index 73a38a4e7..dff93a841 100644 --- a/docs-preview/pr-880/group__settings-plugin.html +++ b/docs-preview/pr-880/group__settings-plugin.html @@ -64,7 +64,7 @@

    Contents

    -

    Initially, parses settings from the Arguments resource. Then, the file at settings.path is loaded, as a JSON file. If the file does not exist, it is created. If it can't be parsed, the plugin aborts. Previously set settings will be overriden, and file settings will be overriden by command line arguments.

    Settings

    • settings.path - path of the settings file (default: ./settings.json).

    Resources

    Startup tags

    • cubos.settings - the settings are loaded, overriding values set previously.
    +

    Initially, parses settings from the Arguments resource. Then, the file at settings.path is loaded, as a JSON file. If the file does not exist, it is created. If it can't be parsed, the plugin aborts. Previously set settings will be overriden, and file settings will be overriden by command line arguments.

    Settings

    • settings.path - path of the settings file (default: ./settings.json).

    Resources

    Startup tags

    • cubos.settings - the settings are loaded, overriding values set previously.

    Files

    diff --git a/docs-preview/pr-880/group__tesseratos-asset-explorer-plugin.html b/docs-preview/pr-880/group__tesseratos-asset-explorer-plugin.html index 28c4409c1..9419413ce 100644 --- a/docs-preview/pr-880/group__tesseratos-asset-explorer-plugin.html +++ b/docs-preview/pr-880/group__tesseratos-asset-explorer-plugin.html @@ -75,7 +75,7 @@

    Files

    Functions

    - void assetExplorerPlugin(cubos::engine::Cubos& cubos) + void assetExplorerPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    @@ -84,7 +84,7 @@

    Functions

    Function documentation

    - void assetExplorerPlugin(cubos::engine::Cubos& cubos) + void assetExplorerPlugin(cubos::engine::Cubos& cubos)

    Plugin entry function.

    diff --git a/docs-preview/pr-880/group__tesseratos-debug-camera-plugin.html b/docs-preview/pr-880/group__tesseratos-debug-camera-plugin.html index eaa947fca..9514073e9 100644 --- a/docs-preview/pr-880/group__tesseratos-debug-camera-plugin.html +++ b/docs-preview/pr-880/group__tesseratos-debug-camera-plugin.html @@ -74,7 +74,7 @@

    Files

    Functions

    - void debugCameraPlugin(cubos::engine::Cubos& cubos) + void debugCameraPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    @@ -83,7 +83,7 @@

    Functions

    Function documentation

    - void debugCameraPlugin(cubos::engine::Cubos& cubos) + void debugCameraPlugin(cubos::engine::Cubos& cubos)

    Plugin entry function.

    diff --git a/docs-preview/pr-880/group__tesseratos-entity-inspector-plugin.html b/docs-preview/pr-880/group__tesseratos-entity-inspector-plugin.html index 8a01a67cc..35a1add1f 100644 --- a/docs-preview/pr-880/group__tesseratos-entity-inspector-plugin.html +++ b/docs-preview/pr-880/group__tesseratos-entity-inspector-plugin.html @@ -74,7 +74,7 @@

    Files

    Functions

    - void entityInspectorPlugin(cubos::engine::Cubos& cubos) + void entityInspectorPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    @@ -83,7 +83,7 @@

    Functions

    Function documentation

    - void entityInspectorPlugin(cubos::engine::Cubos& cubos) + void entityInspectorPlugin(cubos::engine::Cubos& cubos)

    Plugin entry function.

    diff --git a/docs-preview/pr-880/group__tesseratos-entity-selector-plugin.html b/docs-preview/pr-880/group__tesseratos-entity-selector-plugin.html index 48b4fac6a..df5c01510 100644 --- a/docs-preview/pr-880/group__tesseratos-entity-selector-plugin.html +++ b/docs-preview/pr-880/group__tesseratos-entity-selector-plugin.html @@ -53,7 +53,9 @@

    Contents

    -

    Initially sets ShouldQuit to false, and sets it to true only when the window is closed.

    Settings

    • window.title - the window's title (default: CUBOS.).
    • window.width - the window's width (default: 800).
    • window.height - the window's height (default: 600).

    Events

    Resources

    Startup tags

    • cubos.window.init - window is opened, runs after cubos.settings.

    Tags

    • cubos.window.poll - the window is polled for events, sending core::io::WindowEvent's.
    • cubos.window.render - the window's back buffers are swapped.

    Dependencies

    +

    Initially sets ShouldQuit to false, and sets it to true only when the window is closed.

    Settings

    • window.title - the window's title (default: CUBOS.).
    • window.width - the window's width (default: 800).
    • window.height - the window's height (default: 600).

    Events

    Resources

    Startup tags

    • cubos.window.init - window is opened, runs after cubos.settings.

    Tags

    • cubos.window.poll - the window is polled for events, sending core::io::WindowEvent's.
    • cubos.window.render - the window's back buffers are swapped.

    Dependencies

    Files

    diff --git a/docs-preview/pr-880/log_8hpp.html b/docs-preview/pr-880/log_8hpp.html index 9a331a6d4..57ba1a1c5 100644 --- a/docs-preview/pr-880/log_8hpp.html +++ b/docs-preview/pr-880/log_8hpp.html @@ -173,6 +173,12 @@

    Defines

    ...)
    Asserts that a condition is true, aborting the program if it is not.
    +
    + #define CUBOS_ASSERT_IMP(cond, + cons, + ...) +
    +
    Asserts that an implication is true, aborting the program if it is not.
    #define CUBOS_DEBUG_ASSERT(cond, ...) diff --git a/docs-preview/pr-880/modules.html b/docs-preview/pr-880/modules.html index 7f7892336..12f6adda5 100644 --- a/docs-preview/pr-880/modules.html +++ b/docs-preview/pr-880/modules.html @@ -60,13 +60,17 @@

    Modules

  • - module ECS Entity Component System library. + module ECS Entity Component System library.
      -
    • module Component Component part of the ECS.
    • module Entity Entity part of the ECS.
    • module Query Defines the query functionality of the ECS.
    • module Resource Resource part of the ECS.
    • -
    • module System System part of the ECS.
    • +
    • + module System System part of the ECS. +
        +
      • module System arguments Contains types and fetcher specializations for system argument types.
      • +
      +
    • module Table Contains various table-like data structures which storage data associated to entities.
  • @@ -93,7 +97,7 @@

    Modules

  • module Renderer Creates and handles the lifecycle of a renderer.
  • module Scene Adds scenes to CUBOS.
  • -
  • module ScreenPicker Used to select entities and gizmos by clicking them.
  • +
  • module ScreenPicker Used to select entities and gizmos by clicking them.
  • module Settings Adds and manages settings.
  • module Splitscreen Adds viewport to all active cameras to achieve a splitscreen layout.
  • module Transform Adds transform components which assign positions, rotations and scaling to entities.
  • diff --git a/docs-preview/pr-880/namespacecubos_1_1core_1_1ecs.html b/docs-preview/pr-880/namespacecubos_1_1core_1_1ecs.html index f41a4c35a..3def73dc5 100644 --- a/docs-preview/pr-880/namespacecubos_1_1core_1_1ecs.html +++ b/docs-preview/pr-880/namespacecubos_1_1core_1_1ecs.html @@ -57,6 +57,7 @@

    Contents

    @@ -74,19 +75,31 @@

    Classes

    class Blueprint
    -
    Collection of entities and their respective components.
    +
    Collection of entities and their respective components and relations.
    class CommandBuffer
    Stores commands to execute them later.
    - class ComponentManager + struct DeltaTime
    -
    Holds and manages components.
    +
    Resource which stores the time since the last iteration of the main loop started.
    - class Storage + struct ShouldQuit
    -
    Stores the components of a given type.
    +
    Resource used as a flag to indicate whether the main loop should stop running.
    +
    + struct Arguments +
    +
    Resource which stores the command-line arguments.
    +
    + class TagBuilder +
    +
    Used to chain configurations related to tags.
    +
    + class Cubos +
    +
    Represents the engine itself, and exposes the interface with which the game developer interacts with. Ties up all the different parts of the engine together.
    class ArchetypeGraph
    @@ -107,18 +120,10 @@

    Classes

    struct EntityHash
    Used to hash Entity objects.
    -
    - class EntityManager -
    -
    Internal type which holds and manages entities and their component masks.
    class EntityPool
    Manages the creation and destruction of entity identifiers, as well as storing their archetype identifiers.
    -
    - struct QueryAccess -
    -
    Describes the types of data a query accesses.
    template<typename... Ts>
    class QueryData @@ -142,6 +147,14 @@

    Classes

    struct QueryTerm
    Describes a term in a query.
    +
    + struct SymmetricTrait +
    +
    Trait used to identify symmetric relations.
    +
    + struct TreeTrait +
    +
    Trait used to identify tree relations.
    template<typename T>
    class TypeBuilder @@ -162,13 +175,13 @@

    Classes

    Holds and manages resources.
    - class Commands + struct SystemAccess
    -
    System argument used to write ECS commands and execute them at a later time.
    +
    Describes the types of data a system accesses.
    - class Dispatcher + class Commands
    -
    Used to add systems and relations between them and then dispatch them all at once.
    +
    System argument used to write ECS commands and execute them at a later time.
    template<typename T>
    class EventPipe @@ -178,31 +191,35 @@

    Classes

    template<typename T, unsigned int M = DEFAULT_FILTER_MASK>
    class EventReader
    -
    System arguments used to read events of type T.
    +
    System arguments used to read events of type T.
    template<typename T>
    class EventWriter
    -
    System argument which allows the system to send events of type T to other systems.
    +
    System argument which allows the system to send events of type T to other systems.
    template<typename... Ts>
    class Query
    -
    System argument which holds the result of a query over all entities in world which match the given arguments.
    +
    System argument which holds the result of a query over all entities in world which match the given arguments.
    - struct SystemInfo + class Dispatcher
    -
    Describes a system.
    +
    Used to add systems and relations between them and then dispatch them all at once.
    -
    template<typename R>
    - class AnySystemWrapper +
    template<typename T>
    + class SystemFetcher
    -
    Base class for system wrappers.
    +
    Type meant to be specialized which implements for each argument type the necessary logic to extract it from the world.
    -
    template<typename F>
    - class SystemWrapper + struct SystemOptions
    -
    Wrapper for a system of type F.
    +
    Contains extra options for a specific system argument.
    +
    +
    template<typename T>
    + class System +
    +
    Holds a system with a return type T.
    struct ColumnId
    @@ -253,6 +270,50 @@

    Classes

    Holds entities, their components and resources.
    +
    +

    Enums

    +
    +
    + enum class Traversal { Random, + Down, + Up } +
    +
    Possible traversal types for tree relation terms.
    +
    +
    +
    +

    Enum documentation

    +
    +

    + enum class cubos::core::ecs::Traversal + +

    +

    Possible traversal types for tree relation terms.

    +
    + + + + + + + + + + + + + + + +
    Enumerators
    Random +

    Default traversal order. No specific ordering is required.

    +
    Down +

    Starts in the topmost entity and traverses down the relation.

    +
    Up +

    Starts in the bottommost entity and traverses up the relation.

    +
    +
    +

    diff --git a/docs-preview/pr-880/namespacecubos_1_1core_1_1ecs_1_1impl.html b/docs-preview/pr-880/namespacecubos_1_1core_1_1ecs_1_1impl.html index a090f6046..aaeedc19a 100644 --- a/docs-preview/pr-880/namespacecubos_1_1core_1_1ecs_1_1impl.html +++ b/docs-preview/pr-880/namespacecubos_1_1core_1_1ecs_1_1impl.html @@ -49,38 +49,7 @@

    cubos::core::ecs::impl namespace

    Contains functions used internally by the implementation of the ECS.

    -

    Used to avoid cluttering the public namespace with implementation details.

    -
    -

    Classes

    -
    -
    -
    template<typename T>
    - struct SystemFetcher -
    -
    Fetches the requested data from a world.
    -
    -
    template<typename F>
    - struct SystemTraits -
    -
    Template magic used to inspect the arguments of a system.
    -
    -
    template<class T, class Tuple>
    - struct Index -
    -
    Used to get the index of a type in a tuple.
    -
    -
    diff --git a/docs-preview/pr-880/namespacecubos_1_1engine.html b/docs-preview/pr-880/namespacecubos_1_1engine.html index 39ed9dc4a..74d699b56 100644 --- a/docs-preview/pr-880/namespacecubos_1_1engine.html +++ b/docs-preview/pr-880/namespacecubos_1_1engine.html @@ -111,9 +111,9 @@

    Classes

    Stores metadata about an asset - the data stored in .meta files. Each asset has a corresponding meta object, which contains load or import parameters.
    - struct BroadPhaseCandidates + struct PotentiallyCollidingWith
    -
    Resource which stores candidates found in broad phase collision detection.
    +
    Component which represents a potential collisions.
    struct Collider
    @@ -130,30 +130,6 @@

    Classes

    struct CapsuleCollisionShape
    Component which adds a capsule collision shape to an entity, used with a Collider component.
    -
    - struct DeltaTime -
    -
    Resource which stores the time since the last iteration of the main loop started.
    -
    - struct ShouldQuit -
    -
    Resource used as a flag to indicate whether the main loop should stop running.
    -
    - struct Arguments -
    -
    Resource which stores the command-line arguments.
    -
    - class TagBuilder -
    -
    Used to chain configurations related to tags.
    -
    - class SystemBuilder -
    -
    Used to chain configurations related to systems.
    -
    - class Cubos -
    -
    Represents the engine itself, and exposes the interface with which the game developer interacts with. Ties up all the different parts of the engine together.
    class Gizmos
    @@ -209,15 +185,15 @@

    Classes

    struct FixedDeltaTime
    -
    Resouce which holds the value of the fixed delta for the physics update.
    +
    Resource which holds the value of the fixed delta for the physics update.
    struct Gravity
    -
    Resouce which holds the global value of gravity.
    +
    Resource which holds the global value of gravity.
    struct Substeps
    -
    Resouce which holds the amount of substeps for the physics update.
    +
    Resource which holds the amount of substeps for the physics update.
    struct Camera
    @@ -368,6 +344,22 @@

    Typedefs

    using AssetWrite = core::memory::WriteGuard<T, std::unique_lock<std::shared_mutex>>
    Read-write guard for an asset's data.
    +
    + using Cubos = core::ecs::Cubos +
    +
    Represents the engine itself, and exposes the interface with which the game developer interacts with. Ties up all the different parts of the engine together.
    +
    + using DeltaTime = core::ecs::DeltaTime +
    +
    Resource which stores the time since the last iteration of the main loop started.
    +
    + using ShouldQuit = core::ecs::ShouldQuit +
    +
    Resource used as a flag to indicate whether the main loop should stop running.
    +
    + using Arguments = core::ecs::Arguments +
    +
    Resource which stores the command-line arguments.
    template<typename... ComponentTypes>
    using Query = core::ecs::Query<ComponentTypes...> @@ -410,35 +402,35 @@

    Typedefs

    Functions

    - void assetsPlugin(Cubos& cubos) + void assetsPlugin(Cubos& cubos)
    Plugin entry function.
    - void collisionsPlugin(Cubos& cubos) + void collisionsPlugin(Cubos& cubos)
    Plugin entry function.
    - void gizmosPlugin(Cubos& cubos) + void gizmosPlugin(Cubos& cubos)
    Plugin entry function.
    - void imguiPlugin(Cubos& cubos) + void imguiPlugin(Cubos& cubos)
    Plugin entry function.
    - void inputPlugin(Cubos& cubos) + void inputPlugin(Cubos& cubos)
    Plugin entry function.
    - void physicsPlugin(Cubos& cubos) + void physicsPlugin(Cubos& cubos)
    Plugin entry function.
    - void gravityPlugin(Cubos& cubos) + void gravityPlugin(Cubos& cubos)
    Plugin entry function.
    - void rendererPlugin(Cubos& cubos) + void rendererPlugin(Cubos& cubos)
    Plugin entry function.
    @@ -448,41 +440,62 @@

    Functions

    Triangulates a grid of voxels into an indexed mesh.
    - void scenePlugin(Cubos& cubos) + void scenePlugin(Cubos& cubos)
    Plugin entry function.
    - void screenPickerPlugin(Cubos& cubos) + void screenPickerPlugin(Cubos& cubos)
    Plugin entry function.
    - void settingsPlugin(Cubos& cubos) + void settingsPlugin(Cubos& cubos)
    Plugin entry function.
    - void splitscreenPlugin(Cubos& cubos) + void splitscreenPlugin(Cubos& cubos)
    Plugin entry function.
    - void transformPlugin(Cubos& cubos) + void transformPlugin(Cubos& cubos)
    Plugin entry function.
    - void freeCameraControllerPlugin(Cubos& cubos) + void freeCameraControllerPlugin(Cubos& cubos)
    Plugin entry function.
    - void voxelsPlugin(Cubos& cubos) + void voxelsPlugin(Cubos& cubos)
    Plugin entry function.
    - void windowPlugin(Cubos& cubos) + void windowPlugin(Cubos& cubos)
    Plugin entry function.

    Typedef documentation

    +
    +

    + using cubos::engine::DeltaTime = core::ecs::DeltaTime +

    +

    Resource which stores the time since the last iteration of the main loop started.

    +

    This resource is added and updated by the Cubos class.

    +
    +
    +

    + using cubos::engine::ShouldQuit = core::ecs::ShouldQuit +

    +

    Resource used as a flag to indicate whether the main loop should stop running.

    +

    This resource is added by the Cubos class, initially set to true.

    +
    +
    +

    + using cubos::engine::Arguments = core::ecs::Arguments +

    +

    Resource which stores the command-line arguments.

    +

    This resource is added by the Cubos class.

    +

    @@ -578,7 +591,7 @@

    Function documentation

    - void cubos::engine::freeCameraControllerPlugin(Cubos& cubos) + void cubos::engine::freeCameraControllerPlugin(Cubos& cubos)

    Plugin entry function.

    diff --git a/docs-preview/pr-880/namespacetesseratos.html b/docs-preview/pr-880/namespacetesseratos.html index 4ac55c94e..4bb8f6d33 100644 --- a/docs-preview/pr-880/namespacetesseratos.html +++ b/docs-preview/pr-880/namespacetesseratos.html @@ -82,7 +82,7 @@

    Classes

    Functions

    - void assetExplorerPlugin(cubos::engine::Cubos& cubos) + void assetExplorerPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    @@ -100,47 +100,47 @@

    Functions

    Displays a modal popup to select an asset of a specified type.
    - void debugCameraPlugin(cubos::engine::Cubos& cubos) + void debugCameraPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    - void entityInspectorPlugin(cubos::engine::Cubos& cubos) + void entityInspectorPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    - void entitySelectorPlugin(cubos::engine::Cubos& cubos) + void entitySelectorPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    - void metricsPanelPlugin(cubos::engine::Cubos& cubos) + void metricsPanelPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    - void plugin(cubos::engine::Cubos& cubos) + void plugin(cubos::engine::Cubos& cubos)
    Tesseratos entry function.
    - void sceneEditorPlugin(cubos::engine::Cubos& cubos) + void sceneEditorPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    - void settingsInspectorPlugin(cubos::engine::Cubos& cubos) + void settingsInspectorPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    - void toolboxPlugin(cubos::engine::Cubos& cubos) + void toolboxPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    - void transformGizmoPlugin(cubos::engine::Cubos& cubos) + void transformGizmoPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    - void voxelPaletteEditorPlugin(cubos::engine::Cubos& cubos) + void voxelPaletteEditorPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    - void worldInspectorPlugin(cubos::engine::Cubos& cubos) + void worldInspectorPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    diff --git a/docs-preview/pr-880/storage_8hpp.html b/docs-preview/pr-880/options_8hpp.html similarity index 91% rename from docs-preview/pr-880/storage_8hpp.html rename to docs-preview/pr-880/options_8hpp.html index 6625fba5b..bc6647e2a 100644 --- a/docs-preview/pr-880/storage_8hpp.html +++ b/docs-preview/pr-880/options_8hpp.html @@ -2,7 +2,7 @@ - core/ecs/component/storage.hpp file | CUBOS. Docs + core/ecs/system/options.hpp file | CUBOS. Docs @@ -46,9 +46,9 @@

    - core/ecs/component/storage.hpp file + core/ecs/system/options.hpp file

    -

    Class cubos::core::ecs::Storage and related types.

    +

    Struct cubos::core::ecs::SystemOptions.

    diff --git a/docs-preview/pr-880/pages.html b/docs-preview/pr-880/pages.html index 85fc01d30..7b4efa72d 100644 --- a/docs-preview/pr-880/pages.html +++ b/docs-preview/pr-880/pages.html @@ -97,7 +97,7 @@

    Pages

  • Engine Showcases features of the Engine library.
  • diff --git a/docs-preview/pr-880/fetcher_8hpp.html b/docs-preview/pr-880/query_2fetcher_8hpp.html similarity index 100% rename from docs-preview/pr-880/fetcher_8hpp.html rename to docs-preview/pr-880/query_2fetcher_8hpp.html diff --git a/docs-preview/pr-880/query_8hpp.html b/docs-preview/pr-880/query_8hpp.html index a6eaa04e8..6a9b7db35 100644 --- a/docs-preview/pr-880/query_8hpp.html +++ b/docs-preview/pr-880/query_8hpp.html @@ -2,7 +2,7 @@ - core/ecs/system/query.hpp file | CUBOS. Docs + core/ecs/system/arguments/query.hpp file | CUBOS. Docs @@ -46,7 +46,7 @@

    - core/ecs/system/query.hpp file + core/ecs/system/arguments/query.hpp file

    Class cubos::core::ecs::Query.

    diff --git a/docs-preview/pr-880/reader_8hpp.html b/docs-preview/pr-880/reader_8hpp.html index 0fcac090c..155b19771 100644 --- a/docs-preview/pr-880/reader_8hpp.html +++ b/docs-preview/pr-880/reader_8hpp.html @@ -2,7 +2,7 @@ - core/ecs/system/event/reader.hpp file | CUBOS. Docs + core/ecs/system/arguments/event/reader.hpp file | CUBOS. Docs @@ -46,7 +46,7 @@

    - core/ecs/system/event/reader.hpp file + core/ecs/system/arguments/event/reader.hpp file

    Class cubos::core::ecs::EventReader.

    diff --git a/docs-preview/pr-880/core_2include_2cubos_2core_2ecs_2entity_2manager_8hpp.html b/docs-preview/pr-880/resources_8hpp.html similarity index 84% rename from docs-preview/pr-880/core_2include_2cubos_2core_2ecs_2entity_2manager_8hpp.html rename to docs-preview/pr-880/resources_8hpp.html index 7f1ff5ee2..094edb7fc 100644 --- a/docs-preview/pr-880/core_2include_2cubos_2core_2ecs_2entity_2manager_8hpp.html +++ b/docs-preview/pr-880/resources_8hpp.html @@ -2,7 +2,7 @@ - core/ecs/entity/manager.hpp file | CUBOS. Docs + core/ecs/system/arguments/resources.hpp file | CUBOS. Docs @@ -46,9 +46,9 @@

    - core/ecs/entity/manager.hpp file + core/ecs/system/arguments/resources.hpp file

    -

    Class cubos::core::ecs::EntityManager.

    +

    Resource system argument specializations.

    -
    -

    Classes

    -
    -
    - class cubos::core::ecs::EntityManager -
    -
    Internal type which holds and manages entities and their component masks.
    -
    - class cubos::core::ecs::EntityManager::Iterator -
    -
    Used to iterate over all entities in a manager with a certain component mask.
    -
    -
    diff --git a/docs-preview/pr-880/screenpicker_8hpp.html b/docs-preview/pr-880/screen__picker_8hpp.html similarity index 96% rename from docs-preview/pr-880/screenpicker_8hpp.html rename to docs-preview/pr-880/screen__picker_8hpp.html index 67a19b0c1..0df955ddb 100644 --- a/docs-preview/pr-880/screenpicker_8hpp.html +++ b/docs-preview/pr-880/screen__picker_8hpp.html @@ -2,7 +2,7 @@ - engine/screenpicker/screenpicker.hpp file | CUBOS. Docs + engine/screen_picker/screen_picker.hpp file | CUBOS. Docs @@ -46,7 +46,7 @@

    - engine/screenpicker/screenpicker.hpp file + engine/screen_picker/screen_picker.hpp file

    Resource cubos::engine::ScreenPicker.

    -

    Terms are the building blocks used to build queries. Each term adds some restriction to what the query will match. There are three kinds of terms:

    • Component terms, which allow filtering match entities by those which have or don't have a given component.
    • Relation terms, which allow filtering match entities by some relation between them.
    • Entity terms, which don't filter the results but allow accessing one of the matched entities.
    +

    Terms are the building blocks used to build queries. Each term adds some restriction to what the query will match. There are three kinds of terms:

    • Component terms, which allow filtering match entities by those which have or don't have a given component.
    • Relation terms, which allow filtering match entities by some relation between them.
    • Entity terms, which don't filter the results but allow accessing one of the matched entities.

    Public types

    @@ -76,6 +76,10 @@

    Public types

    struct Entity
    Stores entity term data.
    +
    + struct Relation +
    +
    Stores relation term data.
    @@ -100,12 +104,24 @@

    Public static functions

    int target) -> QueryTerm
    Returns a new optional component term for the given component and target.
    +
    + static auto makeRelation(DataTypeId type, + int fromTarget, + int toTarget, + Traversal traversal = Traversal::Random) -> QueryTerm +
    +
    Returns a new relation term for the given relation and targets.
    static auto resolve(const Types& types, const std::vector<QueryTerm>& baseTerms, std::vector<QueryTerm>& otherTerms) -> std::vector<QueryTerm>
    Merges a vector of terms with another, joining pairs of them if possible.
    +
    + static auto toString(const Types& types, + const std::vector<QueryTerm>& terms) -> std::string +
    +
    Gets a string representation of vector of query terms.
    @@ -119,6 +135,10 @@

    Public functions

    auto isComponent(const Types& types) const -> bool
    Checks if the term is a component term.
    +
    + auto isRelation(const Types& types) const -> bool +
    +
    Checks if the term is a relation term.
    auto compare(const Types& types, const QueryTerm& other) const -> bool @@ -141,6 +161,10 @@

    Public variables

    Component component
    Component term data.
    +
    + Relation relation +
    +
    Relation term data.
    @@ -254,6 +278,45 @@

    +

    +
    +

    + static QueryTerm cubos::core::ecs::QueryTerm::makeRelation(DataTypeId type, + int fromTarget, + int toTarget, + Traversal traversal = Traversal::Random) +

    +

    Returns a new relation term for the given relation and targets.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Parameters
    typeRelation type.
    fromTargetIndex of the target which must have the 'from' side of the relation.
    toTargetIndex of the target which must have the 'to' side of the relation.
    traversalTraversal order for the relation.
    ReturnsRelation term.
    +

    @@ -289,6 +352,34 @@

    This function is mainly used to merge terms specified manually for a query with terms obtained from its argument types. For example, if we have a query of the form Query<A&, A&>, we will obtain the terms makeWithComponent(A, -1) and makeWithComponent(A, -1). Those term would be passed into other. If we passed to base the terms makeWithComponent(A, 0) and makeWithComponent(A, 1), then, the base wouldn't be modified, and the other vector would have its targets updated so that it matches the base.

    Any targets found set to -1 will be set to the current default target. The default target is initially 0, and always changes to the last seen non -1 target. If a relation term has one of the targets undefined, the default target is incremented.

    Another example would be to have an empty base vector, and the query Query<A&, B&>. The other vector would be {makeWithComponent(A, -1), makeWithComponent(B, -1)}, and the returned vector would be {makeWithComponent(A, 0), makeWithComponent(B, 0)}.

    +
    +

    + static std::string cubos::core::ecs::QueryTerm::toString(const Types& types, + const std::vector<QueryTerm>& terms) +

    +

    Gets a string representation of vector of query terms.

    + + + + + + + + + + + + + + + + + + + + +
    Parameters
    typesType registry.
    termsVector of terms.
    ReturnsString representation.
    +

    bool cubos::core::ecs::QueryTerm::isEntity() const @@ -326,6 +417,29 @@

    +
    +

    + bool cubos::core::ecs::QueryTerm::isRelation(const Types& types) const +

    +

    Checks if the term is a relation term.

    + + + + + + + + + + + + + + + + +
    Parameters
    typesTypes registry.
    ReturnsWhether it's a relation term.
    +

    bool cubos::core::ecs::QueryTerm::compare(const Types& types, diff --git a/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1QueryTerm_1_1Relation.html b/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1QueryTerm_1_1Relation.html new file mode 100644 index 000000000..5bd0ab0af --- /dev/null +++ b/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1QueryTerm_1_1Relation.html @@ -0,0 +1,131 @@ + + + + + cubos::core::ecs::QueryTerm::Relation struct | CUBOS. Docs + + + + + + + +
    +
    + + + +
    + + diff --git a/docs-preview/pr-880/structcubos_1_1engine_1_1ShouldQuit.html b/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1ShouldQuit.html similarity index 91% rename from docs-preview/pr-880/structcubos_1_1engine_1_1ShouldQuit.html rename to docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1ShouldQuit.html index ddc4055b9..8187adc9c 100644 --- a/docs-preview/pr-880/structcubos_1_1engine_1_1ShouldQuit.html +++ b/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1ShouldQuit.html @@ -2,7 +2,7 @@ - cubos::engine::ShouldQuit struct | CUBOS. Docs + cubos::core::ecs::ShouldQuit struct | CUBOS. Docs @@ -46,8 +46,8 @@

    - cubos::engine::ShouldQuit struct - + cubos::core::ecs::ShouldQuit struct +

    Resource used as a flag to indicate whether the main loop should stop running.

    -

    This resource is added by the Cubos class, initially set to true.

    +

    This resource is added by the Cubos class, initially set to true.

    Public variables

    -
    - bool value +
    + bool value
    Whether the main loop should stop running.
    diff --git a/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1SparseRelationTableId.html b/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1SparseRelationTableId.html index 9ebb960db..409fc6b10 100644 --- a/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1SparseRelationTableId.html +++ b/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1SparseRelationTableId.html @@ -66,9 +66,10 @@

    Contents

    Constructors, destructors, conversion operators

    - SparseRelationTableId(DataTypeId dataType, + SparseRelationTableId(DataTypeId dataType, ArchetypeId from, - ArchetypeId to) + ArchetypeId to, + int depth = 0)
    Constructs.
    @@ -84,11 +85,12 @@

    Public functions

    Function documentation

    -
    +

    - cubos::core::ecs::SparseRelationTableId::SparseRelationTableId(DataTypeId dataType, + cubos::core::ecs::SparseRelationTableId::SparseRelationTableId(DataTypeId dataType, ArchetypeId from, - ArchetypeId to) + ArchetypeId to, + int depth = 0)

    Constructs.

    @@ -108,6 +110,10 @@

    + + + +
    to To archetype identifier.
    depthDepth of the relation. Used in tree relations, always 0 for others.
    diff --git a/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1EntityManager_1_1Iterator.html b/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1SymmetricTrait.html similarity index 91% rename from docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1EntityManager_1_1Iterator.html rename to docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1SymmetricTrait.html index 893583839..565d19f71 100644 --- a/docs-preview/pr-880/classcubos_1_1core_1_1ecs_1_1EntityManager_1_1Iterator.html +++ b/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1SymmetricTrait.html @@ -2,7 +2,7 @@ - cubos::core::ecs::EntityManager::Iterator class | CUBOS. Docs + cubos::core::ecs::SymmetricTrait struct | CUBOS. Docs @@ -46,10 +46,11 @@

    - cubos::core::ecs::EntityManager::Iterator class - + cubos::core::ecs::SymmetricTrait struct +

    -

    Used to iterate over all entities in a manager with a certain component mask.

    +

    Trait used to identify symmetric relations.

    +

    Symmetric relations are relations where the order of the entities does not matter.

    diff --git a/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1QueryAccess.html b/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1SystemAccess.html similarity index 75% rename from docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1QueryAccess.html rename to docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1SystemAccess.html index ac4b7445e..5e6b9010b 100644 --- a/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1QueryAccess.html +++ b/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1SystemAccess.html @@ -2,7 +2,7 @@ - cubos::core::ecs::QueryAccess struct | CUBOS. Docs + cubos::core::ecs::SystemAccess struct | CUBOS. Docs @@ -46,10 +46,10 @@

    - cubos::core::ecs::QueryAccess struct - + cubos::core::ecs::SystemAccess struct +

    -

    Describes the types of data a query accesses.

    +

    Describes the types of data a system accesses.

    +
    +

    Public variables

    +
    +
    + bool usesWorld +
    +
    Whether the system accesses the world directly.
    +
    + std::unordered_set<DataTypeId, DataTypeIdHash> dataTypes +
    +
    Set of data types accessed by the system.
    +
    +

    Function documentation

    -
    -

    - void cubos::core::ecs::QueryAccess::insert(DataTypeId id) -

    -

    Adds a type identifier to the set of types the query accesses.

    - - - - - - - - - - -
    Parameters
    idType identifier.
    -
    -
    +

    - bool cubos::core::ecs::QueryAccess::intersects(const QueryAccess& other) const + bool cubos::core::ecs::SystemAccess::intersects(const SystemAccess& other) const

    Checks if this access patterns intersect with the given ones.

    @@ -106,7 +99,7 @@

    - + diff --git a/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1SystemInfo.html b/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1SystemInfo.html deleted file mode 100644 index a313a05e8..000000000 --- a/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1SystemInfo.html +++ /dev/null @@ -1,191 +0,0 @@ - - - - - cubos::core::ecs::SystemInfo struct | CUBOS. Docs - - - - - - - -
    -
    -
    -
    -
    -

    - cubos::core::ecs::SystemInfo struct - -

    -

    Describes a system.

    - -
    -

    Public functions

    -
    -
    - auto valid() const -> bool -
    -
    Checks if this system is valid.
    -
    - auto compatible(const SystemInfo& other) const -> bool -
    -
    Checks if this system is compatible with another system.
    -
    -
    -
    -

    Public variables

    -
    -
    - bool usesCommands -
    -
    Whether the system uses commands or not.
    -
    - bool usesWorld -
    -
    Whether the system uses the world directly.
    -
    - std::unordered_set<std::type_index> resourcesRead -
    -
    Set of resources the system reads.
    -
    - std::unordered_set<std::type_index> resourcesWritten -
    -
    Set of resources the system writes.
    -
    -
    -
    -

    Function documentation

    -
    -

    - bool cubos::core::ecs::SystemInfo::valid() const -

    -

    Checks if this system is valid.

    -
    otherOther query access patterns.Other system access patterns.
    - - - - - - -
    ReturnsWhether the system is valid.
    -

    A system may be invalid, if, for example, it both reads and writes the same resource.

    -
    -
    -

    - bool cubos::core::ecs::SystemInfo::compatible(const SystemInfo& other) const -

    -

    Checks if this system is compatible with another system.

    - - - - - - - - - - - - - - - - -
    Parameters
    otherOther system.
    ReturnsWhether the systems are compatible.
    -

    Two systems are compatible if they can be executed in parallel. This means that they must not, for example, write to the same resource or component.

    -
    -
    -
    -
    -

    - - - - -
    - - diff --git a/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1SystemOptions.html b/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1SystemOptions.html new file mode 100644 index 000000000..3e224781f --- /dev/null +++ b/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1SystemOptions.html @@ -0,0 +1,123 @@ + + + + + cubos::core::ecs::SystemOptions struct | CUBOS. Docs + + + + + + + +
    +
    + + + +
    + + diff --git a/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1impl_1_1SystemTraits.html b/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1TreeTrait.html similarity index 90% rename from docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1impl_1_1SystemTraits.html rename to docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1TreeTrait.html index 57a62be4b..1ceb5e6fa 100644 --- a/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1impl_1_1SystemTraits.html +++ b/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1TreeTrait.html @@ -2,7 +2,7 @@ - cubos::core::ecs::impl::SystemTraits struct | CUBOS. Docs + cubos::core::ecs::TreeTrait struct | CUBOS. Docs @@ -46,11 +46,11 @@

    - -
    template<typename F>
    - cubos::core::ecs::impl::SystemTraits struct + cubos::core::ecs::TreeTrait struct +

    -

    Template magic used to inspect the arguments of a system.

    +

    Trait used to identify tree relations.

    +

    Tree relations are relations which form trees. Each entity must have at most one target entity for a given tree relation type. These can be used to represent parent-child relationships.

    diff --git a/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1impl_1_1Index.html b/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1impl_1_1Index.html deleted file mode 100644 index c30e9ecaa..000000000 --- a/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1impl_1_1Index.html +++ /dev/null @@ -1,120 +0,0 @@ - - - - - cubos::core::ecs::impl::Index struct | CUBOS. Docs - - - - - - - -
    -
    - - - -
    - - diff --git a/docs-preview/pr-880/structcubos_1_1engine_1_1BroadPhaseCandidates.html b/docs-preview/pr-880/structcubos_1_1engine_1_1BroadPhaseCandidates.html deleted file mode 100644 index 51e6b03e7..000000000 --- a/docs-preview/pr-880/structcubos_1_1engine_1_1BroadPhaseCandidates.html +++ /dev/null @@ -1,246 +0,0 @@ - - - - - cubos::engine::BroadPhaseCandidates struct | CUBOS. Docs - - - - - - - -
    -
    -
    -
    -
    -

    - cubos::engine::BroadPhaseCandidates struct - -

    -

    Resource which stores candidates found in broad phase collision detection.

    - -
    -

    Public types

    -
    -
    - struct CandidateHash -
    -
    Hash function to allow Candidates to be used as keys in an unordered_set.
    -
    - enum class CollisionType { BoxBox = 0, - BoxCapsule, - CapsuleCapsule, - Count } -
    -
    Collision type for each pair of colliders.
    -
    - using Candidate = std::pair<core::ecs::Entity, core::ecs::Entity> -
    -
    Pair of entities that may collide.
    -
    -
    -
    -

    Public functions

    -
    -
    - void addCandidate(CollisionType type, - Candidate candidate) -
    -
    Adds a collision candidate to the list of candidates for a specific collision type.
    -
    - auto candidates(CollisionType type) const -> const std::unordered_set<Candidate, CandidateHash>& -
    -
    Gets the collision candidates for a specific collision type.
    -
    - void clearCandidates() -
    -
    Clears the list of collision candidates.
    -
    -
    -
    -

    Public variables

    -
    -
    - std::unordered_set<Candidate, CandidateHash> candidatesPerType -
    -
    Sets of collision candidates for each collision type. The index of the array is the collision type.
    -
    -
    -
    -

    Enum documentation

    -
    -

    - enum class cubos::engine::BroadPhaseCandidates::CollisionType -

    -

    Collision type for each pair of colliders.

    - - - - - - - - - - - - - - - - - - - - -
    Enumerators
    BoxBox -
    BoxCapsule -
    CapsuleCapsule -
    Count -

    Number of collision types.

    -
    -
    -
    -
    -

    Function documentation

    -
    -

    - void cubos::engine::BroadPhaseCandidates::addCandidate(CollisionType type, - Candidate candidate) -

    -

    Adds a collision candidate to the list of candidates for a specific collision type.

    - - - - - - - - - - - - - - -
    Parameters
    typeCollision type.
    candidateCollision candidate.
    -
    -
    -

    - const std::unordered_set<Candidate, CandidateHash>& cubos::engine::BroadPhaseCandidates::candidates(CollisionType type) const -

    -

    Gets the collision candidates for a specific collision type.

    - - - - - - - - - - - - - - - - -
    Parameters
    typeCollision type.
    ReturnsCollision candidates.
    -
    -
    -
    -
    -
    -
    - - - -
    - - diff --git a/docs-preview/pr-880/structcubos_1_1engine_1_1FixedDeltaTime.html b/docs-preview/pr-880/structcubos_1_1engine_1_1FixedDeltaTime.html index c89013fdf..610258754 100644 --- a/docs-preview/pr-880/structcubos_1_1engine_1_1FixedDeltaTime.html +++ b/docs-preview/pr-880/structcubos_1_1engine_1_1FixedDeltaTime.html @@ -49,7 +49,7 @@

    cubos::engine::FixedDeltaTime struct

    -

    Resouce which holds the value of the fixed delta for the physics update.

    +

    Resource which holds the value of the fixed delta for the physics update.

    diff --git a/docs-preview/pr-880/structcubos_1_1engine_1_1Gravity.html b/docs-preview/pr-880/structcubos_1_1engine_1_1Gravity.html index 79ea7923e..df2814ed5 100644 --- a/docs-preview/pr-880/structcubos_1_1engine_1_1Gravity.html +++ b/docs-preview/pr-880/structcubos_1_1engine_1_1Gravity.html @@ -49,7 +49,7 @@

    cubos::engine::Gravity struct

    -

    Resouce which holds the global value of gravity.

    +

    Resource which holds the global value of gravity.

    diff --git a/docs-preview/pr-880/structcubos_1_1engine_1_1BroadPhaseCandidates_1_1CandidateHash.html b/docs-preview/pr-880/structcubos_1_1engine_1_1PotentiallyCollidingWith.html similarity index 90% rename from docs-preview/pr-880/structcubos_1_1engine_1_1BroadPhaseCandidates_1_1CandidateHash.html rename to docs-preview/pr-880/structcubos_1_1engine_1_1PotentiallyCollidingWith.html index 44a085e57..3b15a149f 100644 --- a/docs-preview/pr-880/structcubos_1_1engine_1_1BroadPhaseCandidates_1_1CandidateHash.html +++ b/docs-preview/pr-880/structcubos_1_1engine_1_1PotentiallyCollidingWith.html @@ -2,7 +2,7 @@ - cubos::engine::BroadPhaseCandidates::CandidateHash struct | CUBOS. Docs + cubos::engine::PotentiallyCollidingWith struct | CUBOS. Docs @@ -46,10 +46,10 @@

    - cubos::engine::BroadPhaseCandidates::CandidateHash struct - + cubos::engine::PotentiallyCollidingWith struct +

    -

    Hash function to allow Candidates to be used as keys in an unordered_set.

    +

    Component which represents a potential collisions.

    diff --git a/docs-preview/pr-880/structcubos_1_1engine_1_1RendererFrame_1_1DrawCmd.html b/docs-preview/pr-880/structcubos_1_1engine_1_1RendererFrame_1_1DrawCmd.html index 32cbe2052..02e39b20d 100644 --- a/docs-preview/pr-880/structcubos_1_1engine_1_1RendererFrame_1_1DrawCmd.html +++ b/docs-preview/pr-880/structcubos_1_1engine_1_1RendererFrame_1_1DrawCmd.html @@ -72,6 +72,10 @@

    Public variables

    glm::mat4 modelMat
    Model transform matrix.
    +
    + uint32_t entityIndex +
    +
    Entity identifier.
    diff --git a/docs-preview/pr-880/structcubos_1_1engine_1_1Substeps.html b/docs-preview/pr-880/structcubos_1_1engine_1_1Substeps.html index f8bdcc897..1ce0cb1da 100644 --- a/docs-preview/pr-880/structcubos_1_1engine_1_1Substeps.html +++ b/docs-preview/pr-880/structcubos_1_1engine_1_1Substeps.html @@ -49,7 +49,7 @@

    cubos::engine::Substeps struct

    -

    Resouce which holds the amount of substeps for the physics update.

    +

    Resource which holds the amount of substeps for the physics update.

    diff --git a/docs-preview/pr-880/structtesseratos_1_1EntitySelector.html b/docs-preview/pr-880/structtesseratos_1_1EntitySelector.html index 2114031b5..5050ebded 100644 --- a/docs-preview/pr-880/structtesseratos_1_1EntitySelector.html +++ b/docs-preview/pr-880/structtesseratos_1_1EntitySelector.html @@ -68,6 +68,10 @@

    Public variables

    cubos::core::ecs::Entity selection
    Selected entity, or null if none.
    +
    + glm::ivec2 lastMousePosition +
    +
    Cursor position.
    diff --git a/docs-preview/pr-880/substeps_8hpp.html b/docs-preview/pr-880/substeps_8hpp.html index 92b444673..59e15cde1 100644 --- a/docs-preview/pr-880/substeps_8hpp.html +++ b/docs-preview/pr-880/substeps_8hpp.html @@ -76,7 +76,7 @@

    Classes

    struct cubos::engine::Substeps
    -
    Resouce which holds the amount of substeps for the physics update.
    +
    Resource which holds the amount of substeps for the physics update.
    diff --git a/docs-preview/pr-880/system_2arguments_2world_8hpp.html b/docs-preview/pr-880/system_2arguments_2world_8hpp.html new file mode 100644 index 000000000..fa521f3f1 --- /dev/null +++ b/docs-preview/pr-880/system_2arguments_2world_8hpp.html @@ -0,0 +1,124 @@ + + + + + core/ecs/system/arguments/world.hpp file | CUBOS. Docs + + + + + + + +
    +
    + + + +
    + + diff --git a/docs-preview/pr-880/core_2include_2cubos_2core_2ecs_2component_2manager_8hpp.html b/docs-preview/pr-880/system_2fetcher_8hpp.html similarity index 90% rename from docs-preview/pr-880/core_2include_2cubos_2core_2ecs_2component_2manager_8hpp.html rename to docs-preview/pr-880/system_2fetcher_8hpp.html index 714822e84..13f299413 100644 --- a/docs-preview/pr-880/core_2include_2cubos_2core_2ecs_2component_2manager_8hpp.html +++ b/docs-preview/pr-880/system_2fetcher_8hpp.html @@ -2,7 +2,7 @@ - core/ecs/component/manager.hpp file | CUBOS. Docs + core/ecs/system/fetcher.hpp file | CUBOS. Docs @@ -46,9 +46,9 @@

    - core/ecs/component/manager.hpp file + core/ecs/system/fetcher.hpp file

    -

    Class cubos::core::ecs::ComponentManager and related types.

    +

    Class cubos::core::ecs::SystemFetcher.

    diff --git a/docs-preview/pr-880/system_8hpp.html b/docs-preview/pr-880/system_8hpp.html index dd893aafd..811cdf7d6 100644 --- a/docs-preview/pr-880/system_8hpp.html +++ b/docs-preview/pr-880/system_8hpp.html @@ -48,7 +48,7 @@

    core/ecs/system/system.hpp file

    -

    Class cubos::core::ecs::SystemWrapper and related types.

    +

    Class cubos::core::ecs::System.

    -

    This file is a bit scary, but it's not as bad as it looks. It's mostly template specializations to handle the different types of arguments a system can take.

    Namespaces

    @@ -71,37 +70,16 @@

    Namespaces

    Core namespace.
    namespace cubos::core::ecs
    ECS module.
    -
    namespace cubos::core::ecs::impl
    -
    Contains functions used internally by the implementation of the ECS.

    Classes

    -
    - struct cubos::core::ecs::SystemInfo -
    -
    Describes a system.
    -
    -
    template<typename R>
    - class cubos::core::ecs::AnySystemWrapper -
    -
    Base class for system wrappers.
    template<typename T>
    - struct cubos::core::ecs::impl::SystemFetcher -
    -
    Fetches the requested data from a world.
    -
    -
    template<typename F>
    - struct cubos::core::ecs::impl::SystemTraits -
    -
    Template magic used to inspect the arguments of a system.
    -
    -
    template<typename F>
    - class cubos::core::ecs::SystemWrapper + class cubos::core::ecs::System
    -
    Wrapper for a system of type F.
    +
    Holds a system with a return type T.
    diff --git a/docs-preview/pr-880/term_8hpp.html b/docs-preview/pr-880/term_8hpp.html index 894c742f2..7f9b1a341 100644 --- a/docs-preview/pr-880/term_8hpp.html +++ b/docs-preview/pr-880/term_8hpp.html @@ -57,6 +57,7 @@

    Contents

    @@ -87,6 +88,21 @@

    Classes

    struct cubos::core::ecs::QueryTerm::Component
    Stores component term data.
    +
    + struct cubos::core::ecs::QueryTerm::Relation +
    +
    Stores relation term data.
    + +
    +
    +

    Enums

    +
    +
    + enum class Traversal { Random, + Down, + Up } +
    +
    Possible traversal types for tree relation terms.
    diff --git a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2asset__explorer_2plugin_8hpp.html b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2asset__explorer_2plugin_8hpp.html index 1cf798e2c..0d923ff1c 100644 --- a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2asset__explorer_2plugin_8hpp.html +++ b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2asset__explorer_2plugin_8hpp.html @@ -82,7 +82,7 @@

    Classes

    Functions

    - void assetExplorerPlugin(cubos::engine::Cubos& cubos) + void assetExplorerPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    diff --git a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2debug__camera_2plugin_8hpp.html b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2debug__camera_2plugin_8hpp.html index 22714540a..7e760f56d 100644 --- a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2debug__camera_2plugin_8hpp.html +++ b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2debug__camera_2plugin_8hpp.html @@ -72,7 +72,7 @@

    Namespaces

    Functions

    - void debugCameraPlugin(cubos::engine::Cubos& cubos) + void debugCameraPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    diff --git a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2entity__inspector_2plugin_8hpp.html b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2entity__inspector_2plugin_8hpp.html index 8df4b14b8..5b0d1aaa8 100644 --- a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2entity__inspector_2plugin_8hpp.html +++ b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2entity__inspector_2plugin_8hpp.html @@ -72,7 +72,7 @@

    Namespaces

    Functions

    - void entityInspectorPlugin(cubos::engine::Cubos& cubos) + void entityInspectorPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    diff --git a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2entity__selector_2plugin_8hpp.html b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2entity__selector_2plugin_8hpp.html index 21b84288e..9ca4b9cd3 100644 --- a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2entity__selector_2plugin_8hpp.html +++ b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2entity__selector_2plugin_8hpp.html @@ -82,7 +82,7 @@

    Classes

    Functions

    - void entitySelectorPlugin(cubos::engine::Cubos& cubos) + void entitySelectorPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    diff --git a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2metrics__panel_2plugin_8hpp.html b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2metrics__panel_2plugin_8hpp.html index 2c6025a95..c500335f5 100644 --- a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2metrics__panel_2plugin_8hpp.html +++ b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2metrics__panel_2plugin_8hpp.html @@ -72,7 +72,7 @@

    Namespaces

    Functions

    - void metricsPanelPlugin(cubos::engine::Cubos& cubos) + void metricsPanelPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    diff --git a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2plugin_8hpp.html b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2plugin_8hpp.html index 74cfaafba..19b5cd87a 100644 --- a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2plugin_8hpp.html +++ b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2plugin_8hpp.html @@ -72,7 +72,7 @@

    Namespaces

    Functions

    - void plugin(cubos::engine::Cubos& cubos) + void plugin(cubos::engine::Cubos& cubos)
    Tesseratos entry function.
    diff --git a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2scene__editor_2plugin_8hpp.html b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2scene__editor_2plugin_8hpp.html index 7ece824e3..bb641eefc 100644 --- a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2scene__editor_2plugin_8hpp.html +++ b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2scene__editor_2plugin_8hpp.html @@ -72,7 +72,7 @@

    Namespaces

    Functions

    - void sceneEditorPlugin(cubos::engine::Cubos& cubos) + void sceneEditorPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    diff --git a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2settings__inspector_2plugin_8hpp.html b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2settings__inspector_2plugin_8hpp.html index 51e8f3805..01171d965 100644 --- a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2settings__inspector_2plugin_8hpp.html +++ b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2settings__inspector_2plugin_8hpp.html @@ -72,7 +72,7 @@

    Namespaces

    Functions

    - void settingsInspectorPlugin(cubos::engine::Cubos& cubos) + void settingsInspectorPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    diff --git a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2toolbox_2plugin_8hpp.html b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2toolbox_2plugin_8hpp.html index 7c35947ba..49d404f8a 100644 --- a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2toolbox_2plugin_8hpp.html +++ b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2toolbox_2plugin_8hpp.html @@ -82,7 +82,7 @@

    Classes

    Functions

    - void toolboxPlugin(cubos::engine::Cubos& cubos) + void toolboxPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    diff --git a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2transform__gizmo_2plugin_8hpp.html b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2transform__gizmo_2plugin_8hpp.html index b71814126..29e6914f4 100644 --- a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2transform__gizmo_2plugin_8hpp.html +++ b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2transform__gizmo_2plugin_8hpp.html @@ -72,7 +72,7 @@

    Namespaces

    Functions

    - void transformGizmoPlugin(cubos::engine::Cubos& cubos) + void transformGizmoPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    diff --git a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2voxel__palette__editor_2plugin_8hpp.html b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2voxel__palette__editor_2plugin_8hpp.html index d9dd821e7..02321de3a 100644 --- a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2voxel__palette__editor_2plugin_8hpp.html +++ b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2voxel__palette__editor_2plugin_8hpp.html @@ -72,7 +72,7 @@

    Namespaces

    Functions

    - void voxelPaletteEditorPlugin(cubos::engine::Cubos& cubos) + void voxelPaletteEditorPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    diff --git a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2world__inspector_2plugin_8hpp.html b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2world__inspector_2plugin_8hpp.html index 4166b4b27..9c699d89d 100644 --- a/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2world__inspector_2plugin_8hpp.html +++ b/docs-preview/pr-880/tools_2tesseratos_2include_2tesseratos_2world__inspector_2plugin_8hpp.html @@ -72,7 +72,7 @@

    Namespaces

    Functions

    - void worldInspectorPlugin(cubos::engine::Cubos& cubos) + void worldInspectorPlugin(cubos::engine::Cubos& cubos)
    Plugin entry function.
    diff --git a/docs-preview/pr-880/writer_8hpp.html b/docs-preview/pr-880/writer_8hpp.html index 79418f988..c899d3a82 100644 --- a/docs-preview/pr-880/writer_8hpp.html +++ b/docs-preview/pr-880/writer_8hpp.html @@ -2,7 +2,7 @@ - core/ecs/system/event/writer.hpp file | CUBOS. Docs + core/ecs/system/arguments/event/writer.hpp file | CUBOS. Docs @@ -46,7 +46,7 @@

    - core/ecs/system/event/writer.hpp file + core/ecs/system/arguments/event/writer.hpp file

    Class cubos::core::ecs::EventWriter.