("latest_pass",c_double)]
#}
+class ent_water(Structure):
+#{
+ _fields_ = [("transform",mdl_transform),
+ ("max_dist",c_float),
+ ("reserved0",c_uint32),
+ ("reserved1",c_uint32)]
+#}
+
def obj_ent_type( obj ):
#{
if obj.type == 'ARMATURE': return 'mdl_armature'
_graph_read( from_node_def, from_node, depth+1 )
#}
-
- # No definition! :(
- # TODO: Make a warning for this?
#}
else:#{
if "default" in link_def:#{
if mat.name in sr_compile.material_cache:
return sr_compile.material_cache[mat.name]
- print( "\n"+ mat.name+"\n" )
-
index = (len(sr_compile.material_data)//sizeof(mdl_material))+1
sr_compile.material_cache[mat.name] = index
elif ent_type == 'ent_route': #{
obj_data = obj.SR_data.ent_route[0]
route = ent_route()
- route.pstr_name = sr_compile_string( obj_data.alias ) #TODO
+ route.pstr_name = sr_compile_string( obj_data.alias )
route.checkpoints_start = checkpoint_count
route.checkpoints_count = 0
rn.co[2] = -obj.location[1]
sr_ent_push( rn )
#}
+ elif ent_type == 'ent_water':#{
+ water = ent_water()
+ compile_obj_transform( obj, water.transform )
+ water.max_dist = 0.0
+ sr_ent_push( water )
+ #}
#}
#}
def sr_get_type_enum( scene, context ):
#{
items = [('none','None',"")]
- mesh_entities=['ent_gate']
+ mesh_entities=['ent_gate','ent_water']
point_entities=['ent_spawn','ent_route_node','ent_route']
for e in point_entities: items += [(e,e,'')]
('ent_gate','Gate','', 1),
('ent_spawn','Spawn','', 2),
('ent_route_node', 'Route Node', '', 3 ),
- ('ent_route', 'Route', '', 4)],
+ ('ent_route', 'Route', '', 4),
+ ('ent_water', 'Water Surface', '', 5)],
update=sr_on_type_change
)
#}
typedef struct ent_path_index ent_path_index;
typedef struct ent_checkpoint ent_checkpoint;
typedef struct ent_route ent_route;
+typedef struct ent_water ent_water;
struct ent_spawn{
mdl_transform transform;
double latest_pass;
};
+struct ent_water{
+ mdl_transform transform;
+ float max_dist;
+ u32 reserved0, reserved1;
+};
+
#endif /* ENTITY_H */
player_animation res;
_player_animate[ player->subsystem ]( player, &res );
- /* TODO: eventually, blending code goes here */
-
m4x3f transform;
q_m3x3( res.root_q, transform );
v3_copy( res.root_co, transform[3] );
VG_STATIC
void (*_player_reset[])( player_instance *player, ent_spawn *rp ) =
{
- NULL,
+ player__walk_reset,
player__skate_reset,
NULL
};
return valid_count;
}
-#if 0
-VG_STATIC
-int create_jump_for_target( world_instance *world, player_instance *player,
- v3f target, float max_angle, jump_info *jump )
-{
-
- if( fabsf(a0-a) > fabsf(a1-a) )
- a0 = a1;
-
- if( fabsf(a0-a) > max_angle )
- return 0;
-
- /* TODO: sweep the path before chosing the smallest dist */
-
-
-#if 0
- /* add a trace */
- for( int i=0; i<=20; i++ )
- {
- float t = (float)i * (1.0f/20.0f) * p->land_dist;
-
- v3f p0;
- v3_muls( p->v, t, p0 );
- v3_muladds( p0, player->basis[1], -0.5f * p->gravity * t*t, p0 );
-
- v3_add( player->rb.co, p0, p->log[ p->log_length ++ ] );
- }
-#endif
-
- return 1;
- }
- else
- return 0;
-}
-#endif
-
VG_STATIC
void player__approximate_best_trajectory( player_instance *player )
{
if( grind_located ) search_for_grind = 0;
if( launch_vy - gravity*t > 0.0f ) search_for_grind = 0;
- /* TODO Cleanup */
+ /* REFACTOR */
v3f closest;
if( search_for_grind ){
create_jumps_to_hit_target( player, grind_jumps, grind.co,
0.175f*VG_PIf, grind_located_gravity );
- /* knock out original landing points in the 1m area
- * TODO: Make this a konstant */
+ /* knock out original landing points in the 1m area */
for( u32 j=0; j<s->possible_jump_count; j++ ){
jump_info *jump = &s->possible_jumps[ j ];
float dist = v3_dist2( jump->log[jump->log_length-1], grind.co );
v3_muladds( co0, basis[1], -0.5f * jump->gravity * t*t, co0 );
v3_add( launch_co, co0, co0 );
-#if 0
/* rough scan to make sure we dont collide with anything */
+ /* NOTE this was rarely needed and ends up with false negatives. */
+#if 0
for( int j=1; j<=16; j++ ){
t = (float)j*(1.0f/16.0f);
t *= 0.9f;
}
/* Throw / collect routine
- *
- * TODO: Max speed boost
*/
if( player->input_grab->axis.value > 0.5f ){
if( s->state.activity == k_skate_activity_ground ){
audio_clip *relevant_samples[] = {
&audio_board[0],
- &audio_board[0], /* TODO? */
+ &audio_board[0],
&audio_board[7],
&audio_board[6],
&audio_board[5]
(float)s->state.manual_direction;
}
- /* TODO: Fall back on land normal */
- /* TODO: Lerp weight distribution */
if( s->state.manual_direction ){
v3f plane_z;
VG_STATIC void skate_grind_orient( struct grind_info *inf, m3x3f mtx )
{
- /* TODO: Is N and Dir really orthogonal? */
v3_copy( inf->dir, mtx[0] );
v3_copy( inf->n, mtx[1] );
v3_cross( mtx[0], mtx[1], mtx[2] );
{
struct player_skate *s = &player->_skate;
- /* TODO: Trash compactor this */
+ /* REFACTOR */
v3f ra = { 0.0f, -k_board_radius, sign * k_board_length };
v3f raw, wsp;
m3x3_mulv( player->rb.to_world, ra, raw );
{
struct player_skate *s = &player->_skate;
- /* TODO: Trash compactor this */
+ /* REFACTOR */
v3f ra = { 0.0f, -k_board_radius, sign * k_board_length };
v3f raw, wsp;
if( !skate_point_visible( vis, inf->co ) )
return 0;
- /* Exit condition: minimum velocity not reached, but allow a bit of error
- * TODO: trash compactor */
+ /* Exit condition: minimum velocity not reached, but allow a bit of error */
float dv = fabsf(v3_dot( player->rb.v, inf->dir )),
minv = k_grind_axel_min_vel*0.8f;
{
struct player_skate *s = &player->_skate;
+ if( s->grind_cooldown > 100 ){
+ vg_fatal_exit_loop( "wth!\n" );
+ }
+
/* debounces this state manager a little bit */
if( s->grind_cooldown ){
s->grind_cooldown --;
mdl_keyframe grind_pose[32];
{
- /* TODO: factor balance into this sampler */
float grind_frame = 0.5f;
if( s->state.activity == k_skate_activity_grind_front50 ){
"metal" }
[w->surface] );
- if( w->state.outro_anim )
- {
+ if( w->state.outro_anim ){
float outro_length = (float)w->state.outro_anim->length /
w->state.outro_anim->rate,
outro_time = vg.time - w->state.outro_start_time;
rb_update_transform( &player->rb );
}
+VG_STATIC void player__walk_reset( player_instance *player, ent_spawn *rp )
+{
+ struct player_walk *w = &player->_walk;
+ w->state.activity = k_walk_activity_air;
+ w->state.outro_type = k_walk_outro_none;
+ w->state.outro_anim = NULL;
+ w->state.outro_start_time = 0.0;
+}
+
#endif /* PLAYER_DEVICE_WALK_H */
VG_STATIC void player__walk_im_gui ( player_instance *player );
VG_STATIC void player__walk_bind ( player_instance *player );
VG_STATIC void player__walk_transition ( player_instance *player, v3f angles );
+VG_STATIC void player__walk_reset ( player_instance *player,
+ ent_spawn *rp );
#endif /* PLAYER_WALK_H */
*/
"water_reflection",
.link = &gpipeline.fb_water_reflection,
- .resolution_div = 3,
+ .resolution_div = 2,
.attachments =
{
{
*/
"water_beneath",
.link = &gpipeline.fb_water_beneath,
- .resolution_div = 4,
+ .resolution_div = 2,
.attachments =
{
{
float world_water_depth( vec3 pos )
{
- vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw;
float ref_depth = g_water_plane.y*g_water_plane.w;
- return texture( g_world_depth, depth_coord ).g - ref_depth;
+ return world_depth_sample( pos ) - ref_depth;
}
float shadow_sample( vec3 vdir )
"{\n"
" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n"
" float ref_depth = g_water_plane.y*g_water_plane.w;\n"
-" return texture( g_world_depth, depth_coord ).g - ref_depth;\n"
+" return texture( g_world_depth, depth_coord ).g-ref_depth;\n"
"}\n"
"\n"
"float shadow_sample( vec3 vdir )\n"
"{\n"
" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n"
" float ref_depth = g_water_plane.y*g_water_plane.w;\n"
-" return texture( g_world_depth, depth_coord ).g - ref_depth;\n"
+" return texture( g_world_depth, depth_coord ).g-ref_depth;\n"
"}\n"
"\n"
"float shadow_sample( vec3 vdir )\n"
"{\n"
" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n"
" float ref_depth = g_water_plane.y*g_water_plane.w;\n"
-" return texture( g_world_depth, depth_coord ).g - ref_depth;\n"
+" return texture( g_world_depth, depth_coord ).g-ref_depth;\n"
"}\n"
"\n"
"float shadow_sample( vec3 vdir )\n"
"{\n"
" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n"
" float ref_depth = g_water_plane.y*g_water_plane.w;\n"
-" return texture( g_world_depth, depth_coord ).g - ref_depth;\n"
+" return texture( g_world_depth, depth_coord ).g-ref_depth;\n"
"}\n"
"\n"
"float shadow_sample( vec3 vdir )\n"
"{\n"
" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n"
" float ref_depth = g_water_plane.y*g_water_plane.w;\n"
-" return texture( g_world_depth, depth_coord ).g - ref_depth;\n"
+" return texture( g_world_depth, depth_coord ).g-ref_depth;\n"
"}\n"
"\n"
"float shadow_sample( vec3 vdir )\n"
"{\n"
" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n"
" float ref_depth = g_water_plane.y*g_water_plane.w;\n"
-" return texture( g_world_depth, depth_coord ).g - ref_depth;\n"
+" return texture( g_world_depth, depth_coord ).g-ref_depth;\n"
"}\n"
"\n"
"float shadow_sample( vec3 vdir )\n"
"{\n"
" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n"
" float ref_depth = g_water_plane.y*g_water_plane.w;\n"
-" return texture( g_world_depth, depth_coord ).g - ref_depth;\n"
+" return texture( g_world_depth, depth_coord ).g-ref_depth;\n"
"}\n"
"\n"
"float shadow_sample( vec3 vdir )\n"
"{\n"
" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n"
" float ref_depth = g_water_plane.y*g_water_plane.w;\n"
-" return texture( g_world_depth, depth_coord ).g - ref_depth;\n"
+" return texture( g_world_depth, depth_coord ).g-ref_depth;\n"
"}\n"
"\n"
"float shadow_sample( vec3 vdir )\n"
"{\n"
" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n"
" float ref_depth = g_water_plane.y*g_water_plane.w;\n"
-" return texture( g_world_depth, depth_coord ).g - ref_depth;\n"
+" return texture( g_world_depth, depth_coord ).g-ref_depth;\n"
"}\n"
"\n"
"float shadow_sample( vec3 vdir )\n"
"{\n"
" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n"
" float ref_depth = g_water_plane.y*g_water_plane.w;\n"
-" return texture( g_world_depth, depth_coord ).g - ref_depth;\n"
+" return texture( g_world_depth, depth_coord ).g-ref_depth;\n"
"}\n"
"\n"
"float shadow_sample( vec3 vdir )\n"
vec2 ssuv = gl_FragCoord.xy*uInvRes;
// Surface colour composite
- float depthvalue = clamp( -world_water_depth( aCo )*(1.0/25.0), 0.0, 1.0 );
+ float depthvalue = clamp( -world_water_depth(aCo)*(1.0/25.0), 0.0,1.0 );
vec2 world_coord = aCo.xz * 0.008;
vec4 time_offsets = vec4( uTime ) * vec4( 0.008, 0.006, 0.003, 0.03 );
"{\n"
" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n"
" float ref_depth = g_water_plane.y*g_water_plane.w;\n"
-" return texture( g_world_depth, depth_coord ).g - ref_depth;\n"
+" return texture( g_world_depth, depth_coord ).g-ref_depth;\n"
"}\n"
"\n"
"float shadow_sample( vec3 vdir )\n"
" vec2 ssuv = gl_FragCoord.xy*uInvRes;\n"
" \n"
" // Surface colour composite\n"
-" float depthvalue = clamp( -world_water_depth( aCo )*(1.0/25.0), 0.0, 1.0 );\n"
+" float depthvalue = clamp( -world_water_depth(aWorldCo)*(1.0/25.0), 0.0,1.0 );\n"
"\n"
" vec2 world_coord = aCo.xz * 0.008;\n"
" vec4 time_offsets = vec4( uTime ) * vec4( 0.008, 0.006, 0.003, 0.03 );\n"
"{\n"
" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n"
" float ref_depth = g_water_plane.y*g_water_plane.w;\n"
-" return texture( g_world_depth, depth_coord ).g - ref_depth;\n"
+" return texture( g_world_depth, depth_coord ).g-ref_depth;\n"
"}\n"
"\n"
"float shadow_sample( vec3 vdir )\n"
if( !player_transparent && player_draw )
player__render( &main_camera, &localplayer );
-
render_water_texture( view_world, &main_camera, 0 );
render_fb_bind( gpipeline.fb_main );
render_water_surface( view_world, &main_camera );
/* Other shite */
glDisable(GL_BLEND);
- glDisable( GL_DEPTH_TEST );
+ glDisable(GL_DEPTH_TEST);
vg_lines_drawall();
glViewport( 0,0, vg.window_x, vg.window_y );
}
sb->collider = bone->collider;
sb->orig_bone = bone;
- vg_info( "orig: %u\n", bone->collider );
-
if( sb->flags & k_bone_flag_ik ){
skele->bones[ sb->parent ].flags |= k_bone_flag_ik;
ent_route_node,
ent_path_index,
ent_checkpoint,
- ent_route;
+ ent_route,
+ ent_water;
ent_gate *rendering_gate;
shader_model_gate_uPv( cam->mtx.pv );
shader_model_gate_uMdl( gate->to_world );
shader_model_gate_uCam( cam->pos );
-
- /* TODO(ART IMPROVEMENT): animate alpha of this? */
shader_model_gate_uColour( (v4f){0.0f,1.0f,0.0f,0.0f} );
shader_model_gate_uTime( vg.time*0.25f );
shader_model_gate_uInvRes( (v2f){
vg_info( "%d foliage models added\n", count );
}
-#if 0
-VG_STATIC void world_ents_allocate( world_instance *world )
-{
- vg_info( "Allocating entities\n" );
-
- /* --count entites to allocate buffers for them.--
- * --maybe in the future we just store these numbers in the model file...--
- *
- * ... 16.03.23: I HOPE YOUR FUCKING HAPPY
- * ... 22.03.23: incomprehensible pain
- *
- * -- use this in world_routes too --
- *
- */
-
- struct countable
- {
- enum classtype ct, ct1;
- void **to_allocate;
- u32 item_size;
- int count;
- }
- entity_counts[] =
- {
- {
- k_classtype_spawn,
- k_classtype_none,
- (void*)&world->spawns,
- sizeof(struct respawn_point)
- },
- {
- k_classtype_audio,
- k_classtype_none,
- (void*)&world->audio_things,
- sizeof(struct world_audio_thing)
- },
- {
- k_classtype_world_light,
- k_classtype_none,
- (void*)&world->lights,
- sizeof(struct world_light)
- },
- {
- k_classtype_nonlocal_gate,
- k_classtype_none,
- (void*)&world->nonlocal_gates,
- sizeof(struct nonlocal_gate)
- },
- };
-
- for( int i=0; i<vg_list_size(entity_counts); i++ )
- entity_counts[i].count = 0;
-
- for( int i=0; i<world->meta->info.node_count; i++ )
- {
- mdl_node *pnode = mdl_node_from_id( world->meta, i );
-
- for( int j=0; j<vg_list_size(entity_counts); j ++ )
- {
- if( (pnode->classtype == entity_counts[j].ct) ||
- (pnode->classtype == entity_counts[j].ct1) )
- {
- pnode->sub_uid = entity_counts[j].count;
- entity_counts[j].count ++;
- break;
- }
- }
- }
-
- for( int i=0; i<vg_list_size(entity_counts); i++ )
- {
- struct countable *counter = &entity_counts[i];
-
- u32 bufsize = counter->item_size*counter->count;
- *counter->to_allocate = vg_linear_alloc( world_global.generic_heap,
- bufsize );
- memset( *counter->to_allocate, 0, bufsize );
- }
-
- world->volume_bh = bh_create( world_global.generic_heap,
- &bh_system_volumes,
- world,
- world->volume_count,
- 1 );
-}
-#endif
#if 0
VG_STATIC void world_pct_spawn( world_instance *world, mdl_node *pnode )
rp->name = mdl_pstr( world->meta, pnode->pstr_name );
}
-VG_STATIC void world_pct_water( world_instance *world, mdl_node *pnode )
-{
- if( world->water.enabled )
- {
- vg_warn( "Multiple water surfaces in level! ('%s')\n",
- mdl_pstr( world->meta, pnode->pstr_name ));
- return;
- }
-
- world->water.enabled = 1;
- water_set_surface( world, pnode->co[1] );
-}
-
VG_STATIC void world_pct_audio( world_instance *world, mdl_node *pnode )
{
struct world_audio_thing *thing = &world->audio_things[
ent_gate *gate = mdl_arritm( &world->ent_gate, j );
gate_transform_update( gate );
}
+
+ /* water */
+ for( u32 j=0; j<mdl_arrcount(&world->ent_water); j++ ){
+ ent_water *water = mdl_arritm( &world->ent_water, j );
+ if( world->water.enabled ){
+ vg_warn( "Multiple water surfaces in level!\n" );
+ break;
+ }
+
+ world->water.enabled = 1;
+ water_set_surface( world, water->transform.co[1] );
+ }
}
VG_STATIC void world_load( world_instance *world, const char *path )
"ent_checkpoint", world_global.generic_heap );
mdl_load_array( &world->meta, &world->ent_route,
"ent_route", world_global.generic_heap );
+ mdl_load_array( &world->meta, &world->ent_water,
+ "ent_water", world_global.generic_heap );
mdl_close( &world->meta );
mesh_bind( &world_global.mesh_gate );
/* skip writing into the motion vectors for this */
- /* TODO: draw future gate if the one we're looking through is to be passed,
- * instead of current gate */
glDrawBuffers( 1, (GLenum[]){ GL_COLOR_ATTACHMENT0 } );
for( u32 i=0; i<mdl_arrcount(&world->ent_route); i++ ){
/*
* Draw world
*/
+ glEnable( GL_DEPTH_TEST );
+ glDisable( GL_BLEND );
glCullFace( GL_FRONT );
render_world( world, &water_cam, layer_depth );
glCullFace( GL_BACK );
m4x4_clip_projection( beneath_cam.mtx.p, clippb );
camera_finalize( &beneath_cam );
+ glEnable( GL_DEPTH_TEST );
+ glDisable( GL_BLEND );
render_world_depth( world, &beneath_cam );
glViewport( 0, 0, vg.window_x, vg.window_y );
}