Commit Graph

584 Commits

Author SHA1 Message Date
35bc7079e3 Whitespace commit in constraints code. 2007-08-14 11:16:11 +00:00
c4114780d4 Little code cleanup.
bsystem_time was being called with an extra variable, which was useless. Most of the places that called it, were passing NULL for that variable anyway.

I've also cleaned up that function a bit, but the underlying problems with that part of the code still exist (EVIL GLOBALS that are exported for frame_to_float), for mblur and fields rendering features. That remains for another time.
2007-08-05 09:21:29 +00:00
655fb548aa Removing some useless code, and fixed a few compiler warnings. 2007-07-30 11:10:30 +00:00
6dcde0b5be More Constraints Bugfixes:
* Transform Constraint should now work in more cases. Somehow the old code (for location case) wasn't working correctly.
* ChildOf Constraint applied on objects, should now get the right 'inverse'/'offset' matrix set. It now uses the same code that is used by Blender's parenting method to do so.
2007-07-29 11:15:37 +00:00
e765fbf126 == Constraints - Important Bugfix ==
At last, the 'Local' option for Armatures works properly! 
Tonight I went through carefully and cross-checked the code once again, and found several bad mistakes I had made. These were:
* the value of one variable from the armatures code was not what I expected it to be, based off the name). 
* Mat4MulSerie swaps the first two args! Grrr...

Note: 
There's only one rig that I've tested that was broken. That was slikdigit's "mancandy", and the part in question was the jaw. It is likely that a few more rigs out there (in particular, their 'local' action constraints) relied on the wacky rotation values that used to be used, so are now broken.
2007-07-28 10:44:03 +00:00
f8544eefad A few little code cleanups for constraints code. I've just removed some lines that weren't needed. 2007-07-28 09:00:15 +00:00
65f4cb14c1 == Constraints - Important Bugfix ==
I've finally fixed the bug with the Constraint Space Conversion. It was a single matrix multiplication in the wrong order (for local->pose). 

Also, there is more code added for the space conversion process when bones have 'hinge' on. (NOTE: this stuff for hinge bones may still not work really nice yet)
2007-07-24 05:08:55 +00:00
Ken Hughes
e7ad09f8b5 Removing what appears to be useless code which causes gcc warnings. Appears
to be a cut-n-paste error: Joshua, please double-check.
2007-07-23 20:38:04 +00:00
939500392e == Constraints - Bugfixes ==
Here are some attempts at fixing bugs being encountered with the constraint system after the recode. I've just fixed a few typos (where relevant), and added some extra checks for things.
2007-07-23 11:28:43 +00:00
74ca178199 == Transformation Constraint ==
This commit adds a new constraint to Blender: the Transformation Constraint. This constraint gives you more freedom to choose how transforms are copied from one object/bone to another object/bone. 

You can assign the Loc/Rot/Scale channels of a source to the Loc/Rot/Scale channels of a destination, specifying the range of motion (per axis) from the source to consider, and the range of motion (per axis) that will be applied to the destination. Also, for each destination axis, you can choose which of the source axes to copy from. 

A similar constraint was coded by Jason Blary (snark), as Patch #4991. This constraint is basically rewritten from scratch, although there are some elements of the original patch which may be borrowed in future.

Various notes:
* PyAPI access has been coded. 
* Space conversion is also enabled for this constraint.
* Also the useless get_constraint_col function has been removed
* Doing a rotation copy with a ratio that is not 1:1 doesn't always work correctly yet (like for the Copy Rotation constraint).
2007-07-21 07:26:15 +00:00
38c84ba938 A few minor changes:
* Removed obsolete comments from constraints code
* ChildOf constraint buttons: Set/Clear Inverse are now Set/Clear Offset. Hopefully that makes it a bit clearer for users.
2007-07-15 07:05:24 +00:00
af55d208f4 == Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.

=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.

=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme. 
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.

=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already. 
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
4f01085709 =ID Property update=
ID Properties weren't being duplicated (by shift-D or any of the other
duplication functions).  So now ID properties are duplicated in the 
main copy_libblock function, which (as far as I can check) covers all
ID-contained ID properties.

I also updated the constraint system to copy pyconstraint ID properties
on shift-D.

