Commit Graph

126 Commits

Author SHA1 Message Date
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
b32408eff8 BLI_math: move interp_*_cubic to its own function 2016-07-11 17:16:35 +10:00
Campbell Barton
6035cf05bf BLI_math: add normalize functions which fit to a length
Convenient since its common to normalize then scale,
since these are inlined, use for regular normalize w/ 1.0 length.
2016-07-08 09:52:29 +10: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
Campbell Barton
66b12ef4ab BLI_math: cleanup arg names
project functions arg naming made it hard to tell which vector was projected onto.
2016-06-12 15:39:04 +10:00
Brecht Van Lommel
2630207ada Fix GCC/Linux build error after finite/isfinite changes. 2016-05-17 23:40:25 +02:00
Campbell Barton
dbf1257b14 Minor optimization for scanfill
Replace angle with with cosine calculation.
2016-04-20 09:53:40 +10:00
Bastien Montagne
aad24468e2 Fix T47038: Particles in Particle Edit Mode get added in completely wrong location.
It also fixes another issue (crash) related to symmetric editing.

Quite involved, we (try to!) fix complete broken logic of parts of particle code, which would use poly index
as tessface one (or vice-versa). Issue most probably goes back to BMesh integration time...

This patch mostly fixes particle editing mode:
  - Adding/removing particles when using generative modifiers (like subsurf) should now work.
  - Adding/removing particles with a non-tessellated mesh (i.e. one having ngons) should also mostly work.
  - X-axis-mirror-editing particles over ngons does not really work, not sure why currently.
  - All this in both 'modes' (with or without using modifier stack for particles).

Tech side:
  - Store a deformed-only DM in particle modifier data.
  - Rename existing DM to make it clear it's a final one.
  - Use deformed-only DM's tessface2poly mapping to 'solve' poly/tessface mismatches.
  - Make (part of) mirror-editing code able to use a DM instead of raw mesh, so that we can mirror based on final DM
    when editing particles using modifier stack (mandatory, since there is no way currently to find orig tessface
    from an final DM tessface index).

Note that this patch is not really nice and clean (current particles are beyond hope on this side anyway),
it's more like some urgency bandage. Whole crap needs complete rewrite anyway,
BMesh's polygons make it really hard to work with current system (and looptri would not help much here).

Also, did not test everything possibly affected by those changes, so it needs some users' testing & validation too.

Reviewers: psy-fi

Subscribers: dfelinto, eyecandy

Maniphest Tasks: T47038

Differential Revision: https://developer.blender.org/D1685
2016-01-04 12:19:45 +01:00
Brecht Van Lommel
6e66ddf5ed Fix warnings and remove casts by adding copy_vx_vx_uchar() functions. 2015-10-11 02:15:44 +02:00
Campbell Barton
ecf0529efd Quiet warning 2015-09-24 15:17:02 +10:00
Bastien Montagne
7837f0e833 BLI_math 'compare' cleanup & enhancements.
This commit:
* Adds a 'compare_ff' function for absolute 'almost equal' comparison of floats.
* Makes 'compare_vxvx' functions use that new 'compare_ff' one.
* Adds a 'compare_ff_relative' function for secured ulp-based relative comparison of floats.
* Adds matching 'compare_vxvx_relative' functions.
* Adds some basic tests for compare_ff_relative.

See https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/

Note that we could replace our python/mathutils' EXPP_FloatsAreEqual() by BLI's compare_ff_relative
(using a very small absolute max_diff), but these do not have exact same behavior...
Left a comment there for now, we can do it later if/when we are sure it won't break anything!
2015-07-10 15:02:43 +02:00
Campbell Barton
6ee653352b Math Lib: double versions of vector funcs
- add_vn_vn_d
- add_vn_vnvn_d
- mul_vn_db
2015-05-21 21:06:29 +10:00
Campbell Barton
e5e73ccc90 Math Lib: rename fill_*, to copy_*
matching convention for fixed length api, eg: copy_v3_fl
2015-05-05 17:08:29 +10:00
Campbell Barton
a4965249ec Math Lib: add range_vn_u 2015-04-28 06:54:50 +10:00
Campbell Barton
01b1eb445c Math Lib: add project_plane_v3_v3v3
Useful for projecting one vector onto another (as a plane).

This is a rather common operation,
doing inline isn't always obvious whats happening.
2015-04-08 23:01:37 +10:00
Bastien Montagne
6ceb84c217 BLI math vec: add 'abs' functions to get absolute values of a vector.
Unseful when handling e.g. scale, sometimes.
2015-03-17 19:57:16 +01:00
Campbell Barton
9ffc66b1c0 Math Lib: add mid_v3_v3v3v3v3 2015-03-09 20:26:09 +11:00
Sergey Sharybin
225f68c324 Fix interpolation functions ignoring number of components when doing early output 2015-02-24 00:36:33 +05:00
Bastien Montagne
e442b9916e BLI_math vectors: add minmax_v3v3_v3_array to get min and max values on each components of an array of 3D vectors. 2015-02-05 14:00:58 +01:00
Bastien Montagne
1794186053 BLI_math: add vector's dot_v3v3v3() func, for when you have three points instead of two vectors. 2015-01-09 13:03:55 +01:00
Antony Riakiotakis
f745564e4e GSOC 2013 paint
Yep, at last it's here!

