diff --git a/core/static_array.jai b/core/static_array.jai index 8f273ce..a3ae998 100644 --- a/core/static_array.jai +++ b/core/static_array.jai @@ -30,4 +30,8 @@ array_contains :: (static_array: Static_Array, value: static_array.Data_Type) -> operator [] :: (static_array: Static_Array, index: int) -> static_array.Data_Type { return static_array.data[index]; -} \ No newline at end of file +} + +operator []= :: (static_array: *Static_Array, index: int, value: static_array.Data_Type) { + static_array.data[index] = value; + } \ No newline at end of file diff --git a/core/transform.jai b/core/transform.jai index 932538f..d92eb87 100644 --- a/core/transform.jai +++ b/core/transform.jai @@ -130,7 +130,7 @@ quaternion_to_euler :: (q: Quaternion) -> yaw: float, pitch: float, roll: float cosy_cosp := 1.0 - 2.0 * (q.y * q.y + q.z * q.z); yaw = atan2(siny_cosp, cosy_cosp); - return pitch, yaw, roll; + return yaw, pitch, roll; } set_rotation :: (e: *Entity, orientation: Quaternion, calculate_matrix: bool = true) { diff --git a/editor/editor_ui.jai b/editor/editor_ui.jai index 35fd9e8..a7d9ed3 100644 --- a/editor/editor_ui.jai +++ b/editor/editor_ui.jai @@ -218,15 +218,17 @@ editor_ui :: () { ui_label(tprint("Id: %", entity.id)); - ui_vector_field("Position", *entity.transform.position); + updated := ui_vector_field("Position", *entity.transform.position); euler_rotation := quaternion_to_euler_v3(entity.transform.orientation); euler_rotation *= RADIANS_TO_DEGREES; - ui_vector_field("Rotation", *euler_rotation); + updated |= ui_vector_field("Rotation", *euler_rotation); euler_rotation *= DEGREES_TO_RADIANS; entity.transform.orientation = euler_to_quaternion(euler_rotation); - ui_vector_field("Scale", *entity.transform.scale); + updated |= ui_vector_field("Scale", *entity.transform.scale); - update_matrix(*entity.transform); + if updated { + update_matrix(*entity.transform); + } entity_ui(entity); } diff --git a/metaprogram.jai b/metaprogram.jai index 0b83c9f..0c4072e 100644 --- a/metaprogram.jai +++ b/metaprogram.jai @@ -94,7 +94,10 @@ generate_member_ui :: (type: *Type_Info_Struct, builder: *String_Builder, path: if it.type.type == { case .STRUCT; { info_struct := cast(*Type_Info_Struct) it.type; - if info_struct.name == "Vector3" { + if info_struct.name == "Quaternion" { + + } + else if info_struct.name == "Vector3" { print_to_builder(builder, "\tui_vector_field(tprint(\"%\"), *e.%);\n", new_path, new_path); } else { generate_member_ui(info_struct, builder, new_path); diff --git a/module.jai b/module.jai index 2161f0b..86b5fdb 100644 --- a/module.jai +++ b/module.jai @@ -80,7 +80,7 @@ coven_init :: (window_title: string, window_width: u32, window_height: u32, full } } -coven_run :: (game_update_proc: (float), game_update_post_physics_proc: (float)) { +coven_run :: (game_update_proc: (float), game_editor_update_proc: (float), game_update_post_physics_proc: (float)) { time = xx seconds_since_init(); while !quit { @@ -124,6 +124,8 @@ coven_run :: (game_update_proc: (float), game_update_post_physics_proc: (float)) game_update_post_physics_proc(clamped_dt); } } else { + game_editor_update_proc(clamped_dt); + if engine.current_scene != null { update_trigger_mesh_colliders(engine.current_scene); } diff --git a/ui/widgets.jai b/ui/widgets.jai index a1e1031..ff6392d 100644 --- a/ui/widgets.jai +++ b/ui/widgets.jai @@ -285,18 +285,22 @@ ui_int_field :: (label: string, value: *int, identifier: s64 = 0, loc := #caller ui_set_next_size_x(.CHILDREN_SUM, 1); } -ui_float_field :: (label: string, value: *float, identifier: s64 = 0, loc := #caller_location) { +ui_float_field :: (label: string, value: *float, identifier: s64 = 0, loc := #caller_location) -> bool { + changed := false; ui_container_layout(identifier=identifier, loc=loc); ui_set_next_size_x(.CHILDREN_SUM); ui_push_parent(ui_state.last_box, .LEFT, .HORIZONTAL); { ui_label(label); - ui_float_field(value, identifier); + changed |= ui_float_field(value, identifier); } ui_pop_parent(); + + return changed; } -ui_float_field :: (value: *float, identifier: s64 = 0, loc := #caller_location) { +ui_float_field :: (value: *float, identifier: s64 = 0, loc := #caller_location) -> bool { + changed := false; ui_set_next_background_color(.{0.0,1.0,1.0,0.0}); ui_set_next_border_color(.{0.3,0.3,0.3,1.0}); ui_set_next_size_x(.CHILDREN_SUM, 1); @@ -344,6 +348,7 @@ ui_float_field :: (value: *float, identifier: s64 = 0, loc := #caller_location) < bool { + changed := false; ui_container_layout(identifier=identifier, loc=loc); ui_push_parent(ui_state.last_box, .LEFT, .HORIZONTAL); { ui_label(label); ui_label("X"); - ui_float_field(*value.x); + changed |= ui_float_field(*value.x); ui_label("Y"); - ui_float_field(*value.y); + changed |= ui_float_field(*value.y); ui_label("Z"); - ui_float_field(*value.z); + changed |= ui_float_field(*value.z); } ui_pop_parent(); + + return changed; } ui_clickable_label :: (text: string, selected: bool = false, identifier: s64 = 0, loc := #caller_location) -> clicked: bool, Interaction_State {