Commit Graph

200 Commits

Author SHA1 Message Date
Jacques Lucke 6f985574b7 Cleanup: take includes out of 'extern "C"' blocks
Surrounding includes with an 'extern "C"' block is not necessary anymore.
Also that made it harder to add any C++ code to some headers, or include headers
that have "optional" C++ code like `MEM_guardedalloc.h`.

I tested compilation on linux and windows (and got help from @LazyDodo).
If this still breaks compilation due to some linker error, the header containing
the symbol in question is probably missing an 'extern "C"' block.

Differential Revision: https://developer.blender.org/D7653
2020-05-08 18:22:41 +02:00
Bastien Montagne 17e1fef85a Cleanup: Library: Move to IDTypeInfo, and remove unused BKE API. 2020-03-06 11:27:54 +01:00
Bastien Montagne f3a3a976b7 Refactor: move `Library`-specific functions into proper `BKE_library` file.
Even though we do not have much of those, this might change in the
future, and in any case having specific functions for this ID type in
generic `BKE_lib` area was really confusing.
2020-02-10 17:10:17 +01:00
Bastien Montagne 56116bbdf4 Cleanup/refactor: Rename `BKE_library` files to `BKE_lib`.
Note that `BKE_library.h`/`library.c` were renamed to
`BKE_lib_id.h`/`lib_id.c` to avoid having a too generic name here.

Part of T72604.
2020-02-10 13:00:42 +01:00
Brecht Van Lommel ccfe5bf215 Cleanup: remove redundant function 2020-01-20 13:27:19 +01:00
Brecht Van Lommel 6368343da9 Fix T73129: sculpt mode slow on mesh with fake user
We can't use the fast path when the mesh is used by mulitple objects and so
slower sculpting is expected then. But fake users should not affect this. This
also fixes the same type of error in a few other areas.
2020-01-20 09:39:54 +01:00
Bastien Montagne 46607bc09d ID Management: Improve speed of code used when creating/renaming and ID.
This commit affects `id_sort_by_name()` and `check_for_dupid()` helper:
* Add a new parameter, `ID *id_sorting_hint`, to `id_sort_by_name()`,
  and when non-NULL, check if we can insert `id` immediately before or
  after it. This can dramatically reduce time spent in that function.
* Use loop over whole list in `check_for_dupid()` to also define the
  likely ID pointer that will be neighbor with our new one.

This gives another decent speedup to all massive addition cases:

| Number and type of names of IDs  | old code | new code | speed improvement |
| -------------------------------- | -------- | -------- | ----------------- |
| 40K, mixed (14k rand, 26k const) |      39s |      33s |               18% |
| 40K, fully random                |      51s |      42s |               21% |
| 40K, fully constant              |      40s |      34s |               18% |

Combined with the previous commits, this makes massive addition of IDs more
than twice as fast as previously.
2019-12-20 14:29:35 +01:00
Brecht Van Lommel 659ccd9cd2 Fix T66154: viewlayer hide/exclude settings getting lost for linked collections
The problem was that the object and collection pointers in Base and
LayerCollection would get lost of file read. Normally such ID pointers would
be resolved by pointing to an ID_ID placeholder which has the datablock name,
and then replacing it will the real datablock. However ID_ID is only written
for directly linked datablocks.

This adds the concept of an indirectly linked datablock with a weak reference
to it. For this we write an ID_ID_WEAK_REF code, which is a reference that
will only be resolved if the datablock was read for another reason.

Differential Revision: https://developer.blender.org/D4416
2019-09-19 11:32:35 +02:00
Bastien Montagne 76650402f3 Fix T69931: Materials with keyframes duplicated by 'make single user' are linked.
Another sneaky bite from the infamous private ID data: While those
monsters are not in bmain, the actions used by their animdata are
regular cute little ID's, living with the herd in the safe and sound
Main DB...

So we have to be careful not to propagate the nasty black magic
required to handle the formers when we duplicate their animdata.

