Commit Graph

137 Commits

Author SHA1 Message Date
Sybren A. Stüvel f9aa6376f1 Cleanup: anim, remove `const` declarations from pass-by-value params
Remove `const` from pass-by-value parameters in function declarations.
The variables passed as parameters can never be modified by the function
anyway, so declaring them as `const` is meaningless. Having the
declaration there could confuse, especially as it suggests it does have
a meaning, training people to write meaningless code.
2022-01-06 11:41:03 +01:00
Philipp Oeser d13970de86 Fix T92930: Outliner "Show Active" bone fails in certain situations
Outliner would frame the armature object instead of the bone if the bone
was on a hidden armature layer.

Similar to issues reported in e.g. T58068 and T80464, this is due to the
fact that `BKE_pose_channel_active` always checks for the armature layer
(and returns NULL if a bone is not on a visible armature layer).

Now propose to make this layer check **optional** (and e.g. from the
Outliner be more permissive). This also introduces
`BKE_pose_channel_active_if_layer_visible` which just wraps
`BKE_pose_channel_active` with the check being ON.

Maniphest Tasks: T92930

Differential Revision: https://developer.blender.org/D13154
2021-12-21 14:07:48 +01: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
Alexander Gavrilov 72acce43bc Animation: allow marking actions as cyclic for Cycle-Aware Keying.
When a manual frame range is set, allow marking an action as having
Cyclic Animation. This does not affect how the action is evaluated,
but the Cycle-Aware Keying option will automatically make any newly
added F-Curves cyclic. This allows using the option from the start
to build the cycle, rather than only for tweaking an existing loop.

The curves are made cyclic when they have only one key, either
after inserting the first key, or before adding the second one.
The latter case avoids the need to manually make the first added
curve cyclic after marking a newly added action cyclic.

Differential Revision: https://developer.blender.org/D11803
2021-11-24 15:58:32 +03:00
Alexander Gavrilov 5d59b38605 Animation: allow manually setting the intended playback range for actions.
Some operations, e.g. adding a new action strip to NLA, require
knowing the active frame range of an action. However, currently it
can only be deduced by scanning the keyframes of the curves within
it. This is not ideal if e.g. curves are staggered for overlap.

As suggested by Nathan Vegdahl in comments to T54724, this patch adds
Action properties that allow manually specifying its active frame range.
The settings are exposed via a panel in the Dopesheet and Action Editor.
When enabled, the range is highlighted in the background using a striped
fill to distinguish it from the solid filled regular playback range.

When set, the frame range is used when adding or updating NLA tracks,
and by add-ons using `Action.frame_range`, e.g. FBX exporter.

Differential Revision: https://developer.blender.org/D11803
2021-11-24 15:58:32 +03:00
Campbell Barton 1143bf281a Cleanup: spelling in comments, comment block formatting 2021-11-13 13:07:13 +11:00
Sybren A. Stüvel b4cfe80547 Assets: Store Action sub-type in asset metadata
Blender 3.0 will only support single-frame Actions in the pose library.
The goal of this patch is to lay the groundwork for making it possible
for the Asset Browser to reject/hide "animation snippet" Action assets.

Determining whether an Action has one or more frames (i.e. whether it
has a single pose or animation) requires inspecting the Action itself,
and thus loading the data-block itself. This would make it impossible to
quickly determine from the asset browser.

To solve this, the Action is inspected before saving, and a
`"is_single_frame"` boolean (well, 0/1 integer) IDProperty is added.

Reviewed by: Severin

Differential Revision: https://developer.blender.org/D13202
2021-11-12 14:36:22 +01:00
Campbell Barton 4b9ff3cd42 Cleanup: comment blocks, trailing space in comments 2021-06-24 15:59:34 +10:00
Campbell Barton c51720a6ad Cleanup: rename BKE_pose_channel_{verify => ensure}
The term `verify` doesn't fit with what this function does
and is sometimes used to check data is valid or to control validity
checking as with `RNA_define_verify_sdna`.
use more common term `ensure`.
2021-04-30 15:30:41 +10:00
Campbell Barton af3eda8185 Cleanup: rename BKE_pose_channels_hash_{make => ensure}
Use the term `ensure` since it makes it clear the data is
not manipulated if it already exists.
2021-04-30 15:28:13 +10:00
Sybren A. Stüvel fd10c21f51 Cleanup: animation, remove `BONE_UNKEYED` flag
Remove the `BONE_UNKEYED` flag. It was only written (set/cleared) but
never actually read.

