Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
SpriteMaskRange.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
14#pragma once
15
16#include "./DrawList.hpp"
17
18namespace esengine {
19
27
34inline bool maskReaches(const ResolvedMask& mask, const DrawList::SortIdentity& where) {
35 if (!(mask.at < where)) return false;
36 return !mask.limited || where <= mask.reachEnd;
37}
38
47 const ResolvedMask* masks, u32 count, const DrawList::SortIdentity& where
48) {
49 const ResolvedMask* nearest = nullptr;
50 for (u32 i = 0; i < count; ++i) {
51 const ResolvedMask& mask = masks[i];
52 if (mask.ref == 0 || !maskReaches(mask, where)) continue;
53 if (!nearest || nearest->at < mask.at) nearest = &mask;
54 }
55 return nearest;
56}
57
58} // namespace esengine
std::int32_t i32
Signed 32-bit integer.
Definition Types.hpp:54
bool maskReaches(const ResolvedMask &mask, const DrawList::SortIdentity &where)
Whether mask still covers a draw sitting at where.
const ResolvedMask * nearestReachingMask(const ResolvedMask *masks, u32 count, const DrawList::SortIdentity &where)
The mask whose ref the stencil still holds at where, or null.
std::uint32_t u32
Unsigned 32-bit integer.
Definition Types.hpp:45
Where a draw sits in the frame's order, once any group has had its say.
Definition DrawList.hpp:282
A SpriteMask's own place in the frame, how far it reaches, and the ref it stamps.
DrawList::SortIdentity at
DrawList::SortIdentity reachEnd