Commit Graph

70 Commits

Author SHA1 Message Date
Antonio Vazquez 0174185e2f GPencil: New Simplify Tint option
This is useful to disable all layers tint in one step and it will be used for future operators.
2019-09-10 17:41:23 +02:00
Antonio Vazquez bbcb4be04f Fix T69597: Changing Grease Pencil Layer in Dopesheet unlocks all layers
The Dopesheet was unlocked all layers because it was using the same logic used in UI panel, but this was wrong.
2019-09-06 23:33:29 +02:00
Antonio Vazquez 1abb1ba9a3 GPencil: Fix unreported autolock layers using Dopesheet
When select a layer in Dopesheet, the autolock layer was not working.

Now the Dopesheet code calls the function for autolock. Also some code cleanup to move the logic to new function.
2019-09-03 18:59:12 +02:00
Antonio Vazquez 505340202e Fix T66452: Convert Curve to Grease Pencil Strokes
This commit adds support to convert curves to Grease Pencil strokes and create the materials too.

Also, there is a new python API. This API is required by the modified SVG import addon to create strokes( see T67065).

All curves selected in one operation are converted in the same Grease Pencil object.
2019-08-31 17:48:44 +02:00
Antonio Vazquez d5d3dc4189 GPencil: Use default material when slot material is empty
When a material slot is empty, the default material is used.

The default color used is Gray to get a good contrast in dense scenes with dark and white background.

Reviewers: brecht, dfelinto, mendio, pepeland

Differential Revision: https://developer.blender.org/D5625
2019-08-30 14:26:39 +02:00
Campbell Barton 6eadd40597 Cleanup: redundant struct declarations 2019-08-25 16:45:47 +10:00
Campbell Barton 67d9647ae4 Cleanup: use eval as a suffix
Follow conversion already used in most places.
2019-08-24 12:06:58 +10:00
Antonio Vazquez ee4ec69b28 Fix T66924 : Move GPencil Modifiers evaluation to Depsgraph
Before, the evaluation of modifers were done in draw manager. The reason of the old design was grease pencil was designed before depsgraph was in place.

This commit moves this logic to depsgraph to follow general design and reduce Draw Manager complexity. Also, this is required in order to use modifiers in Edit modes.

Really, there is nothing really new in the creation of derived data, only the logic has been moved to depsgraph, but the main logic is the same. In order to get a reference to the original stroke and points, a pointer is added to Runtime data as part of the evaluated data. These pointers allow to know and use the original data.

As the modifiers now are evaluated in Depsgraph, the evaluated stroke is usable in Edit modes, so now it's possible to work with the evaluated version instead to use a "ghost" of the final image over the original geometry as work today.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5470
2019-08-23 23:10:48 +02:00
Antonioya 179e886ab3 GPencil: New Simplify modifier mode Sample and operator
This mode simplify the stroke doing a resampling of the points and generate new geometry at the distance defined.

Sample function developed by @NicksBest

New Resample Stroke operator

This operator recreates the stroke geometry with a predefined length between points.

The operator uses the same code used in Simplify modifier.

Reviewers: @mendio
2019-08-08 16:43:54 +02:00
Antonioya b9d0f33530 Fix T67545: GPencil - New Merge by Distance operator
Merge points when the distance is less than a predefined value.

The method to interpolate the position created a wrong merge. Now, always the secondary point is merged with the first one (merge at first), except the last point.
2019-08-08 14:13:01 +02:00
Antonio Vazquez eb2a078f4d GPencil: New function to dissolve points in stroke
This function will be used for new operators.
2019-08-02 11:29:11 +02:00
Lukas Stockner a2f357edc2 Add operator for removing unused material slots
Reviewers: campbellbarton, brecht

Reviewed By: brecht

Subscribers: brecht

Differential Revision: https://developer.blender.org/D4991
2019-07-31 12:08:18 -07:00
Antonioya 789c6e94fb GPencil: Improve Cyclic operator to generate geometry
Now, when close a geometry with cyclic is possible generate new geometry for the gap.

The cyclic operator now supports multiframe edition too. Before only worked with active frame.

Also added the corresponding missing menu options and the new F keymap. All these features were missing, pending of the fix of the alpha glitches in stroke already done.
2019-06-30 21:06:10 +02:00
Antonioya d788f5231e Fix T65741: Removing a GPencil Object's Material Slot deletes the strokes assigned to it
This was a design decision, but now we have decided to change it using the active material for the strokes using deleted material.

If the material slot is empty a new material is created to keep the strokes visible.
2019-06-12 15:52:03 +02: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
Campbell Barton f55026d468 Cleanup: BKE_gpencil naming
- The ambiguous term 'handle' was used where 'ensure'
  is typically used (get or add when missing).
- Rename `current` to `active`, all `current` functions which were
  also ensuring.
- Clarify what is being operated on, using `BKE_gpencil_object_*` for
  objects, `BKE_gpencil_brush_*` for brushes.
2019-04-09 10:09:13 +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 8a125e3b55 Cleanup: remove unused for gpencil bounds calculation 2019-03-19 23:55:04 +11:00
Charlie Jolly 65de468396 GP: Draw: Stroke Trim
New edit mode operator and post-processing brush option.