Saying it again: private ID datablocks should never have had their own
animdata & actions, this is endless issue also with RNA paths... And
makes copying of animation between materials and such needlessly
complicated.
2019-09-16 23:02:38 +02:00
Bastien Montagne 0ebc76354f DatablockManagement: Cleanup logic of private IDs handling in `BKE_libblock_copy_ex()`.
Now that we have the private ID data flag, we can be more simple *and*
generic here.
2019-09-02 18:39:08 +02:00
Campbell Barton 6eadd40597 Cleanup: redundant struct declarations 2019-08-25 16:45:47 +10:00
Bastien Montagne e18e9aa0d0 Cleanup: Typo in naming (BLE instead of BKE, tssttt). 2019-08-08 17:20:39 +02:00
Campbell Barton cd6b49f995 Cleanup: spelling 2019-07-07 15:38:41 +10:00
Campbell Barton 545610d3aa Cleanup: un-wrap lines in headers, use doxy comments 2019-06-26 12:44:22 +10:00
Bastien Montagne ceed34aac1 Merge branch 'blender2.7'
Conflicts:
	source/blender/blenkernel/intern/library.c
	source/blender/blenloader/intern/readfile.c
	source/blender/editors/screen/screen_edit.c
2019-05-22 23:36:02 +02:00
Bastien Montagne 3600e94eba BKE Library handling: add function to recompute usercounts of IDs.
This will be needed in undo/redo case, since we do not re-read linked
IDs, their usercounts become total garbage (especially in 'used by local
ID' cases)...
2019-05-22 21:08:51 +02:00
Campbell Barton aa42da0385 Cleanup: comments (long lines) in blenkernel 2019-04-27 12:07:07 +10:00
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
Bastien Montagne ac40cf76e5 Cleanup: use default ID type's name instead of generic 'Untitled' for new IDs. 2019-03-06 15:19:29 +01:00
Bastien Montagne 173c023197 Cleanup: rename BKE_library's `new_id()` to `BKE_id_new_name_validate()`.
The former was probably one of the worst function names in our whole
code base, totally misleading, and quiet often used as a variable name too.
2019-03-06 15:19:29 +01: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
Bastien Montagne 5123ee74f8 Cleanup: Remove old deprecated BKE_libblock_copy_nolib() from BKE_library.
Was not used anymore, time to get rid of it.
2019-02-05 10:53:16 +01:00
Bastien Montagne 72724211df BKE_library: add 'no preview' flag to LIB_ID_COPY_LOCALIZE.
No local work copy is expected to need preview data, at least it should
not. Part of copy flags cleanup, done in separate commit in case
something goes wrong here...
2019-02-05 10:53:11 +01:00
Bastien Montagne b26c9dfcb2 Cleanup: initial regrouping of ID create/copy flags.
Those two first sets of flags should represent some common use cases.
The goal here is to reduce verbosity of calls to BKE_id_copy_ex, and
help make it more obvious the 'common behaviours' of ID copying across
codebase.
2019-02-05 09:49:50 +01:00
Bastien Montagne 8ebb8add85 Cleanup: comments before items in enums. 2019-02-05 09:49:50 +01:00
Bastien Montagne 6a686b0bfb Cleanup: BKE_library: rename id_copy to BKE_id_copy.
Time to follow conventions for that one as well.
2019-02-05 09:49:50 +01:00
Bastien Montagne 7636e9785d Cleanup: BKE_library: remove 'test' param of id_copy.
This was used in *one* place only... much better to have a dedicated
helper for that kind of things. ;)
2019-02-05 09:49:50 +01:00
Campbell Barton 4ef09cf937 Cleanup: remove author/date info from doxy headers 2019-02-02 11:58:24 +11:00
Campbell Barton 8c68ed6df1 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 02:40:00 +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
Campbell Barton 475a07cd0c Fix duplicate brushes from recent startup files
Default versioning caused duplicates when the startup was re-saved.

See c305759762
2019-01-29 23:53:37 +11:00
Campbell Barton f8ce24f796 Cleanup: sort forward declarations of enum & struct
Done using:
  source/tools/utils_maintenance/c_sort_blocks.py
2019-01-28 22:12:49 +11:00
Campbell Barton c0f88ed8a8 Cleanup: sort forward declarations of enum & struct
Done using:
  source/tools/utils_maintenance/c_sort_blocks.py
2019-01-28 21:17:58 +11:00
Bastien Montagne ce6d20b54e Add experimental batch IDs deletion.
Main idea is to remove IDs to be deleted from Main, to avoid looping on
them to remove other deleted IDs usage (this is the most expensive
process in ID deletion, by far).

