@@ -190,6 +190,36 @@ fn animated_atom_uses_texture() {
190
190
)
191
191
}
192
192
193
+ /// For relevantly animated blocks we always prefer textures, even if the voxels are currently all
194
+ /// identical.
195
+ #[ test]
196
+ fn animated_voxels_uses_texture ( ) {
197
+ let mut u = Universe :: new ( ) ;
198
+ let block = Block :: builder ( )
199
+ . voxels_fn ( R2 , |_| const { & color_block ! ( Rgba :: WHITE ) } )
200
+ . unwrap ( )
201
+ . animation_hint ( block:: AnimationHint :: redefinition (
202
+ block:: AnimationChange :: ColorSameCategory ,
203
+ ) )
204
+ . build_into ( & mut u) ;
205
+
206
+ let ( allocator, _, mesh) = mesh_blocks_and_space (
207
+ & Space :: builder ( GridAab :: ORIGIN_CUBE )
208
+ . filled_with ( block)
209
+ . build ( ) ,
210
+ ) ;
211
+
212
+ assert_eq ! ( allocator. count_allocated( ) , 1 ) ;
213
+ assert_eq ! (
214
+ mesh. vertices( ) [ 0 ] . coloring,
215
+ Coloring :: Texture {
216
+ pos: point3( 0.5 , 0. , 0. ) ,
217
+ clamp_min: point3( 0.5 , 0.5 , 0.5 ) ,
218
+ clamp_max: point3( 0.5 , 1.5 , 1.5 )
219
+ }
220
+ )
221
+ }
222
+
193
223
/// We don't encode light emission in vertex colors (because that would lead to bloated vertices),
194
224
/// so a block with light emission will use a texture, even for resolution 1.
195
225
///
@@ -219,7 +249,7 @@ fn emissive_atom_uses_texture() {
219
249
}
220
250
221
251
/// Test handling of the case where `color` is transparent and `light_emission` is nonzero;
222
- /// it should have a nonempty mesh.
252
+ /// for an atom (resolution-1) block; it should have a nonempty mesh.
223
253
#[ test]
224
254
fn emissive_only_atom ( ) {
225
255
let atom_block = Block :: builder ( )
@@ -246,6 +276,36 @@ fn emissive_only_atom() {
246
276
)
247
277
}
248
278
279
+ /// Test handling of the case where `color` is transparent and `light_emission` is nonzero,
280
+ /// for a non-atom (non-resolution-1) block; it should have a nonempty mesh.
281
+ #[ test]
282
+ fn emissive_only_voxels ( ) {
283
+ let mut u = Universe :: new ( ) ;
284
+ let atom_block = Block :: builder ( )
285
+ . color ( Rgba :: TRANSPARENT )
286
+ . light_emission ( Rgb :: ONE )
287
+ . build ( ) ;
288
+ let voxel_block = Block :: builder ( )
289
+ . voxels_fn ( R2 , |cube| {
290
+ if cube == Cube :: ORIGIN {
291
+ & atom_block
292
+ } else {
293
+ & AIR
294
+ }
295
+ } )
296
+ . unwrap ( )
297
+ . build_into ( & mut u) ;
298
+ let ( allocator, block_meshes, space_mesh) = mesh_blocks_and_space (
299
+ & Space :: builder ( GridAab :: ORIGIN_CUBE )
300
+ . filled_with ( voxel_block)
301
+ . build ( ) ,
302
+ ) ;
303
+
304
+ assert ! ( !block_meshes[ 0 ] . is_empty( ) ) ;
305
+ assert ! ( !space_mesh. is_empty( ) ) ;
306
+ assert_eq ! ( allocator. count_allocated( ) , 1 ) ;
307
+ }
308
+
249
309
/// [`SpaceMesh`] of a 1×1×1 space has the same geometry as the contents.
250
310
///
251
311
/// This test compares 3 different values:
0 commit comments