proxy models
authorhgn <hgodden00@gmail.com>
Sun, 19 Nov 2023 04:40:33 +0000 (04:40 +0000)
committerhgn <hgodden00@gmail.com>
Sun, 19 Nov 2023 04:40:33 +0000 (04:40 +0000)
29 files changed:
blender_export.py
ent_miniworld.c
entity.h
maps_src/dev_hub/main.mdl
shaders/model_board_view.h
shaders/model_character_view.h
shaders/model_entity.h
shaders/model_sky.h
shaders/model_sky_space.h
shaders/scene_cubemapped.h
shaders/scene_depth.h
shaders/scene_font.h
shaders/scene_fxglow.h
shaders/scene_override.h
shaders/scene_position.h
shaders/scene_route.h
shaders/scene_scoretext.h
shaders/scene_standard.h
shaders/scene_standard_alphatest.h
shaders/scene_terrain.h
shaders/scene_vertex_blend.h
shaders/scene_water.h
shaders/scene_water_fast.h
world.h
world_entity.c
world_gen.c
world_load.c
world_render.c
world_volumes.c

index b4a501d64ad36bce28ed88f6473e7f70f46bab25..36ca3681d866831fdf74430cc34176450c85435a 100644 (file)
@@ -40,7 +40,8 @@ sr_entity_list = [
    ('ent_objective',    'Objective',      '', 18 ),
    ('ent_challenge',    'Challenge',      '', 19 ),
    ('ent_relay',        'Relay',          '', 20 ),
-   ('ent_miniworld',    'Mini World',     '', 22 )
+   ('ent_miniworld',    'Mini World',     '', 22 ),
+   ('ent_prop',         'Prop',           '', 23 )
 ]
 
 MDL_VERSION_NR = 104
@@ -283,7 +284,7 @@ class ent_water(Structure):
 class volume_trigger(Structure):
 #{
    _fields_ = [("event",c_uint32),
-               ("blank",c_uint32)]
+               ("event_leave",c_uint32)]
 #}
 
 class volume_particles(Structure):
@@ -527,9 +528,17 @@ class ent_cubemap(Structure):#{
 class ent_miniworld(Structure):#{
    _fields_ = [("transform",mdl_transform),
                ("pstr_world",c_uint32),
-               ("purpose",c_int32)]
+               ("purpose",c_int32),
+               ("proxy",c_uint32)]
 
-   sr_functions = { 0: 'zone' }
+   sr_functions = { 0: 'zone', 1: 'leave' }
+#}
+
+class ent_prop(Structure):#{
+   _fields_ = [("transform",mdl_transform),
+               ("submesh_start",c_uint32),
+               ("submesh_count",c_uint32),
+               ("flags",c_uint32)]
 #}
 
 def obj_ent_type( obj ):
@@ -1665,6 +1674,7 @@ def sr_compile( collection ):
          # entity ignore mesh list
          #
          if ent_type == 'ent_traffic': continue
+         if ent_type == 'ent_prop': continue
          if ent_type == 'ent_font': continue
          if ent_type == 'ent_font_variant': continue
          if ent_type == 'ent_menuitem': continue
@@ -1841,6 +1851,7 @@ def sr_compile( collection ):
             if obj_data.target:#{
                volume.target = sr_entity_id( obj_data.target )
                volume._anon.trigger.event = obj_data.target_event
+               volume._anon.trigger.event_leave = obj_data.target_event_leave
             #}
 
             sr_ent_push(volume)
@@ -1960,8 +1971,17 @@ def sr_compile( collection ):
 
             compile_obj_transform( obj, miniworld.transform )
             miniworld.pstr_world = sr_compile_string( obj_data.world )
+            miniworld.proxy = sr_entity_id( obj_data.proxy )
             sr_ent_push( miniworld )
          #}
+         elif ent_type == 'ent_prop':#{
+            prop = ent_prop()
+            compile_obj_transform( obj, prop.transform )
+            prop.submesh_start, prop.submesh_count, _ = \
+                  sr_compile_mesh_internal( obj )
+            prop.flags = 0
+            sr_ent_push( prop )
+         #}
       #}
    #}
 
