water volumes; cubemap water fix
authorhgn <hgodden00@gmail.com>
Mon, 24 Mar 2025 01:59:48 +0000 (01:59 +0000)
committerhgn <hgodden00@gmail.com>
Mon, 24 Mar 2025 01:59:48 +0000 (01:59 +0000)
20 files changed:
content_skaterift/maps/dev_heaven/main.mdl
content_skaterift/maps/mp_line1/main.mdl
content_skaterift/maps/sr002-local-dev_hub-cm-straw.qoi
skaterift_blender/sr_main.py
skaterift_blender/sr_mdl.py
src/entity.c
src/entity.h
src/menu.c
src/player.c
src/player_remote.c
src/skaterift.c
src/skaterift.h
src/workshop.c
src/world.h
src/world_gate.c
src/world_gate.h
src/world_render.c
src/world_render.h
src/world_volumes.c
src/world_water.c

index a0105eac50f2b8571371a44e639c9d2a5ed35d4b..956e86093c6093f4c550873e40752b0849bdc980 100644 (file)
Binary files a/content_skaterift/maps/dev_heaven/main.mdl and b/content_skaterift/maps/dev_heaven/main.mdl differ
index d99d5a0f6bd35b199e571b5a9cbd021f6c724eef..e8d212ba3d739da9b42a1b4f89aef3fa650433db 100644 (file)
Binary files a/content_skaterift/maps/mp_line1/main.mdl and b/content_skaterift/maps/mp_line1/main.mdl differ
index 3929af0d1135de7bdaeb80bee1f132b2730f4ae8..ea3e30d4be02bed1bdd62a09da9e683c5cd1bfe2 100644 (file)
Binary files a/content_skaterift/maps/sr002-local-dev_hub-cm-straw.qoi and b/content_skaterift/maps/sr002-local-dev_hub-cm-straw.qoi differ
index 0ced07b2fd2ae47e75ab0f9fe994131b1e30bc95..b95a1d83a6da6277188b46db8de13b96fda9c7e6 100644 (file)
@@ -1676,6 +1676,7 @@ class SR_OBJECT_ENT_VOLUME(bpy.types.PropertyGroup):#{
    target_event_leave: bpy.props.IntProperty( name="Leave Ev", default=-1 )
 
    auto_run: bpy.props.BoolProperty( name="Auto Run" )
+   water_volume: bpy.props.BoolProperty( name="Water Volume" )
    text: bpy.props.StringProperty()
 
    @staticmethod
@@ -1715,6 +1716,7 @@ class SR_OBJECT_ENT_VOLUME(bpy.types.PropertyGroup):#{
       SR_OBJECT_ENT_VOLUME.inspect_target( layout, data, 'target', ['_event','_event_leave'] )
       if data[0].subtype == '2':
          layout.prop( data[0], 'text' )
+      layout.prop( data[0], 'water_volume' )
    #}
 #}
 
index b08faaddff44e5bf692452fa188466f63e88dc41..c65ffce80fe99d05b5f9e7d0a578c7a3e10bde84 100644 (file)
@@ -749,6 +749,9 @@ def _mdl_compiler_compile_entities():
             if obj_data.subtype == '1':
                volume.flags |= 0x1
 
+            if obj_data.water_volume:
+               volume.flags |= 0x10
+
             #if obj_data.auto_run:
             #   volume.flags |= 0x4
             compile_obj_transform( obj, volume.transform )
index 449f0507f0ee15a86005391c6fc17a33bab85786..ee2720a2733743421bbbf6d60da1277a94647791 100644 (file)
@@ -7,7 +7,6 @@
 #include "ent_relay.h"
 #include "ent_challenge.h"
 #include "ent_route.h"
-#include "ent_miniworld.h"
 #include "ent_region.h"
 #include "ent_glider.h"
 #include "ent_prop.h"
@@ -33,7 +32,6 @@ void entity_call( world_instance *world, ent_call *call )
       [k_ent_relay]     = ent_relay_call,
       [k_ent_challenge] = ent_challenge_call,
       [k_ent_route]     = ent_route_call,