Speed improvements when deleting a large amount of IDs from a Main
containing a lot of them is quite significant, some examples for Objects:
* Removing 1k from 10k: 32% quicker (2.5s to 1.7s).
* Removing 10k from 20k: 60% quicker (59s to 23s).
* Removing 20k from 20k: 99.5% quicker (82s to 0.4s)!

Note however that this process is more risky/touchy, since we by-pass
some safety checks from regular ID removal here.
So will only give access to that code from python API for now (in
separate commit), so that it gets really tested. Also still need to
think about how to hook it up in UI (probably mostly for Outliner),
since we often do higher-level operations there...
2019-01-16 12:02:37 +01:00
Bastien Montagne 01029c68d2 Cleanup: rename BKE_libblock_delete to BKE_id_delete. 2019-01-15 11:09:16 +01:00
Bastien Montagne f55a178db0 Cleanup: rename BKE_libblock_free_us to BKE_id_free_us. 2019-01-15 11:09:16 +01:00
Bastien Montagne c710ca8933 Cleanup: Remove deprecated BKE_libblock_free(_ex) functions, document BKE_id_free(_ex) ones. 2019-01-15 11:09:16 +01:00
Sergey Sharybin a84c823b89 Fix T58652: Crash editing shape keys weirdness with instances
This is a second attempt to get the crash fixed. The original fix
worked, but it was reverted by d3e0d7f082.

Now the logic goes as:

- All pointers which we can not have shared (the ones which are
  owned by the runtime) are cleared.
- The rest of runtime stays untouched.

This seems to be enough to keep particles happy.
2018-12-17 12:33:37 +01:00
Sergey Sharybin d3e0d7f082 Fix broken particle distribution after recent fix 2018-12-14 17:33:54 +01:00
Campbell Barton d6d76759f8 Fix error in Main cleanup
See 481cdb08ed
2018-12-07 15:42:34 +11:00
Sergey Sharybin 3d013f7b10 Fix for assert failure in material preview
All localized datablocks are not supposed to have animation
data associated with them.

There was an easy way to reproduce assert failure: toggle
animation decorator for Viewport Display -> Color.
2018-12-04 12:31:32 +01:00
Dalai Felinto 88d621a68f BKE_id_is_in_gobal_main > BKE_id_is_in_global_main 2018-11-09 10:59:31 -02:00
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
Bastien Montagne 08a92d8578 UI/Unique ID name: add library ID name if present.
Also reshuffle a bit that whole code, did some renaming,
`BKE_id_to_unique_string_key()` is now using same base code (instead of
using whole library filepath...), etc.
2018-10-31 13:34:06 +01:00
Brecht Van Lommel e1178266e7 Workspace: support reordering of workspaces from RMB menu.
Drag and drop will follow later, it's a bit complicated to make this work
reliable in the current UI code.
2018-09-11 12:43:28 +02:00
Bastien Montagne faafe6e6bc Add helper to BKE_library to generate unique string key for an ID.
Basically just concatenates ID's name (including its IDtype code) and
that library's name, if any. This must give unique string in a given
Main database, suitable for GHash keys e.g.
2018-08-23 08:46:07 +02:00
Bastien Montagne e680a9d80d Cleanup LIB_ID_COPY_ flags a bit, add missing comment. 2018-08-06 11:49:42 +02:00
Bastien Montagne 646412004b Merge branch 'master' into blender2.8
Conflicts:
	source/blender/makesrna/intern/rna_image.c
	source/blender/makesrna/intern/rna_object.c
	source/blender/makesrna/intern/rna_object_force.c
	source/blender/makesrna/intern/rna_screen.c
	source/blender/makesrna/intern/rna_sculpt_paint.c
	source/blender/makesrna/intern/rna_space.c
	source/blender/python/bmesh/bmesh_py_types.c
	source/blender/python/generic/bpy_internal_import.h
	source/blender/python/intern/bpy_rna_anim.c
	source/blender/python/intern/gpu_offscreen.c
2018-06-22 12:46:16 +02:00
Bastien Montagne 1870a1adc7 BKE_library: Add func to check an ID is actually in G_MAIN database. 2018-06-22 11:37:08 +02:00