There are a few minor issues remaining but development can go on in
master after discussion at blender institute.

For full list of features see:

http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.72/Painting

Thanks to Sergey and Campbell for the extensive review and to the
countless artists that have given their input and reported issues during
development.
2014-07-21 12:02:05 +02:00
Campbell Barton
9c48ea3979 Math Lib: add function to get signed angle about an axis 2014-07-09 11:15:08 +10:00
Campbell Barton
c6a34e047c Correct ortho_v2_v2 arg size 2014-05-27 14:42:22 +10:00
Campbell Barton
35380cdcad Fix for uninitialized unit_use_radians variable with inset and bevel 2014-05-06 19:20:03 +10:00
Campbell Barton
233dac1494 Math Lib: increase epsilon for ortho_basis_v3v3_v3
passing in a unit length vector wouldn't always compute unit length vectors because the epsilon tested was too small.
2014-04-16 21:07:28 +10:00
Campbell Barton
5770d691bb Optimize BLI_convexhull_aabb_fit_hull_2d, avoid atan2, sin, cos
add utility functions for using a 2d unit vector as a rotation matrix
mul_v2_v2_cw & mul_v2_v2_ccw
2014-04-03 21:47:03 +11:00
Campbell Barton
55f83e36cc Py API: Vector.slerp(). also added interp_v3_v3v3_slerp(_safe) functions 2014-03-31 13:28:37 +11:00
Campbell Barton
6aa75d3b2c Fix for error in normalize_vn_vn(), add len_squared_vn 2014-03-31 11:19:32 +11:00
Campbell Barton
a6e8137983 Convenience macro for print_ funcs, saves passing id each time 2014-03-30 15:04:20 +11:00
Campbell Barton
5981567ec6 Code cleanup: use len_v2v2_int for view zoom-scale 2014-03-28 15:02:57 +11:00
Bastien Montagne
0e9084d5ec Fix T39210: Grid Fill is generating mesh that's inconsistent with selected edge loops
Issue was in BLI's rotation_between_vecs_to_quat(), which did not handled correctly cases where both vectors are colinear.

Patch by Campbell Barton and me.

Issue originaly tracked down by Yan Shi, many thanks!
2014-03-16 16:31:19 +01:00
Campbell Barton
2f01be2b2f UI: panel tabs, use simple color interpolation that ignores alpha 2014-02-10 17:06:56 +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
13896063bc Math library: minor additions sqrtf_signed and copy_v2_fl2 2013-11-26 20:53:26 +11:00
Campbell Barton
4c01709018 Math Library: add dot_m4_v3_row_x/y/z 2013-11-20 11:48:12 +11:00
Campbell Barton
c80c1c6f5c add copy_v4_fl4, replace QUATSET macro. 2013-10-22 03:31:21 +00:00
Sergey Sharybin
fc8b0ed5e5 Move utility functions from mball to mathutils 2013-10-18 23:38:51 +00:00
Sergey Sharybin
35b61a7512 Move GCC attributes into a centraized defines
Instead of having ifdef __GNUC__ all over the headers
to use special compiler's hints use a special file where
all things like this are concentrated.

Makes code easier to follow and allows to manage special
attributes in more efficient way.

Thanks Campbell for review!
2013-09-01 15:01:15 +00:00
Campbell Barton
38338a51c9 add is_finite_v# functions, use bool's 2013-08-20 09:34:52 +00:00
Brecht Van Lommel
83617429cf Fix build warnings with clang and UNUSED_RESULT_ATTR (attribute declaration must precede definition). 2013-08-05 12:49:13 +00:00
Campbell Barton
e03b1668e0 code cleanup: remove unused functions
- IsectLLPt2Df
- isect_point_quad_uv_v2
- isect_point_face_uv_v2

These are obsoleted by resolve_tri_uv, resolve_quad_uv

also add attributes for unused function results for some math functions.
2013-08-01 17:15:11 +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
c754eaa0f9 add inline functions getting a single axis from mul_m3_v3() 2013-07-28 19:46:33 +00:00
Campbell Barton
e6b22d287f utility function for printing arbitrary sizes vectors. 2013-07-11 15:32:26 +00:00
Brecht Van Lommel
8b2c5e693c Fix #35634: weight paint did not do z-buffer culling anymore on Windows after recent change to size of bool. 2013-06-13 17:11:09 +00:00
Campbell Barton
0ee45c9301 more optimal method of calculating the normal for the solidify modifier.
When adding 2 unit length vectors, the length can be used to calculate the angle.
2013-05-08 14:33:02 +00:00
Campbell Barton
b0752f1b89 add interp_v3_v3v3v3_uv() to use for use with uv value from isect_ray_tri_v3(), rename tree -> bmtree for BMBVHTree. 2013-04-17 05:49:06 +00:00
Campbell Barton
502ddd3128 code cleanup: warnings and style. 2013-04-12 00:50:40 +00:00
Campbell Barton
b77acc2879 add 2d length functions for testing pixel coords. len_manhattan_v2_int, len_manhattan_v2v2_int 2013-04-11 02:23:45 +00:00