Also remove `framechange_poses_clear_unkeyed()` as its only function was
to clear the `BONE_UNKEYED` flag. It wasn't used anywhere either.

The only code that used the flag was the `extract_pose_from_action()`,
which was removed in 2869ce6cfa (2009).

No functional changes.
2021-03-30 09:46:26 +02:00
Campbell Barton e18091650b Animation: action mirror RNA API using pose contents
This adds a new RNA method `Action.flip_with_pose(ob)` to flip the
action channels that control a pose.
The rest-pose is used to properly flip the bones transformation.

This is useful as a way to flip actions used in pose libraries,
so the same action need not be included for each side.

Reviewed By: sybren

Ref D10781
2021-03-26 13:37:40 +11:00
Campbell Barton a869a61c88 Cleanup: sort struct blocks 2020-12-16 16:26:23 +11:00
Jacques Lucke 2acf01ec62 Refactor: move Pose .blend I/O to blenkernel
Ref T76372.
2020-11-06 17:58:25 +01: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
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
Sergey Sharybin 52c2f296bc Pose channel: Add session UUID
Allows to identify pose channels more reliably than by the pointer.
2020-08-04 11:40:09 +02:00
Hans Goudey d42530824e Fix T78994: Clear selected pose doesn't work without animation
It looks like the code left this as a todo, but the basic solution is to
add an extra parameter to BKE_bose_rest to check whether bones
are selected before reseting them.

I also corrected the operator description which said it acted on only
selected bones even when there is an option to turn that off. The
"act on selected" is generally implied for Blender's operators anyway.

Differential Revision: https://developer.blender.org/D8319
2020-07-21 09:51:27 -04:00
Sybren A. Stüvel 686ab4c940 T77086 Animation: Passing Dependency Graph to Drivers
Custom driver functions need access to the dependency graph that is
triggering the evaluation of the driver. This patch passes the
dependency graph pointer through all the animation-related calls.

Instead of passing the evaluation time to functions, the code now passes
an `AnimationEvalContext` pointer:

```
typedef struct AnimationEvalContext {
  struct Depsgraph *const depsgraph;
  const float eval_time;
} AnimationEvalContext;
```

These structs are read-only, meaning that the code cannot change the
evaluation time. Note that the `depsgraph` pointer itself is const, but
it points to a non-const depsgraph.

FCurves and Drivers can be evaluated at a different time than the
current scene time, for example when evaluating NLA strips. This means
that, even though the current time is stored in the dependency graph, we
need an explicit evaluation time.

There are two functions that allow creation of `AnimationEvalContext`
objects:

- `BKE_animsys_eval_context_construct(Depsgraph *depsgraph, float
  eval_time)`, which creates a new context object from scratch, and
- `BKE_animsys_eval_context_construct_at(AnimationEvalContext
  *anim_eval_context, float eval_time)`, which can be used to create a
  `AnimationEvalContext` with the same depsgraph, but at a different
  time. This makes it possible to later add fields without changing any
  of the code that just want to change the eval time.

This also provides a fix for T75553, although it does require a change
to the custom driver function. The driver should call
`custom_function(depsgraph)`, and the function should use that depsgraph
instead of information from `bpy.context`.

Reviewed By: brecht, sergey

Differential Revision: https://developer.blender.org/D8047
2020-07-20 11:51:09 +02:00
Jacques Lucke 6f985574b7 Cleanup: take includes out of 'extern "C"' blocks
Surrounding includes with an 'extern "C"' block is not necessary anymore.
Also that made it harder to add any C++ code to some headers, or include headers
that have "optional" C++ code like `MEM_guardedalloc.h`.

I tested compilation on linux and windows (and got help from @LazyDodo).
If this still breaks compilation due to some linker error, the header containing
the symbol in question is probably missing an 'extern "C"' block.