-      [k_ent_miniworld] = ent_miniworld_call,
       [k_ent_region]    = ent_region_call,
       [k_ent_glider]    = ent_glider_call,
       [k_ent_water]     = ent_water_call,
index ec431352cc4317e69afe6859dc1549da3c33153d..5f853779ea34729a545a6caf663524adc3c9ce90 100644 (file)
@@ -332,7 +332,9 @@ struct volume_interact
 enum ent_volume_flag {
    k_ent_volume_flag_particles = 0x1,
    k_ent_volume_flag_disabled  = 0x2,
-   k_ent_volume_flag_interact  = 0x8
+   k_ent_volume_flag_removed0  = 0x4,
+   k_ent_volume_flag_interact  = 0x8,
+   k_ent_volume_flag_water     = 0x10
 };
 
 struct ent_volume
index 2e8ecde53250ddd690d2e18150b3c8e8b95bd1da..d6d2ad3e34007d51d29c9a8750bb9572e84f2729 100644 (file)
@@ -5,7 +5,6 @@
 #include "entity.h"
 #include "input.h"
 #include "world_map.h"
-#include "ent_miniworld.h"
 #include "audio.h"
 #include "workshop.h"
 #include "gui.h"
@@ -751,7 +750,7 @@ void menu_gui( ui_context *ctx )
                "Here you can visit different locations and keep\n"
                "track of your progress.\n"
                "\n"
-               "Walk through the rifts to visit the worlds. Our\n"
+               "Visit the sandcastles to enter the worlds. Our\n"
                "story begins at the training volcano where you\n"
                "will learn to skate again!\n"
                "\n"
index f4fdc17a498f62c4b292cda234a9a0a264548924..e1789a37d5c25fb64f63d217a7545ff5cc070fd6 100644 (file)
@@ -8,7 +8,6 @@
 #include "network.h"
 #include "network_common.h"
 #include "world_routes.h"
-#include "ent_miniworld.h"
 #include "gui.h"
 
 #include "shaders/model_entity.h"
@@ -298,10 +297,16 @@ void player__im_gui( ui_context *ctx )
                      (const char *[]){ [k_skaterift_menu]      = "menu",
                                        [k_skaterift_replay]    = "replay",
                                        [k_skaterift_default]   = "default",
+                                       [k_skaterift_activity_max] = NULL
                      } [skaterift.activity] );
    player__debugtext( ctx, 1, "world event: %s",
                      (const char *[]){ [k_world_event_none]   = "no event",
                                        [k_world_event_challenge] = "challenge",
+                                       [k_world_event_shop] = "shop",
+                                       [k_world_event_route_leaderboard] = "route leaderboard",
+                                       [k_world_event_interact] = "interact",
+                                       [k_world_event_board_maker] = "board maker",
+                                       [k_world_event_max] = NULL
                      } [_world.event] );
                      
    player__debugtext( ctx, 1, "time_rate: %.4f", skaterift.time_rate );
index 88dbb6cf8fac575868404c275622481becaa0016..fabafb90ba2dc77e32136142748b7b4b57b4957a 100644 (file)
@@ -6,7 +6,6 @@
 #include "addon.h"
 #include "font.h"
 #include "gui.h"
-#include "ent_miniworld.h"
 #include "ent_region.h"
 #include "shaders/model_entity.h"
 #include "vg/vg_steam_friends.h"
index 0edf3f117808389224bcc901e966d9fa5eb1d7d0..8c690d3aab9ac6ca51f11f572528997a9d1e7792 100644 (file)
@@ -40,7 +40,6 @@
 #include "trail.h"
 #include "freecam.h"
 #include "ent_tornado.h"
-#include "ent_miniworld.h"
 #include "ent_skateshop.h"
 #include "ent_camera.h"
 #include "world_map.h"
@@ -432,20 +431,7 @@ static void render_main_game(void)
       glEnable( GL_DEPTH_TEST );
       world_prerender( &_world.main );
 
