PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
scene_environment_settings.h
1#pragma once
2
3#include "pixelbullet/filesystem/virtual_path.h"
4#include "pixelbullet/filesystem/virtual_path_serialization.h"
5#include "pixelbullet/serialization/node.h"
6
7#include <array>
8#include <string_view>
9
10namespace pixelbullet
11{
13{
14 bool enabled = false;
15 VirtualPath environment_asset;
16 float background_intensity = 1.0f;
17 float ambient_intensity = 0.15f;
18 float specular_intensity = 1.0f;
19 float exposure = 1.0f;
20
21 [[nodiscard]] bool operator==(const SceneEnvironmentSettings& other) const noexcept
22 {
23 return enabled == other.enabled && environment_asset.LogicalPath() == other.environment_asset.LogicalPath() &&
24 background_intensity == other.background_intensity && ambient_intensity == other.ambient_intensity &&
25 specular_intensity == other.specular_intensity && exposure == other.exposure;
26 }
27
28 [[nodiscard]] bool operator!=(const SceneEnvironmentSettings& other) const noexcept
29 {
30 return !(*this == other);
31 }
32};
33
34inline constexpr std::array<std::string_view, 6> k_scene_environment_cubemap_faces = {
35 "Right", "Left", "Top", "Bottom", "Front", "Back",
36};
37
38inline Node& operator<<(Node& node, const SceneEnvironmentSettings& settings)
39{
40 node["enabled"] << settings.enabled;
41 node["environmentAsset"] << settings.environment_asset;
42 node["backgroundIntensity"] << settings.background_intensity;
43 node["ambientIntensity"] << settings.ambient_intensity;
44 node["specularIntensity"] << settings.specular_intensity;
45 node["exposure"] << settings.exposure;
46 return node;
47}
48
49inline const Node& operator>>(const Node& node, SceneEnvironmentSettings& settings)
50{
51 if (node.HasProperty("enabled"))
52 {
53 node["enabled"] >> settings.enabled;
54 }
55 if (node.HasProperty("environmentAsset"))
56 {
57 node["environmentAsset"] >> settings.environment_asset;
58 }
59 if (node.HasProperty("backgroundIntensity"))
60 {
61 node["backgroundIntensity"] >> settings.background_intensity;
62 }
63 if (node.HasProperty("ambientIntensity"))
64 {
65 node["ambientIntensity"] >> settings.ambient_intensity;
66 }
67 if (node.HasProperty("specularIntensity"))
68 {
69 node["specularIntensity"] >> settings.specular_intensity;
70 }
71 if (node.HasProperty("exposure"))
72 {
73 node["exposure"] >> settings.exposure;
74 }
75 return node;
76}
77} // namespace pixelbullet
Represents a hierarchical node capable of storing various data types and supporting YAML serializatio...
Definition node.h:45
Definition virtual_path.h:10
Definition scene_environment_settings.h:13