Commit Graph

140 Commits

Author SHA1 Message Date
Bastien Montagne
1ff8be24ef Cleanup/Refactor: move Main stuff into BKE's new main.c file (and header).
We already had a BKE_main.h header, no reason not to put there
Main-specific functions, BKE_library has already more than enough to
handle with IDs and library management!
2018-11-07 20:58:53 +01:00
Alexander Gavrilov
84fa806491 BLI_kdopbvh: add an option to use a priority queue in find_nearest.
Simple find_nearest relies on a heuristic for efficient culling of
the BVH tree, which involves a fast callback that always updates the
result, and the caller reusing the result of the previous find_nearest
to prime the process for the next vertex.

If the callback is slow and/or applies significant restrictions on
what kind of nodes can qualify for the result, the heuristic can't
work. Thus for such tasks it is necessary to order and prune nodes
before the callback at BVH tree level using a priority queue.

Since, according to code history, for simple find_nearest the
heuristic approach is faster, this mode has to be an option.
2018-11-06 21:20:16 +03:00
Bastien Montagne
aa9912ec04 Proper fix for new 'SimpleHeap' gtests...
This reverts reverting commit rB55324b8a2e6799300, and do proper 'cleanup' (sigh)
in gtest as well.

Sorry for the noise, did not understood what had happened here
immediately. :/
2018-11-06 16:25:00 +01:00
Bastien Montagne
55324b8a2e Revert rBfee6ab18e7e9 in BLI_heap_test.cc
Most certainly commite by mistake, FastHeap is not in BLI yet!
2018-11-06 16:06:53 +01:00
Alexander Gavrilov
fee6ab18e7 BLI_heap: implement a limited but faster version of heap.
If the user only needs insertion and removal from top, there is
no need to allocate and manage separate HeapNode objects: the
data can be stored directly in the main tree array.

This measured a 24% FPS increase on a ~50% heap-heavy workload.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D3898
2018-11-05 20:49:17 +03:00
Alexander Gavrilov
d3c815bd08 BLI_heap: add an API function to directly read the top node value.
It is very commonly needed in loop conditions to check if
the items in the heap are good enough to continue.
2018-11-04 13:29:17 +03:00
Campbell Barton
f35e9f047a Merge branch 'master' into blender2.8 2018-09-19 12:14:36 +10:00
Campbell Barton
bb3ec3ebaf BLI_utildefines: rename pointer conversion macros
Terms get/set don't make much sense when casting values.

Name macros so the conversion is obvious,
use common prefix for easier completion.

- GET_INT_FROM_POINTER  -> POINTER_AS_INT
- SET_INT_IN_POINTER    -> POINTER_FROM_INT
- GET_UINT_FROM_POINTER -> POINTER_AS_UINT
- SET_UINT_IN_POINTER   -> POINTER_FROM_UINT
2018-09-19 12:12:21 +10:00
Campbell Barton
d44c8ce1cb Cleanup: BLI_expr_pylike argument ordering
- Order array length after the array.
- Put return argument last.
2018-09-19 11:40:40 +10:00
Campbell Barton
3aea5695bb Cleanup: rename BLI_simple_expr -> BLI_expr_pylike_eval
Simple isn't a good prefix for library names since
lots of unrelated modules could be called 'simple'.

Include 'py' in module name since this is a subset of Python,
one of the main motivations for this is to be Python like/compatible.
2018-09-19 11:08:04 +10:00
Alexander Gavrilov
bf2a54b058 Support evaluating simple driver expressions without Python interpreter.
Recently @sergey found that hard-coding evaluation of certain very
common driver expressions without calling the Python interpreter
produces a 30-40% performance improvement. Since hard-coding is
obviously not suitable for production, I implemented a proper
parser and interpreter for simple arithmetic expressions in C.

The evaluator supports +, -, *, /, (), ==, !=, <, <=, >, >=,
and, or, not, ternary if; driver variables, frame, pi, True, False,
and a subset of standard math functions that seem most useful.

