Files
GhostEngine/Ghost.Entities/Query/QueryFilter.cs
Misaki eed1b9d3d0 Refactor graphics engine dependencies and structure
Removed references to `Misaki.HighPerformance.Unsafe` and replaced them with `Misaki.HighPerformance.LowLevel` in multiple files.
Removed calls to `AllocationManager.Initialize()` and `AllocationManager.Dispose()` in `EngineCore.cs`.
Added new methods to the `ICommandBuffer` interface for enhanced rendering capabilities.
Updated the `D3D12CommandBuffer` class to implement new graphics command handling methods.
Added the `Material` class to manage shader properties and caching for improved performance.
Encapsulated shader compilation and reflection processes within the `Shader` class for better organization.
Added the `CBufferCache` struct to optimize GPU resource management for constant buffer data.
Updated the `MeshRenderPass` class to utilize the new `Material` class for dynamic mesh rendering.
Updated various project files to reflect the restructuring of dependencies.
Modified XAML files and code-behind for improved readability and maintainability.
2025-07-07 22:59:47 +09:00

98 lines
2.1 KiB
C#

using Ghost.Core;
using Misaki.HighPerformance.LowLevel.Collections;
namespace Ghost.Entities.Query;
[Flags]
internal enum FilterMode
{
All = 1 << 0,
Any = 1 << 1,
Absent = 1 << 2,
Disabled = 1 << 3,
}
internal readonly struct FilterEntry(TypeHandle id, FilterMode mode)
{
public readonly TypeHandle typeHandle = id;
public readonly FilterMode mode = mode;
}
internal struct QueryFilter()
{
internal List<TypeHandle> _all = new(6);
internal List<TypeHandle> _any = new(6);
internal List<TypeHandle> _absent = new(6);
internal List<TypeHandle> _disabled = new(6);
public readonly BitSet ComputeFilterBitMask(World world)
{
BitSet? allMask = null;
BitSet? anyMask = null;
BitSet? absentMask = null;
var hasAll = false;
var hasAny = false;
var hasAbsent = false;
foreach (var typeHandle in _all)
{
var mask = world.ComponentStorage.GetOrCreateMask(typeHandle);
if (!hasAll)
{
allMask = new BitSet(mask.Length);
allMask.SetAll();
hasAll = true;
}
allMask &= mask;
}
foreach (var typeHandle in _any)
{
var mask = world.ComponentStorage.GetOrCreateMask(typeHandle);
if (!hasAny)
{
anyMask = new BitSet(mask.Length);
hasAny = true;
}
anyMask |= mask;
}
foreach (var typeHandle in _absent)
{
var mask = world.ComponentStorage.GetOrCreateMask(typeHandle);
if (!hasAbsent)
{
absentMask = new BitSet(mask.Length);
hasAbsent = true;
}
absentMask |= mask;
}
var result = new BitSet(world.EntityManager.EntityCount);
result.SetAll();
if (hasAll)
{
result &= allMask!;
}
if (hasAny)
{
result &= anyMask!;
}
if (hasAbsent)
{
result &= ~absentMask!;
}
return result;
}
}