Transform: Fixed bug in euler to quaternion conversions | Static_Array: Added overload for operator []= | Widgets: Added changed bool to textfields
This commit is contained in:
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
operator []= :: (static_array: *Static_Array, index: int, value: static_array.Data_Type) {
|
||||
static_array.data[index] = value;
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
<<value = parse_float(*temp_str);
|
||||
outer.interaction.editing = false;
|
||||
engine.editor.focused_widget = null;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if engine.input.has_char {
|
||||
@@ -414,21 +419,26 @@ ui_float_field :: (value: *float, identifier: s64 = 0, loc := #caller_location)
|
||||
//
|
||||
}
|
||||
ui_pop_parent();
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
ui_vector_field :: (label: string, value: *Vector3, identifier: s64 = 0, loc := #caller_location) {
|
||||
ui_vector_field :: (label: string, value: *Vector3, 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 {
|
||||
|
||||
Reference in New Issue
Block a user