API Reference

Contents

API Reference#

namespace Hush#

Typedefs

template<typename T, typename E>
using Result = outcome_v2::unchecked<T, E>#

Enums

enum class EFileOpenMode#

Values:

enumerator Read#
enumerator Write#
enumerator ReadWrite#
enum class ECursorLockMode#

Values:

enumerator Free#
enumerator Locked#
enum class ELogLevel : uint32_t#

Log level.

Values:

enumerator Trace#
enumerator Debug#
enumerator Info#
enumerator Warn#
enumerator Error#
enumerator Critical#
enum class EAlphaBlendMode : uint32_t#

Values:

enumerator None#
enumerator OneMinusSrcAlpha#
enumerator OneMinusDestAlpha#
enumerator ConstAlpha#
enumerator DestAlpha#
enumerator SrcAlpha#
enum class ECullMode : uint32_t#

Values:

enumerator None#
enumerator Front#
enumerator Back#
enumerator FrontAndBack#
enum class EMaterialPass : uint8_t#

Values:

enumerator MainColor#
enumerator Transparent#
enumerator Mask#
enumerator Other#
enum class EPbrOptions : int32_t#

Values:

enumerator None#
enumerator UseNormalTexture#
enumerator DebugNormals#
enum class EPlatform : uint8_t#

Enum representing the current platform.

Values:

enumerator Win64#
enumerator Linux#
enumerator OSX#

Functions

std::unique_ptr<IApplication> LoadApplication(HushEngine *engine)#

Loads an application. The method to load an application depends on each platform and if shared library loading is enabled.

If HUSH_STATIC_APP definition is set to true, Hush won’t try to load an application hosted in a shared library. This only applies on platforms that support shared libraries.

If a static application is bundled with the engine, it won’t attempt to load a shared library.

Returns:

A pointer to the loaded application.

void Serialize(Transform *component)#
void Log(ELogLevel logLevel, std::string_view message)#

Logs a message.

Parameters:
  • logLevel – level to log the message

  • message – message to log

template<class ...Args>
void LogFormat(ELogLevel logLevel, fmt::format_string<Args...> format, Args&&... args)#

Logs a message with a given format.

inline void LogTrace(std::string_view message)#

Logs a trace message.

Parameters:

message – message to log

inline void LogDebug(std::string_view message)#

Logs a debug message.

Parameters:

message – message to log

inline void LogInfo(std::string_view message)#

Logs an info message.

Parameters:

message – message to log

inline void LogWarn(std::string_view message)#

Logs a warning message.

Parameters:

message – message to log

inline void LogError(std::string_view message)#

Logs an error message.

Parameters:

message – message to log

inline void LogCritical(std::string_view message)#

Logs a critical message.

Parameters:

message – message to log

inline void ClearLogs()#
void Serialize(DirectionalLight *component)#
void Serialize(IMaterial3D *component, const char *uniqueName)#
void Serialize(Mesh *component, const char *entityName)#
template<BitMaskEnum Enum>
constexpr bool HasFlag(Enum value, Enum flag)#

Check if an enum value has a flag.

Template Parameters:

Enum – Enum type.

Parameters:
  • value – Value to check.

  • flag – Flag to check.

Returns:

True if the value has the flag, false otherwise.

template<BitMaskEnum Enum>
constexpr bool HasAnyFlag(Enum value, Enum flag)#

Check if an enum value has any of the flags.

Template Parameters:

Enum – Enum type.

Parameters:
  • value – Value to check.

  • flag – Flag to check.

Returns:

True if the value has any of the flags, false otherwise.

template<BitMaskEnum Enum>
constexpr bool HasAllFlags(Enum value, Enum flags)#

Check if an enum value has all the flags.

Template Parameters:

Enum – Enum type.

Parameters:
  • value – Value to check.

  • flags – Flags to check.

Returns:

True if the value has all the flags, false otherwise.

inline constexpr EPlatform GetCurrentPlatform()#

Get the current platform.

Returns:

EPlatform

inline auto Success()#

Variables

template<typename Enum>
constexpr bool HAS_BIT_MASK_OPERATORS = EnableBitMaskOperators<Enum>::value#

Helper variable template to check if an enum has bit mask operators.

Template Parameters:

Enum – Enum type to check if it has bit mask operators.

class Camera#

Subclassed by Hush::EditorCamera

Public Functions

Camera() = default#
Camera(const Camera&) = default#
Camera(Camera&&) = delete#
Camera &operator=(const Camera&) = default#
Camera &operator=(Camera&&) = delete#
Camera(const glm::mat4 &projectionMat, const glm::mat4 &unreversedProjectionMat) noexcept#
Camera(float degFov, float width, float height, float nearP, float farP) noexcept#
virtual ~Camera() = default#
inline glm::mat4 GetProjectionMatrix() const noexcept#
const glm::mat4 &GetUnreversedProjectionMatrix() const noexcept#
void SetProjectionMatrix(glm::mat4 projection, glm::mat4 unReversedProjection)#
void SetPerspectiveProjectionMatrix(const float radFov, const float width, const float height, const float nearP, const float farP)#
float GetFarPlane() const noexcept#
class CFile : public Hush::IFile#

Public Functions

inline CFile(FILE *file, FileMetadata &&fileMetadata)#
~CFile() override#
virtual Result<std::size_t> Read(std::span<std::byte> data) override#

Reads the file.

Parameters:

data – Span to the buffer to read the data into.

Returns:

Result with the number of bytes read.

virtual Result<std::span<std::byte>> Read(std::size_t size) override#

Specialized read function that reads a specific amount of bytes. This is used when reading mmaped files. This might not be supported by all implementations.

Parameters:

size – Size to read.

Returns:

Result with the data read.

virtual Result<void> Write(std::span<const std::byte> data) override#

Writes the file.

Parameters:

data – Data to write to the file.

Returns:

Result with the error that occurred.

virtual Result<void> Seek(std::size_t position) override#

Seeks to a specific position in the file.

Parameters:

position – Position to seek to.

Returns:

Result with the error that occurred.

virtual void Close() override#

Closes the file.

inline virtual const FileMetadata &GetMetadata() const override#
class CFileSystem : public Hush::IFileSystem#
#include <CFileSystem.hpp>

Loads data using C APIs. This, however, is not efficient as it loads the whole file into memory. For more complex scenarios, look at memory mapped sources.

Public Functions

CFileSystem(std::string_view root)#
CFileSystem(const CFileSystem&) = delete#
inline CFileSystem(CFileSystem &&rhs) noexcept#
CFileSystem &operator=(const CFileSystem&) = delete#
inline CFileSystem &operator=(CFileSystem &&rhs) noexcept#
~CFileSystem() override = default#
virtual Result<std::unique_ptr<IFile>, IFile::EError> OpenFile(std::filesystem::path vfsPath, std::filesystem::path path, EFileOpenMode mode) override#

Opens a file from a specific path.

Parameters:
  • path – Path of the file to open

  • mode – Mode to open the file

Returns:

A result with a pointer to the file.

class Color#

Public Types

enum class EFormat : uint32_t#

Values:

enumerator Unknown#
enumerator R8Unorm#
enumerator RG8Unorm#
enumerator RGB8Unorm#
enumerator RGBA8Unorm#
enumerator R16Float#
enumerator RG16Float#
enumerator RGB16Float#
enumerator RGBA16Float#
enumerator R32Float#
enumerator RG32Float#
enumerator RGB32Float#
enumerator RGBA32Float#
enumerator D32Float#
enumerator D24S8Unorm#

Public Functions

Color() = default#
inline constexpr Color(float red, float green, float blue, float alpha)#
inline constexpr Color(float red, float green, float blue)#
inline constexpr Color(glm::vec3 rgb)#
inline constexpr Color(glm::vec4 rgba)#
inline constexpr const glm::vec4 &GetRGBA32F() const#
inline glm::vec4 &GetRGBA32F()#
inline constexpr uint32_t ToColor32() const#

Public Static Functions

static inline constexpr Color White()#
static inline constexpr Color Black()#
static inline constexpr Color Magenta()#
static inline constexpr Color Transparent()#
class CommandPanel : public Hush::IEditorPanel#

Public Types

enum class EState#

Values:

enumerator None#
enumerator Editing#
enumerator ForceFocus#
enumerator SearchMode#
enumerator AddComponentMode#
enumerator IsPopupMode#

Public Functions

virtual void Init(Scene *activeScene) noexcept override#
virtual void OnRender() override#
class CommandSystem : public Hush::ISystem#

Public Functions

inline CommandSystem(Scene &scene)#
virtual void Init() override#

Init() is called when the system is initialized.

virtual void OnShutdown() override#

OnShutdown() is called when the system is shutting down.

virtual void OnUpdate(float delta) override#

OnRender() is called when the system should render.

Parameters:

delta – Time since last frame

virtual void OnFixedUpdate(float delta) override#

OnFixedUpdate() is called when the system should update its state.

Parameters:

delta – Time since last fixed frame

virtual void OnRender() override#

OnRender() is called when the system should render.

virtual void OnPreRender() override#

OnPreRender() is called before rendering.

virtual void OnPostRender() override#

OnPostRender() is called after rendering.

inline virtual std::string_view GetName() const override#

GetName() is used to get the name of the system

Returns:

Name of the system

class ContentPanel : public Hush::IEditorPanel#
class DebugTooltip : public Hush::IEditorPanel#

Public Functions

virtual void OnRender() noexcept override#
inline virtual void Init(Scene *activeScene) noexcept override#
const glm::vec3 &GetScale() const#
const glm::vec3 &GetRotation() const#
const glm::vec3 &GetTranslation() const#

Public Static Attributes

static DebugTooltip *s_debugTooltip = nullptr#
class DebugUI : public Hush::IEditorPanel#

Public Functions

inline DebugUI()#
inline ~DebugUI()#
inline virtual void Init(Scene *activeScene) noexcept override#
inline virtual void OnRender() override#

Public Static Functions

static inline bool MouseInfoEnabled()#
static inline bool KeyboardInfoEnabled()#
class DefaultImageProvider#

Public Functions

void CreateDefaultImages(IRenderer *renderer)#
inline const GpuAllocatedImage &GetWhiteImage() const#
inline const GpuAllocatedImage &GetBlackImage() const#
inline const GpuAllocatedImage &GetNormalImage() const#
inline const GpuAllocatedImage &GetTransparentImage() const#
struct DescriptorAllocator#

Public Functions

void InitPool(VkDevice device, uint32_t maxSets, const std::vector<PoolSizeRatio> &poolRatios) noexcept#
void ClearDescriptors(VkDevice device) const#
void DestroyPool(VkDevice device) const#
VkDescriptorSet Allocate(VkDevice device, VkDescriptorSetLayout layout) const#

Public Members

VkDescriptorPool pool = {}#
struct PoolSizeRatio#

Public Members

VkDescriptorType type#
float ratio#
struct DescriptorAllocatorGrowable#

Public Functions

void Init(VkDevice device, uint32_t initialSets, const std::vector<PoolSizeRatio> &poolRatios)#
void ClearPool(VkDevice device)#
void DestroyPool(VkDevice device)#
VkDescriptorSet Allocate(VkDevice device, VkDescriptorSetLayout layout, void *pNext = nullptr)#
struct PoolSizeRatio#

Public Members

VkDescriptorType type#
float ratio#
struct DescriptorLayoutBuilder#

Public Functions

void AddBinding(uint32_t binding, VkDescriptorType type, uint32_t stageFlags = 0)#
void Clear()#
VkDescriptorSetLayout Build(VkDevice device, VkShaderStageFlags shaderStages, void *pNext = nullptr, VkDescriptorSetLayoutCreateFlags flags = 0)#

Public Members

std::vector<VkDescriptorSetLayoutBinding> bindings#
struct DescriptorWriter#

Public Functions

void WriteImage(int32_t binding, VkImageView image, VkSampler sampler, VkImageLayout layout, VkDescriptorType type)#
void WriteBuffer(int32_t binding, VkBuffer buffer, size_t size, size_t offset, VkDescriptorType type)#
void Clear()#
void UpdateSet(VkDevice device, VkDescriptorSet set)#

Public Members

std::deque<VkDescriptorImageInfo> imageInfos#
std::deque<VkDescriptorBufferInfo> bufferInfos#
std::vector<VkWriteDescriptorSet> writes#
struct DirectionalLight#

Public Members

float intensity = 1.0F#
Color color = Vector4Math::ONE#
class DotnetHost#
#include <DotnetHost.hpp>

hold references to all .NET function pointers with a valid initialization, to pass onto ScriptingManager

Public Functions

DotnetHost(const char *dotnetPath)#

Creates a new .NET host using hostfxr with the provided path of the runtime.

DotnetHost(const DotnetHost &other) = default#
DotnetHost(DotnetHost &&other) = default#
DotnetHost &operator=(const DotnetHost&) = default#
DotnetHost &operator=(DotnetHost&&) = default#
~DotnetHost()#
get_function_pointer_fn GetFunctionGetterFuncPtr()#
struct DrawContext#

Public Members

std::vector<VkRenderObject> opaqueSurfaces#
std::vector<VkRenderObject> transparentSurfaces#
class EditorCamera : public Hush::Camera#

Public Functions

EditorCamera() = default#
EditorCamera(float degFov, float width, float height, float nearP, float farP)#
glm::mat4 GetViewMatrix() const noexcept#
glm::mat4 GetOrientationMatrix() const noexcept#
const glm::vec3 &GetPosition() const noexcept#
glm::vec3 &GetPosition() noexcept#
float &GetPitch() noexcept#
float &GetYaw() noexcept#
class EditorCameraSystem : public Hush::ISystem#

Public Functions

EditorCameraSystem(const EditorCameraSystem&) = delete#
EditorCameraSystem(EditorCameraSystem&&) = delete#
EditorCameraSystem &operator=(const EditorCameraSystem&) = delete#
EditorCameraSystem &operator=(EditorCameraSystem&&) = delete#
~EditorCameraSystem() override = default#
virtual void Init() override#

Init() is called when the system is initialized.

virtual void OnShutdown() override#

OnShutdown() is called when the system is shutting down.

virtual void OnUpdate(float delta) override#

OnRender() is called when the system should render.

Parameters:

delta – Time since last frame

virtual void OnFixedUpdate(float delta) override#

OnFixedUpdate() is called when the system should update its state.

Parameters:

delta – Time since last fixed frame

virtual void OnRender() override#

OnRender() is called when the system should render.

virtual void OnPreRender() override#

OnPreRender() is called before rendering.

virtual void OnPostRender() override#

OnPostRender() is called after rendering.

virtual std::string_view GetName() const override#

GetName() is used to get the name of the system

Returns:

Name of the system

inline ISystem(Scene &scene)#
ISystem(const ISystem&) = delete#
ISystem(ISystem&&) noexcept = default#
template<typename Enum>
struct EnableBitMaskOperators : public std::false_type#
#include <EnumFlags.hpp>

Trait to enable bit mask operators for an enum. To implement this trait, specialize the EnableBitMaskOperators struct for the enum. There’s a helper macro to do this in the EnumFlags.hpp file. Use HUSH_ENABLE_BITMASK_OPERATORS(Enum) However, we recommend implementing it manually to avoid macros.

template<>
struct EnableBitMaskOperators<ComponentTraits::EComponentOpsFlags> : public std::true_type#
class Entity#
#include <Entity.hpp>

Describes an entity in the scene. An entity is something that exists in the scene. It can have components attached to it. Entities are not meant to be created directly, but through the scene.

Creating components requires the component to be registered in the scene. This is done automatically when any of the component functions are called. If the component is not registered, it will be registered in the scene.

For scripting, this class exposes *ComponentRaw functions that are used to interact with components using raw component ids. These functions are not meant to be used directly, and, while you can, they’re inconvenient. The *Component functions are the ones that should be used.

Public Types

using EntityId = std::uint64_t#

Public Functions

inline explicit Entity(Scene *ownerScene, std::uint64_t entityId)#
~Entity() noexcept = default#

Entity destructor. It does not destroy the entity. For that, use Scene::DestroyEntity.

