Commit Graph

72 Commits

Author SHA1 Message Date
dd129125b6 GHash: ensure function, avoids multiple lookups 2015-04-06 20:33:02 +10:00
cfdd27381c GHash - code reorganization, performance enhancements, add a few missing utils to API.
This patch is the root of the GHash rework, all other diff will be based on it:

Reduce average load from 3.0 to 0.75
----------------------------------

This is the big performance booster part, e.g. makes tracing a dyntopo stroke between 25% and 30% faster.

Not much to say about it, aside that it obviously increase memory footprint (about 25% - 30% too).

Add optional shrinking
----------------------------------

I.e. ghashes/gsets can now shrink their buckets array when you remove enough entries. This remains optional and OFF by default.

Add code to use masking instead of modulo
----------------------------------

Buckets indices are obtained from hashes by “reducing” the hash value into the valid bucket range. This can be done either by bit-masking, or using modulo operation.
The former is quicker, but requires real hashes, while the later is slower (average 10% impact on ghash operations) but can also be used as a 'fake' hashing on raw values, like e.g. indices.

In Blender currently not all ghash usages actually hash their keys, so we stick to modulo for now (masking is ifdef’ed out), we may however investigate the benefits of switching to masking with systematic very basic hashing later…

Add various missing API helpers
----------------------------------

I.e. a way to deep-copy a ghash/gset, and a way to (re-)reserve entries (i.e. manually grow or shrink the ghash after its creation).

Various code refactoring
----------------------------------

* Get rid of the 'hack' regarding ghash size when used as gset (it’s simpler and safer to have two structs defined here, and cast pointers as needed).
* Various re-shuffle and factorization in low-level internal code.
* Some work on hashing helpers, introducing some murmur2a-based hashing too.

Thanks a bunch to Campbell for the extensive review work. :)

Reviewers: sergey, campbellbarton

Subscribers: psy-fi, lukastoenne

Projects: #bf_blender

Maniphest Tasks: T43766

Differential Revision: https://developer.blender.org/D1178
2015-03-19 17:37:54 +01:00
b09563ca8c Cleanup: fixes for building with recent clang 2015-01-14 05:11:20 +11:00
15bde0dbea Docs: comments (hash table & beauty fill) 2014-12-17 09:58:23 +01:00
171a6bb5dc Fix T42488: Knife (selected_only + occlude) failed 2014-12-09 15:51:58 +01:00
6f2f80887b GHash: use bool for comparison (simplify compare) 2014-09-25 06:16:37 +10:00
6be4b39526 GHash: add flag get/set for gset 2014-08-12 13:29:40 +10:00
ce0ff266e9 GHash: generic comparison for int[4] 2014-07-30 07:30:18 +10:00
8554fa2fad GHash, EdgeHash: add debugging function to measure the hash quality
Can use to check on improvements to hash functions.
2014-07-14 23:59:47 +10:00
a82d3f85c6 Correct casts for IS_EQ and other macro tweaks
- ensure GET_INT_FROM_POINTER us only used to get values
- rename STACK_POP_ELSE -> STACK_POP_DEFAULT
2014-06-18 14:02:41 +10:00
365ff66987 GSet, GHash: Add BLI_gset_add, since its common to add members to a set
also rename BLI_edgeset_reinsert -> BLI_edgeset_add, in this case its the same.
2014-06-14 00:47:12 +10:00
9bff19fbfd GHash, Edgehash: add lookup_default() funcs.
Returns a fallback argument when the key isn't found.
2014-04-22 01:36:59 +10:00
aa10cf7f5c GHash: add BLI_ghashutil_uinthash_v4 for hashing 4 ints at once 2014-04-15 14:40:33 +10:00
a7241d09cd GHash: add typed hash functions (were all (void *))
- BLI_ghashutil_strhash_n takes string length, to avoid terminating the string before hashing.
- BLI_ghashutil_inthash/uinthash take ints, to avoid casting to (void *)