This would probably be a good thing to add to the stable branch, btw.
2007-07-09 20:42:14 +00:00
2929e8f65a == Constraints/Arithb Code ==
* Formatting 'fixes' for more consistency with rest of code
* Moved Mat4BlendMat4 from constraint.c to arithb.c/h
2007-07-03 00:58:38 +00:00
0616766f87 == Constraints - Code Cleanup ==
Simplified the code in two functions where checking for targets/subtargets could really have been done using Constraint API methods (constraint_has_target, get_constraint_target).
2007-06-20 07:11:31 +00:00
01e8789f3f == PyConstraints ==
At last! The ability to code constraints in Python. This opens up many interesting rigging possibilities, as well as making prototyping constraints easier.

* A PyConstraint script must begin with the line 
#BPYCONSTRAINT
* It must also define a doConstraint function, which performs the core actions of the constraint.
* PyConstraints use IDProperties to store custom properties for each PyConstraint instance. The scripter can choose which of these ID-Properties to expose to a user to control the behaviour of the constraint. This must be done using the Draw.PupBlock method.

Credits to Joe Eager (joeedh) for coding the original patch on which this is based. I've made heavy revisions to large parts of the patch.

For more detailed information, and some demo scripts, see the following page:
http://aligorith.googlepages.com/pyconstraints2
2007-06-18 07:41:21 +00:00
3c469b88f5 == Constraints Code ==
Relatively harmless removal of useless code. Also formatted things in a few places.
2007-05-17 06:45:16 +00:00
1b789314b6 Bugfix #6547
Constraint "limit location" was using type "No parent" without checking
a pointer for NULL, causing crashes on append.
2007-04-11 12:44:03 +00:00
655f9a61de == Clamp-To Constraint (was Patch #4818) ==
This (new) constraint limits the location of an object/bone to the range of locations
on a given curve. It works by comparing the location of the owner on one axis, to
the extents of the curve's bounding-box on the same axis, to find the location on
the curve.

Usage Notes:
* 'Ob:' field must point to a valid curve object
* This curve should have 'Path' turned on in order for this constraint to work. You
don't really need to do this as it will be taken care of by the code.
* 'Auto' toggle automically determines which axis should be used for the distance estimations/calculations. It is the default option, but may not work that well for
some cases.
* X/Y/Z toggles can be used to select the axis to use for these calculations. Try
to choose the axis along which the curve stretches out for most.

Python Notes:
Python API access for this constraint is not included in this commit. Will be coming
soon.
2007-04-07 03:32:57 +00:00
afdd54fa37 moved source and text to american spelling
* colour -> color
* centre -> center
* normalise -> normalize
* modelling -> modeling
2007-04-04 13:18:41 +00:00
269e943d58 == Copy Location Constraint ==
I've added two new options for this constraint:
* Copy Bone Tip Location
* Apply owner's location on top of copied location ('Offset')
2007-03-24 03:00:54 +00:00
31f79cf5b4 === Constraints ===
Patch by Juho Vepsäläinen (bebraw)
[ #5850 ] Inverted axis' buttons to Copy Rotation and Copy Location constraints

This patch adds the options to invert the value being copied from each axis of the Copy Rot/Copy Loc constraints.


This commit also includes some slight code sanitization and tool tips cleanup (for the two track constraints, the tool tips were really unuseful).
2007-03-18 14:53:17 +00:00
b5343551ac Bugfix:
Removed the ability to change the name of a constraint or vertex group
to "" as it was causing problems. Anyway, it shouldn't be allowed.
2007-03-02 07:30:52 +00:00
6e3b4ee0d4 Code Cleanups for Constraints
* Removed some code which really wasn't needed
2007-02-27 04:35:05 +00:00
3318bef2f1 === Constraints Bug Fix ===
Fix for bug: [ #5418 ] Follow Path constraint overrides objects' inherited scale

Patch provided by Aligorith.
2007-01-14 23:42:06 +00:00
f4ee0f4b4c fixes in rigidbody constraints rigidbody -> IPO baking:
copy system with rigidbody constraint will link new constraints to new objects (instead of old)
fps from blender will be used when baking (left shift/ctrl/alt + P)
2007-01-07 04:54:29 +00:00
ed2f161c72 == Copy Rotation Constraint - Bugfix #5519 ==
Now, when only one axis toggle is on and click on it, all of the other
toggles will not be turned on.

For this to work, I've moved the version patches in the drawing/evaluation
code for this constraint to the file-reading code.
2006-12-27 05:00:43 +00:00
0e6518731f Use degrees instead of radians for rigidbody constraint axis (euler angles). Radians can't specifiy 90-degree angles precisely, the input is only 3 decimals accurate... 2006-12-18 07:51:12 +00:00
0f7f11fafc Removed a few unused variables - compiler warnings. 2006-12-05 02:06:51 +00:00
4a2eceff20 === [ #5094 ] TrackTo Constraint with an animatable "up" direction ===
Patch by Matthew Plough: This adds an option to the Track To constraint to use the target's Z axis for Up axis reference instead of the global Z axis.

Off by default for backward compat.
2006-12-03 18:38:51 +00:00
2572b9f72c Reserved some Bullet 2.x constraint data.
Although we will delay the main Rigid Body user interface after 2.43 release early 2007, I need some constraint data/UI to make progress with COLLADA Physics.
Added RigidBody constraint UI
LR_ALTKEY+LR_CTRLKEY+LR_SHIFTKEY+ P will bake rigidbody
Contribution by RCRuiz, Ramon Carlos.
2006-11-30 00:19:27 +00:00
68a2f29db3 Cleanup of evaluation code for Copy Rotation and Limit Rotation constraints.
Made them use the new the two new math functions I've added in arith.c (in
various patches) - Mat4ToEul and LocEulSizeToMat4 - cutting down on the
amount of code reuse.
2006-11-10 23:00:31 +00:00
b48c514db8 Added an option in the IK constraint to disable stretching, useful
in rigs with layered IK constraints. Also removed the tolerance
setting, this value wasn't used in the solver anymore.
2006-11-06 23:51:37 +00:00
358a6e6e88 Oops! A debug return in code disabled many constraints to work even :) 2006-11-01 11:54:46 +00:00
2145c35e12 Bugfix #5038
The "Copy Size" constraint was calling a where_is_object(), this caused
the depsgraph to mess up in very weird ways and rare occasions. In the
sample file it showed strange lags in bones for using the "Stride bone"
option.

While trying to locate the bug I've revisited the Pose depsgraph in detail,
trying to figure out how it can print possible cycle errors in dependency.
That has been added now too (in console). Unfortunately the bugreport
example had no cycle errors. :)
2006-11-01 11:26:16 +00:00
4725ca6c02 This commit adds local target rotation support to the floor constraint,
making it much more useful. Requested and taunted for frequently by
Plumiferos folks. Click on "Use Rot" to take target object rotations
into account.

Good for using rotated empties, etc., as a sloped floor.
2006-09-22 15:57:58 +00:00
3147963237 Bugfix #4983
- Using NLA stride didn't work at all for Motion Blur render... appeared to
  be a typo even, using 'ctime' instead of 'stime'. :)
