diff --git a/assets/testblend.glb b/assets/testblend.glb new file mode 100644 index 0000000..a861918 --- /dev/null +++ b/assets/testblend.glb @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:56d430b11fdf2b7633791c69f9f4ac300f1b683503892aab3cc88a2501cba738 +size 7549972 diff --git a/game/game.odin b/game/game.odin index a75c3cf..54c899c 100644 --- a/game/game.odin +++ b/game/game.odin @@ -20,6 +20,7 @@ import "core:hash" import "core:log" import "core:math" import "core:math/linalg" +import "core:mem" import "core:slice" import "game:physics" import "game:physics/bvh" @@ -693,6 +694,26 @@ update_world :: proc(world: ^World, dt: f32, config: World_Update_Config) { wheel.turn_angle = TURN_ANGLE * turn_vel_correction * turn_input } + { + level_model := assets.get_model(&g_mem.assetman, "assets/testblend.glb") + + for i in 0 ..< level_model.meshCount { + mesh := &level_model.meshes[i] + + if mesh.triangleCount > 0 { + physics.immediate_level_geom( + &world.physics_scene, + hash.fnv32a(cast([]byte)(fmt.tprintf("level mesh {}", i))), + { + rotation = linalg.QUATERNIONF32_IDENTITY, + vertices = (cast([^]rl.Vector3)mesh.vertices)[:mesh.vertexCount], + indices = mesh.indices[:mesh.triangleCount * 3], + }, + ) + } + } + } + if len(world.track.points) > 1 { interpolated_points := calculate_spline_interpolated_points( world.track.points[:], @@ -1031,6 +1052,8 @@ draw_world :: proc(world: ^World) { sim_state := physics.get_sim_state(&world.physics_scene) + level_model := assets.get_model(&g_mem.assetman, "assets/testblend.glb") + car_body := physics.get_body(sim_state, world.car_handle) car_model := assets.get_model(&g_mem.assetman, "assets/ice_cream_truck.glb") engine := physics.get_engine(sim_state, world.engine_handle) @@ -1105,6 +1128,8 @@ draw_world :: proc(world: ^World) { // .VEC3, // ) + render.draw_model(level_model, {}, 1) + render.draw_model(car_model, {}, car_matrix) render.draw_mesh_light( diff --git a/game/physics/simulation.odin b/game/physics/simulation.odin index 02507a3..08b53a0 100644 --- a/game/physics/simulation.odin +++ b/game/physics/simulation.odin @@ -128,6 +128,7 @@ build_static_tlas :: proc(sim_state: ^Sim_State) -> Static_TLAS { } } + log.debugf("num vertices {}, len vertices {}", num_vertices, len(vertices)) assert(num_vertices == len(vertices)) assert(num_indices == len(indices)) diff --git a/src_assets/testblend.blend b/src_assets/testblend.blend new file mode 100644 index 0000000..38e4040 --- /dev/null +++ b/src_assets/testblend.blend @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c5a61b68fa0350c31b5c02d456f4b661a790bec568c6d7ba01716ca9fc9e0066 +size 13321681 diff --git a/src_assets/testblend.blend1 b/src_assets/testblend.blend1 new file mode 100644 index 0000000..c22e491 --- /dev/null +++ b/src_assets/testblend.blend1 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a4db340afd41c32bf3576fa18eeec89127cef66a9c4c090ef4f652b65e14536e +size 13321681