1 // Copyright (C) 2021 Harry Godden (hgn) - All Rights Reserved
6 SHADER_DEFINE( shader_tile_colour
,
9 "layout (location=0) in vec2 a_co;"
11 "uniform vec3 uOffset;"
15 "gl_Position = vec4( uPv * vec3( a_co * uOffset.z + uOffset.xy, 1.0 ), 1.0 );"
20 "uniform vec4 uColour;"
24 "FragColor = uColour;"
27 UNIFORMS({ "uPv", "uOffset", "uColour" })
30 const char *level_pack
[] =
60 "###+##+####;bbb,bb\n"
65 "###-#####-###;a,aaa\n"
72 "######+######;aaaa\n"
77 "###-#####-###;aaa,aa\n"
84 "###+#####+###;aa,aaa\n"
92 #define FLAG_INPUT 0x1
93 #define FLAG_OUTPUT 0x2
94 #define FLAG_CANAL 0x4
96 #define FLAG_DROP_L 0x10
97 #define FLAG_SPLIT 0x20
98 #define FLAG_MERGER 0x40
99 #define FLAG_DROP_R 0x80
100 #define FLAG_FLIP_FLOP 0x100
103 { { 0.9f
, 0.2f
, 0.01f
},
104 { 0.2f
, 0.9f
, 0.14f
},
105 { 0.1f
, 0.3f
, 0.85f
} };
107 static void colour_code_v3( char cc
, v3f target
)
109 if( cc
>= 'a' && cc
<= 'z' )
113 if( id
< vg_list_size( colour_sets
) )
115 v3_copy( colour_sets
[ id
], target
);
120 v3_copy( (v3f
){0.0f
,0.0f
,0.0f
}, target
);
129 static void init_mesh( struct mesh
*m
, float *tris
, u32 length
)
131 m
->elements
= length
/3;
132 glGenVertexArrays( 1, &m
->vao
);
133 glGenBuffers( 1, &m
->vbo
);
135 glBindVertexArray( m
->vao
);
136 glBindBuffer( GL_ARRAY_BUFFER
, m
->vbo
);
137 glBufferData( GL_ARRAY_BUFFER
, length
*sizeof(float), tris
, GL_STATIC_DRAW
);
139 glVertexAttribPointer( 0, 2, GL_FLOAT
, GL_FALSE
, 2 * sizeof(float), (void*)0 );
140 glEnableVertexAttribArray( 0 );
145 static void free_mesh( struct mesh
*m
)
147 glDeleteVertexArrays( 1, &m
->vao
);
148 glDeleteBuffers( 1, &m
->vbo
);
151 static void draw_mesh( int const start
, int const count
)
153 glDrawArrays( GL_TRIANGLES
, start
*3, count
*3 );
156 static void use_mesh( struct mesh
*m
)
158 glBindVertexArray( m
->vao
);
178 // TODO: Split into input/output structures
188 struct mesh tile
, circle
, splitter_l
, splitter_r
;
204 static void map_free(void)
206 for( int i
= 0; i
< arrlen( world
.io
); i
++ )
207 arrfree( world
.io
[ i
].conditions
);
209 arrfree( world
.data
);
218 static int map_load( const char *str
)
227 if( str
[world
.w
] == ';' )
229 else if( !str
[world
.w
] )
231 vg_error( "Unexpected EOF when parsing level\n" );
236 struct cell
*row
= arraddnptr( world
.data
, world
.w
);
238 int reg_start
= 0, reg_end
= 0;
254 if( reg_start
< reg_end
)
256 if( *c
>= 'a' && *c
<= 'z' )
258 arrpush( world
.io
[ reg_start
].conditions
, *c
);
262 if( *c
== ',' || *c
== '\n' )
271 vg_error( "Unkown attribute '%c' (row: %u)\n", *c
, world
.h
);
278 vg_error( "Too many values to assign (row: %u)\n", world
.h
);
286 if( reg_start
!= reg_end
)
288 vg_error( "Not enough values assigned (row: %u, %u of %u)\n", world
.h
, reg_start
, reg_end
);
294 vg_error( "Not enough cells to match previous row definition (row: %u, %u<%u)\n", world
.h
, cx
, world
.w
);
298 row
= arraddnptr( world
.data
, world
.w
);
301 reg_end
= reg_start
= arrlen( world
.io
);
307 vg_error( "Too many cells to match previous row definition (row: %u, %u>%u)\n", world
.h
, cx
, world
.w
);
311 // Tile initialization
314 if( *c
== '+' || *c
== '-' )
316 struct cell_terminal term
= { .id
= cx
+ world
.h
*world
.w
};
317 arrpush( world
.io
, term
);
318 row
[ cx
++ ].state
= *c
== '+'? FLAG_INPUT
: FLAG_OUTPUT
;
323 row
[ cx
++ ].state
= FLAG_WALL
;
327 row
[ cx
++ ].state
= 0x00;
334 vg_success( "Map loaded! (%u:%u)\n", world
.w
, world
.h
);
338 static struct cell
*pcell( v2i pos
)
340 return &world
.data
[ pos
[1]*world
.w
+ pos
[0] ];
343 int main( int argc
, char *argv
[] )
345 vg_init( argc
, argv
, "Fish (Marbles Computer) Ladder Simulator 2022 | N,M: change level | SPACE: Test | LeftClick: Toggle tile" );
348 void vg_register(void)
350 SHADER_INIT( shader_tile_colour
);
359 0.0f
, 0.0f
, 0.0f
, 1.0f
, 1.0f
, 1.0f
,
360 0.0f
, 0.0f
, 1.0f
, 1.0f
, 1.0f
, 0.0f
,
362 0.48f
, 0.48f
, 0.5f
, 0.52f
, 0.52f
, 0.52f
, // Static dot
363 0.375f
, 0.25f
, 0.5f
, 0.75f
, 0.625f
, 0.25f
, // Downwards pointing arrow
364 0.25f
, 0.625f
, 0.75f
, 0.5f
, 0.25f
, 0.375f
, // Left
365 0.625f
, 0.75f
, 0.5f
, 0.25f
, 0.375f
, 0.75f
, // up
366 0.75f
, 0.375f
, 0.25f
, 0.5f
, 0.75f
, 0.625f
369 init_mesh( &world
.tile
, quad_mesh
, vg_list_size(quad_mesh
) );
374 float circle_mesh
[32*6*3];
375 int res
= vg_list_size( circle_mesh
) / (6*3);
377 for( int i
= 0; i
< res
; i
++ )
379 v2f v0
= { sinf( ((float)i
/(float)res
)*VG_TAUf
), cosf( ((float)i
/(float)res
)*VG_TAUf
) };
380 v2f v1
= { sinf( ((float)(i
+1)/(float)res
)*VG_TAUf
), cosf( ((float)(i
+1)/(float)res
)*VG_TAUf
) };
382 circle_mesh
[ i
*6+0 ] = 0.0f
;
383 circle_mesh
[ i
*6+1 ] = 0.0f
;
385 v2_copy( v0
, circle_mesh
+ 32*6 + i
*12 );
386 v2_muls( v0
, 0.8f
, circle_mesh
+ 32*6 + i
*12+2 );
387 v2_copy( v1
, circle_mesh
+ 32*6 + i
*12+4 );
389 v2_copy( v1
, circle_mesh
+ 32*6 + i
*12+6 );
390 v2_muls( v1
, 0.8f
, circle_mesh
+ 32*6 + i
*12+8 );
391 v2_muls( v0
, 0.8f
, circle_mesh
+ 32*6 + i
*12+10 );
393 v2_copy( v0
, circle_mesh
+ i
*6+4 );
394 v2_copy( v1
, circle_mesh
+ i
*6+2 );
395 v2_copy( v0
, circle_mesh
+i
*6+4 );
396 v2_copy( v1
, circle_mesh
+i
*6+2 );
399 init_mesh( &world
.circle
, circle_mesh
, vg_list_size( circle_mesh
) );
406 #include "models/splitter_l.obj.h"
410 #include "models/splitter_r.obj.h"
413 init_mesh( &world
.splitter_l
, splitter_l
, vg_list_size( splitter_l
) );
414 init_mesh( &world
.splitter_r
, splitter_r
, vg_list_size( splitter_r
) );
417 map_load( level_pack
[ 0 ] );
424 free_mesh( &world
.tile
);
425 free_mesh( &world
.circle
);
426 free_mesh( &world
.splitter_l
);
427 free_mesh( &world
.splitter_r
);
433 static int cell_interactive( v2i co
)
436 if( co
[0] < 2 || co
[0] >= world
.w
-2 || co
[1] < 2 || co
[1] >= world
.h
-2 )
440 if( world
.data
[ world
.w
*co
[1] + co
[0] ].state
& (FLAG_WALL
|FLAG_INPUT
|FLAG_OUTPUT
) )
443 // List of 3x3 configurations that we do not allow
444 static u32 invalid_src
[][9] =
476 // Statically compile invalid configurations into bitmasks
477 static u32 invalid
[ vg_list_size(invalid_src
) ];
479 for( int i
= 0; i
< vg_list_size(invalid_src
); i
++ )
483 for( int j
= 0; j
< 3; j
++ )
484 for( int k
= 0; k
< 3; k
++ )
485 comped
|= invalid_src
[i
][ j
*3+k
] << ((j
*5)+k
);
490 // Extract 5x5 grid surrounding tile
492 for( int y
= co
[1]-2; y
< co
[1]+3; y
++ )
493 for( int x
= co
[0]-2; x
< co
[0]+3; x
++ )
495 struct cell
*cell
= pcell((v2i
){x
,y
});
497 if( cell
&& (cell
->state
& (FLAG_CANAL
|FLAG_INPUT
|FLAG_OUTPUT
)) )
498 blob
|= 0x1 << ((y
-(co
[1]-2))*5 + x
-(co
[0]-2));
501 // Run filter over center 3x3 grid to check for invalid configurations
502 int kernel
[] = { 0, 1, 2, 5, 6, 7, 10, 11, 12 };
503 for( int i
= 0; i
< vg_list_size(kernel
); i
++ )
505 if( blob
& (0x1 << (6+kernel
[i
])) )
507 u32 window
= blob
>> kernel
[i
];
509 for( int j
= 0; j
< vg_list_size(invalid
); j
++ )
510 if((window
& invalid
[j
]) == invalid
[j
])
520 static int curlevel
= 0;
521 int changelvl
= curlevel
;
522 if( vg_get_button_down( "prev" ) ) { if( curlevel
> 0 ) changelvl
--; }
523 else if( vg_get_button_down( "next" ) ) { if( curlevel
< vg_list_size( level_pack
)-1 ) changelvl
++; }
525 if( changelvl
!= curlevel
)
527 map_load( level_pack
[ changelvl
] );
528 curlevel
= changelvl
;
531 world
.simulating
= 0;
532 world
.num_fishes
= 0;
535 for( int i
= 0; i
< arrlen( world
.io
); i
++ )
536 world
.io
[i
].recv_count
= 0;
538 vg_info( "Stopping simulation!\n" );
541 float ratio
= (float)vg_window_y
/ (float)vg_window_x
;
542 float const size
= 9.5f
;
545 origin
[0] = -0.5f
* world
.w
;
546 origin
[1] = -0.5f
* world
.h
;
549 m3x3_projection( m_projection
, -size
, size
, -size
*ratio
, size
*ratio
);
550 m3x3_identity( m_view
);
551 m3x3_translate( m_view
, origin
);
552 m3x3_mul( m_projection
, m_view
, vg_pv
);
553 vg_projection_update();
558 v2_copy( vg_mouse_ws
, tile_pos
);
560 int tile_x
= floorf( tile_pos
[0] );
561 int tile_y
= floorf( tile_pos
[1] );
564 if( !world
.simulating
)
566 if( cell_interactive( (v2i
){ tile_x
, tile_y
} ))
568 world
.selected
= tile_y
* world
.w
+ tile_x
;
570 if( vg_get_button_down("primary") )
572 world
.data
[ world
.selected
].state
^= FLAG_CANAL
;
579 // Simulation stop/start
580 if( vg_get_button_down("go") )
582 if( world
.simulating
)
584 world
.simulating
= 0;
585 world
.num_fishes
= 0;
588 for( int i
= 0; i
< arrlen( world
.io
); i
++ )
589 world
.io
[i
].recv_count
= 0;
591 vg_info( "Stopping simulation!\n" );
595 vg_success( "Starting simulation!\n" );
597 world
.simulating
= 1;
598 world
.num_fishes
= 0;
600 world
.sim_start
= vg_time
;
602 for( int i
= 0; i
< world
.w
*world
.h
; i
++ )
604 world
.data
[ i
].state
&= ~FLAG_FLIP_FLOP
;
607 for( int i
= 0; i
< arrlen( world
.io
); i
++ )
608 world
.io
[i
].recv_count
= 0;
613 // ========================================================
615 // Reclassify world. TODO: Move into own function
616 for( int y
= 2; y
< world
.h
-2; y
++ )
618 for( int x
= 2; x
< world
.w
-2; x
++ )
620 v2i dirs
[] = {{1,0},{0,1},{-1,0},{0,-1}};
624 if( pcell((v2i
){x
,y
})->state
& FLAG_CANAL
)
626 for( int i
= 0; i
< vg_list_size( dirs
); i
++ )
628 struct cell
*neighbour
= pcell((v2i
){x
+dirs
[i
][0], y
+dirs
[i
][1]});
629 if( neighbour
->state
& (FLAG_CANAL
|FLAG_INPUT
|FLAG_OUTPUT
) )
634 pcell((v2i
){x
,y
})->config
= config
;
635 pcell((v2i
){x
,y
})->state
&= ~(FLAG_DROP_L
|FLAG_DROP_R
|FLAG_SPLIT
|FLAG_MERGER
);
639 for( int y
= 2; y
< world
.h
-2; y
++ )
640 for( int x
= 2; x
< world
.w
-2; x
++ )
642 // R,D,L,- 1110 (splitter, 1 drop created)
644 // R,-,L,U - 1011 (merger, 2 drop created)
646 u8 config
= pcell((v2i
){x
,y
})->config
;
648 if( config
== 0x7 ) // splitter
650 world
.data
[y
*world
.w
+x
].state
|= (FLAG_SPLIT
| FLAG_DROP_L
| FLAG_DROP_R
);
652 else if( config
== 0xD )
654 world
.data
[y
*world
.w
+x
-1].state
|= FLAG_DROP_R
;
655 world
.data
[y
*world
.w
+x
+1].state
|= FLAG_DROP_L
;
656 world
.data
[y
*world
.w
+x
].state
|= FLAG_MERGER
;
661 if( world
.simulating
)
663 while( world
.sim_frame
< (int)((vg_time
-world
.sim_start
)*2.0f
) )
665 vg_info( "frame: %u\n", world
.sim_frame
);
667 for( int i
= 0; i
< arrlen( world
.io
); i
++ )
669 struct cell_terminal
*term
= &world
.io
[ i
];
670 int posx
= term
->id
% world
.w
;
671 int posy
= (term
->id
- posx
)/world
.w
;
672 int is_input
= world
.data
[ term
->id
].state
& FLAG_INPUT
;
676 if( world
.sim_frame
< arrlen( term
->conditions
) )
678 struct fish
*fish
= &world
.fishes
[world
.num_fishes
++];
682 fish
->payload
= term
->conditions
[world
.sim_frame
];
686 v2i dirs
[] = {{1,0},{-1,0},{0,-1}};
687 for( int j
= 0; j
< vg_list_size(dirs
); j
++ )
688 if( pcell( (v2i
){ posx
+dirs
[j
][0], posy
+dirs
[j
][1] } )->state
& FLAG_CANAL
)
690 fish
->dir
[0] = dirs
[j
][0];
691 fish
->dir
[1] = dirs
[j
][1];
702 for( int i
= 0; i
< world
.num_fishes
; i
++ )
704 struct fish
*fish
= &world
.fishes
[i
];
705 struct cell
*cell_current
= pcell( fish
->pos
);
711 if( cell_current
->state
& FLAG_OUTPUT
)
713 for( int j
= 0; j
< arrlen( world
.io
); j
++ )
715 struct cell_terminal
*term
= &world
.io
[j
];
717 if( term
->id
== fish
->pos
[1]*world
.w
+ fish
->pos
[0] )
719 term
->recv
[ term
->recv_count
++ ] = fish
->payload
;
728 if( !(cell_current
->state
& (FLAG_INPUT
|FLAG_CANAL
)) )
734 if( cell_current
->state
& FLAG_SPLIT
)
737 fish
->dir
[0] = cell_current
->state
&FLAG_FLIP_FLOP
?1:-1;
740 cell_current
->state
^= FLAG_FLIP_FLOP
;
742 else if( cell_current
->state
& FLAG_MERGER
)
750 struct cell
*cell_next
= pcell( (v2i
){ fish
->pos
[0]+fish
->dir
[0], fish
->pos
[1]+fish
->dir
[1] } );
751 if( !(cell_next
->state
& (FLAG_CANAL
|FLAG_OUTPUT
)) )
753 // Try other directions for valid, so down, left, right..
754 v2i dirs
[] = {{1,0},{-1,0},{0,-1}};
755 vg_info( "Trying some other directions...\n" );
757 for( int j
= 0; j
< vg_list_size(dirs
); j
++ )
759 if( (dirs
[j
][0] == -fish
->dir
[0]) && (dirs
[j
][1] == -fish
->dir
[1]) )
762 if( pcell( (v2i
){ fish
->pos
[0]+dirs
[j
][0], fish
->pos
[1]+dirs
[j
][1] } )->state
& (FLAG_CANAL
|FLAG_OUTPUT
) )
764 fish
->dir
[0] = dirs
[j
][0];
765 fish
->dir
[1] = dirs
[j
][1];
771 fish
->pos
[0] += fish
->dir
[0];
772 fish
->pos
[1] += fish
->dir
[1];
783 glViewport( 0,0, vg_window_x
, vg_window_y
);
785 glDisable( GL_DEPTH_TEST
);
786 glClearColor( 0.8f
, 0.8f
, 0.8f
, 1.0f
);
787 glClear( GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
789 use_mesh( &world
.tile
);
790 SHADER_USE( shader_tile_colour
);
791 glUniformMatrix3fv( SHADER_UNIFORM( shader_tile_colour
, "uPv" ), 1, GL_FALSE
, (float *)vg_pv
);
794 glUniform4f( SHADER_UNIFORM( shader_tile_colour
, "uColour" ), 0.5f
, 0.5f
, 0.5f
, 1.0f
);
795 for( int y
= 0; y
< world
.h
; y
++ )
796 for( int x
= 0; x
< world
.w
; x
++ )
798 struct cell
*cell
= pcell((v2i
){x
,y
});
800 if( cell
->state
& FLAG_CANAL
)
805 glUniform3f( SHADER_UNIFORM( shader_tile_colour
, "uOffset" ), (float)x
- 0.2f
, (float)y
- 0.15f
, 1.0f
);
809 for( int y
= 0; y
< world
.h
; y
++ )
811 for( int x
= 0; x
< world
.w
; x
++ )
813 struct cell
*cell
= pcell((v2i
){x
,y
});
814 int selected
= world
.selected
== y
*world
.w
+ x
;
816 if( cell
->state
& FLAG_SPLIT
)
818 glUniform4f( SHADER_UNIFORM( shader_tile_colour
, "uColour" ), 0.9f
, 0.9f
, 0.9f
, 1.0f
);
819 glUniform3f( SHADER_UNIFORM( shader_tile_colour
, "uOffset" ), (float)x
, (float)y
, 1.0f
);
821 struct mesh
*splitter
= cell
->state
& FLAG_FLIP_FLOP
? &world
.splitter_r
: &world
.splitter_l
;
823 use_mesh( splitter
);
824 draw_mesh( 0, splitter
->elements
);
825 use_mesh( &world
.tile
);
828 if( (cell
->state
& FLAG_CANAL
) && !selected
)
831 glUniform3f( SHADER_UNIFORM( shader_tile_colour
, "uOffset" ), (float)x
, (float)y
, 1.0f
);
835 if( cell
->state
& FLAG_WALL
) { v4_copy( (v4f
){ 0.2f
, 0.2f
, 0.2f
, 1.0f
}, colour
); }
836 else if( cell
->state
& FLAG_CANAL
) { v4_copy( (v4f
){ 0.6f
, 0.6f
, 0.6f
, 1.0f
}, colour
); }
837 else if( cell
->state
& FLAG_INPUT
) { v4_copy( (v4f
){ 0.5f
, 0.5f
, 0.5f
, 1.0f
}, colour
); }
838 else if( cell
->state
& FLAG_OUTPUT
) { v4_copy( (v4f
){ 0.4f
, 0.4f
, 0.4f
, 1.0f
}, colour
); }
839 else v4_copy( (v4f
){ 0.9f
, 0.9f
, 0.9f
, 1.0f
}, colour
);
841 //if( cell->water[world.frame&0x1] )
842 // v4_copy( (v4f){ 0.2f, 0.3f, 0.7f * (float)(cell->water[world.frame&0x1]) * (1.0f/16.0f), 1.0f }, colour );
845 v3_muls( colour
, sinf( vg_time
)*0.25f
+ 0.5f
, colour
);
847 //if( cell->state & (FLAG_SPLIT) )
848 // v4_copy( (v4f){ 0.75f, 0.75f, 0.02f, 1.0f }, colour );
849 //if( cell->state & (FLAG_MERGER) )
850 // v4_copy( (v4f){ 0.75f, 0.02f, 0.75f, 1.0f }, colour );
852 glUniform4fv( SHADER_UNIFORM( shader_tile_colour
, "uColour" ), 1, colour
);
858 use_mesh( &world
.circle
);
861 for( int i
= 0; i
< arrlen( world
.io
); i
++ )
863 struct cell_terminal
*term
= &world
.io
[ i
];
864 int posx
= term
->id
% world
.w
;
865 int posy
= (term
->id
- posx
)/world
.w
;
866 int is_input
= world
.data
[ term
->id
].state
& FLAG_INPUT
;
868 int const filled_start
= 0;
869 int const filled_count
= 32;
870 int const empty_start
= 32;
871 int const empty_count
= 32*2;
873 v4f dot_colour
= { 0.0f
, 0.0f
, 0.0f
, 1.0f
};
875 for( int j
= 0; j
< arrlen( term
->conditions
); j
++ )
877 glUniform3f( SHADER_UNIFORM( shader_tile_colour
, "uOffset" ), (float)posx
+ 0.2f
+ 0.2f
* (float)j
, (float)posy
+ 0.2f
, 0.1f
);
881 colour_code_v3( term
->conditions
[j
], dot_colour
);
882 glUniform4fv( SHADER_UNIFORM( shader_tile_colour
, "uColour" ), 1, dot_colour
);
884 // Draw filled if tick not passed, draw empty if empty
885 if( world
.sim_frame
> j
)
886 draw_mesh( empty_start
, empty_count
);
888 draw_mesh( filled_start
, filled_count
);
892 if( term
->recv_count
> j
)
894 colour_code_v3( term
->recv
[j
], dot_colour
);
895 v3_muls( dot_colour
, 0.8f
, dot_colour
);
896 glUniform4fv( SHADER_UNIFORM( shader_tile_colour
, "uColour" ), 1, dot_colour
);
898 draw_mesh( filled_start
, filled_count
);
901 colour_code_v3( term
->conditions
[j
], dot_colour
);
902 glUniform4fv( SHADER_UNIFORM( shader_tile_colour
, "uColour" ), 1, dot_colour
);
904 draw_mesh( empty_start
, empty_count
);
910 if( world
.simulating
)
912 float scaled_time
= (vg_time
-world
.sim_start
)*2.0f
;
913 float lerp
= 1.0f
-(scaled_time
- (float)world
.sim_frame
);
915 v4f dot_colour
= { 0.0f
, 0.0f
, 0.0f
, 1.0f
};
917 for( int i
= 0; i
< world
.num_fishes
; i
++ )
919 struct fish
*fish
= &world
.fishes
[i
];
924 colour_code_v3( fish
->payload
, dot_colour
);
925 glUniform4fv( SHADER_UNIFORM( shader_tile_colour
, "uColour" ), 1, dot_colour
);
927 glUniform3f( SHADER_UNIFORM( shader_tile_colour
, "uOffset" ), (float)fish
->pos
[0] + 0.5f
- (float)fish
->dir
[0]*lerp
, (float)fish
->pos
[1] + 0.25f
- (float)fish
->dir
[1]*lerp
, 0.25f
);
932 if( world
.simulating
)
934 glUniform4f( SHADER_UNIFORM( shader_tile_colour
, "uColour" ), 0.0f
, 0.0f
, 0.0f
, 1.0f
);
935 glUniform3f( SHADER_UNIFORM( shader_tile_colour
, "uOffset" ), -0.5f
+ cosf( vg_time
* 4.0f
) * 0.2f
, sinf( vg_time
* 4.0f
) * 0.2f
+ (float)world
.h
* 0.5f
, 0.05f
);