Fight with event leaking; disabled unncecessary camera checks
This commit is contained in:
@@ -270,11 +270,6 @@ void BuildingsEditor::mouse_drag(const Vector2 &position)
|
||||
itos(editor->get_current_mode()));
|
||||
return;
|
||||
}
|
||||
if (editor->get_camera_mode() != 3) {
|
||||
print_verbose("bad camera mode: " +
|
||||
itos(editor->get_camera_mode()));
|
||||
return;
|
||||
}
|
||||
print_line("in mouse_drag");
|
||||
Camera *camera = editor->get_viewport()->get_camera();
|
||||
Vector3 start = camera->project_ray_origin(position);
|
||||
@@ -354,11 +349,6 @@ void BuildingsEditor::mouse_press(const Vector2 &position)
|
||||
itos(editor->get_current_mode()));
|
||||
return;
|
||||
}
|
||||
if (editor->get_camera_mode() != 3) {
|
||||
print_verbose("bad camera mode: " +
|
||||
itos(editor->get_camera_mode()));
|
||||
return;
|
||||
}
|
||||
print_line("in mouse_press");
|
||||
Camera *camera = editor->get_viewport()->get_camera();
|
||||
Vector3 start = camera->project_ray_origin(position);
|
||||
|
||||
@@ -69,7 +69,7 @@ void NavPanel::_notification(int which)
|
||||
float delta = get_physics_process_delta_time();
|
||||
Transform move_xform(camera_xform.basis, Vector3());
|
||||
Vector3 front = move_xform.xform(Vector3(0, 0, -1));
|
||||
Vector3 side = move_xform.xform(Vector3(0, 0, -1));
|
||||
Vector3 side = move_xform.xform(Vector3(1, 0, 0));
|
||||
if (Math::abs(zz) > 0.1f) {
|
||||
camera_xform.origin +=
|
||||
front * 60.0f * zz * delta;
|
||||
@@ -130,6 +130,7 @@ void NavPanel::gui_input_handler_h(const Ref<InputEvent> &e)
|
||||
camera_xform.origin +=
|
||||
mdir.rotated(Vector3(0, 1, 0), rotations.y);
|
||||
cam->set_global_transform(camera_xform);
|
||||
get_viewport()->set_input_as_handled();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,12 +153,14 @@ void NavPanel::gui_input_handler_v(const Ref<InputEvent> &e)
|
||||
camera_xform.origin.x += rel.x;
|
||||
camera_xform.origin.y += rel.y;
|
||||
cam->set_global_transform(camera_xform);
|
||||
get_viewport()->set_input_as_handled();
|
||||
}
|
||||
}
|
||||
|
||||
void NavPanel::gui_input_handler_r(const Ref<InputEvent> &e)
|
||||
{
|
||||
Camera *cam = get_viewport()->get_camera();
|
||||
Ref<InputEventMouseButton> mb = e;
|
||||
if (Input::get_singleton()->is_action_just_pressed("mouse1")) {
|
||||
camera_xform = cam->get_global_transform();
|
||||
rotations = camera_xform.basis.get_euler();
|
||||
@@ -170,6 +173,8 @@ void NavPanel::gui_input_handler_r(const Ref<InputEvent> &e)
|
||||
Input::get_singleton()->set_mouse_mode(
|
||||
Input::MOUSE_MODE_VISIBLE);
|
||||
}
|
||||
if (mb.is_valid())
|
||||
get_viewport()->set_input_as_handled();
|
||||
Ref<InputEventMouseMotion> mm = e;
|
||||
Vector2 sensivity(0.06f, 0.05f);
|
||||
if (mm.is_valid() && r_active) {
|
||||
@@ -185,6 +190,7 @@ void NavPanel::gui_input_handler_r(const Ref<InputEvent> &e)
|
||||
camera_xform.basis =
|
||||
camera_xform.basis.rotated(axis, rotations.x);
|
||||
transform_changhed = true;
|
||||
get_viewport()->set_input_as_handled();
|
||||
#if 0
|
||||
camera_xform.basis = camera_xform.basis.rotated(
|
||||
Vector3(0, 1, 0), rel.x * 0.1);
|
||||
|
||||
@@ -924,26 +924,6 @@ void RoadLinesEditor::handle_input()
|
||||
{
|
||||
if (editor->get_camera_mode() != 3)
|
||||
return;
|
||||
bool moved = false;
|
||||
float xx = Input::get_singleton()->get_axis("left", "right");
|
||||
float zz = Input::get_singleton()->get_axis("backward", "forward");
|
||||
float hh = Input::get_singleton()->get_axis("action2", "action");
|
||||
|
||||
if (Math::abs(zz) > 0.1f) {
|
||||
camera_motion.z -= zz;
|
||||
moved = true;
|
||||
}
|
||||
if (Math::abs(xx) > 0.1f) {
|
||||
camera_motion.x += xx;
|
||||
moved = true;
|
||||
}
|
||||
if (Math::abs(hh) > 0.1f && Math::abs(xx) < 0.1f &&
|
||||
Math::abs(zz) < 0.1f) {
|
||||
camera_motion.y += 10.0f * hh;
|
||||
moved = true;
|
||||
}
|
||||
if (moved)
|
||||
camera_moved = true;
|
||||
}
|
||||
void RoadLinesEditor::place_zebras()
|
||||
{
|
||||
|
||||
@@ -339,6 +339,7 @@ void WorldEditor::_notification(int which)
|
||||
"mouse_drag_off", args);
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
if (current_camera_mode == 1) {
|
||||
Vector2 mouse_pos =
|
||||
get_viewport()->get_mouse_position();
|
||||
@@ -350,6 +351,7 @@ void WorldEditor::_notification(int which)
|
||||
old_mouse_pos = mouse_pos;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!dragging && drag_delay >= 0.0f)
|
||||
drag_delay -= delta;
|
||||
switch (current_mode) {
|
||||
@@ -367,41 +369,58 @@ void WorldEditor::_notification(int which)
|
||||
|
||||
void WorldEditor::_unhandled_input(const Ref<InputEvent> &event)
|
||||
{
|
||||
if (Input::get_singleton()->is_action_just_pressed("editor_cam1"))
|
||||
Ref<InputEventMouseMotion> mm = event;
|
||||
Ref<InputEventMouseButton> mb = event;
|
||||
Ref<InputEventKey> kb = event;
|
||||
bool input_handled = false;
|
||||
if (event->is_action_pressed("editor_cam1")) {
|
||||
set_camera_mode(1);
|
||||
if (Input::get_singleton()->is_action_just_pressed("editor_cam2"))
|
||||
set_camera_mode(2);
|
||||
if (Input::get_singleton()->is_action_just_pressed("editor_cam3"))
|
||||
set_camera_mode(3);
|
||||
if (current_camera_mode != 1) {
|
||||
Ref<InputEventMouseMotion> motionevt = event;
|
||||
if (motionevt.is_valid())
|
||||
motion = motionevt->get_relative();
|
||||
input_handled = true;
|
||||
}
|
||||
if (Input::get_singleton()->is_action_just_pressed("mouse1")) {
|
||||
if (event->is_action_pressed("editor_cam2")) {
|
||||
set_camera_mode(2);
|
||||
input_handled = true;
|
||||
}
|
||||
if (event->is_action_pressed("editor_cam3")) {
|
||||
set_camera_mode(3);
|
||||
input_handled = true;
|
||||
}
|
||||
if (event->is_action_pressed("mouse1")) {
|
||||
// if (Input::get_singleton()->is_action_just_pressed("mouse1")) {
|
||||
Array args;
|
||||
Vector2 position = get_viewport()->get_mouse_position();
|
||||
args.push_back(position);
|
||||
EditorEvent::get_singleton()->event.emit("mouse_press", args);
|
||||
} else if (Input::get_singleton()->is_action_pressed("mouse1")) {
|
||||
if (dragging) {
|
||||
Array args;
|
||||
Vector2 position = get_viewport()->get_mouse_position();
|
||||
args.push_back(position);
|
||||
EditorEvent::get_singleton()->event.emit("mouse_drag",
|
||||
args);
|
||||
} else {
|
||||
if (drag_delay < 0.0f && !dragging) {
|
||||
dragging = true;
|
||||
// }
|
||||
input_handled = true;
|
||||
}
|
||||
if (mm.is_valid()) {
|
||||
motion += mm->get_relative();
|
||||
if (Input::get_singleton()->is_action_pressed("mouse1")) {
|
||||
if (dragging) {
|
||||
Array args;
|
||||
Vector2 position =
|
||||
get_viewport()->get_mouse_position();
|
||||
args.push_back(position);
|
||||
EditorEvent::get_singleton()->event.emit(
|
||||
"mouse_drag_on", args);
|
||||
"mouse_drag", args);
|
||||
} else {
|
||||
if (drag_delay < 0.0f && !dragging) {
|
||||
dragging = true;
|
||||
Array args;
|
||||
Vector2 position =
|
||||
get_viewport()
|
||||
->get_mouse_position();
|
||||
args.push_back(position);
|
||||
EditorEvent::get_singleton()->event.emit(
|
||||
"mouse_drag_on", args);
|
||||
}
|
||||
}
|
||||
input_handled = true;
|
||||
}
|
||||
}
|
||||
if (input_handled)
|
||||
get_viewport()->set_input_as_handled();
|
||||
if (current_mode == MODE_ROAD_LINES)
|
||||
road_lines_editor->handle_input();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user