-#if 0
-      if( menu_viewing_preview() )
-      {
-         glClearColor( 0.1f, 0.1f, 0.2f, 0.0f );
-         glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
-
-         if( _world.preview_instance.complete )
-            render_world_preview();
-
-         return;
-      }
-#endif
-
-      render_world( &_world.main, &g_render.cam, render_stenciled, 0, 1, 1 );
+      render_world( &_world.main, &g_render.cam, render_stenciled, 0, 1, 1, _vg_render.fb_main );
 
       particle_system_update( &particles_grind, vg.time_delta );
       //particle_system_debug( &particles_grind );
@@ -474,7 +460,7 @@ static void render_main_game(void)
 
       /* continue with variable rate */
       vg_framebuffer_bind( _vg_render.fb_main, _vg_render.scale );
-      render_world_gates( &_world.main, &g_render.cam );
+      render_world_gates( &_world.main, &g_render.cam, _vg_render.fb_main );
    }
 
    /* composite */
@@ -566,7 +552,6 @@ void vg_framebuffer_resize( int w, int h )
 #include "ent_challenge.c"
 #include "ent_glider.c"
 #include "entity.c"
-#include "ent_miniworld.c"
 #include "ent_objective.c"
 #include "ent_region.c"
 #include "ent_relay.c"
index e4f7a3c0f3a4ad464045156efc2910ac9321d07c..f7d7ddc96155d77e40b16d081ce93abc96cb4551 100644 (file)
@@ -20,6 +20,7 @@ struct skaterift_globals
       k_skaterift_default    = 0x00,  /* regular playing */
       k_skaterift_replay     = 0x01,
       k_skaterift_menu       = 0x04,
+      k_skaterift_activity_max = 0x8
    }
    activity;
 
index 16b6d7fb51833a0602790ca33805bf59df84c0d6..cf8be7d3a6ed0591d784ed6f804e89af7538516e 100644 (file)
@@ -902,7 +902,7 @@ static void workshop_render_world_preview(void)
    glEnable( GL_DEPTH_TEST );
    glDisable( GL_BLEND );
 
-   render_world( &_world.main, &g_render.cam, 0, 0, 1, 1 );
+   render_world( &_world.main, &g_render.cam, 0, 0, 1, 1, g_render.fb_workshop_preview );
 
    glBindFramebuffer( GL_FRAMEBUFFER, 0 );
    glViewport( 0,0, vg.window_x, vg.window_y );
@@ -1046,10 +1046,9 @@ static void workshop_render_board_preview(void)
    m4x3_mulv( mmdl1, vp0, ubo->g_board_0 );
    m4x3_mulv( mmdl1, vp1, ubo->g_board_1 );
    glBindBuffer( GL_UNIFORM_BUFFER, world->ubo_lighting );
-   glBufferSubData( GL_UNIFORM_BUFFER, 0, 
-                    sizeof(struct ub_world_lighting), &world->ub_lighting );
+   glBufferSubData( GL_UNIFORM_BUFFER, 0, sizeof(struct ub_world_lighting), &world->ub_lighting );
 
-   render_world( world, &cam, 0, 0, 0, 0 );
+   render_world( world, &cam, 0, 0, 0, 0, g_render.fb_workshop_preview );
    struct player_board_pose pose = {0};
    render_board( &cam, world, board, mmdl,  &pose, k_board_shader_entity );
    render_board( &cam, world, board, mmdl1, &pose, k_board_shader_entity );
index 2c99f1b66da184584109a75df1b47ab5445cd73a..9fffb713f0334ce639948b16226939a2ccf9aa72 100644 (file)
@@ -264,7 +264,8 @@ struct world_static
       k_world_event_shop,
       k_world_event_route_leaderboard,
       k_world_event_interact,
-      k_world_event_board_maker
+      k_world_event_board_maker,
+      k_world_event_max
    }
    event;
 
