(50c0271)
authorhgn <hgodden00@gmail.com>
Tue, 19 Mar 2024 13:33:08 +0000 (13:33 +0000)
committerhgn <hgodden00@gmail.com>
Tue, 19 Mar 2024 13:33:08 +0000 (13:33 +0000)
25 files changed:
ent_challenge.c
ent_challenge.h
ent_glider.c
ent_glider.h
ent_miniworld.c
ent_miniworld.h
ent_npc.c
ent_npc.h
ent_objective.c
ent_objective.h
ent_region.c
ent_region.h
ent_relay.c
ent_relay.h
ent_route.c
ent_route.h
ent_skateshop.c
ent_skateshop.h
entity.c
entity.h
shaders/impl.c
world_entity.c
world_entity.h
world_gate.c
world_gate.h

index 8f8c277338f3312562591e0b9924a951fd712ba6..9499d0fed8e7b0e6ce9f51fcd1cf0a161d373c55 100644 (file)
@@ -4,13 +4,15 @@
 #include "gui.h"
 #include "audio.h"
 
-void ent_challenge_call( world_instance *world, ent_call *call )
+entity_call_result ent_challenge_call( world_instance *world, ent_call *call )
 {
    u32 index = mdl_entity_id_id( call->id );
    ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
 
-   if( call->function == 0 ){ /* unlock() */
-      if( !challenge->status ){
+   if( call->function == 0 ) /* unlock() */
+   {
+      if( !challenge->status )
+      {
          vg_info( "challenge( '%s' )\n", 
                   mdl_pstr( &world->meta, challenge->pstr_alias) );
          ent_call call;
@@ -20,10 +22,13 @@ void ent_challenge_call( world_instance *world, ent_call *call )
          entity_call( world, &call );
       }
       challenge->status = 1;
+      return k_entity_call_result_OK;
    }
-   else if( call->function == 1 ){  /* view() */
+   else if( call->function == 1 ) /* view() */
+   {
       if( (localplayer.subsystem == k_player_subsystem_walk) &&
-          (world_static.challenge_target == NULL) ){
+          (world_static.challenge_target == NULL) )
+      {
          world_static.challenge_target = NULL;
          world_entity_set_focus( call->id );
          world_entity_focus_modal();
@@ -35,11 +40,10 @@ void ent_challenge_call( world_instance *world, ent_call *call )
          if( gui_new_helper( input_button_list[k_srbind_mback], &text ))
             vg_strcat( &text, "exit" );
       }
+      return k_entity_call_result_OK;
    }
-   else {
-      vg_print_backtrace();
-      vg_error( "Unhandled function id: %u\n", call->function );
-   }
+   else 
+      return k_entity_call_result_unhandled;
 }
 
 void ent_challenge_preupdate( ent_challenge *challenge, int active )
index 9b9ea10fad61accb3ab25b7f74353561ff550543..d5108a8c9bb5b2a4993ab074bec69a815481789d 100644 (file)
@@ -2,4 +2,4 @@
 #include "entity.h"
 
 void ent_challenge_preupdate( ent_challenge *challenge, int active );
-void ent_challenge_call( world_instance *world, ent_call *call );
+entity_call_result ent_challenge_call( world_instance *world, ent_call *call );
index dbea8eadaaaecb0d425ce7780055c496051403e7..12b05757cd1ce1c30e9ab933361d69bb475fd9a2 100644 (file)
@@ -2,21 +2,24 @@
 #include "entity.h"
 #include "player_glide.h"
 
-void ent_glider_call( world_instance *world, ent_call *call )
+entity_call_result ent_glider_call( world_instance *world, ent_call *call )
 {
    u32 index = mdl_entity_id_id( call->id );
    ent_glider *glider = mdl_arritm( &world->ent_glider, index );
 
-   if( call->function == 0 ){
+   if( call->function == 0 )
+   {
       glider->flags |= 0x1;
+      return k_entity_call_result_OK;
    }
-   else if( call->function == 1 ){
-      if( glider->flags & 0x1 ){
+   else if( call->function == 1 )
+   {
+      if( glider->flags & 0x1 )
+      {
          player_glide_equip_glider();
       }
+      return k_entity_call_result_OK;
    }
-   else {
-      vg_print_backtrace();
-      vg_error( "Unhandled function id: %i\n", call->function );
-   }
+   else 
+      return k_entity_call_result_unhandled;
 }
index 51857b2fb57a072fa6eef93a425e62cd7e898784..5815ddafb309e5796b121353a4d3d35f915c0f16 100644 (file)
@@ -1,4 +1,4 @@
 #pragma once
 #include "entity.h"
 
-void ent_glider_call( world_instance *world, ent_call *call );
+entity_call_result ent_glider_call( world_instance *world, ent_call *call );
index fcdba0b12c20cf62967d84c6037cda3ab9d97fe1..2fed03137313e7549a36cfee7939cd716ca2491c 100644 (file)
@@ -9,14 +9,15 @@
 
 struct global_miniworld global_miniworld;
 
-void ent_miniworld_call( world_instance *world, ent_call *call )
+entity_call_result ent_miniworld_call( world_instance *world, ent_call *call )
 {
    ent_miniworld *miniworld = mdl_arritm( &world->ent_miniworld, 
                                           mdl_entity_id_id(call->id) );
 
    int world_id = world - world_static.instances;
 
-   if( call->function == 0 ){ /* zone() */
+   if( call->function == 0 ) /* zone() */
+   {
       const char *uid = mdl_pstr( &world->meta, miniworld->pstr_world );
       skaterift_load_world_command( 1, (const char *[]){ uid } );
 
@@ -28,17 +29,25 @@ void ent_miniworld_call( world_instance *world, ent_call *call )
 
       if( gui_new_helper( input_button_list[k_srbind_miniworld_resume], &text ))
          vg_strcat( &text, "Enter World" );
+
+      return k_entity_call_result_OK;
    }
-   else if( call->function == 1 ){
+   else if( call->function == 1 )
+   {
       global_miniworld.active = NULL;
       gui_helper_clear();
 
-      if( miniworld->proxy ){
+      if( miniworld->proxy )
+      {
          ent_prop *prop = mdl_arritm( &world->ent_prop, 
                                       mdl_entity_id_id(miniworld->proxy) );
          prop->flags &= ~0x1;
       }
+
+      return k_entity_call_result_OK;
    }
+   else
+      return k_entity_call_result_unhandled;
 }
 
 static void miniworld_icon( vg_camera *cam, enum gui_icon icon, 
index b1aed55bf12d73b2717e8ff51d35e6ab827fb66e..278cf75ec6eb50c2912e329b1df93ef9fb5ce313 100644 (file)
@@ -12,7 +12,7 @@ struct global_miniworld
 }
 extern global_miniworld;
 
-void ent_miniworld_call( world_instance *world, ent_call *call );
+entity_call_result ent_miniworld_call( world_instance *world, ent_call *call );
 void ent_miniworld_render( world_instance *host_world, vg_camera *cam );
 void ent_miniworld_goback(void);
 void ent_miniworld_preupdate(void);
index d43122330120a34bbec263daed8f30d2f8ba1cf9..8fccd29552bab08f21344dba4951cdc848a7496f 100644 (file)
--- a/ent_npc.c
+++ b/ent_npc.c
@@ -70,7 +70,7 @@ static struct npc *npc_resolve( u32 id )
    else return NULL;
 }
 
-static void npc_slowmo_call( ent_npc *npc, ent_call *call )
+static entity_call_result npc_slowmo_call( ent_npc *npc, ent_call *call )
 {
    if( call->function == 0 )
    {
@@ -96,22 +96,26 @@ static void npc_slowmo_call( ent_npc *npc, ent_call *call )
          if( gui_new_helper( input_button_list[k_srbind_replay_resume], &text ))
             vg_strcat( &text, "Resume" );
       }
+      return k_entity_call_result_OK;
    }
    else if( call->function == -1 )
    {
       world_entity_clear_focus();
       gui_helper_clear();
+      return k_entity_call_result_OK;
    }
+   else
+      return k_entity_call_result_unhandled;
 }
 
-void ent_npc_call( world_instance *world, ent_call *call )
+entity_call_result ent_npc_call( world_instance *world, ent_call *call )
 {
    u32 index = mdl_entity_id_id( call->id );
    ent_npc *npc = mdl_arritm( &world->ent_npc, index );
 
    if( npc->id == 2 )
    {
-      npc_slowmo_call( npc, call );
+      return npc_slowmo_call( npc, call );
    }
    else if( npc->id == 3 )
    {
@@ -122,12 +126,16 @@ void ent_npc_call( world_instance *world, ent_call *call )
          vg_str text;
          if( gui_new_helper( input_button_list[k_srbind_maccept], &text ))
             vg_strcat( &text, "Preview course" );
+         return k_entity_call_result_OK;
       }
       else if( call->function == -1 )
       {
          world_entity_clear_focus();
          gui_helper_clear();
+         return k_entity_call_result_OK;
       }
+      else
+         return k_entity_call_result_unhandled;
    }
    else if( npc->id == 4 )
    {
@@ -137,11 +145,15 @@ void ent_npc_call( world_instance *world, ent_call *call )
          vg_str text;
          if( gui_new_helper( input_button_list[k_srbind_camera], &text ))
             vg_strcat( &text, "First/Thirdperson" );
+         return k_entity_call_result_OK;
       }
       else if( call->function == -1 )
       {
          gui_helper_clear();
+         return k_entity_call_result_OK;
       }
+      else
+         return k_entity_call_result_unhandled;
    }
    else
    {
@@ -152,17 +164,16 @@ void ent_npc_call( world_instance *world, ent_call *call )
          vg_str text;
          if( gui_new_helper( input_button_list[k_srbind_maccept], &text ))
             vg_strcat( &text, "Talk to ???" );
+         return k_entity_call_result_OK;
       }
       else if( call->function == -1 )
       {
          world_entity_clear_focus();
          gui_helper_clear();
+         return k_entity_call_result_OK;
       }
       else 
-      {
-         vg_print_backtrace();
-         vg_error( "Unhandled function id: %i\n", call->function );
-      }
+         return k_entity_call_result_unhandled;
    }
 }
 
index 24e7e02bcb5922bbba6baa54508e944ab08dd35c..648f44775db3a729cfad4bff10558604c12bc286 100644 (file)
--- a/ent_npc.h
+++ b/ent_npc.h
@@ -22,7 +22,7 @@ enum npc_id
 
 void npc_load_model( struct npc *npc, const char *path );
 void ent_npc_preupdate( ent_npc *ent, int active );
-void ent_npc_call( world_instance *world, ent_call *call );
+entity_call_result ent_npc_call( world_instance *world, ent_call *call );
 void npc_update( ent_npc *ent );
 void npc_render( ent_npc *ent, world_instance *world, vg_camera *cam );
 void npc_init(void);
index 66b822db62d9e4eb9bf2a20cd71ab76db8c2230f..6a8bbe5bef6a2afb3224cc388e1fd101fbbc97e7 100644 (file)
@@ -81,21 +81,26 @@ static int ent_objective_check_filter( ent_objective *objective ){
    }
 }
 
-void ent_objective_call( world_instance *world, ent_call *call )
+entity_call_result ent_objective_call( world_instance *world, ent_call *call )
 {
    u32 index = mdl_entity_id_id( call->id );
    ent_objective *objective = mdl_arritm( &world->ent_objective, index );
 
-   if( call->function == 0 ){
-      if( objective->flags & (k_ent_objective_hidden|
-                              k_ent_objective_passed)) return;
+   if( call->function == 0 )
+   {
+      if( objective->flags & (k_ent_objective_hidden|k_ent_objective_passed))
+      {
+         return k_entity_call_result_OK;
+      }
 
-      if( world_static.challenge_target ){
+      if( world_static.challenge_target )
+      {
          if( (world_static.challenge_target == objective) && 
               ent_objective_check_filter( objective )){
             ent_objective_pass( world, objective );
          }
-         else {
+         else 
+         {
             audio_lock();
             audio_oneshot_3d( &audio_challenge[6], localplayer.rb.co,
                               30.0f, 1.0f );
@@ -106,25 +111,29 @@ void ent_objective_call( world_instance *world, ent_call *call )
             world_static.focused_entity = 0;
          }
       }
+
+      return k_entity_call_result_OK;
    }
-   else if( call->function == 2 ){
+   else if( call->function == 2 )
+   {
       objective->flags &= ~k_ent_objective_hidden;
 
       if( mdl_entity_id_type( objective->id_next ) == k_ent_objective ){
          call->id = objective->id_next;
          entity_call( world, call );
       }
+      return k_entity_call_result_OK;
    }
-   else if( call->function == 3 ){
+   else if( call->function == 3 )
+   {
       objective->flags |=  k_ent_objective_hidden;
 
       if( mdl_entity_id_type( objective->id_next ) == k_ent_objective ){
          call->id = objective->id_next;
          entity_call( world, call );
       }
+      return k_entity_call_result_OK;
    }
-   else {
-      vg_print_backtrace();
-      vg_error( "Unhandled function id: %u\n", call->function );
-   }
+   else 
+      return k_entity_call_result_unhandled;
 }
index 0f3e4e5d476263e7174a2c65724ec46be0ad96a3..9d947723e029ec893ad698960b0b6e8937679232 100644 (file)
@@ -1,4 +1,4 @@
 #pragma once
 #include "entity.h"
 #include "world.h"
-void ent_objective_call( world_instance *world, ent_call *call );
+entity_call_result ent_objective_call( world_instance *world, ent_call *call );
index e58d594708443bd46c3ef92e70569932410348ff..5e0ec03dd2349891f09ee00bfca3c07aa3a19081 100644 (file)
@@ -15,29 +15,33 @@ u32 region_spark_colour( u32 flags )
       return 0x00;
 }
 
-void ent_region_call( world_instance *world, ent_call *call )
+entity_call_result ent_region_call( world_instance *world, ent_call *call )
 {
    ent_region *region = 
       mdl_arritm( &world->ent_region, mdl_entity_id_id(call->id) );
 
    if( !region->zone_volume )
-      return;
+      return k_entity_call_result_invalid;
 
    ent_volume *volume = 
       mdl_arritm( &world->ent_volume, mdl_entity_id_id(region->zone_volume) );
 
-   if( call->function == 0 ){ /* enter */
-      for( u32 i=0; i<mdl_arrcount(&world->ent_route); i ++ ){
+   if( call->function == 0 ) /* enter */
+   {
+      for( u32 i=0; i<mdl_arrcount(&world->ent_route); i ++ )
+      {
          ent_route *route = mdl_arritm( &world->ent_route, i );
 
          v3f local;
          m4x3_mulv( volume->to_local, route->board_transform[3], local );
          if( (fabsf(local[0]) <= 1.0f) &&
              (fabsf(local[1]) <= 1.0f) &&
-             (fabsf(local[2]) <= 1.0f) ){
+             (fabsf(local[2]) <= 1.0f) )
+         {
             route->flags &= ~k_ent_route_flag_out_of_zone;
          }
-         else {
+         else 
+         {
             route->flags |= k_ent_route_flag_out_of_zone;
          }
       }
@@ -52,14 +56,20 @@ void ent_region_call( world_instance *world, ent_call *call )
       network_send_region();
 
       localplayer.effect_data.spark.colour = region_spark_colour(region->flags);
+      return k_entity_call_result_OK;
    }
-   else if( call->function == 1 ){ /* leave */
-      for( u32 i=0; i<mdl_arrcount(&world->ent_route); i ++ ){
+   else if( call->function == 1 ) /* leave */
+   {
+      for( u32 i=0; i<mdl_arrcount(&world->ent_route); i ++ )
+      {
          ent_route *route = mdl_arritm( &world->ent_route, i );
          route->flags |= k_ent_route_flag_out_of_zone;
       }
       localplayer.effect_data.spark.colour = 0x00;
+      return k_entity_call_result_OK;
    }
+   else
+      return k_entity_call_result_unhandled;
 }
 
 /* 
index 8aed2405f99c8428a230e716d433c7f53c9bfe0e..6a86a320b33ba136d63e0750550bf230974caaad 100644 (file)
@@ -11,4 +11,4 @@ extern global_ent_region;
 
 u32 region_spark_colour( u32 flags );
 void ent_region_re_eval( world_instance *world );
-void ent_region_call( world_instance *world, ent_call *call );
+entity_call_result ent_region_call( world_instance *world, ent_call *call );
index 50bbeabf690429b442e4d3043de67bf1c655d214..1f97584af5843f1b0384a73f9dde4bfc3be5339b 100644 (file)
@@ -1,13 +1,16 @@
 #include "ent_relay.h"
 
-void ent_relay_call( world_instance *world, ent_call *call )
+entity_call_result ent_relay_call( world_instance *world, ent_call *call )
 {
    u32 index = mdl_entity_id_id( call->id );
    ent_relay *relay = mdl_arritm( &world->ent_relay, index );
 
-   if( call->function == 0 ){
-      for( u32 i=0; i<vg_list_size(relay->targets); i++ ){
-         if( relay->targets[i][0] ){
+   if( call->function == 0 )
+   {
+      for( u32 i=0; i<vg_list_size(relay->targets); i++ )
+      {
+         if( relay->targets[i][0] )
+         {
             ent_call call;
             call.data = NULL;
             call.function = relay->targets[i][1];
@@ -15,9 +18,8 @@ void ent_relay_call( world_instance *world, ent_call *call )
             entity_call( world, &call );
          }
       }
+      return k_entity_call_result_OK;
    }
-   else {
-      vg_print_backtrace();
-      vg_error( "Unhandled function id: %u\n", call->function );
-   }
+   else 
+      return k_entity_call_result_unhandled;
 }
index acbe9432439a4c06243bf54fd83f51ec04cc62a8..054570cd6f2e4e3e05ddacb75eaa16602a7ff2a1 100644 (file)
@@ -1,3 +1,3 @@
 #pragma once
 #include "entity.h"
-void ent_relay_call( world_instance *world, ent_call *call );
+entity_call_result ent_relay_call( world_instance *world, ent_call *call );
index 11b680d6f08a00cb6419754ad2998fe676200017..026bf7048ac01237a55526ebceb827f53a99c155 100644 (file)
@@ -4,12 +4,13 @@
 
 struct global_ent_route global_ent_route;
 
-void ent_route_call( world_instance *world, ent_call *call )
+entity_call_result ent_route_call( world_instance *world, ent_call *call )
 {
    u32 index = mdl_entity_id_id( call->id );
    ent_route *route = mdl_arritm( &world->ent_route, index );
 
-   if( call->function == 0 ){ /* view() */
+   if( call->function == 0 )
+   { /* view() */
       if( localplayer.subsystem == k_player_subsystem_walk )
       {
          world_entity_set_focus( call->id );
@@ -29,12 +30,11 @@ void ent_route_call( world_instance *world, ent_call *call )
          if( gui_new_helper( input_button_list[k_srbind_mback], &text ) )
             vg_strcat( &text, "exit" );
       }
+
+      return k_entity_call_result_OK;
    }
-   else {
-      /* TODO: Comrpession */
-      vg_print_backtrace();
-      vg_error( "Unhandled function id: %u\n", call->function );
-   }
+
+   return k_entity_call_result_unhandled;
 }
 
 /* TODO: these should recieve the world instance */
index ecc3278b72714522d31a58864a5e543537ad9e10..7c5dfa3785bef6c42b7d3cc833fee5f36e391b95 100644 (file)
@@ -7,5 +7,5 @@ struct global_ent_route
 }
 extern global_ent_route;
 
-void ent_route_call( world_instance *world, ent_call *call );
+entity_call_result ent_route_call( world_instance *world, ent_call *call );
 void ent_route_preupdate( ent_route *route, int active );
index d5128f0302a447f77ffb5d439bbb65512689edc3..1065d4b58ab6a1095cd7d3d7f26e2cf1a5261780 100644 (file)
@@ -797,18 +797,20 @@ static void world_scan_thread( void *_args )
 /*
  * Entity logic: entrance event
  */
-void ent_skateshop_call( world_instance *world, ent_call *call )
+entity_call_result ent_skateshop_call( world_instance *world, ent_call *call )
 {
    u32 index = mdl_entity_id_id( call->id );
    ent_skateshop *shop = mdl_arritm( &world->ent_skateshop, index );
    vg_info( "skateshop_call\n" );
 
-   if( skaterift.activity != k_skaterift_default ) return;
-   if( !vg_loader_availible() ) return;
+   if( (skaterift.activity != k_skaterift_default) || 
+       !vg_loader_availible() ) 
+      return k_entity_call_result_invalid;
 
    if( call->function == k_ent_function_trigger )
    {
-      if( localplayer.subsystem != k_player_subsystem_walk ) return;
+      if( localplayer.subsystem != k_player_subsystem_walk )
+         return k_entity_call_result_OK;
       
       vg_info( "Entering skateshop\n" );
 
@@ -840,5 +842,8 @@ void ent_skateshop_call( world_instance *world, ent_call *call )
             vg_strcat( &text, "exit" );
          skateshop_server_helper_update();
       }
+      return k_entity_call_result_OK;
    }
+   else
+      return k_entity_call_result_unhandled;
 }
index cf8b9838cf1e3c91111ea8678ba3e1ff844b35dc..ed03ecdb74ec3095a6c8078d09e2c80ad718afc7 100644 (file)
@@ -50,5 +50,5 @@ void skateshop_render( ent_skateshop *shop );
 void skateshop_render_nonfocused( world_instance *world, vg_camera *cam );
 void skateshop_autostart_loading(void);
 void skateshop_world_preupdate( world_instance *world );
-void ent_skateshop_call( world_instance *world, ent_call *call );
+entity_call_result ent_skateshop_call( world_instance *world, ent_call *call );
 void skateshop_world_preview_preupdate(void);
index 557ba799a792d2e61e96f8fa3591b67ed72a4b78..ae506bd68fdc04fc39807abafc9cd1d5afaadb76 100644 (file)
--- a/entity.c
+++ b/entity.c
 #include "ent_glider.h"
 #include "ent_npc.h"
 
-typedef void (*fn_entity_call_handler)( world_instance *, ent_call *);
-
 void entity_call( world_instance *world, ent_call *call )
 {
-   u32 type = mdl_entity_id_type( call->id );
+   u32 type = mdl_entity_id_type( call->id ),
+       index = mdl_entity_id_id( call->id );
 
    fn_entity_call_handler table[] = {
       [k_ent_volume]    = ent_volume_call,
@@ -41,12 +40,19 @@ void entity_call( world_instance *world, ent_call *call )
 
    fn_entity_call_handler fn = table[ type ];
 
-   if( !fn ){
-      vg_error( "call to entity type: %u is undefined\n", type );
+   if( !fn )
+   {
+      vg_error( "Entity type %u does not have a call handler, "
+                "but was called anyway\n", type );
       return;
    }
 
-   fn( world, call );
+   enum entity_call_result res = fn( world, call );
+
+   if( res == k_entity_call_result_unhandled )
+   {
+      vg_warn( "Call to entity %u#%u was unhandled.\n", type, index );
+   }
 }
 
 ent_marker *ent_find_marker( mdl_context *mdl, mdl_array_ptr *arr, 
index d67c5f35d81683fda4bec559a5d7b344eb170357..80f4df7573fc7b62c440b9ba2cd29e4af024ddc4 100644 (file)
--- a/entity.h
+++ b/entity.h
@@ -38,6 +38,25 @@ typedef struct ent_list ent_list;
 typedef struct ent_glider ent_glider;
 typedef struct ent_npc ent_npc;
 
+typedef struct ent_call ent_call;
+struct ent_call{
+   u32 id;
+   i32 function;
+   void *data;
+};
+
+typedef enum entity_call_result entity_call_result;
+enum entity_call_result 
+{
+   k_entity_call_result_OK,
+   k_entity_call_result_unhandled,
+   k_entity_call_result_invalid
+};
+
+typedef enum entity_call_result 
+   (*fn_entity_call_handler)( world_instance *, ent_call *);
+
+
 enum entity_alias{
    k_ent_none        = 0,
    k_ent_gate        = 1,
@@ -527,13 +546,6 @@ struct ent_cubemap {
        framebuffer_id, renderbuffer_id, placeholder[2];
 };
 
-typedef struct ent_call ent_call;
-struct ent_call{
-   u32 id;
-   i32 function;
-   void *data;
-};
-
 struct ent_miniworld {
    mdl_transform transform;
    u32 pstr_world;
index dbcebf8258ab0a0d9067d92a3a4153d8675f0161..746279473a3d9526dd6bb94f9253b88344525f24 100644 (file)
@@ -4507,7 +4507,9 @@ struct vg_shader _shader_scene_depth = {
 "\n"
 "   float d = dot( pnorm, halfview );\n"
 "   float t = dot((pnorm*pdist - pos), pnorm) / d;\n"
-"   return t * g_water_fog;\n"
+"\n"
+"   // TODO: Make g_water_fog a material param\n"
+"   return t * 0.3;//g_water_fog;\n"
 "}\n"
 "\n"
 "void main()\n"
@@ -6018,7 +6020,8 @@ struct vg_shader _shader_scene_water = {
 "{\n"
 "   vec3 surface_tint = mix(uShoreColour, uOceanColour, depthvalue);\n"
 "\n"
-"   float ffresnel = pow(1.0-dot( vnorm, halfview ),5.0);\n"
+"   //TODO: Make exponent a material param (default: 5.0)\n"
+"   float ffresnel = pow(1.0-dot( vnorm, halfview ),0.8);\n"
 "\n"
 "   vec3 lightdir = vec3(0.95,0.0,-0.3);\n"
 "   vec3 specdir = reflect( -lightdir, vnorm );\n"
@@ -6062,8 +6065,10 @@ struct vg_shader _shader_scene_water = {
 "   // Surface colour composite\n"
 "   float depthvalue = clamp( -world_water_depth(aCo)*(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"
+"   //TODO: Material param (default: 0.008)\n"
+"   vec2 world_coord = aCo.xz * 0.12;\n"
+"   //TODO: Material param ( 0.008, 0.006, 0.003, 0.03 );\n"
+"   vec4 time_offsets = vec4( uTime ) * vec4( 0.08, -0.08, -0.03, -0.01 );\n"
 "   vec4 dudva = texture( uTexDudv, world_coord + time_offsets.xy )-0.5;\n"
 "   vec4 dudvb = texture( uTexDudv, world_coord *7.0 - time_offsets.zw )-0.5;\n"
 "\n"
index 88e0e7e1a240815bc38bde6606efa077f919d09d..13c89a025da827f4382dddd0830040f8074d083e 100644 (file)
@@ -347,16 +347,20 @@ void world_default_spawn_pos( world_instance *world, v3f pos )
    }
 }
 
-void ent_volume_call( world_instance *world, ent_call *call )
+entity_call_result 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( call->function == k_ent_function_trigger ){
+   if( !volume->target ) 
+      return k_entity_call_result_OK;
+
+   if( call->function == k_ent_function_trigger )
+   {
       call->id = volume->target;
 
-      if( volume->flags & k_ent_volume_flag_particles ){
+      if( volume->flags & k_ent_volume_flag_particles )
+      {
          float *co = alloca( sizeof(float)*3 );
          co[0] = vg_randf64(&vg.rand)*2.0f-1.0f;
          co[1] = vg_randf64(&vg.rand)*2.0f-1.0f;
@@ -367,29 +371,40 @@ void ent_volume_call( world_instance *world, ent_call *call )
          call->data = co;
          entity_call( world, call );
       }
-      else{
+      else
+      {
          call->function = volume->trigger.event;
          entity_call( world, call );
       }
+
+      return k_entity_call_result_OK;
    }
-   else if( call->function == k_ent_function_trigger_leave ){
+   else if( call->function == k_ent_function_trigger_leave )
+   {
       call->id = volume->target;
 
-      if( volume->flags & k_ent_volume_flag_particles ){
+      if( volume->flags & k_ent_volume_flag_particles )
+      {
          vg_warn( "Invalid condition; calling leave on particle volume.\n" );
       }
-      else{
+      else
+      {
          call->function = volume->trigger.event_leave;
          entity_call( world, call );
       }
+
+      return k_entity_call_result_OK;
    }
+
+   return k_entity_call_result_unhandled;
 }
 
-void ent_audio_call( world_instance *world, ent_call *call )
+entity_call_result ent_audio_call( world_instance *world, ent_call *call )
 {
-   if( world->status == k_world_status_unloading ){
+   if( world->status == k_world_status_unloading )
+   {
       vg_warn( "cannot modify audio while unloading world\n" );
-      return;
+      return k_entity_call_result_invalid;
    }
 
    u8 world_id = (world - world_static.instances) + 1;
@@ -398,14 +413,16 @@ void ent_audio_call( world_instance *world, ent_call *call )
 
    v3f sound_co;
 
-   if( call->function == k_ent_function_particle_spawn ){
+   if( call->function == k_ent_function_particle_spawn )
+   {
       v3_copy( call->data, sound_co );
    }
-   else if( call->function == k_ent_function_trigger ){
+   else if( call->function == k_ent_function_trigger )
+   {
       v3_copy( audio->transform.co, sound_co );
    }
    else
-      return;
+      return k_entity_call_result_unhandled;
 
    float chance = vg_randf64(&vg.rand)*100.0f,
          bar = 0.0f;
@@ -458,7 +475,7 @@ void ent_audio_call( world_instance *world, ent_call *call )
                if( existing ){
                   if( existing->source == &clip->_.clip ){
                      audio_unlock();
-                     return;
+                     return k_entity_call_result_OK;
                   }
                  
                   existing->group = 0;
@@ -479,20 +496,24 @@ void ent_audio_call( world_instance *world, ent_call *call )
          }
 
          audio_unlock();
-         return;
+         return k_entity_call_result_OK;
       }
    }
+   return k_entity_call_result_OK;
 }
 
 
-void ent_ccmd_call( world_instance *world, ent_call *call )
+entity_call_result ent_ccmd_call( world_instance *world, ent_call *call )
 {
-   if( call->function == k_ent_function_trigger ){
+   if( call->function == k_ent_function_trigger )
+   {
       u32 index = mdl_entity_id_id( call->id );
       ent_ccmd *ccmd = mdl_arritm( &world->ent_ccmd, index );
-      vg_execute_console_input( mdl_pstr(&world->meta, ccmd->pstr_command), 
-                                0 );
+      vg_execute_console_input( mdl_pstr(&world->meta, ccmd->pstr_command), 0 );
+      return k_entity_call_result_OK;
    }
+   else
+      return k_entity_call_result_unhandled;
 }
 
 /*
index f9a3ec9447212b8428b743dd7e1fb681432636a3..5f784d200aa3fc9c92eac920dc2d89ef377eb8d6 100644 (file)
@@ -13,9 +13,9 @@ void world_default_spawn_pos( world_instance *world, v3f pos );
 void world_entity_start( world_instance *world, vg_msg *sav );
 void world_entity_serialize( world_instance *world, vg_msg *sav );
 
-void ent_volume_call( world_instance *world, ent_call *call );
-void ent_audio_call( world_instance *world, ent_call *call );
-void ent_ccmd_call( world_instance *world, ent_call *call );
+entity_call_result ent_volume_call( world_instance *world, ent_call *call );
+entity_call_result ent_audio_call( world_instance *world, ent_call *call );
+entity_call_result ent_ccmd_call( world_instance *world, ent_call *call );
 
 void entity_bh_expand_bound( void *user, boxf bound, u32 item_index );
 float entity_bh_centroid( void *user, u32 item_index, int axis );
index 26ce0924ff39dcb2f7d83fcbd472b8665750a13b..2a236d4391c0d8d7f67d8bcc94bcbad42151a787 100644 (file)
@@ -295,17 +295,19 @@ u32 world_intersect_gates( world_instance *world, v3f pos, v3f last )
    return 0;
 }
 
-void ent_gate_call( world_instance *world, ent_call *call )
+entity_call_result ent_gate_call( world_instance *world, ent_call *call )
 {
    u32 index = mdl_entity_id_id( call->id );
    ent_gate *gate = mdl_arritm( &world->ent_gate, index );
 
-   if( call->function == 0 ){ /* unlock() */
+   if( call->function == 0 ) /* unlock() */
+   { 
       gate->flags &= ~k_ent_gate_locked;
+      return k_entity_call_result_OK;
    }
-   else {
-      vg_print_backtrace();
-      vg_error( "Unhandled function id: %u\n", call->function );
+   else 
+   {
+      return k_entity_call_result_unhandled;
    }
 }
 
@@ -315,10 +317,12 @@ void ent_gate_call( world_instance *world, ent_call *call )
  */
 void world_unlink_nonlocal( world_instance *world )
 {
-   for( u32 j=0; j<mdl_arrcount(&world->ent_gate); j ++ ){
+   for( u32 j=0; j<mdl_arrcount(&world->ent_gate); j ++ )
+   {
       ent_gate *gate = mdl_arritm( &world->ent_gate, j );
 
-      if( gate->flags & k_ent_gate_nonlocal ){
+      if( gate->flags & k_ent_gate_nonlocal )
+      {
          gate->flags &= ~k_ent_gate_linked;
       }
    }
index 13b14785df386cef816b646800845d2741ecf6e1..a071e4bb20ee575e59c5f1722ade8b4da0ac0dab 100644 (file)
@@ -27,7 +27,7 @@ int render_gate( world_instance *world, world_instance *world_inside,
 int gate_intersect( ent_gate *gate, v3f pos, v3f last );
 u32 world_intersect_gates( world_instance *world, v3f pos, v3f last );
 
-void ent_gate_call( world_instance *world, ent_call *call );
+entity_call_result ent_gate_call( world_instance *world, ent_call *call );
 void ent_gate_get_mdl_mtx( ent_gate *gate, m4x3f mmdl );
 
 void world_link_gates_async( void *payload, u32 size );