Commit Graph

111 Commits

Author SHA1 Message Date
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
29039e5c74 Cleanup: remove compare_len_squared utility
There isn't any advantage to this over comparing the squared length.
2019-03-19 00:37:58 +11: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
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
Bastien Montagne
482c4d099a Cleanup: remove all BLI_utiledefines' ugly vectorial macros.
Not only were those often making doublons with already existing
BLI_math's stuff, but they were also used to hide implicit type
conversions...

As usual this adds some more exotic inlined vector functions (one of
the rare cases where I really miss C++ and its templates... ;) ).
2019-01-20 16:27:06 +01:00
Sergey Sharybin
cb5302f962 Math: Make it possible to use vector for both input and output
Avoids nasty code all over where such math is required, and
compilers can easily deal with such situation.

Don't prefer questionable micro-optimization which comes with
a cost of nasty actual logic code.
2019-01-18 12:29:53 +01:00
Clément Foucault
0c987aa7ac BLI: Math: Add normal_float_to_short_v4 2018-11-17 14:56:17 +01:00
Campbell Barton
0d69a5aa34 Merge branch 'master' into blender2.8 2018-11-04 18:12:58 +11:00
Brecht Van Lommel
1b974563b1 Fix T57529: 2D image paint fill tool not taking into account alpha. 2018-11-01 13:05:57 +01:00
Clément Foucault
a5101de6a9 BLI: Add mul_v2_v2v2 function 2018-10-01 15:14:46 +02:00
Brecht Van Lommel
28324143c4 UI: draw mono icons with button type text color, instead of area text color. 2018-09-27 18:39:50 +02:00
Antonioya
66da2f537a New Grease Pencil object for 2D animation
This commit merge the full development done in greasepencil-object branch and include mainly the following features.

- New grease pencil object.
- New drawing engine.
- New grease pencil modes Draw/Sculpt/Edit and Weight Paint.
- New brushes for grease pencil.
- New modifiers for grease pencil.
- New shaders FX.
- New material system (replace old palettes and colors).
- Split of annotations (old grease pencil) and new grease pencil object.
- UI adapted to blender 2.8.

You can get more info here:

https://code.blender.org/2017/12/drawing-2d-animation-in-blender-2-8/
https://code.blender.org/2018/07/grease-pencil-status-update/

This is the result of nearly two years of development and I want thanks firstly the other members of the grease pencil team: Daniel M. Lara, Matias Mendiola and Joshua Leung for their support, ideas and to keep working in the project all the time, without them this project had been impossible.

Also, I want thanks other Blender developers for their help, advices and to be there always to help me, and specially to Clément Foucault, Dalai Felinto, Pablo Vázquez and Campbell Barton.
2018-07-31 10:50:43 +02:00
Bastien Montagne
ecfb74833d Merge branch 'master' into blender2.8 2018-07-20 12:13:58 +02:00
Alexander Gavrilov
0bf8096501 Resolve the opposite vector ambiguity in Damped Track constraint.
Damped Track by specification attempts to arrive at the desired
direction via the shortest rotation. However with opposite vectors
there are infinitely many valid 180 degree rotations. Currently
it gives up and does nothing.

I think that it would be more reasonable to resolve the ambiguity
arbitrarily, so that Damped Track won't have a weird dead zone.
To make it more predictable I use a local axis.

In addition, the singularity area vicinity has some floating
point precision problems that result in significant jitter.
This applies workarounds for two causes of instability.

Differential Revision: https://developer.blender.org/D3530
2018-07-19 17:58:27 +03:00
Campbell Barton
e159ec8bc1 Cleanup: compiler warnings, use const 2018-05-14 23:12:51 +02:00
Campbell Barton
40ad1cf0b1 BLI: sync changes from 2.8 2017-11-14 16:10:48 +11:00
Clément Foucault
e053fade99 Mesh Batch Cache: get rid of the ORCO VBO data, and reconstruct it in shader.
With only one MADD instruction we recover the orco data and reduce both the storage and the fetching cost of an attrib layer.
2017-05-15 16:14:18 +02:00
Clément Foucault
38125d0499 Mesh Batch Cache: Define Compressed format for shading data.
Deactivated by default.
All shading attribs can be packed to take less VRAM at the cost of precision (not noticable in this case).
UVs can be packed into I16 but that limits their positions into the [-1, +1] range.

This could be a setting option in the future.
2017-05-15 16:14:17 +02:00
Sergey Sharybin
cdaed4d360 Fix compilation error with strict flags and gcc-6 2017-01-20 17:43:13 +01:00
Campbell Barton
d5edaac42d Comments: mul_project_m4_v3_zfac 2016-12-28 15:49:39 +11: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
Brecht Van Lommel
2630207ada Fix GCC/Linux build error after finite/isfinite changes. 2016-05-17 23:40:25 +02:00
Brecht Van Lommel
21fddf7d1c C99/C++11: replace deprecated finite() by isfinite(). 2016-05-17 21:39:16 +02: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
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
c31aae0487 Use fabsf for floats 2015-03-19 06:13:50 +11: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
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
Campbell Barton
4a92620d3e Comments: clarify math lib 2014-09-28 15:08:55 +10:00
Campbell Barton
1dd17bed4a Knife tool: simplify hit-depth calculation 2014-08-17 12:50:48 +10: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
d9f39257f4 Math Lib: add compare_len_squared_v3v3 from paint branch 2014-07-14 11:55:38 +10:00
Campbell Barton
d56e6bf1bf Math Lib: accept a limit of 0.0 when comparing vectors 2014-07-14 11:33:19 +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
5981567ec6 Code cleanup: use len_v2v2_int for view zoom-scale 2014-03-28 15:02:57 +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
Campbell Barton
38338a51c9 add is_finite_v# functions, use bool's 2013-08-20 09:34:52 +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
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
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