Booleans are represented as numbers, since within the supported
operation set it seems to be impossible to distinguish True/False
from 1.0/0.0. Boolean operations properly implement lazy evaluation
with jumps, and comparisons support chaining like 'a < b < c...'.

Expressions are parsed into a very simple stack machine program
that can then be safely evaluated in multiple threads.

Reviewers: sergey, campbellbarton

Differential Revision: https://developer.blender.org/D3698
2018-09-18 13:25:28 +03:00
Campbell Barton
3140304940 Cleanup: overly polite/rude messages 2018-09-04 18:45:17 +10:00
Campbell Barton
9bd0c63382 Merge branch 'master' into blender2.8 2018-06-29 08:05:38 +02:00
Campbell Barton
af36dd4664 Cleanup: trailing newlines 2018-06-29 08:02:49 +02:00
Sybren A. Stüvel
e36ecb8a66 Alembic unit tests: fixed compiler errors
This doesn't mean the code is correct, but at least it builds.
2018-06-08 14:48:50 +02:00
Campbell Barton
da53c3f020 Merge branch 'master' into blender2.8 2018-06-04 18:50:14 +02:00
Campbell Barton
f6740993f7 Cleanup: strip tests trailing space 2018-06-04 18:47:31 +02:00
Campbell Barton
9a74b60367 Merge branch 'master' into blender2.8 2018-05-27 11:06:29 +02:00
Diego Gangl
4dee702332 Add number and memory size formatting throughout the UI
This commit adds number formatting (thousands separator) to the baking panel. It also adds a new function to format memory sizes (KB/GB/etc) and applies it to the baking panel and scene stats. The new function is unit tested.

Reviewers: Severin
Tags: #user_interface
Differential Revision: https://developer.blender.org/D1248
2018-05-25 22:41:49 +02:00
Campbell Barton
d09920687c Merge branch 'master' into blender2.8 2018-05-02 12:46:14 +02:00
422a325acf Fix build of Alembic test. 2018-04-30 10:04:29 +02:00
Aaron Carlisle
128506eeb1 BLI Color: YUV to/from rgb colorspace option
This commit does two things:

- Adds an option to do the calculation in different color spaces (BT601
or BT709).
- Changes the default caluclation from legacy BT601 to BT709.

This affects several areas:

- UI areas (mainly scopes)
- ViewLevelsNode
- Several other nodes that use `COM_ConvertOperation.h`
2018-04-29 18:00:45 -04:00
34ab90f546 Depsgraph: remove EvaluationContext, pass Depsgraph instead.
The depsgraph was always created within a fixed evaluation context. Passing
both risks the depsgraph and evaluation context not matching, and it
complicates the Python API where we'd have to expose both which is not so
easy to understand.

This also removes the global evaluation context in main, which assumed there
to be a single active scene and view layer.

