Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Onion skinning #12572

Merged
merged 6 commits into from
Nov 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions drivers/gles3/rasterizer_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ void RasterizerGLES3::blit_render_target_to_screen(RID p_render_target, const Re
canvas->canvas_end();
}

void RasterizerGLES3::end_frame() {
void RasterizerGLES3::end_frame(bool p_swap_buffers) {

#if 0
canvas->canvas_begin();
Expand Down Expand Up @@ -384,7 +384,10 @@ void RasterizerGLES3::end_frame() {

canvas->draw_generic_textured_rect(Rect2(0,0,15,15),Rect2(0,0,1,1));
#endif
OS::get_singleton()->swap_buffers();
if (p_swap_buffers)
OS::get_singleton()->swap_buffers();
else
glFinish();

/* print_line("objects: "+itos(storage->info.render_object_count));
print_line("material chages: "+itos(storage->info.render_material_switch_count));
Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/rasterizer_gles3.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class RasterizerGLES3 : public Rasterizer {
virtual void restore_render_target();
virtual void clear_render_target(const Color &p_color);
virtual void blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect, int p_screen = 0);
virtual void end_frame();
virtual void end_frame(bool p_swap_buffers);
virtual void finalize();

static void make_current();
Expand Down
13 changes: 11 additions & 2 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5624,6 +5624,7 @@ EditorNode::EditorNode() {

editor_plugin_screen = NULL;
editor_plugins_over = memnew(EditorPluginList);
editor_plugins_force_over = memnew(EditorPluginList);
editor_plugins_force_input_forwarding = memnew(EditorPluginList);

_edit_current();
Expand Down Expand Up @@ -5748,6 +5749,7 @@ EditorNode::~EditorNode() {
memdelete(EditorHelp::get_doc_data());
memdelete(editor_selection);
memdelete(editor_plugins_over);
memdelete(editor_plugins_force_over);
memdelete(editor_plugins_force_input_forwarding);
memdelete(file_server);
memdelete(progress_hb);
Expand Down Expand Up @@ -5801,10 +5803,17 @@ bool EditorPluginList::forward_spatial_gui_input(Camera *p_camera, const Ref<Inp
return discard;
}

void EditorPluginList::forward_draw_over_canvas(Control *p_canvas) {
void EditorPluginList::forward_draw_over_viewport(Control *p_overlay) {

for (int i = 0; i < plugins_list.size(); i++) {
plugins_list[i]->forward_draw_over_canvas(p_canvas);
plugins_list[i]->forward_draw_over_viewport(p_overlay);
}
}

void EditorPluginList::forward_force_draw_over_viewport(Control *p_overlay) {

for (int i = 0; i < plugins_list.size(); i++) {
plugins_list[i]->forward_force_draw_over_viewport(p_overlay);
}
}

Expand Down
5 changes: 4 additions & 1 deletion editor/editor_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ class EditorNode : public Node {
Vector<EditorPlugin *> editor_plugins;
EditorPlugin *editor_plugin_screen;
EditorPluginList *editor_plugins_over;
EditorPluginList *editor_plugins_force_over;
EditorPluginList *editor_plugins_force_input_forwarding;

EditorHistory editor_history;
Expand Down Expand Up @@ -636,6 +637,7 @@ class EditorNode : public Node {

EditorPlugin *get_editor_plugin_screen() { return editor_plugin_screen; }
EditorPluginList *get_editor_plugins_over() { return editor_plugins_over; }
EditorPluginList *get_editor_plugins_force_over() { return editor_plugins_force_over; }
EditorPluginList *get_editor_plugins_force_input_forwarding() { return editor_plugins_force_input_forwarding; }
PropertyEditor *get_property_editor() { return property_editor; }
VBoxContainer *get_property_editor_vb() { return prop_editor_vb; }
Expand Down Expand Up @@ -820,7 +822,8 @@ class EditorPluginList : public Object {
void edit(Object *p_object);
bool forward_gui_input(const Ref<InputEvent> &p_event);
bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled);
void forward_draw_over_canvas(Control *p_canvas);
void forward_draw_over_viewport(Control *p_overlay);
void forward_force_draw_over_viewport(Control *p_overlay);
void add_plugin(EditorPlugin *p_plugin);
void clear();
bool empty();
Expand Down
46 changes: 39 additions & 7 deletions editor/editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,12 @@ void EditorPlugin::set_input_event_forwarding_always_enabled() {
always_input_forwarding_list->add_plugin(this);
}

void EditorPlugin::set_force_draw_over_forwarding_enabled() {
force_draw_over_forwarding_enabled = true;
EditorPluginList *always_draw_over_forwarding_list = EditorNode::get_singleton()->get_editor_plugins_force_over();
always_draw_over_forwarding_list->add_plugin(this);
}

void EditorPlugin::notify_scene_changed(const Node *scn_root) {
if (scn_root == NULL) return;
emit_signal("scene_changed", scn_root);
Expand Down Expand Up @@ -410,15 +416,38 @@ bool EditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
return false;
}

void EditorPlugin::forward_draw_over_canvas(Control *p_canvas) {
void EditorPlugin::forward_draw_over_viewport(Control *p_overlay) {

if (get_script_instance() && get_script_instance()->has_method("forward_draw_over_canvas")) {
get_script_instance()->call("forward_draw_over_canvas", p_canvas);
if (get_script_instance() && get_script_instance()->has_method("forward_draw_over_viewport")) {
get_script_instance()->call("forward_draw_over_viewport", p_overlay);
}
}

void EditorPlugin::update_canvas() {
CanvasItemEditor::get_singleton()->get_viewport_control()->update();
void EditorPlugin::forward_force_draw_over_viewport(Control *p_overlay) {

if (get_script_instance() && get_script_instance()->has_method("forward_force_draw_over_viewport")) {
get_script_instance()->call("forward_force_draw_over_viewport", p_overlay);
}
}

// Updates the overlays of the 2D viewport or, if in 3D mode, of every 3D viewport.
int EditorPlugin::update_overlays() const {

if (SpatialEditor::get_singleton()->is_visible()) {
int count = 0;
for (int i = 0; i < SpatialEditor::VIEWPORTS_COUNT; i++) {
SpatialEditorViewport *vp = SpatialEditor::get_singleton()->get_editor_viewport(i);
if (vp->is_visible()) {
vp->update_surface();
count++;
}
}
return count;
} else {
// This will update the normal viewport itself as well
CanvasItemEditor::get_singleton()->get_viewport_control()->update();
return 1;
}
}

bool EditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
Expand Down Expand Up @@ -590,7 +619,7 @@ void EditorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_custom_type", "type", "base", "script", "icon"), &EditorPlugin::add_custom_type);
ClassDB::bind_method(D_METHOD("remove_custom_type", "type"), &EditorPlugin::remove_custom_type);

ClassDB::bind_method(D_METHOD("update_canvas"), &EditorPlugin::update_canvas);
ClassDB::bind_method(D_METHOD("update_overlays"), &EditorPlugin::update_overlays);

ClassDB::bind_method(D_METHOD("make_bottom_panel_item_visible", "item"), &EditorPlugin::make_bottom_panel_item_visible);
ClassDB::bind_method(D_METHOD("hide_bottom_panel"), &EditorPlugin::hide_bottom_panel);
Expand All @@ -602,11 +631,13 @@ void EditorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_export_plugin", "exporter"), &EditorPlugin::add_export_plugin);
ClassDB::bind_method(D_METHOD("remove_export_plugin", "exporter"), &EditorPlugin::remove_export_plugin);
ClassDB::bind_method(D_METHOD("set_input_event_forwarding_always_enabled"), &EditorPlugin::set_input_event_forwarding_always_enabled);
ClassDB::bind_method(D_METHOD("set_force_draw_over_forwarding_enabled"), &EditorPlugin::set_force_draw_over_forwarding_enabled);

ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorPlugin::get_editor_interface);

ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::TRANSFORM2D, "canvas_xform"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_draw_over_canvas", PropertyInfo(Variant::TRANSFORM2D, "canvas_xform"), PropertyInfo(Variant::OBJECT, "canvas", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
MethodInfo gizmo = MethodInfo(Variant::OBJECT, "create_spatial_gizmo", PropertyInfo(Variant::OBJECT, "for_spatial", PROPERTY_HINT_RESOURCE_TYPE, "Spatial"));
gizmo.return_val.hint = PROPERTY_HINT_RESOURCE_TYPE;
Expand Down Expand Up @@ -653,6 +684,7 @@ void EditorPlugin::_bind_methods() {
EditorPlugin::EditorPlugin() {
undo_redo = NULL;
input_event_forwarding_always_enabled = false;
force_draw_over_forwarding_enabled = false;
last_main_screen_name = "";
}

Expand Down
9 changes: 7 additions & 2 deletions editor/editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class EditorPlugin : public Node {
UndoRedo *_get_undo_redo() { return undo_redo; }

bool input_event_forwarding_always_enabled;
bool force_draw_over_forwarding_enabled;

String last_main_screen_name;

Expand Down Expand Up @@ -151,13 +152,17 @@ class EditorPlugin : public Node {
void set_input_event_forwarding_always_enabled();
bool is_input_event_forwarding_always_enabled() { return input_event_forwarding_always_enabled; }

void set_force_draw_over_forwarding_enabled();
bool is_force_draw_over_forwarding_enabled() { return force_draw_over_forwarding_enabled; }

void notify_main_screen_changed(const String &screen_name);
void notify_scene_changed(const Node *scn_root);
void notify_scene_closed(const String &scene_filepath);

virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial *p_spatial);
virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event);
virtual void forward_draw_over_canvas(Control *p_canvas);
virtual void forward_draw_over_viewport(Control *p_overlay);
virtual void forward_force_draw_over_viewport(Control *p_overlay);
virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event);
virtual String get_name() const;
virtual bool has_main_screen() const;
Expand All @@ -178,7 +183,7 @@ class EditorPlugin : public Node {

EditorInterface *get_editor_interface();

void update_canvas();
int update_overlays() const;

void queue_save_layout() const;

Expand Down
2 changes: 2 additions & 0 deletions editor/editor_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {

_initial_set("editors/animation/autorename_animation_tracks", true);
_initial_set("editors/animation/confirm_insert_track", true);
_initial_set("editors/animation/onion_layers_past_color", Color(1, 0, 0));
_initial_set("editors/animation/onion_layers_future_color", Color(0, 1, 0));

_initial_set("docks/property_editor/texture_preview_width", 48);
_initial_set("docks/property_editor/auto_refresh_interval", 0.3);
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/abstract_polygon_2d_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
return false;
}

void AbstractPolygon2DEditor::forward_draw_over_canvas(Control *p_canvas) {
void AbstractPolygon2DEditor::forward_draw_over_viewport(Control *p_overlay) {
if (!_get_node())
return;

Expand Down
4 changes: 2 additions & 2 deletions editor/plugins/abstract_polygon_2d_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class AbstractPolygon2DEditor : public HBoxContainer {

public:
bool forward_gui_input(const Ref<InputEvent> &p_event);
void forward_draw_over_canvas(Control *p_canvas);
void forward_draw_over_viewport(Control *p_overlay);

void edit(Node *p_polygon);
AbstractPolygon2DEditor(EditorNode *p_editor, bool p_wip_destructive = true);
Expand All @@ -152,7 +152,7 @@ class AbstractPolygon2DEditorPlugin : public EditorPlugin {

public:
virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return polygon_editor->forward_gui_input(p_event); }
virtual void forward_draw_over_canvas(Control *p_canvas) { polygon_editor->forward_draw_over_canvas(p_canvas); }
virtual void forward_draw_over_viewport(Control *p_overlay) { polygon_editor->forward_draw_over_viewport(p_overlay); }

bool has_main_screen() const { return false; }
virtual String get_name() const { return klass; }
Expand Down
Loading