fixed time worldinfo
authorhgn <hgodden00@gmail.com>
Mon, 27 Nov 2023 13:39:13 +0000 (13:39 +0000)
committerhgn <hgodden00@gmail.com>
Mon, 27 Nov 2023 13:39:13 +0000 (13:39 +0000)
blender_export.py
entity.h
world_load.c
world_render.c

index 168f023d71f6c65c3009adec6edb046a62391603..30b1fe99fbe5f8503caa8c867d8c6c95a61b648d 100644 (file)
@@ -484,7 +484,8 @@ class ent_worldinfo(Structure):
                ("pstr_author",c_uint32),    # unused
                ("pstr_desc",c_uint32),      # unused
                ("timezone",c_float),
-               ("pstr_skybox",c_uint32)]
+               ("pstr_skybox",c_uint32),
+               ("flags",c_uint32)]
 #}
 
 class ent_ccmd(Structure):
@@ -1936,7 +1937,17 @@ def sr_compile( collection ):
             worldinfo.pstr_name = sr_compile_string( obj_data.name )
             worldinfo.pstr_author = sr_compile_string( obj_data.author )
             worldinfo.pstr_desc = sr_compile_string( obj_data.desc )
-            worldinfo.timezone = obj_data.timezone
+
+            flags = 0x00
+
+            if obj_data.fix_time:#{
+               worldinfo.timezone = obj_data.fixed_time
+               flags |= 0x1
+            #}
+            else:
+               worldinfo.timezone = obj_data.timezone
+
+            worldinfo.flags = flags
             worldinfo.pstr_skybox = sr_compile_string( obj_data.skybox )
             sr_ent_push( worldinfo )
          #}
@@ -3411,8 +3422,24 @@ class SR_OBJECT_ENT_WORLD_INFO(bpy.types.PropertyGroup):
    name: bpy.props.StringProperty(name="Name")
    desc: bpy.props.StringProperty(name="Description")
    author: bpy.props.StringProperty(name="Author")
-   timezone: bpy.props.FloatProperty(name="Timezone(hrs) (UTC0 +hrs)")
    skybox: bpy.props.StringProperty(name="Skybox")
+
+   fix_time: bpy.props.BoolProperty(name="Fix Time")
+   timezone: bpy.props.FloatProperty(name="Timezone(hrs) (UTC0 +hrs)")
+   fixed_time: bpy.props.FloatProperty(name="Fixed Time (0-1)")
+
+   @staticmethod
+   def sr_inspector( layout, data ):#{
+      layout.prop( data[0], 'name' )
+      layout.prop( data[0], 'desc' )
+      layout.prop( data[0], 'author' )
+
+      layout.prop( data[0], 'fix_time' )
+      if data[0].fix_time:
+         layout.prop( data[0], 'fixed_time' )
+      else:
+         layout.prop( data[0], 'timezone' )
+   #}
 #}
 
 class SR_OBJECT_ENT_CCMD(bpy.types.PropertyGroup):
index 1033807ea552489928e6bf4ff1608dd623d62ff8..ce148162a2ba670a0def87cb9ab488fd5dbce383 100644 (file)
--- a/entity.h
+++ b/entity.h
@@ -407,6 +407,7 @@ struct ent_worldinfo{
    u32 pstr_name, pstr_author, pstr_desc;
    f32 timezone;
    u32 pstr_skybox;
+   u32 flags;
 };
 
 static ent_marker *ent_find_marker( mdl_context *mdl,
index f196c269450959f960a07a0841ead06193925a40..3dce0288024f76612b89a65502d1d5b60ceef2b2 100644 (file)
@@ -90,6 +90,7 @@ static void world_instance_load_mdl( u32 instance_id, const char *path ){
       world->info.pstr_desc = 0;
       world->info.pstr_name = 0;
       world->info.timezone = 0.0f;
+      world->info.flags = 0;
    }
 
    time_t seconds = time(NULL) % ((u32)vg_maxf(1.0f,k_day_length)*60);
index 2542ce3b19b1a48e450beb78479d212fed592a99..990a1abfcc3ed6e565e322f36d67307d6b87114e 100644 (file)
@@ -852,6 +852,10 @@ static void world_prerender( world_instance *world ){
       world->time = 0.834;
    }
 
+   if( world->info.flags & 0x1 ){
+      world->time = world->info.timezone;
+   }
+
    struct ub_world_lighting *state = &world->ub_lighting;
 
    state->g_time = world->time;