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
Perspective mode #685
base: master
Are you sure you want to change the base?
Perspective mode #685
Conversation
This is a really interesting start, and I want to pick it up for 1.3.0. I really love how you lay down strokes towards the control points with the brush, and it just does the right thing. This has a deeply satisfying feeling to me, and it's exactly the sort of intuitive thing MyPaint tools should have. Can you start by rebasing against the latest mypaint/master? There has been a fairly major project split, and there are some changes that this branch needs to incorporate in order to build against the upcoming libmypaint release. A forced push will be OK. Some quick UI notes:
|
I've put my thoughts down about the perspective mode on the thread which @achadwick started on our community forums: https://community.mypaint.org/t/testers-wanted-perspective-mode-early-stages/369/7?u=odysseywestra It's a promising start, but I can't wait to see it implemented into MyPaint. Great job @gwojcik! |
5297e09
to
274586b
Compare
Branch is now rebased against mypaint/master.
I don't understand what you mean. Points should appear after using 'Add' button and clicking on canvas.
I'll describe it on community forum.
Names are not important. Currently only default points have special properties (scaling/rotation and moving other points).
I'll check it.
Currently it is possible to change perspective point while drawing line. Pressure data should be stored while drawing and after changing vanishing point interpolated and used in new line for that point. Now perspective line is drawing use same function as line mode. Making drawing incremental also would be good thing.
What do you mean by integration? |
0e5ca2f
to
32da4e3
Compare
@gwojcik could you rebase your PR to the latest commit from master? |
138ad11
to
dee3ef1
Compare
Okay, testing this out. I'm liking the options panel a lot more now, although I think there are a lot of rough edges still. I managed to trigger a new exception :/
Mypaint version: 1.3.0-alpha+git.1069fdf3
System information: Linux-4.9.0-2-amd64-x86_64-with-debian-9.0
Using: Python 2.7.13, GTK 3.22.11, GdkPixbuf 2.36.5, Cairo 1.14.8, GLib 2.50.3
Traceback (most recent call last):
File "/tmp/demo-pxCK_Q/lib/mypaint/gui/tileddrawwidget.py", line 1159, _draw_cb(self=<tileddrawwidget.CanvasRenderer object at 0x7f2a...ileddrawwidget+CanvasRenderer at 0x5584d99290f0)>, widget=<tileddrawwidget.CanvasRenderer object at 0x7f2a...ileddrawwidget+CanvasRenderer at 0x5584d99290f0)>, cr=<cairo.Context object>)
cr.save()
overlay.paint(cr)
cr.restore()
variables: {'cr': ('local', <cairo.Context object at 0x7f2ac423ea10>), 'overlay.paint': ('local', <bound method Overlay.paint of <gui.perspective.Overlay object at 0x7f2add8766d0>>)}
File "/tmp/demo-pxCK_Q/lib/mypaint/gui/perspective.py", line 598, paint(self=<gui.perspective.Overlay object>, cr=<cairo.Context object>)
point = self._perspective.get_point_by_uid(uid)
text = point.name
layout = self._tdw.create_pango_layout(text)
variables: {'text': (None, []), 'point': ('local', None)}
AttributeError: 'NoneType' object has no attribute 'name' |
@achadwick I was not able to reproduce this exception, but I think, I managed to fix it in last commit. |
Some more thoughts on this in its current form: Showstopper: it's possible to delete everything from the configuration panel. After this, I cannot click on any of the add/delete/2P/3P buttons to start again. Showstopper: There are some major problems with the circle/triangle/square geometry features:
If the perspective mode feature is to be usable, it should prevent impossible shapes from being drawn, and show some feedback more generally. Would it be possible to overlay some construction lines for things to make it clearer what clicking and dragging would draw (or not?) |
I would like the perspective settings and vanishing points to be saved as part of the working document. I am working on a patch to allow a doc.settings object with full observe-ability bells and whistles, so watch this space 😄 |
Thanks for information and testing.
Add button should be always accessible, this bug was added recently with code for enabling and disabling buttons.
I know about them. I should prevent drawing shapes after moving cursor to other side of "vanishing horizon".
I agree that adding overlay with lines will be helpful. There could be some performance problems with overlays? I tested overlays some time ago on older computer and performance was not good enough for interactive part of interface.
Will this require xml data format? I will be looking for this change. |
9a78a2b
to
f1b72f3
Compare
f1b72f3
to
3139cac
Compare
Tiage Note: Moving this to limbo for now, and make this the next big feature for us when it comes to the next version of MyPaint. |
e12d368
to
cc1bc05
Compare
'lib/libperspective/Projection.cpp', | ||
], | ||
swig_opts = ['-Wall', '-noproxydel', '-c++', '-outdir', 'lib'], | ||
language = 'c++', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unexpected spaces around keyword / parameter equals
'lib/libperspective/PythonGraph.cpp', | ||
'lib/libperspective/Projection.cpp', | ||
], | ||
swig_opts = ['-Wall', '-noproxydel', '-c++', '-outdir', 'lib'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unexpected spaces around keyword / parameter equals
gui/perspectivedata.py
Outdated
""" update data returned from get_default_data | ||
insert additional_params into node with id == node_id | ||
""" | ||
for node in data['nodes']: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Black would make changes.
gui/perspective.py
Outdated
points_3d = [] | ||
for point in points_cube: | ||
point_3d = corner_3d + p.rotate(space.get_rotation(), | ||
point.scalar_mul(self._cube_size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line under-indented for visual indent
gui/perspective.py
Outdated
view = self._space.get_view().as_projection() | ||
center = view.get_center_complex() | ||
|
||
corner = center + self._cube_corner * view.get_rotation() * view.get_size() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (83 > 79 characters)
gui/perspective.py
Outdated
center = view.get_center_complex() | ||
up = p.rotate(space.get_rotation(), Quaternion(0, 1, 0, 0)) | ||
|
||
corner = center + self._cube_corner * view.get_rotation() * view.get_size() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (87 > 79 characters)
gui/perspective.py
Outdated
|
||
for index, point in enumerate(points_cube): | ||
point_3d = corner_3d + p.rotate(space.get_rotation(), | ||
point.scalar_mul(self._cube_size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line under-indented for visual indent
gui/perspective.py
Outdated
view = self._space.get_view().as_projection() | ||
center = view.get_center_complex() | ||
|
||
corner = center + self._cube_corner * view.get_rotation() * view.get_size() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (83 > 79 characters)
gui/perspective.py
Outdated
self._queue_draw_node(point_pos) | ||
|
||
def get_overlay_widgets(self): | ||
default_color = gui.style.EDITABLE_ITEM_COLOR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local variable 'default_color' is assigned to but never used
import gui.dialogs | ||
|
||
from gui.overlays import rounded_box | ||
from gui.perspectivedata import (get_default_data, update_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Black would make changes.
Nice to see this get picked up again! The travis build image might need to be bumped to As for the hound warnings, when the PR is otherwise ready, you can ignore the "Black would make changes" complaints. The rest should be fixed, however. |
changes: - remove `#include <variant>`, std::variant is part of c++17 - Add missing inline. Remove conditional constexpr for recent version of gcc, it was used for functions with math functions calls. Math functions are constexpr only in g++, clang++ does not allow it.
data = { | ||
"nodes": [ | ||
{"type": "Group", "id": "Root", "name": _("Root")}, | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Black would make changes.
Most problems reported by hound was fixed, only left are "Black would make changes" and E251 - "unexpected spaces around keyword / parameter equals". Second problem is ignored in |
First part of changes for perspective mode.
Description of changes:
After first activation default vanishing points are created. They are placed
around point (0, 0) on canvas.
Vanishing point details can be viewed in "Tool Options".
"Right" and "Left" points define horizon. Dragging these point rotate
all points around "Center" point.
"Center" point can be dragged to change position of all points.
"Horizontal" and "Vertical" allow drawing horizontal and vertical lines,
they are influenced by rotation of "Right" and "Left" points.
Perspective Tool Options
"Add" - add point after clicking on canvas
"Delete" - delete pint selected on list
"Edit" - edit points on list, works only for added points
"Set active" - active points are visible on canvas and lines can be draw
to them. Active points have open eye icon on list.
Clicking on canvas start drawing of line to one of vanishing points.
Clicking with shift start drawing line starting in position of point
selected on list to current mouse position.
There are still need for some changes.
I don't think this changes are reedy for merge with master.
What should be changed next?
Maybe on community forum should be created discussion about perspective mode?