index 525661c69dc6934fd3e7717b58df8c466841b83b..4402730e6ffbf3125a8754ecb2638da0afb0d96b 100644 (file)
@@ -104,8 +104,8 @@ static void render_gate_mesh( world_instance *world, ent_gate *gate )
 /*
  * Render the view through a gate
  */
-int render_gate( world_instance *world, world_instance *world_inside,
-                 ent_gate *gate, vg_camera *cam )
+int render_gate( world_instance *world, world_instance *world_inside, ent_gate *gate, vg_camera *cam, 
+                 vg_framebuffer *target_fb )
 {
    v3f viewdir, gatedir;
    m3x3_mulv( cam->transform, (v3f){0.0f,0.0f,-1.0f}, viewdir );
@@ -186,10 +186,7 @@ int render_gate( world_instance *world, world_instance *world_inside,
    render_gate_mesh( world, gate );
 
    if( world_inside )
-   {
-      render_world( world_inside, &world_gates.cam, 
-                    1, !localplayer.gate_waiting, 1, 1 );
-   }
+      render_world( world_inside, &world_gates.cam, 1, !localplayer.gate_waiting, 1, 1, target_fb );
 
    return 1;
 }
index 6bdfe91dfc221c9f0b109fbcc142d05068a4e0bd..20f60426eecd0d439177d4701a5f2efffbec1276 100644 (file)
@@ -22,7 +22,7 @@ extern world_gates;
 void world_gates_init(void);
 void gate_transform_update( ent_gate *gate );
 int render_gate( world_instance *world, world_instance *world_inside,
-                    ent_gate *gate, vg_camera *cam );
+                    ent_gate *gate, vg_camera *cam, vg_framebuffer *target_fb );
 
 int gate_intersect( ent_gate *gate, v3f pos, v3f last );
 u32 world_intersect_gates( world_instance *world, v3f pos, v3f last );
index c18406b46930383e84e8b2576be9e8181e3b7a0b..1a2a07026f21355e864580bddff1393da0cf72f6 100644 (file)
@@ -7,7 +7,6 @@
 #include "font.h"
 #include "gui.h"
 #include "world_map.h"
-#include "ent_miniworld.h"
 #include "player_remote.h"
 #include "ent_skateshop.h"
 #include "shaders/model_entity.h"
@@ -874,7 +873,7 @@ static void render_sky( world_instance *world, vg_camera *cam )
    glDepthMask( GL_TRUE );
 }
 
-void render_world_gates( world_instance *world, vg_camera *cam )
+void render_world_gates( world_instance *world, vg_camera *cam, vg_framebuffer *target_fb )
 {
    float closest = INFINITY;
    struct ent_gate *gate = NULL;
@@ -917,7 +916,7 @@ void render_world_gates( world_instance *world, vg_camera *cam )
 
          if( gate->flags & k_ent_gate_linked )
          {
-            render_gate( world, NULL, gate, cam );
+            render_gate( world, NULL, gate, cam, target_fb );
 
             m4x3f mmdl;
             m4x4f pvm;
@@ -962,7 +961,7 @@ void render_world_gates( world_instance *world, vg_camera *cam )
          }
       }
       else
-         render_gate( world, world, gate, cam );
+         render_gate( world, world, gate, cam, target_fb );
    }
 }
 
