Commit Graph

85 Commits

Author SHA1 Message Date
Alexander Gavrilov 64a584b38a Python API: add methods to allow copying of constraints.
Blender has an operator to do Copy & Paste of constraints between
objects and bones, but no simple method to do that directly via
the Python API is provided. This adds a copy() method to object
and pose bone constraint collections.

Differential Revision: https://developer.blender.org/D8112
2020-06-25 12:10:18 +03:00
Hans Goudey a24cd69d78 Cleanup: Remove unused BKE_constraint functions 2020-06-19 13:21:39 -04:00
Hans Goudey eaa44afe70 UI: Drag and Drop Constraints, Layout Updates
This patch implements the list panel system D7490 for constraints.
In this case the panels are still defined in Python.

The layouts are also updated to use subpanels and the a more organized
single column layout. There may be more tweaks necessary for the
layouts.

Reviewed By: Severin, billreynish, Mets

Differential Revision: https://developer.blender.org/D7499
2020-06-19 12:40:48 -04:00
Sybren A. Stüvel f881162f81 Revert "Constraints: remove special meaning of Local Space for parentless Objects."
This reverts commit 7728bfd4c4.

Although this brings back an inconsistency in the behaviour of
constraints on objects and bones, people were relying on the old
behaviour, and the new behaviour broke their files.

It is still desired to remove this inconsistency, but it will happen
more gradually.
2020-03-09 10:44:55 +01:00
Alexander Gavrilov 7728bfd4c4 Constraints: remove special meaning of Local Space for parentless Objects.
In 2011 special handling was introduced, apparently for no other
reason than to address a complaint in T25707 that World and Local
space are equivalent for objects without parent. This causes issues
and confusion, as mentioned in rB599c8a2c8e4.

This special meaning of Local Space is not documented in the manual,
and is not known to experienced riggers, so removing it should not
be a problem.

Differential Revision: https://developer.blender.org/D6095
2019-11-06 15:36:05 +03: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
Campbell Barton a1d73d03eb Cleanup: move comments above definitions
For clang-format not to wrap definitions.
2019-01-14 16:20:55 +11:00
Alexander Gavrilov 5c27c76ed3 Depsgraph: fix relations for drivers on bone weight in Armature constraint. 2018-11-14 14:01:40 +03:00
Alexander Gavrilov 798cdaeeb6 Implement an Armature constraint that mimics the modifier.
The main use one can imagine for this is adding tweak controls to
parts of a model that are already deformed by multiple other major
bones. It is natural to expect such locations to deform as if the
tweaks aren't there by default; however currently there is no easy
way to make a bone follow multiple other bones.

