Fixed some editor bugs
This commit is contained in:
@@ -160,7 +160,7 @@ create_scene :: (name: string = "", max_entities: s64 = 256) -> *Scene {
|
||||
|
||||
array_reserve(*scene.entities, max_entities);
|
||||
|
||||
scene.directional_light.color_and_intensity = .{1,1,1,1};
|
||||
scene.directional_light.color_and_intensity = .{1,1,1,2};
|
||||
scene.directional_light.direction = to_v4(normalize(Vector3.{0.2, -0.7, 0.4}));
|
||||
|
||||
dir_light_data : Directional_Light_Buffer_Data;
|
||||
|
||||
@@ -602,7 +602,7 @@ intersect_rotation_gizmo :: (ray: Ray) -> Transform_Axis, Vector3 {
|
||||
update_gizmo_buffers :: () {
|
||||
entity := engine.editor.selected_entities[0];
|
||||
engine.editor.transform_gizmo.transform.position = entity.transform.position;
|
||||
engine.editor.transform_gizmo.transform.orientation = entity.transform.orientation;
|
||||
engine.editor.transform_gizmo.transform.orientation = ifx engine.editor.transform_gizmo.space == .LOCAL then entity.transform.orientation else .{0,0,0,1};
|
||||
update_matrix(*engine.editor.transform_gizmo.transform);
|
||||
|
||||
up_rotation := rotation_matrix(Matrix3, euler_to_quaternion(degrees_to_radians(90), degrees_to_radians(90), degrees_to_radians(0)));
|
||||
|
||||
@@ -11,7 +11,7 @@ pick_scene_view_at :: (camera: Camera, coordinates: Vector2) {
|
||||
|
||||
for engine.current_scene.entities {
|
||||
if !(it.flags & .RENDERABLE) continue;
|
||||
//if it.flags & Entity_Flags.DELETED || !it.selectable || it.parent != null continue;
|
||||
if it.flags & Entity_Flags.DELETED || it.parent != null continue;
|
||||
|
||||
success, dist := ray_entity_intersect(ray, it);
|
||||
if success && dist < closest {
|
||||
@@ -211,39 +211,27 @@ text_fun : string;
|
||||
slider_value : float = 0.0;
|
||||
|
||||
base_editor_update :: () {
|
||||
if engine.editor.show_menu && (key_down(.MOUSE_LEFT) || key_down(.ESCAPE)) {
|
||||
engine.editor.show_menu = false;
|
||||
eat_key(.MOUSE_LEFT);
|
||||
}
|
||||
|
||||
// @Incomplete: Show that we saved the scene in the editor. Maybe a quick text message or just inside one of the tab titles
|
||||
if key_pressed(.CTRL) && key_down(.S) {
|
||||
save_scene(engine.current_scene);
|
||||
}
|
||||
|
||||
// Check if we hit the gizmo
|
||||
// @Incomplete: MOVE THIS
|
||||
engine.editor.should_check_entities = true;
|
||||
|
||||
if engine.editor.selected_entities.count == 1 {
|
||||
entity := engine.editor.selected_entities[0];
|
||||
gizmo_scale := distance(entity.transform.position, engine.editor.camera.position) * 0.1 * 0.5;
|
||||
engine.editor.transform_gizmo.uniform_gizmo_scale = gizmo_scale;
|
||||
set_scale(*engine.editor.transform_gizmo.transform, .{gizmo_scale, gizmo_scale, gizmo_scale});
|
||||
|
||||
coordinates := Vector2.{engine.editor.mouse_viewport_state.normalized_local_mouse_coordinates.x, 1.0 - engine.editor.mouse_viewport_state.normalized_local_mouse_coordinates.y};
|
||||
ray := normalized_screen_to_ray_v2(engine.editor.camera, coordinates);
|
||||
|
||||
if update_transform_gizmo(ray, coordinates) {
|
||||
engine.editor.should_check_entities = false;
|
||||
}
|
||||
}
|
||||
|
||||
editor_ui();
|
||||
|
||||
camera := *engine.editor.camera;
|
||||
|
||||
if engine.editor.focused_widget == null {
|
||||
if engine.editor.focused_widget == null && engine.mode == .EDITING {
|
||||
engine.editor.should_check_entities = true;
|
||||
|
||||
if engine.editor.selected_entities.count == 1 {
|
||||
entity := engine.editor.selected_entities[0];
|
||||
gizmo_scale := distance(entity.transform.position, engine.editor.camera.position) * 0.1 * 0.5;
|
||||
engine.editor.transform_gizmo.uniform_gizmo_scale = gizmo_scale;
|
||||
set_scale(*engine.editor.transform_gizmo.transform, .{gizmo_scale, gizmo_scale, gizmo_scale});
|
||||
|
||||
coordinates := Vector2.{engine.editor.mouse_viewport_state.normalized_local_mouse_coordinates.x, 1.0 - engine.editor.mouse_viewport_state.normalized_local_mouse_coordinates.y};
|
||||
ray := normalized_screen_to_ray_v2(engine.editor.camera, coordinates);
|
||||
|
||||
if update_transform_gizmo(ray, coordinates) {
|
||||
engine.editor.should_check_entities = false;
|
||||
}
|
||||
}
|
||||
|
||||
if key_pressed(.CTRL) && key_down(.S) {
|
||||
save_scene(engine.current_scene, "../assets/scenes/");
|
||||
//show_message("Saved scene");
|
||||
@@ -254,6 +242,7 @@ base_editor_update :: () {
|
||||
mark_entity_deleted(it);
|
||||
}
|
||||
|
||||
engine.editor.transform_gizmo.selected_axis = .NONE;
|
||||
engine.editor.selected_entities.count = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -144,6 +144,7 @@ switch_engine_mode :: (to_mode: Engine_Mode) {
|
||||
|
||||
#if EDITOR {
|
||||
engine.editor.selected_entities.count = 0;
|
||||
engine.editor.transform_gizmo.selected_axis = .NONE;
|
||||
}
|
||||
|
||||
if engine.current_scene != null {
|
||||
|
||||
@@ -210,6 +210,10 @@ physics_step :: (scene: *Scene, timestep: float) {
|
||||
if e.collider.ignore continue;
|
||||
|
||||
if e.flags & .PHYSICS {
|
||||
if e.body.check_for_grounded {
|
||||
e.body.grounded = false;
|
||||
}
|
||||
|
||||
for other_e: scene.entities {
|
||||
if e == other_e continue;
|
||||
if other_e.collider.ignore continue;
|
||||
|
||||
Reference in New Issue
Block a user