This also showed up incorrect use of inthash, which was using a pointer.
2014-04-15 14:22:36 +10:00
5580afb5df GHash/Edgehash: make simple iterator checking functions inline.
also remove NULL check, only a few areas made use of this.
2014-04-08 15:50:38 +10:00
d59b4752e4 add hash iterator functions to access the pointer to the value. 2013-09-02 02:58:53 +00:00
75a2b5ee35 add attributes to ghash and edgehash functions. 2013-09-01 22:47:44 +00:00
8ef934c73f ghash/bli-listbase edits, rename BLI_ghash_pop -> BLI_ghash_popkey (since it takes a key as an arg and isnt popping any element from the hash as you might expect).
add BLI_pophead/tail, since getting the first element from a list and removing it is a common task.
2013-08-26 23:37:08 +00:00
1d5eff36f5 BKI_gset and EdgeSet api, use when hash values aren't used (reuses ghash internally without allocating space for the value). 2013-08-25 20:00:19 +00:00
df01ad250e move doxy docs out of the ghash header into the C file. 2013-08-25 16:28:48 +00:00
e2bd3a4644 clearing the mempool can now keep more then a single element reserved. 2013-08-25 16:16:38 +00:00
7c65015ab8 use ints for ghash/edgehash flags, since its allocated theres not much point to try save a few bytes here. 2013-08-24 20:16:14 +00:00
4b1fc0593e add versions of BLI_ghash_int_new, BLI_ghash_str_new, etc. that take a reserve argument. 2013-08-24 15:14:50 +00:00
9c090cecfe ghash and edgehash api, allow newly defined hashes to take in the size of the hash as an arg (avoids resizing in simple cases when the hash is created and filled immediately). 2013-08-24 13:04:03 +00:00
52eb61f84b Fix state losses for recursive outliner trees (e.g. datablocks editor)
In previous optimization in outliner I assumed that order in treehash was not important.
But testing outliner in datablocks mode revealed a problem: when user expands multiple recursive levels and then closes any element, it always closed the top level of recursion.
Now it should work fine with recursive trees.
Now treehash contains groups of elements indexed by (id,nr,type). Adding an element with the same (id,nr,type) results in appending it to existing group. No duplicates are possible in treehash.
This commit should also make lookups a little bit faster, because searching in small arrays by "used" is faster than searching in hashtable with duplicates by "id,nr,type,used".
2013-08-23 20:35:00 +00:00
a31db0c7e9 rename recently added BLI_ghash_assign() -> BLI_ghash_reinsert() 2013-08-21 16:06:03 +00:00
754b4ab3bc add hash function BLI_ghash_assign, BLI_edgehash_assign
avoids remove,insert and only hashes the key once.
2013-08-18 03:41:39 +00:00
ee2d95f850 minor api cleanup for ghash/edgehash
- use single inlined lookup function.
- move comments into source.
- pack iterator vars more efficiently.
2013-08-18 01:00:52 +00:00
fbb446dff6 add assert for hashes if an existing element is ever inserted into a ghash/edgehash.
the outliner does this intentionally, so add a flag to allow this situation optionally.
2013-08-18 00:36:04 +00:00
22dae3e600 fix for BLI_ghash_clear from Sv. Lockal (lockal) 2013-07-31 20:50:55 +00:00
2efea8cf03 reduce sign comparisons for ghash and add more strict warnings for gcc. 2013-06-20 19:39:29 +00:00
0ff22044cd Support for bridge tool subdivisions, smoothing and shape along the profile.
also added the underlying subdivision as a standalone operator in the edge menu, named: subdivide edge-ring.
http://www.graphicall.org/ftp/ideasman42/bridge_subd.png
2013-05-23 06:19:04 +00:00
a9fb183901 rename BLI_ghashIterator_notDone() -> BLI_ghashIterator_done()
was renamed fairly recently but other similar iterators not negated
	like this, would prefer to keep it as it was
2013-05-08 12:58:11 +00:00
3b341068ba warn of sign conversions for low level apis - ghash, heap, mempool 2013-05-08 12:55:51 +00:00
Lukas Toenne
4638e5f99a Merge of the PyNodes branch (aka "custom nodes") into trunk.
PyNodes opens up the node system in Blender to scripters and adds a number of UI-level improvements.