Differential Revision: https://developer.blender.org/D7653
2020-05-08 18:22:41 +02:00
Dalai Felinto 68b6d0302a Cleanup: Action: Move to IDTypeInfo, and remove unused BKE API. 2020-03-06 16:43:09 +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
Sybren A. Stüvel 7830ea29c2 Fix T68665: FCurve group disappear on Curve/Surface object data
When going from EDIT to OBJECT mode, Blender updates the object data from
the edit-mode data. This took care of renaming FCurves that animate Curve
control points when control points are added/removed, but this didn't keep
the FCurve groups intact. Since the FCurve groups are tightly connected to
the Action channels, it's hard to keep the group pointers intact during
this process. Instead of making the code even more complex in an attempt to
do that, I implemented a function (`BKE_action_groups_reconstruct()`) that
rebuilds the group channel pointers.

The call to `action_groups_add_channel()` had to be removed because it
updates the the next/prev pointers of the FCurve while we're looping over
them, causing infinite loops.
2019-12-17 15:22:29 +01:00
Sergey Sharybin fc2b966fc7 Refactor: Add C++ guard code to headers
C++ is used more and more, and it is becoming more and more annoying to
keep track of whether header have C++ guard or not.

Is easier and more clear to be consistent in all headers and have such
guards in all headers.
2019-11-29 14:39:54 +01:00
Sergey Sharybin e7367c607e Cleanup: Fix naming of a function 2019-10-14 10:45:35 +02:00
Campbell Barton 9e60e86057 Cleanup: clang-format 2019-09-13 21:12:43 +10:00
Campbell Barton c6c9e168e2 Fix T58447: Unselected bone used for constraint target 2019-07-18 19:12:09 +10:00
Alexander Gavrilov 7ec6bca92f Fix T63332: backup and restore bPoseChannel_Runtime data during COW. 2019-04-18 21:32:17 +03: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
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
Alexander Gavrilov 1e820898ff Depsgraph: add a new operation node for computing B-Bone segments.
Computing the shape of a B-Bone is a quite expensive operation, and
there are multiple constraints that can access this information in
a variety of useful ways. This means computing the shape once per
bone and saving it is good for performance.

Since the shape may depend on the position of up to two other bones,
often in a "cyclic" manner, this computation has to be a separate
node with its own dependencies.

Reviewers: sergey

Differential Revision: https://developer.blender.org/D3975
2018-11-23 23:19:23 +03:00
Campbell Barton 55e719ec35 Merge branch 'master' into blender2.8 2018-11-14 17:21:34 +11:00
Campbell Barton d7f55c4ff5 Cleanup: comment block tabs 2018-11-14 17:10:56 +11: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
Sergey Sharybin bb7b1cc884 Fix T56170: Fake dependency cycle in new depsgraph + interleaved armature update + proxy
Make proxy copy result more atomic operation.
2018-07-31 13:24:57 +02:00
Campbell Barton 18d87e79e9 Merge branch 'master' into blender2.8 2018-06-29 09:25:40 +02:00
Campbell Barton b372766816 Cleanup: trailing newlines 2018-06-29 09:23:51 +02:00
Campbell Barton 06a1a66a9b Merge branch 'master' into blender2.8 2018-06-17 17:10:19 +02:00
Campbell Barton 6fc8a74886 Cleanup: trailing space for blenkernel 2018-06-17 17:05:51 +02:00
Sergey Sharybin 554fb0e7e0 Merge branch 'master' into blender2.8 2018-05-04 15:21:42 +02:00
Sergey Sharybin aa0380a6a5 Cleanup: Remove G.main from framechange_poses_clear_unkeyed() 2018-05-04 15:18:47 +02:00
Joshua Leung 6e67d8e3bb Cleanup: Move FOREACH_PCHAN_*_IN_OBJECT_*() macros to BKE_armature.h
This reduces the number of headers we need to import (and/or dependencies
on the order of them), as these depend on PBONE_VISIBLE(), which is already
in BKE_armature.h
2018-04-30 18:46:52 +02:00
Campbell Barton 602f0bc2d4 Use macros for looping over pose bones 2018-04-18 18:56:27 +02:00
Dalai Felinto 159806140f Removing Blender Game Engine from Blender 2.8
Folders removed entirely:
* //extern/recastnavigation
* //intern/decklink
* //intern/moto
* //source/blender/editors/space_logic
* //source/blenderplayer
* //source/gameengine

This includes DNA data and any reference to the BGE code in Blender itself.
We are bumping the subversion.

Pending tasks:
* Tile/clamp code in image editor draw code.
* Viewport drawing code (so much of this will go away because of BI removal
  that we can wait until then to remove this.
2018-04-17 17:51:28 +02:00