Commit Graph

3689 Commits

Author SHA1 Message Date
Campbell Barton 7a58ff928c Math Lib: signed versions of quaternion angle
There was no simple way to get the shortest quaternion angle.
2017-12-19 14:03:29 +11:00
Sergey Sharybin 5e28b71457 math utils: Add utilities to scan bit and clear it 2017-12-15 16:54:28 +01:00
Sergey Sharybin de9e5a0926 Math utils: Go away form naive code for highest_order_bit_uint 2017-12-15 16:54:28 +01:00
Sergey Sharybin 412de222f8 Math utils: Add bit scan operations 2017-12-15 16:54:28 +01:00
Sergey Sharybin 02ec0b53df Math utils: Make it more clear what the functions are returning 2017-12-15 16:54:28 +01:00
Sergey Sharybin 2aa0f8a41b Math utils: Cleanup, use _uint suffix for function which operates on uint 2017-12-15 16:54:28 +01:00
Campbell Barton e1eb1fbfca BLI_ghash: Description of GHash, GSet
Also some re-indenting.
2017-12-03 03:35:45 +11:00
Campbell Barton 28d2148b09 Haiku OS Support
D2860 by @miqlas

Even though Haiku is a niche OS, only minor changes are needed.
2017-11-30 18:05:21 +11:00
Brecht Van Lommel 4f7280da40 Fix paint float color blending bugs with alpha 1.0 and vivid light.
For some blend modes there would be no effect with factor 1.0, even if factor
0.999 would give a very different image. Now the result should have no
discontinuity.

Differential Revision: https://developer.blender.org/D2925
2017-11-29 18:01:36 +01:00
Bastien Montagne b63442e0b6 Minor cleanup for own recent commits. 2017-11-23 22:43:11 +01:00
Bastien Montagne efb86b712d Add a new parallel looper for MemPool items to BLI_task.
It merely uses the new thread-safe iterators system of mempool, quite
straight forward.

Note that to avoid possible confusion with two void pointers as
parameters of the callback, a dummy opaque struct pointer is used
instead for the second parameter (pointer generated by iteration over
mempool), callback functions must explicitely convert it to expected
real type.

Also added a basic gtest for this new feature.
2017-11-23 21:14:43 +01:00
Bastien Montagne b84e6dfee4 Add ability to use more than one mempool iterator simultaneously.
This will allow threaded tasks to 'consume' all mempool items in
parallel tasks, each one working on a whole chunk at once (to reduce
concurrency managing overhead).
2017-11-23 21:12:00 +01:00
Bastien Montagne d423e66d34 Add non-gcc variant of static assert macro.
Adapted from http://www.pixelbeat.org/programming/gcc/static_assert.html.

Note that this macro just discards error message, so error when building
is much less nice than with gcc's _Static_assert... But error log will
point to right place in code, so should still be OK.
2017-11-23 20:25:55 +01:00
Bastien Montagne 497e2b3dfa Cleanup: use signed atomic ops when needed. 2017-11-23 16:24:34 +01:00
Campbell Barton 434ed96dd2 Revert "BLI_utildefines: Support SWAP macro with two args"
This reverts commit d749320e3b.

It's possible the container struct is larger,
we could do sizeof checks that falls back to memmove
but rather avoid complicating things.
2017-11-23 15:21:50 +11:00
Campbell Barton d749320e3b BLI_utildefines: Support SWAP macro with two args 2017-11-23 03:11:48 +11:00
Brecht Van Lommel 96415cb52a Code cleanup: fix harmless compiler warning. 2017-11-20 23:32:06 +01:00
Campbell Barton 92ea281017 Cleanup: remove BKE_utildefines
This was meant to be used for less general macros but was never used.

Rename BKE_BIT_TEST_SET to SET_FLAG_FROM_TEST
2017-11-20 01:47:31 +11:00
Campbell Barton 83e4e65074 Cleanup: outdated comment 2017-11-19 03:25:52 +11:00
Campbell Barton 40c8a18229 Cleanup: style 2017-11-18 17:22:54 +11:00
Bastien Montagne d697e3d46e BLI listbase: add bytes finding helpers.
Quite similar to string ones actually, except more generic. Used in
id_override_static branch currently.
2017-11-16 12:49:31 +01:00
Campbell Barton 9c7b89241d BLI_utildefines: sync w/ 2.8 2017-11-15 23:06:34 +11:00
Campbell Barton 474362b363 Cleanup: use 'uint' 2017-11-15 22:58:39 +11:00
Campbell Barton 9cbf374814 GSet: utils to access data stored outside the set 2017-11-15 22:45:37 +11:00
Arto Kitula 0a3fa9c25c Fix missing SpinLock typedef on macOS 2017-11-14 16:51:34 +02:00
Sergey Sharybin 55696b56d9 Fix T53068: AMD Threadripper not working well with Blender
The issue was caused by SpinLock implementation in old pthreads we ar eusing on
Windows. Using newer one (2.10-rc) demonstrates same exact behavior. But likely
using own atomics and memory barrier based implementation solves the issue.

A bit annoying that we need to change such a core part of Blender just to make
specific CPU happy, but it's better to have artists happy on all computers.

