Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/servers/rendering/dummy/storage/light_storage.cpp
10279 views
1
/**************************************************************************/
2
/* light_storage.cpp */
3
/**************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* https://godotengine.org */
7
/**************************************************************************/
8
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10
/* */
11
/* Permission is hereby granted, free of charge, to any person obtaining */
12
/* a copy of this software and associated documentation files (the */
13
/* "Software"), to deal in the Software without restriction, including */
14
/* without limitation the rights to use, copy, modify, merge, publish, */
15
/* distribute, sublicense, and/or sell copies of the Software, and to */
16
/* permit persons to whom the Software is furnished to do so, subject to */
17
/* the following conditions: */
18
/* */
19
/* The above copyright notice and this permission notice shall be */
20
/* included in all copies or substantial portions of the Software. */
21
/* */
22
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29
/**************************************************************************/
30
31
#include "light_storage.h"
32
33
using namespace RendererDummy;
34
35
LightStorage *LightStorage::singleton = nullptr;
36
37
LightStorage *LightStorage::get_singleton() {
38
return singleton;
39
}
40
41
LightStorage::LightStorage() {
42
singleton = this;
43
}
44
45
LightStorage::~LightStorage() {
46
singleton = nullptr;
47
}
48
49
bool LightStorage::free(RID p_rid) {
50
if (owns_lightmap(p_rid)) {
51
lightmap_free(p_rid);
52
return true;
53
} else if (owns_lightmap_instance(p_rid)) {
54
lightmap_instance_free(p_rid);
55
return true;
56
}
57
58
return false;
59
}
60
61
/* LIGHTMAP API */
62
63
RID LightStorage::lightmap_allocate() {
64
return lightmap_owner.allocate_rid();
65
}
66
67
void LightStorage::lightmap_initialize(RID p_lightmap) {
68
lightmap_owner.initialize_rid(p_lightmap, Lightmap());
69
}
70
71
void LightStorage::lightmap_free(RID p_rid) {
72
lightmap_set_textures(p_rid, RID(), false);
73
lightmap_owner.free(p_rid);
74
}
75
76
/* LIGHTMAP INSTANCE */
77
78
RID LightStorage::lightmap_instance_create(RID p_lightmap) {
79
LightmapInstance li;
80
li.lightmap = p_lightmap;
81
return lightmap_instance_owner.make_rid(li);
82
}
83
84
void LightStorage::lightmap_instance_free(RID p_lightmap) {
85
lightmap_instance_owner.free(p_lightmap);
86
}
87
88