Entity(const Entity&) = delete#
Entity &operator=(const Entity&) = delete#
inline Entity(Entity &&other) noexcept#
inline Entity &operator=(Entity &&other) noexcept#
template<typename T>
inline bool HasComponent()#

Checks if the entity has a component of the given type.

Template Parameters:

T – Type of the component.

Returns:

True if the entity has the component, false otherwise.

template<typename T>
inline std::remove_cvref_t<T> &AddComponent()#

Add a component to the entity. If the component is already added, it will return a reference to the existing component.

Template Parameters:

T – Type of the component.

Returns:

Reference to the added component.

template<typename T, typename ...Args>
inline std::remove_cvref_t<T> &EmplaceComponent(Args&&... args)#

Emplace a component to the entity. If the component is already added, it will return a reference to the existing component.

Template Parameters:
  • T – Type of the component.

  • Args – Arguments to pass to the constructor of the component.

Parameters:

args – Arguments to pass to the constructor of the component.

Returns:

Reference to the added component.

template<typename T>
inline std::remove_cvref_t<T> *GetComponent()#

Get a component from the entity.

Template Parameters:

T – Type of the component.

Returns:

Pointer to the component, or nullptr if the component is not found.

template<typename T>
inline const std::remove_cvref_t<T> *GetComponent() const#

Get a component from the entity.

Template Parameters:

T – Type of the component.

Returns:

Pointer to the component, or nullptr if the component is not found.

template<typename T>
inline bool RemoveComponent()#

Remove a component from the entity.

Template Parameters:

T – Type of the component.

Returns:

True if the component was removed, false otherwise.

template<typename T>
inline void RegisterComponent() const#

Register a component to the entity.

Template Parameters:

T – Type to register.

EntityId RegisterComponentRaw(const ComponentTraits::ComponentInfo &desc) const#

Register a component.

Parameters:

desc – Component description.

Returns:

Id of the component.

void *AddComponentRaw(EntityId componentId)#

Add a component to the entity.

Parameters:

componentId – Id of the component.

Returns:

Pointer to the component.

void *GetComponentRaw(EntityId componentId)#

Get a component from the entity.

Parameters:

componentId – Id of the component.

Returns:

Pointer to the component.

void *GetComponentRaw(EntityId componentId) const#

Get a component from the entity.

Parameters:

componentId – Id of the component.

Returns:

Pointer to the component.

bool HasComponentRaw(EntityId componentId)#

Check if the entity has a component.

Parameters:

componentId – Id of the component.

Returns:

True if the entity has the component, false otherwise.

void *EmplaceComponentRaw(EntityId componentId, bool &isNew)#

Emplace a component to the entity. If the component is already added, it will return a reference to the existing component. If the component is new, the user is in charge of constructing it. Not constructing it is undefined behavior.

Parameters:
  • componentId – Id of the component.

  • isNew – Flag to indicate if the component is new. If it is new, user is in charge of constructing it.

Returns:

Pointer to the component.

bool RemoveComponentRaw(EntityId componentId)#

Remove a component from the entity.

Parameters:

componentId – Id of the component.

Returns:

True if the component was removed, false otherwise.

EntityId GetId() const#
std::optional<std::string_view> GetName() const#

Get the name of the entity.

Returns:

Name of the entity.

Public Static Functions

static void Destroy(Entity &&entity)#

Destroy an entity. This will remove all components from the entity and destroy it. This consumes the entity, so it should not be used after this function is called.

Parameters:

entityEntity to destroy.

struct FileMetadata#
#include <IFile.hpp>

Metadata for a file.

Public Members

std::filesystem::path path#
std::size_t size#
std::uint64_t lastModified#
EFileOpenMode mode#
struct FrameData#
#include <FrameData.hpp>

