Commit Graph

99 Commits

Author SHA1 Message Date
Hans Goudey b1b153b88c Cleanup: Improve const correctness of shape key functions 2022-04-28 09:10:50 -05:00
Hans Goudey b0aaf6ff4a Fix T96294: Crash and error with shape key normal calculation
A mistake in the mesh normal refactor caused the wrong mesh to
be used when calculating normals with a shape key's deformation.

This commit fixes the normal calculation by using the correct mesh,
with just adjusted vertex positions, and calculating the results
directly into the result arrays when possible. This completely avoids
the need to make a local copy of the mesh, which makes sense,
since the only thing that changes is the vertex positions.

Differential Revision: https://developer.blender.org/D14317
2022-03-22 09:43:02 -05:00
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00
Campbell Barton 3d3bc74884 Cleanup: remove redundant const qualifiers for POD types
MSVC used to warn about const mismatch for arguments passed by value.
Remove these as newer versions of MSVC no longer show this warning.
2022-01-07 14:16:26 +11:00
Hans Goudey c0fb8ea8f3 Cleanup: Spelling/grammar in comments 2022-01-05 19:03:05 -06:00
Campbell Barton a37a6fb445 Cleanup: remove incorrect/unhelpful comments 2021-12-07 18:23:57 +11:00
Campbell Barton ffc4c126f5 Cleanup: move public doc-strings into headers for 'blenkernel'
- Added space below non doc-string comments to make it clear
  these aren't comments for the symbols directly below them.
- Use doxy sections for some headers.
- Minor improvements to doc-strings.

Ref T92709
2021-12-07 17:38:48 +11:00
Campbell Barton cea24b4b4a Cleanup: use "free_data" suffix when the argument isn't freed
Avoid API misuse that caused leaks in T90791 &
2788b0261c.
2021-08-20 16:37:50 +10:00
Campbell Barton 9b89de2571 Cleanup: consistent use of tags: NOTE/TODO/FIXME/XXX
Also use doxy style function reference `#` prefix chars when
referencing identifiers.
2021-07-04 00:43:40 +10:00
Campbell Barton 501d2443d0 Cleanup: use const arguments for accessor functions 2021-06-30 16:42:19 +10:00
Bastien Montagne 5f364216ac Cleanup/Refactor: Shapekey: Get rid of `BKE_key_copy_nolib()`
Once again, no behavioral change expected here.
2020-10-08 16:25:34 +02:00
Bastien Montagne 253dbe71dc Refactor: remove `BKE_<id_type>_copy` functions.
Those were only shallow wrappers around `BKE_id_copy`, barely used (even
fully unused in some cases), and we want to get rid of those ID-specific
helpers for the common ID management tasks. Also prevents weird custom
behaviors (like `BKE_object_copy`, who was the only basic ID copy
function to reset user count of the new copy to zero).

Part of 71219.
2020-10-07 18:05:06 +02: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 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
Campbell Barton 2308668bac Fix T72622: Transform object origin ignores shape keys
D8367 by @paul2t with edits.
2020-07-25 17:19:13 +10:00
Bastien Montagne 15c834ebbf Cleanup: ShapeKey: Move to IDTypeInfo and remove unused BKE API. 2020-03-06 12:52:52 +01:00
Campbell Barton 6eadd40597 Cleanup: redundant struct declarations 2019-08-25 16:45:47 +10:00
Campbell Barton 50fdbf3ec0 Cleanup: use const arguments for vertex coords 2019-08-21 11:58:41 +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
Dalai Felinto dbab52e4c0 Cleanup: Set BKE_key_from_object/_p to take const Object * 2019-03-01 11:44:19 -03: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 a42441d145 ShapeKey: add utils to say whether given ID type supports shapekeys.
Those kind of checks are handy to have for generic processing...
2019-01-25 17:46:09 +01:00
Alexander Gavrilov 1278890611 Put the Radius property of Curve points under shape key control.
Since shape keys are stored as raw floating point data, this
unfortunately requires changes to all code that works with it.

An additional complication is that bezier and nurbs control
points have different entry size, and can be mixed in the same
object (and hence shape key buffer).

Shape key entries are changed from:

  bezier: float v1[3], v2[3], v3[3], tilt, pad, pad;
  nurbs:  float vec[3], tilt;

To:

  bezier: float v1[3], v2[3], v3[3], tilt, radius, pad;
  nurbs:  float vec[3], tilt, radius, pad;

The official shape key element size is changed to 3 floats,
with 4 elements for  bezier nodes, and 2 for nurbs. This also
means that the element count is not equal to the vertex count
anymore.

While searching for all curve Shape Key code, I also found that
BKE_curve_transform_ex and BKE_curve_translate were broken. This
can be seen by trying to change the Origin of a Curve with keys.

Reviewers: campbellbarton, sergey

