Commit Graph

89 Commits

Author SHA1 Message Date
Alexander Gavrilov 58dae919e5 Weight Paint: avoid creating very small values with locked weights.
When painting using Auto-Normalize or Lock Relative with some
groups locked, the locked weights may not add up precisely to
1 because of precision limitations, which results in creating
nonzero weights close to FLT_EPSILON. With Lock Relative display
mode this is very obvious and annoying (random red points amid
black or blue), so add an epsilon check to consider less than
1e-6 unlocked weight to be the same as 0.

In addition, in cases when no weight can be painted due to locks,
don't create vertex group entries at all if they don't exist yet.
Also, don't run Auto Normalize when not painting a deform group.

Differential Revision: https://developer.blender.org/D10000
2021-01-12 14:32:05 +03:00
Campbell Barton 38a66903e5 Cleanup: sort struct declarations 2020-09-30 11:51:13 +10:00
Sebastian Parborg 2115232a16 Cleanup: Clang-Tidy readability-inconsistent-declaration-parameter-name fix
No functional changes
2020-09-04 21:04:16 +02:00
Jacques Lucke 3dc222ea7b Refactor: move defvert .blend IO to blenkernel
This is part of T76372.
2020-08-28 14:30:45 +02:00
Jacques Lucke 91694b9b58 Code Style: use "#pragma once" in source directory
This replaces header include guards with `#pragma once`.
A couple of include guards are not removed yet (e.g. `__RNA_TYPES_H__`),
because they are used in other places.

This patch has been generated by P1561 followed by `make format`.

Differential Revision: https://developer.blender.org/D8466
2020-08-07 09:50:34 +02:00
Jacques Lucke 725973485a Clang Tidy: enable readability-non-const-parameter warning
Clang Tidy reported a couple of false positives. I disabled
those `NOLINTNEXTLINE`.

Differential Revision: https://developer.blender.org/D8199
2020-07-13 11:27:09 +02:00
Brecht Van Lommel 3e4f49fe71 Revert "Fix T78296: Performance - Use Binary Search for MDeformWeight"
This reverts commit 39b525e0f0 and
3121015dce as tests are failing.
2020-07-10 18:03:21 +02:00
Jeroen Bakker 39b525e0f0 Fix T78296: Performance - Use Binary Search for MDeformWeight
Use binary search for querying deform weights.

Spring 02_020_A.anim.blend on Ryzen 1700X goes from 12.4 to 12.7fps.

During profiling it was detected that adding new items to the head was faster than adding to the tail.

Reviewed By: Campbell Barton

Differential Revision: https://developer.blender.org/D8127
2020-07-10 12:09:40 +02:00
Campbell Barton 827959ff98 Cleanup: use const arguments to deform functions
This changes curve deform code not to set the objects inverse matrix,
this shouldn't cause problems as it's not used elsewhere afterwards.
2020-06-13 16:20:09 +10:00
Alexander Gavrilov 084bf7daee Weight Paint: Implement a new Lock-Relative mode.
This check box alters how weights are displayed and painted,
similar to Multi Paint, but in a different way. Specifically,
weights are presented as if all locked vertex groups were
deleted, and the remaining deform groups normalized.

The new feature is intended for use when balancing weights within
a group of bones while all others are locked. Enabling the option
presents weight as if the locked bones didn't exist, and their
weight was proportionally redistributed to the editable bones.

Conversely, the Multi-Paint feature allows balancing a group of
bones as a whole against all unselected bones, while ignoring
weight distribution within the selected group.

This mode also allows temporarily viewing non-normalized weights
as if they were normalized, without actually changing the values.

Differential Revision: https://developer.blender.org/D3837
2020-03-18 11:55:44 +03:00
Campbell Barton 54ab8c6abd Cleanup: rename 'verify' to 'ensure' for argument name 2020-03-06 13:00:01 +11:00
Campbell Barton bba4a09b2f Cleanup: use 'BKE_' prefix for BKE_deform API calls
- Use 'BKE_object_defgroup' prefix for object functions.

