Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
ViewShading.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
7#pragma once
8
10
11#include <unordered_map>
12
13namespace esengine {
14
41
42inline constexpr u8 kShadingModeCount = 7;
43
45inline bool shadesAsClay(ShadingMode mode) {
47}
48
57 bool active() const { return entity != INVALID_ENTITY; }
58};
59
65public:
66 void set(u32 view, ShadingMode mode) {
67 if (mode == ShadingMode::Shaded) modes_.erase(view);
68 else modes_[view] = mode;
69 }
70
71 ShadingMode get(u32 view) const {
72 const auto it = modes_.find(view);
73 return it == modes_.end() ? ShadingMode::Shaded : it->second;
74 }
75
77 usize count() const { return modes_.size() + weights_.size(); }
78
80 void setWeights(u32 view, Entity entity, u32 joint) {
81 if (entity == INVALID_ENTITY) weights_.erase(view);
82 else weights_[view] = {entity, joint};
83 }
84
85 WeightTarget weights(u32 view) const {
86 const auto it = weights_.find(view);
87 return it == weights_.end() ? WeightTarget{} : it->second;
88 }
89
90private:
91 std::unordered_map<u32, ShadingMode> modes_;
92 std::unordered_map<u32, WeightTarget> weights_;
93};
94
95} // namespace esengine
Core type definitions and utilities for ESEngine.
The mode each view asked for. A view that never asked is Shaded, which is why a frame with nothing se...
void setWeights(u32 view, Entity entity, u32 joint)
Colour entity in view by how much joint moves each vertex; an invalid entity stops.
usize count() const
Views holding a non-default mode, for a criterion that checks nothing leaked.
WeightTarget weights(u32 view) const
ShadingMode get(u32 view) const
void set(u32 view, ShadingMode mode)
std::size_t usize
Size type for indexing and sizes.
Definition Types.hpp:64
constexpr Entity INVALID_ENTITY
Invalid entity sentinel value.
Definition Types.hpp:174
bool shadesAsClay(ShadingMode mode)
Whether a mode draws meshes as clay (the lit neutral surface).
std::uint32_t u32
Unsigned 32-bit integer.
Definition Types.hpp:45
std::uint8_t u8
Unsigned 8-bit integer.
Definition Types.hpp:41
ShadingMode
What a mesh is drawn WITH in a view, whatever its own material says.
@ Wireframe
A dark surface with every triangle edge drawn on it, hidden edges hidden.
@ Shaded
Each mesh as authored: its material, its textures, its light.
@ Clay
One neutral matte surface, lit: form and silhouette without anyone's colours.
@ Albedo
Base colour and texture with no light and no material: what was painted.
constexpr u8 kShadingModeCount
Entity identifier with packed index + generation.
Definition Types.hpp:135
The one skinned entity a view colours by a joint's weights, and which joint.