Trim works on a single GP stroke. It removes trailing points before and after the first intersection (or loop) nearest to the start of the stroke.
2019-02-26 16:04:27 +00:00
Campbell Barton 085e9e3bed Cleanup: move variable declarations to headers
Quiet undeclared variable warning.
2019-02-23 12:59:13 +11: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 48a36ff9e9 Cleanup: manually apply changes missed last commit
Automatic edits failed for indented comment blocks,
removed indentation & adjusted.
2019-02-06 15:52:04 +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 4ef09cf937 Cleanup: remove author/date info from doxy headers 2019-02-02 11:58:24 +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 88a80fcec8 Cleanup: commas at the end of enums
Without this clang-format may wrap them onto a single line.
2019-01-16 00:03:03 +11:00
Antonioya bb9c9d0eaa GP: New Cutter, Constraints and Segment selection
This commit groups a set of new tools that were tested in grease pencil object branch before moving to master. We decide to do all the development in a separated branch because it could break master during days or weeks before the new tools were ready to deploy.

The commit includes:

- New Cutter tool to trim strokes and help cleaning up drawings.

- New set of constraints and guides to draw different types of shapes. All the credits for this development goes to Charlie Jolly (@charlie), thanks for your help!

- Segment selection mode to select strokes between intersections.

- New operator to change strokes cap mode.

- New option to display only keyframed frames. This option is very important when fill strokes with color.

- Multiple small fixes and tweaks.

Thanks to @pepeland and @mendio for their ideas, tests, reviews and support.

Note: Still pending the final icons for Cutter in Toolbar and Segment Selection in Topbar. @billreynish could help us here?
2019-01-11 19:21:56 +01:00
Antonioya 94dfa6eaac GP: Remove duplicate code moving to single function 2018-12-25 11:10:05 +01:00
Antonioya e63c947204 GP: Refactor drawing engine to single VBO
This is part of T57829.

Reduce the number of batches used to only one by shader type.  This reduces GPU overhead and increase a lot the FPS. As the number of batches is small, the time to allocate and free memory was reduced in 90% or more.

Also the code has been simplified and all batch management has been removed because this is not necessary. Now, all shading groups are created after all vertex buffer data for all strokes has been created using DRW_shgroup_call_range_add().

All batch cache data has been moved to the Object runtime struct and not as before where some parts (derived data) were saved inside GPD datablock.

For particles, now the code is faster and cleaner and gets better FPS.

Thanks to Clément Foucault for his help and advices to improve speed.
2018-11-20 20:05:37 +01:00
Campbell Barton 184ab749c3 Merge branch 'master' into blender2.8 2018-11-13 14:25:36 +11:00
Campbell Barton b323167600 GP: box/lasso support for select-operations
This adds support for more adbvanced select operations
matching 3D view select operators.

Also de-duplicate box/lasso select code.
2018-11-13 14:04:00 +11:00
Antonioya 39bc44ffc5 GP: Refactor Instance modifier and rename to Array
The old name Instance was logic when the modifier created new object instances, but now works equal to mesh Array modifier, so the old name was not logic and must be Array.

Also added a Object to use as offset similar to mesh Array modifier.
2018-10-28 18:20:50 +01:00
Antonioya 90e360c39f GP: Improve center object in viewport when press .
Before when press . (view_select) the object was centered at the dummy, but now it's centered with the strokes bounding box size.

Also fixed some problems in edit mode when the object origin was not in view origin.
2018-10-09 16:55:29 +02:00
Brecht Van Lommel 253dce07d7 Merge branch 'master' into blender2.8 2018-09-24 17:42:52 +02:00
Brecht Van Lommel 0cff044d84 Spelling fixes in comments and descriptions, patch by luzpaz.
Differential Revision: https://developer.blender.org/D3719
2018-09-24 17:28:40 +02:00
Antonioya 0845b1c8c8 GP: Improve Subdivide and Simplify
Now the weights are managed in the operators.

The subdivide operator and modifier code have been replaced with a shared function.

Some cleanup also.
2018-08-30 11:11:47 +02:00
Antonioya 9a9b1e9884 GP: Revert replace custom function by standard API
Using custom api breaks material at object level
2018-08-28 08:18:09 +02:00
Antonioya 9195b5b3b1 GP: Replace custom function by standard API
Replace BKE_gpencil_get_material_index by BKE_object_material_slot_find_index
2018-08-27 23:16:02 +02:00
Campbell Barton 21c75bc7c5 GP: replace custom API w/ BKE_deform API 2018-08-27 14:20:40 +10:00
Antonioya 1948681440 GP: Reduce weight paint data memory footprint
Before, the weight data array was created always, but now only is added when a weight value is assigned.

This change was suggested by algorithm, and both agreed it was good idea.
2018-08-26 16:40:06 +02:00
Dalai Felinto 613523d5f5 Rename: *_batch_cache_dirty > *_batch_cache_dirty_tag 2018-08-23 10:20:16 -03:00
Antonioya d9fc59c37c Cleanup: Remove unused param 2018-08-10 17:00:48 +02:00
Antonioya 5c4fd52612 Fix T56220: Adding Grease Object crashes if link Material is set to Object 2018-08-08 16:56:56 +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 6fc8a74886 Cleanup: trailing space for blenkernel 2018-06-17 17:05:51 +02:00
Bastien Montagne 67e8c1e1c7 Cleanup: remove more G.main from BKE area. 2018-06-13 10:57:10 +02: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
Antonio Vazquez e30d94bb3b Cleanup: rename paramenter to right name 2016-12-19 12:28:51 +01:00