Commit Graph

132 Commits

Author SHA1 Message Date
Campbell Barton 5de109cc2d Remove G.relbase_valid
In almost all cases there is no difference between `G.relbase_valid`
and checking `G.main->filepath` isn't an empty string.

In many places a non-empty string is already being used instead of
`G.relbase_valid`.

The only situation where this was needed was when saving from
`wm_file_write` where they temporarily became out of sync.
This has been replaced by adding a new member to `BlendFileWriteParams`
to account for saving an unsaved file for the first time.

Reviewed By: brecht

Ref D13564
2021-12-16 11:41:46 +11:00
Campbell Barton a207c1cdaf Cleanup: resolve parameter mis-matches in doc-strings
Renamed or removed parameters which no longer exist.
2021-12-14 18:35:23 +11:00
Campbell Barton 8ad2642c47 Cleanup: use "filepath" term for Main, BlendFileData & FileGlobal
Use "filepath" which is the current convention for naming full paths.

- Main use "name" which isn't obviously a file path.
- BlendFileData & FileGlobal used "filename" which is often
  used for the name component of a path (without the directory).
2021-12-13 16:22:19 +11:00
Campbell Barton ffc4c126f5 Cleanup: move public doc-strings into headers for 'blenkernel'
- Added space below non doc-string comments to make it clear
  these aren't comments for the symbols directly below them.
- Use doxy sections for some headers.
- Minor improvements to doc-strings.

Ref T92709
2021-12-07 17:38:48 +11:00
Germano Cavalcante a84f1c02d2 Assets: Snapping with visual feedback while dragging
The drag and drop feature of objects in 3D View has been modified to include:
- Snap the object being dragged.
- Visual feedback through a box and the placement tool grid.

Maniphest Tasks: T90198

Differential Revision: https://developer.blender.org/D12912
2021-10-25 11:57:26 -03:00
Campbell Barton 9c8255d486 Cleanup: use 'e' prefix for enum types 2021-10-19 18:35:39 +11:00
Bastien Montagne b7dc0346aa BMain: Add utils to check if a Main is empty or not.
Mostly intended for debug code (asserts).
2021-10-06 16:53:20 +02:00
Bastien Montagne 794c2828af Initial implementation of local ID re-use when appending.
This commit adds to ID struct a new optional 'weak reference' to a
linked ID (in the form of a blend file library path and full ID name).

This can then be used on next append to try to find a matching local ID
instead of re-making the linked data local again.

Ref. T90545

NOTE: ID re-use will be disabled for regular append for the time being
(3.0 release), and only used for assets. Therefore, this commit should
not change anything user-wise.

Differential Revision: https://developer.blender.org/D12545
2021-09-22 16:55:39 +02:00
Bastien Montagne db4fe8e322 BlenRead: Add GHash-based search for already read linked IDs.
Ths commit adds a new `IDNameLibMap` to `Main`, used during file reading
to quickly find already read linked IDs.

Without that, search would use string-based search over list of linked
data, which becomes extremely slow and inneficient in cases where a lot
of IDs are linked from a same library. See also {T89194}.

Extrem-usecase reported in T89194 is now about 4 times faster in linked
data reading (about 2 times faster for the whole .blend file loading).

More normal cases (like Sprites studio production files) have barely
measurable speed improvements, a few percents at best.

NOTE: `main_idmap` API was extended to support insertion and removal of
IDs from the mapping, avoids having to re-create the whole thing several
time during libraries expansion in readcode.

Differential Revision: https://developer.blender.org/D11757
2021-07-27 14:53:49 +02:00
Campbell Barton 9b89de2571 Cleanup: consistent use of tags: NOTE/TODO/FIXME/XXX
Also use doxy style function reference `#` prefix chars when
referencing identifiers.
2021-07-04 00:43:40 +10:00
Bastien Montagne 63b7ff9f4e Cleanup: Main `foreach ID` code: Remove `MAX_LIBARRAY` and improve comments.
The `MAX_LIBARRAY` define was an annoying doublon to the `INDEX_ID_MAX` enum value
now defined in `DNA_ID.h`, and it is no more useful.

And comments were somewhat outdated. Also added an explanation about
chosen order for the `INDEX_ID_<IDTYPE>` order.
2021-03-04 18:43:30 +01:00
Bastien Montagne 4ff5051ffc BKE BMain relations: add utils to (re)set tags of the entries. 2021-02-02 17:26:59 +01:00
Bastien Montagne 131a758b6f Refactor BMain relations temp data.
`bmain.relations` is used to store temp data of relations between IDs,
to speed-up some complex processes heavily relying on such information.

Previous implementation was failry unclear/confusing, and required a
not-so-nice hack to 'tag' some ID as processed.

