Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Include/Misc/PipeDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,14 @@ namespace p
DebugECSContext ecs;
DebugReflectContext reflect;

EntityContext* ctx = nullptr;
IdContext* ctx = nullptr;

bool initialized = false;
bool isFirstDebug = true;


DebugContext() = default;
DebugContext(EntityContext& ctx) : ctx{&ctx} {}
DebugContext(IdContext& ctx) : ctx{&ctx} {}
};

bool BeginDebug(DebugContext& Context);
Expand Down Expand Up @@ -221,7 +221,7 @@ namespace p


// For internal use only
EntityContext& GetDebugCtx()
IdContext& GetDebugCtx()
{
return *currentContext->ctx;
}
Expand Down Expand Up @@ -552,7 +552,7 @@ namespace p
#pragma region ECS
i32 DebugECSInspector::uniqueIdCounter = 0;

using DrawNodeAccess = TAccessRef<CParent, CChild>;
using DrawNodeAccess = TIdScopeRef<CParent, CChild>;
namespace details
{
bool ChooseTypePopup(const char* label, ImGuiTextFilter& filter, TypeId& selectedTypeId)
Expand Down Expand Up @@ -1282,7 +1282,7 @@ namespace p
return false;
}

if (!P_EnsureMsg(context.ctx, "Debug Context does not contain a valid EntityContext."))
if (!P_EnsureMsg(context.ctx, "Debug Context does not contain a valid IdContext."))
{
return false;
}
Expand Down
58 changes: 38 additions & 20 deletions Include/Pipe/Core/EnumFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,73 +7,91 @@

namespace p
{
template<Integral I>
constexpr bool HasAllFlags(I value, I flags) noexcept
{
return (value & flags) == flags;
}

template<Integral I>
constexpr bool HasAnyFlags(I value, I flags) noexcept
{
return (value & flags) != 0;
}

template<Integral I>
constexpr bool HasFlag(I value, I flag) noexcept
{
return HasAllFlags(value, flag);
}

namespace EnumOperators
{
// Bitwise operators: ~, |, &, ^, |=, &=, ^=
using namespace magic_enum::bitwise_operators;

template<typename E>
constexpr UnderlyingType<E> operator*(E value) noexcept requires(IsEnum<E>)
template<IsEnum E>
constexpr UnderlyingType<E> operator*(E value) noexcept
{
return static_cast<UnderlyingType<E>>(value);
}

template<typename E>
constexpr E operator|(E lhs, E rhs) noexcept requires(IsEnum<E>)
template<IsEnum E>
constexpr E operator|(E lhs, E rhs) noexcept
{
return static_cast<E>(
static_cast<UnderlyingType<E>>(lhs) | static_cast<UnderlyingType<E>>(rhs));
}
} // namespace EnumOperators

template<typename E>
constexpr bool HasAllFlags(E value, E flags) noexcept requires(IsEnum<E>)
template<IsEnum E>
constexpr bool HasAllFlags(E value, E flags) noexcept
{
return (static_cast<UnderlyingType<E>>(value) & static_cast<UnderlyingType<E>>(flags))
== static_cast<UnderlyingType<E>>(flags);
}

template<typename E>
constexpr bool HasAnyFlags(E value, E flags) noexcept requires(IsEnum<E>)
template<IsEnum E>
constexpr bool HasAnyFlags(E value, E flags) noexcept
{
return (static_cast<UnderlyingType<E>>(value) & static_cast<UnderlyingType<E>>(flags)) != 0;
}

template<typename E, typename R = UnderlyingType<E>>
constexpr bool HasAllFlags(R value, E flags) noexcept requires(IsEnum<E>)
template<IsEnum E, typename R = UnderlyingType<E>>
constexpr bool HasAllFlags(R value, E flags) noexcept
{
return (static_cast<R>(value) & static_cast<UnderlyingType<E>>(flags))
== static_cast<UnderlyingType<E>>(flags);
}

template<typename E, typename R = UnderlyingType<E>>
constexpr bool HasAnyFlags(R value, E flags) noexcept requires(IsEnum<E>)
template<IsEnum E, typename R = UnderlyingType<E>>
constexpr bool HasAnyFlags(R value, E flags) noexcept
{
return (static_cast<R>(value) & static_cast<UnderlyingType<E>>(flags)) != 0;
}

template<typename E>
constexpr bool HasFlag(E value, E flag) noexcept requires(IsEnum<E>)
template<IsEnum E>
constexpr bool HasFlag(E value, E flag) noexcept
{
return HasAllFlags(value, flag);
}

template<typename E, typename R = UnderlyingType<E>>
constexpr bool HasFlag(R value, E flag) noexcept requires(IsEnum<E>)
template<IsEnum E, typename R = UnderlyingType<E>>
constexpr bool HasFlag(R value, E flag) noexcept
{
return HasAllFlags(value, flag);
}

template<typename E>
void AddFlags(E& value, E flags) noexcept requires(IsEnum<E>)
template<IsEnum E>
void AddFlags(E& value, E flags) noexcept
{
auto rawValue = static_cast<UnderlyingType<E>>(value);
rawValue |= static_cast<UnderlyingType<E>>(flags);
value = static_cast<E>(rawValue);
}

template<typename E>
void RemoveFlags(E& value, E flags) noexcept requires(IsEnum<E>)
template<IsEnum E>
void RemoveFlags(E& value, E flags) noexcept
{
auto rawValue = static_cast<UnderlyingType<E>>(value);
rawValue &= ~static_cast<UnderlyingType<E>>(flags);
Expand Down
Loading
Loading