Differential Revision: https://developer.blender.org/D3152
2018-04-16 19:55:33 +02:00
dfd9e549ee Fix build errors after recent depsgraph changes. 2018-04-16 15:18:48 +02:00
Sergey Sharybin
8ad93dd009 Merge branch 'master' into blender2.8 2018-04-16 10:19:03 +02:00
Sergey Sharybin
5bfe6126f8 Added lock-free single linked list implementation
Only supports lock-free insertion for now, can not delete element
or traverse the list at the same time.
2018-04-16 10:18:43 +02:00
Campbell Barton
2bc952fdb6 Merge branch 'master' into blender2.8 2018-02-18 22:33:05 +11:00
Campbell Barton
deacb3d6b8 Cleanup: add 2d suffix to BLI files
Some of these API's can have 3D versions, explicitly name them 2D.
2018-02-18 21:27:33 +11:00
Sergey Sharybin
df1c88b652 Merge branch 'master' into blender2.8 2018-02-15 14:15:55 +01:00
Campbell Barton
ccdacf1c9b Cleanup: use '_len' instead of '_size' w/ BLI API
- When returning the number of items in a collection use BLI_*_len()
- Keep _size() for size in bytes.
- Keep _count() for data structures that don't store length
  (hint this isn't a simple getter).

See P611 to apply instead of manually resolving conflicts.
2018-02-15 23:39:08 +11:00
Campbell Barton
88bd994a37 Merge branch 'master' into blender2.8 2018-02-14 16:04:07 +11:00
Campbell Barton
b48815a9b7 Cleanup: use prefix for tests
Allows for running all `bmesh_*` or `object_*` tests.
2018-02-14 16:02:21 +11:00
Campbell Barton
c850320b35 Merge branch 'master' into blender2.8 2018-01-19 17:21:15 +11:00
Campbell Barton
7a24e0d175 Cleanup: typos 2018-01-19 15:34:54 +11:00
27dff3fbc1 Merge branch 'master' into blender2.8 2018-01-18 01:01:17 +01:00
a6700362c7 Memory: add MEM_malloc_arrayN() function to protect against overflow.
Differential Revision: https://developer.blender.org/D3002
2018-01-17 19:59:47 +01:00
Bastien Montagne
a786baa193 Merge branch 'master' into blender2.8 2017-11-23 21:36:27 +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
Dalai Felinto
3abe8b3292 Rename any instance of scene layer or render layer in code with view layer
The RenderResult struct still has a listbase of RenderLayer, but that's ok
since this is strictly for rendering.

* Subversion bump (to 2.80.2)
* DNA low level doversion (renames) - only for .blend created since 2.80 started

Note: We can't use DNA_struct_elem_find or get file version in init_structDNA,
so we are manually iterating over the array of the SDNA elements instead.

Note 2: This doversion change with renames can be reverted in a few months. But
so far it's required for 2.8 files created between October 2016 and now.

Reviewers: campbellbarton, sergey

Differential Revision: https://developer.blender.org/D2927
2017-11-23 07:48:23 -02:00
Sergey Sharybin
d325e6f0e8 Depsgraph: Make dependency graph to be built from scene layer
This is a final step of having proper ownership. Now selecting different
layers in the "top bar" will actually do what this is expected to do.

Surely, there are still things to be done under the hood, that will happen
in a less intrusive way.
2017-11-09 11:20:17 +01:00
Sergey Sharybin
e72dfee66f Depsgraph: Use explicit depsgraph in alembic module 2017-11-03 12:02:39 +01:00
Sybren A. Stüvel
f7d59fbc46 Merge branch 'master' into blender2.8
# Conflicts:
#	tests/gtests/alembic/abc_export_test.cc
2017-11-02 14:37:10 +01:00
Sybren A. Stüvel
8a3728800c Alembic: not using global in unit test.
Thanks @sergey for pointing out this fix.
2017-11-02 14:33:21 +01:00
Sybren A. Stüvel
405980b1fa Merge branch 'master' into blender2.8
# Conflicts:
#	source/blender/alembic/intern/abc_exporter.cc
#	source/blender/alembic/intern/abc_exporter.h
#	source/blender/alembic/intern/alembic_capi.cc
#	tests/gtests/alembic/abc_export_test.cc
2017-10-29 15:38:55 +01:00
Sybren A. Stüvel
89eb05a890 Alembic: exporting MetaBalls as mesh
- Only basis balls are exported, as they represent the resulting mesh.
  As a result the mesh is written to Alembic using the name of the basis
  ball.
- MetaBalls are converted to a mesh on every frame, then an
  AbcMeshWriter is used to write that mesh to Alembic.
2017-10-29 15:21:36 +01:00
Sybren A. Stüvel
7530c54c3c Merge branch 'master' into blender2.8 2017-10-29 15:14:04 +01: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
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
4af1af70ad BLI_hash: add BLI_heap_reinsert
Allows avoiding remove/insert calls.
2017-10-29 04:42:58 +11:00
Campbell Barton
b84e3dc7f3 GTest: initial BLI_heap test 2017-10-29 00:56:56 +11:00