- Rename 'defvert_verify_index' to 'defvert_ensure_index'
  since this adds the group if it isn't found.
2020-03-06 12:56:44 +11:00
Campbell Barton ad2a8400e9 Fix T56108: Crash editing corrupted vertex groups
While the file in this report had corrupted values,
this is avoidable without adding any extra overhead.

Use unsigned vertex group indices since we don't need negative values,
this is an alternative to checking they aren't negative in many places.

Vertex group values over INT_MAX is still considered invalid,
so any accidental unsigned wrapping won't be silently ignored.
2020-02-11 13:20:49 +11:00
Jacques Lucke f3db5a0965 Cleanup: Improve usage of extern "C" 2020-02-07 17:22:11 +01:00
Campbell Barton aa42da0385 Cleanup: comments (long lines) in blenkernel 2019-04-27 12:07:07 +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
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 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
Bastien Montagne 5ba87cf22e Cleanup: remove another bunch of DM usages, includes etc. 2018-06-29 14:57:02 +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 e0303d0297 Cleanup/refactor: move BKE_deform_flip_side_name & co to BLI_string_utils
Functions like that do not have anything to do in BKE really, even less
when actually more used for bones than vgroups!
2017-01-16 20:36:23 +01:00
Bastien Montagne 7ce833af5b Cleanup/refactor: get rid of fixed name limit in BKE_deform_flip_side_name & co.
Those were forcing to use vgroup name define in bones area, or even
mixing with maxbonename... ugly, and totally avoidable.
2017-01-16 20:36:23 +01:00
Alexander Gavrilov c6afa36f47 Fix group flipping when syncing mirror weights
Corrects mirror syncing for invert, levels & smooth.

Note that the code changed to process mirroring even if both verts are selected,
since group flipping can mean that is still meaningful.
2016-02-09 00:19:28 +11:00
Campbell Barton 172143d4f8 Cleanup: use doxy comments for deform.c 2016-02-08 22:40:57 +11:00
Alexander Gavrilov b88b73816a Weight Paint: 'Sample' now supports multi-paint
Since the coloring uses sum or average of the weights of all selected
groups, the weight pick tool should also use that instead of reading
the weight of the single active group that you can't see.
2016-01-21 07:11:56 +11:00
Campbell Barton b1d758ae6b Cleanup: redundant struct declarations 2015-03-29 03:56:39 +11:00
Bastien Montagne ee4453f083 Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.