=== Dynamic node type registration ===
Node types can now be added at runtime, using the RNA registration mechanism from python. This enables addons such as render engines to create a complete user interface with nodes.

Examples of how such nodes can be defined can be found in my personal wiki docs atm [1] and as a script template in release/scripts/templates_py/custom_nodes.py [2].

=== Node group improvements ===
Each node editor now has a tree history of edited node groups, which allows opening and editing nested node groups. The node editor also supports pinning now, so that different spaces can be used to edit different node groups simultaneously. For more ramblings and rationale see (really old) blog post on code.blender.org [3].

The interface of node groups has been overhauled. Sockets of a node group are no longer displayed in columns on either side, but instead special input/output nodes are used to mirror group sockets inside a node tree. This solves the problem of long node lines in groups and allows more adaptable node layout. Internal sockets can be exposed from a group by either connecting to the extension sockets in input/output nodes (shown as empty circle) or by adding sockets from the node property bar in the "Interface" panel. Further details such as the socket name can also be changed there.

[1] http://wiki.blender.org/index.php/User:Phonybone/Python_Nodes
[2] http://projects.blender.org/scm/viewvc.php/trunk/blender/release/scripts/templates_py/custom_nodes.py?view=markup&root=bf-blender
[3] http://code.blender.org/index.php/2012/01/improving-node-group-interface-editing/
2013-03-18 16:34:57 +00:00
221a383366 use 'bool' for BLI_/BKE_ functions. 2013-03-09 05:35:49 +00:00
53b7bc8f1f Change !BLI_ghashIterator_isDone to BLI_ghashIterator_notDone. It is
always used in that context so we can at least avoid reverting it twice
:p.
2013-03-06 20:55:04 +00:00
0d5b028d43 patch [#34103] use boolean in path functions and add comments.
path_util_1.patch from Lawrence D'Oliveiro (ldo)
2013-03-04 19:27:51 +00:00
ebaf1306b8 bmesh operator api:
avoid per vert/edge/face string lookups in BMO_slot_map_* functions --- used in array modifier, subdivide, remove doubles and other tools.
2012-11-20 13:29:27 +00:00
4f90d757c7 add BLI_ghash_pop() which returns the value for a key and removes it at the same time, saves a lookup if you need to check if the item exists before removing. 2012-05-28 19:33:14 +00:00
ed33320e3f Code cleanup: simplify standard GHash creation.
Added four new functions as shortcuts to creating GHashes that use the
standard ptr/str/int/pair hash and compare functions.

GHash *BLI_ghash_ptr_new(const char *info);
GHash *BLI_ghash_str_new(const char *info);
GHash *BLI_ghash_int_new(const char *info);
GHash *BLI_ghash_pair_new(const char *info);

Replaced almost all occurrences of BLI_ghash_new() with one of the
above functions.
2012-05-16 00:51:36 +00:00
9892736206 code cleanup: header cleanup and remove some duplicate defines. 2012-05-12 20:39:39 +00:00
68d9e73ecd Fix: forgot to commit these files as part of strand bugfix. 2012-05-04 12:46:51 +00:00
5979893711 style cleanup: edits to convex hull. 2012-04-30 10:39:35 +00:00
650edc90b1 Add GHASH_ITER macro 2012-04-29 16:09:28 +00:00
7bbf4b7831 style cleanup
- spelling - turns out we had tessellation spelt wrong all over.
- use \directive for doxy (not @directive)
- remove BLI_sparsemap.h - was from bmesh merge IIRC but entire file commented and not used.
2012-03-02 16:05:54 +00:00
2b7ca2304a unify include guard defines, __$FILENAME__
without the underscores these clogged up the namespace for autocompleation which was annoying.
2012-02-17 18:59:41 +00:00
ad96dacbc5 style edit only - move parenthesis onto second line of function definition (in keeping with most of blenders code)
also split some long lines in own code.
2011-12-17 00:52:36 +00:00
4d6c34462c Fix #29640: make duplicates release keep hierarchy and parent properties not
working for multiple objects.

ID.newid only worked for one object, now it uses a hash instead.
2011-12-16 23:56:18 +00:00
4a04f72069 remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00