@@ -2601,6 +2621,9 @@ class SR_OBJECT_ENT_ROUTE_ENTRY(bpy.types.PropertyGroup):
 class SR_OBJECT_ENT_MINIWORLD(bpy.types.PropertyGroup):
 #{
    world: bpy.props.StringProperty( name='world UID' )
+   proxy: bpy.props.PointerProperty( \
+               type=bpy.types.Object, name='proxy', \
+               poll=lambda self,obj: sr_filter_ent_type(obj,['ent_prop']))
 #}
 
 class SR_UL_ROUTE_NODE_LIST(bpy.types.UIList):
@@ -2950,40 +2973,44 @@ class SR_OBJECT_ENT_VOLUME(bpy.types.PropertyGroup):#{
    target: bpy.props.PointerProperty( \
            type=bpy.types.Object, name="Target", \
            poll=lambda self,obj: sr_filter_ent_type(obj,SR_TRIGGERABLE))
-   target_event: bpy.props.IntProperty( name="Event/Method" )
+   target_event: bpy.props.IntProperty( name="Enter Ev" )
+   target_event_leave: bpy.props.IntProperty( name="Leave Ev" )
 
    @staticmethod
-   def inspect_target( layout, data, propname ):#{
+   def inspect_target( layout, data, propname, evs = ['_event'] ):#{
       box = layout.box()
       box.prop( data[0], propname )
 
-      row = box.row()
-      row.prop( data[0], propname + '_event')
-
-      target = getattr( data[0], propname )
-      if target:#{
-         tipo = target.SR_data.ent_type
-         cls = globals()[ tipo ]
-
-         table = getattr( cls, 'sr_functions', None )
-         if table:#{
-            index = getattr( data[0], propname+'_event')
-            if index in table:
-               row.label( text=table[index] )
-            else:
-               row.label( text="undefined function" )
+      for evname in evs:#{
+         row = box.row()
+         row.prop( data[0], propname + evname )
+
+         target = getattr( data[0], propname )
+         if target:#{
+            tipo = target.SR_data.ent_type
+            cls = globals()[ tipo ]
+
+            table = getattr( cls, 'sr_functions', None )
+            if table:#{
+               index = getattr( data[0], propname + evname )
+               if index in table:
+                  row.label( text=table[index] )
+               else:
+                  row.label( text="undefined function" )
+            #}
+         #}
+         else:#{
+            row.label( text="..." )
+            row.enabled=False
          #}
-      #}
-      else:#{
-         row.label( text="..." )
-         row.enabled=False
       #}
    #}
 
    @staticmethod
    def sr_inspector( layout, data ):#{
       layout.prop( data[0], 'subtype' )
-      SR_OBJECT_ENT_VOLUME.inspect_target( layout, data, 'target' )
+      SR_OBJECT_ENT_VOLUME.inspect_target( layout, data, 'target', \
+            ['_event','_event_leave'] )
    #}
 #}
 
index bc59d470f6c17e2aeb6ee8f169c76a4f4839c661..54ce8ae5c6782752897d639da0014fbad417430e 100644 (file)
@@ -14,6 +14,19 @@ static void ent_miniworld_call( world_instance *world, ent_call *call ){
 
       global_miniworld.active_id = call->id;
    }