- When entering editmode on a striding Armature, the position of the
  armature was incorrect (missing depsgraph refresh)
- changes in constraint.c is just a small cleanup, unused 'ctime' arg.
2006-09-17 11:40:28 +00:00
e341a4e1f4 Patch: Constraints to Limit Transforms (#4662) by Joshua Leung (aligorith)
This adds three new constraints to limit the range of location, rotation and scaling values.
2006-08-13 14:18:15 +00:00
f27acb2e7c Bugfix #4872
Posemode, Wkey option "Select constraint target" did not work for Copy
Scale constraint.
Also added a check for NULL pointer, constraint targets cannot exist...
2006-08-12 12:33:24 +00:00
a6c97c90fb Rotation constraint update.
Small fix, but results are at least less frustrating now. It uses the
"compatible euler" function from inserting key positions here, preventing
euler values to be constrainted that differ weirdly.

I've tried several other approaches to get a definite rotate constraint,
but only constraining a single axes seems to me impossible magic still...
2006-06-03 17:21:45 +00:00
da6b87abb1 Path: [ #2789 ] Add a "copy size" constraint
At long last!
This new constraint is pretty simple. Following in the footsteps of such giants as Copy Loc and Copy Rot, it lets you constrain the size of an object/bone to another object/bone, with per axis restrictions.
2006-02-19 17:42:20 +00:00
Chris Want
c8b48e70e6 Final merge of HEAD (bf-blender) into the orange branch.
Here are my notes on things to look out for as potential problem
spots:

source/blender/blenkernel/intern/displist.c:
+ is initfastshade(void) supposed to be empty? I had
to make it empty to get the merged tree to compile.

source/blender/python/api2_2x/Armature.c:
+ went with the version that had Armature_getLayers()

source/blender/python/api2_2x/Object.c
+ went with the version of Object_getPose() from bf-blender.
(#ifdef 0-ed the other version)

source/blender/python/api2_2x/Pose.[ch]
+ had problems linking due to no Pose_Init() ... copied these
two files straight from bf-blender.

source/blender/src/drawview.c:
+ view3d_panel_properties() had things shifted a few things shifted
a few pixels, otherwise, things were painless

source/blender/src/splash.jpg.c:
+ went with bf-blender version (orange is dead)

source/gameengine:
+ went with bf-blender version -- does not compile due to IMB_rect* stuff,
Ton should look into this.
2006-01-28 16:35:18 +00:00
9d889a94b7 Bugfix as provided by 'stealth apprentice' on the bf-comitters list.
Function get_constraint_target() should catch the case when a constraint
has unknown type, to prevent a pointer to become unitialized.
2006-01-13 12:14:13 +00:00
63c8678263 Orange: small fixes as reported,
- follow path constraint + stride path didn't update correct on file load
- selection of 'stick' bones didn't work in object mode, solid view
- change bone layer sends redraw to NLA too
2005-12-21 17:49:43 +00:00
8c2c8bbfaa New Constraint option for Pose: "Local" Copy Location/Rotation.
The locality is restricted to action or user-transform only. Or as it goes
in the code now: by setting a constraint local, it executes the constraint
before it calculates the influence of Action or user transforms.

ALso note that this works in Evil Eulerians. Meaning that when you only
want to copy the X,Y or Z compenent of a euler, it can give unpredictable
results when the other euler values are set, this because euler axis
rotations work on top of each other.
2005-11-16 14:32:57 +00:00
ea8b08c2cc Two new IK features.
1) Target-less IK

If you add an IK constraint without a target set (no object or bone target),
it now can be grabbed and moved with IK, using its own Bone tip or root as
target itself. This way you can use IK for posing, without having the IK
executed while it animates or while a Pose is being solved for real IK.

After grabbing "Target-less IK", it applies the resulted motion in the
pose-channels, which then can be used to insert keypositions.

The Target-less IK bone can still be rotated without IK, also its chain
can be edited as usual.

UI: The CTRL+I menu gives this as an option too. In the 3D window it is
drawn with orangish color.

Note that IK is not resistant to non-uniform scaling yet.

2) Auto-IK

When the option "Automatic IK" is set, in Edit Buttons Armature Panel,
it creates automatic temporal Target-less IK for the Bone you grab or
translate.

The rules are:

- it only works when a single Bone is selected
- if the Bone is a root bone (no parent), it adds IK to the end of the
  chain(s)
- otherwise it adds the IK to the active Bone
- the temporal IK chain only consists of connected Bones.

This method is still a bit experimental. Maybe it should become a special
grabbing option (like SHIFT+G in Pose Mode). It also only works OK for rigs
that fit for it well... when a rig already is fully setup with IK it can't
do much good. :)
2005-10-30 13:50:42 +00:00
3635bde6f4 Orange's buglist!
- Action Editor: hotkeys V and H for handles were invisible, added menus
- NLA strips: when current frame is exactly on the strip end, it didn't
  include that action... needs a rounding correction for it.
