Fix segmentation fault that can occur when reordering animation
channels.
Under some specific conditions, the list "act->curves" is empty in the
"join_groups_action_temp" function. In particular, this happens when a
scene contains an action that has not been pushed down, and with no
keyframe in it.
Reviewed By: sybren
Differential Revision: https://developer.blender.org/D11569
While this preprocessing does take some time upfront,
it avoids longer lookup later on, especially as nodes get
more sockets.
It's probably possible to make this more efficient in some cases
but this is good enough for now.
Scanline processor did its own heurestic what didn't scale well when
having a multiple cores. In stead of using our own code this patch will
leave it to TBB to determine how to split the scanlines over the
available threads.
Performance of the IMB_transform before this change was 0.002123s, with
this change 0.001601s. This change increases performance in other areas
as well including color management conversions.
Reviewed By: zeddb
Differential Revision: https://developer.blender.org/D11578
When using large sequences including audio the drawing of the audio on
top of the strip takes a lot of time. This effects the playback
performance heavily.
During the animation playback performance there was a solution for this
by only drawing the playhead overlay. This was reverted for the sequence
editor as it didn't update the color strips when they were animated.
This patch checks if there are animated color strips if so the full
screen is redrawn, otherwise only the playhead is redrawn.
Reviewed By: ISS
Differential Revision: https://developer.blender.org/D11580
One drawback to trying to predict the number of threads that will be
used in the `task_graph` is that we are only sure of the number when the
threads are running.
Using `BLI_task_parallel_range` allows the driver to
choose the best thread distribution through `parallel_reduce`.
The benefit is most evident on hardware with fewer cores.
This is the result on an 4-core laptop:
||before:|after:
|---|---|---|
|large_mesh_editing:|Average: 5.203638 FPS|Average: 5.398925 FPS
||rdata 15ms iter 43ms (frame 193ms)|rdata 14ms iter 36ms (frame 187ms)
Differential Revision: https://developer.blender.org/D11558
This is an adaptation of {D11488}.
A disadvantage of manually setting the iter ranges per thread is that
we don't know how many threads are running in the background and so we
don't know how to best distribute the ranges.
To solve this limitation we can use `parallel_reduce` and thus let the
driver choose the best distribution of ranges among the threads.
This proved to be especially beneficial for computers with few cores.
**Benchmarking:**
Here's the result on an 4-core laptop:
||master:|PATCH:
|---|---|---|
|large_mesh_editing:|Average: 5.203638 FPS|Average: 5.398925 FPS
||rdata 15ms iter 43ms (frame 193ms)|rdata 14ms iter 36ms (frame 187ms)
Here's the result on an 8-core PC:
||master:|PATCH:
|---|---|---|
|large_mesh_editing:|Average: 15.267482 FPS|Average: 15.906881 FPS
||rdata 9ms iter 28ms (frame 65ms)|rdata 9ms iter 25ms (frame 63ms)
|large_mesh_editing_ledge: |Average: 15.145966 FPS|Average: 15.520474 FPS
||rdata 9ms iter 29ms (frame 65ms)|rdata 9ms iter 25ms (frame 64ms)
|looptris_test:|Average: 4.001917 FPS|Average: 4.061105 FPS
||rdata 12ms iter 90ms (frame 236ms)|rdata 12ms iter 87ms (frame 230ms)
|subdiv_mesh_cage_and_final:|Average: 1.917769 FPS|Average: 1.971790 FPS
||rdata 7ms iter 37ms (frame 261ms)|rdata 7ms iter 31ms (frame 258ms)
||rdata 7ms iter 38ms (frame 252ms)|rdata 7ms iter 33ms (frame 249ms)
|subdiv_mesh_final_only:|Average: 6.387240 FPS|Average: 6.591251 FPS
||rdata 3ms iter 25ms (frame 151ms)|rdata 3ms iter 16ms (frame 145ms)
|subdiv_mesh_final_only_ledge:|Average: 6.247393 FPS|Average: 6.596024 FPS
||rdata 3ms iter 26ms (frame 158ms)|rdata 3ms iter 16ms (frame 148ms)
**Notes:**
- The improvement can only be noticed if all extracts are multithreaded.
- This patch touches different areas of the code, so it can be split into another patch if the idea is accepted.
These screenshots show how threads behave in a quadcore:
Master:
{F10164664}
Patch:
{F10164666}
Differential Revision: https://developer.blender.org/D11558
Move `WorkSpace.active_pose_asset_index` and `WindowManager.pose_assets`
from Blender to the Pose Library add-on. Since that add-on is the only
code using them, they belong there.
Configure the build pipeline to use the `asset-browser-poselib` addons
branch. This makes the `pose_library` addon available.
This change is similar to rB15a791d85cb29abc5f775c1aa57c5433cea0d958.
Add a call to orthogonalize the matrix before processing for the
same reasons as D8915, and an early exit in case no limits are
enabled for a bit of extra efficiency.
Since the constraint goes through Euler decomposition, it would
in fact remove shear even before this change, but the resulting
rotation won't make much sense.
This change allows using the constraint without any enabled limits
purely for the purpose of efficiently removing shear.
Differential Revision: https://developer.blender.org/D9626
Since Limit Rotation is based on Euler decomposition, it should allow
specifying the order to use for the same reasons as Copy Rotation does,
namely, if the bone uses Quaternion rotation for its animation channels,
there is no way to choose the order for the constraint.
Ref D9626
Fixed the logic for seeking in ffmpeg video files.
The main fix is that we now apply a small offset in ffmpeg_get_seek_pos
to make sure we don't get the frame in front of the seek position when
seeking backward.
The rest of the changes is general cleanup and untangling code.
Reviewed By: Richard Antalik
Differential Revision: http://developer.blender.org/D11492
Due to the way we ship the CRT on windows TBB's
malloc proxy was unable to attach it self to
the memory management functions on windows 10.
This change moves ucrtbase.dll out of the blender.crt
folder and back into the main blender folder to side
step some undesirable behaviour on win10 making TBB
once more able to attach it self.
Having this work again, should give a speed
boost in memory allocation heavy workloads
such as mantaflow.
For details on how this only failed on Win10
see T88813
This patch exposes functionality for performing partial mesh updates
for normal calculation and face tessellation while transforming a mesh.
The partial update data only needs to be generated once,
afterwards the cached connectivity information can be reused
(with the exception of changing proportional editing radius).
Currently this is only used for transform, in the future it could be
used for other operators as well as the transform panel.
The best-case overall speedup while transforming geometry is about
1.45x since the time to update a small number of normals and faces is
negligible.
For an additional speedup partial face tessellation is multi-threaded,
this gives ~15x speedup on my system (timing tessellation alone).
Exact results depend on the number of CPU cores available.
Ref D11494
Reviewed By: mano-wii
Cycles, Eevee, OSL, Geo, Attribute
This operator provides consistency with the standard math node. Allows users to use a single node instead of two nodes for this common operation.
Reviewed By: HooglyBoogly, brecht
Differential Revision: https://developer.blender.org/D10808
rB847579b42250 updated the TBB build script
which had some unintended consequences for
windows as the directory layout slightly
changed.
This change adjusts the builder to the new
structure, there are no version/functional
changes.
When changing to another texture paint slot, the texture displayed in
the viewport should change accordingly (as well as the image displayed
in the Image Editor).
The procedure to find the texture to display in the viewport
(BKE_texpaint_slot_material_find_node) could fail
though because it assumed iterating nodes would always happen in the
same order (it was index based). This is not the case though, nodes can
get sorted differently based on selection (see ED_node_sort).
Now check the actual image being referenced in the paint slot for
comparison.
ref T88788 (probably enough to call this a fix, the other issue(s)
mentioned in the report are more likely a feature request)
Reviewed By: mano-wii
Maniphest Tasks: T88788
Differential Revision: https://developer.blender.org/D11496
This is useful information to have and the Open Blend File makes sense to have
next to it.
A general Asset Browser feature really, but the Open Blend File operator is
only available in this branch, so committing that here.
Also added a TODO note about something that would be especially good to have
for this change.
With undo/redo after creating assets, previews of the "Current File"
asset library would often go missing, e.g. see T83884.
The preview generation in a background job will eventually modify ID
data, but the undo push was done prior to that. So obviously, an undo
then would mean the preview is lost.
This patch makes it so undo/redo will regenerate the preview, if the
preview rendering was invoked but not finished in the undone/redone
state.
The preview flag `PRV_UNFINISHED` wasn't entirely what we needed. So I
had to change it to a slightly different flag.
This makes the dropping use the object's bounding box for snapping, so
that it matches the bounding box we draw while dragging.
Not that this may have to be optional in future, there may be valid
cases to use the origin instead of the bounding box for snapping.
Note: Object assets have to be saved with this commit or later for the bounding
box to appear.
Basic idea is:
* Store the bounding box (and related info) in the asset metadata.
* The bounding box has to be updated and written to custom properties of the
asset metadata.
* There's a new `AssetTypeInfo` struct, to set asset type dependent callbacks
or data (in future). ID types can conveniently define asset-type info as part
of their `IDTypeInfo` definition.
* The asset-type info can contain a custom callback to be executed before the
asset is saved. This is how the object can write its custom asset metadata.
* The dropbox can also register a callback to set properties for its
gizmo-group now. Used to copy
* The "placement plane" gizmo is scaled to the bounding box size too.
* For local ID assets, the data should be accessed directly, so the file
doesn't have to be saved to get the bounding box updated.
Also:
* Added proper gizmo group custom property support to C (was already supported
in Python, or in C with some hacking).
* Store the basis matrix (world matrix without parent or constraint transforms)
in the custom asset metadata. Used by the placement gizmo to scale the
bounding box to match the result visually when dropping.
* The preview image is disabled while dragging objects over the 3D view.
* The bounding box always snaps with its lower edge (Z axis) to the surface.
Snapping with other axes can be added still.
* However, actually dropping the object still uses the origin, so the drop
position may not match what the bounding box indicated. This could be changed
to also use the bounding box instead. Or the drawn bounding box should be
translated to respect the origin position.
I want to clean this up a bit still, but it seems to work now.
Also includes (to be split off):
* Don't allow renaming assets from the file list for now (e.g. right-click >
Rename). This doesn't work yet and I'm not sure it should even. If an asset
is a local data-block it can be renamed in the sidebar.
* Fix broken logic to scroll a preview into view.
* Partially includes D9994. These changes were needed for this to work.
Differential Revision: https://developer.blender.org/D11119
On MSVC it failed with this error:
```
source\blender\blenkernel\BKE_context.h(361,20): error C2526:
'CTX_wm_asset_handle': C linkage function cannot return C++ class 'AssetHandle'
```
On Apple Clang I would get this:
```
warning: 'CTX_wm_asset_handle' has C-linkage specified, but returns incomplete
type 'struct AssetHandle' which could be incompatible with C
[-Wreturn-type-c-linkage]
struct AssetHandle CTX_wm_asset_handle(const bContext *C, bool *r_is_valid);
^
1 warning generated.
```
Just include the asset header defining the type for now, it should later on be
solved properly with a better design for `AssetHandle`.
Add improved arrow key walk navigation in grid layout UI List templates.
Pressing up or down walks the active item to the adjacent row in that
direction, while left and right walk through the items along the columns
wrapping at the rows.
Differential Revision: https://developer.blender.org/D11063
Fix a glitch when blending a pose by always starting blending at 0%.
Previously, the blend percentage was remembered between operator
invocations, causing the glitch.
The `ASSET_OT_open_containing_blend_file` operator starts a new Blender
process, and refreshes the assets after it quits. It now also refreshes
the assets UIlist (f.e. the pose library panel in the 3D Viewport).
Add a class `AssetBrowserSpecificCategoryPanel` that only shows if the
asset browser is showing a specific set of categories. This makes it
simple for the Pose Library panels to only show when the user has selected
the Animations category.
Uses the same snapping logic as the placement plane from the Add Object
tool, which means it matches the plane that we already draw as a
preview.
This is quite primitive at this point - you can't change options for the
snapping like the up-axis or the snapping target - but it already feels
quite great.
Another limitation is that it uses the origin of the dropped object to
place it, the bounding box should give better results in practice. This
is something we can add.
Shows the same grid overlay as the Add Object tool when dragging an
asset into a 3D view. Uses the gizmo-system for that.
How visibility of gizmo-groups is managed is rather tricky, for now I
hacked things a bit to work. I have ideas to make this nicer.
Besides that, this is generally a design that I think can work in
master: Just like tools, drop-boxes can set a gizmo-group to use while
they are active. If the gizmo-group supports usage while dragging, it is
drawn.
When using the arrow keys to "walk" the active item in the asset view, call the
activate operator which applies the pose asset. This is useful for animators to
easily go through poses on the search for an appropriate one.
The Ctrl+F is a general UI list feature. You can hover any UI list and
press Ctrl+F now to open and activate the search field. If needed the
view is scrolled to make it completely visible (with some additional
margin). Plus, the view is updated to keep the search field visible
while typing.
The latter part is also a text button feature. When you activate a text
button (that doesn't have a search menu attached, which causes further
issues), the UI code makes sure it's visible and keeps it visible while
typing.
This could go into master (after some functionality review), I'll check
on that in a bit.
Free the flipped Action before calling `poselib_tempload_exit()`, to avoid
any problems from indirectly referenced ID pointers.
Thanks @campbellbarton for the patch!
When a (Python defined) UI-list type is unregistered, we have to make sure no
list still references that type. We do the same for other such UI types.
This didn't happen to be an issue before, since the list type was not accessed
until the list was drawn again (which re-assigns the type).
After macro expansion, there would be C++ code in code with C linkage
(`extern "C"`). Clang warned about this.
Make sure the expanded C++ code always uses C++ linkage. Will commit this to
master soon.
C++ has strongly typed enums (which is great!), so a bitwise OR on two
enum values will result in a compiler error. Use our `ENUM_OPERATORS()`
utility to overload the bitwise operations to be valid for this strong
enum type.
The asset view so far showed up to 5 items by default. If there were
more assets to be shown than that, it the list would become scrollable.
This would cause a scrollable box inside a scrollable region, which is
not nice for interaction. We can just expand the list so all assets are
in the layout, and the user can scroll the region rather than scrolling
the list.
Also hide the "grip" button so the list can't be resized. If needed we
could allow making the list smaller still, even if that causes double
scrolling again. For now keeping it simple.
Had to add a "no grip" option for that, so I changed the signature a bit
to avoid too many boolean arguments.
And another also: Adds missing return after error check.
Rendering a preview for an Action requires temporarily modifying the pose
of some object (otherwise there is nothing to render); after this is done,
the object needs to be tagged correctly to flush the temporary changes.
When rendering the preview icon of an Action, apply it to the pose
object first. This ensures that the "Refresh" button of a pose actually
uses that pose.
This splits some functions into two flavours, one that acts on all bones
and one that acts on the selected bones only. Normal use of the pose
library only acts on selected bones, but for the preview the entire pose
from the library is applied, regardless of selection.
Move the pose backup & restore functionality into its own file, so that
the functions can be called from other places in Blender as well.
No functional changes.
After temp-loading an asset datablock, explicitly free it before calling
`BLO_library_temp_free()`. Without this step, normal linking would be
performed, causing temp datablocks to actually be linked into the current
blend file.
Make `ASSET_OT_open_containing_blend_file` in a asset view UIList as
well as the Asset Browser. This uses the context variables
`asset_file_handle` and `asset_library`, which are temporary in lieu of
a better asset API.
Needed so the pose library add-on can keep its operators work outside of
the Asset Browser context, namely with the asset view template.
An issue here is that we can't expose an asset handle from the Asset
Browser, because there is not permanently saved one whose pointer we can
pass around. This is planned to be addressed, but for now Python will
have to use the file wrapped by the asset-handle directly, via
`context.asset_file_handle`.
Makes it possible to add custom entries to the context menu of UI List items, by doing the following:
`bpy.types.UI_MT_list_item_context_menu.prepend(some_draw_function)`/`append(...)`.
The given draw function must check if the list is of the correct type. For that
to work I made it possible to get the hovered UI List using `context.ui_list`
and the list-ID via `ui_list.list_id`.
Rename the operator property `apply_flipped` to simply `flipped`, as the
verb ("apply") is already in the operator name. This will make it possible
to add a `flipped` property to the select/deselect operators too, keeping
things consistent.
No functional changes.
We'd store references to temporary objects, e.g. see
`AssetListStorage::ensure_list_storage()`. Stupid mistake, store a copy
of the `AssetLibraryReference` struct now (cheap to copy).
This will make it possible to click and drag on the poses in the
asset view template to do the blending. On mouse release, the blended
pose will be applied.
This isn't used yet, follow-up commits will enable it.
This also hides the cursor and enables continuous grabbing when dragging
with the "Release Confirm" enabled. To be evaluated; maybe it should
always do this while blending.
Also fixes mouse hover highlights not being updated when confirming or
cancelling the pose blending operator.
The asset view template now provides a way to set the operator
properties of its custom drag & activate operators. In Python they are
returned from `UILayout.template_asset_view()` as tuple.
Includes some cleanup to better manage the data of the custom operators.
The preview rendering notifiers would be continuously sent, causing
continuous redraws. In the File Browser that also happens (and I don't
think it's intentionaly) although it causes refreshes there that don't
do much and there won't be redraws unless necessary. Correcting this may
cause issues, so better to do it separately.
Issue is that the previews were fetched using the BLI_task API, and a
timer was started to send notifiers continuously. But there was nothing
to check if the tasks were done, so that the timer could be stopped.
The pose apply operator would be invoked when double-clicking a
directory in the File Browser, while in pose mode.
The operator's poll would succeed because since 29887bbb32, the
File/Asset Browser would just create a `AssetHandle` from the active
file received from context, without ensuring that the file actually
represents an asset.
When the interactive blending operator finishes, store the chosen blend
factor in the RNA properties. This ensures that pressing F9 shows the
actual factor, which can then be readjusted.
When Blender quits while the pose blending operator is active, set the
correct state (`POSE_BLEND_CANCEL`) before exiting, so that cleanup done
correctly.
Add an "Open Blend File" operator to the Asset Browser context menu,
which starts a new blender process to open the blend file containing the
active asset.
Similar to the pose sliding tools, use the relative mouse position in the
active area to determine the pose blend factor.
This is not a final implementation, but at least makes the pose library
usable with a tablet.
The Asset Browser uses the `FileList` from the File Browser, which isn't
properly using the `AssetList` yet. So of course getting the file-path
from the asset list will fail.
For now just add a little hack to fall-back to get the data from the
Asset Browser directly.
I did some casting hack to return an `AssetHandle` from a
`FileDirEntry`. But this doesn't actually work.
What I added now isn't something I'm happy with either, but it will have
to do for now. Basically we request an `AssetHandle`, which the Asset
Browser doesn't actually store, since it's just a wrapper around the
Asset Browser's `FileDirEntry`. So there is no consistent pointer the
editor could return to context queries, and the context needs a pointer
so that it can be passed around as `void *`.
Eventually once we have the planned asset storage design implemented,
the storage would include actual asset handles. So we can pass around
consistent pointers to them then.
The operators are not exclusive to the File Browser anymore now. The logic to
get the asset file information and use that to append the ID if necessary is
abstracted away by the asset system now, see 10383566b8.
Add operator `POSELIB_OT_apply_pose_asset` that does the same as executing
(instead of invoking) `POSELIB_OT_blend_pose_asset` with
`blend_factor=1.0f`. This will replace the Python equivalent in the
pose library add-on.
Rename the pose blending operator to `POSELIB_OT_blend_pose_asset`, so that
we can make an operator `POSELIB_OT_apply_pose_asset` without colliding
with the old `POSELIB_OT_apply_pose` operator (from the current pose
library system instead of the new one).
No functional changes.
The operators are not exclusive to the File Browser anymore now. The logic to
get the asset file information and use that to append the ID if necessary is
abstracted away by the asset system now, see 10383566b8.
This adds a new RNA method `Action.flip_with_pose(ob, frame)`
to flip the action channels that control a pose.
The rest-pose it's self is used to properly flip the bones transformation.
This is useful as a way to flip actions used in pose libraries,
so the same action need not be included for each side.
API calls to cache F-curve look-ups have also been added,
supporting a single hash lookup to access all channels controlling an RNA path.
----
**Motivation**
This patch adds functionality to flip an entire action on the X axis using a symmetrical rig.
This was written so the asset manager can apply poses flipped, see T86159,
tested with spring.blend.
**Alternative Solutions**
It's possible to calculate this on the pose directly (see D10766), however operating on the action data makes this more useful as an API function, since the data can be flipped before it's applied to the pose.
Instead of flipping on the pose, then writing back to the action.
**Limitations**
There is some information not easily available at the time of flipping, for example - it's possible the flipped data-path doesn't exist in all cases, although the ideal behavior isn't obvious when the RNA path only resolves on one side of the pose.
- Currently the API function flips all channels, we could add an argument so it only operates on some of the channels.
**Open Topics**
- When some actions transform channels don't exist, they could be created (for example - if only X & Y rotation are set, it may be necessary to create a Z F-Curve to properly flip the rotation).
- The key-framing API is currently part of the editors (it would be a bad-level call from the BKE), we could expose some keyframing functionality to BKE, or move this functionality to editors. For now there is a simple keyframe adjusting function.
- Currently only the armature rest-matrices is used, not the pose. This API could take an armature instead of an object, although we might want to use pose content in the future, it doesn't seem like a big issue either way.
- This could eventually be exposed as an operator.
- Currently this re-orders channels which could have other frames keyed. A more comprehensive approach could be to operate on all keyed frames for an action, so an action that includes multiple poses will have them all properly flipped.
-----
**Notes**
- The F-Curve lookup cache can be committed separately.
- This is an example script for testing with the pose object set active:
```
import bpy
from bpy import context
ob = context.object
action = bpy.data.actions['07_040_A.spring']
action.flip_with_pose(ob, context.scene.frame_current)
```
Differential Revision: https://developer.blender.org/D10781
An annoyance is that the operator names have to be passed to the template which
makes the already long argument list even longer.
Thought about a couple of ways to do this, unfortunately this is the only
decent way to do this that I see. There's also no way to pass operator options
currently.
Getting the handling to work correctly took some effort, and the code is not
exactly nice.
Note that even though we activate the item when calling the custom drag
operator (helps indicating the pose being blended for example), we only call
the drag operator then, not the activate one. They are never executed both.
Also note that this won't compile right now, I'll have to commit some changes
to master first.
Uses the new `BLO_library_temp_xxx` functions, but deals with all the asset
specific file path building. This is a reasonable utility for the asset system
to have, it will probably be needed by more asset types than IDs.
`CTX_wm_asset_library()` returns the active asset library from the workspace,
or the the Asset Browser one while inside that. The active asset handle is set
by the Asset Browser and the asset view UI template so that operators executed
via the template can access it.
Expand the `POSELIB_OT_blend_pose` poll function to check whether there
is an actively selected pose, and don't crash even if the operator gets
called regardless.
Switch addons submodule to `asset-browser-poselib` branch in the
`.gitmodules` file. This should affect any subsequent calls to `git
submodule update`.
Care should be taken when merging this branch back to master, because
this change should *not* be included.
This commit sets the `release/scripts/addons` to its
`asset-browser-poselib` branch, with the aim that animators checking out
this branch on the main Blender repo also get the corresponding branch
in the addons repo.
This is generally what people expect when generating a cone. Note that
this translation currently happens after the rotation, but since the rotation
will likely be removed in the future, that won't be a problem for long.
This patch adds the remaining 6 interpolations for mesh domains.
The new interpolations are:
- Corner / point / polygon to edge
- Edge to corner / point / polygon
After this it is possible to adapt an attribute to and from every
mesh domain. This is simple to test with the "Attribute Convert" node.
Though, as a note for the future, there are still some improvements
possible to the interpolations, like lazily calculating values for the
interpolations where it's possible, and slightly improving the
algorithms used for some interpolations, like using corner angles
for polygon to point.
Differential Revision: https://developer.blender.org/D10765
This is not only potentially extremely expensive, it is also fairly
futile, and code is not designed to handle it currently anyway (could
easily end up in inifinite loops and other crashes).
- Remove use of evaluated poses, instead calculate transformations
into an array which is applied afterwards.
- Only update ID's for poses that have been changed.
This is simply a convenience when using this type. More similar
constructors can be added in the future when they are useful.
Differential Revision: https://developer.blender.org/D10714
Allow python access to the `reset_view` functionality which before
was only available through the menu. This was suggested for
consistency after D10561.
Differential Revision: https://developer.blender.org/D10595
The size in the transform matrices was extra, since it is also
passed as an argument to the BMesh operators.
Differential Revision: https://developer.blender.org/D10763
Previously even if the input goemetry set had no point cloud or no mesh
instances, `geometry_set_realize_instances` would create empty data.
This isn't necessarily bad, but it can complicate things down the line if
there are a bunch of empty components getting passed around.
This was reported for geometry nodes, but was true for all nodetrees
(e.g. after deleting the active node). Geometry node trees just made
this more obvious since they start without an active node to begin with.
Fix provided by @lone_noel, thx!
Maniphest Tasks: T86677
Differential Revision: https://developer.blender.org/D10762
Caused by {rB2917f550caa9} which renamed the entry in the toolsystem,
but not the corresponding keymap.
Maniphest Tasks: T86548
Differential Revision: https://developer.blender.org/D10725
Since {rB46aa70cb486d}, using `NC_SPACE | ND_SPACE_VIEW3D` as notifier is
restricted to space data as a reference. This was still used though for
RNA updates in other places (namely `rna_camera`, `rna_scene`,
`rna_animviz`), and passing NULL would automatically set the notifier
reference to the owner id. Above commit would happily filter these out,
leading to missing refreshes.
Now use more specific notifiers (in case of animviz a new
`ND_DRAW_ANIMVIZ` was added).
This was reported for Camera background images btw.
Fixes T86670.
Maniphest Tasks: T86670
Differential Revision: https://developer.blender.org/D10758
E.g. opening a file with an asset viewer and an Asset Browser could cause one
of them to not load its files properly. That is because there was only one
`wmJob` per scene so when the first one was done it would end the other one(s).
I think this would be a problem in master for the regular File Browser too.
Instead of setting the scene as owner of the job, use the file-list, so that
each file/asset-list gets its own job.
`UIList` is designed to use collection properties. I previously did a
whole bunch of hacks to use it without. This isn't acceptable for
master, instead a proper collection property should be provided.
Idea is to let scripts register a custom collection property, that the
asset view template can fill with the latest asset list contents and
pass that to the UI list.
Longer term I'd prefer if the UI code would support other containers,
and not rely so much on RNA and custom/ID properties. I have ideas and
plans for this, but meanwhile, this will do to remove the hacks.
Would give a warning:
```
'ED_asset_library_reference_from_enum_value' has C-linkage specified, but
returns incomplete type 'struct AssetLibraryReference' which could be
incompatible with C [-Wreturn-type-c-linkage]
```
We didn't actually run into the static initialization fiasco, but only
because `blender::Map` didn't use the guarded allocator on default
destruction. Better to stay far way from static initialization fiasco,
and the construct on first use idiom is trivial and prevents it. So
better use that.
Previously I just used the active color index of the first palette to
get things to work.
I would've preferred if the asset view template could register own
properties and store them in the `UIList` it creates. That way you could
have multiple asset views with entirely independent data. But since this
isn't possible, we need a different way to store such data, I think the
workspace makes sense. It should still be possible to store different
data for different use-cases, e.g. to show a pose asset list in pose
mode and a material asset list in object mode. So idea is to let
scripts/add-ons register custom properties for their specific use case
(e.g. "Active Pose Asset" for the pose libraries).
Previously I just used the active color index of the first palette to
get things to work.
I would've preferred if the asset view template could register own
properties and store them in the `UIList` it creates. That way you could
have multiple asset views with entirely independent data. But since this
isn't possible, we need a different way to store such data, I think the
workspace makes sense. It should still be possible to store different
data for different use-cases, e.g. to show a pose asset list in pose
mode and a material asset list in object mode. So idea is to let
scripts/add-ons register custom properties for their specific use case
(e.g. "Active Pose Asset" for the pose libraries).
The Asset Browser still has its own active asset library. But for the UI
(e.g. the asset view UI template), there is one active asset library per
workspace now. This is needed because for technical reasons the property
has to be registered in C, ideally you could just register it as custom
property for any use-case and pass that to the asset view template.
Since this isn't possible, an active asset library per workspace seems
reasonable.
This also removes the `bool flush_to_original` argument, as this flushing
is not required for the pose library (poses are always applied to the
original, and not to evaluated copies).
My code for interpolating booleans basically performed the same function
as the rounding for ints and enums. Now the code is the same, too.
No functional changes
Naieve blending of the pose Action onto the current pose. This performs
linear blending (LERP) per FCurve. This is not suitable for rotations, so
it's probably better to do proper matrix interpolation for loc/rot/scale.
However, for other properties, the current LERP will be necessary anyway.
The operator doesn't blend yet, but it does allow temporarily applying the
pose, switching between the original and the given pose with Tab, applying
the pose with Enter/LeftClick, and cancelling with Esc/RightClick.
Makes sure the asset list is updated and redrawn correctly an local asset data
changes: Creating assets, removing assets, clearing assets, undo/redo, reading
files (with and without UI), parallel reading of asset data from files, ...
For redraws there now is a listener callback in the uiList type (C only) that
asks the asset lists if it needs a redraw after a given notifier. For the case
of asset data-block removal there is a ID remapping function in the asset list
now (just tags the list for a complete re-read). File reading, undo, redo and
the "Mark Asset"/"Clear Asset" operators explicitly tag asset lists showing
main data as dirty (via the global asset storage).
The ID type filter can be set as follows:
```
template_asset_view(..., filter_id_types={'filter_material', 'filter_object'})
```
I would have prefered if you could just create a
`bpy.types.AssetFilterSettings` object, fill that and pass it to the
template. But that doesn't seem possible right now without more complex
BPY additions.
Also, newer ID types (hair, point cloud, volume and simulation IDs) do
not support filtering, because their filtering flags exceed 32, meaning
we have to store them in 64 bit integers which RNA doesn't support for
enum properties...
No reason to skip adding the UI elements just because the preview is missing.
We can still show the text and allow dragging. Also makes it feel more
interactive while the previews load in a background thread.
The new button type (UI_BTYPE_PREVIEW_TILE) shows the items similar to
the Asset Browser, or the File Browser in thumbnail display mode. That
is, previews bigger than normal buttons, with the name drawn centered
below it.
Would be nice if the File/Asset Browser and preview templates could
adopt that new button type, so that there's no ad-hoc drawing for these
anymore. That's for a future cleanup though.
This was very glitchy before and just didn't work in most cases. The mouse
press event was simply caught by the preview icon button and didn't make its
way to the underlying list-row button.
The SSS shader in Eevee has the following drawbacks (elaborated in {T79933}):
1. Glowing
2. Ringing. On low SSS jittering it is rendered a bunch of sharp lines
3. Overall blurriness due to the nature of the effect
4. Shadows near occlusions as in T65849
5. Too much SSS near the edge and on highly-tilted surfaces
{F9438636}
{F9427302}
In the original shader code there was a depth correction factor, as far as I can understand for fixing light bleeding from one object to another. But it was scaled incorrectly. I modified its scale to depend on SSS scale*radius and made it independent from the scene scale. The scale parameter (`-4`) is chosen so that it makes tilted surfaces to have visually the same SSS radius as straight surfaces (surfaces with normal pointed directly to the camera).
This depth correction factor alone fixes all the problems except for ringing (pt. 2). Because of float-point precision errors and irradiance interpolation some samples near the border of an object might leak light, causing sparkly or dashed (because of aliasing) patterns around the highlights. Switching from `texture()` to `texelFetch()` fixes this problem and makes textures on renders visually sharper.
An alternative solution would be to detect object borders and somehow prevent samples from crossing it. This can be done by:
1. Adding an `object_id` texture. I think it requires much more code changing and makes the shader more complicated. Again, `object_id` is not interpolatable.
2. Watch gradient of depth and discard samples if the gradient is too big. This solution depends on scene scale and requires more texture lookups. Since SSS is usually a minor effect, it probably doesn't require that level of accuracy.
I haven't notice it in practice, but I assume it can make visible SSS radius slightly off (up to 0.5 px in screen space, which is negligible). It is completely mitigated with render sampling.
Reviewed By: Clément Foucault
Differential Revision: https://developer.blender.org/D9740
This is ported from Cycles and fixes issues with bump/normal mapping
giving weird reflections/lighting.
Fixes T81070 Specular light should be limited to normal pointing toward the camera
Fixes T78501 Normal mapping making specular artifact
Steps to reproduce:
- switch to Scripting workspace
- execute bpy.data.meshes['Cube'].copy()
- Outliner will not show the new mesh immediately
Now just send appropriate notifier.
Differential Revision: https://developer.blender.org/D10584
The `bNodeLinkDrag` struct was NULL when dragging a node instead of
a link. It is allocated with `calloc` anyway, so this field doesn't
need to be explitely cleared.
This commit includes a few simple improvements to the direct mesh
boolean code added recently.
- Passing the transforms and meshes to `direct_mesh_boolean` as spans
makes the function easier to call from C++.
- The definition of `TransMat`, was unecessary when we have the
`float4x4` type already used elsewhere in C++ code.
Differential Revision: https://developer.blender.org/D10592
The socket drag operator stored the index of the last picked socket
into RNA in case the mouse cursor leaves the link while dragging.
This id was not unique which is why sometimes a link from an other node
with the same id is picked.
This patch changes the way the last picked link is stored and stores a
pointer to the link directly into bNodeLinkDrag struct instead.
Differential Revision: https://developer.blender.org/D10590
The Python API for the curve mapping widget offers the `update`
function, but no way to reset the view to the clipping rectangle.
This commit adds a blenkernel function for this operation,
and exposes it to the CurvMapping RNA API. This allows addons
to display a more user-friendly view of the data in this widget.
Differential Revision: https://developer.blender.org/D10561
This commit adds a search for existing attributes when you click
on an attribute field. This is useful because otherwise you have
to remember which attributes should be available at each node in
the tree.
The fundamental complication is that this information is not
accessible statically. So the search data is only a cache from
the previous node tree evaluation. The information is added
with `BKE_nodetree_attribute_hint_add`, currently for every
input geometry socket for a single node.
This is only an initial implementation, and later versions will
expose the data type and domain of the attributes.
Differential Revision: https://developer.blender.org/D10519
I landed D10527 in rB1a8aee0a7cec accidentally, and the version there was
missing a name change discussed in review. This commit just renames the
boolean variable controlling the special behavior for attribute search.
Original message meant for this change:
For geometry nodes we will use search buttons to display a list of
attributes available the last time the node tree was executed (D10519).
Because this list is just a hint, we need to be able to enter any string,
not just strings from the search items.
This patch adds a boolean option to string buttons to enable this.
The change is quite simple, changes to behavior are only required in
two places. The type-specific button struct changes help a lot here.
Differential Revision: https://developer.blender.org/D10527
In Blender, we used to use the term 'draw' to refer to information
displayed to the user. For version 2.80, it was decided to change these
instances to 'display' instead. This was to avoid the ambiguity between
end-user drawing tools and display options.
From the Oxford English Dictionary:
- Draw: produce (a picture or diagram) by making lines and marks on
paper with a pencil, pen, etc.
- Display: show (data or an image) on a computer, television, or
other screen.
Therefore, we should use draw when referring to drawing tools for
making marks, but use display when referring to information
shown/displayed to the user. From a user POV, the computer displays
certain information, whereas the user draws a mark.
Apparently this change was not implemented consistently, so this patch
changes all remaining relevant instances of "draw".
Differential Revision: https://developer.blender.org/D10551
Currently when you open an RNA collection search button, like a
vertex group selector, the search filter isn't applied until you
start typing, in order to display every option at the start.
Otherwise they wouldn't be visible, since the search filter would
run for the current text.
Currently this check happens in one place, but it relies on the
`changed` value of `uiBut`. This is fine in the interface directory,
but anywhere else it would require exposing `uiBut.changed`, which
is probably too low-level to expose.
The solution is adding an `is_first` argument to the search callbacks,
which is nice for a few reasons:
- They work at a higher level of abstraction, meaning they don't
have to worry about how exactly to tell if this is the first
search.
- It makes it easier to do special behavior when the search menu
is first opened.
- Then, obviously, it makes that state accessible without including
`interface_intern.h`.
Needed for attribute search: T85658
Differential Revision: https://developer.blender.org/D10528
Since the same node tree can be used in modifiers on different objects,
there can be multiple threads writing to the maps in the node tree UI
storage at the same time. The additions for attribute name hints and
error messages made it so this would often cause a crash or at least
an ASAN report. This patch adds locks to prevent multiple threads
from using the maps concurrently.
In a brief test I actually didn't observe a crash without the global
`bNodeTree` UI storage mutex, but I think it's necessary for the change
to be correct, and I did notice some unfreed memory without it anyway.
Ideally it would be in a node tree runtime struct though.
Differential Revision: https://developer.blender.org/D10577
The shadowing was computed on the light distance squared,
leaking to much light since it was integrating the extinction behind
the ligth itself.
Also bump the maximum shadow max step to the actual UI values. Otherwise
we get shadowing under evaluated because `dd` is too small.
Expand is a new operator for Sculpt Mode which is intended to be the main
tool for masking, Face Set editing, interacting with the filters and pattern
creation.
The fundamentals of the tool are similar to the previous sculpt.mask_expand
operator. It shares the same default shortcuts and functionality, making
the previous operator obsolete.
The shortcuts to execute the operator are:
- Shift + A: Expand mask
- Shift + Alt + A: Expand mask by normals
- Shift + W: Expand Face Set
- Shift + Alt + W: Resize current Face Set
The main changes compared to the previous sculpt.mask_expand operator are:
- Modal keymap, all operator options can be changed in real time while the
operator is running.
- Supports creating Mask, Face Sets and Sculpt Vertex Colors.
- Much better code, new features can be easily integrated.
Limitations:
- All Mask operations are supported for Sculpt Vertex colors, but not exposed
by default as their support is still experimental.
- Dyntopo does not support any Face Set or Sculpt Vertex Colors. functionality
(they are not implemented in general for Dyntopo).
- Multires does not support any feature related to geodesic distances.
- Multires does not support vertex colors.
- Multires does not support recursions.
- In Multires, Face Sets snaping does not initialize all current enabled Face
Sets when toggling snapping.
- In Multires, Face Sets are created at base mesh level (works by this by
design, like any other tool).
- Unlike the previous mask_expand operator, this one does not blur the mask
by default after finishing Expand as that does not fit the new design.
The mask can still be blurred by using the mask filter manually.
Reviewed By: JacquesLucke
Differential Revision: https://developer.blender.org/D10455
The performance debug menu isn't used that often anymore as render doc
also show the timings. This patch will make sure that enabling the
performance debug view (21) does not crash blender.
The crash happened when the density in the Point Distribute node was
above zero but so small, that no point was generated. In this case, there
was a point cloud component, but the point cloud was empty, making some
attributes unavailable.
One could also make more attributes available in this case, but that can
be done separately if necessary.
Move low level logic to module code and versioning logic to versioning code.
Metas strip position was handled in diffrent way compared to other strips.
This was introduced in c8b0d25794 as bugfix for T28158.
I disagree with such design. Meta strips should be handled in same way as
any other strips.
I have tested this change and haven't found any problems.
No problems after checking T28158 as well.
There should be no functional changes on user level.
Reviewed By: campbellbarton
Differential Revision: https://developer.blender.org/D9972
Nicely hidden bug in pose read library code, it was using the library
from the wrong ID as reference to relink the custom shape object pointer
(pose is data from Object, not Armature).
This is same issue as fixed by d857892553, but I forgot to check meta
strips. Meta strip output is always in render size.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D10560
Applying negative offset to seek position before scanning doesnn't have
any effect. This change results in 1.5x faster seeking (random frame,
average value) in sample file with 30 frame GOP length.
If I am not mistaken, B frames can have pts that can be less than
pts of I frame that must be decoded. Even in this case though, B frame
packet will be stored after that I frame.
In addition, preseek value is de facto hardcoded so seeking would fail
if it could. This can be hard to spot though.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D10529
Isolate RNA and operator logic from functions that create strips.
- Operator specific code was removed from `SeqLoadInfo` structure and
`SEQ_add_*` functions.
- Strip loading code was removed from RNA and operator functions.
- `SEQ_add_*` API was unified to work on `SeqLoadData` struct.
Only exception is image strip, which require files to be loaded
separately to strip creation itself. This is not ideal, but I think
it's acceptable.
- Some functions and variables were refactored so the code reads
better.
There are minor functional changes (coincidental bugfixes):
- Operator errors are reported per-strip. Previously they were not
reported at all?
- `new_sound()` RNA API function now create sound with length of 1
if source file does not exist. Previously it created strip with
length of 0.
- Replace selection operator property wasn't working correctly.
Fixed in this patch.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D9760
This enables the quick access button [to show the relevant Texture in
the Properties Editor] for textures used in geometry nodes.
This goes in line to what we do for other textures:
- modifier textures have this button
- particle textures have this button
- brush textures will soon have it, too (see D9813)
When outside of the Properties Editor, the button will always show (if a
texture is actually assigned), but will be inactive if no suiting
Properties Editor to show the texture in can be found.
Note this also changes the behavior to not show the button if _no_
texture is assigned (as in: we are still showing the "New" button).
Previously it was always there (e.g. for modifier textures), even if it
would take us to an empty texture tab. (Sure, we could add a texture
there then, but imho it makes more sense to just start showing it once a
texture is already there)
For this to work with geometry nodes, the following chages were done:
- implement foreachTexLink for geonode modifiers
- new buttons_texture_user_node_property_add() that stores prop as well
as node
- also use NODE_ACTIVE_TEXTURE flag in geometry nodetrees
notes:
- this still uses the first suiting (as in: pinning does not interfere)
Properties Editor it finds, this should (maybe?) find the _closest_
Property Editor instead (see related feedback in D9813).
- this will already show the button for brush textures as well
(disabled), but there is another mandatory change in an upcomming commit
to make it work there as well (see D9813)
ref. T85278
Maniphest Tasks: T85278
Differential Revision: https://developer.blender.org/D10293
Lots of hacks and temporary code here. I wanted a first working version to find
possible pain points before getting into details.
Basic idea is to store each asset library in an `AssetList`, with a globally
accessible storage. Internally the list uses the File Browser's `FileList`
which already does a fair amount of heavy lifting (threaded file & external
asset reading, lazy loading of visible previews, ...). The File Browser could
access the global asset-list storage as well.
The asset view template uses the new asset list to load and display the assets.
Current state: {F9856940}
Open TODOs: https://developer.blender.org/maniphest/query/M6RWFxFSDor3/#R
Idea is to be able to display a list of assets in a layout, by giving it
some custom filtering settings (not done yet). This would be just a
uiList managed by Blender, displaying previews similar to the Asset
Browser.
I decided to use uiLists for this because it already deals with stuff
like writing its UI data to .blends (e.g. filtering and sort settings),
filtering and scrolling. But I think we'll have to do a number of
general improvements to them. Here I just added a new (C-only for now)
"flexible grid" list display type, which uses bigger previews and
behaves much better than the currend "grid" one.
There's a bit of hacking going on here and things will probably change.
For now I'm just interested in getting the basics done to see if the
direction is good.
* Remove ID-map and ID session-UUID code, we can now reference the ID directly.
* Store imported asset metadata separately.
* Because of that, `FILE_TYPE_ASSET_EXTERNAL` could be removed.
* Get asset metadata of the current files via the ID directly.
* Move local data references into a nested struct, to group them together and
allow a clear comment on how they must be updated.
* Improve comments and note how the local data needs to be updated.
Implement proper mechanisms to ensure the file list is recreated after undo,
data-blocks are removed, assets created/removed or file loading without UI.
This could be further improved (e.g. don't recreate it if no asset data-block
is affected by undo or deletion).
Addresses T82886 & T83242.
Implement proper mechanisms to ensure the file list is recreated after undo,
data-blocks are removed, assets created/removed or file loading without UI.
This could be further improved (e.g. don't recreate it if no asset data-block
is affected by undo or deletion).
Addresses T82886 & T83242.
Always select a directory - although this could contain a single .blend file of
course. But this will make it easier to add the index/cache in future because
it could just be placed in this directory.
I recently found out that the file reading code already supports listing the
data-blocks from all .blends in a directory. All that was left to do was making
sure drag & drop works, which is what this commit fixes.
Addresses T82682.
- Tweak Asset Libraries panel UI in Preferences (by Hans mostly)
- Rename "Repositories" to "Asset Libraries" in code and UI
- Fix "Only Assets" filter hiding non-data-block file types
- Address review comments
- Avoid use-after-free
- Rename "Make Asset" & "Remove Asset Data" to "Mark Asset" and "Clear Asset"
Still not the best names, but we can live with this for now. We can still
rename the operators if we find something better.
- Use new 16bit fetch+AND rather than changing DNA type
- Atomics: Add 16-bit fetch+AND and fetch+OR operations (signed)
- Also adds tests for the new functions.
- Explicitly enforce a size for preview flag
- Disable loading custom previews for overriden data-blocks
- Cleanup: Address review requests
I could use a 16bit atomic fetch+AND for D9719. The alternative would be to
turn a `short` into a `int` in DNA, which isn't a nice workaround.
Also adds tests for the new functions.
Mostly internal changes. But also adds removing of asset data via the "Remove
Asset-Data" operator in the Outliner and button context menus, as well as
through deleting asset files in the Asset Browser.
This introduces the UI part of the Asset Browser.
Additions:
* Asset Browser as sub-editor of the File Browser.
* Asset repository dropdown, showing "Current File" and all custom repositories.
* Display popover, filter popover and search box (partially dummies, see T82680).
* Navigation region showing asset categories.
* Asset metadata editing UI in the sidebar (preview, description, tags).
* Make asset files draggable (with preview image).
* If a repository with invalid path is selected, draw a message in the main region to help the user understand what's wrong.
* Operators to add and remove asset tags.
* "Only Assets" option for Link/Append.
Differential Revision: https://developer.blender.org/D9725
The Asset Browser will be a sub-editor of the File Browser. This prepares the File Browser code for that.
**File-Lists**
* Support loading assets with metadata read from external files into the file-list.
* New main based file-list type, for the "Current File" asset repository.
* Refresh file-list when switching between browse modes or asset repositories.
* Support empty file-lists (repository with no assets).
* Store file previews as icons, so scripts can reference them via icon-id. See D9719.
**Space Data**
* Introduce "browse mode" to differeniate between file and asset browsing.
* Add `FileAssetSelectParams` to `SpaceFile`, with `FileSelectParams` as base. Makes sure data is separated between asset and file browsing when switching between them. The active params can be obtained through `ED_fileselect_get_active_params()`.
* `FileAssetSelectParams` stores the currently visible repository ID.
* Introduce file history abstraction so file and asset browsing can keep a separate history (previous and next directories).
**General**
* Option to only show asset data-blocks while file browsing (not exposed here).
* Add "active_file" context member, so scripts can get and display info about the active file.
* Add "active_id" context member, so `ED_OT_lib_id_load_custom_preview` can set a custom ID preview. (Only for "Current File" repository)
* Expose some of `FileDirEntry` in RNA as (non-editable). That way scripts can obtain name, preview icon and asset-data.
Differential Revision: https://developer.blender.org/D9724
Idea is simple: In {nav Preferences > File Paths}, you can create custom repositories, give them a name and select a path.
Currently, this has to be a path to a .blend, only .blend files are supported as repositories right now. But directories should be supported as well, see {T82682}.
Differential Revision: https://developer.blender.org/D9722
Idea is simple: When dragging an asset, store the source file-path and
data-block name and when dropping, append the data-block. It uses existing drop
operators, but the function to get the dropped ID is replaced with one that
returns the local ID, or, in case of an external asset, appends the ID first.
Note that I expect this to be a short-lived change. A refactor like D4071 is
needed to make the drag & drop system more future proof for assets and other
use cases.
Differential Revision: https://developer.blender.org/D9721
* Operator to set a custom data-block preview. Copies an image from a selected path to the ID's preview buffer.
* Object preview support (threaded). Creates a localized copy of the object, creates a temporary main, scene, view-layer and depsgraph, uses the "Frame Selected" logic to place a camera in front of the object, and renders that offscreen.
* Support defining (not necessarily rendering) icons in threads. Needed so the File Browser can expose file previews with an icon-id to scripts.
** For that, ported the C++ to be able to use scope based mutex locks.
** Also support ImBuf icons.
* Tag previews as "unfinished" while they render in a thread, for the File Browser to dynamically load previews as they get finished.
* Better handle cases where threaded preview generation is requested, but the ID type doesn't support it (fallback to single threaded).
Differential Revision: https://developer.blender.org/D9719
Exposes "Make Asset" in Outliner context menus and button context menus.
The Outliner can tell operators which IDs are selected via a new "selected_ids"
context member. We can use that for more operators and editors in future.
Other UI code can set a new "focused_id" context member (automatically done for
ID pointer property buttons). That way, data-block search menus or other
buttons representing a data-block (e.g. materal slots) can hand an ID to
operators via context.
Differential Revision: https://developer.blender.org/D9717
* Use "metadata" not "meta-data", just like elsewhere.
* Move asset repositories panel in the Preferences to the bottom, looks weird
otherwise.
* Slightly improve layout of the panel, after review feedback.
After feedback from review, I decided to change data-structure names
(`AssetData` -> `AssetMetaData`, `CustomTag` -> `AssetTag`).
This will break DNA compatibility so old assets created with this branch won't
be readable.
Rather than verbose and unsafe (in case of early exits or exceptions) explicit
lock/unlock pairs, use RAII based locks which explicitly unlock on stack
unwinding.
That way we can use scoped mutex locks, which should make code cleaner/saver
and avoids the annoying unlock calls for every early-exit. Will happen in a
followup commit.
Mostly had to address casts from `void *` of course. Used C style casts, almost
all of the file still uses C style coding anyway.
`BKE_icon_geom_from_memory()` was using `goto`s for cleanup logic which
wouldn't compile with C++. Changed to RAII based resource handling.
That way we can expose an icon-id that scripts can use to reference the icon.
The Python API for file entries has the icon-id exposed.
To get this to work I had to make parts of the icon system thread safe. I added
a bunch of spin locks, but as a whole it's rather weak.
Part of T82977.
Buttons or other UI elements can now set a "focused_id" context pointer. The
asset operators (and in future, general data-block operators) can use this
then. Further the UI code automatically sets it when a button represents a
data-block pointer. That way, data-block search menus or data-block selectors
also show "Make Asset" in the context menu.
This also works for material slots now, the material slot you right click will
properly set the "focused_id" context pointer, and "Make Asset" makes that
material an asset.
Had to add support for using custom context pointers to context menus and
UILists.
Addresses T82664.
Assets types that already support previews (objects, collections, images,
textures, materials, brushes, lights, worlds, scenes and screens) now support
custom previews too.
To assign a preview, the Asset Browser sidebar shows a "Load Custom Preview"
button. It opens a File Browser to select an image. Once an image is selected,
it overrides whatever preview was previously set. No reference to the image is
created, it basically copies the image to the data-block preview.
The button looks a bit out-of-place currently, that will be improved later.
NOTE: This is not ready for a merge yet. Purpose of this patch is to give
reviewers a first look. I plan to address some TODOs marked in code, and then
merge it soon to continue work in master. The patch can go through some proper
review then.
For remaining TODOs and project description, see #asset_browser_milestone_1.
This patch includes:
* "Make Asset" operator, exposed in Outliner and button context menus (the
latter is disabled currently)
* Asset meta-data storage and management
* Custom asset tags
* Reading asset meta-data for separate files (but not more)
* Automatic object previews
* Custmo Asset repository setup via Preferences (has to be .blend files
currently), directories are a ToDo.
* Default repository at ~/assets.blend on Linux/macOS, ~/Documents/assets.blend
on Windows
* Asset Browser editor, internally a sub-editor of the File Browser
* Internal File Browser changes need for asset browsing
* "Current File" repository for the File Browser
* Basic UI for editing asset meta-data
* Dragging object, collection, image and material assets into 3D Views
* Option to only show assets on Append/Link
* Some unfinished code for per repository Asset Catalogs (should likely be
disabled for now)
Differential Revision: https://developer.blender.org/D9633
When displaying a repository that is not the "Current File" one, we can now
show all the meta-data of its assets in the UI. Editing is currently possible,
but changes will be lost on reload of the repository. Editing should simply not
be disabled for now.
Note that this also works for custom properties. So assets can store custom
properties, and the Asset Browser can show them, even if they are stored in an
external repository.
One important thing is that custom asset properties must not store pointers to
other data-blocks, but the BPY should forbid this already for assets.
Addresses T82860.
I didn't do this earlier because I was afraid it would make reading of asset
data (and asset data only!) difficult. Mainly because custom properties could
store pointers to other data, that would have to be read too then (e.g. an
object). But turns out, we can easily disable custom pointers to other
data-blocks, so reading stays simple :).
If the repository is not found, draw a nice hint why nothing is shown and how
you can address that.
This should greatly help understand users how to set up repositories and where
the Asset Browser expects to find the assets.
{F9355048}
If the repository did not point to a valid .blend, all .blend files in the
parent directory were read, and all their assets shown. While this may be a
cool side effect, it's not wanted by design and would break when dragging in
assets.
The followup commit will add a hint text to the Asset Browser UI if the
repository is invalid.
External repositories (ie all repositories but the "Current File" one) need
manual refreshing to reflect changes. So show a button for that in the Asset
Browser header, attached to the repository selector.
Addresses T82738.
Only works in the Outliner right now.
Also breaks the button context menu entry, I'll have to work on that again
anyway (see T82664).
Show buttons for adding and removing asset tags in the Asset Browser sidebar.
Also adds some utility Python files that we will need further I think,
especially once we want to add Python APIs for the Asset Browser for asset
management systems.
Tags can still only be edited from Python. Operators and buttons still have to
be added.
Also, tags aren't read for other files yet, so the tag list is only shown for
the "Current File".
Internally, the Asset Browser is based on the File Browser. So if you opened
one of them as a regular editor and switched back and forth between them, data
like display options, current path and navigation history (for previous/next
navigation) would be shared between them. This was quite confusing and not what
users would expect.
Now the data is entirely separate: The Asset Browser can have its own display
options, navigation history, etc.
I had to refactor some bits. But I think the resulting code is actually cleaner
than what we had before.
Addresses T82103.
Object assets support this too now, plus the Asset Browser can dynamically
start showing the previews as they get finished. This makes for a quite nice
and interactive experience.
When creating the preview, the object is now deep-copied so the preview
generation doesn't have to be done on the main thread, or block it.
There's a failing assert for objects with particle settings, I think the assert
needs to be corrected but I'll leave this aside for later. Disabled it for now.
It's confusing when this doesn't refresh, it's local data after all. It's not
entirely cheap to do, but is quite fast to do still. I don't think it will be
an issue if it's just done for creating/deleting assets.
A catalog at this stage is just a named item stored in a file's asset
repository meta-data.
With these changes one can create a named asset catalog that is written
to the file and can be read successfully.
Given that a repository can be built up from a single, or multiple
.blends, it's not clear where the repository data should live. It should
still be possible to easily share a .blend file to share assets,
including relevant meta-data that is not solely stored on the asset
level.
E.g. if you want to share a single pose library, that should be
doable by sharing a single .blend. So the .blend needs to have the pose
library meta-data, i.e. the name of the library and which poses belong
to it. The current design forsees that the Pose Library is implemented
as a "cataloge" (aka "smart-filter", to be determined). These should be
stored per asset category in the repository.
So this commit works towards the following design idea:
Each .blend file with assets can additionally store repository
meta-data. When reading a repository, we don't only read the asset
meta-data but also the repository meta-data in each .blend file. The
union over all the .blend files is the total repository meta-data the
asset browser can display.
That way each .blend file still is an isolated unit that doesn't
necessarily depend on the existence of other .blend files (or an index)
in the same repository.
This commit implements the storage framework of the repository meta-data.
I also added a temporary define to help spotting the related changes in
future.
* Rename "Local" to "Current File"
* Better separate built-in and custom repositories. Use columns with
headings "Custom" and "Built-in".
* Add separator before repository selector.
Now the repository list in Asset Browers includes the custom
repositories. They can be selected and should load fine (making the
Browser show assets stored in the repository's .blend file).
Some sanity checks (e.g. test if the repository path is valid and points
to a .blend file) could be added still.
Can be found under the File Paths category. There already is a default
repository, called "Default" and pointing to the documents or home
directory. For most Linux users it will be ~/assets.blend, for Windows
users it will be the Documents directory.
Note that this is only the Preference part of this. The Asset-Browser
doesn't use this yet.
For now, asset repositories will be single .blend files. There are some
design questions regarding how the Asset Browser would display a
directory structure as repository.
Adds a new repository "Local" (will probably rename this in a bit, together
with other UI improvements).
The asset browser shows the assets in the current Blender session then. Note
that there's a difference between the data saved in the file, and the current
session's data - the file may have unsaved changes.
So this new repository acts on the current runtime "main" data, not on a file
stored on disk.
Note that the Asset Browser still has to refreshed or reopened when
creating/deleting assets, so that the changes are reflected.
Partially a compile fix for previous commit. But also moving asset-data
read/write into `asset.c`, like we do it for more and more
data-structures in master.
Previously my idea was that when creating an asset for the user
repository, we'd always create a deep copy of the data-block for storage
in the repository.
However for the initial design, we decided to not let Blender
automatically save things into a repository. The user has to mark a
data-block as asset and save the file, so the asset is stored as part of
that file. By adding a path to the Preferences, all .blend files in that
path become part of a repository and users can then access their assets
in different projects through the Asset Browser (not done yet).
Because of this, the operator is now called "Make Asset" again, not
"Create Asset". We don't create a new asset, we just add asset data to
an existing data-block.
This should work for objects, groups, materials, images. It can be added
for more data-block types.
The Asset Browser UI code basically forwards some asset information
(like the path) to the general UI code. This can then append the asset's
data-block once dropping it into the viewport.
* Add search button
* Add filter and display options popups from the File Browser. These might have
to be tweaked for the Asset Browser, but adding the buttons as a first step
to fill the space.
* Add properties sidebar toggle button (gear icon, like in the File Browser)
* Add dummy repository selector
* Use placeholder icon for Asset Browser editor
The categories are the same you can find in the File Browser filter popup:
Scenes, animations, object & collections, geometry, shading, images & sounds,
environments and miscellaneous.
And again, all of this is more of a prototype, things will change a lot still.
* Make sure exactly the wanted regions are visible
* Make sure toggling back and forth between the Asset and the File Browser
works fine (with correct region setup and other settings)
* Hide File Browser only region contents (e.g. panels on the left)
* Use thumbnail mode as default for the Asset Browser
So rather than having an asset data-block to reference data-blocks, let
the data-blocks reference asset-data.
After talking to Brecht, it seems that this approach is just fine. I previously
added the data-block type because I saw some benefits (faster & simpler asset
metadata reading, non-data-block assets, better file-browser integration,
simple remapping of referenced data-blocks), but there are ways to do the same
without the data-block. It's a bit more complicated that way, but still very
doable.
Tags are basically a list of strings. We could optimize these in future if
needed. We could also easily add colors or icons for individual tags (e.g. like
on developer.blender.org).
Note that there's no UI for this yet. Functionality is available via Python
though.
Assets have to own a copy of the referenced data-block's preview for this to
work. We *could* do without that, but it complicates partial reading of
data-blocks for the file browser (which may be addressed with further work
though).
With this we can read asset data in .blends more efficiently, e.g. for browsing
files or assets (where we avoid reading more than we have to). But there are
other things besides performance that I'd like to play with.
Basically I see the asset information a bit similar to library information,
which we also deal with as a separate data-block.
The "Create Asset" operator doesn't actually create these data-blocks yet.
That'll be added in a followup commit.
Of course this is not set in stone, but I think a reasonable design to work
with for now.
To generate the preview, a temporary main data-base is created (think of this
as a virtual .blend within the current .blend) with a new scene and the object
to generate the preview for. It's rendered with a camera from the front, using
the "Camera Fit Frame to Selected" logic.
This should be a simple solution requiring no further setup that should work in
most cases. If needed we can have a way to set up the preview differently.
To see it in action:
* In the Outliner context menu for an object run ID Data > Create Asset
* Save the file
* Open a different file (so you can browse into the former)
* Use link/append to navigate into the saved file with the assets. You should
see the preview in thumbnail mode.
The term "make" in this context refers to modifying an item to obtain a certain
property. Creating an asset however means saving a copy of a data-block as
asset. So "create" is better suited here.
Accessible via the Outliner context menu (ID Data submenu).
The operator currently copies the data-block and creates empty asset data for
it. This will later contain all the meta-data to "give the data-block meaning".
Of course there are many TODOs and questions remaining. This is the first step
so I can work more on meta-data support.
I created some files and that I think make sense.
2020-07-01 20:30:13 +02:00
4853 changed files with 171038 additions and 354223 deletions
option(WITH_VULKAN_SHADER_COMPILATION"Temporary flag to enable vulkan shader compilation needed to continue development during the migration of GLSL to Vulkan."OFF)
# OpenGL
option(WITH_OPENGL"When off limits visibility of the opengl headers to just bf_gpu (temporary option for development purposes)"ON)
option(WITH_OPENGL"When off limits visibility of the opengl headers to just bf_gpu and gawain (temporary option for development purposes)"ON)
option(WITH_GLEW_ES"Switches to experimental copy of GLEW that has support for OpenGL ES. (temporary option for development purposes)"OFF)
option(WITH_GL_EGL"Use the EGL OpenGL system library instead of the platform specific OpenGL system library (CGL, glX, or WGL)"OFF)
option(WITH_GL_PROFILE_ES20"Support using OpenGL ES 2.0. (through either EGL or the AGL/WGL/XGL 'es20' profile)"OFF)
@@ -530,7 +495,6 @@ mark_as_advanced(
WITH_GLEW_ES
WITH_GL_EGL
WITH_GL_PROFILE_ES20
WITH_VULKAN_SHADER_COMPILATION
)
if(WIN32)
@@ -640,6 +604,12 @@ if(WIN32)
option(WITH_WINDOWS_FIND_MODULES"Use find_package to locate libraries"OFF)
mark_as_advanced(WITH_WINDOWS_FIND_MODULES)
option(WINDOWS_USE_VISUAL_STUDIO_PROJECT_FOLDERS"Organize the visual studio projects according to source folder structure."ON)
message(FATAL_ERROR"32 bit compiler detected, blender no longer provides pre-build libraries for 32 bit windows, please set the LIBDIR cmake variable to your own library folder")
Thisconfigurationfile isusedbybuildbot new pipelineforthe`update-code`step.
The file allows to set branches or specific commits for both git submodules and svn artifacts. Can also define various build package versions for use by build workers. Especially useful in experimental and release branches.
Itwillsoonbeusedby the ../utils/make_update.pyscript.
NOTE:
* The configurationfile is ```NOT``` used by the `../utils/make_update.py`script.
setBUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -G "Visual Studio %BUILD_VS_VER%%BUILD_VS_YEAR%%BUILD_GENERATOR_POST%"%BUILD_PLATFORM_SELECT%%TESTS_CMAKE_ARGS%%CLANG_CMAKE_ARGS%%ASAN_CMAKE_ARGS%%PYDEBUG_CMAKE_ARGS%
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.