feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -149,7 +149,31 @@ void Path3DGizmo::set_handle(int p_id, bool p_secondary, Camera3D *p_camera, con
|
|||
local.snapf(snap);
|
||||
}
|
||||
|
||||
if (info.type == HandleType::HANDLE_TYPE_IN) {
|
||||
// Determine if control points should be swapped based on delta movement.
|
||||
// Only run on the next update after an overlap is detected, to get proper delta movement.
|
||||
if (control_points_overlapped) {
|
||||
control_points_overlapped = false;
|
||||
Vector3 delta = local - (info.type == HANDLE_TYPE_IN ? c->get_point_in(idx) : c->get_point_out(idx));
|
||||
Vector3 p0 = c->get_point_position(idx - 1) - base;
|
||||
Vector3 p1 = c->get_point_position(idx + 1) - base;
|
||||
HandleType new_type = Math::abs(delta.angle_to(p0)) < Math::abs(delta.angle_to(p1)) ? HANDLE_TYPE_IN : HANDLE_TYPE_OUT;
|
||||
if (info.type != new_type) {
|
||||
swapped_control_points_idx = idx;
|
||||
}
|
||||
}
|
||||
|
||||
// Detect control points overlap.
|
||||
bool control_points_equal = c->get_point_in(idx).is_equal_approx(c->get_point_out(idx));
|
||||
if (idx > 0 && idx < (c->get_point_count() - 1) && control_points_equal) {
|
||||
control_points_overlapped = true;
|
||||
}
|
||||
|
||||
HandleType control_type = info.type;
|
||||
if (swapped_control_points_idx == idx) {
|
||||
control_type = info.type == HANDLE_TYPE_IN ? HANDLE_TYPE_OUT : HANDLE_TYPE_IN;
|
||||
}
|
||||
|
||||
if (control_type == HandleType::HANDLE_TYPE_IN) {
|
||||
c->set_point_in(idx, local);
|
||||
if (Path3DEditorPlugin::singleton->mirror_angle_enabled()) {
|
||||
c->set_point_out(idx, Path3DEditorPlugin::singleton->mirror_length_enabled() ? -local : (-local.normalized() * orig_out_length));
|
||||
|
|
@ -190,6 +214,9 @@ void Path3DGizmo::set_handle(int p_id, bool p_secondary, Camera3D *p_camera, con
|
|||
}
|
||||
|
||||
void Path3DGizmo::commit_handle(int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
|
||||
swapped_control_points_idx = -1;
|
||||
control_points_overlapped = false;
|
||||
|
||||
Ref<Curve3D> c = path->get_curve();
|
||||
if (c.is_null()) {
|
||||
return;
|
||||
|
|
@ -272,7 +299,6 @@ void Path3DGizmo::commit_handle(int p_id, bool p_secondary, const Variant &p_res
|
|||
void Path3DGizmo::redraw() {
|
||||
clear();
|
||||
|
||||
Ref<StandardMaterial3D> path_material = gizmo_plugin->get_material("path_material", this);
|
||||
Ref<StandardMaterial3D> path_thin_material = gizmo_plugin->get_material("path_thin_material", this);
|
||||
Ref<StandardMaterial3D> path_tilt_material = gizmo_plugin->get_material("path_tilt_material", this);
|
||||
Ref<StandardMaterial3D> path_tilt_muted_material = gizmo_plugin->get_material("path_tilt_muted_material", this);
|
||||
|
|
@ -291,11 +317,24 @@ void Path3DGizmo::redraw() {
|
|||
return;
|
||||
}
|
||||
|
||||
debug_material = gizmo_plugin->get_material("path_material", this);
|
||||
|
||||
Color path_color = path->get_debug_custom_color();
|
||||
if (path_color != Color(0.0, 0.0, 0.0)) {
|
||||
debug_material.instantiate();
|
||||
debug_material->set_albedo(path_color);
|
||||
debug_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
|
||||
debug_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
|
||||
debug_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
|
||||
debug_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
|
||||
debug_material->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
|
||||
}
|
||||
|
||||
real_t interval = 0.1;
|
||||
const real_t length = c->get_baked_length();
|
||||
|
||||
// 1. Draw curve and bones.
|
||||
if (length > CMP_EPSILON) {
|
||||
// 1. Draw curve and bones if it is visible (alpha > 0.0).
|
||||
if (length > CMP_EPSILON && path_color.a > 0.0) {
|
||||
const int sample_count = int(length / interval) + 2;
|
||||
interval = length / (sample_count - 1); // Recalculate real interval length.
|
||||
|
||||
|
|
@ -356,8 +395,8 @@ void Path3DGizmo::redraw() {
|
|||
}
|
||||
|
||||
add_collision_segments(_collision_segments);
|
||||
add_lines(bones, path_material);
|
||||
add_vertices(ribbon, path_material, Mesh::PRIMITIVE_LINE_STRIP);
|
||||
add_lines(bones, debug_material);
|
||||
add_vertices(ribbon, debug_material, Mesh::PRIMITIVE_LINE_STRIP);
|
||||
}
|
||||
|
||||
// 2. Draw handles when selected.
|
||||
|
|
@ -433,11 +472,11 @@ void Path3DGizmo::redraw() {
|
|||
|
||||
const int n = 36;
|
||||
for (int i = 0; i <= n; i++) {
|
||||
const float a = Math_TAU * i / n;
|
||||
const float a = Math::TAU * i / n;
|
||||
const Vector3 edge = sin(a) * side + cos(a) * up;
|
||||
disk.append(pos + edge * disk_size);
|
||||
}
|
||||
add_vertices(disk, path_tilt_material, Mesh::PRIMITIVE_LINE_STRIP);
|
||||
add_vertices(disk, debug_material, Mesh::PRIMITIVE_LINE_STRIP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -509,6 +548,7 @@ Path3DGizmo::Path3DGizmo(Path3D *p_path, float p_disk_size) {
|
|||
|
||||
// Connecting to a signal once, rather than plaguing the implementation with calls to `Node3DEditor::update_transform_gizmo`.
|
||||
path->connect("curve_changed", callable_mp(this, &Path3DGizmo::_update_transform_gizmo));
|
||||
path->connect("debug_color_changed", callable_mp(this, &Path3DGizmo::redraw));
|
||||
|
||||
Path3DEditorPlugin::singleton->curve_edit->connect(SceneStringName(pressed), callable_mp(this, &Path3DGizmo::redraw));
|
||||
Path3DEditorPlugin::singleton->curve_edit_curve->connect(SceneStringName(pressed), callable_mp(this, &Path3DGizmo::redraw));
|
||||
|
|
@ -580,10 +620,9 @@ EditorPlugin::AfterGUIInput Path3DEditorPlugin::forward_3d_gui_input(Camera3D *p
|
|||
from = gt.xform(from);
|
||||
to = gt.xform(to);
|
||||
if (cdist > 0) {
|
||||
Vector2 s[2];
|
||||
s[0] = viewport->point_to_screen(from);
|
||||
s[1] = viewport->point_to_screen(to);
|
||||
Vector2 inters = Geometry2D::get_closest_point_to_segment(mbpos, s);
|
||||
const Vector2 segment_a = viewport->point_to_screen(from);
|
||||
const Vector2 segment_b = viewport->point_to_screen(to);
|
||||
Vector2 inters = Geometry2D::get_closest_point_to_segment(mbpos, segment_a, segment_b);
|
||||
float d = inters.distance_to(mbpos);
|
||||
|
||||
if (d < 10 && d < closest_d) {
|
||||
|
|
@ -880,6 +919,7 @@ Path3DEditorPlugin::Path3DEditorPlugin() {
|
|||
curve_edit->set_toggle_mode(true);
|
||||
curve_edit->set_focus_mode(Control::FOCUS_NONE);
|
||||
curve_edit->set_tooltip_text(TTR("Select Points") + "\n" + TTR("Shift+Click: Select multiple Points") + "\n" + keycode_get_string((Key)KeyModifierMask::CMD_OR_CTRL) + TTR("Click: Add Point") + "\n" + TTR("Right Click: Delete Point"));
|
||||
curve_edit->set_accessibility_name(TTRC("Select Points"));
|
||||
toolbar->add_child(curve_edit);
|
||||
curve_edit->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_mode_changed).bind(MODE_EDIT));
|
||||
|
||||
|
|
@ -888,6 +928,7 @@ Path3DEditorPlugin::Path3DEditorPlugin() {
|
|||
curve_edit_curve->set_toggle_mode(true);
|
||||
curve_edit_curve->set_focus_mode(Control::FOCUS_NONE);
|
||||
curve_edit_curve->set_tooltip_text(TTR("Select Control Points") + "\n" + TTR("Shift+Click: Drag out Control Points"));
|
||||
curve_edit_curve->set_accessibility_name(TTRC("Select Control Points"));
|
||||
toolbar->add_child(curve_edit_curve);
|
||||
curve_edit_curve->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_mode_changed).bind(MODE_EDIT_CURVE));
|
||||
|
||||
|
|
@ -896,6 +937,7 @@ Path3DEditorPlugin::Path3DEditorPlugin() {
|
|||
curve_edit_tilt->set_toggle_mode(true);
|
||||
curve_edit_tilt->set_focus_mode(Control::FOCUS_NONE);
|
||||
curve_edit_tilt->set_tooltip_text(TTR("Select Tilt Handles"));
|
||||
curve_edit_tilt->set_accessibility_name(TTRC("Select Tilt Handles"));
|
||||
toolbar->add_child(curve_edit_tilt);
|
||||
curve_edit_tilt->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_mode_changed).bind(MODE_EDIT_TILT));
|
||||
|
||||
|
|
@ -904,6 +946,7 @@ Path3DEditorPlugin::Path3DEditorPlugin() {
|
|||
curve_create->set_toggle_mode(true);
|
||||
curve_create->set_focus_mode(Control::FOCUS_NONE);
|
||||
curve_create->set_tooltip_text(TTR("Add Point (in empty space)") + "\n" + TTR("Split Segment (in curve)"));
|
||||
curve_create->set_accessibility_name(TTRC("Add Point"));
|
||||
toolbar->add_child(curve_create);
|
||||
curve_create->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_mode_changed).bind(MODE_CREATE));
|
||||
|
||||
|
|
@ -912,6 +955,7 @@ Path3DEditorPlugin::Path3DEditorPlugin() {
|
|||
curve_del->set_toggle_mode(true);
|
||||
curve_del->set_focus_mode(Control::FOCUS_NONE);
|
||||
curve_del->set_tooltip_text(TTR("Delete Point"));
|
||||
curve_del->set_accessibility_name(TTRC("Delete Point"));
|
||||
toolbar->add_child(curve_del);
|
||||
curve_del->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_mode_changed).bind(MODE_DELETE));
|
||||
|
||||
|
|
@ -919,6 +963,7 @@ Path3DEditorPlugin::Path3DEditorPlugin() {
|
|||
curve_closed->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
curve_closed->set_focus_mode(Control::FOCUS_NONE);
|
||||
curve_closed->set_tooltip_text(TTR("Close Curve"));
|
||||
curve_closed->set_accessibility_name(TTRC("Close Curve"));
|
||||
toolbar->add_child(curve_closed);
|
||||
curve_closed->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_toggle_closed_curve));
|
||||
|
||||
|
|
@ -926,6 +971,7 @@ Path3DEditorPlugin::Path3DEditorPlugin() {
|
|||
curve_clear_points->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
curve_clear_points->set_focus_mode(Control::FOCUS_NONE);
|
||||
curve_clear_points->set_tooltip_text(TTR("Clear Points"));
|
||||
curve_clear_points->set_accessibility_name(TTRC("Clear Points"));
|
||||
curve_clear_points->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_confirm_clear_points));
|
||||
toolbar->add_child(curve_clear_points);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue