Commit Graph

116 Commits

Author SHA1 Message Date
Antonio Vazquez 29f3af9527 GPencil: Refactor of Draw Engine, Vertex Paint and all internal functions
This commit is a full refactor of the grease pencil modules including Draw Engine, Modifiers, VFX, depsgraph update, improvements in operators and conversion of Sculpt and Weight paint tools to real brushes.

Also, a huge code cleanup has been done at all levels.

Thanks to @fclem for his work and yo @pepeland and @mendio for the testing and help in the development.

Differential Revision: https://developer.blender.org/D6293
2020-03-09 16:27:24 +01:00
Bastien Montagne f0808b53ab Cleanup: Brush: Move to IDTypeInfo, and remove unused BKE API. 2020-03-06 12:54:04 +01:00
Bastien Montagne 4bfa256ea4 Refactor ID make local to use a single flag parameter.
Instead of using anonymous booleans flags, also allows to keep the same
behavior in all cases, without needing special handling from calling
code for our beloved oddballs object proxies...
2020-03-04 11:43:31 +01:00
Jacques Lucke 5de56f9596 Cleanup: make remaining blenkernel headers work in C++ 2020-03-02 15:07:49 +01:00
Pablo Dobarro 9251b07720 Sculpt/Paint: Remove Unified SIZE_PRESSURE and ALPHA_PRESSURE
The relation between the pressure/size and the pressure/alpha is a
fundamental property that defines the behavior of a brush, so it does
not make sense to have it unified across all brushes. This applies both
for sculpting and painting.

Some of the new 2.82 brushes need pressure/size or pressure/alpha to be
enabled to work propely, while others don't. Users should not be
switching on and off this property manually when changing brushes if they
want to use unified size. This is also causing that some users are using
the brushes with an incorrect configuration.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D6291
2019-11-27 17:17:46 +01:00
Campbell Barton 60f0a94ab2 Cleanup: clang-format 2019-10-07 15:22:22 +11:00
Pablo Dobarro be985bdde2 Sculpt: Sculpt cursor UX improvements
This commit introduces the following changes:
- Invert the direction of the brush strength WM control. It was working in the opposite direction to any other control in Blender. Now dragging to the right increases the strength.
- Increase the alpha of the cursor
- Remove the font shadow of the numbers in the WM control. It was adding too much visual noise when rendered on top of the brush alpha
- Add a second circle to preview the strength in the cursor
- Increase the resolution of the cursor circles. Now they look smooth even when working with large brush sizes.
- Add a line preview to display the brush curve
- Don't offset the cursor preview when changing size and strength

Reviewed By: billreynish, brecht

Differential Revision: https://developer.blender.org/D5889
2019-09-27 19:16:03 +02:00
Antonio Vazquez 3c7707b49f GPencil: New Brush default settings
This patch replaces D5787. Now instead to replace the startup.blend file, all the changes are done in versioning and moved to shared module to be reused by Brush reset.

Reviewers: brecht, mendio

Reviewed By: brecht

Subscribers: pepeland, mendio

Differential Revision: https://developer.blender.org/D5913
2019-09-27 16:52:50 +02:00
Campbell Barton 6eadd40597 Cleanup: redundant struct declarations 2019-08-25 16:45:47 +10:00
Campbell Barton e12c08e8d1 ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.

For details on usage and instructions for migrating branches
without conflicts, see:

https://wiki.blender.org/wiki/Tools/ClangFormat
2019-04-17 06:21:24 +02:00
Antonioya 7021bd5273 GPencil: Only brushes with pinned materials have materials
Using GP_BRUSH_MATERIAL_PINNED to switch between active material and brush material, instead of updating all brushes on active material changes. This will allow brushes to have no material and therefore to not inflate the user count.

This fix T62465.

Patch contributed by @matc
Reviewers: @brecht @antoniov @billreynish @mendio
2019-03-25 17:06:07 +01:00
Campbell Barton de13d0a80c doxygen: add newline after \file
While \file doesn't need an argument, it can't have another doxy
command after it.
2019-02-18 08:22:12 +11:00
Campbell Barton eef4077f18 Cleanup: remove redundant doxygen \file argument
Move \ingroup onto same line to be more compact and
make it clear the file is in the group.
2019-02-06 15:45:22 +11:00
Campbell Barton 65ec7ec524 Cleanup: remove redundant, invalid info from headers
BF-admins agree to remove header information that isn't useful,
to reduce noise.

- BEGIN/END license blocks

  Developers should add non license comments as separate comment blocks.
  No need for separator text.

- Contributors

  This is often invalid, outdated or misleading
  especially when splitting files.

  It's more useful to git-blame to find out who has developed the code.

See P901 for script to perform these edits.
2019-02-02 01:36:28 +11:00
Campbell Barton c0f88ed8a8 Cleanup: sort forward declarations of enum & struct
Done using:
  source/tools/utils_maintenance/c_sort_blocks.py
2019-01-28 21:17:58 +11:00
Campbell Barton 184ab749c3 Merge branch 'master' into blender2.8 2018-11-13 14:25:36 +11:00
Campbell Barton fe566a30f3 Cleanup: use lowercase 2d/3d in function names 2018-11-13 14:21:42 +11:00
Campbell Barton fb70ee0bb5 Cleanup: minor gpencil changes
- Replace BKE_brush_getactive_gpencil -> BKE_paint_brush
  (no need for per-paint-type brush access).
- Rename TOT_GP_EDITBRUSH_TYPES -> GP_EDITBRUSH_TYPE_MAX
  (avoid sharing prefix w/ unrelated constants).
- Rename instances of `GP_EditBrush_Data` to 'gp_brush'
  (`Brush` is typically called 'brush').
2018-11-12 09:59:16 +11:00
Campbell Barton fb932bb52a Cleanup: use BKE_brush_tool_get/set macros
Also add API call WM_toolsystem_ref_sync_from_context
(was in rna_workspace_api.c)
2018-11-07 08:43:56 +11:00
Campbell Barton 8b31f6fb21 Paint: add BKE_paint_ensure to initialize toolsettings
Each mode had its own logic for initializing paint structs,
move to a single function.

Also remove "BKE_brush_get_gpencil_paint", entering grease pencil
mode is responsible for ensuring the data is created.
2018-11-05 15:31:25 +11:00
Antonioya 1a7837596c GP: Select color in Brush or in Properties
After some artist feedback the material selection was not clear.

Now, the material can be selected in the top bar or in the properties panel.

1) If the material is selected in properties panel, all Brushes except pinned will be assigned to this material.

2) If the material is selected in the brush, the properties panel is updated to set the active material.

Added a new Pin icon to keep locked the material to one brush
2018-08-25 00:04:40 +02:00
Antonioya 75e34b9002 GP: Add python api to create brush settings for grease pencil 2018-08-05 16:19:24 +02:00
Antonioya 66da2f537a New Grease Pencil object for 2D animation
This commit merge the full development done in greasepencil-object branch and include mainly the following features.

- New grease pencil object.
- New drawing engine.
- New grease pencil modes Draw/Sculpt/Edit and Weight Paint.
- New brushes for grease pencil.
- New modifiers for grease pencil.
- New shaders FX.
- New material system (replace old palettes and colors).
- Split of annotations (old grease pencil) and new grease pencil object.
- UI adapted to blender 2.8.

You can get more info here:

https://code.blender.org/2017/12/drawing-2d-animation-in-blender-2-8/
https://code.blender.org/2018/07/grease-pencil-status-update/

This is the result of nearly two years of development and I want thanks firstly the other members of the grease pencil team: Daniel M. Lara, Matias Mendiola and Joshua Leung for their support, ideas and to keep working in the project all the time, without them this project had been impossible.

Also, I want thanks other Blender developers for their help, advices and to be there always to help me, and specially to Clément Foucault, Dalai Felinto, Pablo Vázquez and Campbell Barton.
2018-07-31 10:50:43 +02:00
Campbell Barton b372766816 Cleanup: trailing newlines 2018-06-29 09:23:51 +02:00
Campbell Barton 83cb34ccd1 Cleanup: unused functions 2018-06-09 18:47:39 +02:00
Campbell Barton f9f64ca4a3 Use eObjectMode for function arguments 2018-02-06 23:34:58 +11:00
Campbell Barton 99520e3f92 Cleanup: use 'e' prefix for enum typedefs
Convention was only followed loosely,
apply to DNA where changes aren't likely to conflict.

(Skipped ModifierType for eg).
2017-10-17 13:49:20 +11:00
Campbell Barton 775c773cf4 Fix sculpt secondary color missing some brushes
D2841 by @uvwxyz w/ edits
2017-10-05 12:59:22 +11:00
Campbell Barton 3c67efbbc5 Cleanup: use bool for brush checks 2017-10-05 12:59:18 +11:00
Campbell Barton 515e69999e Weight Paint: don't set weight w/ average brush
Also use 'const' for brush.
2017-10-03 18:43:18 +11:00
Campbell Barton b2a10fa615 Vertex Paint: projection options
This makes vertex paint match image painting more closely.

- Add falloff shape option sphere/circle
  where sphere uses a 3D radius around the cursor and
  circle uses a 2D radius (projected), like previous releases.
- Add normal angle option so you can control the falloff.
- Add Cull option, to paint onto faces pointing away.

Disabling normals, culling and using circle falloff
allows you to paint through the mesh.
2017-10-02 22:07:58 +11:00
Bastien Montagne 9da7dfa158 Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).

This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.

It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).

Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!

As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.

Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
Bastien Montagne eeb9e5316a Make whole ID copying code use const source pointer.
Noisy change, but safe, and better do it sooner than later if we are to
rework copying code. Also, previous commit shows this *is* useful to
catch some mistakes.
2017-06-14 22:38:11 +02:00
Bastien Montagne d8d4bef6cc Refactor/deduplicate even more make_local code (and fix part of T48907).
Turns out most BKE_foo_make_local datablock-specific functions are actually doing
exactly the same thing, only two currently need special additional operations
(object and brush ones). So added a BKE_id_make_local_generic instead
of copying same code over and over.

Also, changed a bit how make_local works in case we are localizing a whole library.
We need to do the 'remap' step (from old linked ID to new local one) in the second loop,
otherwise we miss some dependencies. This fixes main part of T48907.
2016-07-21 16:54:36 +02:00
Bastien Montagne f87603662d Add option to id_make_local to force localization of datablock, even if not used locally.
Will be used by link/append code.
2016-07-14 18:33:12 +02:00
Bastien Montagne 0f0eeffece Refactor/enhance BKE_brush_make_local() and BKE_speaker_make_local().
Now using modern features from libquery/libremap areas.

Provides same kind of fixes/improvements as for BKE_object_make_local() (see rBd1a4ae3f395a6).
2016-07-10 17:14:45 +02:00
Bastien Montagne 87b974caa1 Cleanup/Refactor: pass Main pointer to all ID copy functions.
Also allows us to get rid of a few _copy_ex() versions...
2016-07-10 14:52:00 +02:00
Campbell Barton e1f624ecef Cleanup: add missing struct qualifier 2016-02-18 19:35:48 +11:00
Campbell Barton 7b7aba31f2 Fix T46626: Crash generating previews
Brush.toggle_brush was allowed to be an invalid pointer,
it worked for the one operator that used it - but in general bad practice,
requiring a lookup on every access.

Ensure the pointer is kept valid now.
2015-11-02 21:42:47 +11:00
Bastien Montagne e5916187e8 First step to handle missing libs/datablocks when reading a file.
Idea is, instead of ignoring completely missing linked datablocks, to
create void placeholders for them.

That way, you can work on your file, save it, and find again your missing data once
lib becomes available again. Or you can edit missing lib's path (in Outliner),
save and reload the file, and you are done.

Also, Outliner now shows broken libraries (and placeholders) with a 'broken lib' icon.

Future plans are also to be able to relocate missing libs and reload them at runtime.

Code notes:
    - Placeholder ID is just a regular datablock of same type as expected linked one,
      with 'default' data, and a LIB_MISSING bitflag set.
    - To allow creation of such datablocks, creation of datablocks in BKE was split in two step:
        + Allocation of memory itself.
        + Setting of all internal data to default values.

See also the design task (T43351).

Reviewed by @campbellbarton, thanks a bunch!

Differential Revision: https://developer.blender.org/D1394
2015-10-20 14:44:57 +02:00
Antony Riakiotakis 333feea6e9 Fix T45258, impossible to select brush when removing it from 2d
painting.

Also system added a brush every time it found no paint brush in the
system which is not what we would want.

Solution:
* Brush panel stays visible always, regardless of whether there is a
brush or not.
* We search for first available brush when we find no brush in paint
struct instead of always generating a new one.
* Generating and searching for a brush take a mode argument now. Needed
some refactoring to users of BKE_paint_init as well.
* Did some style cleanups for paint mode enums.

Patch is big but it's mostly argument refactoring.
2015-08-31 22:00:30 +03:00
Antony Riakiotakis 9f911f62dc Fix T45013 negative curve falloff not working.
Was doing clamping as fix for T42984. Seems we can ommit clamping for
sculpting if we make sure overlap is not zero with negative values.

Control for clamping is moved to the "Use Clipping" function of curves
(which is on by default), so both bugs remain squashed and advanced
users can now properly utilize curves in sculpting, though not all
brushes work well with negative curves.
2015-06-10 13:32:28 +02:00
Campbell Barton afc2f415ab Cleanup: use const for sculpt code 2015-04-17 03:11:26 +10:00
Campbell Barton b1d758ae6b Cleanup: redundant struct declarations 2015-03-29 03:56:39 +11:00
Campbell Barton c41431f1e9 cleanup: use 'coords' abbreviation for functions. 2015-01-04 14:21:16 +11:00
Antony Riakiotakis a3e832e68b Fix T42984 detail flood fill not respecting mask values for smooth/sharp
curves.

Issue here is that brush curve could return negative values. This would
result in overflow of mask values. Those were not visible during real
time preview because result would be clamped.

We had two functions in the code, one of which allowed negatives but I
don't think that we really want that, users have no control over the
negative values at all anyway.

Thanks to the reporter, Leon Cheung for figuring out the issue :)
2014-12-31 13:11:54 +01:00
Antony Riakiotakis f745564e4e GSOC 2013 paint
Yep, at last it's here!

There are a few minor issues remaining but development can go on in
master after discussion at blender institute.

For full list of features see:

http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.72/Painting

Thanks to Sergey and Campbell for the extensive review and to the
countless artists that have given their input and reported issues during
development.
2014-07-21 12:02:05 +02:00
Campbell Barton d3309ac5c9 Code cleanup: correct arg size 2014-03-29 08:42:59 +11:00
Antony Riakiotakis 43bd8c2b28 Undo the front-facing only commit for clay strips brushes, it adds an
attenuation that should really be optional. There's also a minor
performance penalty and all this only for one problematic case. In case
the tool flattens two surfaces, users can manually set the front face
only option. A better non-attenuating way to cull such vertices can be
added later.

Also flatten brush should calculate the flatten plane from the original
vertices or the flattening will not converge for planes offsets
different than zero.

Reported by Michalis Zissiou, thanks!
2013-09-16 02:24:41 +00:00
Antony Riakiotakis b1179c4752 Sculpting:
* Cleanup for previous commit and reduce some local variable referencing
* Add support for brushes that operate on frontfaces only and do not
show the option for those brushes. Currently only clay strips is in the
list but this may change according to artist feedback. This should take
care of the "sticky" surface problem completely.
2013-09-13 23:58:00 +00:00