+   else if( call->function == 1 ){
+
+      if( global_miniworld.active_id == call->id )
+         global_miniworld.active_id = 0;
+      else 
+         vg_warn( "bad call\n" );
+
+      if( miniworld->proxy ){
+         ent_prop *prop = mdl_arritm( &world->ent_prop, 
+                                      mdl_entity_id_id(miniworld->proxy) );
+         prop->flags &= ~0x1;
+      }
+   }
 }
 
 static void ent_miniworld_render( world_instance *host_world ){
@@ -25,7 +38,20 @@ static void ent_miniworld_render( world_instance *host_world ){
    ent_miniworld *miniworld = mdl_arritm( &host_world->ent_miniworld, 
                                           mdl_entity_id_id(entity_id) );
 
+   int rendering = 1;
    if( miniworld->purpose == k_world_purpose_invalid )
+      rendering = 0;
+
+   if( miniworld->proxy ){
+      ent_prop *prop = mdl_arritm( &host_world->ent_prop, 
+                                   mdl_entity_id_id(miniworld->proxy) );
+      if( !rendering )
+         prop->flags &= ~0x1;
+      else
+         prop->flags |= 0x1;
+   }
+
+   if( !rendering )
       return;
 
    world_instance *dest_world = &world_static.instances[miniworld->purpose];
index cab16c84ee2bb11ebbf075e5eaa94de58d6a1453..bdb69f85593b01008d3793f267b4cff26fd3992f 100644 (file)
--- a/entity.h
+++ b/entity.h
@@ -31,6 +31,7 @@ typedef struct ent_challenge ent_challenge;
 typedef struct ent_relay ent_relay;
 typedef struct ent_cubemap ent_cubemap;
 typedef struct ent_miniworld ent_miniworld;
+typedef struct ent_prop ent_prop;
 
 enum entity_alias{
    k_ent_none        = 0,
@@ -72,7 +73,8 @@ static u32 mdl_entity_id( u32 type, u32 index ){
 
 enum entity_function{
    k_ent_function_trigger,
-   k_ent_function_particle_spawn
+   k_ent_function_particle_spawn,
+   k_ent_function_trigger_leave
 };
 
 struct ent_spawn{
@@ -207,7 +209,7 @@ struct volume_particles{
 };
 
 struct volume_trigger{
-   u32 event, blank;
+   u32 event, event_leave;
 };
 
 enum ent_volume_flag {
@@ -504,6 +506,12 @@ struct ent_miniworld {
    u32 pstr_world;
 
    i32 purpose;
+   u32 proxy;
+};
+
+struct ent_prop {
+   mdl_transform transform;
+   u32 submesh_start, submesh_count, flags;
 };
 
 #include "world.h"
index 106e213105632022dc9de5da022840c63e07cf74..deae0e2fd6a1888498422b2e5643d600e58ae432 100644 (file)
Binary files a/maps_src/dev_hub/main.mdl and b/maps_src/dev_hub/main.mdl differ
index 19e3b2cc0cddb13221453341779fe5550af32d91..2d40352589aa899ac6d19b8ac61eb878490194e4 100644 (file)
@@ -205,14 +205,18 @@ static struct vg_shader _shader_model_board_view = {
 "   vec3 sun_colour  = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n"
 "        sun_colour *= sun_shape;\n"
 "\n"
-"\n"
+"   \n"
 "   float star = 0.0;\n"
-"   for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
-"      float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
-"      star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));\n"
+"   float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"\n"
+"   if( star_blend > 0.001 ){\n"
+"      for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
+"         float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
+"         star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n"
+"      }\n"
 "   }\n"
 "   \n"
-"   vec3 composite   = sky_colour + sun_colour + star*10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"   vec3 composite   = sky_colour + sun_colour + star*star_blend;\n"
 "   return composite;\n"
 "}\n"
 "\n"
index 03df443a418b59a333098bf3357227638f817bcb..51e06db12b3bbe5e72b62687bd38b2dcceef2f5c 100644 (file)
@@ -213,14 +213,18 @@ static struct vg_shader _shader_model_character_view = {
 "   vec3 sun_colour  = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n"
 "        sun_colour *= sun_shape;\n"
 "\n"
-"\n"
+"   \n"
 "   float star = 0.0;\n"
-"   for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
-"      float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
-"      star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));\n"
+"   float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"\n"
+"   if( star_blend > 0.001 ){\n"
+"      for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
+"         float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
+"         star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n"
+"      }\n"
 "   }\n"
 "   \n"
-"   vec3 composite   = sky_colour + sun_colour + star*10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"   vec3 composite   = sky_colour + sun_colour + star*star_blend;\n"
 "   return composite;\n"
 "}\n"
 "\n"
index 585c89737f1b7c197e3865439058b55089fbe6dc..e7044edad39f5847a684f05c0eee42bb98dacb68 100644 (file)
@@ -205,14 +205,18 @@ static struct vg_shader _shader_model_entity = {
 "   vec3 sun_colour  = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n"
 "        sun_colour *= sun_shape;\n"
 "\n"
-"\n"
+"   \n"
 "   float star = 0.0;\n"
-"   for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
-"      float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
-"      star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));\n"
+"   float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"\n"
+"   if( star_blend > 0.001 ){\n"
+"      for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
+"         float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
+"         star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n"
+"      }\n"
 "   }\n"
 "   \n"
-"   vec3 composite   = sky_colour + sun_colour + star*10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"   vec3 composite   = sky_colour + sun_colour + star*star_blend;\n"
 "   return composite;\n"
 "}\n"
 "\n"
index 882e1743117f4bfdf82dcc9fb1eb249a27993070..0bf67512e38ff29c4fc51bbdaacc882a803e4eca 100644 (file)
@@ -207,14 +207,18 @@ static struct vg_shader _shader_model_sky = {
 "   vec3 sun_colour  = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n"
 "        sun_colour *= sun_shape;\n"
 "\n"
-"\n"
+"   \n"
 "   float star = 0.0;\n"
-"   for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
-"      float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
-"      star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));\n"
+"   float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"\n"
+"   if( star_blend > 0.001 ){\n"
+"      for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
+"         float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
+"         star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n"
+"      }\n"
 "   }\n"
 "   \n"
-"   vec3 composite   = sky_colour + sun_colour + star*10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"   vec3 composite   = sky_colour + sun_colour + star*star_blend;\n"
 "   return composite;\n"
 "}\n"
 "\n"
index 72511960236728b05d9f4c5f2bf47a8b4f65221b..589175ffbc5908cd627f0715dca4c28055abe66a 100644 (file)
@@ -207,14 +207,18 @@ static struct vg_shader _shader_model_sky_space = {
 "   vec3 sun_colour  = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n"
 "        sun_colour *= sun_shape;\n"
 "\n"
-"\n"
+"   \n"
 "   float star = 0.0;\n"
-"   for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
-"      float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
-"      star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));\n"
+"   float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"\n"
+"   if( star_blend > 0.001 ){\n"
+"      for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
+"         float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
+"         star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n"
+"      }\n"
 "   }\n"
 "   \n"
-"   vec3 composite   = sky_colour + sun_colour + star*10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"   vec3 composite   = sky_colour + sun_colour + star*star_blend;\n"
 "   return composite;\n"
 "}\n"
 "\n"
index 4c90269b27f737a1ad2f54fa543c658c4e3f9fb4..5f8b80aa47c6d55e1a2d98f6e2194ded7f46adbb 100644 (file)
@@ -207,14 +207,18 @@ static struct vg_shader _shader_scene_cubemapped = {
 "   vec3 sun_colour  = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n"
 "        sun_colour *= sun_shape;\n"
 "\n"
-"\n"
+"   \n"
 "   float star = 0.0;\n"
-"   for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
-"      float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
-"      star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));\n"
+"   float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"\n"
+"   if( star_blend > 0.001 ){\n"
+"      for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
+"         float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
+"         star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n"
+"      }\n"
 "   }\n"
 "   \n"
-"   vec3 composite   = sky_colour + sun_colour + star*10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"   vec3 composite   = sky_colour + sun_colour + star*star_blend;\n"
 "   return composite;\n"
 "}\n"
 "\n"
index 160fd02d2a9f2c9ebf17249cd66af3e7e44d46ba..ea2fbebb45cd24128a30ac221c54cd81e9589534 100644 (file)
@@ -206,14 +206,18 @@ static struct vg_shader _shader_scene_depth = {
 "   vec3 sun_colour  = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n"
 "        sun_colour *= sun_shape;\n"
 "\n"
-"\n"
+"   \n"
 "   float star = 0.0;\n"
-"   for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
-"      float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
-"      star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));\n"
+"   float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"\n"
+"   if( star_blend > 0.001 ){\n"
+"      for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
+"         float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
+"         star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n"
+"      }\n"
 "   }\n"
 "   \n"
-"   vec3 composite   = sky_colour + sun_colour + star*10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"   vec3 composite   = sky_colour + sun_colour + star*star_blend;\n"
 "   return composite;\n"
 "}\n"
 "\n"
index 7eba1b0e854f3b9645f90ab9aa8f2ee9b8cfc37e..2cae29230482e13dde1bdb2f58a32618b4e664ee 100644 (file)
@@ -209,14 +209,18 @@ static struct vg_shader _shader_scene_font = {
 "   vec3 sun_colour  = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n"
 "        sun_colour *= sun_shape;\n"
 "\n"
-"\n"
+"   \n"
 "   float star = 0.0;\n"
-"   for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
-"      float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
-"      star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));\n"
+"   float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"\n"
+"   if( star_blend > 0.001 ){\n"
+"      for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
+"         float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
+"         star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n"
+"      }\n"
 "   }\n"
 "   \n"
-"   vec3 composite   = sky_colour + sun_colour + star*10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"   vec3 composite   = sky_colour + sun_colour + star*star_blend;\n"
 "   return composite;\n"
 "}\n"
 "\n"
index 98bb0e374c16dbe71a8569483564c3ee84396049..f5c14c3a8f90af7085bf9856216a180668e2d5bc 100644 (file)
@@ -204,14 +204,18 @@ static struct vg_shader _shader_scene_fxglow = {
 "   vec3 sun_colour  = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n"
 "        sun_colour *= sun_shape;\n"
 "\n"
-"\n"
+"   \n"
 "   float star = 0.0;\n"
-"   for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
-"      float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
-"      star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));\n"
+"   float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"\n"
+"   if( star_blend > 0.001 ){\n"
+"      for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
+"         float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
+"         star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n"
+"      }\n"
 "   }\n"
 "   \n"
-"   vec3 composite   = sky_colour + sun_colour + star*10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"   vec3 composite   = sky_colour + sun_colour + star*star_blend;\n"
 "   return composite;\n"
 "}\n"
 "\n"
index fb5367148cb095043f21aab4eea7e53bc4d6ec9c..d0c7ab924ac175300f217f3ee3903898bd94f7c4 100644 (file)
@@ -210,14 +210,18 @@ static struct vg_shader _shader_scene_override = {
 "   vec3 sun_colour  = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n"
 "        sun_colour *= sun_shape;\n"
 "\n"
-"\n"
+"   \n"
 "   float star = 0.0;\n"
-"   for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
-"      float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
-"      star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));\n"
+"   float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"\n"
+"   if( star_blend > 0.001 ){\n"
+"      for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
+"         float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
+"         star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n"
+"      }\n"
 "   }\n"
 "   \n"
-"   vec3 composite   = sky_colour + sun_colour + star*10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"   vec3 composite   = sky_colour + sun_colour + star*star_blend;\n"
 "   return composite;\n"
 "}\n"
 "\n"
@@ -478,7 +482,7 @@ static struct vg_shader _shader_scene_override = {
 "\n"
 "   compute_motion_vectors();\n"
 "\n"
-"   vec3 vfrag = vec3(0.5);\n"
+"   vec3 vfrag = vec3(0.7);\n"
 "   vec3 qnorm = aNorm.xyz;\n"
 "\n"
 "   qnorm = normalize(floor(aNorm.xyz*4.0)*0.25);\n"
index 99fe303a11a815a8f0c980296d8d28b5c436df79..4b0a22652bade7b0f0ae6448a062def867a8d762 100644 (file)
@@ -206,14 +206,18 @@ static struct vg_shader _shader_scene_position = {
 "   vec3 sun_colour  = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n"
 "        sun_colour *= sun_shape;\n"
 "\n"
-"\n"
+"   \n"
 "   float star = 0.0;\n"
-"   for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
-"      float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
-"      star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));\n"
+"   float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"\n"
+"   if( star_blend > 0.001 ){\n"
+"      for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
+"         float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
+"         star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n"
+"      }\n"
 "   }\n"
 "   \n"
-"   vec3 composite   = sky_colour + sun_colour + star*10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"   vec3 composite   = sky_colour + sun_colour + star*star_blend;\n"
 "   return composite;\n"
 "}\n"
 "\n"
index ecaf5fe5f3357aae9d69fb76da751cebf27e5e68..8e3cc10385942f9d1d493c01e15e158e0a78ebcf 100644 (file)
@@ -205,14 +205,18 @@ static struct vg_shader _shader_scene_route = {
 "   vec3 sun_colour  = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n"
 "        sun_colour *= sun_shape;\n"
 "\n"
-"\n"
+"   \n"
 "   float star = 0.0;\n"
-"   for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
-"      float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
-"      star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));\n"
+"   float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"\n"
+"   if( star_blend > 0.001 ){\n"
+"      for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
+"         float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
+"         star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n"
+"      }\n"
 "   }\n"
 "   \n"
-"   vec3 composite   = sky_colour + sun_colour + star*10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"   vec3 composite   = sky_colour + sun_colour + star*star_blend;\n"
 "   return composite;\n"
 "}\n"
 "\n"
index a2241c866427ce62aad827038ba30d20da406eb0..17d0eba18715ad7dc62b79218526266a03527a23 100644 (file)
@@ -225,14 +225,18 @@ static struct vg_shader _shader_scene_scoretext = {
 "   vec3 sun_colour  = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n"
 "        sun_colour *= sun_shape;\n"
 "\n"
-"\n"
+"   \n"
 "   float star = 0.0;\n"
-"   for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
-"      float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
-"      star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));\n"
+"   float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"\n"
+"   if( star_blend > 0.001 ){\n"
+"      for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
+"         float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
+"         star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n"
+"      }\n"
 "   }\n"
 "   \n"
-"   vec3 composite   = sky_colour + sun_colour + star*10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"   vec3 composite   = sky_colour + sun_colour + star*star_blend;\n"
 "   return composite;\n"
 "}\n"
 "\n"
index 3904980597a073d16cc230d1df3165444042bfe7..b5b329847025c4a2445b3b1918bf50a320dcdfe0 100644 (file)
@@ -205,14 +205,18 @@ static struct vg_shader _shader_scene_standard = {
 "   vec3 sun_colour  = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n"
 "        sun_colour *= sun_shape;\n"
 "\n"
-"\n"
+"   \n"
 "   float star = 0.0;\n"
-"   for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
-"      float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
-"      star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));\n"
+"   float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"\n"
+"   if( star_blend > 0.001 ){\n"
+"      for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
+"         float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
+"         star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n"
+"      }\n"
 "   }\n"
 "   \n"
-"   vec3 composite   = sky_colour + sun_colour + star*10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"   vec3 composite   = sky_colour + sun_colour + star*star_blend;\n"
 "   return composite;\n"
 "}\n"
 "\n"
index 2240b4be35b1891534e75312586ecd1537391ea5..f54889965d5b7e6aa204ff9a3c3ba6377716e3f8 100644 (file)
@@ -205,14 +205,18 @@ static struct vg_shader _shader_scene_standard_alphatest = {
 "   vec3 sun_colour  = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n"
 "        sun_colour *= sun_shape;\n"
 "\n"
-"\n"
+"   \n"
 "   float star = 0.0;\n"
-"   for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
-"      float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
-"      star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));\n"
+"   float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"\n"
+"   if( star_blend > 0.001 ){\n"
+"      for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
+"         float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
+"         star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n"
+"      }\n"
 "   }\n"
 "   \n"
-"   vec3 composite   = sky_colour + sun_colour + star*10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"   vec3 composite   = sky_colour + sun_colour + star*star_blend;\n"
 "   return composite;\n"
 "}\n"
 "\n"
index faeb11ec78470456d2f54966afd783a900df33b7..5bf992c28944e6c07e2f383271b19731d1871f06 100644 (file)
@@ -206,14 +206,18 @@ static struct vg_shader _shader_scene_terrain = {
 "   vec3 sun_colour  = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n"
 "        sun_colour *= sun_shape;\n"
 "\n"
-"\n"
+"   \n"
 "   float star = 0.0;\n"
-"   for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
-"      float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
-"      star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));\n"
+"   float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"\n"
+"   if( star_blend > 0.001 ){\n"
+"      for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
+"         float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
+"         star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n"
+"      }\n"
 "   }\n"
 "   \n"
-"   vec3 composite   = sky_colour + sun_colour + star*10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"   vec3 composite   = sky_colour + sun_colour + star*star_blend;\n"
 "   return composite;\n"
 "}\n"
 "\n"
index 672d154f5d1b2233a7ad2006f56f03876101f378..2cc345b6c95768a7ff6d9b82f9d3764d84f5bba3 100644 (file)
@@ -204,14 +204,18 @@ static struct vg_shader _shader_scene_vertex_blend = {
 "   vec3 sun_colour  = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n"
 "        sun_colour *= sun_shape;\n"
 "\n"
-"\n"
+"   \n"
 "   float star = 0.0;\n"
-"   for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
-"      float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
-"      star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));\n"
+"   float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"\n"
+"   if( star_blend > 0.001 ){\n"
+"      for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
+"         float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
+"         star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n"
+"      }\n"
 "   }\n"
 "   \n"
-"   vec3 composite   = sky_colour + sun_colour + star*10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"   vec3 composite   = sky_colour + sun_colour + star*star_blend;\n"
 "   return composite;\n"
 "}\n"
 "\n"
index 2ce696ca8b9561a481bb4eb5fd73e5553f5ac4b3..3a733b33780f452d82f944c882716451122afc1c 100644 (file)
@@ -214,14 +214,18 @@ static struct vg_shader _shader_scene_water = {
 "   vec3 sun_colour  = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n"
 "        sun_colour *= sun_shape;\n"
 "\n"
-"\n"
+"   \n"
 "   float star = 0.0;\n"
-"   for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
-"      float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
-"      star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));\n"
+"   float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"\n"
+"   if( star_blend > 0.001 ){\n"
+"      for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
+"         float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
+"         star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n"
+"      }\n"
 "   }\n"
 "   \n"
-"   vec3 composite   = sky_colour + sun_colour + star*10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"   vec3 composite   = sky_colour + sun_colour + star*star_blend;\n"
 "   return composite;\n"
 "}\n"
 "\n"
index 3e88f1d52c241f3d26624e455a4d8b491cb178c4..8a1ba5ed6beb339dbb0d33d42530d78afb59eaf0 100644 (file)
@@ -211,14 +211,18 @@ static struct vg_shader _shader_scene_water_fast = {
 "   vec3 sun_colour  = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );\n"
 "        sun_colour *= sun_shape;\n"
 "\n"
-"\n"
+"   \n"
 "   float star = 0.0;\n"
-"   for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
-"      float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
-"      star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));\n"
+"   float star_blend = 10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"\n"
+"   if( star_blend > 0.001 ){\n"
+"      for( float j = 1.0; j <= 4.1; j += 1.0 ){\n"
+"         float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));\n"
+"         star += stars( ray_dir, 1.94 * pow( 1.64, j ), m ) * (1.0/pow(4.0, j));\n"
+"      }\n"
 "   }\n"
 "   \n"
-"   vec3 composite   = sky_colour + sun_colour + star*10.0*max(0.0,(1.0-g_day_phase*2.0));\n"
+"   vec3 composite   = sky_colour + sun_colour + star*star_blend;\n"
 "   return composite;\n"
 "}\n"
 "\n"
diff --git a/world.h b/world.h
index 02bb02e9a0564b0fa856bc43a3bfc473bfd72493..dde9aea83048a93f26a4f0227c0464df69132fb7 100644 (file)
--- a/world.h
+++ b/world.h
@@ -180,7 +180,8 @@ struct world_instance {
                  ent_challenge,
                  ent_relay,
                  ent_cubemap,
-                 ent_miniworld;
+                 ent_miniworld,
+                 ent_prop;
 
    enum skybox {
       k_skybox_default,
index 73caa0bf8849ec6e83323d824b937733b61c5a26..975c008c2d4910ceb48f7feb9c09f98eeccf07fe 100644 (file)
@@ -286,6 +286,17 @@ static void ent_volume_call( world_instance *world, ent_call *call )
          entity_call( world, call );
       }
    }
+   else if( call->function == k_ent_function_trigger_leave ){
+      call->id = volume->target;
+
+      if( volume->flags & k_ent_volume_flag_particles ){
+         assert(0);
+      }
+      else{
+         call->function = volume->trigger.event_leave;
+         entity_call( world, call );
+      }
+   }
 }
 
 static void ent_audio_call( world_instance *world, ent_call *call ){
index 7d3cc81dc30be79cdfd4c68df8d13e2b5d1e9e05..51d0302badbeba28a6a7a7d5581f6b426df0348a 100644 (file)
@@ -300,6 +300,17 @@ static void world_gen_generate_meshes( world_instance *world ){
       }
    }
 
+   /* unpack prop models */
+   for( u32 i=0; i<mdl_arrcount( &world->ent_prop ); i++ ){
+      ent_prop *prop = mdl_arritm( &world->ent_prop, i );
+
+      for( u32 j=0; j<prop->submesh_count; j ++ ){
+         mdl_submesh *sm = mdl_arritm( &world->meta.submeshs, 
+                                       prop->submesh_start+j );
+         world_unpack_submesh_dynamic( world, &world->scene_no_collide, sm );
+      }
+   }
+
    vg_async_dispatch( call, async_scene_upload );
 }
 
index 1605325f44fb6c37ea511aee360590c961b6863b..6378e9bd5cac18487da984d3c3b97a1d408fb00c 100644 (file)
@@ -68,6 +68,7 @@ static void world_instance_load_mdl( u32 instance_id, const char *path ){
    mdl_load_array( meta, &world->ent_relay,     "ent_relay",      heap );
    mdl_load_array( meta, &world->ent_cubemap,   "ent_cubemap",    heap );
    mdl_load_array( meta, &world->ent_miniworld, "ent_miniworld",  heap );
+   mdl_load_array( meta, &world->ent_prop,      "ent_prop",  heap );
 
    mdl_array_ptr infos;
    mdl_load_array( meta, &infos, "ent_worldinfo", vg_mem.scratch );
index 14631421c25304a3dc4de936de1987ae999a827f..1d2256b4f6ddf88d7cefc696b68ece318e23e585 100644 (file)
@@ -154,6 +154,45 @@ struct world_pass{
    void (*fn_set_uNormalMtx)( m3x3f mnorm );
 };
 
+/* FIXME: we gotta do something about this crap, maybe batch lists. something..
+ * anything but this. */
+static
+void world_render_props( world_instance *world, u32 material_id,
+                         struct world_pass *pass ){
+   if( !mdl_arrcount( &world->ent_prop ) ) return;
+
+   /* HACK: use the first material for every prop entity */
+   ent_prop *first = mdl_arritm( &world->ent_prop, 0 );
+   if( !first->submesh_count ) return;
+
+   mdl_submesh *sm = mdl_arritm( &world->meta.submeshs, first->submesh_start );
+   if( sm->material_id != material_id ) return;
+
+   struct world_surface *mat = &world->surfaces[ material_id ];
+   pass->fn_bind_textures( world, mat );
+
+   for( u32 j=0; j<mdl_arrcount( &world->ent_prop ); j++ ){
+      ent_prop *prop = mdl_arritm( &world->ent_prop, j );
+      if( prop->flags & 0x1 ) continue;
+      
+      for( u32 k=0; k<prop->submesh_count; k++ ){
+         sm = mdl_arritm( &world->meta.submeshs, prop->submesh_start+k );
+
+         m4x3f mmdl;
+         mdl_transform_m4x3( &prop->transform, mmdl );
+
+         m4x4f m4mdl;
+         m4x3_expand( mmdl, m4mdl );
+         m4x4_mul( pass->cam->mtx_prev.pv, m4mdl, m4mdl );
+
+         pass->fn_set_mdl( mmdl );
+         pass->fn_set_uPvmPrev( m4mdl );
+
+         mdl_draw_submesh( sm );
+      }
+   }
+}
+
 static
 void world_render_traffic( world_instance *world, u32 material_id,
                            struct world_pass *pass ){
@@ -205,6 +244,7 @@ void world_render_pass( world_instance *world, struct world_pass *pass ){
          }
          else{
             world_render_traffic( world, i, pass );
+            world_render_props( world, i, pass );
             sm = &mat->sm_no_collide;
          }
 
index dac790e9baa0d99387186ab20a5b03fc2d20a218..23b8299ccdcdfffe21ed3b1f81049212d242b150 100644 (file)
@@ -23,6 +23,12 @@ static void world_volumes_update( world_instance *world, v3f pos ){
       }
       else{
          /* trigger on exit...... */
+         ent_call basecall;
+         basecall.function = k_ent_function_trigger_leave;
+         basecall.id = mdl_entity_id( k_ent_volume, idx );
+         basecall.data = NULL;
+
+         entity_call( world, &basecall );
       }
    }
    world_static.active_trigger_volume_count = j;