Page MenuHome

Improve GP reproject operator in surface mode
AbandonedPublic

Authored by Lukas W (geloescht) on May 16 2019, 8:58 PM.

Details

Summary

When using the surface option for the reproject operator, currently this is implemented through OpenGL, which results in stairstepping artifacts that depend on your screen resolution. Also points outside the current view will not be reprojected properly. This patch uses raycasting instead to get rid of those drawbacks.

Diff Detail

Repository
rB Blender

Event Timeline

I have tested and works, but I have several comments:

  1. I have never used ED_transform_snap_object_project_ray() function, so not sure if this correct or not. @Brecht Van Lommel (brecht) could you tell us your opinion about this?
  1. When you are drawing on surface in gpencil_paint and primitives, the program is using the same old reproject method (opengl), so it would be better to keep all methods equal.... maybe adding a new BKE_xxxx function and call it from several places would be a good solution.

Agree with @Antonio Vazquez (antoniov) . If this solution is better technically speaking and more accurate, it should be use also when drawing on surface

Lukas W (geloescht) added a comment.EditedMay 18 2019, 10:19 AM

There some reasons I implemented ray casting for the operator only and not drawing

  • It is to be expected that the resolution of drawing is dependent on the size of the drawing surface. Also being able to draw outside the drawing surface is not necessarily expected. (On a related note, does Blender do sub-pixel input?)
  • I was unsure about the performance of ray casting. Low performance is not such an issue with the operator where some delays are to be expected while it can be quite disruptive while drawing.
  • This is my first experience with the Blender C code base, so I am already happy with a small victory.

If you agree that this would be something worthy of implementation for draw mode as well I will give it a shot. It would be indeed useful if someone with experience with ED_transform_snap_object_project_ray() could comment on its usefulness and performance compared to ED_view3d_autodist_simple().

@Lukas W (geloescht) I'm going to review the drawing code (I know how the code works) and I will try to use your code to create a more general function. Anyway, I think your change is in the right direction and we can use it... and of course, thanks a lot for your contribution, we always welcome new developers.

After looking in paint operators, maybe the best plan is to implement this change and later change paint operators (currently we are near to freeze 2.80 and it's not the best moment to change things in paint operators).

For 2.81 I'm thinking to use this idea to improve paint and primitive operators and maybe add new modifiers.

Great, looking forward to it. If you are interested, my use case for this patch is that I often forget to set the correct cursor or drawing mode or do some animation by eye that I later want to correctly align with other 3D elements. It avoids a lot of mode switching (brain- and software-wise) to do alignment and drawing in separate passes.

Only to keep a note, when this code will be applied, we must add the feature requested in T64814

@Lukas W (geloescht) As we are almost in 2.80 freeze date, I'm going to hold this change until 2.80 release date and will apply for 2.81. Anyway, I'm going to apply your patch to greasepencil-branch and we can test freely.

We have included this patch in greasepencil-object branch already. The change will be applied with a merge.