- Action/NLA: deleting keys in Action, which results in only 1 key left,
  resulted in zero sized strip length. Now the strips are defaulted to be
  1 frame in size minimal.
- NLA editor: ALT+C "Convert to strip" didn't increment Action user count
- 3D Window: CTRL+P make parent to Bone still gave the insane menu with all
  bone names. With unified PoseMode select it can just parent to the
  active Bone. Note; this now requires the Armature to be in PoseMode to
  work.
- Rotation Constraint; the new options to only map to X,Y,Z rotation, did
  set the not mapped rotation axes to zero. These should remain unchanged.
- AutoKey optionn for Actions; should not insert action keys on ESC

And added a fix myself:

- When SHIFT+selecting a Bone in PoseMode, and the Armature was not selected
  or active yet, it doesn't extend-select/deselect the Bone anymore.
  This case is only useful when you try to add IK or Constraint, so the
  shift+selection should only activate the clicked Bone.
2005-10-29 10:15:36 +00:00
129097a097 Bugfix #3231
Constraint Ipos didnt work when the bone/channel had no Action Ipo...
just had to move a line of code. :)
2005-10-25 19:40:13 +00:00
8a21421e54 New; Rotation Constraint allows to only copy X,Y,Z axis rotations.
Note this is based on eulers, so might give the common issues. :)
For most cases it goes fine though, especially with only 1 axis constraint.
2005-10-25 19:13:04 +00:00
d004754d6b One Constraint function missed the new MINMAX (floor) type, caused the
last commit (add constraint menu) to fail on adding floor constraints.
2005-10-23 16:13:04 +00:00