Differential Revision: https://developer.blender.org/D3676
2018-09-20 11:52:42 +03:00
Campbell Barton c13644c390 Cleanup: make shapekey functions local
Were only exposed for the BGE.
2018-09-12 17:27:22 +10:00
Bastien Montagne 31d916210c Cleanup: remove DM from 'join as shape' operator.
Also deduplicated the 'mesh as shapekey' code, we had kind of two funcs
doing the same thing here...
2018-06-21 18:26:12 +02:00
Bastien Montagne be57cf9b2a Cleanup: remove moar G.main from BKE area. 2018-06-12 12:53:27 +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
Bastien Montagne e10ddc7a91 Get rid of BKE_key_make_local().
This function was only a wrapper around id_clear_lib_data(), and shapekeys
are not linkable nor shareable anyway, no point keeping this currently,
was only adding confusion about shapekey 'status' as a datatblock.
2016-07-14 18:33:12 +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 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
Bastien Montagne ae2033aca2 Add BKE_key_copy_ex() that takes a Main as parameter. 2016-07-09 15:44:12 +02:00
Bastien Montagne 9044ccec5f Cleanup to shapekeys' make_local (and copy) functions.
Mostly pass bmain and do not check for NULL key, keys' make_local is
suspiciously simple in fact, but think until those behave like real
full-featured IDs, it's doing enough!
2016-07-09 15:44:12 +02:00
Bastien Montagne cdd727b7ce Add functions to compute normals (verts, polys and loops ones) for a given shapekey.
Title says pretty much everything, we now have BKE and RNA funcs to get vertex, poly and
loop normals of a given shapekey.

This will be used e.g. in FBX exporter (shapekeys need normal data too).

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D1510
2015-10-12 20:12:55 +02:00
Campbell Barton 1d9de55949 BKE_key: add BKE_key_from_id helper functions 2015-10-08 18:19:28 +11:00
Campbell Barton 87629b2a74 RNA: Object.shape_key_remove method
Python had no ability to remove shape keys
Original D1169 from @lichtwerk, with edits
2015-06-08 19:52:04 +10:00
Campbell Barton b1d758ae6b Cleanup: redundant struct declarations 2015-03-29 03:56:39 +11:00
Campbell Barton 8e73b770d4 Remove slurph shape-key feature
This is an old option which wasn't working in over a year without complaint.
2015-01-07 02:06:37 +11:00
Bastien Montagne b7f5ab0cd3 ShapeKeys: Add `BKE_keyblock_is_basis` to check whether a given keyblock is used a basis by others.
Also fix stupid debug-only error in previous commit.
2014-11-17 11:19:54 +01:00
Bastien Montagne d526ef607d Cleanup: rename `BKE_key_convert/update` to `BKE_keyblock_convert/update`.
We are handling a keyblock here, not a whole key(set). Names are alreay a bit confusing,
let's be consistent at least.
2014-11-17 11:19:54 +01:00
Bastien Montagne a52fbfa828 ShapeKey: Refactor a bit `BKE_key_convert_from_...`
Thing is, those functions always reallocate the whole keyblock's data mem,
while in some cases we already have right amount of elements, so we can just
copy over. Further more, `BKE_key_convert_from_offset`, despite its name,
was not making any check nor allocation on keyblock's data elements!

So split 'copy' operation itself in `BKE_key_update_from_...`,
where no mem checks/operations are performed (only an assert).

Only useful in sculpt mode currently, but will be used by fix for T35170 too.
2014-11-17 11:19:54 +01:00
Bastien Montagne 00ff9da2ee ShapeKeys: rework 'move skey' code, and add options to move to first/last position.
Main moving logic is moved to new `BKE_keyblock_move()`, which makes it available from anywhere.
In addition, move code was reworked so that it only loops once on whole keyblocks list,
and it accepts arbitrary org and dest indices, not only neighbor ones.

Partly based on work by revzin (Grigory Revzin) in his soc-2014-shapekey GSoC branch, thanks!
2014-10-21 12:07:24 +02:00
Campbell Barton d900f5be55 Code cleanup: use bools where possible 2014-02-03 19:35:44 +11:00
Sergey Sharybin 9f7961b6b1 Optimization and threading fix for shapekeys weights calculation
This commit fixes two different issues, which were caused by
how weights are being calculated for relative shapekeys.

Weights for key block used to saved in KeyBlock DNA structure,
which lead to situations when different objects could start
writing to the same weights array if they're sharing the same
key datablock.

Solved this in a way so weights are never stored in KeyBlock
and being passed to shapekeys routines as an array of pointers.
This way weights are still computed run-time (meaning they're
calculated before shapekey evaluation and freed afterwards).

This required some changes to GameEngine as well, to make it
never cache weights in the key blocks.

Another aspect of this commit makes it so weight for a given
vertex group is only computed once. So if multiple key blocks
are using the same influence vertex group, they'll share the
same exact weights array. This gave around 1.7x speedup in
test chinchilla file which is close enough to if we've been
caching weights permanently in DNA (test machine is dual-code
4 threads laptop, speedup measured in depsgraph_mt branch,
trunk might be not so much high speedup).

Some further speed is optimization possible, but it could be
done later as well.

Thanks Brecht for idea of how the things might be solved in
really clear way.

--
svn merge -r58786:58787  ^/branches/soc-2013-depsgraph_mt
2013-08-19 10:36:39 +00:00
Campbell Barton f4609acedc optimization: avoid memcpy with shake key vertex array. 2013-07-19 10:40:20 +00:00
Campbell Barton d8d24bdebd fix [#33682] Animation not updated when the active shape index isnt set 2013-01-03 06:47:44 +00:00