There is no expected downsides of this change, but it is so called "works for
me" category. Let's see how it all goes.
2017-11-14 12:21:15 +01:00
Campbell Barton 40ad1cf0b1 BLI: sync changes from 2.8 2017-11-14 16:10:48 +11:00
Stefan Werner df886b178c Moved alignment attributes from my last commit to BLI_compiler_attrs.h for future use. 2017-11-09 14:59:31 +01:00
Campbell Barton 765e28948e Cleanup: code style 2017-11-02 15:09:11 +11:00
Alexander Gavrilov 8bdc391c54 Implement a new automatic handle algorithm to produce smooth F-Curves.
The legacy algorithm only considers two adjacent points when computing
the bezier handles, which cannot produce satisfactory results. Animators
are often forced to manually adjust all curves.

The new approach instead solves a system of equations to trace a cubic spline
with continuous second derivative through the whole segment of auto points,
delimited at ends by keyframes with handles set by other requirements.

This algorithm also adjusts Vector handles that face ordinary bezier keyframes
to achieve zero acceleration at the Vector keyframe, instead of simply pointing
it at the adjacent point.

Original idea and implementation by Benoit Bolsee <benoit.bolsee@online.be>;
code mostly rewritten to improve code clarity and extensibility.

Reviewers: aligorith

Differential Revision: https://developer.blender.org/D2884
2017-11-01 21:57:39 +03:00
Campbell Barton 512b879241 BLI_heap: add validation check, improve tests
Also minor readability changes, avoid running both heap_up/down
gives minor speedup too.
2017-10-29 18:23:33 +11:00
Campbell Barton bd0d41059f Cleanup: move docs out of header 2017-10-29 16:08:10 +11:00
Campbell Barton 4518c0f3e8 Cleanup: const args 2017-10-29 15:47:10 +11:00
Campbell Barton 3425732926 BLI_heap: minor changes to the API
Recent addition of 'reinsert' didn't match logic for ghash API.

Rename to BLI_heap_node_value_update,
also add BLI_heap_insert_or_update since it's a common operation.
2017-10-29 15:47:06 +11:00
Campbell Barton 336885beba Use BLI_heap_reinsert for decimate and beautify
Improves performance for high poly meshes,
~70% faster for decimate, only ~10% for beautify.
2017-10-29 05:28:00 +11:00
Campbell Barton 4af1af70ad BLI_hash: add BLI_heap_reinsert
Allows avoiding remove/insert calls.
2017-10-29 04:42:58 +11:00
Campbell Barton fdae9e1e03 BLI_array_store: correct hashing single bytes
The single byte version of hash_data was casting from unsigned char
instead of signed.

This didn't cause any errors since the result of each aren't compared.
Even so, better keep them matching.
2017-10-28 18:28:55 +11:00
Campbell Barton 8ac69ff9dc Cleanup: use uint type in BLI 2017-10-28 17:48:45 +11:00
Campbell Barton 6dfe4cbc6b Polyfill Beautify: half-edge optimization
Was using an edge hash for triangle -> edge lookups,
updating triangle indices for each edge-rotation.

Replace this with half-edge which can rotate edges much more simply,
writing triangles back once the solution has been calculated.

Gives ~33% speedup in own tests.
2017-10-23 01:40:03 +11:00
Campbell Barton 959a58da9e Cleanup: redundant casts 2017-10-20 14:03:22 +11:00
Campbell Barton 99520e3f92 Cleanup: use 'e' prefix for enum typedefs
Convention was only followed loosely,
apply to DNA where changes aren't likely to conflict.

(Skipped ModifierType for eg).
2017-10-17 13:49:20 +11:00
Campbell Barton 3df139c530 Cleanup: Math lib naming (use v3 suffix) 2017-10-06 21:06:38 +11:00
Campbell Barton c454d816a9 Cleanup: style 2017-10-06 16:56:41 +11:00
Campbell Barton deb16defd5 Math Lib: distance to AABB
Original code by @mano-wii, modified for general use.
2017-10-02 22:07:39 +11:00
Campbell Barton 5a1954a5cb Drop platform support for Solaris & AIX
These platforms didn't see maintenance in years.
This commit just removes ifdef's & cmake check.
2017-09-29 19:16:34 +10:00
Campbell Barton 43b4913051 Math Lib: Add non-clamped round_* functions
Replace iroundf with round_fl_to_int, add other types
2017-09-27 11:13:03 +10:00
Campbell Barton aba2f8ea67 Beauty fill was skipping small faces 2017-09-26 12:59:23 +10:00
Campbell Barton e40e29cd38 Fix T52871: beauty fill error
Only lock tri's facing different directions.
Needed because scanfill creates zero area faces.
2017-09-26 12:14:46 +10:00
Campbell Barton 293dc4e084 Revert "Fix T52871: `BLI_polyfill_beautify_quad_rotate_calc_ex` was mistakenly considering the state as degenerated"
This reverts commit a8f11f5422.

Result is no longer symmetrical, will investigate a different fix.
2017-09-26 12:14:04 +10:00
Germano a8f11f5422 Fix T52871: `BLI_polyfill_beautify_quad_rotate_calc_ex` was mistakenly considering the state as degenerated 2017-09-23 12:59:02 -03:00