This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.

Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).

Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
  usable one in weightpaint mode (it transfers from selected object to active one,
  this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.

Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:32:44 +01:00
Campbell Barton e62cdbb474 code cleanup: rename flip_side_name to BKE_deform_flip_side_name 2013-11-17 05:23:05 +11:00
Irie Shinsuke 4be7427346 Weight Paint Tools: Add "Subset" option to "Normalize All"
This option is needed when vertex groups are used for both armature
deformation and the other purpose such as influence of mesh modifier.

Thanks to Campbell for code review!
2013-10-10 06:33:23 +00:00
Campbell Barton 70dc1d8cb6 stop adding groups from changing the active group with weight transfer, add BKE_defgroup_new function. 2013-07-04 03:56:18 +00:00
Gaia Clary 70fd2320c8 Added polished Vertex Weights Panel (properties sidebar) 2013-06-23 15:37:08 +00:00
Campbell Barton 65dcc6ad4f use bool arrays rather then char for weight paint lock/select arrays 2013-05-15 15:52:48 +00:00
Campbell Barton 8655be437d code cleanup: use bool where values are true/false, for view3d and related functions. 2013-03-20 23:14:18 +00:00
Campbell Barton b00c3b801b new weight paint draw option to display unweighted vertices with the option to check on the active group or all groups.
notes:
- vertices with zero weights are considered the same as vertices outside of a group.
- currently these show black but this can be made a theme color.
- multi-paint overrides this option (noted in description)
2013-02-22 04:09:04 +00:00
Campbell Barton 0ac2f6e7d7 fix for own bug - memory leak when cancelling weight gradient tool 2013-02-11 04:43:49 +00:00
Campbell Barton 7730ddb3d6 code cleanup:
- free_dverts -> BKE_defvert_array_free
- copy_dverts -> BKE_defvert_array_copy

also move the functions from BKE_mesh into BKE_deform
2012-12-28 09:06:48 +00:00
Campbell Barton e09a1bc7cf minor changes to select similar,
- replace ngon_fake_area() with generic call to BM_face_calc_area().
- add defvert_find_shared() utility function.
2012-10-30 11:40:36 +00:00
Campbell Barton 99fcec3334 fix [#29431] "Normalize All" from Weight Tools don't work correctly 2012-09-05 04:16:09 +00:00
Campbell Barton 9892736206 code cleanup: header cleanup and remove some duplicate defines. 2012-05-12 20:39:39 +00:00
Campbell Barton 112162e09e code cleanup: header cleanup 2012-04-30 14:24:11 +00:00
Campbell Barton 60c9addf79 - improve select grouped prefix/suffix from recent patch
- added select similar direction (Y axis)
2012-04-30 08:24:44 +00:00
Campbell Barton daae72e17b patch [#30834] Quick Hack: Select similar for bones in edit mode
from Felix Schlitter (dalai) 

made some changes to select length measurement.
2012-04-29 18:23:33 +00:00
Campbell Barton f87c5b3453 fix [#30715] bmesh: select linked not ignoring hidden verts/edges/faces
add optional flag to ignore hidden elements.
also remove loop mask flag - since it wasnt used and vert/edge/face is enough.
2012-03-29 13:09:07 +00:00
Brecht Van Lommel f18dab65ad Fix #30531: mirror modifier with vertex groups did not add both the left and
right groups to merged vertices, only one. This made the result asymmetric,
now merged vertices will be part of both groups with half weight.
2012-03-19 21:09:16 +00:00
Campbell Barton 2b7ca2304a unify include guard defines, __$FILENAME__
without the underscores these clogged up the namespace for autocompleation which was annoying.
2012-02-17 18:59:41 +00:00
Sergey Sharybin 51bada696f Longer names support for all ID and other object names
This commit extends limit of ID and objects to 64 (it means 63 meaning
characters and 1 for zero-terminator). CustomData layers names are also
extended.
Changed DNA structures and all places where length constants were hardcoded.

All names which are "generating" from ID block should be limited by MAX_ID_NAME-2,
all non-id names now has got own define called MAX_NAME which should be used all
over for non-id names to make further name migration stuff easier.

All name fields in DNA now have comment with constant which corresponds to
hardcoded numeric value which should make it easier to further update this
limits or even switch to non-hardcoded values in DNA.

Special thanks to Campbell who helped figuring out some issues and helped a lot
in finding all cases where hardcoded valued were still used in code.

Both of forwards and backwards compatibility is stored with blender versions newer
than January 5, 2011. Older versions had issue with placing null-terminator to
DNA strings on file load which will lead to some unpredictable behavior or even
crashes.
2012-01-11 08:51:06 +00:00
Campbell Barton 3d5330f789 vertex group changes,
use more api functions more (some vertex group editing functions were copied about), also make some functions int oapi calls.

- remove defgroup_find_index(), use BLI_findlink instead since they both work the same way.
- move static function getNearestPointOnPlane() to BLI_math api function closest_to_plane_v3()
- ED_vgroup_give_parray() added option to return an array where unselected verts are NULL (simplifies code & works for lattice when it didn't before).
- more consistant error checking of ob->actdef.
2011-12-14 21:08:08 +00:00