if( sprite_type != k_audio_sprite_type_none ){
if( sprite_type == k_audio_sprite_type_grass ){
- audio_ambient_sprite_play( sprite_pos, &audio_grass[vg_randu32()%4] );
+ audio_ambient_sprite_play( sprite_pos,
+ &audio_grass[vg_randu32(&vg.rand)%4] );
}
else if( sprite_type == k_audio_sprite_type_water ){
if( world->water.enabled ){
audio_ambient_sprite_play( sprite_pos,
- &audio_water[vg_randu32()%6] );
+ &audio_water[vg_randu32(&vg.rand)%6] );
}
}
}
v3_tangent_basis( dir, tx, ty );
v3f rand;
- vg_rand_cone( rand, angle );
+ vg_rand_cone( &vg.rand, rand, angle );
v3_muls( tx, rand[0]*speed, p->v );
v3_muladds( p->v, ty, rand[1]*speed, p->v );
v3_muladds( p->v, dir, rand[2]*speed, p->v );
static void effect_blink_apply( effect_blink *ef, player_pose *pose, f32 dt ){
if( ef->t < 0.0f ){
- ef->t = (1.0f-powf(vg_randf64(),4.0f))*4.0f;
+ ef->t = (1.0f-powf(vg_randf64(&vg.rand),4.0f))*4.0f;
ef->l = 0.08f;
}
if( !ef->colour ) return;
if( ef->t < 0.0f ){
- ef->t = 0.05f+vg_randf64()*0.1f;
+ ef->t = 0.05f+vg_randf64(&vg.rand)*0.1f;
v3f dir;
v3_copy( v, dir );
if( stress ){
temp_filter = 20;
audio_lock();
- audio_oneshot_3d( &audio_hits[vg_randu32()%5], stress->co, 20.0f, 1.0f );
+ audio_oneshot_3d( &audio_hits[vg_randu32(&vg.rand)%5],
+ stress->co, 20.0f, 1.0f );
audio_unlock();
}
}
for( int i=0; i<NETWORK_MAX_PLAYERS; i ++ ){
struct network_player *player = &netplayers.list[i];
- player->active = (vg_randu32() & 0x1)? 2: 0;
- player->isfriend = vg_randu32() & vg_randu32() & 0x1;
- player->isblocked = vg_randu32() & vg_randu32() & vg_randu32() & 0x1;
- player->world_match[ 0 ] = vg_randu32() & 0x1;
+ player->active = (vg_randu32(&vg.rand) & 0x1)? 2: 0;
+ player->isfriend = vg_randu32(&vg.rand) & vg_randu32(&vg.rand) & 0x1;
+ player->isblocked = vg_randu32(&vg.rand) &
+ vg_randu32(&vg.rand) &
+ vg_randu32(&vg.rand) & 0x1;
+ player->world_match[ 0 ] = vg_randu32(&vg.rand) & 0x1;
player->world_match[ 1 ] = 0;
if( player->world_match[0] )
player->active_world = NULL;
for( int i=0; i<sizeof(player->username)-1; i ++ ){
- player->username[i] = 'a' + (vg_randu32() % 30);
+ player->username[i] = 'a' + (vg_randu32(&vg.rand) % 30);
player->username[i+1] = '\0';
- if( (vg_randu32() % 8) == 3 )
+ if( (vg_randu32(&vg.rand) % 8) == 3 )
break;
}
for( int i=0; i<3; i ++ ){
- player->medals[i] = vg_randu32() % 3;
+ player->medals[i] = vg_randu32(&vg.rand) % 3;
}
v3f pos;
- vg_rand_sphere( pos );
+ vg_rand_sphere( &vg.rand, pos );
v3_muladds( localplayer.rb.co, pos, 100.0f,
netplayers.final_mtx[ i*localplayer.skeleton.bone_count][3] );
}
v3_zero( state->trick_vel );
audio_lock();
- audio_oneshot_3d( &audio_flips[vg_randu32()%4],
+ audio_oneshot_3d( &audio_flips[vg_randu32(&vg.rand)%4],
localplayer.rb.co, 40.0f, 1.0f );
audio_unlock();
}
if( (trick = player_skate_trick_input()) ){
if( state->trick_time == 0.0f ){
audio_lock();
- audio_oneshot_3d( &audio_flips[vg_randu32()%4],
+ audio_oneshot_3d( &audio_flips[vg_randu32(&vg.rand)%4],
localplayer.rb.co, 40.0f, 1.0f );
audio_unlock();
}
float curspeed = v3_length( localplayer.rb.v ),
kickspeed = vg_clampf( curspeed*(1.0f/40.0f), 0.0f, 1.0f ),
- kicks = (vg_randf64()-0.5f)*2.0f*kickspeed,
+ kicks = (vg_randf64(&vg.rand)-0.5f)*2.0f*kickspeed,
sign = vg_signf( kicks );
animator->wobble[0] = vg_lerpf( animator->wobble[0], kicks*kicks*sign,
audio_lock();
if( id == k_player_skate_soundeffect_jump ){
- audio_oneshot_3d( &audio_jumps[vg_randu32()%2], pos, 40.0f, volume );
+ audio_oneshot_3d( &audio_jumps[vg_randu32(&vg.rand)%2],
+ pos, 40.0f, volume );
}
else if( id == k_player_skate_soundeffect_tap ){
- audio_oneshot_3d( &audio_taps[vg_randu32()%4], pos, 40.0f, volume );
+ audio_oneshot_3d( &audio_taps[vg_randu32(&vg.rand)%4],
+ pos, 40.0f, volume );
}
else if( id == k_player_skate_soundeffect_land_good ){
- audio_oneshot_3d( &audio_lands[vg_randu32()%3], pos, 40.0f, volume );
+ audio_oneshot_3d( &audio_lands[vg_randu32(&vg.rand)%3],
+ pos, 40.0f, volume );
}
else if( id == k_player_skate_soundeffect_land_bad ){
- audio_oneshot_3d( &audio_lands[vg_randu32()%2+3], pos, 40.0f, volume );
+ audio_oneshot_3d( &audio_lands[vg_randu32(&vg.rand)%2+3],
+ pos, 40.0f, volume );
}
else if( id == k_player_skate_soundeffect_grind_metal ){
audio_oneshot_3d( &audio_board[3], pos, 40.0f, volume );
audio_lock();
if( w->surface == k_surface_prop_concrete ){
audio_oneshot_3d(
- &audio_footsteps[vg_randu32()%vg_list_size(audio_footsteps)],
+ &audio_footsteps[vg_randu32(&vg.rand) %
+ vg_list_size(audio_footsteps)],
localplayer.rb.co, 40.0f, 1.0f
);
}
else if( w->surface == k_surface_prop_grass ){
audio_oneshot_3d(
- &audio_footsteps_grass[ vg_randu32()%
+ &audio_footsteps_grass[ vg_randu32(&vg.rand) %
vg_list_size(audio_footsteps_grass)],
localplayer.rb.co, 40.0f, 1.0f
);
}
else if( w->surface == k_surface_prop_wood ){
audio_oneshot_3d(
- &audio_footsteps_wood[ vg_randu32()%
+ &audio_footsteps_wood[ vg_randu32(&vg.rand) %
vg_list_size(audio_footsteps_wood)],
localplayer.rb.co, 40.0f, 1.0f
);
* Trace out a random point, near the player to try and determine water areas
*/
static
-enum audio_sprite_type world_audio_sample_sprite_random(v3f origin, v3f output)
-{
- v3f chance = { (vg_randf64()-0.5f) * 30.0f,
- 8.0f,
- (vg_randf64()-0.5f) * 30.0f };
+enum audio_sprite_type world_audio_sample_sprite_random(v3f origin, v3f output){
+ v3f chance = { (vg_randf64(&vg.rand)-0.5f) * 30.0f,
+ 8,
+ (vg_randf64(&vg.rand)-0.5f) * 30.0f };
v3f pos;
v3_add( chance, origin, pos );
return rp;
}
-static void ent_volume_call( world_instance *world, ent_call *call )
-{
+static void ent_volume_call( world_instance *world, ent_call *call ){
u32 index = mdl_entity_id_id( call->id );
ent_volume *volume = mdl_arritm( &world->ent_volume, index );
if( !volume->target ) return;
if( volume->flags & k_ent_volume_flag_particles ){
float *co = alloca( sizeof(float)*3 );
- co[0] = vg_randf64()*2.0f-1.0f;
- co[1] = vg_randf64()*2.0f-1.0f;
- co[2] = vg_randf64()*2.0f-1.0f;
+ co[0] = vg_randf64(&vg.rand)*2.0f-1.0f;
+ co[1] = vg_randf64(&vg.rand)*2.0f-1.0f;
+ co[2] = vg_randf64(&vg.rand)*2.0f-1.0f;
m4x3_mulv( volume->to_world, co, co );
call->function = k_ent_function_particle_spawn;
else
return;
- float chance = vg_randf64()*100.0f,
+ float chance = vg_randf64(&vg.rand)*100.0f,
bar = 0.0f;
for( u32 i=0; i<audio->clip_count; i++ ){
* | |
* |________|
*/
-static void world_gen_add_blob( world_instance *world,
+static void world_gen_add_blob( vg_rand *rand, world_instance *world,
scene_context *scene, ray_hit *hit )
{
m4x3f transform;
float angle = v3_dot(hit->normal,(v3f){0.0f,1.0f,0.0f});
q_axis_angle( qsurface, axis, angle );
- q_axis_angle( qrandom, (v3f){0.0f,1.0f,0.0f}, vg_randf64()*VG_TAUf );
+ q_axis_angle( qrandom, (v3f){0.0f,1.0f,0.0f}, vg_randf64(rand)*VG_TAUf );
q_mul( qsurface, qrandom, qsurface );
q_m3x3( qsurface, transform );
v3_copy( hit->pos, transform[3] );
float area = volume[0]*volume[2];
u32 particles = 0.08f * area;
- /* TODO: Quasirandom? */
vg_info( "Map area: %f. Max particles: %u\n", area, particles );
-
u64 t0 = SDL_GetPerformanceCounter();
#if 0
for( u32 i=0; i<particles; i++ ){
}
}
#else
+
+ vg_rand rand;
+ vg_rand_seed( &rand, 3030 );
const f32 tile_scale = 16.0f;
v2i tiles = { volume[0]/tile_scale, volume[2]/tile_scale };
for( i32 x=0; x<tiles[0]; x ++ ){
for( i32 z=0; z<tiles[1]; z ++ ){
for( u32 i=0; i<per_tile; i ++ ){
- v3f co = { (f32)x+vg_randf64(), 0.0f, (f32)z+vg_randf64() };
+ v3f co = { (f32)x+vg_randf64(&rand), 0, (f32)z+vg_randf64(&rand) };
v3_muls( co, tile_scale, co );
co[1] = 1000.0f;
v3_add( co, world->scene_geo.bbx[0], co );
struct world_surface *m1 = ray_hit_surface( world, &hit );
if((hit.normal[1] > 0.8f) && (m1 == mat) &&
(hit.pos[1] > 0.0f+10.0f)){
- world_gen_add_blob( world, scene, &hit );
+ world_gen_add_blob( &rand, world, scene, &hit );
count ++;
}
}
* load the .mdl file located in path as a world instance
*/
static void world_instance_load_mdl( u32 instance_id, const char *path ){
- vg_rand_seed( 9001 );
-
world_instance *world = &world_static.instances[ instance_id ];
world_init_blank( world );
world->status = k_world_status_loading;
vg_info( "Generating route meshes\n" );
vg_async_stall();
- vg_rand_seed( 2000 );
vg_async_item *call_scene = scene_alloc_async( &world->scene_lines,
&world->mesh_route_lines,
200000, 300000 );
rb_presolve_contacts( rb_contact_buffer, rb_contact_count );
for( int i=0; i<rb_contact_count; i++ ){
- rb_contact_restitution( rb_contact_buffer+i, vg_randf64() );
+ rb_contact_restitution( rb_contact_buffer+i, vg_randf64(&vg.rand) );
}
for( int i=0; i<6; i++ ){
v3_muls( origin, -1.0f, particle->mlocal[3] );
v3_copy( world_co, particle->obj.rb.co );
- v3_muls( imp_v, 1.0f+vg_randf64(), particle->obj.rb.v );
+ v3_muls( imp_v, 1.0f+vg_randf64(&vg.rand), particle->obj.rb.v );
particle->obj.rb.v[1] += 2.0f;
v4_copy( q, particle->obj.rb.q );
- particle->obj.rb.w[0] = vg_randf64()*2.0f-1.0f;
- particle->obj.rb.w[1] = vg_randf64()*2.0f-1.0f;
- particle->obj.rb.w[2] = vg_randf64()*2.0f-1.0f;
+ particle->obj.rb.w[0] = vg_randf64(&vg.rand)*2.0f-1.0f;
+ particle->obj.rb.w[1] = vg_randf64(&vg.rand)*2.0f-1.0f;
+ particle->obj.rb.w[2] = vg_randf64(&vg.rand)*2.0f-1.0f;
particle->obj.type = k_rb_shape_sphere;
particle->obj.inf.sphere.radius = r*0.6f;