Definition of the frame data structure to pass in Vulkan’s dynamic rendering from VKGuide (https://vkguide.dev/docs/new_chapter_1/vulkan_mainloop_code/)

Public Members

VkSemaphore swapchainSemaphore#

Used for making the render commands wait for the swapchain image.

VkSemaphore renderSemaphore#

Controls presenting the image to the OS once drawing is finished.

VkFence renderFence#

Lets us wait for the draw commands of a given frame to be finished.

VkCommandBuffer mainCommandBuffer#
VkCommandPool commandPool#
VulkanDeletionQueue deletionQueue#
DescriptorAllocatorGrowable frameDescriptors#
struct GeoSurface#

Public Members

uint32_t startIndex#
uint32_t count#
std::shared_ptr<IMaterial3D> material#
class GLTFMetallicRoughness : public Hush::IMaterial3D#

Public Functions

HUSH_STATIC_ASSERT (sizeof(MaterialConstants) % 16==0, "Metallic Roughness size mismatch!")
GLTFMetallicRoughness() = default#
void Init(IRenderer *renderer)#
void ClearResources(VkDevice device)#
virtual EAlphaBlendMode GetAlphaBlendMode() const noexcept override#
virtual void SetAlphaBlendMode(EAlphaBlendMode blendMode) noexcept override#
virtual EMaterialPass GetMaterialPass() const noexcept override#
virtual void SetMaterialPass(EMaterialPass pass) override#
virtual ECullMode GetCullMode() const noexcept override#
virtual void SetCullMode(ECullMode cullMode) override#
void GenerateMaterialInstance(DescriptorAllocatorGrowable *descriptorAllocator)#
const glm::vec4 &GetAlbedo() const noexcept#
glm::vec4 &GetAlbedo() noexcept#
void SetAlbedo(const glm::vec4 &color) noexcept#
const glm::vec3 &GetEmissionColor() const noexcept#
glm::vec3 &GetEmissionColor() noexcept#
void SetEmissionColor(const glm::vec3 &color) noexcept#
const float &EmissionFactor() const noexcept#
void SetEmissionFactor(float emissionFactor) noexcept#
const float &GetMetallicFactor() const noexcept#
void SetMetallicFactor(float factor) noexcept#
const float &GetRoughnessFactor() const noexcept#
void SetRoughnessFactor(float factor) noexcept#
const float &GetAlphaThreshold() const noexcept#
void SetAlphaThreshold(float alphaThreshold) noexcept#
virtual GraphicsApiMaterialInstance *GetInternalMaterial() override#
MaterialResources &GetMaterialResources()#
MaterialConstants &GetMaterialConstants() noexcept#
void SetMaterialConstants(const MaterialConstants &values)#
inline EPbrOptions GetPbrOptions() const#
inline void SetPbrOptions(EPbrOptions options)#
inline virtual void SetName(const std::string_view &name) override#
inline virtual const std::string &GetName() const noexcept override#

Public Members

DescriptorWriter writer#
struct MaterialConstants#

Public Members

glm::vec4 colorFactors#
glm::vec4 metalRoughFactors#
glm::vec4 emissionFactors#
float alphaThreshold#
int32_t options = 0#
char padding[8]#
struct MaterialResources#

Public Members

GpuAllocatedImage colorImage#
VkSampler colorSampler#
GpuAllocatedImage metalRoughImage#
VkSampler metalRoughSampler#
GpuAllocatedImage normalImage#
VkSampler normalSampler#
GpuAllocatedImage emissiveImage#
VkSampler emissiveSampler#
GpuAllocatedBuffer gpuDataBuffer#
uint32_t dataBufferOffset#
class GpuAllocatedBuffer#

Public Types

enum class EBufferUsage : uint32_t#

Values:

enumerator None#
enumerator VertexBuffer#
enumerator IndexBuffer#
enumerator UniformBuffer#
enumerator TransferSrc#
enumerator TransferDst#
enumerator StorageBuffer#
enumerator ShaderDeviceAddress#
enum class EMemoryUsage : uint32_t#

Values:

enumerator GpuOnly#
enumerator CpuOnly#
enumerator CpuToGpu#
enumerator GpuToCpu#

Public Functions

GpuAllocatedBuffer() = default#
GpuAllocatedBuffer(size_t size, EBufferUsage usage, EMemoryUsage memoryUsage, void *allocator)#
void Dispose(void *allocator)#
size_t GetSize() const noexcept#
const OpaqueAllocationData *GetAllocationData()#
void *GetBuffer()#
void *GetMappedData()#
struct GpuAllocatedImage#

Public Members

ImageExtent3D imageExtent#
struct GPUMeshBuffers#

Public Functions

GPUMeshBuffers() = default#

Public Members

GpuAllocatedBuffer indexBuffer#
GpuAllocatedBuffer vertexBuffer#
struct GraphicsApiMaterialInstance#

Public Members

EMaterialPass passType#
class HierarchyPanel : public Hush::IEditorPanel#

Public Functions

virtual void Init(Scene *activeScene) noexcept override#
virtual void OnRender() override#
class HushEngine#

Public Functions

HushEngine()#

Initializes the HushEngine with all its properties.

HushEngine(const HushEngine&) = delete#
HushEngine &operator=(const HushEngine&) = delete#
HushEngine(HushEngine&&) noexcept = default#
HushEngine &operator=(HushEngine&&) noexcept = default#
void AddSystem(ISystem *system)#

Intended to be used for engine systems, user-defined systems should be added using Hush::Scene::AddSystem()

~HushEngine()#
void Run()#

Starts running the engine with UI components.

void Quit()#

Disposes of the HushEngine.

Scene *GetScene()#
inline Threading::Executors::ThreadPool *GetEngineThreadPool() noexcept#

Returns the engine’s default thread pool. The default threadpool contains a number of threads equal to the number of hardware threads available on the system, and each thread is pinned to a core.

Returns:

A pointer to the engine’s thread pool.

class IApplication#

Subclassed by EditorApp

Public Functions

IApplication() = default#
IApplication(const IApplication&) = delete#
IApplication(IApplication&&) = delete#
IApplication &operator=(const IApplication&) = default#
IApplication &operator=(IApplication&&) = default#
virtual ~IApplication() = default#
virtual void Init() = 0#
virtual void Update(float delta) = 0#
virtual void FixedUpdate(float delta) = 0#
virtual void OnPreRender() = 0#
virtual void OnRender() = 0#
virtual void OnPostRender() = 0#
virtual Hush::Scene *GetScene() = 0#
virtual std::string_view GetAppName() const noexcept = 0#
class IEditorPanel#

Subclassed by Hush::CommandPanel, Hush::ContentPanel, Hush::DebugTooltip, Hush::DebugUI, Hush::HierarchyPanel, Hush::InspectorPanel, Hush::ScenePanel, Hush::StatsPanel, Hush::TitleBarMenuPanel

Public Functions

IEditorPanel() noexcept = default#
IEditorPanel(const IEditorPanel &other) = default#
IEditorPanel(IEditorPanel &&other) = default#
IEditorPanel &operator=(const IEditorPanel&) = default#
IEditorPanel &operator=(IEditorPanel&&) = default#
virtual ~IEditorPanel() = default#
virtual void OnRender() = 0#
virtual void Init(Scene *activeScene) noexcept = 0#
class IEditorSerializable#

Public Functions

virtual void Serialize()#
class IFile#
#include <IFile.hpp>

File interface for the VFS. A file is a resource that maps to a specific path in the VFS. Files support reading, writing, and reading metadata. Not all the VFS implementations will support all the operations, and, in those cases, the implementation will return a “OperationNotSupported” error. TODO: async interfaces.

Subclassed by Hush::CFile

Public Types

enum class EError#

Errors that can occur when reading or writing a file.

Values:

enumerator None#
enumerator FileDoesntExist#
enumerator OperationNotSupported#
enumerator NotWritable#
enumerator NotReadable#
enumerator CannotRead#
enumerator CannotWrite#
enumerator PathDoesntExist#
template<typename T>
using Result = Hush::Result<T, EError>#

Public Functions

IFile() = default#
virtual ~IFile() = default#
virtual const FileMetadata &GetMetadata() const = 0#
virtual Result<void> Write(std::span<const std::byte> data) = 0#

Writes the file.

Parameters:

data – Data to write to the file.

Returns:

Result with the error that occurred.

virtual Result<std::size_t> Read(std::span<std::byte> data) = 0#

Reads the file.

Parameters:

data – Span to the buffer to read the data into.

Returns:

Result with the number of bytes read.

virtual Result<std::span<std::byte>> Read(std::size_t size) = 0#

Specialized read function that reads a specific amount of bytes. This is used when reading mmaped files. This might not be supported by all implementations.

Parameters:

size – Size to read.

Returns:

Result with the data read.

virtual Result<void> Seek(std::size_t position) = 0#

Seeks to a specific position in the file.

Parameters:

position – Position to seek to.

Returns:

Result with the error that occurred.

virtual void Close() = 0#

Closes the file.

class IFileSystem#
#include <FileSystem.hpp>

A resource loader is an interface meant to be implemented by classes that load things from a specific source (i.e. a ZIP file). This means that they must implement a way to load resources from an underlying sources, both in an async and a sync way. Some resource sources do not support a Resource sources must live until all of their children are deleted.

Subclassed by Hush::CFileSystem

Public Types

enum class EError#

Errors when loading data.

Values:

enumerator None#
enumerator PathDoesntExist#
enumerator NotSupported#
enumerator CannotRead#
using AsyncCallback = std::function<void(Result<std::span<std::byte>, EError>)>#

Callback to be called when data is loaded. Raw data is owned by the Resource Source, not by the caller.

Public Functions

IFileSystem() = default#
IFileSystem(const IFileSystem&) = delete#
IFileSystem(IFileSystem&&) = default#
IFileSystem &operator=(const IFileSystem&) = delete#
IFileSystem &operator=(IFileSystem&&) = default#
virtual ~IFileSystem() = default#
virtual Result<std::unique_ptr<IFile>, IFile::EError> OpenFile(std::filesystem::path vfsPath, std::filesystem::path path, EFileOpenMode mode = EFileOpenMode::Read) = 0#

Opens a file from a specific path.

Parameters:
  • path – Path of the file to open

  • mode – Mode to open the file

Returns:

A result with a pointer to the file.

class IImGuiForwarder#

Subclassed by Hush::VulkanImGuiForwarder

Public Functions

IImGuiForwarder() = default#
virtual ~IImGuiForwarder() = default#
IImGuiForwarder(const IImGuiForwarder&) = default#
IImGuiForwarder(IImGuiForwarder&&) = default#
IImGuiForwarder &operator=(const IImGuiForwarder&) = default#
IImGuiForwarder &operator=(IImGuiForwarder&&) = default#
virtual void SetupImGui(IRenderer *renderer) = 0#
virtual void NewFrame() = 0#
virtual void EndFrame() = 0#
virtual void HandleEvent(const SDL_Event*) noexcept = 0#
virtual void Dispose() noexcept = 0#
struct ImageExtent3D#

Public Functions

constexpr ImageExtent3D() = default#
inline constexpr ImageExtent3D(uint32_t width, uint32_t height, uint32_t depth)#
inline constexpr ImageExtent3D(uint32_t scalar)#

Public Members

uint32_t width = 0#
uint32_t height = 0#
uint32_t depth = 0#
class ImageTexture#

Public Functions

ImageTexture() = default#
ImageTexture(const std::filesystem::path &filePath)#
ImageTexture(const std::byte *data, size_t size)#
const int32_t &GetWidth() const noexcept#
const int32_t &GetHeight() const noexcept#
const std::byte *GetImageData() const#
class IMaterial3D#

Subclassed by Hush::GLTFMetallicRoughness, Hush::ShaderMaterial

Public Functions

virtual EAlphaBlendMode GetAlphaBlendMode() const noexcept = 0#
virtual void SetAlphaBlendMode(EAlphaBlendMode blendMode) noexcept = 0#
virtual ECullMode GetCullMode() const noexcept = 0#
virtual void SetCullMode(ECullMode cullMode) = 0#
virtual EMaterialPass GetMaterialPass() const noexcept = 0#
virtual void SetMaterialPass(EMaterialPass pass) = 0#
virtual GraphicsApiMaterialInstance *GetInternalMaterial() = 0#
virtual void SetName(const std::string_view &name) = 0#
virtual const std::string &GetName() const noexcept = 0#
class InputManager#

Public Static Functions

static bool IsKeyDown(EKeyCode key)#

Evaluates to true whilst the key is pressed down.

static bool IsKeyDownThisFrame(EKeyCode key)#

Evaluates to true the frame the key is identified as EKeyState::Pressed.

static bool IsKeyUp(EKeyCode key)#

Evaluates to true the frame the key is identified as EKeyState::Release.

static bool IsKeyHeld(EKeyCode key)#

Evaluates to true as long as the key is identified asEKeyState::Held.

static bool GetMouseButtonPressed(EMouseButton button)#

Evaluates to true for as long as the mouse button is pressed.

static bool FetchCharThisFrame(char *outChar)#
static glm::vec2 GetMousePosition()#

Gets the vector of the mouse’s position in pixels.

static glm::vec2 GetMouseAcceleration()#

Gets the vector of the mouse’s acceleration in pixels/s^2.

static const glm::vec2 &GetMouseScrollAcceleration()#
static void SendKeyEvent(KeyCode key, EKeyState state)#
static void SendMouseButtonEvent(MouseButton mouseButton, EKeyState state)#
static void SendMouseMovementEvent(int32_t posX, int32_t posY, int32_t accelerationX, int32_t accelerationY)#
static void SendWheelEvent(float posX, float posY)#
static void ResetMouseAcceleration()#
static void ResetCharData()#
static void SendCharEvent(char pressedChar)#
static void SetCursorLock(ECursorLockMode lockMode)#
class InspectorPanel : public Hush::IEditorPanel#

Public Functions

virtual void OnRender() override#
virtual void Init(Scene *activeScene) noexcept override#
void SetInspectTarget(Entity::EntityId entity)#
const std::optional<Entity> &GetInspectTarget() const#
std::optional<Entity> &GetInspectTarget()#
class IRenderer#
#include <Renderer.hpp>

A common interface for renderers, Hush supports many graphics APIs, and this is the interface that allows us to standardize all of them… All renderers MUST bind to SDL and ImGUI, the latter can be done through the IImGuiForwarder interface.

Subclassed by Hush::VulkanRenderer

Public Functions

inline IRenderer(void *windowContext)#
IRenderer(const IRenderer&) = delete#
IRenderer &operator=(const IRenderer&) = delete#
IRenderer(IRenderer&&) = delete#
IRenderer &operator=(IRenderer&&) = delete#
virtual ~IRenderer() = default#
virtual void CreateSwapChain(uint32_t width, uint32_t height) = 0#
virtual void SetActiveScene(Scene *scene) = 0#
virtual void InitImGui() = 0#
virtual void PushMesh(const glm::mat4 &globalTransform, std::shared_ptr<Mesh> mesh) = 0#
virtual void DestroyMesh(const std::string_view &name) = 0#
virtual void Draw(float delta) = 0#
virtual void UpdateSceneObjects(float delta) = 0#

Each renderer will have to implement a way of updating all the objects inside of the scene, these are instances of the IRenderableNode, which is a common interface for all renderers, but additional render data (i.e drawContext) might be needed by their underlying implementation (see VulkanMeshNode for an example)

virtual void InitRendering() = 0#

Initializes all the internal structures needed to begin rendering, call after a swapchain has been created!

virtual void NewUIFrame() const noexcept = 0#
virtual void EndUIFrame() const noexcept = 0#
virtual void HandleEvent(const SDL_Event *event) noexcept = 0#
virtual void SetDirectionalLight(DirectionalLight *light) noexcept = 0#
virtual GpuAllocatedImage CreateImage(const void *data, const ImageExtent3D &size, Color::EFormat format, uint32_t usage, bool mipmapped = false) = 0#
virtual void DestroyImage(GpuAllocatedImage *image) = 0#
virtual void AddToDeletionQueue(std::function<void()> &&deleteFunc) = 0#
virtual const DefaultImageProvider *GetDefaultImageProvider() const noexcept = 0#
virtual void *GetWindowContext() const noexcept = 0#
virtual const EditorCamera &GetEditorCamera() const noexcept = 0#
virtual EditorCamera *GetEditorCamera() noexcept = 0#
class ISystem#
#include <ISystem.hpp>

ISystem is the base interface for all systems in the engine It implements helper functions that all systems should implement.

The lifecycle of a system is as follows:

  • Constructor: Called when the system is created, could be used for some early initialization

  • Init: Called when the system is initialized, at this point all the systems are created.

  • OnUpdate: Called every frame, this is where the system should update its state.

  • OnFixedUpdate: Called every fixed frame, this is where the system should update its state. Usually helpful for physics.

  • OnShutdown: Called when the system is shutting down, could be used for some cleanup.

  • OnRender: Called when the system should render, could be used for rendering.

  • Destructor: Called when the system is destroyed, could be used for some cleanup.

Hooks are provided for all the lifecycle events, so the system can implement them as needed.

Systems provide a member function called Order that should return the order in which the system should be updated. The game engine will sort the systems based on this value. Every time a new system is added, the engine will sort the systems based on this value. The engine provides 255 order slots, so the system can return any value between 0 and 255. Systems that belong to the same order will be updated concurrently.

The systems will be bucketed BEFORE init is called, so the order of the systems should be set in the constructor.

Subclassed by Hush::CommandSystem, Hush::EditorCameraSystem, Hush::TransformationSystem

Public Functions

inline ISystem(Scene &scene)#
ISystem(const ISystem&) = delete#
ISystem &operator=(const ISystem&) = delete#
ISystem(ISystem&&) noexcept = default#
ISystem &operator=(ISystem&&) noexcept = default#
virtual ~ISystem() = default#
virtual void Init() = 0#

Init() is called when the system is initialized.

virtual void OnShutdown() = 0#

OnShutdown() is called when the system is shutting down.

virtual void OnUpdate(float delta) = 0#

OnRender() is called when the system should render.

Parameters:

delta – Time since last frame

virtual void OnFixedUpdate(float delta) = 0#

OnFixedUpdate() is called when the system should update its state.

Parameters:

delta – Time since last fixed frame

virtual void OnRender() = 0#

OnRender() is called when the system should render.

virtual void OnPreRender() = 0#

OnPreRender() is called before rendering.

virtual void OnPostRender() = 0#

OnPostRender() is called after rendering.

inline std::uint16_t Order() const#

Order() is used to get the order in which the system should be updated

Returns:

Order in which the system should be updated

virtual std::string_view GetName() const = 0#

GetName() is used to get the name of the system

Returns:

Name of the system

inline Scene &GetScene() const#

Public Static Attributes

static constexpr std::uint16_t MAX_ORDER = 255#
struct LocalTransform : public Hush::Transform#

Public Functions

inline const Entity::EntityId &GetParentId() const#
inline void SetParent(const Entity::EntityId &parent)#
inline bool HasParent() const noexcept#
Transform() = default#
Transform(const glm::vec3 &position, const glm::vec3 &scale = Vector3Math::ONE, const glm::quat &rotation = {})#
class Mesh#
#include <Mesh.hpp>

Simple CPU representation of a mesh “component”, holds index and vertex buffers, as well as the RenderingAPI specific buffer data.

Public Functions

inline std::vector<uint32_t> &GetIndexBuffer()#
inline std::vector<Vertex> &GetVertexBuffer()#
void CalculateTangentBasis()#
inline const std::vector<GeoSurface> &GetSurfaces() const#
inline void AddSurface(GeoSurface &&surface)#
inline void SetName(const std::string_view &name)#
inline const std::string &GetName() const#
inline void SetMeshBuffers(GPUMeshBuffers buffers)#
inline GPUMeshBuffers &GetMeshBuffers()#
inline const GPUMeshBuffers &GetMeshBuffers() const#
void CalculateNormals()#
struct Vertex#

Public Members

glm::vec3 position = {}#
glm::vec3 normal = Vector3Math::RIGHT#
glm::vec4 color = glm::vec4{1.f}#
glm::vec4 tangent#
glm::vec2 uv = {}#
struct MouseData#

Public Members

std::unordered_map<EMouseButton, EKeyState> mouseButtonMap = {}#
int32_t positionX = 0#
int32_t positionY = 0#
int32_t accelerationX = 0#
int32_t accelerationY = 0#
glm::vec2 wheelAcceleration = {0.0f}#
struct OpaqueMaterialData#

Public Members

VkMaterialPipeline pipeline#
VkDescriptorSetLayout descriptorLayout#
DescriptorWriter writer#
VkBufferCreateInfo uniformBufferCreateInfo#
template<typename ...Components>
class Query : public Hush::impl::QueryImpl#
#include <Query.hpp>

Query for entities. This wraps the raw query and allows getting components in a type-safe way.

It allows iterating using two methods:

  1. Accessing directly to the component arrays, to do this, use the begin and end functions. This also can be iterated using range-based for loops.

  2. Using the Each function, which allows applying a function to each entity in the query. This is a simple way of iterating over the entities.

Example using the first method:

Query<Position, Velocity> query = scene.CreateQuery<Position, Velocity>();
auto it = query.begin();
for (; it != query.end(); ++it)
{
    auto [positions, velocities] = *it;
    for (auto position : positions)
    {
        // Do something with the position
    }

    for (auto velocity : velocities)
    {
        // Do something with the velocity
    }

    // Or
    for (std::size_t i = 0; i < it.Size(); ++i)
    {
        Position& position = positions[i];
        Velocity& velocity = velocities[i];
        Hush::Entity entity = it.GetEntity(i);
    }
}

Example using the second method:

Query<Position, Velocity> query = scene.CreateQuery<Position, Velocity>();

query.Each([](Position &position, Velocity &velocity) { });
query.Each([](Entity::EntityId entityId, Position &position, Velocity &velocity) { });
query.Each([](Hush::Entity &entity, Position &position, Velocity &velocity) { });
Template Parameters:

Components – Components to query.

Public Types

using ECacheMode = RawQuery::ECacheMode#
using ComponentTuple = std::tuple<std::span<std::remove_reference_t<Components>>...>#
using ConstComponentTuple = std::tuple<std::span<std::add_const_t<std::remove_reference_t<Components>>>...>#

Public Functions

inline Query(RawQuery query) noexcept#

Constructor.

Parameters:

query – Raw query.

inline QueryIterator begin()#

Get an iterator to iterate over the entities in the query.

Returns:

Iterator to iterate over the entities in the query.

inline SentinelQueryIterator end()#

Get the sentinel iterator. This is used to check if the iterator is finished.

Returns:

SentinelQueryIterator

inline QueryIterator begin() const#

Const version of the begin function.

Returns:

Const query iterator

inline SentinelQueryIterator end() const#

Const version of the end function.

Returns:

SentinelQueryIterator

template<typename Func>
inline void Each(Func &&func)#

Apply a function to each entity in the query. This version of the function will only pass the components as arguments. Order is as the query was created.

Template Parameters:

Func – Function type.

Parameters:

func – Function to apply to each entity.

template<typename Func>
inline void Each(Func &&func)

Apply a function to each entity in the query. This version of the function also provides the entity id as the first argument.

Template Parameters:

Func – Function type.

Parameters:

func – Function to apply to each entity.

template<typename Func>
inline void Each(Func &&func)

Apply a function to each entity in the query. This version of the function will pass the entity as the first argument.

Template Parameters:

Func – Function type.

Parameters:

func – Function to apply to each entity.

struct QueryIterator#
#include <Query.hpp>

Query iterator. This allows using for-range loops to iterate over the array of components.

Public Functions

inline QueryIterator(RawQuery::QueryIterator iter)#
QueryIterator(const QueryIterator&) = delete#
QueryIterator &operator=(const QueryIterator&) = delete#
inline QueryIterator(QueryIterator &&rhs) noexcept#
inline QueryIterator &operator=(QueryIterator &&rhs) noexcept#
~QueryIterator() = default#
inline QueryIterator &operator++()#

Move to the next table.

Returns:

self

inline ComponentTuple operator*()#

Get the next table of components. For instance, for a Query<Position, Velocity>, this will return a std::tuple<std::span<Position>, std::span<Velocity>>.

Returns:

A std::tuple of spans of the components.

inline ConstComponentTuple operator*() const#

Get the next table of components. For instance, for a const Query<Position, Velocity>, this will return a std::tuple<std::span<const

Position>, std::span<const Velocity>>.

Returns:

A std::tuple of spans of the components.

inline bool operator==(const SentinelQueryIterator&) const#

Returns true if the iterator is finished.

Returns:

True if the iterator is finished, false otherwise.

inline bool operator!=(const SentinelQueryIterator&) const#

Returns true if the iterator is not finished.

Returns:

True if the iterator is not finished, false otherwise.

inline RawQuery::QueryIterator &GetRawIterator()#

Get the underlying raw iterator.

Note: Advancing the raw iterator will also advance this iterator.

Returns:

The raw iterator.

inline std::size_t Size() const#

Get the number of entities in the current table.

Returns:

The number of entities in the current table.

inline EntityId GetEntityId(std::size_t index) const#

Get the entity id at the given index. Range is [0, Size()).

Parameters:

index – Index of the entity.

Returns:

Entity id at the given index.

inline Hush::Entity GetEntity(std::size_t index) const#

Get the entity at the given index. Range is [0, Size()).

Parameters:

index – Index of the entity.

Returns:

Entity at the given index.

struct SentinelQueryIterator#
#include <Query.hpp>

This is a sentinel iterator that is used to signal the end of the query.

class RawQuery#
#include <Query.hpp>

Low-level query for entities. This allows getting raw void pointers to components. To iterate, this class provides a Hush::RawQuery::GetIterator function that returns an iterator. For more information about the iterator, see QueryIterator.

Public Types

enum class ECacheMode#

Cache mode for the query.

Values:

enumerator Default#
enumerator Auto#
enumerator All#
enumerator None#
enum class EComponentAccess#

Component access mode.

Values:

enumerator ReadOnly#
enumerator WriteOnly#
enumerator ReadWrite#
enumerator Default#

Public Functions

RawQuery() = delete#
RawQuery(const RawQuery&) = delete#
RawQuery &operator=(const RawQuery&) = delete#
RawQuery(RawQuery &&rhs) noexcept#

Move constructor.

Parameters:

rhs – Other query to move from.

RawQuery &operator=(RawQuery &&rhs) noexcept#

Move assignment operator.

Parameters:

rhs – Other query to move from.

Returns:

self

~RawQuery() noexcept#
Scene *GetScene() const noexcept#

Get the scene where the query is running.

Returns:

Scene where the query is running.

QueryIterator GetIterator()#

Get an iterator to iterate over the entities in the query.

Returns:

Iterator to iterate over the entities in the query.

Public Static Attributes

static constexpr std::uint32_t MAX_COMPONENTS = 32#
struct QueryIterator#
#include <Query.hpp>

Raw query iterator. This allows iterating over the entities in the query.

This iterator works by giving direct access to the arrays of components in the query. So, this doesn’t give an array of |Component1, Component2, …|, but instead gives n arrays of |Component1, Component1, …|, |Component2, Component2, …|, etc. Keep this in mind when using this iterator.

For end-users (not scripting), it is recommended to use the Hush::Query class instead.

Public Functions

inline QueryIterator(Scene *scene) noexcept#
QueryIterator(const QueryIterator&) = delete#
QueryIterator &operator=(const QueryIterator&) = delete#
QueryIterator(QueryIterator &&rhs) noexcept#
QueryIterator &operator=(QueryIterator &&rhs) noexcept#
~QueryIterator()#
bool Next()#

Move to the next entity.

Returns:

True if there is a next entity, false otherwise.

void Skip()#

Skip the current entity.

bool Finished() const#

Check if the iterator has been finished.

Returns:

True if the iterator has been finished. False otherwise.

std::size_t Size() const#

Gives the number of entities in the current table. This number is updated when using Next.

Returns:

The number of entities in the query.

void *GetComponentAt(std::int8_t index, std::size_t size) const#

Get an array of components at the given index. Index is given by the order of the components in the query. For instance, if the query was creating with a list of components [Position, Velocity], then Position would be at index 0 and Velocity at index 1.

The length of the array is given by Size.

Parameters:
  • index – Index of the component.

  • size – Size of the component.

Returns:

Pointer to the component.

std::uint64_t GetEntityAt(std::size_t index) const#

Get the entity id at the given index.

Parameters:

index – Index of the entity. This must be in range [0, Size()).

Returns:

Entity id at the given index.

inline Scene *GetScene() const#
class Scene#

Public Functions

Scene(HushEngine *engine, Hush::Threading::Executors::ThreadPool *threadPool)#

Constructor.

Parameters:

engine – Game engine

~Scene()#
void Init()#

Init is called when the scene is initialized.

void Update(float delta)#

Update is called every frame.

void FixedUpdate(float delta)#

FixedUpdate is called every fixed frame.

void PreRender()#

PreRender is called before rendering.

void Render()#

Render is called when the scene should render.

void PostRender()#

PostRender is called after rendering.

void Shutdown()#

Shutdown is called when the scene is shutting down.

template<typename S>
inline void AddSystem()#
Template Parameters:

S – Add a system to the scene

void RemoveSystem(std::string_view name)#

Remove a system from the scene by name.

Parameters:

name – Name of the system to remove.

Entity CreateEntity()#

Creates an entity.

Entity CreateEntityWithName(std::string_view name)#

Creates an entity with a name

Parameters:

name – Unique name of the entity

Returns:

Entity

void DestroyEntity(Entity &&entity)#

Destroy an entity.

Parameters:

entityEntity to destroy

std::optional<std::uint64_t> GetRegisteredComponentId(std::string_view name)#

Get the component registered id by name

Parameters:

name – Component name

Returns:

The component id if it exists, std::nullopt otherwise

void RegisterComponentId(std::string_view name, Entity::EntityId id)#

Register a component id

Parameters:
  • name – Name of the component

  • id – Id of the component

std::optional<Entity> EntityFromId(EntityId id)#
EntityId RegisterComponentRaw(const ComponentTraits::ComponentInfo &desc) const#
template<typename ...Components>
inline Query<Components...> CreateQuery(RawQuery::ECacheMode cacheMode = RawQuery::ECacheMode::Default)#
void AddEngineSystem(ISystem *system)#

Add an engine system to the scene

Parameters:

system – System to add

RawQuery CreateRawQuery(std::span<Entity::EntityId> components, RawQuery::ECacheMode cacheMode = RawQuery::ECacheMode::Default)#
inline const std::unordered_map<std::string, Entity::EntityId> &GetAllEntities()#

returns a map of all registered entities without a query (mostly for internal use)

Friends

friend class impl::QueryImpl
class ScenePanel : public Hush::IEditorPanel#

Public Functions

virtual void Init(Scene *activeScene) noexcept override#
virtual void OnRender() noexcept override#
class ScriptingManager#
#include <ScriptingManager.hpp>

Class for bridging with .NET using hostfxr.

Public Functions

ScriptingManager(std::shared_ptr<DotnetHost> host, std::string_view targetAssembly)#

Creates a new scripting manager to invoke C# methods.

Parameters:
  • host – The host connected to the C# runtime

  • m_targetAssembly – The desired assembly this manager is going to invoke methods from, THIS SHOULD BE CONSTANT WHEN POSSIBLE

template<class R, class ...Types>
inline R InvokeCSharpWithReturn(const char *targetNamespace, const char *targetClass, const char *fnName, Types... args)#
template<class ...Types>
inline void InvokeCSharp(const char *targetNamespace, const char *targetClass, const char *fnName, Types... args)#
struct ShaderBindings#

Public Types

enum class EBindingType#

Values:

enumerator Unknown#
enumerator PushConstant#
enumerator InputVariable#
enumerator UniformBuffer#
enumerator StorageBuffer#
enumerator Sampler#
enumerator Texture#
enumerator CombinedImageSampler#
enumerator StorageImage#
enumerator UniformTexelBuffer#
enumerator StorageTexelBuffer#
enumerator UniformBufferDynamic#
enumerator StorageBufferDynamic#
enumerator InputAttachment#
enumerator InlineUniformBlock#
enumerator AccelerationStructure#
enumerator UniformBufferMember#

Public Members

uint32_t bindingIndex = {}#
uint32_t size = {}#
uint32_t offset = {}#
uint32_t stageFlags = {}#
uint32_t setIndex = {}#
EBindingType type = EBindingType::Unknown#
class ShaderMaterial : public Hush::IMaterial3D#
#include <ShaderMaterial.hpp>

Represents a material created by a custom shader with dynamic mappings and reflections The performance impact of this class is considerable since it needs to keep track of the bindings in both RAM and GPU, as well as process the shader initially with Reflection (initialization cost) This class’s interface is Rendering API agnostic.

Public Types

enum class EError#

Values:

enumerator None#
enumerator FragmentShaderNotFound#
enumerator VertexShaderNotFound#
enumerator ReflectionError#
enumerator PipelineLayoutCreationFailed#
enumerator PropertyNotFound#
enumerator ShaderNotLoaded#

Public Functions

ShaderMaterial() = default#
~ShaderMaterial()#
EError LoadShaders(IRenderer *renderer, const std::filesystem::path &fragmentShaderPath, const std::filesystem::path &vertexShaderPath)#

Will create and bind pipelines for both shaders.

void GenerateMaterialInstance(OpaqueDescriptorAllocator *descriptorAllocator)#
OpaqueMaterialData *GetMaterialData()#
virtual EAlphaBlendMode GetAlphaBlendMode() const noexcept override#
virtual void SetAlphaBlendMode(EAlphaBlendMode blendMode) noexcept override#
virtual ECullMode GetCullMode() const noexcept override#
virtual void SetCullMode(ECullMode cullMode) override#
virtual EMaterialPass GetMaterialPass() const noexcept override#
virtual void SetMaterialPass(EMaterialPass pass) override#
inline virtual void SetName(const std::string_view &name) override#
inline virtual const std::string &GetName() const noexcept override#
template<class T>
inline EError SetProperty(const std::string_view &name, T value)#
template<class T>
inline Result<T, EError> GetProperty(const std::string_view &name)#
virtual GraphicsApiMaterialInstance *GetInternalMaterial() override#
class ShaderModuleLoader#

Public Functions

bool LoadShaderModule(const std::string_view &filePath, VkDevice device, VkShaderModule *outShaderModule, std::vector<uint32_t> *outBuffer = nullptr)#
class SharedLibrary#

Public Types

enum class EError#

SharedLibrary error.

Values:

enumerator EmptyName#
enumerator NotFound#
enumerator InternalError#

Public Functions

SharedLibrary(const SharedLibrary&) = delete#
SharedLibrary &operator=(const SharedLibrary&) = delete#
SharedLibrary(SharedLibrary &&rhs) noexcept#
SharedLibrary &operator=(SharedLibrary &&rhs) noexcept#
~SharedLibrary()#
inline void *GetNativeHandle() const#
template<typename T>
inline T *GetSymbolUnsafe(std::string_view symbolName)#

Gets a pointer to a symbol. This call does not check if the pointer is null.

Template Parameters:

T – Type of the symbol

Parameters:

symbolName – Name of the symbol

Returns:

A pointer to the symbol

template<typename T>
inline Result<T, EError> GetSymbol(std::string_view symbolName) noexcept#

Gets a pointer to a symbol.

Template Parameters:

T – Type of the symbol

Parameters:

symbolName – Name of the symbol

Returns:

A result with the symbol, or an error if it can’t be found

Public Static Functions

static Result<SharedLibrary, EError> OpenSharedLibrary(std::string_view libraryName) noexcept#

Opens a shared library and returns a handle to it.

Parameters:

libraryName – Shared Library name.

Returns:

A handle to the shared library

class StatsPanel : public Hush::IEditorPanel#

Public Functions

virtual void Init(Scene *activeScene) noexcept override#
virtual void OnRender() noexcept override#
void SetDeltaTime(float delta)#
void SetDrawCallsCount(int32_t count)#
void SetDeviceName(const std::string &deviceName)#
class Timer#
#include <Timer.hpp>

Measures REAL TIME differences.

Public Functions

inline void Start()#
inline float Ellapsed()#

Returns the amount of time passed since Start() was called in ms.

inline float Reset()#

Stops the timer and returns the amount of time passed since Start() was called in ms Then proceeds to start the timer again.

class TitleBarMenuPanel : public Hush::IEditorPanel#

Public Functions

virtual void Init(Scene *activeScene) noexcept override#
virtual void OnRender() noexcept override#
struct Transform#

Subclassed by Hush::LocalTransform, Hush::WorldTransform

Public Functions

Transform() = default#
Transform(const glm::vec3 &position, const glm::vec3 &scale = Vector3Math::ONE, const glm::quat &rotation = {})#
void SetPosition(const glm::vec3 &position) noexcept#
const glm::vec3 *GetPosition() const noexcept#
glm::vec3 *GetPosition() noexcept#
void SetScale(const glm::vec3 &scale) noexcept#
const glm::vec3 &GetScale() const noexcept#
glm::vec3 &GetScale() noexcept#
void SetRotationQuat(const glm::quat &rotationQuat) noexcept#
glm::quat GetRotationQuat() const noexcept#
void SetEulerAngles(const glm::vec3 &euler) noexcept#
glm::vec3 GetEulerAngles() const noexcept#
glm::mat3 GetRotationMatrix() const noexcept#
glm::vec3 Forward() const noexcept#
glm::vec3 Up() const noexcept#
glm::vec3 Right() const noexcept#
void SetTransformationMatrix(const glm::mat4 &xform)#
glm::mat4 GetTransformationMatrix() const#
glm::mat4 XForm(const Transform &other) const#
glm::mat4 operator*(const Transform &other) const#
class TransformationSystem : public Hush::ISystem#

Public Functions

virtual void Init() override#

Init() is called when the system is initialized.

virtual void OnShutdown() override#

OnShutdown() is called when the system is shutting down.

virtual void OnUpdate(float delta) override#

OnRender() is called when the system should render.

Parameters:

delta – Time since last frame

virtual void OnFixedUpdate(float delta) override#

OnFixedUpdate() is called when the system should update its state.

Parameters:

delta – Time since last fixed frame

virtual void OnRender() override#

OnRender() is called when the system should render.

virtual void OnPreRender() override#

OnPreRender() is called before rendering.

virtual void OnPostRender() override#

OnPostRender() is called after rendering.

class UI#

Public Types

enum class ESerializableComponentType#

Values:

enumerator Unkwon#
enumerator Transform#

Public Functions

UI()#
void Init(Scene *parentScene)#
void DrawPanels()#
template<class T>
inline T &GetPanel() const noexcept#

Public Static Functions

static bool Spinner(const char *label, float radius, int thickness, const uint32_t &color = 3435973836u)#
static bool InputTextWithHint(const char *label, const char *hint, char *buffer, size_t size, bool focusOnInput)#
static bool BeginCenterPopup(const char *label, bool transparent = false)#
static bool CustomSelectable(const char *label, bool *isHovered, ImDrawList *drawList, bool forceHover = false)#
static bool BeginToolBar()#
static ImGuiID DockSpace(const char *dockspaceId, const char *name, ImGuiDockNodeFlags additionalFlags = 0)#
static UI &Get()#
class VirtualFilesystem#
#include <VirtualFilesystem.hpp>

The VFS allows to manage paths as virtual locations (that might not refer to the real filesystem). For instance, to access an asset, we could use rs://myasset.txt, instead of referring to the physical location of the file. This, while introducing overhead, allows to manage more complex scenarios such as having the game files in a ZIP or a tar file. Or some other format. To use it, you must instantiate it

Public Types

enum class EError#

Values:

enumerator None#
enumerator FileDoesntExist#
enumerator OperationNotSupported#
enum class EListOptions#

Values:

enumerator None#
enumerator Recursive#

Public Functions

VirtualFilesystem()#
~VirtualFilesystem()#
VirtualFilesystem(const VirtualFilesystem&) = delete#
VirtualFilesystem &operator=(const VirtualFilesystem&) = delete#
VirtualFilesystem(VirtualFilesystem &&rhs) noexcept#
VirtualFilesystem &operator=(VirtualFilesystem &&rhs) noexcept#
void Unmount(std::string_view virtualPath)#
std::vector<std::string_view> ListPath(std::string_view virtualPath, EListOptions options = EListOptions::None)#
Result<std::unique_ptr<IFile>, IFile::EError> OpenFile(std::string_view virtualPath, EFileOpenMode mode = EFileOpenMode::Read)#
template<class T, class ...Args>
inline void MountFileSystem(std::string_view path, Args&&... args)#
struct VkMaterialPipeline#

Public Members

VkPipeline pipeline#
VkPipelineLayout layout#
struct VkRenderObject#

Public Members

uint32_t indexCount#
uint32_t firstIndex#
VkBuffer indexBuffer#
GraphicsApiMaterialInstance *material#
glm::mat4 transform#
VkDeviceAddress vertexBufferAddress#
class VulkanFullScreenPass#

Public Functions

VulkanFullScreenPass() = default#
VulkanFullScreenPass(VulkanRenderer *renderer, std::shared_ptr<ShaderMaterial> material)#
void RecordCommands(VkCommandBuffer cmd, VkDescriptorSet globalDescriptorSet)#
ShaderMaterial *GetMaterial()#
class VulkanHelper#

Public Static Functions

static bool LoadShaderModule(const std::string_view &filePath, VkDevice device, VkShaderModule *outShaderModule, std::vector<uint32_t> *outBuffer = nullptr)#
class VulkanImGuiForwarder : public Hush::IImGuiForwarder#

Public Functions

virtual void SetupImGui(IRenderer *renderer) override#
virtual void NewFrame() override#
virtual void HandleEvent(const SDL_Event *event) noexcept override#
virtual void EndFrame() override#
virtual void Dispose() noexcept override#
void RenderFrame(VkCommandBuffer cmd)#
class VulkanLoader#

Public Types

enum class EError#

Values:

enumerator None#
enumerator FileNotFound#
enumerator InvalidMeshFile#
enumerator FormatNotSupported#

Public Static Functions

static Result<std::vector<Entity>, EError> LoadGltfMeshes(VulkanRenderer *engine, std::filesystem::path filePath, Scene *activeScene)#
static GpuAllocatedImage LoadTexture(VulkanRenderer *engine, const ImageTexture &texture)#
class VulkanPipelineBuilder#

Public Functions

VulkanPipelineBuilder(VkPipelineLayout pipelineLayout)#
void Clear()#
VkPipeline Build(VkDevice device)#
VulkanPipelineBuilder &SetShaders(VkShaderModule vertexShader, VkShaderModule fragmentShader)#
VulkanPipelineBuilder &SetInputTopology(VkPrimitiveTopology topology)#
VulkanPipelineBuilder &SetPolygonMode(VkPolygonMode mode)#
VulkanPipelineBuilder &SetCullMode(VkCullModeFlags cullMode, VkFrontFace frontFace)#
VulkanPipelineBuilder &SetMultiSamplingNone()#
VulkanPipelineBuilder &DisableBlending()#
VulkanPipelineBuilder &EnableBlendingAdditive()#
VulkanPipelineBuilder &EnableBlendingAlphaBlend()#
VulkanPipelineBuilder &SetAlphaBlendMode(EAlphaBlendMode blendMode)#
VulkanPipelineBuilder &DisableDepthTest()#
VulkanPipelineBuilder &EnableDepthTest(bool depthWriteEnable, VkCompareOp op)#
VulkanPipelineBuilder &SetColorAttachmentFormat(VkFormat format)#
VulkanPipelineBuilder &SetDepthFormat(VkFormat format)#
class VulkanRenderer : public Hush::IRenderer#

Public Functions

VulkanRenderer(void *windowContext)#

Creates a new vulkan renderer from a given window context.

Parameters:

windowContext – opaque pointer to the window context

VulkanRenderer(const VulkanRenderer&) = delete#
VulkanRenderer &operator=(const VulkanRenderer&) = delete#
VulkanRenderer(VulkanRenderer &&rhs) noexcept#
VulkanRenderer &operator=(VulkanRenderer &&rhs) noexcept#
~VulkanRenderer() override#
virtual void SetActiveScene(Scene *scene) override#
virtual void CreateSwapChain(uint32_t width, uint32_t height) override#
virtual void InitRendering() override#

Initializes all the internal structures needed to begin rendering, call after a swapchain has been created!

void InitializeCommands() noexcept#
virtual void InitImGui() override#
virtual void PushMesh(const glm::mat4 &globalTransform, std::shared_ptr<Mesh> mesh) override#
virtual void DestroyMesh(const std::string_view &name) override#
virtual void Draw(float delta) override#
virtual void NewUIFrame() const noexcept override#
virtual void EndUIFrame() const noexcept override#
virtual void HandleEvent(const SDL_Event *event) noexcept override#
virtual void UpdateSceneObjects(float delta) override#

Each renderer will have to implement a way of updating all the objects inside of the scene, these are instances of the IRenderableNode, which is a common interface for all renderers, but additional render data (i.e drawContext) might be needed by their underlying implementation (see VulkanMeshNode for an example)

void Dispose()#
void ImmediateSubmit(std::function<void(VkCommandBuffer cmd)> &&function) noexcept#
FrameData &GetCurrentFrame() noexcept#
FrameData &GetLastFrame() noexcept#
VkSampler GetDefaultSamplerLinear() noexcept#
VkSampler GetDefaultSamplerNearest() noexcept#
GLTFMetallicRoughness &GetMetalRoughMaterial() noexcept#
DescriptorAllocatorGrowable &GlobalDescriptorAllocator() noexcept#
VmaAllocator GetVmaAllocator() noexcept#
VkInstance GetVulkanInstance() noexcept#
VkDevice GetVulkanDevice() noexcept#
VkDescriptorSetLayout GetGpuSceneDataDescriptorLayout() noexcept#
const GpuAllocatedImage &GetDrawImage() const noexcept#
GpuAllocatedImage &GetDrawImage() noexcept#
const GpuAllocatedImage &GetDepthImage() const noexcept#
GpuAllocatedImage &GetDepthImage() noexcept#
VkPhysicalDevice GetVulkanPhysicalDevice() const noexcept#
VkQueue GetGraphicsQueue() const noexcept#
virtual void *GetWindowContext() const noexcept override#
virtual void SetDirectionalLight(DirectionalLight *light) noexcept override#
virtual const EditorCamera &GetEditorCamera() const noexcept override#
VulkanSwapchain &GetSwapchain()#
GPUMeshBuffers UploadMesh(const std::vector<uint32_t> &indices, const std::vector<Mesh::Vertex> &vertices)#
virtual GpuAllocatedImage CreateImage(const void *data, const ImageExtent3D &size, Color::EFormat format, uint32_t usage, bool mipmapped = false) override#
VkSurfaceKHR GetSurface() noexcept#
virtual void AddToDeletionQueue(std::function<void()> &&deleteFunc) override#
virtual const DefaultImageProvider *GetDefaultImageProvider() const noexcept override#
ShaderModuleLoader &GetShaderModuleLoader() noexcept#
virtual EditorCamera *GetEditorCamera() noexcept override#

Public Static Functions

static PFN_vkVoidFunction CustomVulkanFunctionLoader(const char *functionName, void *userData)#
class VulkanSwapchain#

Public Functions

void Recreate(uint32_t width, uint32_t height, VulkanRenderer *renderer)#
void Resize(uint32_t width, uint32_t height)#
void Destroy()#
void Present(VkCommandBuffer cmd, uint32_t *swapchainImageIndex, bool *shouldResize)#
uint32_t AcquireNextImage(VkSemaphore swapchainSemaphore, bool *shouldResize)#
const VkFormat &GetImageFormat() const noexcept#
const VkExtent2D &GetExtent() const noexcept#
const std::vector<VkImage> &GetImages() const noexcept#
const std::vector<VkImageView> &GetImageViews() const noexcept#
VkSwapchainKHR GetRawSwapchain() noexcept#
class WindowManager#

Public Static Functions

static inline WindowRenderer *GetMainWindow()#
static inline void SetMainWindow(WindowRenderer *window)#
class WindowRenderer#

Public Functions

WindowRenderer(const char *windowName, Scene *activeScene) noexcept#
WindowRenderer(WindowRenderer &&other) = default#
WindowRenderer(const WindowRenderer &other) = default#
WindowRenderer &operator=(const WindowRenderer&) = default#
WindowRenderer &operator=(WindowRenderer&&) = default#
void HandleEvents(bool *applicationRunning)#
~WindowRenderer()#
IRenderer *GetInternalRenderer() noexcept#
bool IsActive() const noexcept#
struct WorldTransform : public Hush::Transform#

Public Functions

Transform() = default#
Transform(const glm::vec3 &position, const glm::vec3 &scale = Vector3Math::ONE, const glm::quat &rotation = {})#
namespace ArrayUtils#

Provides utility functions for handling Arrays and collection types.

Functions

template<class ArrayType, class ElementType>
inline std::vector<ElementType> FuzzyFind(const ArrayType &candidates, const std::string &query)#
template<class ArrayType, class ElementType>
inline std::vector<size_t> FuzzyFindIndices(const ArrayType &candidates, const std::string &query)#
namespace Bitwise#

Definitions and all that just to make everything type safe.

Functions

template<class T, class U>
inline constexpr bool HasFlag(T base, U flag)#
template<class T, class U>
inline constexpr bool HasCompositeFlag(T base, U compositeFlag)#
namespace ComponentTraits#

Typedefs

using ComponentCtor = void (*)(void *array, std::int32_t count, const void *componentInfo)#
using ComponentDtor = void (*)(void *array, std::int32_t count, const void *componentInfo)#
using ComponentCopy = void (*)(void *dst, const void *src, std::int32_t count, const void *componentInfo)#
using ComponentMove = void (*)(void *dst, void *src, std::int32_t count, const void *componentInfo)#
using ComponentCopyCtor = void (*)(void *dst, const void *src, std::int32_t count, const void *componentInfo)#
using ComponentMoveCtor = void (*)(void *dst, void *src, std::int32_t count, const void *componentInfo)#

Enums

enum class EComponentOpsFlags : std::uint32_t#

Values:

enumerator None#
enumerator HasCtor#
enumerator HasDtor#
enumerator HasCopy#
enumerator HasMove#
enumerator HasCopyCtor#
enumerator HasMoveCtor#
enumerator HasMoveDtor#
enumerator HasMoveAssignDtor#
enumerator NoCtor#
enumerator NoDtor#
enumerator NoCopy#
enumerator NoMove#
enumerator NoCopyCtor#
enumerator NoMoveCtor#
enumerator NoMoveDtor#
enumerator NoMoveAssignDtor#

Functions

template<typename T>
void CtorImpl(void *array, std::int32_t count, const void*)#
template<typename T>
void DtorImpl(void *array, std::int32_t count, const void*)#
template<typename T>
void CopyImpl(void *dst, const void *src, std::int32_t count, const void*)#
template<typename T>
void MoveImpl(void *dst, void *src, std::int32_t count, const void*)#
template<typename T>
void CopyCtorImpl(void *dst, const void *src, std::int32_t count, const void*)#
template<typename T>
void MoveCtorImpl(void *dst, void *src, std::int32_t count, const void*)#
template<typename T>
void MoveCtorDtorImpl(void *dst, void *src, std::int32_t count, const void*)#
template<typename T>
void MoveAssignDtorImpl(void *dst, void *src, std::int32_t count, const void*)#
template<typename T>
constexpr ComponentCtor GetCtorImpl(EComponentOpsFlags&)#

Get the constructor function for a component.

Template Parameters:

T – Type of the component.

Returns:

Function pointer to the function that will construct the component.

template<typename T>
constexpr ComponentCtor GetCtorImpl(EComponentOpsFlags&)

Get the constructor function for a component that does not have a trivial constructor.

Template Parameters:

T – Type of the component.

Returns:

Nullptr

template<typename T>
constexpr ComponentCtor GetCtorImpl(EComponentOpsFlags &flags)
template<typename T>
constexpr ComponentDtor GetDtorImpl(EComponentOpsFlags&)#
template<typename T>
constexpr ComponentDtor GetDtorImpl(EComponentOpsFlags&)
template<typename T>
constexpr ComponentDtor GetDtorImpl(EComponentOpsFlags &flags)
template<typename T>
constexpr ComponentCopy GetCopyImpl(EComponentOpsFlags&)#
template<typename T>
constexpr ComponentCopy GetCopyImpl(EComponentOpsFlags&)
template<typename T>
constexpr ComponentCopy GetCopyImpl(EComponentOpsFlags &flags)
template<typename T>
constexpr ComponentMove GetMoveImpl(EComponentOpsFlags&)#
template<typename T>
constexpr ComponentMove GetMoveImpl(EComponentOpsFlags&)
template<typename T>
constexpr ComponentMove GetMoveImpl(EComponentOpsFlags &flags)
template<typename T>
constexpr ComponentCopyCtor GetCopyCtorImpl(EComponentOpsFlags&)#
template<typename T>
constexpr ComponentCopyCtor GetCopyCtorImpl(EComponentOpsFlags&)
template<typename T>
constexpr ComponentCopyCtor GetCopyCtorImpl(EComponentOpsFlags &flags)
template<typename T>
constexpr ComponentMoveCtor GetMoveCtorImpl(EComponentOpsFlags&)#
template<typename T>
constexpr ComponentMoveCtor GetMoveCtorImpl(EComponentOpsFlags&)
template<typename T>
constexpr ComponentMoveCtor GetMoveCtorImpl(EComponentOpsFlags &flags)
template<typename T>
constexpr ComponentMoveCtor GetMoveDtorImpl(EComponentOpsFlags&)#
template<typename T>
constexpr ComponentMoveCtor GetMoveDtorImpl(EComponentOpsFlags&)
template<typename T>
constexpr ComponentMoveCtor GetMoveDtorImpl(EComponentOpsFlags &flags)
template<typename T>
constexpr ComponentMoveCtor GetMoveAssignDtorImpl(EComponentOpsFlags&)#
template<typename T>
constexpr ComponentMoveCtor GetMoveAssignDtorImpl(EComponentOpsFlags &flags)
template<typename T>
constexpr ComponentMoveCtor GetMoveAssignDtorImpl(EComponentOpsFlags&)
template<typename T>
constexpr ComponentOps GetOps(EComponentOpsFlags &flags)#

Get the operations for a component.

Template Parameters:

T – Type of the component.

Returns:

Operations for the component.

template<typename T>
ComponentInfo GetComponentInfo()#
struct ComponentInfo#

Public Members

std::size_t size#
std::size_t alignment#
const char *name#
ComponentOps ops#
EComponentOpsFlags opsFlags#
void *userCtx#
void (*userCtxFree)(void*)#
struct ComponentOps#

Public Members

ComponentCtor ctor#
ComponentDtor dtor#
ComponentCopy copy#
ComponentMove move#
ComponentCopyCtor copyCtor#
ComponentMoveCtor moveCtor#
ComponentMoveCtor moveDtor#
ComponentMoveCtor moveAssignDtor#
namespace detail#

Enums

enum class EEntityRegisterStatus#

Values:

enumerator Registered#
enumerator NotRegistered#

Functions

template<typename T>
static std::pair<EEntityRegisterStatus, std::uint64_t*> GetEntityIdImpl(const void *worldPtr)#

Get the entity id for a given entity type.

Template Parameters:

T – Type of the entity, without cvref.

Parameters:

worldPtr – Pointer to the world.

Returns:

Pair with the status of the entity and the entity id.

template<typename T>
static std::pair<EEntityRegisterStatus, std::uint64_t*> GetEntityId(const void *worldPtr)#

Get the entity id for a given entity type.

Template Parameters:

T – Type of the entity.

Parameters:

worldPtr – Pointer to the world.

Returns:

Pair with the status of the entity and the entity id.

namespace DefaultObjects#

Enums

enum EDefaultObjectType#

Values:

enumerator EntWithDirectionalLight#

Functions

Entity::EntityId MakeDefault(Scene *activeScene, EDefaultObjectType objectType)#
namespace Export#

Functions

template<std::size_t N>
constexpr void name(const char (&name)[N])#

Renames a class or struct.

Parameters:

name – The new name of the class or struct. For instance, given the following class: class [[hush::export(Hush::Export::name(“MyExportedClass”))]] MyClass2 { public: int myVariable; }; The generated C code will be: typedef struct MyExportedClass MyExportedClass;

Variables

constexpr bool asHandle = true#

Export a class or struct as a handle. This will generate a typedef for the class or struct. If not defined, the class or struct will be exported as a struct with all the members.

For instance, given the following class: class [[hush::export(Hush::Export::asHandle)]] MyClass { public: int myVariable; }; The generated C code will be: typedef struct MyClass MyClass;

constexpr bool ignore = true#

Ignores a member of a class or struct. It, however, will be exported as a buffer. For instance, given the following class: class [[hush::export(Hush::Export::ignore)]] MyClass { public: int myVariable; [[hush::export(Hush::Export::ignore)]] int myVariable2; }; The generated C code will be: typedef struct MyClass MyClass { int myVariable; alignas(4) char myVariable2[4]; };

namespace GltfLoadFunctions#

Enums

enum class EError#

Values:

enumerator None#
enumerator InvalidMeshFile#
enumerator FormatNotSupported#
enumerator TextureNotFound#

Functions

glm::mat4 GetNodeTransform(const fastgltf::Node &node)#
EMaterialPass GetMaterialPassFromFastGltfPass(fastgltf::AlphaMode pass)#
std::shared_ptr<ImageTexture> TextureFromImageDataSource(const fastgltf::Asset &asset, const fastgltf::Image &image)#
EError SetMaterialTextures(GLTFMetallicRoughness *outMaterialResources, const fastgltf::Asset &asset, const fastgltf::Material &material, const void *loadedTextures)#
Hush::Result<const std::byte*, EError> GetDataFromBufferSource(const fastgltf::Buffer &buffer)#
template<class BufferType>
inline std::vector<BufferType> FindAttributeByName(const fastgltf::Primitive &primitive, const fastgltf::Asset &asset, const std::string_view &attributeName)#
namespace Hashing#

Functions

constexpr uint32_t Fnv1a(const char *data, const uint32_t length)#
constexpr std::uint64_t Fnv1a64(const char *data, const uint32_t length)#
constexpr uint32_t Fnv1a(const std::string_view &data)#
constexpr std::uint64_t Fnv1a64(const std::string_view &data)#
namespace impl#
class QueryImpl#

Subclassed by Hush::Query< Components >

Public Functions

inline QueryImpl(RawQuery query) noexcept#
QueryImpl(const QueryImpl&) = delete#
QueryImpl &operator=(const QueryImpl&) = delete#
inline QueryImpl(QueryImpl &&rhs) noexcept#
inline QueryImpl &operator=(QueryImpl &&rhs) noexcept#
namespace Mat4Math#

Functions

inline void DecomposeTRS(const glm::mat4 &matrix, glm::vec3 &translation, glm::quat &rotation, glm::vec3 &scale)#
inline glm::mat4 ComposeTRS(const glm::vec3 &position, const glm::quat &rotation, const glm::vec3 &scale)#

Variables

constexpr glm::mat4 IDENTITY = glm::mat4(1.0F)#
constexpr size_t TRANSLATION_COLUMN = 3#
namespace MathUtils#

Functions

inline float Clamp(float value, float min, float max)#
inline int32_t CircleBack(int32_t value, int32_t min, int32_t maxInclusive)#
inline float Lerp(float from, float to, float t)#
inline float Pow(float x, float n)#
namespace Networking#
namespace Reflection#

Functions

template<typename T>
inline TypeInfo GetTypeInfo()#
template<>
inline TypeInfo GetTypeInfo<void>()#
template<typename T>
constexpr TypeId GetTypeId()#
template<>
constexpr TypeId GetTypeId<uint8_t>()#
template<>
constexpr TypeId GetTypeId<uint16_t>()#
template<>
constexpr TypeId GetTypeId<uint32_t>()#
template<>
constexpr TypeId GetTypeId<uint64_t>()#
template<>
constexpr TypeId GetTypeId<int8_t>()#
template<>
constexpr TypeId GetTypeId<int16_t>()#
template<>
constexpr TypeId GetTypeId<int32_t>()#
template<>
constexpr TypeId GetTypeId<int64_t>()#
template<>
constexpr TypeId GetTypeId<bool>()#
template<>
constexpr TypeId GetTypeId<float>()#
template<>
constexpr TypeId GetTypeId<double>()#
template<>
constexpr TypeId GetTypeId<void>()#
template<>
constexpr TypeId GetTypeId<std::string_view>()#
class FieldInfo#

Public Types

using EVariantError = Variant::EVariantError#
using Setter = std::function<EVariantError(std::span<const VariantView>)>#
using Getter = std::function<Result<Variant, EVariantError>(std::span<const VariantView>)>#

Public Functions

inline FieldInfo(TypeId typeId, std::string name, Setter setter, Getter getter, uint64_t offset = 0)#
inline TypeId GetTypeId() const#
inline std::string_view GetName() const#
inline Result<Variant, Variant::EVariantError> Get(std::span<const VariantView> args) const#
inline Result<Variant, Variant::EVariantError> Get(std::initializer_list<const VariantView> args) const#
inline EVariantError Set(const std::span<const VariantView> args) const#
inline EVariantError Set(std::initializer_list<VariantView> args) const#
inline uint64_t GetOffset() const#
class FunctionInfo#

Public Types

enum class EFunctionInfoError : uint8_t#

Values:

enumerator None#
enumerator InvalidType#
enumerator InvalidArgsCount#
enumerator InvalidArgsType#
enumerator NonMatchingArgs#
using CallFunc = Result<Variant, EFunctionInfoError> (*)(std::span<const VariantView>)#

Public Functions

inline FunctionInfo(CallFunc callFunc, std::string name, std::span<const TypeId> argsType)#
inline Result<Variant, EFunctionInfoError> Call(std::span<const VariantView> args) const#

Calls the function with the given arguments.

Parameters:
  • returnVal – Return value type.

  • args – Arguments to the function.

Returns:

Result with the return value or an error.

template<typename ...Args>
inline Result<Variant, EFunctionInfoError> Call(Args&&... args) const#

Calls the function with the given arguments.

Template Parameters:

Args – Arguments to the function.

Parameters:
  • returnVal – Return value type.

  • args – Arguments to the function.

Returns:

Result with the return value or an error.

inline std::uint64_t GetArgsCount() const#
inline bool IsCallableWith(std::span<const VariantView> args) const#
inline std::string_view GetName() const#

Public Static Functions

template<typename ...Args>
static inline FunctionInfo Create(CallFunc callFunc, std::string name)#

Public Static Attributes

static constexpr std::uint8_t MAX_ARGS = 16#
class ReflectionDB#

Public Functions

inline void RegisterClass(TypeInfo typeInfo)#
inline const TypeInfo *GetTypeInfo(TypeId id) const#
inline const TypeInfo *GetTypeInfo(std::string_view name) const#
template<ReflectedType T>
inline RegisterClassBuilder<T> RegisterClass()#
template<typename T>
struct RegisterClassBuilder#

Public Functions

inline explicit RegisterClassBuilder(ReflectionDB *reflectionDB)#
inline RegisterClassBuilder &AddConstructor(FunctionInfo constructor)#
inline RegisterClassBuilder &AddInPlaceConstructor(TypeInfo::InPlaceCtor ctor)#
inline RegisterClassBuilder &AddFunction(FunctionInfo function)#
inline RegisterClassBuilder &SizeOf(std::size_t size)#
inline RegisterClassBuilder &AlignmentOf(std::size_t alignment)#
inline RegisterClassBuilder &AddProperty(FieldInfo property)#
inline void Register()#
struct TypeId#

Public Functions

inline bool operator==(const TypeId &other) const#
inline bool operator!=(const TypeId &other) const#

Public Members

std::uint64_t id = {}#
class TypeInfo#

Public Types

enum class EInPlaceConstructorError#

Values:

enumerator None#
enumerator InsufficientMemory#
enumerator NoInPlaceConstructors#
enumerator NonMatchingArgs#
enumerator InvalidType#
using InPlaceCtorFunc = EInPlaceConstructorError (*)(void *mem, std::span<const VariantView>)#

Public Functions

inline TypeInfo(TypeId id = {})#
inline TypeId GetId() const#
inline void AddFunction(const FunctionInfo &function)#
inline void AddField(const FieldInfo &field)#
inline std::span<const FunctionInfo> GetFunctions() const#
inline std::span<const FieldInfo> GetFields() const#
inline std::optional<std::reference_wrapper<const FieldInfo>> GetField(std::string_view name) const#
inline const std::string &GetName() const#
inline void SetName(std::string_view name)#
inline std::size_t GetSize() const#
inline void SetSize(std::size_t size)#
inline std::size_t GetAlignment() const#
inline void SetAlignment(std::size_t alignment)#
inline Result<Variant, FunctionInfo::EFunctionInfoError> CreateInstance(std::span<const VariantView> args) const#

Creates an instance of this type with the given arguments and returns it as a Variant. If you wish to create an instance in a specific memory location, or avoid heap allocation, use CreateInPlaceInstance(void *mem, size_t memSize, std::span<const VariantView> args) const instead.

Note

This function might allocate memory for the instance, depending on the size of the type. See Hush::Reflection::Variant::MAX_SIZE for the maximum size of a type that can be created without allocating in the heap.

Parameters:

args – Arguments to pass to the constructor.

Returns:

Result with the created instance or an error.

inline Result<Variant, FunctionInfo::EFunctionInfoError> CreateInstance(std::initializer_list<const VariantView> args) const#

Creates an instance of this type with the given arguments. See CreateInstance(std::span<constVariantView> args) const for more information.

Parameters:

args – Arguments to pass to the constructor.

Returns:

Result with the created instance or an error.

inline std::optional<EInPlaceConstructorError> CreateInPlaceInstance(void *mem, size_t memSize, std::span<const VariantView> args) const#

Creates an instance of this type in-place using the provided memory and arguments. This function checks if the provided memory is sufficient and if there are any in-place constructors available.

When using this function, ensure that the memory provided is properly aligned for the type being constructed. Also, the memory must be large enough to hold the type’s data.

Note

This function is designed for advanced use cases where you need to create an instance of a type in a specific memory location, This function never allocates memory for the instance.

Warning

Keep in mind that this function does not keep track of the lifetime of the created instance. You’re responsible for managing the memory and ensuring that the instance is destroyed properly.

Parameters:
  • mem – Pointer to the memory where the instance should be created.

  • memSize – Size of the memory in bytes. Must be at least as large as the size of the type.

  • args – Arguments to pass to the in-place constructor.

Returns:

An optional error if the in-place construction fails, or an empty optional if it succeeds.

inline std::optional<EInPlaceConstructorError> CreateInPlaceInstance(void *mem, size_t memSize, std::initializer_list<const VariantView> args) const#

Creates an instance of this type in-place using the provided memory and arguments. See CreateInPlaceInstance(void *mem, size_t memSize, std::span<const VariantView> args) const for more information.

Parameters:
  • mem – Pointer to the memory where the instance should be created.

  • memSize – Size of the memory in bytes.

  • args – Arguments to pass to the in-place constructor.

Returns:

An optional error if the in-place construction fails, or an empty optional if it succeeds.

inline Result<Variant, FunctionInfo::EFunctionInfoError> CallFunction(std::string_view name, std::span<const VariantView> args) const#

Calls a function with the given name and arguments. This helper function searches for a function in O(n) time, where n is the number of functions in this type. This also supports overloaded functions, as it checks the argument types to find a matching function.

Parameters:
  • name – Name of the function to call.

  • args – Arguments to pass to the function.

Returns:

Result with the return value or an error.

inline Result<Variant, FunctionInfo::EFunctionInfoError> CallFunction(std::string_view name, std::initializer_list<const VariantView> args) const#

Calls a function with the given name and arguments. This is a convenience overload that allows passing arguments as an initializer list. For more information, see the CallFunction(std::string_view name, std::span<const VariantView> args) const function.

Parameters:
  • name – Name of the function to call.

  • args – Arguments to pass to the function.

Returns:

Result with the return value or an error.

inline void SetConstructors(std::vector<FunctionInfo> &&constructors)#
inline void SetFunctions(std::vector<FunctionInfo> &&functions)#
inline void SetFields(std::vector<FieldInfo> &&fields)#
inline void SetInPlaceCtors(std::vector<InPlaceCtor> &&inPlaceCtor)#

Sets the in-place constructors for this type.

Parameters:

inPlaceCtor – A vector of in-place constructors to set.

struct InPlaceCtor#

Public Functions

inline InPlaceCtor(InPlaceCtorFunc callFunc, std::span<const TypeId> args)#
inline EInPlaceConstructorError ConstructUnchecked(void *mem, std::span<const VariantView> args) const#
inline bool IsCallableWith(std::span<const VariantView> args) const#

Public Members

std::array<TypeId, FunctionInfo::MAX_ARGS> m_argsType#
InPlaceCtorFunc m_func#
uint8_t m_argsCount = {}#

Public Static Functions

template<typename ...Args>
static inline InPlaceCtor Create(InPlaceCtorFunc callFunc)#
class Variant#

Public Types

using EVariantError = VariantView::EVariantError#

Public Functions

inline Variant()#
template<typename T>
inline explicit Variant(T &&value)#
Variant(const Variant&) = delete#
Variant &operator=(const Variant&) = delete#
Variant(Variant &&rhs) noexcept#
~Variant()#
inline Variant &operator=(Variant &&rhs) noexcept#
template<typename T>
inline Result<T*, EVariantError> Get() const#
inline Result<void*, EVariantError> GetRaw(TypeId id) const#
inline void Clear()#
template<typename T>
inline bool IsType() const#
inline bool IsType(TypeId id) const#
inline TypeId StoredTypeId() const#

Public Members

char m_data[MAX_SMALL_SIZE] = {}#
void *m_ptr#

Public Static Functions

template<typename T, typename ...Args>
static inline Variant CreateInPlace(Args&&... args)#
struct VariantView#
#include <Variant.hpp>

A VariantView that holds a reference to any type.

Public Types

enum class EVariantError : uint8_t#

Values:

enumerator NonSameType#

Public Functions

inline VariantView()#
template<typename T>
inline explicit VariantView(T *value)#
template<typename T>
inline explicit VariantView(T &value)#
VariantView(const Variant &variant)#
inline explicit VariantView(void *value, std::uint64_t typeId)#
template<typename T>
inline Result<T*, EVariantError> Get() const#
inline void *GetRaw(TypeId id) const#
inline TypeId GetTypeId() const#
namespace Serialization#

Enums

enum class EFormatDescribingType#

Describing format type. A self-describing format is a format that includes the type information in the format itself. For instance, JSON contains the name of the field along with the value (which is of a specific type). A non-self-describing format is a format that does not include the type information in the format itself. For instance, a binary format may not include the name of the field along with the value.

Values:

enumerator SelfDescribing#

Self-describing format.

enumerator NonSelfDescribing#

Non-self-describing format.

enum class EDeserializationError#

SerializationError enum class.

Values:

enumerator None#
enumerator InvalidType#
enumerator InvalidData#
enumerator InvalidFormat#
enumerator InvalidKey#
enumerator NotSupported#
enum class ESerializationError#

SerializationError enum class.

Values:

enumerator None#
enumerator InvalidType#
enumerator InvalidData#
enumerator InvalidFormat#

Functions

template<typename T>
inline Result<T, EDeserializationError> DeserializeJson(std::string_view json)#
template<typename T>
inline Result<std::string, ESerializationError> SerializeJson(const T &value)#
class IVisitor#
#include <Deserialization.hpp>

Base class for visitors. A Serialization visitor is a class that implements the visitor pattern to visit the different types of data that a format passes. For instance, when a JSON parser sees a number, it will call the VisitInt method of the visitor.

TODO(Alan): how a non-self-describing format will work? We might need to implement a VisitRaw(const char* data,

size_t maxSize, size_t currentOffset)?

Subclassed by Hush::Serialization::BuiltinVisitors::FloatVisitor< double >, Hush::Serialization::BuiltinVisitors::FloatVisitor< float >, Hush::Serialization::BuiltinVisitors::IntVisitor< int16_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< int32_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< int64_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< int8_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< uint16_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< uint32_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< uint64_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< uint8_t >, Hush::Serialization::Visitor< T, typename >

Public Types

using Result = Hush::Result<IVisitor*, EDeserializationError>#

Public Functions

inline IVisitor(IVisitor *parent, EFormatDescribingType format)#
virtual ~IVisitor() = default#
inline virtual Result VisitInt8(std::int8_t value)#

Visit a signed 8-bit integer.

Parameters:

value – Value to visit

Returns:

Result with the next visitor or an error.

inline virtual Result VisitInt16(std::int16_t value)#

Visit a signed 16-bit integer.

Parameters:

value – Value to visit

Returns:

Result with the next visitor or an error.

inline virtual Result VisitInt32(std::int32_t value)#

Visit a signed 32-bit integer.

Parameters:

value – Value to visit

Returns:

Result with the next visitor or an error.

inline virtual Result VisitInt64(std::int64_t value)#

Visit a signed 64-bit integer.

Parameters:

value – Value to visit

Returns:

Result with the next visitor or an error.

inline virtual Result VisitUInt8(std::uint8_t value)#

Visit an unsigned 8-bit integer.

Parameters:

value – Value to visit

Returns:

Result with the next visitor or an error.

inline virtual Result VisitUInt16(std::uint16_t value)#

Visit an unsigned 16-bit integer.

Parameters:

value – Value to visit

Returns:

Result with the next visitor or an error.

inline virtual Result VisitUInt32(std::uint32_t value)#

Visit an unsigned 32-bit integer.

Parameters:

value – Value to visit

Returns:

Result with the next visitor or an error.

inline virtual Result VisitUInt64(std::uint64_t value)#

Visit an unsigned 64-bit integer.

Parameters:

value – Value to visit

Returns:

Result with the next visitor or an error.

inline virtual Result VisitFloat(float value)#

Visit a float value.

Parameters:

value – Value to visit

Returns:

Result with the next visitor or an error.

inline virtual Result VisitDouble(double value)#

Visit a double value.

Parameters:

value – Value to visit

Returns:

Result with the next visitor or an error.

inline virtual Result VisitBool(bool value)#

Visit a boolean value.

Parameters:

value – Value to visit

Returns:

Result with the next visitor or an error.

inline virtual Result VisitString(std::string_view value)#

Visit a string value.

Parameters:

value – Value to visit

Returns:

Result with the next visitor or an error.

inline virtual Result VisitNull()#

Visit a null value.

Returns:

Result with the next visitor or an error.

inline virtual Result VisitArrayStart()#

Visit an array start.

Returns:

Result with the next visitor or an error.

inline virtual Result VisitArrayEnd()#

Visit the end of an array.

Returns:

Result with the next visitor or an error.

inline virtual Result VisitObjectStart()#

Visit the start of an object.

Returns:

Result with the next visitor or an error.

inline virtual Result VisitObjectEnd()#

Visit the end of an object.

Returns:

Result with the next visitor or an error.

inline virtual Result VisitKey(std::string_view value)#

Visit a key in an object.

Parameters:

value – Key to visit

Returns:

Result with the next visitor or an error.

inline void SetParentVisitor(IVisitor *parent)#

Visit a key in an object.

Parameters:

parent – Parent visitor

inline IVisitor *GetParentVisitor() const#

Get the parent visitor.

Returns:

Parent visitor

inline IVisitor *GetStartVisitor() const#

Get the starting visitor.

Returns:

Starting visitor

class JsonDeserializer#

Public Functions

inline JsonDeserializer(std::string_view json)#
template<typename T>
inline Result<T, EDeserializationError> Deserialize()#
template<typename T>
inline Result<T, EDeserializationError> Deserialize()
class JsonSerializer#
#include <JsonSerializer.hpp>

JsonSerializer class.

This class is used to serialize data to a JSON string. It has member functions to set keys, start and end objects, and serialize data. It also supports serializing custom types that follow the IsSerializable concept.

Public Functions

inline JsonSerializer()#
inline ESerializationError SetKey(std::string_view key)#

Sets the key for the next value to be serialized.

Parameters:

key – Key to serialize

Returns:

SerializationError

inline ESerializationError BeginObject()#

Begins an object in the JSON string.

Returns:

SerializationError

inline ESerializationError EndObject()#

Ends an object in the JSON string.

Returns:

SerializationError

template<IsSerializable<JsonSerializer> T>
inline ESerializationError Serialize(const T &value)#

Serializes an object to a JSON string.

Template Parameters:

T – Serializable object

Parameters:

value – Value to serialize

Returns:

SerializationError

template<typename T>
inline ESerializationError Serialize(const T&)#
template<typename T>
inline ESerializationError Serialize(const T)#
template<typename T>
inline ESerializationError SerializeArray(const std::span<const T> values)#

Serializes a span of values to a JSON array.

Parameters:

values – Value to serialize

Returns:

SerializationError

template<typename V, IsMapIterator<std::string, V> It>
inline ESerializationError SerializeMap(It begin, It end)#

Serializes a map of values to a JSON object.

Template Parameters:
  • V – Value type

  • It – Iterator type

Parameters:
  • begin – Begin iterator

  • end – End iterator

Returns:

SerializationError

template<typename T>
inline ESerializationError Serialize(std::string_view key, const T &value)#

Serializes a key-value pair to a JSON object.

Template Parameters:

T – Type

Parameters:
  • key – Key

  • value – Value

Returns:

SerializationError

template<typename T>
inline ESerializationError Serialize(std::string_view key, const std::span<const T> values)#

Serializes an array of values to a JSON array.

Template Parameters:

T – Type

Parameters:
  • key – Key

  • values – Values

Returns:

SerializationError

template<typename V, IsMapIterator<std::string, V> It>
inline ESerializationError Serialize(std::string_view key, It begin, It end)#

Serializes a map of values to a JSON object.

Template Parameters:
  • V – Value type

  • It – Iterator type

Parameters:
  • key – Key

  • begin – Iterator begin

  • end – Iterator end

Returns:

SerializationError

inline std::string FinishSerialization()#

Finalizes the serialization process and returns the serialized JSON string. You should not call any other function after this one.

Returns:

Serialized JSON string

template<>
inline ESerializationError Serialize(const double value)#

Serializes a double value to a JSON string.

Parameters:

value – Value to serialize

Returns:

SerializationError

template<>
inline ESerializationError Serialize(const float value)#

Serializes a float value to a JSON string.

Parameters:
  • key – Key to serialize

  • value – Value to serialize

Returns:

SerializationError

template<>
inline ESerializationError Serialize(const bool value)#

Serializes a boolean value to a JSON string.

Parameters:

value – Value to serialize

Returns:

SerializationError

template<>
inline ESerializationError Serialize(const std::uint8_t value)#

Serializes an uint8 value to a JSON string.

Parameters:

value – Value to serialize

Returns:

SerializationError

template<>
inline ESerializationError Serialize(const std::uint16_t value)#

Serializes an uint16 value to a JSON string.

Parameters:

value – Value to serialize

Returns:

SerializationError

template<>
inline ESerializationError Serialize(const std::uint32_t value)#

Serializes an uint32 value to a JSON string.

Parameters:

value – Value to serialize

Returns:

SerializationError

template<>
inline ESerializationError Serialize(const std::uint64_t value)#

Serializes an uint64 value to a JSON string.

Parameters:

value – Value to serialize

Returns:

SerializationError

template<>
inline ESerializationError Serialize(const std::int8_t value)#

Serializes an int8 value to a JSON string.

Parameters:

value – Value to serialize

Returns:

SerializationError

template<>
inline ESerializationError Serialize(const std::int16_t value)#

Serializes an int16 value to a JSON string.

Parameters:

value – Value to serialize

Returns:

SerializationError

template<>
inline ESerializationError Serialize(const std::int32_t value)#

Serializes an int32 value to a JSON string.

Parameters:

value – Value to serialize

Returns:

SerializationError

template<>
inline ESerializationError Serialize(const std::int64_t value)#

Serializes an int64 value to a JSON string.

Parameters:

value – Value to serialize

Returns:

SerializationError

template<>
inline ESerializationError Serialize(const std::string &value)#

Serializes a string value to a JSON string.

Parameters:

value – Value to serialize

Returns:

SerializationError

template<>
inline ESerializationError Serialize(const std::string_view value)#

Serializes a string_view value to a JSON string.

Parameters:

value – Value to serialize

Returns:

SerializationError

template<typename T, typename = void>
struct Visitor : public Hush::Serialization::IVisitor#

Public Functions

inline Visitor(IVisitor *parent, T *value, EFormatDescribingType describingType)#
template<typename T> Visitor< T > : public Hush::Serialization::BuiltinVisitors::Visitor< T > , public decltypestd::declval< T & >Deserializestd::declval , public EFormatDescribingType::NonSelfDescribing

Public Types

using Parent = decltype(std::declval<T&>().Deserialize(std::declval<IVisitor*>(), EFormatDescribingType::NonSelfDescribing))#
using Type = T#

Public Functions

inline Visitor(IVisitor *parent, T *value, EFormatDescribingType describingType)#
inline Visitor(IVisitor *parent, T *value, EFormatDescribingType describingType)
namespace BuiltinVisitors#
template<typename F>
struct FloatVisitor : public Hush::Serialization::IVisitor#

Public Types

using Exists = std::true_type#

Public Functions

inline FloatVisitor(IVisitor *parent, F *value, EFormatDescribingType describingType)#
inline Result VisitFloat(float v) override#
inline Result VisitDouble(double v) override#

Public Members

F *value#
template<typename IntType>
struct IntVisitor : public Hush::Serialization::IVisitor#

Public Types

using Exists = std::true_type#

Public Functions

inline IntVisitor(IVisitor *parent, IntType *value, EFormatDescribingType describingType)#
inline Result VisitUInt8(std::uint8_t v) override#
inline Result VisitUInt16(std::uint16_t v) override#
inline Result VisitUInt32(std::uint32_t v) override#
inline Result VisitUInt64(std::uint64_t v) override#
inline Result VisitInt8(std::int8_t v) override#
inline Result VisitInt16(std::int16_t v) override#
inline Result VisitInt32(std::int32_t v) override#
inline Result VisitInt64(std::int64_t v) override#

Public Members

IntType *value#

Public Static Attributes

static constexpr bool IsUnsigned = std::is_unsigned_v<IntType>#
template<typename T>
struct Visitor : public Hush::Serialization::IVisitor#

Subclassed by Hush::Serialization::Visitor< T >

Public Types

using Exists = std::false_type#
template<>
struct Visitor<bool> : public Hush::Serialization::IVisitor#

Public Functions

inline Visitor(IVisitor *parent, bool *value, EFormatDescribingType describingType)#
inline Result VisitBool(bool v) override#

Public Members

bool *value = {}#
template<>
struct Visitor<double> : public Hush::Serialization::BuiltinVisitors::FloatVisitor<double>#

Public Functions

inline Visitor(IVisitor *parent, double *value, EFormatDescribingType describingType)#
template<>
struct Visitor<float> : public Hush::Serialization::BuiltinVisitors::FloatVisitor<float>#

Public Types

using Exists = std::true_type#

Public Functions

inline Visitor(IVisitor *parent, float *value, EFormatDescribingType describingType)#
template<>
struct Visitor<int16_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<int16_t>#

Public Functions

inline Visitor(IVisitor *parent, int16_t *value, EFormatDescribingType describingType)#
template<>
struct Visitor<int32_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<int32_t>#

Public Functions

inline Visitor(IVisitor *parent, int32_t *value, EFormatDescribingType describingType)#
template<>
struct Visitor<int64_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<int64_t>#

Public Functions

inline Visitor(IVisitor *parent, int64_t *value, EFormatDescribingType describingType)#
template<>
struct Visitor<int8_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<int8_t>#

Public Types

using Exists = std::true_type#

Public Functions

inline Visitor(IVisitor *parent, int8_t *value, EFormatDescribingType describingType)#
template<>
struct Visitor<std::map<std::string, std::string>> : public Hush::Serialization::IVisitor#

Public Types

using Exists = std::true_type#

Public Functions

inline Visitor(IVisitor *parent, std::map<std::string, std::string> *value, EFormatDescribingType describingType)#
inline Result VisitObjectStart() override#
inline Result VisitObjectEnd() override#
inline Result VisitKey(std::string_view v) override#
inline Result VisitString(std::string_view v) override#

Public Members

bool insideObject = {false}#
std::map<std::string, std::string> *value = {}#
std::string currentKey = {}#
template<>
struct Visitor<std::string> : public Hush::Serialization::IVisitor#

Public Types

using Exists = std::true_type#

Public Functions

inline Visitor(IVisitor *parent, std::string *value, EFormatDescribingType describingType)#
inline Result VisitString(std::string_view v) override#

Public Members

std::string *value = {}#
template<>
struct Visitor<uint16_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<uint16_t>#

Public Functions

inline Visitor(IVisitor *parent, uint16_t *value, EFormatDescribingType describingType)#
template<>
struct Visitor<uint32_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<uint32_t>#

Public Functions

inline Visitor(IVisitor *parent, uint32_t *value, EFormatDescribingType describingType)#
template<>
struct Visitor<uint64_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<uint64_t>#

Public Functions

inline Visitor(IVisitor *parent, uint64_t *value, EFormatDescribingType describingType)#
template<>
struct Visitor<uint8_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<uint8_t>#

Public Functions

inline Visitor(IVisitor *parent, uint8_t *value, EFormatDescribingType describingType)#
namespace StringUtils#

Provides utility functions for handling strings (C and std strings)

Functions

std::wstring ToWString(const char *data)#

Converts the given char* to a standard wstring, used for Windows, since char_t* is wchar_t*.

Parameters:

data – String to convert

Returns:

wstring of the converted string, from 8B to 16B chars

std::string FromWString(const std::wstring &str)#
inline constexpr std::string_view SubstrView(const std::string &str, int32_t offset, int32_t endIdx)#
template<uint32_t N1, uint32_t N2>
constexpr auto CompileTimeConcat(const char (&str1)[N1], const char (&str2)[N2])#
namespace Tests#

Functions

inline void CreateTempFile(const std::string &path, const std::string &content)#
inline std::string GenerateRandomString(const std::size_t length)#
inline void DeleteFile(const std::string &path)#
namespace Threading#

Enums

enum class EStealError : uint8_t#

Enumeration for errors that can occur during stealing operations.

Values:

enumerator Empty#

The queue is empty, and no items can be stolen.

enumerator Busy#

The queue is busy, and stealing cannot proceed at this time.

Functions

constexpr uint64_t pack(uint32_t workerHead, uint32_t stealerHead) noexcept#

Pack two 32-bit integers into a 64-bit integer.

Parameters:
  • workerHeadWorker’s head index.

  • stealerHeadStealer’s head index.

Returns:

A 64-bit integer containing both indices packed together.

constexpr std::tuple<uint32_t, uint32_t> unpack(uint64_t value) noexcept#

Unpack a 64-bit integer into two 32-bit integers.

Parameters:

value – The 64-bit integer to unpack.

Returns:

A tuple containing the worker’s head index and the stealer’s head index.

template<typename T>
Task<void> RunOn(Hush::Threading::Concepts::Executor auto *executor, Task<T> task)#
template<typename T>
void SpawnOn(Hush::Threading::Concepts::Executor auto *executor, Task<T> task)#
inline impl::SelfDeleteTask MakeSelfDeleteTask(Task<void> task) noexcept#
template<Concepts::Awaitable A, typename T = typename Concepts::AwaitableTraits<A>::ResultType>
decltype(auto) Wait(A &&awaitable)#
template<Concepts::Awaitable... Awaitables>
auto WhenAll(Awaitables&&... awaitables)#
template<std::ranges::range RangeType, Concepts::Awaitable AwaitableType = typename std::ranges::range_value_t<RangeType>, typename T = typename Concepts::AwaitableTraits<AwaitableType>::ResultType>
auto WhenAll(RangeType awaitables)#
template<typename It, typename Fn>
Task<void> ParallelFor(Hush::Threading::Concepts::Executor auto *executor, It begin, It end, Fn &&function)#

Variables

static constexpr size_t MAX_PARALLEL_TASKS = 1024#
static constexpr size_t MIN_CHUNK_SIZE = 1000#
template<typename T, size_t Size>
class Stealer#
#include <StealingQueue.hpp>

Handle for multi-threaded stealing operations.

Template Parameters:
  • T – The type of the items in the queue.

  • Size – The size of the queue. It must be a power of 2 and less than 2^31.

Public Functions

explicit Stealer(std::shared_ptr<StealingQueue<T, Size>> workerQueue) noexcept#
template<typename F>
Result<std::tuple<uint32_t, uint32_t>, EStealError> Steal(Worker<T, Size> &dest, F &countFunc)#
template<typename F>
Result<std::tuple<T, size_t>, EStealError> StealAndPop(Worker<T, Size> &dest, F &&countFunc)#
template<typename T, size_t Size>
class StealingQueue#
#include <StealingQueue.hpp>

This queue is heavily inspired by the work of asynchronics/st3, which is a Rust implementation of a stealing queue. Its work is MIT-licensed and can be found at: asynchronics/st3

Its work is based on Tokio’s worker queue, itself based on Go scheduler work-stealing queues.

Unlike his implementation, we use a statically-sized array to store the data because it is meant to be used by our thread pool.

This queue is a ring buffer with wrap-around semantics with a tail and a head positions. The actual buffer index is the least significant bits of the tail and head positions.

Template Parameters:
  • T – The type of the elements stored in the queue. It must be a trivial type (non trivial types could be implemented in the future).

  • Size – The size of the queue. It must be a power of 2 and less than 2^31.

Public Functions

inline StealingQueue() noexcept#
StealingQueue(const StealingQueue&) = delete#
StealingQueue &operator=(const StealingQueue&) = delete#
StealingQueue(StealingQueue&&) = delete#
StealingQueue &operator=(StealingQueue&&) = delete#
~StealingQueue() noexcept#
T &ReadAt(uint32_t index) noexcept#

Read an item at the given index in the queue.

This position is mapped to a valid ring buffer index using the mask.

For this to work correctly, the item must have been previously initialized at that index.

Parameters:

index – The index to read from. It must be less than the capacity of the queue.

Returns:

A reference to the item at the given index.

void WriteAt(uint32_t index, T &&value) noexcept#

Write an item at the given index in the queue.

This position is mapped to a valid ring buffer index using the mask.

If a previous item was at that index, it will be overwritten and not destructed. So care must be taken.

Parameters:
  • index – The index to write to.

  • value – The value to write at the given index. It must be a valid item.

template<typename F>
Result<std::tuple<uint32_t, uint32_t>, EStealError> MarkForSteal(F &countFunc, uint32_t maxCount)#

Attempt to mark a range of items for stealing. The amount of items is determined by the provided function countFunc, which is invoked with the number of items available in the queue.

In case of success, it returns a tuple containing the stealer’s head index and the number of items. The number of items is guaranteed to be at least 1.

If the queue is empty, it returns EStealError::Empty. If the queue is busy (concurrent stealing operation), it returns EStealError::Busy.

Template Parameters:

F – The type of the function that will be used to determine the number of items to steal. It must take a size_t and return a size_t.

Parameters:
  • countFunc – The function that will be used to determine the number of items to steal. It is invoked with the number of items available in the queue.

  • maxCount – The maximum number of items to steal. It is used to limit the number of items stolen in case the function returns a larger value than the available items.

Returns:

A Result containing a tuple with the stealer’s head index and the number of items stolen, or an EStealError in case of failure.

inline constexpr uint32_t Capacity() const noexcept#
template<typename T>
class SyncWait#
template<typename T>
class SyncWaitTask#
#include <SyncWait.hpp>

Sync wait task.

Public Types

using promise_type = impl::SyncWaitPromise<T>#
using CoroutineType = std::coroutine_handle<promise_type>#

Public Functions

inline SyncWaitTask(CoroutineType coroutine) noexcept#

Constructor

Parameters:

coroutine – coroutine handle

inline SyncWaitTask(SyncWaitTask &&other) noexcept#

Move constructor

Parameters:

other – Other SyncWaitTask to move from

inline SyncWaitTask &operator=(SyncWaitTask &&other) noexcept#

Move assignment operator

Parameters:

other – Other SyncWaitTask to move from

Returns:

self

inline ~SyncWaitTask()#

Destructor.

inline promise_type &promise() & noexcept#

Returns the promise

Returns:

The promise

inline const promise_type &promise() const & noexcept#

Returns the promise

Returns:

The promise

inline promise_type &&promise() && noexcept#

Returns the promise

Returns:

The promise

inline CoroutineType GetCoroutine() const noexcept#

Returns the coroutine

Returns:

The coroutine

inline CoroutineType GetCoroutine() noexcept#

Returns the coroutine

Returns:

The coroutine

T Result() noexcept#

Returns the result. If the coroutine is not done, it will crash.

Returns:

Get the result

template<typename T>
struct Task#

Public Types

using promise_type = impl::TaskPromise<T>#
using value_type = T#

Public Functions

inline Task() noexcept#
inline explicit Task(std::coroutine_handle<promise_type> coroutine) noexcept#
inline Task(Task &&other) noexcept#
Task(const Task&) = delete#
inline ~Task()#
inline Task &operator=(Task &&other) noexcept#
Task &operator=(const Task&) = delete#
inline bool Ready() const noexcept#
inline bool Resume()#
inline auto operator co_await() const & noexcept#
template<typename U = T>
inline auto operator co_await() const && noexcept#
inline std::coroutine_handle<promise_type> GetCoroutine() const noexcept#
template<typename T, size_t Size>
class Worker#
#include <StealingQueue.hpp>

Handle for single-threaded FIFO operations.

Template Parameters:
  • T – The type of the items in the queue.

  • Size – The size of the queue. It must be a power of 2 and less than 2^31.

Public Functions

Worker() noexcept#
Stealer<T, Size> MakeStealer() noexcept#

Creates a new stealer associated with this worker queue.

Any number of stealers can be created from a single worker queue.

Returns:

A new Stealer instance that can be used to steal items from this worker queue.

size_t Capacity() const noexcept#

Returns the capacity of the worker queue.

Returns:

The capacity of the worker queue, which is equal to Size.

size_t SpareCapacity() const noexcept#

Returns the number of items that can be succesfully pushed onto the queue.

This number might not reflect the real number due to concurrent stealing operations.

Returns:

The number of items that can be succesfully pushed onto the queue.

bool IsEmpty() const noexcept#

Returns true if the worker queue is empty, false otherwise.

While the queue size might not be accurate, it is guaranteed that if a call to IsEmpty() returns true, a subsequent call to Pop() will fail.

Returns:

True if the worker queue is empty, false otherwise.

bool Push(T &&value) noexcept#

Push an item onto the worker queue.

Parameters:

value – The value to push onto the queue. It must be a valid item.

Returns:

True if the item was successfully pushed onto the queue, false if the queue is full.

std::optional<T> Pop() noexcept#

Attempt to pop an item from the head of the queue.

Returns:

An empty optional if the queue is empty, or an optional containing the item if it was successfully popped.

namespace Concepts#

Functions

template<Awaitable A>
static auto GetAwaiter(A &&awaitable)#
template<Awaitable A, typename = void>
struct AwaitableTraits#
template<Awaitable A>
struct AwaitableTraits<A>#

Public Types

using AwaiterType = decltype(GetAwaiter(std::declval<A>()))#
using ResultType = decltype(std::declval<AwaiterType>().await_resume())#
template<typename T, typename = void>
struct ExecutorTraits#
template<typename T>
struct ExecutorTraits<T>#

Public Types

using ReturnType = std::invoke_result_t<decltype(&T::Schedule), T>#

Public Static Attributes

static constexpr bool is_executor = Executor<T>#
namespace Executors#

Variables

static constexpr size_t WORKER_QUEUE_SIZE = 256#
static constexpr size_t GLOBAL_QUEUE_STEALING_COUNT = 64#
thread_local WorkerThread *g_currentWorkerThread = nullptr#
class TaskOperation#

Public Functions

inline bool await_ready() const noexcept#
void await_suspend(std::coroutine_handle<Task<void>::promise_type> awaitingCoroutine) noexcept#
inline void await_resume() noexcept#
class ThreadPool#

Public Functions

~ThreadPool()#
TaskOperation Schedule()#
inline uint32_t GetNumThreads() const noexcept#

Public Static Functions

static ThreadPool Create(ThreadPoolOptions options = ThreadPoolOptions())#
struct ThreadPoolOptions#

Public Members

uint32_t numThreads = std::thread::hardware_concurrency()#
bool pinToCore = false#
class WorkerThread#

Public Functions

inline WorkerThread(ThreadPool &threadpool, std::barrier<> &startBarrier, int32_t threadAffinity)#
inline void SetStealers(std::vector<Stealer<TaskOperation*, WORKER_QUEUE_SIZE>> workers) noexcept#
inline void Wake() noexcept#
inline Stealer<TaskOperation*, WORKER_QUEUE_SIZE> MakeStealer() noexcept#
inline void Stop() noexcept#
inline void Join() noexcept#
namespace impl#

Functions

template<Concepts::Awaitable A, typename T = typename Concepts::AwaitableTraits<A>::ResultType>
static SyncWaitTask<T> MakeSyncWaitTask(A &&awaitable)#
template<Concepts::Awaitable A, typename T = typename Concepts::AwaitableTraits<A>::ResultType>
static WhenAllTask<T> MakeWhenAllTask(A awaitable)#
struct PromiseBase#

Subclassed by Hush::Threading::impl::TaskPromise< T >, Hush::Threading::impl::TaskPromise< T & >, Hush::Threading::impl::TaskPromise< void >

Public Functions

PromiseBase() noexcept = default#
inline std::suspend_always initial_suspend() noexcept#
inline FinalAwaiter final_suspend() noexcept#
inline void SetContinuation(std::coroutine_handle<> coroContinuation) noexcept#

Public Members

std::coroutine_handle continuation#
struct FinalAwaiter#

Public Functions

inline bool await_ready() const noexcept#
template<typename PromiseType>
inline std::coroutine_handle await_suspend(std::coroutine_handle<PromiseType> coroutine) noexcept#
inline void await_resume() noexcept#
class SelfDeletePromise#

Public Functions

inline SelfDeletePromise() noexcept#
SelfDeletePromise(SelfDeletePromise&&) noexcept = default#
SelfDeletePromise(const SelfDeletePromise&) = delete#
SelfDeletePromise &operator=(SelfDeletePromise&&) noexcept = default#
SelfDeletePromise &operator=(const SelfDeletePromise&) = delete#
~SelfDeletePromise() noexcept = default#
inline SelfDeleteTask get_return_object() noexcept#
inline std::suspend_always initial_suspend() noexcept#
inline std::suspend_never final_suspend() noexcept#
inline void return_void() noexcept#
inline void unhandled_exception() noexcept#
class SelfDeleteTask#

Public Types

using promise_type = SelfDeletePromise#

Public Functions

inline explicit SelfDeleteTask(promise_type &promise) noexcept#
inline SelfDeleteTask(SelfDeleteTask &&other) noexcept#
inline SelfDeleteTask &operator=(SelfDeleteTask &&other) noexcept#
SelfDeleteTask(const SelfDeleteTask&) = delete#
SelfDeleteTask &operator=(const SelfDeleteTask&) = delete#
inline promise_type *GetPromise() const noexcept#
inline std::coroutine_handle<promise_type> GetCoroutineHandle() const noexcept#
inline bool Resume() const noexcept#
template<typename T>
struct SyncWaitPromise : public Hush::Threading::impl::SyncWaitPromiseBase#

Public Types

using ResultType = std::conditional_t<std::is_reference_v<T>, std::remove_reference_t<T>*, std::remove_const_t<T>>#
using VariantType = std::variant<std::monostate, ResultType, std::exception_ptr>#
using coroutine_type = std::coroutine_handle<SyncWaitPromise>#

Public Functions

SyncWaitPromise() noexcept = default#
SyncWaitPromise(SyncWaitPromise&&) noexcept = delete#
SyncWaitPromise &operator=(SyncWaitPromise&&) noexcept = delete#
SyncWaitPromise(const SyncWaitPromise&) noexcept = delete#
SyncWaitPromise &operator=(const SyncWaitPromise&) noexcept = delete#
~SyncWaitPromise() = default#
inline std::suspend_always initial_suspend() noexcept#
inline void Start(std::atomic_flag &done) noexcept#
inline auto get_return_object() noexcept#
inline void Wait() noexcept#
template<typename U>
inline void return_value(U &&value) noexcept#
inline void return_value(ResultType value) noexcept#
inline auto final_suspend() noexcept#
inline decltype(auto) Result() &#
inline decltype(auto) Result() const &#
inline decltype(auto) Result() && noexcept#
inline void unhandled_exception() noexcept#
template<>
struct SyncWaitPromise<void> : public Hush::Threading::impl::SyncWaitPromiseBase#

Public Types

using CoroutineType = std::coroutine_handle<SyncWaitPromise>#

Public Functions

SyncWaitPromise() noexcept = default#
~SyncWaitPromise() = default#
inline void Start(std::atomic_flag &done) noexcept#
inline void Wait() noexcept#
inline auto get_return_object() noexcept#
inline auto final_suspend() noexcept#
inline void return_void() noexcept#
inline void Result() noexcept#
inline void unhandled_exception() noexcept#
struct SyncWaitPromiseBase#

Subclassed by Hush::Threading::impl::SyncWaitPromise< T >, Hush::Threading::impl::SyncWaitPromise< void >

Public Functions

SyncWaitPromiseBase() noexcept = default#
inline std::suspend_always initial_suspend() noexcept#
inline void SetFlag(std::atomic_flag &done) noexcept#
template<typename T>
struct TaskPromise : public Hush::Threading::impl::PromiseBase#

Public Functions

inline TaskPromise() noexcept#
Task<T> get_return_object() noexcept#
inline ~TaskPromise()#
inline T &Result() &&#
inline T &Result() &#
inline void return_value(T &&value) noexcept#
inline void unhandled_exception() noexcept#

Public Members

T m_value#
std::exception_ptr m_exception#
template<typename T>
struct TaskPromise<T&> : public Hush::Threading::impl::PromiseBase#

Public Functions

Task<T&> get_return_object() noexcept#
inline T &Result()#
inline void unhandled_exception() noexcept#
template<>
struct TaskPromise<void> : public Hush::Threading::impl::PromiseBase#

Public Functions

inline TaskPromise() noexcept#
inline Task<void> get_return_object() noexcept#
inline void return_void() noexcept#
inline void unhandled_exception() noexcept#
inline void Result() noexcept#
class WhenAllLatch#

Public Functions

inline WhenAllLatch(size_t count) noexcept#
WhenAllLatch(const WhenAllLatch&) = delete#
inline WhenAllLatch(WhenAllLatch &&rhs) noexcept#
WhenAllLatch &operator=(const WhenAllLatch&) = delete#
inline WhenAllLatch &operator=(WhenAllLatch &&rhs) noexcept#
inline bool IsReady() const noexcept#
inline bool TryAwait(std::coroutine_handle<> handle) noexcept#
inline void NotifyCompleted() noexcept#
template<typename TaskContainerType>
class WhenAllReadyAwaitable#

Public Functions

inline explicit WhenAllReadyAwaitable(TaskContainerType &&tasks) noexcept#
WhenAllReadyAwaitable(const WhenAllReadyAwaitable&) = delete#
inline WhenAllReadyAwaitable(WhenAllReadyAwaitable &&rhs) noexcept#
WhenAllReadyAwaitable &operator=(const WhenAllReadyAwaitable&) = delete#
WhenAllReadyAwaitable &operator=(WhenAllReadyAwaitable&&) noexcept = delete#
inline auto operator co_await() & noexcept#
inline auto operator co_await() && noexcept#
template<typename ...TaskTypes>
class WhenAllReadyAwaitable<std::tuple<TaskTypes...>>#

Public Functions

inline explicit WhenAllReadyAwaitable(TaskTypes&&... tasks) noexcept(std::conjunction_v<std::is_nothrow_move_constructible<TaskTypes>...>)#
WhenAllReadyAwaitable(const WhenAllReadyAwaitable&) = delete#
inline WhenAllReadyAwaitable(WhenAllReadyAwaitable &&rhs) noexcept#
WhenAllReadyAwaitable &operator=(const WhenAllReadyAwaitable&) = delete#
WhenAllReadyAwaitable &operator=(WhenAllReadyAwaitable&&) noexcept = delete#
inline auto operator co_await() & noexcept#
inline auto operator co_await() && noexcept#
template<>
class WhenAllReadyAwaitable<std::tuple<>>#

Public Functions

constexpr WhenAllReadyAwaitable() noexcept = default#
inline explicit constexpr WhenAllReadyAwaitable(std::tuple<>) noexcept#
inline constexpr bool await_ready() const noexcept#
inline void await_suspend(std::coroutine_handle<> handle) noexcept#
inline std::tuple await_resume() const noexcept#
template<typename T>
class WhenAllTask#

Public Types

using promise_type = WhenAllTasksPromise<T>#
using coroutine_handle_type = typename promise_type::coroutine_handle_type#

Public Functions

inline WhenAllTask(coroutine_handle_type handle) noexcept#
WhenAllTask(const WhenAllTask&) = delete#
inline WhenAllTask(WhenAllTask &&rhs) noexcept#
WhenAllTask &operator=(const WhenAllTask&) = delete#
inline WhenAllTask &operator=(WhenAllTask &&rhs) noexcept#
inline ~WhenAllTask() noexcept#
inline decltype(auto) return_value() &#
inline decltype(auto) return_value() &&#

Friends

friend class WhenAllReadyAwaitable
template<typename T>
class WhenAllTasksPromise#

Public Types

using coroutine_handle_type = std::coroutine_handle<WhenAllTasksPromise<T>>#

Public Functions

WhenAllTasksPromise() = default#
inline auto get_return_object() noexcept#
inline std::suspend_always initial_suspend() const noexcept#
inline auto final_suspend() noexcept#
inline void unhandle_exception() noexcept#
inline auto yield_value(T &&value) noexcept#
inline void Start(WhenAllLatch &latch) noexcept#
inline T &Result() &#
inline T &&Result() &&#
inline void return_void() noexcept#
template<>
class WhenAllTasksPromise<void>#

Public Types

using coroutine_handle_type = std::coroutine_handle<WhenAllTasksPromise<void>>#

Public Functions

WhenAllTasksPromise() = default#
inline auto get_return_object() noexcept#
inline std::suspend_always initial_suspend() const noexcept#
inline auto final_suspend() noexcept#
inline void unhandled_exception() noexcept#
inline void return_void() noexcept#
inline void Result()#
inline void Start(WhenAllLatch &latch)#
namespace TypeUtils#
namespace Vector3Math#

Functions

inline glm::vec3 Lerp(glm::vec3 from, glm::vec3 to, float t)#
inline constexpr glm::vec3 FromVec4(const glm::vec4 &vec)#

Performs a narrowing conversion from vec4 to vec3.

inline float Magnitude(const glm::vec3 &vec)#

Variables

constexpr glm::vec3 ZERO = glm::vec3(0.0F)#
constexpr glm::vec3 ONE = glm::vec3(1.0F)#
constexpr glm::vec3 RIGHT = glm::vec3(1.0F, 0.0F, 0.0F)#
constexpr glm::vec3 UP = glm::vec3(0.0F, 1.0F, 0.0F)#
constexpr glm::vec3 FORWARD = glm::vec3(0.0F, 0.0F, -1.0F)#
namespace Vector4Math#

Functions

inline constexpr glm::vec4 FromVec3(const glm::vec3 &vec, float w)#

Variables

constexpr glm::vec4 ONE = glm::vec4(1.0F)#