feat: updated engine version to 4.4-rc1
This commit is contained in:
parent
ee00efde1f
commit
21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions
|
|
@ -277,8 +277,15 @@ void Path3DGizmo::redraw() {
|
|||
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);
|
||||
Ref<StandardMaterial3D> handles_material = gizmo_plugin->get_material("handles");
|
||||
Ref<StandardMaterial3D> first_pt_handle_material = gizmo_plugin->get_material("first_pt_handle");
|
||||
Ref<StandardMaterial3D> last_pt_handle_material = gizmo_plugin->get_material("last_pt_handle");
|
||||
Ref<StandardMaterial3D> closed_pt_handle_material = gizmo_plugin->get_material("closed_pt_handle");
|
||||
Ref<StandardMaterial3D> sec_handles_material = gizmo_plugin->get_material("sec_handles");
|
||||
|
||||
first_pt_handle_material->set_albedo(Color(0.2, 1.0, 0.0));
|
||||
last_pt_handle_material->set_albedo(Color(1.0, 0.2, 0.0));
|
||||
closed_pt_handle_material->set_albedo(Color(1.0, 0.8, 0.0));
|
||||
|
||||
Ref<Curve3D> c = path->get_curve();
|
||||
if (c.is_null()) {
|
||||
return;
|
||||
|
|
@ -333,16 +340,19 @@ void Path3DGizmo::redraw() {
|
|||
// Path3D as a ribbon.
|
||||
ribbon_ptr[i] = p1;
|
||||
|
||||
// Fish Bone.
|
||||
const Vector3 p_left = p1 + (side + forward - up * 0.3) * 0.06;
|
||||
const Vector3 p_right = p1 + (-side + forward - up * 0.3) * 0.06;
|
||||
if (i % 4 == 0) {
|
||||
// Draw fish bone every 4 points to reduce visual noise and performance impact
|
||||
// (compared to drawing it for every point).
|
||||
const Vector3 p_left = p1 + (side + forward - up * 0.3) * 0.06;
|
||||
const Vector3 p_right = p1 + (-side + forward - up * 0.3) * 0.06;
|
||||
|
||||
const int bone_idx = i * 4;
|
||||
const int bone_idx = i * 4;
|
||||
|
||||
bones_ptr[bone_idx] = p1;
|
||||
bones_ptr[bone_idx + 1] = p_left;
|
||||
bones_ptr[bone_idx + 2] = p1;
|
||||
bones_ptr[bone_idx + 3] = p_right;
|
||||
bones_ptr[bone_idx] = p1;
|
||||
bones_ptr[bone_idx + 1] = p_left;
|
||||
bones_ptr[bone_idx + 2] = p1;
|
||||
bones_ptr[bone_idx + 3] = p_right;
|
||||
}
|
||||
}
|
||||
|
||||
add_collision_segments(_collision_segments);
|
||||
|
|
@ -369,7 +379,7 @@ void Path3DGizmo::redraw() {
|
|||
info.point_idx = idx;
|
||||
|
||||
// Collect in-handles except for the first point.
|
||||
if (idx > 0 && Path3DEditorPlugin::singleton->curve_edit_curve->is_pressed()) {
|
||||
if (idx > (c->is_closed() ? -1 : 0) && Path3DEditorPlugin::singleton->curve_edit_curve->is_pressed()) {
|
||||
const Vector3 in = c->get_point_in(idx);
|
||||
|
||||
info.type = HandleType::HANDLE_TYPE_IN;
|
||||
|
|
@ -383,7 +393,7 @@ void Path3DGizmo::redraw() {
|
|||
}
|
||||
|
||||
// Collect out-handles except for the last point.
|
||||
if (idx < c->get_point_count() - 1 && Path3DEditorPlugin::singleton->curve_edit_curve->is_pressed()) {
|
||||
if (idx < (c->is_closed() ? c->get_point_count() : c->get_point_count() - 1) && Path3DEditorPlugin::singleton->curve_edit_curve->is_pressed()) {
|
||||
const Vector3 out = c->get_point_out(idx);
|
||||
|
||||
info.type = HandleType::HANDLE_TYPE_OUT;
|
||||
|
|
@ -441,7 +451,42 @@ void Path3DGizmo::redraw() {
|
|||
}
|
||||
|
||||
if (!Path3DEditorPlugin::singleton->curve_edit->is_pressed() && primary_handle_points.size()) {
|
||||
add_handles(primary_handle_points, handles_material);
|
||||
// Need to define indices separately.
|
||||
// Point count.
|
||||
const int pc = primary_handle_points.size();
|
||||
Vector<int> idx;
|
||||
idx.resize(pc);
|
||||
int *idx_ptr = idx.ptrw();
|
||||
for (int j = 0; j < pc; j++) {
|
||||
idx_ptr[j] = j;
|
||||
}
|
||||
|
||||
// Initialize arrays for first point.
|
||||
PackedVector3Array first_pt_handle_point;
|
||||
Vector<int> first_pt_id;
|
||||
first_pt_handle_point.append(primary_handle_points[0]);
|
||||
first_pt_id.append(idx[0]);
|
||||
|
||||
// Initialize arrays and add handle for last point if needed.
|
||||
if (pc > 1) {
|
||||
PackedVector3Array last_pt_handle_point;
|
||||
Vector<int> last_pt_id;
|
||||
last_pt_handle_point.append(primary_handle_points[pc - 1]);
|
||||
last_pt_id.append(idx[pc - 1]);
|
||||
primary_handle_points.remove_at(pc - 1);
|
||||
idx.remove_at(pc - 1);
|
||||
add_handles(last_pt_handle_point, c->is_closed() ? handles_material : last_pt_handle_material, last_pt_id);
|
||||
}
|
||||
|
||||
// Add handle for first point.
|
||||
primary_handle_points.remove_at(0);
|
||||
idx.remove_at(0);
|
||||
add_handles(first_pt_handle_point, c->is_closed() ? closed_pt_handle_material : first_pt_handle_material, first_pt_id);
|
||||
|
||||
// Add handles for remaining intermediate points.
|
||||
if (!primary_handle_points.is_empty()) {
|
||||
add_handles(primary_handle_points, handles_material, idx);
|
||||
}
|
||||
}
|
||||
if (secondary_handle_points.size()) {
|
||||
add_handles(secondary_handle_points, sec_handles_material, collected_secondary_handle_ids, false, true);
|
||||
|
|
@ -469,7 +514,7 @@ Path3DGizmo::Path3DGizmo(Path3D *p_path, float p_disk_size) {
|
|||
Path3DEditorPlugin::singleton->curve_edit_curve->connect(SceneStringName(pressed), callable_mp(this, &Path3DGizmo::redraw));
|
||||
Path3DEditorPlugin::singleton->curve_create->connect(SceneStringName(pressed), callable_mp(this, &Path3DGizmo::redraw));
|
||||
Path3DEditorPlugin::singleton->curve_del->connect(SceneStringName(pressed), callable_mp(this, &Path3DGizmo::redraw));
|
||||
Path3DEditorPlugin::singleton->curve_close->connect(SceneStringName(pressed), callable_mp(this, &Path3DGizmo::redraw));
|
||||
Path3DEditorPlugin::singleton->curve_closed->connect(SceneStringName(pressed), callable_mp(this, &Path3DGizmo::redraw));
|
||||
}
|
||||
|
||||
EditorPlugin::AfterGUIInput Path3DEditorPlugin::forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
|
||||
|
|
@ -652,6 +697,7 @@ void Path3DEditorPlugin::edit(Object *p_object) {
|
|||
if (path->get_curve().is_valid()) {
|
||||
path->get_curve()->emit_signal(CoreStringName(changed));
|
||||
}
|
||||
_update_toolbar();
|
||||
}
|
||||
} else {
|
||||
Path3D *pre = path;
|
||||
|
|
@ -686,16 +732,16 @@ void Path3DEditorPlugin::make_visible(bool p_visible) {
|
|||
}
|
||||
|
||||
void Path3DEditorPlugin::_mode_changed(int p_mode) {
|
||||
curve_create->set_pressed(p_mode == MODE_CREATE);
|
||||
curve_edit_curve->set_pressed(p_mode == MODE_EDIT_CURVE);
|
||||
curve_edit_tilt->set_pressed(p_mode == MODE_EDIT_TILT);
|
||||
curve_edit->set_pressed(p_mode == MODE_EDIT);
|
||||
curve_del->set_pressed(p_mode == MODE_DELETE);
|
||||
curve_create->set_pressed_no_signal(p_mode == MODE_CREATE);
|
||||
curve_edit_curve->set_pressed_no_signal(p_mode == MODE_EDIT_CURVE);
|
||||
curve_edit_tilt->set_pressed_no_signal(p_mode == MODE_EDIT_TILT);
|
||||
curve_edit->set_pressed_no_signal(p_mode == MODE_EDIT);
|
||||
curve_del->set_pressed_no_signal(p_mode == MODE_DELETE);
|
||||
|
||||
Node3DEditor::get_singleton()->clear_subgizmo_selection();
|
||||
}
|
||||
|
||||
void Path3DEditorPlugin::_close_curve() {
|
||||
void Path3DEditorPlugin::_toggle_closed_curve() {
|
||||
Ref<Curve3D> c = path->get_curve();
|
||||
if (c.is_null()) {
|
||||
return;
|
||||
|
|
@ -703,13 +749,10 @@ void Path3DEditorPlugin::_close_curve() {
|
|||
if (c->get_point_count() < 2) {
|
||||
return;
|
||||
}
|
||||
if (c->get_point_position(0) == c->get_point_position(c->get_point_count() - 1)) {
|
||||
return;
|
||||
}
|
||||
EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton();
|
||||
ur->create_action(TTR("Close Curve"));
|
||||
ur->add_do_method(c.ptr(), "add_point", c->get_point_position(0), c->get_point_in(0), c->get_point_out(0), -1);
|
||||
ur->add_undo_method(c.ptr(), "remove_point", c->get_point_count());
|
||||
ur->create_action(TTR("Toggle Open/Closed Curve"));
|
||||
ur->add_do_method(c.ptr(), "set_closed", !c.ptr()->is_closed());
|
||||
ur->add_undo_method(c.ptr(), "set_closed", c.ptr()->is_closed());
|
||||
ur->commit_action();
|
||||
}
|
||||
|
||||
|
|
@ -732,6 +775,21 @@ void Path3DEditorPlugin::_handle_option_pressed(int p_option) {
|
|||
}
|
||||
}
|
||||
|
||||
void Path3DEditorPlugin::_create_curve() {
|
||||
ERR_FAIL_NULL(path);
|
||||
|
||||
Ref<Curve3D> new_curve;
|
||||
new_curve.instantiate();
|
||||
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("Create Curve in Path3D"));
|
||||
undo_redo->add_do_property(path, "curve", new_curve);
|
||||
undo_redo->add_undo_property(path, "curve", Ref<Curve3D>());
|
||||
undo_redo->add_do_method(this, "_update_toolbar");
|
||||
undo_redo->add_undo_method(this, "_update_toolbar");
|
||||
undo_redo->commit_action();
|
||||
}
|
||||
|
||||
void Path3DEditorPlugin::_confirm_clear_points() {
|
||||
if (!path || path->get_curve().is_null() || path->get_curve()->get_point_count() == 0) {
|
||||
return;
|
||||
|
|
@ -755,6 +813,7 @@ void Path3DEditorPlugin::_clear_curve_points() {
|
|||
return;
|
||||
}
|
||||
Ref<Curve3D> curve = path->get_curve();
|
||||
curve->set_closed(false);
|
||||
curve->clear_points();
|
||||
}
|
||||
|
||||
|
|
@ -774,53 +833,37 @@ void Path3DEditorPlugin::_restore_curve_points(const PackedVector3Array &p_point
|
|||
}
|
||||
|
||||
void Path3DEditorPlugin::_update_theme() {
|
||||
// TODO: Split the EditorPlugin instance from the UI instance and connect this properly.
|
||||
// See the 2D path editor for inspiration.
|
||||
curve_edit->set_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("CurveEdit"), EditorStringName(EditorIcons)));
|
||||
curve_edit_curve->set_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("CurveCurve"), EditorStringName(EditorIcons)));
|
||||
curve_edit_tilt->set_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("CurveTilt"), EditorStringName(EditorIcons)));
|
||||
curve_create->set_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("CurveCreate"), EditorStringName(EditorIcons)));
|
||||
curve_del->set_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("CurveDelete"), EditorStringName(EditorIcons)));
|
||||
curve_close->set_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("CurveClose"), EditorStringName(EditorIcons)));
|
||||
curve_clear_points->set_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("Clear"), EditorStringName(EditorIcons)));
|
||||
curve_edit->set_button_icon(topmenu_bar->get_editor_theme_icon(SNAME("CurveEdit")));
|
||||
curve_edit_curve->set_button_icon(topmenu_bar->get_editor_theme_icon(SNAME("CurveCurve")));
|
||||
curve_edit_tilt->set_button_icon(topmenu_bar->get_editor_theme_icon(SNAME("CurveTilt")));
|
||||
curve_create->set_button_icon(topmenu_bar->get_editor_theme_icon(SNAME("CurveCreate")));
|
||||
curve_del->set_button_icon(topmenu_bar->get_editor_theme_icon(SNAME("CurveDelete")));
|
||||
curve_closed->set_button_icon(topmenu_bar->get_editor_theme_icon(SNAME("CurveClose")));
|
||||
curve_clear_points->set_button_icon(topmenu_bar->get_editor_theme_icon(SNAME("Clear")));
|
||||
create_curve_button->set_button_icon(topmenu_bar->get_editor_theme_icon(SNAME("Curve3D")));
|
||||
}
|
||||
|
||||
void Path3DEditorPlugin::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
curve_create->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_mode_changed).bind(MODE_CREATE));
|
||||
curve_edit_curve->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_mode_changed).bind(MODE_EDIT_CURVE));
|
||||
curve_edit_tilt->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_mode_changed).bind(MODE_EDIT_TILT));
|
||||
curve_edit->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_mode_changed).bind(MODE_EDIT));
|
||||
curve_del->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_mode_changed).bind(MODE_DELETE));
|
||||
curve_close->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_close_curve));
|
||||
|
||||
_update_theme();
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_READY: {
|
||||
// FIXME: This can trigger theme updates when the nodes that we want to update are not yet available.
|
||||
// The toolbar should be extracted to a dedicated control and theme updates should be handled through
|
||||
// the notification.
|
||||
Node3DEditor::get_singleton()->connect(SceneStringName(theme_changed), callable_mp(this, &Path3DEditorPlugin::_update_theme));
|
||||
} break;
|
||||
void Path3DEditorPlugin::_update_toolbar() {
|
||||
if (!path) {
|
||||
return;
|
||||
}
|
||||
bool has_curve = path->get_curve().is_valid();
|
||||
toolbar->set_visible(has_curve);
|
||||
create_curve_button->set_visible(!has_curve);
|
||||
}
|
||||
|
||||
void Path3DEditorPlugin::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_update_toolbar"), &Path3DEditorPlugin::_update_toolbar);
|
||||
ClassDB::bind_method(D_METHOD("_clear_curve_points"), &Path3DEditorPlugin::_clear_curve_points);
|
||||
ClassDB::bind_method(D_METHOD("_restore_curve_points"), &Path3DEditorPlugin::_restore_curve_points);
|
||||
}
|
||||
|
||||
Path3DEditorPlugin *Path3DEditorPlugin::singleton = nullptr;
|
||||
|
||||
Path3DEditorPlugin::Path3DEditorPlugin() {
|
||||
path = nullptr;
|
||||
singleton = this;
|
||||
mirror_handle_angle = true;
|
||||
mirror_handle_length = true;
|
||||
|
||||
disk_size = EDITOR_DEF_RST("editors/3d_gizmos/gizmo_settings/path3d_tilt_disk_size", 0.8);
|
||||
disk_size = EDITOR_GET("editors/3d_gizmos/gizmo_settings/path3d_tilt_disk_size");
|
||||
|
||||
Ref<Path3DGizmoPlugin> gizmo_plugin = memnew(Path3DGizmoPlugin(disk_size));
|
||||
Node3DEditor::get_singleton()->add_gizmo_plugin(gizmo_plugin);
|
||||
|
|
@ -828,80 +871,93 @@ Path3DEditorPlugin::Path3DEditorPlugin() {
|
|||
|
||||
topmenu_bar = memnew(HBoxContainer);
|
||||
topmenu_bar->hide();
|
||||
Node3DEditor::get_singleton()->add_control_to_menu_panel(topmenu_bar);
|
||||
|
||||
toolbar = memnew(HBoxContainer);
|
||||
topmenu_bar->add_child(toolbar);
|
||||
|
||||
curve_edit = memnew(Button);
|
||||
curve_edit->set_theme_type_variation("FlatButton");
|
||||
curve_edit->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
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"));
|
||||
topmenu_bar->add_child(curve_edit);
|
||||
toolbar->add_child(curve_edit);
|
||||
curve_edit->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_mode_changed).bind(MODE_EDIT));
|
||||
|
||||
curve_edit_curve = memnew(Button);
|
||||
curve_edit_curve->set_theme_type_variation("FlatButton");
|
||||
curve_edit_curve->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
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"));
|
||||
topmenu_bar->add_child(curve_edit_curve);
|
||||
toolbar->add_child(curve_edit_curve);
|
||||
curve_edit_curve->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_mode_changed).bind(MODE_EDIT_CURVE));
|
||||
|
||||
curve_edit_tilt = memnew(Button);
|
||||
curve_edit_tilt->set_theme_type_variation("FlatButton");
|
||||
curve_edit_tilt->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
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"));
|
||||
topmenu_bar->add_child(curve_edit_tilt);
|
||||
toolbar->add_child(curve_edit_tilt);
|
||||
curve_edit_tilt->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_mode_changed).bind(MODE_EDIT_TILT));
|
||||
|
||||
curve_create = memnew(Button);
|
||||
curve_create->set_theme_type_variation("FlatButton");
|
||||
curve_create->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
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)"));
|
||||
topmenu_bar->add_child(curve_create);
|
||||
toolbar->add_child(curve_create);
|
||||
curve_create->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_mode_changed).bind(MODE_CREATE));
|
||||
|
||||
curve_del = memnew(Button);
|
||||
curve_del->set_theme_type_variation("FlatButton");
|
||||
curve_del->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
curve_del->set_toggle_mode(true);
|
||||
curve_del->set_focus_mode(Control::FOCUS_NONE);
|
||||
curve_del->set_tooltip_text(TTR("Delete Point"));
|
||||
topmenu_bar->add_child(curve_del);
|
||||
toolbar->add_child(curve_del);
|
||||
curve_del->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_mode_changed).bind(MODE_DELETE));
|
||||
|
||||
curve_close = memnew(Button);
|
||||
curve_close->set_theme_type_variation("FlatButton");
|
||||
curve_close->set_focus_mode(Control::FOCUS_NONE);
|
||||
curve_close->set_tooltip_text(TTR("Close Curve"));
|
||||
topmenu_bar->add_child(curve_close);
|
||||
curve_closed = memnew(Button);
|
||||
curve_closed->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
curve_closed->set_focus_mode(Control::FOCUS_NONE);
|
||||
curve_closed->set_tooltip_text(TTR("Close Curve"));
|
||||
toolbar->add_child(curve_closed);
|
||||
curve_closed->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_toggle_closed_curve));
|
||||
|
||||
curve_clear_points = memnew(Button);
|
||||
curve_clear_points->set_theme_type_variation("FlatButton");
|
||||
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->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_confirm_clear_points));
|
||||
topmenu_bar->add_child(curve_clear_points);
|
||||
toolbar->add_child(curve_clear_points);
|
||||
|
||||
clear_points_dialog = memnew(ConfirmationDialog);
|
||||
clear_points_dialog->set_title(TTR("Please Confirm..."));
|
||||
clear_points_dialog->set_text(TTR("Remove all curve points?"));
|
||||
clear_points_dialog->connect(SceneStringName(confirmed), callable_mp(this, &Path3DEditorPlugin::_clear_points));
|
||||
topmenu_bar->add_child(clear_points_dialog);
|
||||
toolbar->add_child(clear_points_dialog);
|
||||
|
||||
handle_menu = memnew(MenuButton);
|
||||
handle_menu->set_flat(false);
|
||||
handle_menu->set_theme_type_variation("FlatMenuButton");
|
||||
handle_menu->set_text(TTR("Options"));
|
||||
topmenu_bar->add_child(handle_menu);
|
||||
toolbar->add_child(handle_menu);
|
||||
|
||||
PopupMenu *menu;
|
||||
menu = handle_menu->get_popup();
|
||||
create_curve_button = memnew(Button);
|
||||
create_curve_button->set_text(TTR("Create Curve"));
|
||||
create_curve_button->hide();
|
||||
topmenu_bar->add_child(create_curve_button);
|
||||
create_curve_button->connect(SceneStringName(pressed), callable_mp(this, &Path3DEditorPlugin::_create_curve));
|
||||
|
||||
PopupMenu *menu = handle_menu->get_popup();
|
||||
menu->add_check_item(TTR("Mirror Handle Angles"));
|
||||
menu->set_item_checked(HANDLE_OPTION_ANGLE, mirror_handle_angle);
|
||||
menu->add_check_item(TTR("Mirror Handle Lengths"));
|
||||
menu->set_item_checked(HANDLE_OPTION_LENGTH, mirror_handle_length);
|
||||
menu->connect(SceneStringName(id_pressed), callable_mp(this, &Path3DEditorPlugin::_handle_option_pressed));
|
||||
|
||||
curve_edit->set_pressed(true);
|
||||
}
|
||||
curve_edit->set_pressed_no_signal(true);
|
||||
|
||||
Path3DEditorPlugin::~Path3DEditorPlugin() {
|
||||
topmenu_bar->connect(SceneStringName(theme_changed), callable_mp(this, &Path3DEditorPlugin::_update_theme));
|
||||
Node3DEditor::get_singleton()->add_control_to_menu_panel(topmenu_bar);
|
||||
}
|
||||
|
||||
Ref<EditorNode3DGizmo> Path3DGizmoPlugin::create_gizmo(Node3D *p_spatial) {
|
||||
|
|
@ -909,7 +965,7 @@ Ref<EditorNode3DGizmo> Path3DGizmoPlugin::create_gizmo(Node3D *p_spatial) {
|
|||
|
||||
Path3D *path = Object::cast_to<Path3D>(p_spatial);
|
||||
if (path) {
|
||||
ref = Ref<Path3DGizmo>(memnew(Path3DGizmo(path, disk_size)));
|
||||
ref.instantiate(path, disk_size);
|
||||
}
|
||||
|
||||
return ref;
|
||||
|
|
@ -930,6 +986,14 @@ void Path3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
|||
Ref<Curve3D> curve = path->get_curve();
|
||||
|
||||
Ref<StandardMaterial3D> handle_material = get_material("handles", p_gizmo);
|
||||
Ref<StandardMaterial3D> first_pt_handle_material = get_material("first_pt_handle", p_gizmo);
|
||||
Ref<StandardMaterial3D> last_pt_handle_material = get_material("last_pt_handle", p_gizmo);
|
||||
Ref<StandardMaterial3D> closed_pt_handle_material = get_material("closed_pt_handle", p_gizmo);
|
||||
|
||||
first_pt_handle_material->set_albedo(Color(0.2, 1.0, 0.0));
|
||||
last_pt_handle_material->set_albedo(Color(1.0, 0.2, 0.0));
|
||||
closed_pt_handle_material->set_albedo(Color(1.0, 0.8, 0.0));
|
||||
|
||||
PackedVector3Array handles;
|
||||
|
||||
if (Path3DEditorPlugin::singleton->curve_edit->is_pressed()) {
|
||||
|
|
@ -942,7 +1006,37 @@ void Path3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
|||
}
|
||||
|
||||
if (handles.size()) {
|
||||
p_gizmo->add_vertices(handles, handle_material, Mesh::PRIMITIVE_POINTS);
|
||||
// Point count.
|
||||
const int pc = handles.size();
|
||||
|
||||
// Initialize arrays for first point.
|
||||
PackedVector3Array first_pt;
|
||||
first_pt.append(handles[0]);
|
||||
|
||||
// Initialize arrays and add handle for last point if needed.
|
||||
if (pc > 1) {
|
||||
PackedVector3Array last_pt;
|
||||
last_pt.append(handles[handles.size() - 1]);
|
||||
handles.remove_at(handles.size() - 1);
|
||||
if (curve->is_closed()) {
|
||||
p_gizmo->add_vertices(last_pt, handle_material, Mesh::PRIMITIVE_POINTS);
|
||||
} else {
|
||||
p_gizmo->add_vertices(last_pt, last_pt_handle_material, Mesh::PRIMITIVE_POINTS);
|
||||
}
|
||||
}
|
||||
|
||||
// Add handle for first point.
|
||||
handles.remove_at(0);
|
||||
if (curve->is_closed()) {
|
||||
p_gizmo->add_vertices(first_pt, closed_pt_handle_material, Mesh::PRIMITIVE_POINTS);
|
||||
} else {
|
||||
p_gizmo->add_vertices(first_pt, first_pt_handle_material, Mesh::PRIMITIVE_POINTS);
|
||||
}
|
||||
|
||||
// Add handles for remaining intermediate points.
|
||||
if (!handles.is_empty()) {
|
||||
p_gizmo->add_vertices(handles, handle_material, Mesh::PRIMITIVE_POINTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1051,7 +1145,7 @@ int Path3DGizmoPlugin::get_priority() const {
|
|||
|
||||
Path3DGizmoPlugin::Path3DGizmoPlugin(float p_disk_size) {
|
||||
Color path_color = SceneTree::get_singleton()->get_debug_paths_color();
|
||||
Color path_tilt_color = EDITOR_DEF_RST("editors/3d_gizmos/gizmo_colors/path_tilt", Color(1.0, 1.0, 0.4, 0.9));
|
||||
Color path_tilt_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/path_tilt");
|
||||
disk_size = p_disk_size;
|
||||
|
||||
create_material("path_material", path_color);
|
||||
|
|
@ -1059,5 +1153,8 @@ Path3DGizmoPlugin::Path3DGizmoPlugin(float p_disk_size) {
|
|||
create_material("path_tilt_material", path_tilt_color);
|
||||
create_material("path_tilt_muted_material", path_tilt_color * 0.7);
|
||||
create_handle_material("handles", false, EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("EditorPathSmoothHandle"), EditorStringName(EditorIcons)));
|
||||
create_handle_material("first_pt_handle", false, EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("EditorPathSmoothHandle"), EditorStringName(EditorIcons)));
|
||||
create_handle_material("last_pt_handle", false, EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("EditorPathSmoothHandle"), EditorStringName(EditorIcons)));
|
||||
create_handle_material("closed_pt_handle", false, EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("EditorPathSmoothHandle"), EditorStringName(EditorIcons)));
|
||||
create_handle_material("sec_handles", false, EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("EditorCurveHandle"), EditorStringName(EditorIcons)));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue