gate passthrough jump
authorhgn <hgodden00@gmail.com>
Mon, 27 Mar 2023 14:58:07 +0000 (15:58 +0100)
committerhgn <hgodden00@gmail.com>
Mon, 27 Mar 2023 14:58:07 +0000 (15:58 +0100)
player_skate.c
world.h
world_gen.h
world_render.h

index df54c58e02fbe411734b7e38ce8dddd70f4899e1..2ebcee2448668cbdcd0152c5c5b98a537e414069 100644 (file)
@@ -394,15 +394,18 @@ void player__approximate_best_trajectory( player_instance *player )
 
       v3_copy( launch_v, p->v );
 
+      m3x3f basis;
+      m3x3_copy( player->basis, basis );
+
       for( int i=1; i<=50; i++ )
       {
          float t = (float)i * k_trace_delta;
 
          v3_muls( launch_v, t, co1 );
-         v3_muladds( co1, player->basis[1], -0.5f * gravity * t*t, co1 );
+         v3_muladds( co1, basis[1], -0.5f * gravity * t*t, co1 );
          v3_add( launch_co, co1, co1 );
 
-         float launch_vy = v3_dot( launch_v,player->basis[1] );
+         float launch_vy = v3_dot( launch_v,basis[1] );
          if( !grind_located && (launch_vy - gravity*t < 0.0f) )
          {
             v3f closest;
@@ -410,15 +413,15 @@ void player__approximate_best_trajectory( player_instance *player )
             {
                v3f ve;
                v3_copy( launch_v, ve );
-               v3_muladds( ve, player->basis[1], -gravity * t, ve );
+               v3_muladds( ve, basis[1], -gravity * t, ve );
 
                if( skate_grind_scansq( player, closest, ve, 0.5f, &grind ) )
                {
                   /* check alignment */
-                  v2f v0 = { v3_dot( ve, player->basis[0] ), 
-                             v3_dot( ve, player->basis[2] ) },
-                      v1 = { v3_dot( grind.dir, player->basis[0] ), 
-                             v3_dot( grind.dir, player->basis[2] ) };
+                  v2f v0 = { v3_dot( ve, basis[0] ), 
+                             v3_dot( ve, basis[2] ) },
+                      v1 = { v3_dot( grind.dir, basis[0] ), 
+                             v3_dot( grind.dir, basis[2] ) };
 
                   v2_normalize( v0 );
                   v2_normalize( v1 );
@@ -433,6 +436,17 @@ void player__approximate_best_trajectory( player_instance *player )
             }
          }
 
+         if( world->rendering_gate ){
+            ent_gate *gate = world->rendering_gate;
+            if( gate_intersect( gate, co1, co0 ) ){
+               m4x3_mulv( gate->transport, co0, co0 );
+               m4x3_mulv( gate->transport, co1, co1 );
+               m3x3_mulv( gate->transport, launch_v, launch_v);
+               m4x3_mulv( gate->transport, launch_co, launch_co );
+               m3x3_mul( gate->transport, basis, basis );
+            }
+         }
+
          float t1;
          v3f n;
 
diff --git a/world.h b/world.h
index f00e146b0f53fe0f0c7a199f5aeb93f45335d268..ff2c2e3610b4bb79b809bbd1be2e289d641b8d92 100644 (file)
--- a/world.h
+++ b/world.h
@@ -18,6 +18,7 @@ typedef struct world_instance world_instance;
 #include "rigidbody.h"
 #include "bvh.h"
 #include "model.h"
+#include "entity.h"
 
 #include "shaders/scene_standard.h"
 #include "shaders/scene_standard_alphatest.h"
@@ -155,6 +156,8 @@ struct world_instance
                  ent_checkpoint,
                  ent_route;
 
+   ent_gate *rendering_gate;
+
 #if 0
    /*
     * Named safe places to respawn
index f63026e7b44304943e1b4d1dce39a1610de9b93e..b35c6c25f036a3a4380b1d7a0b24afa47ee2f401 100644 (file)
@@ -875,13 +875,17 @@ VG_STATIC void world_unload( world_instance *world )
    mesh_free( &world->mesh_route_lines );
    mesh_free( &world->mesh_geo );
    mesh_free( &world->mesh_no_collide );
-
+   
+   /* glDeleteBuffers silently ignores 0's and names that do not correspond to 
+    * existing buffer objects. 
+    * */
    glDeleteBuffers( 1, &world->tbo_light_entities );
    glDeleteTextures( 1, &world->tex_light_entities );
    glDeleteTextures( 1, &world->tex_light_cubes );
 
    /* FIXME: CANT DO THIS HERE */
    /*        whynot? */
+   /*        oh this should be moved to a global function */
    world_global.time = 0.0;
    world_global.rewind_from = 0.0;
    world_global.rewind_to = 0.0;
@@ -898,7 +902,6 @@ VG_STATIC void world_unload( world_instance *world )
    vg_linear_clear( world->audio_vgl );
 #endif
 
-
    vg_release_thread_sync();
 }
 
@@ -907,8 +910,11 @@ VG_STATIC void world_clean( world_instance *world )
    memset( &world->meta, 0, sizeof(mdl_context) );
 
    /*
-    * TODO: Theres probably a better way to do this? 
-    */
+    * TODO: Theres probably a better way to do this? */
+   /*       yep, find all members that can be memsetted to 0. this is probably
+    *       every member anyway, given the below is just setting to 0
+    *
+    *       also: rename clean to init? */
 
    world->textures = NULL;
    world->texture_count = 0;
@@ -922,6 +928,7 @@ VG_STATIC void world_clean( world_instance *world )
    world->geo_bh = NULL;
    world->volume_bh = NULL;
    world->audio_bh = NULL;
+   world->rendering_gate = NULL;
 
    world->water.enabled = 0;
 
index 811e6a447bf5cd4e287d75c3bf5a46375fdaa042..09ecc19e4ce9241eca46edcf04ab43df6cd406a3 100644 (file)
@@ -376,6 +376,10 @@ VG_STATIC void render_world_gates( world_instance *world, camera *cam,
 #else
       render_gate( world, gate, cam, layer_depth );
 #endif
+
+      /* should really be set in fixed update since its used in the physics
+       * of most systems. too bad! */
+      world->rendering_gate = gate;
    }
 }