From dc18060729f6f1620b21fdc475e13baba3194103 Mon Sep 17 00:00:00 2001 From: Daniel Bross Date: Wed, 30 Jul 2025 14:00:04 +0200 Subject: [PATCH] Removed non #if'ed physics code. --- core/mesh_entity.jai | 6 +++-- core/scene.jai | 16 ++++++++++--- module.jai | 7 ++++-- renderer/trigger_rendering.jai | 44 ++++++++++++++++++---------------- 4 files changed, 45 insertions(+), 28 deletions(-) diff --git a/core/mesh_entity.jai b/core/mesh_entity.jai index 416c29e..54d5c48 100644 --- a/core/mesh_entity.jai +++ b/core/mesh_entity.jai @@ -9,8 +9,10 @@ Mesh_Entity :: struct { init_entity :: (e: *Mesh_Entity) { if e.model_path.count > 0 { load_model_into_entity(e, get_or_load_model(e.model_path)); - e.flags |= .PHYSICS; - e.physics.type = .TRIANGLE_MESH; + #if PHYSICS { + e.flags |= .PHYSICS; + e.physics.type = .TRIANGLE_MESH; + } //e.physics.box.half_extent = .{0.5,0.5,0.5}; } } diff --git a/core/scene.jai b/core/scene.jai index dd28dae..107df68 100644 --- a/core/scene.jai +++ b/core/scene.jai @@ -144,7 +144,9 @@ unload_scene :: (scene: *Scene) { destroy_entity(e); } - deinit_physx_scene(scene); + #if PHYSICS { + deinit_physx_scene(scene); + } free(scene.name); fini(*scene.pool); @@ -163,7 +165,7 @@ reload_scene :: (scene: *Scene) { load_scene(name); } -create_scene :: (name: string = "", max_entities: s64 = 256) -> *Scene { +create_scene :: (name: string = "", max_entities: s64 = 256, trigger_callbacks := false) -> *Scene { scene := New(Scene); new_name := name; @@ -195,7 +197,9 @@ create_scene :: (name: string = "", max_entities: s64 = 256) -> *Scene { array_reserve(*scene.entities, max_entities); - init_physx_scene(scene); + #if PHYSICS { + init_physx_scene(scene); + } scene.directional_light.color_and_intensity = .{1,1,1,2}; scene.directional_light.direction = to_v4(normalize(Vector3.{0.4, -0.7, 0.4})); @@ -205,6 +209,12 @@ create_scene :: (name: string = "", max_entities: s64 = 256) -> *Scene { dir_light_data.direction = scene.directional_light.direction; upload_data_to_buffer(engine.renderer, engine.directional_light_buffer, *dir_light_data, size_of(Directional_Light_Buffer_Data)); + if trigger_callbacks { + if engine.procs.on_scene_loaded != null { + engine.procs.on_scene_loaded(scene, engine.mode); + } + } + return scene; } diff --git a/module.jai b/module.jai index edec464..bbe7308 100644 --- a/module.jai +++ b/module.jai @@ -46,8 +46,11 @@ Engine_Core :: struct { on_scene_loaded: (*Scene, Engine_Mode); on_pre_scene_loaded: (*Scene, Engine_Mode); on_pre_scene_unloaded: (*Scene); - on_trigger_enter: (*Entity, *Entity); - on_trigger_exit: (*Entity, *Entity); + + #if PHYSICS { + on_trigger_enter: (*Entity, *Entity); + on_trigger_exit: (*Entity, *Entity); + } } paused: bool; diff --git a/renderer/trigger_rendering.jai b/renderer/trigger_rendering.jai index 1be9749..d965475 100644 --- a/renderer/trigger_rendering.jai +++ b/renderer/trigger_rendering.jai @@ -61,28 +61,30 @@ init_trigger_line_rendering :: () { } render_trigger_lines :: () { - for e: engine.current_scene.entities { - if e.physics.type == .BOX { - color := Color.{0,0,1,1};//e.collider.aabb_color; - aabb := AABB.{-e.physics.box.half_extent, e.physics.box.half_extent}; + #if PHYSICS { + for e: engine.current_scene.entities { + if e.physics.type == .BOX { + color := Color.{0,0,1,1};//e.collider.aabb_color; + aabb := AABB.{-e.physics.box.half_extent, e.physics.box.half_extent}; - min := aabb.min; - max := aabb.max; + min := aabb.min; + max := aabb.max; - add_line(transform_position(.{min.x, min.y, min.z}, e.transform.model_matrix), transform_position(.{min.x, min.y, max.z}, e.transform.model_matrix), color); - add_line(transform_position(.{max.x, min.y, min.z}, e.transform.model_matrix), transform_position(.{max.x, min.y, max.z}, e.transform.model_matrix), color); - add_line(transform_position(.{min.x, max.y, min.z}, e.transform.model_matrix), transform_position(.{min.x, max.y, max.z}, e.transform.model_matrix), color); - add_line(transform_position(.{max.x, max.y, min.z}, e.transform.model_matrix), transform_position(.{max.x, max.y, max.z}, e.transform.model_matrix), color); - add_line(transform_position(.{min.x, min.y, min.z}, e.transform.model_matrix), transform_position(.{min.x, max.y, min.z}, e.transform.model_matrix), color); - add_line(transform_position(.{max.x, min.y, min.z}, e.transform.model_matrix), transform_position(.{max.x, max.y, min.z}, e.transform.model_matrix), color); - add_line(transform_position(.{max.x, min.y, max.z}, e.transform.model_matrix), transform_position(.{max.x, max.y, max.z}, e.transform.model_matrix), color); - add_line(transform_position(.{min.x, min.y, max.z}, e.transform.model_matrix), transform_position(.{min.x, max.y, max.z}, e.transform.model_matrix), color); - add_line(transform_position(.{min.x, min.y, min.z}, e.transform.model_matrix), transform_position(.{max.x, min.y, min.z}, e.transform.model_matrix), color); - add_line(transform_position(.{min.x, max.y, min.z}, e.transform.model_matrix), transform_position(.{max.x, max.y, min.z}, e.transform.model_matrix), color); - add_line(transform_position(.{min.x, min.y, max.z}, e.transform.model_matrix), transform_position(.{max.x, min.y, max.z}, e.transform.model_matrix), color); - add_line(transform_position(.{min.x, max.y, max.z}, e.transform.model_matrix), transform_position(.{max.x, max.y, max.z}, e.transform.model_matrix), color); - } - } + add_line(transform_position(.{min.x, min.y, min.z}, e.transform.model_matrix), transform_position(.{min.x, min.y, max.z}, e.transform.model_matrix), color); + add_line(transform_position(.{max.x, min.y, min.z}, e.transform.model_matrix), transform_position(.{max.x, min.y, max.z}, e.transform.model_matrix), color); + add_line(transform_position(.{min.x, max.y, min.z}, e.transform.model_matrix), transform_position(.{min.x, max.y, max.z}, e.transform.model_matrix), color); + add_line(transform_position(.{max.x, max.y, min.z}, e.transform.model_matrix), transform_position(.{max.x, max.y, max.z}, e.transform.model_matrix), color); + add_line(transform_position(.{min.x, min.y, min.z}, e.transform.model_matrix), transform_position(.{min.x, max.y, min.z}, e.transform.model_matrix), color); + add_line(transform_position(.{max.x, min.y, min.z}, e.transform.model_matrix), transform_position(.{max.x, max.y, min.z}, e.transform.model_matrix), color); + add_line(transform_position(.{max.x, min.y, max.z}, e.transform.model_matrix), transform_position(.{max.x, max.y, max.z}, e.transform.model_matrix), color); + add_line(transform_position(.{min.x, min.y, max.z}, e.transform.model_matrix), transform_position(.{min.x, max.y, max.z}, e.transform.model_matrix), color); + add_line(transform_position(.{min.x, min.y, min.z}, e.transform.model_matrix), transform_position(.{max.x, min.y, min.z}, e.transform.model_matrix), color); + add_line(transform_position(.{min.x, max.y, min.z}, e.transform.model_matrix), transform_position(.{max.x, max.y, min.z}, e.transform.model_matrix), color); + add_line(transform_position(.{min.x, min.y, max.z}, e.transform.model_matrix), transform_position(.{max.x, min.y, max.z}, e.transform.model_matrix), color); + add_line(transform_position(.{min.x, max.y, max.z}, e.transform.model_matrix), transform_position(.{max.x, max.y, max.z}, e.transform.model_matrix), color); + } + } - render_lines(); + render_lines(); + } }