New code changes as such:
* Using `from`/`to` naming (instead of `user`/`used`).
* More clear separation between `to` `id_pointer` and `from` one,
  using an union instead of hacking around difference between `ID *` and
  `ID **` pointers.
* Adds storage of `session_uuid` informations (mainly useful as
  debug/ensuring proper consistency of data currently).
* Adds a structure per ID in the mapping. This enables possibility of
  storing tags (and potentially more  data in the future) per-ID,
  without polluting the IDs themselves with very short-life info.

Differential Revision: https://developer.blender.org/D10164
2021-01-22 16:05:17 +01:00
Hans Goudey e9ddb21df3 Cleanup: Grammar: "Allow to" vs gerund missed in last commit 2020-11-18 16:31:26 -05:00
Harley Acheson 3a7fd309fc Spelling: It's Versus Its
Corrects incorrect usage of contraction for 'it is', when possessive 'its' was required.

Differential Revision: https://developer.blender.org/D9250

Reviewed by Campbell Barton
2020-10-19 08:12:33 -07:00
Sebastian Parborg 2115232a16 Cleanup: Clang-Tidy readability-inconsistent-declaration-parameter-name fix
No functional changes
2020-09-04 21:04:16 +02:00
Jacques Lucke 91694b9b58 Code Style: use "#pragma once" in source directory
This replaces header include guards with `#pragma once`.
A couple of include guards are not removed yet (e.g. `__RNA_TYPES_H__`),
because they are used in other places.

This patch has been generated by P1561 followed by `make format`.

Differential Revision: https://developer.blender.org/D8466
2020-08-07 09:50:34 +02:00
Bastien Montagne b723d38812 Add utils to remove an ID from the relations runtime data in Main. 2020-06-29 17:28:04 +02:00
Brecht Van Lommel c93a88413d Merge branch 'blender-v2.83-release' 2020-05-29 18:05:04 +02:00
Brecht Van Lommel a86b5df005 Blender: change bugfix release versioning from a/b/c to .1/.2/.3
The file subversion is no longer used in the Python API or user interface,
and is now internal to Blender.

User interface, Python API and file I/O metadata now use more consistent
formatting for version numbers. Official releases use "2.83.0", "2.83.1",
and releases under development use "2.90.0 Alpha", "2.90.0 Beta".

Some Python add-ons may need to lower the Blender version in bl_info to
(2, 83, 0) or (2, 90, 0) if they used a subversion number higher than 0.
https://wiki.blender.org/wiki/Reference/Release_Notes/2.83/Python_API#Compatibility

This change is in preparation of LTS releases, and also brings us more
in line with semantic versioning.

Fixes T76058.

Differential Revision: https://developer.blender.org/D7748
2020-05-29 17:48:26 +02:00
Campbell Barton 20c25bffda Merge branch 'blender-v2.83-release' 2020-05-15 17:47:58 +10:00
Campbell Barton 6a850f3cc8 Fix duplicate ID's being created when appending/linking
This removes grease pencil brush creation/dat-block delete on load,
since this causes duplicate data-blocks.

Add assert to prevent this happening in the future
since the error is isn't obvious.
2020-05-15 17:42:01 +10:00
Jacques Lucke eb4e3bbe68 Simulations: Add new simulation data block
This data block will be the container for simulation node trees.
It will be used for the new particle node system (T73324).

The new data block has the type `ID_SIM`.
It is not visible to users and other developers by default yet.
To enable it, activate the cmake option `WITH_NEW_SIMULATION_TYPE`.

New simulation data blocks can be created by running `bpy.data.simulations.new("name")`.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D7225
2020-04-20 10:45:18 +02:00
Campbell Barton 9fe0505db0 Cleanup: macro hygiene, parenthesize arguments 2020-04-05 13:53:32 +10:00
Brecht Van Lommel b0a1cf2c9a Objects: add Volume object type, and prototypes for Hair and PointCloud
Only the volume object is exposed in the user interface. It is based on OpenVDB
internally. Drawing and rendering code will follow in another commit.
https://wiki.blender.org/wiki/Source/Objects/Volume
https://wiki.blender.org/wiki/Reference/Release_Notes/2.83/Volumes

Hair and PointCloud object types are hidden behind a WITH_NEW_OBJECT_TYPES
build option. These are unfinished, and included only to make it easier to
cooperate on development in the future and avoid tricky merges.
https://wiki.blender.org/wiki/Source/Objects/New_Object_Types

Ref T73201, T68981

Differential Revision: https://developer.blender.org/D6945
2020-03-18 11:23:05 +01:00
Bastien Montagne b852db57ba Add experimental global undo speedup.
The feature is hidden behind an experimental option, you'll have to
enable it in the preferences to try it.

This feature is not yet considered fully stable, crashes may happen, as
well as .blend file corruptions (very unlikely, but still possible).

