MENY
[carveJwlIkooP6JGAAIwe30JlM.git] / world.h
diff --git a/world.h b/world.h
index 9ae654e27937333728d5db924b404edb88723176..7f8432ab08d9f0630777be8aa1e33db78cac529f 100644 (file)
--- a/world.h
+++ b/world.h
@@ -1,3 +1,7 @@
+/*
+ * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved
+ */
+
 #include "common.h"
 
 static int ray_world( v3f pos, v3f dir, ray_hit *hit );
@@ -10,11 +14,9 @@ static int ray_world( v3f pos, v3f dir, ray_hit *hit );
 #include "network.h"
 #include "network_msg.h"
 #include "scene.h"
-#include "terrain.h"
 #include "render.h"
 #include "rigidbody.h"
 #include "bvh.h"
-#include "lighting.h"
 #include "model.h"
 
 #include "traffic.h" /*TODO: -> world_traffic.h */
@@ -56,6 +58,17 @@ static struct gworld
    spawns[32];
    u32 spawn_count;
 
+   struct achievement_zone
+   {
+      m4x3f transform, inv_transform;
+      char name[32];
+      int triggered;
+   }
+   * achievement_zones;
+
+   u32 achievement_zones_count,
+       achievement_zones_cap;
+
    struct subworld_routes
    {
       struct route_node
@@ -286,12 +299,15 @@ static void world_free( void *_ )
 {
    mesh_free( &world.cars );
    mesh_free( &world.skydome );
+   vg_free( world.achievement_zones );
 }
 
 static void world_update( v3f pos )
 {
    world_routes_update();
+#if 0
    world_routes_debug();
+#endif
    
    int closest = 0;
    float min_dist = INFINITY;
@@ -327,6 +343,30 @@ static void world_update( v3f pos )
          }
       }
    }
+
+   for( int i=0; i<world.achievement_zones_count; i++ )
+   {
+      struct achievement_zone *zone = &world.achievement_zones[i];
+
+      if( zone->triggered )
+         continue;
+
+      v3f local;
+      m4x3_mulv( zone->inv_transform, pos, local );
+      
+      if( (fabsf(local[0]) <= 1.0f) &&
+          (fabsf(local[1]) <= 1.0f) &&
+          (fabsf(local[2]) <= 1.0f) )
+      {
+         zone->triggered = 1;
+         steam_set_achievement( zone->name );
+         steam_store_achievements();
+      }
+
+      vg_line_boxf_transformed( zone->transform, (boxf){{-1.0f,-1.0f,-1.0f},
+                                                        { 1.0f, 1.0f, 1.0f}}, 
+                                                        0xff00ff00 );
+   }
    
    sfd_update( &world.sfd.tester );
 }