Mike Erwin
a731c75442
port math function from Viewport FX
...
mul_v4_m4v3(r, M, v) means r = M * vec4(v, 1.0)
Based on rB194998766c65
2016-09-25 19:01:18 +02:00
Mike Erwin
9bea012b8c
specialize mat3 multiply routines
...
Same as 5c6baf1ee9 but for 3x3 matrices.
2016-09-25 18:48:11 +02:00
Mike Erwin
5c6baf1ee9
specialize mat4 multiply routines
...
mul_m4_m4m4(R, A, B) gives us R = AB in general. Existing code assumed the worst, that A and B both alias the output R. For safety it makes internal copies of A and B before calculating & writing R.
This is the least common case. Usually all 3 matrices differ. Often we see M = AM or M = MB, but never M = MM.
With this revision mul_m4_m4m4 is called in exactly the same way but copies inputs only when needed. If you know the inputs are independent of the output use the "uniq" variant to skip the saftety checks.
2016-09-25 14:27:48 +02:00
Mike Erwin
addc666999
constify BLI_math_matrix inputs
...
GPU_matrix needs this very soon, and it's good practice in general.
also sprinkled in some TODOs for later
2016-09-24 16:21:38 +02:00
Campbell Barton
47a5d7d1bc
BLI_math: Add double versions of functions
...
- mul_v3_m3v3_db
- mul_m3_v3_db
- negate_v3_db
2016-06-16 19:20:08 +10:00
Bastien Montagne
ba6519f0a7
BLI_math: add 'equals_m4m4' (and 'm3' variant) helpers.
2016-05-13 12:06:15 +02:00
Campbell Barton
41a2b97c30
Minor changes needed for standalone mathutils
2015-12-07 11:09:00 +11:00
Campbell Barton
fbca69c69a
BLI_math: add mat3_normalized_to_* functions
...
Many uses of matrices for rotation keep them normalized,
so no need to normalize each time.
2015-10-24 07:02:51 +11:00
Campbell Barton
3de81314fa
Error in last commit
2015-10-15 21:30:24 +11:00
Campbell Barton
83d6b73e96
Error in last commit
2015-10-15 21:28:07 +11:00
Campbell Barton
0a82a20fe4
BLI_math: add normalize_m#_ex functions
...
Useful when we need to use the axis lengths too.
2015-10-15 21:03:27 +11:00
Brecht Van Lommel
d7ceca8c93
Fix T46085: UV project modifier artifacts with vertices behind the camera.
2015-10-11 20:36:38 +02:00
Bastien Montagne
be72df4f06
BLI_math: add mat3_polar_decompose, interp_m3_m3m3 and interp_m4_m4m4.
...
mat3_polar_decompose gives the right polar decomposition of given matrix,
as a pair (U, P) of matrices.
interp_m3_m3m3 uses that polar decomposition to perform a correct matrix interpolation,
even with non-uniformly scaled ones (where blend_m3_m3m3 would fail).
interp_m4_m4m4 just adds translation interpolation to the _m3 variant.
2015-10-09 21:26:33 +02:00
Bastien Montagne
909fa34c5f
BLI_matrix space_transform: Add a 'local-invariant' setter.
...
`BLI_space_transform_from_matrices()` defines a 'global-invariant' transform
(same point in global space, two different coordinates in local and target spaces).
New `BLI_space_transform_global_from_matrices()` is kind of opposite, it defines
a 'local-invariant' transform (two different points in global space, same coordinates in local and target spaces).
Useful to 'match' meshes.
2015-07-11 00:04:27 +02:00
Campbell Barton
52b9d83417
Fix T44592: Zero scale on an axis, zeros all
2015-05-04 22:39:33 +10:00
Lukas Tönne
c19f3ea1b2
Fixed comment.
2015-05-04 14:31:44 +02:00
Brecht Van Lommel
b6caefdaa9
Fix T43711: dual quaternion deform bug with shearing in deform matrix.
...
This also increases the tolerances in is_orthogonal / is_orthonormal functions,
which were much too low for practical purposes.
2015-05-01 19:21:41 +02:00
Campbell Barton
9dadc8f599
Math Lib: add mul_v3_mat3_m4v3
2015-04-27 21:52:42 +10:00
Bastien Montagne
9c782c17ba
Cleanup: hopefully last int->bool one in this area!
2014-12-01 17:11:55 +01:00
Campbell Barton
1cb59394ae
Cleanup: use const, avoid float -> double in matrix invert
2014-11-29 17:49:38 +01:00
Campbell Barton
25c5542fe7
Math Lib: add constant: M_SQRT1_3 1/sqrt(3)
2014-11-22 18:21:52 +01:00
Lukas Tönne
af9da0be43
Complementary fix for rB8054372: Follow the common naming scheme by
...
using negate_mat3_m4 instead of negate_m4.
This avoids changing the behavior and only flips the 3x3 part of the
matrix.
2014-10-30 15:31:18 +01:00
Campbell Barton
be63ba315f
Math Lib: pseudoinverse_m4_m4 changed input matrix
2014-10-30 14:49:57 +01:00
Campbell Barton
c2dc51d827
Math Lib: add transpose_m3_m3, m3_m4, m4_m4
2014-10-30 12:15:14 +01:00
Campbell Barton
0414ed1c48
Fix for mat3_to_rot_size modifying input matrix
2014-10-30 10:37:55 +01:00
Campbell Barton
8054372d22
Fix negate_m3 (taking 4x4 matrix)
...
Cycles bake used incorrectly.
2014-10-30 10:29:37 +01:00
Campbell Barton
775a54485b
Math Lib: add mul_v3_project_m4_v3
2014-09-16 15:41:17 +10:00
Campbell Barton
671f75a12a
Math Lib: Add copy_m2_m2, unit_m2, zero_m2
2014-09-06 11:29:27 +10:00
Campbell Barton
eadfddd02a
Cleanup: magic numbers
2014-08-12 15:58:53 +10:00
Bastien Montagne
3c9e11df37
Cleanup: Move SpaceTransform helpers from BKE_shrinkwrap to BLI_math_matrix.
2014-08-01 16:31:06 +02:00
Bastien Montagne
74758576fc
Cleanup: general cleanup in BLI_math code (mostly, use 'const' where possible, true/false for booleans, format for float litterals).
2014-07-30 12:19:41 +02:00
Campbell Barton
8489b94e07
Math Lib: rename mul_serie_m3 to mul_m3_series & reorder args
...
Importantly, reversed mul_serie_m3 argument order (so it matches the m4 function)
2014-07-21 18:57:35 +10:00
Sergey Sharybin
6f1f5771ff
Correction to 7c7b730, multiplication order was flipped
...
That's really annoying that multiplication order is flipped
comparing mat3 and mat4 cases, but for the purposes of not
breaking all the branches which might use this stuff we'd
better keep order consistent with old version for now.
Suggestion here would be to make order consistent but rename
this functions to mult_* to make compilation fail instead
of failing and using wrong order silently.
2014-07-20 20:44:42 +06:00
Campbell Barton
7c7b7302d3
Math Lib: use variable length args for mul_serie_m3,m4 (instead of trailing NULL's)
2014-07-20 14:01:42 +10:00
Campbell Barton
b2cad79500
Math lib: add negate_m3, negate_m4
2014-05-30 00:26:32 +10:00
Dalai Felinto
7f089afc8b
Bake-API: relaxing in the check for scale uniformity
...
It still warns the user that there may be an error, but the baking goes
on. Also using the new is_uniform_scaled_m4() instead of float comparison.
Reported and fix suggested by Campbell Barton as a concern over 2bfc3deb
2014-05-22 21:35:58 -03:00
Campbell Barton
617557b08e
Code cleanup: remove TRUE/FALSE & WITH_BOOL_COMPAT define
2014-04-01 15:22:28 +11:00
Sergey Sharybin
b7dbb2f48e
Correction to the previous commit
2014-03-25 16:22:47 +06:00
Sergey Sharybin
d4cc81d552
Fix T38870: Freezes when jumping in front of a keyframe.
...
Issue was caused by inverting a degenerate matrix when
evaluating drivers.
Solved by using tweaked inverse code (same as used in Cycles).
Should have no affect on cases when matrix is not degenerate.
2014-03-25 16:07:13 +06:00
Campbell Barton
798e684c7c
Math lib: simplify size_to_mat4 and use in b_bone_spline_setup
2014-02-02 02:24:47 +11:00
Campbell Barton
99d050f88b
Text3d: selection in editmode now follows rotated text along path
2014-01-05 22:20:33 +11:00
Campbell Barton
07ceb99213
Code Cleanup: use strict flags for math lib, add inline declarations
2013-12-06 03:57:17 +11:00
Campbell Barton
f3d13bec6d
Code Cleanup: correct fabsf/fabs/abs use
2013-12-04 09:24:38 +11:00
Campbell Barton
a304b5a988
correct typo
2013-10-25 22:12:05 +00:00
Sergey Sharybin
e9d5e9813c
Code cleanup: added generic function copt_m3_m3d
2013-10-20 12:08:51 +00:00
Sergey Sharybin
fc8b0ed5e5
Move utility functions from mball to mathutils
2013-10-18 23:38:51 +00:00
Sergey Sharybin
9b09af0dca
Fix #36701 : Mask pivioting doesnt honor parenting
...
Made mask transformation aware of parent matrix.
2013-09-11 10:06:54 +00:00
Sergey Sharybin
8d6e5606d8
Add assert to mul_v3_m3v3 and mul_v2_m3v3,
...
So they're not likely to be called with bad arguments.
2013-08-06 02:37:02 +00:00
Campbell Barton
76e989d7b1
function renaming for own recently added BLI_math functions, suggested by Brecht.
2013-07-30 10:58:36 +00:00
Campbell Barton
5dc3cfc983
fix [ #36282 ] Spin error with non uniform scale
...
add support for passing object matrix to bmesh transform operators.
2013-07-26 11:15:22 +00:00