Fix level reload not working when paused

This commit is contained in:
sergeypdev 2025-07-13 23:28:07 +04:00
parent 073e65265a
commit 37736753e5
13 changed files with 24 additions and 22 deletions

Binary file not shown.

BIN
assets/blender/test_level_blend/Plane.glb (Stored with Git LFS)

Binary file not shown.

View File

@ -15,7 +15,7 @@
:scale (1.000000 1.000000 1.000000)) :scale (1.000000 1.000000 1.000000))
(inst (inst
:model "assets/blender/testblend_blend/Gas_Station_Shop.glb" :model "assets/blender/testblend_blend/Gas_Station_Shop.glb"
:pos (-7.000000 0.000000 -20.000000) :pos (-16.000000 0.000000 -18.000000)
:rot (0.000000 0.000000 0.000000 1.000000) :rot (0.000000 0.000000 0.000000 1.000000)
:scale (1.000000 1.000000 1.000000)) :scale (1.000000 1.000000 1.000000))
(inst (inst

BIN
assets/blender/testblend_blend/Bakery.glb (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
assets/blender/testblend_blend/Hotel.glb (Stored with Git LFS)

Binary file not shown.

View File

@ -778,15 +778,15 @@ get_scene_desc :: proc(
force_no_reload := false, force_no_reload := false,
) -> ( ) -> (
scene: Scene_Desc, scene: Scene_Desc,
reloaded: bool, modtime: i64,
) { ) {
asset, _, res := assetman_fetch_or_load( asset, mtime, _ := assetman_fetch_or_load(
assetman, assetman,
Asset_Key{path = path, type = .Scene}, Asset_Key{path = path, type = .Scene},
nil, nil,
force_no_reload, force_no_reload,
) )
return asset.(Scene_Desc), (res == .Loaded || res == .Reloaded) return asset.(Scene_Desc), mtime
} }
get_convex :: proc(assetman: ^Asset_Manager, path: cstring) -> (result: Loaded_Convex) { get_convex :: proc(assetman: ^Asset_Manager, path: cstring) -> (result: Loaded_Convex) {

View File

@ -49,6 +49,7 @@ Debug_Draw_State :: struct {
Scene :: struct { Scene :: struct {
scene_desc_path: name.Name, scene_desc_path: name.Name,
modtime: i64,
level_geoms: []physics.Level_Geom_Handle, level_geoms: []physics.Level_Geom_Handle,
} }
@ -66,12 +67,13 @@ immediate_scene :: proc(world: ^World, scene: ^Scene, path: cstring) {
tracy.Zone() tracy.Zone()
path_name := name.from_cstring(path) path_name := name.from_cstring(path)
desc, reloaded := assets.get_scene_desc(&g_mem.assetman, path_name) desc, modtime := assets.get_scene_desc(&g_mem.assetman, path_name)
if reloaded || scene.scene_desc_path != path_name { if scene.scene_desc_path != path_name || scene.modtime != modtime {
scene_destroy(world, scene) scene_destroy(world, scene)
scene.scene_desc_path = path_name scene.scene_desc_path = path_name
scene.modtime = modtime
scene.level_geoms = make([]physics.Level_Geom_Handle, len(desc.instances)) scene.level_geoms = make([]physics.Level_Geom_Handle, len(desc.instances))
sim_state := physics.get_sim_state(&world.physics_scene) sim_state := physics.get_sim_state(&world.physics_scene)

View File

@ -140,6 +140,7 @@ copy_sim_state :: proc(dst: ^Sim_State, src: ^Sim_State) {
dst.first_free_engine_plus_one = src.first_free_engine_plus_one dst.first_free_engine_plus_one = src.first_free_engine_plus_one
dst.first_free_shape_plus_one = src.first_free_shape_plus_one dst.first_free_shape_plus_one = src.first_free_shape_plus_one
// TODO: shrink when possible
resize(&dst.bodies, len(src.bodies)) resize(&dst.bodies, len(src.bodies))
resize(&dst.suspension_constraints, len(src.suspension_constraints)) resize(&dst.suspension_constraints, len(src.suspension_constraints))
resize(&dst.engines, len(src.engines)) resize(&dst.engines, len(src.engines))
@ -174,10 +175,9 @@ copy_physics_scene :: proc(dst, src: ^Scene) {
dst.assetman = src.assetman dst.assetman = src.assetman
dst.simulation_state_index = src.simulation_state_index dst.simulation_state_index = src.simulation_state_index
src_sim_state := get_sim_state(src)
dst_sim_state := get_sim_state(dst)
copy_sim_state(dst_sim_state, src_sim_state) copy_sim_state(&dst.simulation_states[0], &src.simulation_states[0])
copy_sim_state(&dst.simulation_states[1], &src.simulation_states[1])
copy_solver_state(&dst.solver_state, &src.solver_state) copy_solver_state(&dst.solver_state, &src.solver_state)
} }

BIN
src_assets/test_level.blend (Stored with Git LFS)

Binary file not shown.

BIN
src_assets/test_level.blend1 (Stored with Git LFS)

Binary file not shown.