In a nutshell, the ideas behind this code are to:
* Detect unchanged IDs across an undo step.
* Reuse as much as possible existing IDs memory, even when its content
  did change.
* Re-use existing depsgraphs instead of building new ones from scratch.
* Store accumulated recalc flags, to avoid needless re-compute of things
  that did not change, when the ID itself is detected as modified.

See T60695 and D6580 for more technical details.
2020-03-17 15:02:05 +01:00
Bastien Montagne ad9b919962 Cleanup: protect parameters of `FOREACH_MAIN_ID` & co macros. 2020-02-18 14:38:33 +01:00
Bastien Montagne d4e38d99b2 libquery: add optional handling of 'UI' ID pointers.
Handling those through different ways /might/ be needed sometimes, but
in most case this is just a nest of issues, since you can easily forget
to take them into account.

Note that this should be a 'non-functional' change, as this new behavior
is not used anywhere yet.
2020-02-18 11:22:32 +01:00
Bastien Montagne cd48b132ff Cleanup: Add basic doc about each `BKE_main` and `BKE_lib` files.
Including expected prefixes for functions in those files.

Part of T72604.
2020-02-10 15:05:54 +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
Campbell Barton 79b703bb63 Fix T69822: Switching sculpt objects breaks undo
This introduces object mode tagging for data which hasn't yet been
written back to the ID data.

Now when selecting other sculpt objects, the original objects data is
flushed back to the ID before writing a memfile undo step.
2019-11-07 16:56:21 +11:00
Campbell Barton 6eadd40597 Cleanup: redundant struct declarations 2019-08-25 16:45:47 +10:00
Campbell Barton aa42da0385 Cleanup: comments (long lines) in blenkernel 2019-04-27 12:07:07 +10:00
Campbell Barton 2fb9c8ef12 Cleanup: add missing macros to clang-format 2019-04-21 04:40:16 +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 07355ff74b Fix mistake in previous commit. 2019-03-18 11:42:35 +01:00
Bastien Montagne d0e28721b0 Cleanup: Main id looping: add FOREACH_MAIN_LISTBASE macro.
We don't want to use flow control like `break` statement into the basic
`FOREACH_MAIN_ID` macro, as this is a nested loop.

When refined behavior is needed (like breaking whole iteration, or just
skipping to next ID type), FOREACH_MAIN_LISTBASE and
FOREACH_MAIN_LISTBASE_ID macros should be used instead.

Based on D4382 by @campbellbarton
(Other potential solution, using flow control macros: D4384).
2019-03-18 11:36:50 +01:00
Campbell Barton 8f817de0cb Cleanup: use plural names for Main lists
Convention was not to but after discussion on 918941483f we agree its
best to change the convention.

Names now mostly follow RNA.

Some exceptions:

- Use 'nodetrees' instead of 'nodegroups'
  since the struct is called NodeTree.
- Use 'gpencils' instead of 'grease_pencil'
  since 'gpencil' is a common abbreviation in the C code.

Other exceptions:

- Leave 'wm' as it's a list of one.
- Leave 'ipo' as is for versioning.
2019-03-08 09:50:00 +11:00
Campbell Barton 918941483f Cleanup: Main struct member names
Rename latt to lattice and don't use plural names.
2019-02-27 11:14:41 +11:00
Campbell Barton 3051e2f4ae DNA: rename Lamp -> Light
- BKE_lamp -> BKE_light
- Main.lamp -> light
2019-02-27 11:03:16 +11:00
Bastien Montagne 4c2330bd53 BKE_main: FOREACH macros: fix shadowing 'i' variable. 2019-02-18 17:16:33 +01:00
Bastien Montagne 614a0a47e5 BKE_main: make FOREACH new macros working when deleting some IDs. 2019-02-18 17:16:33 +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
Bastien Montagne fa7149893a Cleanup: replace Main ID's foreach functions by macros.
Am really no a big fan of using macros for that kind of things, but
meh... C solution to do that with functions (using callbacks) is
even worse. :(
2019-02-14 16:26:32 +01:00
Campbell Barton 1724ff29e0 readfile: skip negative sized thumbnails
We may want to use 'TEST' BCode in the future for including data
besides thumbnails. This allows negative values to be used w/o
attempting to load a thumbnail.
2019-02-11 19:09:27 +11:00
Bastien Montagne 6ba8e71fa2 BKE_main: add a util to generate/extend a GSet with all ID pointers of a Main database. 2019-02-08 18:53:09 +01:00
Bastien Montagne 599561de84 BKE_main: add utils to loop over whole IDs of a given Main database.
We are currently having the same boiler plate code in tens of places
accross our code, we can as well have a utils to do that.
2019-02-07 20:46:41 +01: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 4ef09cf937 Cleanup: remove author/date info from doxy headers 2019-02-02 11:58:24 +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