@@ -30,8 +30,6 @@ class TestVoxelAlgorithms : public TestBase {
30
30
31
31
void runTests (IGameDef *gamedef);
32
32
33
- void testPropogateSunlight (INodeDefManager *ndef);
34
- void testClearLightAndCollectSources (INodeDefManager *ndef);
35
33
void testVoxelLineIterator (INodeDefManager *ndef);
36
34
};
37
35
@@ -41,171 +39,11 @@ void TestVoxelAlgorithms::runTests(IGameDef *gamedef)
41
39
{
42
40
INodeDefManager *ndef = gamedef->getNodeDefManager ();
43
41
44
- TEST (testPropogateSunlight, ndef);
45
- TEST (testClearLightAndCollectSources, ndef);
46
42
TEST (testVoxelLineIterator, ndef);
47
43
}
48
44
49
45
// //////////////////////////////////////////////////////////////////////////////
50
46
51
- void TestVoxelAlgorithms::testPropogateSunlight (INodeDefManager *ndef)
52
- {
53
- VoxelManipulator v;
54
-
55
- for (u16 z = 0 ; z < 3 ; z++)
56
- for (u16 y = 0 ; y < 3 ; y++)
57
- for (u16 x = 0 ; x < 3 ; x++) {
58
- v3s16 p (x,y,z);
59
- v.setNodeNoRef (p, MapNode (CONTENT_AIR));
60
- }
61
-
62
- VoxelArea a (v3s16 (0 ,0 ,0 ), v3s16 (2 ,2 ,2 ));
63
-
64
- {
65
- std::set<v3s16> light_sources;
66
- voxalgo::setLight (v, a, 0 , ndef);
67
- voxalgo::SunlightPropagateResult res = voxalgo::propagateSunlight (
68
- v, a, true , light_sources, ndef);
69
- // v.print(dstream, ndef, VOXELPRINT_LIGHT_DAY);
70
- UASSERT (res.bottom_sunlight_valid == true );
71
- UASSERT (v.getNode (v3s16 (1 ,1 ,1 )).getLight (LIGHTBANK_DAY, ndef)
72
- == LIGHT_SUN);
73
- }
74
-
75
- v.setNodeNoRef (v3s16 (0 ,0 ,0 ), MapNode (t_CONTENT_STONE));
76
-
77
- {
78
- std::set<v3s16> light_sources;
79
- voxalgo::setLight (v, a, 0 , ndef);
80
- voxalgo::SunlightPropagateResult res = voxalgo::propagateSunlight (
81
- v, a, true , light_sources, ndef);
82
- UASSERT (res.bottom_sunlight_valid == true );
83
- UASSERT (v.getNode (v3s16 (1 ,1 ,1 )).getLight (LIGHTBANK_DAY, ndef)
84
- == LIGHT_SUN);
85
- }
86
-
87
- {
88
- std::set<v3s16> light_sources;
89
- voxalgo::setLight (v, a, 0 , ndef);
90
- voxalgo::SunlightPropagateResult res = voxalgo::propagateSunlight (
91
- v, a, false , light_sources, ndef);
92
- UASSERT (res.bottom_sunlight_valid == true );
93
- UASSERT (v.getNode (v3s16 (2 ,0 ,2 )).getLight (LIGHTBANK_DAY, ndef)
94
- == 0 );
95
- }
96
-
97
- v.setNodeNoRef (v3s16 (1 ,3 ,2 ), MapNode (t_CONTENT_STONE));
98
-
99
- {
100
- std::set<v3s16> light_sources;
101
- voxalgo::setLight (v, a, 0 , ndef);
102
- voxalgo::SunlightPropagateResult res = voxalgo::propagateSunlight (
103
- v, a, true , light_sources, ndef);
104
- UASSERT (res.bottom_sunlight_valid == true );
105
- UASSERT (v.getNode (v3s16 (1 ,1 ,2 )).getLight (LIGHTBANK_DAY, ndef)
106
- == 0 );
107
- }
108
-
109
- {
110
- std::set<v3s16> light_sources;
111
- voxalgo::setLight (v, a, 0 , ndef);
112
- voxalgo::SunlightPropagateResult res = voxalgo::propagateSunlight (
113
- v, a, false , light_sources, ndef);
114
- UASSERT (res.bottom_sunlight_valid == true );
115
- UASSERT (v.getNode (v3s16 (1 ,0 ,2 )).getLight (LIGHTBANK_DAY, ndef)
116
- == 0 );
117
- }
118
-
119
- {
120
- MapNode n (CONTENT_AIR);
121
- n.setLight (LIGHTBANK_DAY, 10 , ndef);
122
- v.setNodeNoRef (v3s16 (1 ,-1 ,2 ), n);
123
- }
124
-
125
- {
126
- std::set<v3s16> light_sources;
127
- voxalgo::setLight (v, a, 0 , ndef);
128
- voxalgo::SunlightPropagateResult res = voxalgo::propagateSunlight (
129
- v, a, true , light_sources, ndef);
130
- UASSERT (res.bottom_sunlight_valid == true );
131
- }
132
-
133
- {
134
- std::set<v3s16> light_sources;
135
- voxalgo::setLight (v, a, 0 , ndef);
136
- voxalgo::SunlightPropagateResult res = voxalgo::propagateSunlight (
137
- v, a, false , light_sources, ndef);
138
- UASSERT (res.bottom_sunlight_valid == true );
139
- }
140
-
141
- {
142
- MapNode n (CONTENT_AIR);
143
- n.setLight (LIGHTBANK_DAY, LIGHT_SUN, ndef);
144
- v.setNodeNoRef (v3s16 (1 ,-1 ,2 ), n);
145
- }
146
-
147
- {
148
- std::set<v3s16> light_sources;
149
- voxalgo::setLight (v, a, 0 , ndef);
150
- voxalgo::SunlightPropagateResult res = voxalgo::propagateSunlight (
151
- v, a, true , light_sources, ndef);
152
- UASSERT (res.bottom_sunlight_valid == false );
153
- }
154
-
155
- {
156
- std::set<v3s16> light_sources;
157
- voxalgo::setLight (v, a, 0 , ndef);
158
- voxalgo::SunlightPropagateResult res = voxalgo::propagateSunlight (
159
- v, a, false , light_sources, ndef);
160
- UASSERT (res.bottom_sunlight_valid == false );
161
- }
162
-
163
- v.setNodeNoRef (v3s16 (1 ,3 ,2 ), MapNode (CONTENT_IGNORE));
164
-
165
- {
166
- std::set<v3s16> light_sources;
167
- voxalgo::setLight (v, a, 0 , ndef);
168
- voxalgo::SunlightPropagateResult res = voxalgo::propagateSunlight (
169
- v, a, true , light_sources, ndef);
170
- UASSERT (res.bottom_sunlight_valid == true );
171
- }
172
- }
173
-
174
- void TestVoxelAlgorithms::testClearLightAndCollectSources (INodeDefManager *ndef)
175
- {
176
- VoxelManipulator v;
177
-
178
- for (u16 z = 0 ; z < 3 ; z++)
179
- for (u16 y = 0 ; y < 3 ; y++)
180
- for (u16 x = 0 ; x < 3 ; x++) {
181
- v3s16 p (x,y,z);
182
- v.setNode (p, MapNode (CONTENT_AIR));
183
- }
184
-
185
- VoxelArea a (v3s16 (0 ,0 ,0 ), v3s16 (2 ,2 ,2 ));
186
- v.setNodeNoRef (v3s16 (0 ,0 ,0 ), MapNode (t_CONTENT_STONE));
187
- v.setNodeNoRef (v3s16 (1 ,1 ,1 ), MapNode (t_CONTENT_TORCH));
188
-
189
- {
190
- MapNode n (CONTENT_AIR);
191
- n.setLight (LIGHTBANK_DAY, 1 , ndef);
192
- v.setNode (v3s16 (1 ,1 ,2 ), n);
193
- }
194
-
195
- {
196
- std::set<v3s16> light_sources;
197
- std::map<v3s16, u8> unlight_from;
198
- voxalgo::clearLightAndCollectSources (v, a, LIGHTBANK_DAY,
199
- ndef, light_sources, unlight_from);
200
- // v.print(dstream, ndef, VOXELPRINT_LIGHT_DAY);
201
- UASSERT (v.getNode (v3s16 (0 ,1 ,1 )).getLight (LIGHTBANK_DAY, ndef) == 0 );
202
- UASSERT (light_sources.find (v3s16 (1 ,1 ,1 )) != light_sources.end ());
203
- UASSERT (light_sources.size () == 1 );
204
- UASSERT (unlight_from.find (v3s16 (1 ,1 ,2 )) != unlight_from.end ());
205
- UASSERT (unlight_from.size () == 1 );
206
- }
207
- }
208
-
209
47
void TestVoxelAlgorithms::testVoxelLineIterator (INodeDefManager *ndef)
210
48
{
211
49
// Test some lines
0 commit comments