This adds a new constraint that implements the math behind the Armature
modifier, with support for explicit weights, bone envelopes, and dual
quaternion blending. It can also access bones from multiple armatures
at the same time (mainly because it's easier to code it that way.)

This also fixes dquat_to_mat4, which wasn't used anywhere before.

Differential Revision: https://developer.blender.org/D3664
2018-11-06 10:56:08 +03:00
Campbell Barton ae57383648 Cleanup: comment blocks 2018-09-02 18:28:27 +10: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
Dalai Felinto fbc65c6b28 Fix T55165: Driving camera lens with property behaves unexpectedly
Differential Revision: https://developer.blender.org/D3438
2018-05-25 12:48:33 +02:00
Bastien Montagne 43f9b6ba45 Tweak constraint copying code for static override needs.
No expected change in any existing behaviour from this commit.
2018-05-02 11:34:19 +02:00
Brecht Van Lommel 34ab90f546 Depsgraph: remove EvaluationContext, pass Depsgraph instead.
The depsgraph was always created within a fixed evaluation context. Passing
both risks the depsgraph and evaluation context not matching, and it
complicates the Python API where we'd have to expose both which is not so
easy to understand.

This also removes the global evaluation context in main, which assumed there
to be a single active scene and view layer.

Differential Revision: https://developer.blender.org/D3152
2018-04-16 19:55:33 +02:00
Campbell Barton 1b462e5a51 Pass EvaluationContext instead of bContext
2.8x branch added bContext arg in many places,
pass eval-context instead since its not simple to reason about what
what nested functions do when they can access and change almost anything.

Also use const to prevent unexpected modifications.

This fixes crash loading files with shadows,
since off-screen buffers use a NULL context for rendering.
2017-08-16 12:46:04 +10:00
Bastien Montagne 41830cc432 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 20:34:36 +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
Luca Rood 1c4c288727 Pass EvaluationContext argument everywhere
Note that some little parts of code have been dissabled because eval_ctx
was not available there. This should be resolved once DerivedMesh is
replaced.
2017-07-21 14:47:26 +02:00
Bastien Montagne 2a78635dea Cleanup: get rid of unused `BKE_constraints_relink()`.
Libquery/generic ID remapping code handles this now.
2016-11-21 15:25:33 +01:00
Campbell Barton 268524c025 Cleanup: use const for typeinfo 2015-03-30 21:18:49 +11:00
Sergey Sharybin 6405aa4e9c Fix access freed memory when doing constraints ID counter on main free
Basically just made constraints free function aware of possible do_id_users
argument, same as we've got for objects, object data and so on.
2015-03-06 15:22:25 +05:00
Campbell Barton 23214ecad0 Outliner: ContextMenus for constraints/modifiers
Context menu to toggle render, visibility & delete

D996 by @lichtwerk
2015-02-12 07:29:31 +11:00
Bastien Montagne 599c8a2c8e Fix T43204: Shrinkwrap constraint, project mode: Space ignored in bone case.
Own fault in rBb154aa8c060a60d to fix T42447... Reverted that commit, and added
kind of not-so-nice hack instead.

Note root of the issue comes from the special case we are doing here re 'Local'
space of parent-less objects. In that case, local space should be the same as
world one, but instead we apply the object rotation to it... This is inconsistent
with all other cases and could very well lead to other issues as T42447, but afraid
fixing that properly would be rather hairy - not to mention it would likely break
all existing riggings etc. :(

Should be safe for a 2.73a, shall we need it.
2015-01-11 14:59:11 +01:00
Campbell Barton 3216e4b202 API Cleanup: Use BKE_constraint prefix for constraint api 2014-04-11 11:47:07 +10:00
Campbell Barton a15b3c4d11 Code cleanup: use bool 2014-04-11 11:33:29 +10:00
Campbell Barton 617557b08e Code cleanup: remove TRUE/FALSE & WITH_BOOL_COMPAT define 2014-04-01 15:22:28 +11:00
Bastien Montagne ba14beb000 Code cleanup: add usual 'BKE_' prefix to 'public' constraint functions from blenkernel... 2012-12-23 11:31:15 +00:00
Campbell Barton 7c699a217a define the size of matrix args for both rows/cols. 2012-12-11 14:29:01 +00:00
Campbell Barton 9892736206 code cleanup: header cleanup and remove some duplicate defines. 2012-05-12 20:39:39 +00:00
Joshua Leung 7c58e6a9f2 Simplifying constraints code - removed relink_data() callbacks in favour of a
more generic system which goes through id_looper(), reducing the maintainance
burden for new constraint authors
2012-05-06 01:27:48 +00:00
Joshua Leung ff4ff9c8a4 Bugfixes for various ID-block references (Constraints, NLA)
* ID-blocks referenced by Constraints but not being used as the target objects
(such as Actions in the Action Constraint, or Text Blocks in PyConstraints) now
get usercounts for being referenced in this way. This should fix ancient bugs
such as [#19205] and [#8593]. More tests still needed to verify that this
does now play nicely with proxies.

* Changing actions used by NLA strips should now update the usercounts
accordingly
2012-05-05 15:54:08 +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
Joshua Leung db72192c22 Bye bye vile relics of extinct version control systems,
Causing a flurry of refresh file prompts post-commit,
Confusing local diffs and causing merge conflicts,
Stating the obvious; redundant and useless...

We shall not miss thou, blasted expand $keywords$
2011-08-12 07:20:49 +00:00
Joshua Leung 1788bc298c = Limit Distance Constraint - 'For Transform' Option =
The Limit Distance Constraint now has a "For Transform" option just
like all the other Limit constraints. This option controls whether the
constraint gets applied to interactive transforms in the 3D View too,
preventing controllers from getting large values without the animator
knowing.


Additional code changes:
* Split code to get constraint targets and grab their matrices for
solving out to a separate helper function:
get_constraint_targets_for_solving()
* Fixed a bug where "found constraint ...." prints would appear in the
console. Looks like some warning print that was forgotten

TODO:
* While coding this, I noticed potential division by zero bugs with
the Limit Distance constraint. Looking into these after this commit.
2011-05-24 12:12:12 +00:00
Nathan Letwory 22638e22ea doxygen: blenkernel under core as module. 2011-02-18 13:05:18 +00:00
Campbell Barton adae794233 py/rna remove functions now all work in a similar way.
- some remove() functions took an int argument rather then the item to remove.
- disallow None argument.
- raise an error if the item isnt in the collection.
2010-08-24 06:40:28 +00:00
Campbell Barton 610c4befd4 option to copy constraints without making their ID references direct links.
needed because proxies are causing libs to be linked directly when they should be kept indirect (likely slowing load times though I didnt time this)
2010-04-29 15:31:53 +00:00
Matt Ebb f85fe4d633 Pass constraint names as operator properties in constraint operators
This is similar to commit revision 22078, but for constraint operators rather 
than modifiers, making it possible to use them from scripting.
2010-04-26 03:42:38 +00:00
Joshua Leung f3b9ea066e Bugfix #21245: "Track to" (Ctrl + T) operator was missing notifier updates
Bugfix #21255: Clear track operator did not remove TrackTo constraints too. This could still be made to do Locked Track and other tracking constraints later too, but for now this will do.
2010-02-21 11:05:52 +00:00
Campbell Barton 081c1205a3 correct fsf address 2010-02-12 13:34:04 +00:00
Joshua Leung ae22d97c45 Constraints API: ID-Loopers
Added a system for running a callback on all the ID-blocks referenced by constraints (like for modifiers). Also, added an API function which calls these on the constraints present in the given list.

These could be used for:
- the proxies + action/pyconstraint fix that campbell committed
- simplification of file loading code
2010-02-06 11:28:22 +00:00