@@ -1071,7 +1070,7 @@ static void render_other_entities( world_instance *world, vg_camera *cam )
 
 void render_world( world_instance *world, vg_camera *cam,
                    int stenciled, int viewing_from_gate, 
-                   int with_water, int with_cubemaps )
+                   int with_water, int with_cubemaps, vg_framebuffer *target_fb )
 {
    if( stenciled )
    {
@@ -1110,12 +1109,14 @@ void render_world( world_instance *world, vg_camera *cam,
       u32 closest = 0;
       float min_dist = INFINITY;
 
-      if( af_arrcount( &world->ent_route ) ){
-         for( u32 i=0; i<af_arrcount( &world->ent_route ); i++ ){
+      if( af_arrcount( &world->ent_route ) )
+      {
+         for( u32 i=0; i<af_arrcount( &world->ent_route ); i++ )
+         {
             ent_route *route = af_arritm( &world->ent_route, i );
             float dist = v3_dist2( route->board_transform[3], cam->pos );
-
-            if( dist < min_dist ){
+            if( dist < min_dist )
+            {
                min_dist = dist;
                closest = i;
             }
@@ -1163,7 +1164,7 @@ void render_world( world_instance *world, vg_camera *cam,
    if( with_water )
    {
       render_water_texture( world, cam );
-      vg_framebuffer_bind( _vg_render.fb_main, _vg_render.scale );
+      vg_framebuffer_bind( target_fb, _vg_render.scale );
    }
 
    if( stenciled )
@@ -1181,7 +1182,6 @@ void render_world( world_instance *world, vg_camera *cam,
 
    render_remote_players( world, cam );
    render_other_entities( world, cam );
-   ent_miniworld_render( world, cam );
    _board_maker_render( world, cam );
 
    if( stenciled )
@@ -1335,7 +1335,7 @@ void render_world_preview( vg_camera *cam )
    glEnable( GL_CULL_FACE );
 }
 
-static void render_cubemap_side( world_instance *world, v3f co, m3x3f rotation, u32 side )
+static void render_cubemap_side( world_instance *world, v3f co, m3x3f rotation, u32 side, vg_framebuffer *target_fb )
 {
    vg_camera cam;
    v3f forward[6] = {
@@ -1378,8 +1378,7 @@ static void render_cubemap_side( world_instance *world, v3f co, m3x3f rotation,
    vg_camera_finalize( &cam );
    vg_camera_finalize( &cam );
 
-   /* TODO: CANT RENDER CUBEMAPS BECAUSE RENDER_WORLD FUCKS WITH GLVIEWPORT AND STUFF */
-   render_world( world, &cam, 0, 1, 0, 0 );
+   render_world( world, &cam, 0, 1, 1, 0, target_fb );
 }
 
 void render_world_cubemaps( world_instance *world )
@@ -1403,11 +1402,21 @@ void render_world_cubemaps( world_instance *world )
             world->cubemap_side = 0;
 
          glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
-               GL_TEXTURE_CUBE_MAP_POSITIVE_X + world->cubemap_side, 
-               cm->texture_id, 0 );
+                                 GL_TEXTURE_CUBE_MAP_POSITIVE_X + world->cubemap_side, 
+                                 cm->texture_id, 0 );
          glClear( GL_DEPTH_BUFFER_BIT );
 
-         render_cubemap_side( world, cm->co, identity, world->cubemap_side );
+         vg_framebuffer temp_vg_framebuffer =
+         {
+            .display_name = NULL,
+            .resolution_div = 0,
+            .fixed_w = WORLD_CUBEMAP_RES,
+            .fixed_h = WORLD_CUBEMAP_RES,
+            .id = cm->framebuffer_id,
+            .attachment_count = 0,
+            .attachments = NULL
+         };
+         render_cubemap_side( world, cm->co, identity, world->cubemap_side, &temp_vg_framebuffer );
       }
    }
 }
@@ -1450,6 +1459,16 @@ void render_world_portal_cubemaps(void)
       }
 
       glViewport( 0, 0, 512, 512 );
+      vg_framebuffer temp_vg_framebuffer =
+      {
+         .display_name = NULL,
+         .resolution_div = 0,
+         .fixed_w = 512,
+         .fixed_h = 512,
+         .id = temp_fb,
+         .attachment_count = 0,
+         .attachments = NULL
+      };
 
       world_instance *world = &_world.main;
 
@@ -1468,7 +1487,7 @@ void render_world_portal_cubemaps(void)
             for( u32 i=0; i<6; i ++ )
             {
                glClear( GL_DEPTH_BUFFER_BIT );
-               render_cubemap_side( &_world.main, co, gate->to_world, i );
+               render_cubemap_side( &_world.main, co, gate->to_world, i, &temp_vg_framebuffer );
 
                u8 *dest_side = src_image + i*512*512*3;
                glReadBuffer( GL_COLOR_ATTACHMENT0 );
index f488bc59010eed8825532c76ede4806ae357435a..347cea7eebbabfc676d4b30867de840ee645306a 100644 (file)
@@ -73,7 +73,7 @@ void render_world_position( world_instance *world, vg_camera *cam );
 void render_world_depth( world_instance *world, vg_camera *cam );
 void render_world( world_instance *world, vg_camera *cam,
                    int stenciled, int viewing_from_gate, 
-                   int with_water, int with_cubemaps );
+                   int with_water, int with_cubemaps, vg_framebuffer *target_fb );
 void render_world_cubemaps( world_instance *world );
 void bind_terrain_noise(void);
 void render_world_override( world_instance *world,
@@ -82,7 +82,7 @@ void render_world_override( world_instance *world,
                             vg_camera *cam,
                             ent_spawn *dest_spawn, v4f map_info );
 void render_world_preview( vg_camera *cam );
-void render_world_gates( world_instance *world, vg_camera *cam );
+void render_world_gates( world_instance *world, vg_camera *cam, vg_framebuffer *target_fb );
 void imgui_world_light_edit( ui_context *ctx, world_instance *world );
 
 #define WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( WORLD, SHADER )            \
index d3dbcf703fbac4110734f7ad78f575d2bfc96e76..bfa5064baadd06d8949e5142b4b6e0ed434f35b9 100644 (file)
@@ -11,12 +11,17 @@ void world_volumes_update( world_instance *world, v3f pos )
       i32 idx = _world.active_trigger_volumes[i];
       ent_volume *volume = af_arritm( &world->ent_volume, idx );
 
+      bool in_volume = 1;
+
       v3f local;
       m4x3_mulv( volume->to_local, pos, local );
-      if( (fabsf(local[0]) <= 1.0f) &&
-          (fabsf(local[1]) <= 1.0f) &&
-          (fabsf(local[2]) <= 1.0f) && 
-          (localplayer.subsystem != k_player_subsystem_dead) )
+      if( (fabsf(local[0]) > 1.0f) || (fabsf(local[1]) > 1.0f) || (fabsf(local[2]) > 1.0f) )
+         in_volume = 0;
+
+      if( (localplayer.subsystem == k_player_subsystem_dead) && !(volume->flags & k_ent_volume_flag_water) )
+         in_volume = 0;
+
+      if( in_volume )
       {
          _world.active_trigger_volumes[ j ++ ] = idx;
          boxf cube = {{-1.0f,-1.0f,-1.0f},{1.0f,1.0f,1.0f}};
@@ -112,7 +117,7 @@ void world_volumes_update( world_instance *world, v3f pos )
          if( _world.active_trigger_volume_count > VG_ARRAY_LEN(_world.active_trigger_volumes) ) 
             continue;
 
-         if( localplayer.subsystem == k_player_subsystem_dead )
+         if( (localplayer.subsystem == k_player_subsystem_dead) && !(volume->flags & k_ent_volume_flag_water) )
             continue;
 
          v3f local;
index 741843cc263db542cee1f4c48525a03d6c68a7c6..f9ced3f3dc6650018de442c33f6abc5f3a2579c3 100644 (file)
@@ -90,7 +90,7 @@ void render_water_texture( world_instance *world, vg_camera *cam )
    glEnable( GL_DEPTH_TEST );
    glDisable( GL_BLEND );
    glCullFace( GL_FRONT );
-   render_world( world, &water_cam, 0, 1, 0, 1 );
+   render_world( world, &water_cam, 0, 1, 0, 1, _vg_render.fb_water_reflection );
    glCullFace( GL_BACK );
    
    /*
@@ -117,7 +117,6 @@ void render_water_texture( world_instance *world, vg_camera *cam )
    glEnable( GL_DEPTH_TEST );
    glDisable( GL_BLEND );
    render_world_depth( world, &beneath_cam );
-   //glViewport( 0,0, g_render_x, g_render_y );
 }
 
 void render_water_surface( world_instance *world, vg_camera *cam )