1
1

Compare commits

...

798 Commits

Author SHA1 Message Date
29704854df hide new nodes behind feature flag 2021-09-09 11:40:09 +02:00
015bde6145 Add description for domain property 2021-09-08 09:58:09 -05:00
8d19ceaee7 Rename "dst_hints" to "dst_varrays", update comments 2021-09-08 09:58:01 -05:00
d62cf98164 A few picky changes to comments 2021-09-08 09:51:00 -05:00
655223e4c6 Merge branch 'master' into temp-geometry-nodes-fields 2021-09-08 09:13:22 -05:00
6bc6ffc35c Fix T91241: wrong labels and identifiers for id sockets
`nodeAddSocket` expects the name and identifier in a
different order.
2021-09-08 15:57:22 +02:00
96ef184377 USD import: remove unused files.
Removed unused usd_reader_instance.cc and .h files.
2021-09-08 09:29:16 -04:00
ba5d9fa275 Cleanup: typedef enum for eImageType. 2021-09-08 10:35:16 +02:00
b5f2b81751 Cleanup: typedef enum for eImageSource. 2021-09-08 10:34:21 +02:00
60e9fb9929 Cleanup: consisten naming slot -> resolution.
Makes naming consistent with image_gpu.c
2021-09-08 10:28:45 +02:00
Jeroen Bakker
2b2d427bba Fix T90825: Performance texture painting with limited scale.
Improve texture painting/uv editing performance when limited scale is active.
Cause of the slow down is that the image editor draws the image in maximum resolution,
but the 3d viewport uses the limited scale. The variation reuses the same GPU texture
and needed to be uploaded/scaled twice to the GPU.

This patch will adds texture slots that can hold the scaled down and the maximum
resolution image. This would allow better cache hits and reuse of existing caches.

Maximum resolution textures are reused for limited scale when they fit to reduce memory
and CPU footprint.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D12388
2021-09-08 09:56:13 +02:00
Jeroen Bakker
54f5c174a8 Asset: Dropping Material assets on material slot under mouse cursor.
This patch allows dropping material assets from material slot under the mouse
cursor. Before this change the material slot had to be hand-picked from the
properties panel.

For consistency it is chosen to do this in any shading mode as the tooltip shows
what is exactly going to happen during release.

The feature also works for other object types than Meshes as it uses the drawn surface on the
GPU to detect the material slots. Performance of this patch has been tested with AMD GCN3.0
cards and are very responsive.

Reviewed By: fclem, Severin

Differential Revision: https://developer.blender.org/D12190
2021-09-08 08:47:26 +02:00
8d40d61af0 Fix T91225: Quick Favorites and shortcuts are broken for some properties
Caused by {rB3e4d720ae483}.

Before above commit, this had a different path handling and
RNA_path_from_ID_to_struct() was always used [which kind of took care of
this]. Now this is only used if ptr represents an ID itself, so we are
"loosing" part of the path.

This patch adds the path back on the member_id in
wm_context_member_from_ptr() for everthing related to space_data, so
WM_context_path_resolve_property_full() can construct a full path even
for these.

Maniphest Tasks: T91225

Differential Revision: https://developer.blender.org/D12418
2021-09-08 08:25:57 +02:00
7beb4a0e0a Fix non-exiting property in keymap
In e6a1d488ab `deselect_all` property was removed from
`sequencer.select` operator but some keymap items were missed, which was
caught by tests by buildbot.
2021-09-08 01:23:07 +02:00
1680c3d510 UI: Remove label of mode in Point Instance node
There isn't enough space for this label at the default node width, and
it was obvious what the drop-down is doing anyway.
2021-09-07 17:05:58 -05:00
e6a1d488ab Cleanup: VSE select operator
Operator combines more features and it wasn't very transparent which
properties are used in which feature and how they are used.

Features linked_time, side_of_frame and linked_handle are
isolated, logic moved into own function.

deselect_all property was removed as it practically equals to
!extend in all cases.

Functional change: Dragging existing selection will not change active
strip. Previously this could happen if click happened on strip that
wasn't active.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D12320
2021-09-08 00:01:00 +02:00
4abbf6d82b Fix T90967: Snapping not working with single strip
Even if `snap_targets` `SeqCollection` is empty, there can be static
snap points defined, so don't condition snapping on non-zero target
count.

Differential Revision: https://developer.blender.org/D12400
2021-09-07 23:39:50 +02:00
Christoph Lendenfeld
adbafe3b43 Animation: Implement generic slider in graph_slider_ops
This patch implements the generic slider from
`ed_draw.c` to the `GRAPH_OT_decimate` operator
This draws a useful UI and enables precision mode and stepping
Overshoot is disabled
The status message is moved to the workspace footer

Reviewed by: Sybren A. Stüvel
Differential Revision: https://developer.blender.org/D9361
Ref: D9361
2021-09-07 20:10:53 +01:00
a392609ab6 Cleanup: Move function to versioning_common.cc 2021-09-07 13:28:14 -05:00
54cc128a31 Remove changes to the Point Translate node 2021-09-07 13:14:31 -05:00
fa5a9b0f6a Merge branch 'master' into temp-geometry-nodes-fields 2021-09-07 13:05:06 -05:00
73ef2fc2f4 Fix T91093: off by one error in when resampling curve
The bug existed in the Curve Resample and Curve to Points node.

Differential Revision: https://developer.blender.org/D12416
2021-09-07 16:07:18 +02:00
08acbdc1ff Fix T91219: Crash canceling scale keyframes in dope sheet grease pencil
Caused by {rBb0d9e6797fb8}

Ideally `td->loc` should always be set and point to a 3d array.
2021-09-07 11:04:20 -03:00
2b4afcbb4c Fix T91236: AssetBrowser crash with certain collections
Caused by {rB5a9a16334c57}

Linking/appending an asset made from a collection containing certain
types of objects lacking bounding boxes (camera, light) would crash.

Add simple bbox check to prevent the crash.

Maniphest Tasks: T91236

Differential Revision: https://developer.blender.org/D12415
2021-09-07 13:22:04 +02:00
c2ce68a018 Fix T91238: crash when instancing geometry group input 2021-09-07 13:18:59 +02:00
8cc3d2d6f5 ID management: add options to force make local or force copy IDs when making them local.
This is to be used when calling code already knows whether the 'made
local' linked ID should be copied, or can directly be converted to a
local one.

Currently unused , this is preparation for rewrite of append code.
2021-09-07 10:18:49 +02:00
cffd4a7ccf Cleanup: Add comment about reusing span for input and output 2021-09-06 20:43:21 -05:00
2012469acc fix exposed string property 2021-09-06 20:54:56 +02:00
713da0fcc4 remove unused function 2021-09-06 20:54:56 +02:00
8ba889a4be Merge branch 'master' into temp-geometry-nodes-fields 2021-09-06 19:42:52 +02:00
5cd7e557ae Cleanup: Comment formatting 2021-09-06 12:39:53 -05:00
584af77101 Add assertion in FieldEvaluator for evaluation state 2021-09-06 12:30:40 -05:00
d53e400454 Merge branch 'temp-geometry-nodes-fields' of git.blender.org:blender into temp-geometry-nodes-fields 2021-09-06 12:24:21 -05:00
64d1fe3450 Update field tests for the newer API 2021-09-06 12:24:17 -05:00
d7d8eb7de4 GPencil: Change icons missing in previous commit
It was missing to change the modifier itself, not only RNA enum list.
2021-09-06 18:56:45 +02:00
08593e46a3 Fix T91187: incorrect socket identifier 2021-09-06 18:47:06 +02:00
3b1a16833b UI: Area Split and Join Mouse Cursor Feedback
This patch just changes the mouse cursor to a "stop sign" when dragging
to an unsupported location during Join or Split operations.

See D11396 for details and examples.

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

Reviewed by Campbell Barton
2021-09-06 09:40:59 -07:00
5a9a16334c Geometry Nodes: support for geometry instancing
Previously, the Point Instance node in geometry nodes could only instance
existing objects or collections. The reason was that large parts of Blender
worked under the assumption that objects are the main unit of instancing.
Now we also want to instance geometry within an object, so a slightly larger
refactor was necessary.

This should not affect files that do not use the new kind of instances.

The main change is a redefinition of what "instanced data" is. Now, an
instances is a cow-object + object-data (the geometry). This can be nicely
seen in `struct DupliObject`. This allows the same object to generate
multiple geometries of different types which can be instanced individually.

A nice side effect of this refactor is that having multiple geometry components
is not a special case in the depsgraph object iterator anymore, because those
components are integrated with the `DupliObject` system.

Unfortunately, different systems that work with instances in Blender (e.g.
render engines and exporters) often work under the assumption that objects are
the main unit of instancing. So those have to be updated as well to be able to
handle the new instances. This patch updates Cycles, EEVEE and other viewport
engines. Exporters have not been updated yet. Some minimal (not master-ready)
changes to update the obj and alembic exporters can be found in P2336 and P2335.
Different file formats may want to handle these new instances in different ways.

For users, the only thing that changed is that the Point Instance node now
has a geometry mode.

This also fixes T88454.

Differential Revision: https://developer.blender.org/D11841
2021-09-06 18:31:25 +02:00
d9ad77fa58 GPencil: Replace temp icons for final design
New icons for LIneArt and Length modifier
2021-09-06 18:00:50 +02:00
bd79d6067c make.bat: Fix missing quotes in python detection 2021-09-06 17:58:38 +02:00
4b091f2eb6 add comments for anonymous attributes 2021-09-06 17:41:15 +02:00
e70f9b0d0e Cleanup: Rename functions
- "try" is not necessary / doesn't really make it clearer
- Fix incorrect name
2021-09-06 10:39:05 -05:00
ce71357711 Fix T90414: New GPencil icons
Designed by @mendio

The new icons are:

* Dot-Dash modifier
* Length Modifier
* Line Art modifier
2021-09-06 17:35:12 +02:00
Erik Abrahamsson
5a02d0da7a Fluid: Parallelizations for Mantaflow functions (D12002)
This update includes part of a performance boost from D12002.
Contributed by @erik85
2021-09-06 17:30:30 +02:00
3e23af4c49 Fluid: Clang-format cleanups
Just cleanup.
2021-09-06 17:30:30 +02:00
d2d10e63c9 Merge branch 'master' into temp-geometry-nodes-fields 2021-09-06 17:25:40 +02:00
b51f68d780 Various small cleanups and comment changes 2021-09-06 10:22:21 -05:00
a3ca973dec Nodes: fix incorrect id socket update
The issue was that the entire socket was rebuild, even though
only its `SOCK_HIDE_LABEL` flag changed. This broke e.g.
Object sockets from old files.
2021-09-06 17:21:42 +02:00
c3adfd6d5d Cleanup: Rename node identifier's and file to include "Input" 2021-09-06 09:50:08 -05:00
861b7071a2 Fix crash drawing hair with older GPUs.
Some GPU's have support for compute shaders, but don't support
GLSL 4.3. This resulted in compiler errors and crashes.

This issue could have been solved by supporting older GLSL languages but
that would have been a hassle to get it right. We already have a
fallback in place for GPU's that don't support compute shaders at all.
2021-09-06 15:47:44 +02:00
edac56b414 more comments 2021-09-06 13:35:06 +02:00
8c76ca6a53 cleanup 2021-09-06 13:24:38 +02:00
William Leeson
5eed7cdc8c Division by zero when there are no lights and only emissive surfaces
When rendering the test scene in T79190 which has only emissive surfaces a division by zero occurs. This is a simple patch to remove this.

Reviewed By: brecht

Maniphest Tasks: T79190

Differential Revision: https://developer.blender.org/D11682
2021-09-06 13:14:46 +02:00
0bd2b314e8 Merge branch 'master' into temp-geometry-nodes-fields 2021-09-06 12:55:48 +02:00
e2bbb5b07e BLI: add default hash for shared_ptr and reference_wrapper
This makes it easier to use these types as keys in Map, Set and VectorSet.
2021-09-06 12:54:51 +02:00
2963be588d cleanup 2021-09-06 12:53:03 +02:00
4d0497bea4 Cleanup: format, spelling 2021-09-06 20:34:00 +10:00
4f0ec3cea5 Cleanup: use pre-calculated size variable
Oversight in a0912ff566
2021-09-06 20:32:35 +10:00
687f70ceca ImBuf: add IMB_allocFromBufferOwn that takes ownership of the buffer
Avoids duplicating the image buffer when saving thumbnails.
2021-09-06 20:05:58 +10:00
507f2628fd rename Freeze to Capture 2021-09-06 12:05:41 +02:00
a0912ff566 Cleanup: support passing in arbitrary buffers to IMB_allocFromBuffer
Also remove IB_metadata flag from the resulting imbuf as this image
has no meta-data.
2021-09-06 20:04:25 +10:00
c227b4da17 cleanup 2021-09-06 11:45:50 +02:00
605f145aba cleanup FieldNode 2021-09-06 10:58:56 +02:00
49f1695ed0 BLI_utildefines: add UNUSED_FUNCTION_WITH_RETURN_TYPE
Unfortunately the UNUSED_FUNCTION macro doesn't work for pointer types.

Add UNUSED_FUNCTION_WITH_RETURN_TYPE to workaround this limitation.
2021-09-06 18:58:46 +10:00
81978594a8 Fix tests broken by rB58632a7f3c0f1be6.
Commits breaking RNA API should always run all tests, and do text search
in python code base to ensure everything is updated as needed.
2021-09-06 10:56:02 +02:00
deb7cd5783 Merge branch 'master' into temp-geometry-nodes-fields 2021-09-06 10:31:26 +02:00
b4c9f88cbe Fix thumbnail screenshot error in 58632a7f3c
Scaling didn't clamp above zero, see T89868.
2021-09-06 17:03:45 +10:00
3e44592cb9 Cleanup: comment unused functions 2021-09-06 15:51:53 +10:00
cb0a78cb8f Merge branch 'master' into temp-geometry-nodes-fields 2021-09-05 23:15:06 -05:00
58632a7f3c UI: Blend Preview Thumbnails Showing Workspace
This adds an option to use a capture of the entire main window as the
blend file preview thumbnail.

See D10492 for details and examples.

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

Reviewed by Campbell Barton
2021-09-05 21:05:50 -07:00
91bca410c0 Cleanup: clang-format 2021-09-05 23:25:36 -04:00
bf0ac711fd UI: Increase Size of Blend File Thumbnails
Increase effective resolution of blend preview images from 128x128 to
256x256 for versions saved in the file system thumbnail cache.

See D10491 for details and examples.

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

Reviewed by Campbell Barton
2021-09-05 19:55:50 -07:00
Aaron Carlisle
4ddad5a7ee UI: Split Output Properties Dimensions panel
I remember when we originally decided on the Dimensions panel,
one of the reasons we combined time and image size properties in the same panel,
was simply because the 2.49 and previous UIs used fixed-size panels,
so we often put two categories of properties inside a panel, using two columns.

Now that we no longer do this, we could clarify and simplify some panels
by splitting them, such as the Output > Dimensions panel

{F6753690}

Reviewed By: brecht, pablovazquez

Differential Revision: https://developer.blender.org/D4440
2021-09-05 21:27:49 -04:00
Aaron Carlisle
d10ea97053 Compositor: New Posterize Node
The posterize node limits the number of colors per channel.
This is useful to generate masks or to generate stylized images

Both the tiled and full-frame implementation are included in this patch

{F10314012}

Reviewed By: manzanilla, jbakker

Differential Revision: https://developer.blender.org/D12304
2021-09-05 15:24:35 -04:00
b7718bbdf5 Cleanup: improve code clarity
Addresses D12341 review.
2021-09-05 14:25:14 +02:00
079bd11556 Fix T91143: Gpencil Set Vertex Color not using Linear
The color was not converted to Linear from Brush color.
2021-09-04 18:28:54 +02:00
b225a7c470 Compositor: Merge equal operations
Some operations can take a lot of time to execute and
any duplication should be avoided.

This patch implements a compile step that detects
operations with the same type, inputs and parameters that
produce the same result and merge them. Now operations
can generate a hash that represents their output result. They only
need to implement `hash_output_params` and hash any parameter
that affects the output result.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D12341
2021-09-04 17:09:59 +02:00
d84c79a218 Compositor: Full frame vector nodes
Adds full frame implementation to Map Range, Map Value, Normal and
Normalize nodes. The other nodes in "Vector" sub-menu are submitted
separately.

Part of T88150.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D12233
2021-09-04 17:06:01 +02:00
9d7cb5c4a1 Compositor: Full frame filter nodes
Adds full frame implementation to Anti-Aliasing, Defocus, Denoise,
Despeckle, Dilate/Erode, Directional Blur, Filter, Inpaint and
Vector Blur nodes. The other nodes in "Filter" sub-menu are
submitted separately.

Part of T88150.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D12219
2021-09-04 17:05:58 +02:00
9290b41381 Python: Allow Area Close via Scripting
Screen area maintenance "Close" function allowed to be scripted.

See D12307 for usage example.

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

Reviewed by Campbell Barton
2021-09-04 08:00:22 -07:00
Henrik Dick
54b72fe9ff GPencil: Fix Noise Modifier Randomize Panel disabled
Fix regression introduced in rB34b213d60472

Reviewed By: antoniov

Differential Revision: https://developer.blender.org/D12398
2021-09-04 16:03:15 +02:00
Henrik Dick
c23b6596b9 GPencil: Fix subdivision modifier disabled on strokes with 2 points
Fixes the regression introduces in rB29f3af952725 . The subdivision modifier used to work on two point strokes with simple mode but not with catmul clark. Now it will work with simple mode and in case of catmull clark mode it will still use simple mode on these strokes.

Differential Revision: https://developer.blender.org/D12397
2021-09-04 15:41:43 +02:00
Mikkel Gjoel
863d806526 BMesh: optimize edge & face group calculation
This changes the search for unprocessed faces to only search
from the previously found face. Local testing on 1.5 million
triangle meshes gives a 75x speedup
(of the code affected, which is the first half of the work).

The former code would traverse all faces of a mesh until a face was
found that had not been processed. This ended up being slow mainly
because it had to load face-data to determine the state of the flag.
Secondarily, the way it iterated and marked the mesh, it would end up
traversing all previously processed faces to find and unprocessed one.

The same optimization has been made for edge-group calculation.

Reviewed By: campbellbarton

Ref D12379
2021-09-04 23:07:45 +10:00
e6194e7357 RNA: support extracting names from paths without allocating memory
Support extracting identifiers RNA paths into fixed size buffer
since the maximum size of the identifier is known all cases.

- Add BLI_str_unescape_ex to support limiting the destination buffer.
- Add BLI_str_quoted_substr to copy values into a fixed size buffer.
2021-09-04 16:59:54 +10:00
716682365c Fix T91119: Curve to mesh node inverted face normals
Previously I thought I fixed this by reversing the face corner indices
in quads created by the curve to mesh node. But then we fixed a problem
with the transforms used in that node by inverting one of their
components, so the required direction also reversed. This commit
reverts rBcf28398471c84 and reverses the default direction of the
quadrilateral primitive so it's the same as the others.

Tests will be updated.
2021-09-03 16:49:47 -05:00
70e3b6d11f Rename position node file 2021-09-03 15:16:35 -05:00
e041389c68 Fix crash in normal node 2021-09-03 15:15:06 -05:00
4fb7217043 UDIM: Show the UV grid even when images are loaded
Allow the UDIM grid to be shown and adjusted when there are images
loaded in UV edit mode. Right now the grid feature disappears once an
image is loaded and many have found this to be confusing.

Based on community and artist feedback, there was support to change this
behavior[1]

This patch does the following:
- Allows the grid to be shown even when images are present
- The max allowable dimensions for the grid has been increased from
10x10 to 10x100 to match the underlying maximum UDIM range that blender
supports

Note: This should not affect other Image editor modes like Paint/Mask or
the Render Result viewer etc. Future work in this area is currently
documented in a dedicated design task[2]

[1] https://devtalk.blender.org/t/the-udim-tile-grid-design-and-feedback-thread/20136
[2] https://developer.blender.org/T90913

Differential Revision: https://developer.blender.org/D11860
2021-09-03 13:03:28 -07:00
38574e37cc Various small cleanups 2021-09-03 13:42:45 -05:00
8186dddec1 Merge branch 'master' into temp-geometry-nodes-fields 2021-09-03 13:21:26 -05:00
47fa00ffef Support fields in the point translate node, add selection input
Because we don't have a "Extract Named Attribute" node currently,
I had to keep the old string input. Otherwise we wouldn't be able to
add versioning.
2021-09-03 13:12:50 -05:00
62f8bb87b7 Add utility methods for field destinations and selection fields 2021-09-03 13:06:54 -05:00
235655ee0d Improve message in ob_parbone() about the missing Parent Bone
- lower to warning (might be debatable, but this is not really
malfunctioning and e.g. constraints/modifiers dont spit out errors if
targets are not specified)
- clarify _what_ of the two actualy does not exist

ref. T91101

Maniphest Tasks: T91101

Differential Revision: https://developer.blender.org/D12389
2021-09-03 17:16:42 +02:00
a45dd52cf0 Depsgraph: skip parentbone relation if bone prop is empty
Clearing the Parent Bone field in relations would result in something
like this:

```
add_relation(Bone Parent) - Could not find op_from
(ComponentKey(OBArmature, BONE))
add_relation(Bone Parent) - Failed, but op_to (ComponentKey(OBEmpty,
TRANSFORM)) was ok
ERROR (bke.object): /source/blender/blenkernel/intern\object.c:3330
ob_parbone: Object Empty with Bone parent: bone  doesn't exist
```

Now skip creation of a depsgraph relation if the Parent Bone field is
empty (since this would be invalid anyways).

ref. T91101

Maniphest Tasks: T91101

Differential Revision: https://developer.blender.org/D12389
2021-09-03 17:15:05 +02:00
5617cb5500 add some comments 2021-09-03 17:09:43 +02:00
Leon Leno
ac97893dfc Fix T88411: Draw frame node text when label is empty
This patch fixes the issue described in T88411, that the text in frame nodes is only shown, when the node has a label. This has been caused by rB8f04ddbbc626, because `node_draw_frame_label` not only draws the label, but also all the other text. Therefore skipping it, when the label is empty, also skips drawing the other text.
This is fixed by moving the check for the empty label into `node_frame_draw_label`.

**Patch:** Frame nodes show text despite not having a label.
{F10286204, size = full}

**Same setup in master:**
{F10128099, size = full}

**Test file**
{F10128102}

Reviewed By: #user_interface, pablovazquez

Maniphest Tasks: T88411

Differential Revision: https://developer.blender.org/D11315
2021-09-03 16:18:40 +02:00
a4d4188c8d rename field related classes 2021-09-03 16:12:47 +02:00
ae334532cf GPencil: Smooth thickness when joining strokes
When joining two strokes in paint mode using the auto merge option, the join was very hard if the thickness was too different.

This patch adds a smooth to the join in order to get better transition.

Also fixed the problem to join existing strokes very far from actual stroke.

Some cleanup and rename of old code is included in order to make code more readable.

Reviewed By: pepeland

Differential Revision: https://developer.blender.org/D12362
2021-09-03 15:24:13 +02:00
f9ccd26b03 Fix T87768: .path_resolve fails when requested property is None.
Add a version of RNA_path_resolve_full that returns true
when the path resolves to a NULL RNA pointer.
2021-09-03 21:58:52 +10:00
f487dbae97 use GFieldRef where appropriate 2021-09-03 13:29:22 +02:00
0950cfd9d5 PyAPI: add read-only 'is_valid' attribute to mathutils types
There was no convenient way to check if the owner
of a mathutils type was valid.

Added to support issue reported in T91111.
2021-09-03 21:21:44 +10:00
94b98d3f88 fix bug when the same field is evaluated twice 2021-09-03 12:54:28 +02:00
f530b43550 Fix T91159: GPencil Smooth brush is using Affect Pressure but not used
The parameter wa sin the UI but was not used because it was replaced by Use Thickness.
2021-09-03 12:42:18 +02:00
d97fd305a0 RNA: minor optimize for token extraction of RNA paths
- Split rna_path_token in two,
  extracting bracket handling into it's own function.

- Only handle escape characters for quoted tokens.
  Numbers were copied using BLI_str_unescape which is unnecessary.

- Extract text without without quotes,
  use a return argument so the caller can tell if the token was quoted.
  This avoids having to strip the tokens quotes afterwards.
2021-09-03 20:35:46 +10:00
32f101c603 add initial Attribute Freeze node 2021-09-03 11:55:22 +02:00
671640b4c7 Cleanup: use bool for RNA path token extraction 2021-09-03 19:42:54 +10:00
2feed5ce33 support deduplication of normal node 2021-09-03 11:06:50 +02:00
f7b9114eec fix typo 2021-09-03 10:53:06 +02:00
7f017a51bb Merge branch 'master' into temp-geometry-nodes-fields 2021-09-03 10:48:12 +02:00
Rajesh Advani
684500837d Cleanup: convert function nodes socket list to use new API
The new API was introduced in rB1e69a25043120cc8dddc3f58622eb50e1443def1.

Differential Revision: https://developer.blender.org/D12380
2021-09-03 10:45:48 +02:00
4a3243f311 Docs: add note to skip_fcurve_selected_data sequence strip check
Without an explanation the sequencer logic looked wrong since
other selection checks don't skip data that can't be found.
2021-09-03 15:15:45 +10:00
efbe1ea8c7 Cleanup and improve comment 2021-09-02 23:05:54 -05:00
2b38770ebd Add initial normal node
In contrast with the read-only "normal" attribute on the face domain,
this node gives normalized values for every mesh domain, including
edges and corners. This is preferrable since it's much more predictable
to work with.

The implementation is a little more complicated than I would like,
but could be improved with const access to lazy calculation of normals
on meshes, which is something I've been planning to work on anyway.
2021-09-02 23:00:00 -05:00
5a96096c5e Fix function and define names 2021-09-02 22:55:09 -05:00
ce1519d804 Cleanup: Internally rename "position" to "input_position"
Maybe we'll decide not to do this, for now maybe it's better to be consistent though
2021-09-02 16:24:08 -05:00
bd1375f9cb Cleanup: Rename index node define 2021-09-02 16:20:00 -05:00
af641d0912 Add "Index" node 2021-09-02 16:13:44 -05:00
6c0ae5e890 Allow Set Position node to act on more component types, cleanup 2021-09-02 16:11:30 -05:00
fac0723e92 Add a special case for a selection span
This will probably end up being a utility used elsewhere,
so it's worth adding this case.
2021-09-02 15:57:35 -05:00
68a8a89c49 Reorder input sockets
Since the position is the more important input compared to the
selection, it should be on top
2021-09-02 15:48:36 -05:00
8c9432be6a Cleanup: Remove unnecessary include 2021-09-02 15:47:50 -05:00
6e08de6028 Merge branch 'master' into temp-geometry-nodes-fields 2021-09-02 14:58:26 -05:00
6fc92b296f GPencil: Change default Scale Thickness to True in 2D template
This parameter is more logic as true because is better scale thickness when the size of the stroke changes.

Reviewed by: @mendio @pepeland
2021-09-02 16:26:13 +02:00
8849bed671 Revert "PyAPI: GPU Shader: add 'state' parameter to uniform sampler"
This reverts commit 2aad8fc7bc.

It was a commit without proper review.

A better API needs to be discussed.
2021-09-02 10:19:58 -03:00
546314fc96 Build utils: make_update: Add option to choose SVN branch.
Needed for studio sprite-fright frozen branch.

Also do not overwrite branch for git sub-modules when it is defined, and
fallback to `master` branch in case specified branch is not found in a
specific sub-repository.
2021-09-02 14:56:46 +02:00
00ed599fe4 fix test 2021-09-02 13:42:54 +02:00
769c7521b5 fix attribute field source deduplication 2021-09-02 13:00:59 +02:00
e23ccfe913 Merge branch 'master' into temp-geometry-nodes-fields 2021-09-02 12:50:26 +02:00
7398076be2 cleanup 2021-09-02 12:48:02 +02:00
ea98f53dcd add initial Position and Set Position node 2021-09-02 12:42:38 +02:00
70cbbd614f get more efficient virtual array from MFParams 2021-09-02 12:41:51 +02:00
95288eba59 improve field evaluator and add geometry context 2021-09-02 12:41:19 +02:00
799a2b07ad Fix possible missing render result with update_result
Need to ensure render result's pixels are allocated prior to merge.

Differential Revision: https://developer.blender.org/D12371
2021-09-02 09:28:42 +02:00
a8739ae6c2 Fix regression in recent change 0708733c46
Adding a mirror modifier in edit-mode crashed.

Freeing meshes that hold a shallow copy happens in multiple places
while calculating modifiers, making it impractical to clear the
edit-mode pointer before freeing the mesh (as done in
BKE_editmesh_free_derived_caches).

Add a struct member to the edit-mesh struct so evaluated copies
don't free the edit-mesh contents.
2021-09-02 16:12:24 +10:00
a2f3aca647 Cleanup: remove redundant edit-mesh memory allocation
This memory was only duplicated to satisfy mesh_data_free
which was incorrectly freeing the pointer (but nothing else).
2021-09-02 15:30:54 +10:00
19e1b5c1fd Fix T90972: Crash calling Mesh.clear_geometry in edit-mode
No longer free the edit-mesh pointer while in edit-mode since this
isn't reliable to keep the object in edit-mode while freeing it's
edit-mesh data.

Users who want to exit edit-mode should do so explicitly.

Caused by 6d2f9b1dfa.
2021-09-02 15:30:54 +10:00
0708733c46 Fix T91123: Freeing meshes in edit-mode leaks memory
Freeing the edit-mesh pointer wasn't free the edit-mesh data it's self.

Unlinking from the outliner or through the Python API leaked memory.

This didn't often cause leaks in practice since ED_editors_exit
exits edit-mode for all objects.

Now freeing mesh data frees the edit-mode data as well,
this matches the behavior of other object types that support edit-mode.
2021-09-02 15:30:54 +10:00
809b33b69a Docs: improve the error when undo poll fails
Calling undo in from Python background-mode would raise an exception
without any information about how to initialize undo.
2021-09-02 15:30:54 +10:00
01037308d5 Cleanup: Change wording of comments 2021-09-01 23:46:25 -05:00
1765e1b20a Merge branch 'master' into temp-geometry-nodes-fields 2021-09-01 23:03:23 -05:00
Johnny Matthews
0ccbf50694 Cleanup: Convert geometry nodes socket list to use new API
The new API introduced in rB1e69a25043120c provides a shorted, more
flexibly way to declare node socket inputs and outputs. This commit
updates all geometry nodes to use the `NodeSocketBuilder` API, except
the four nodes that need `SOCK_HIDE_VALUE` or `SOCK_MULTI_INPUT`.

Differential Revisions: D12377, D12376, D12374, D12373, D12372
2021-09-01 22:53:52 -05:00
4170668776 Cleanup: Grammar 2021-09-01 22:22:35 -05:00
f77de678d8 EditMesh: recalculate normals after running rip
Failure to calculate normals caused an assertion since face
tessellation was being calculated with invalid normals.

In practice the rip-drag action would recalculate normals anyway,
however mesh tessellation should always be performed with valid normals.
2021-09-02 11:45:55 +10:00
011d3a95e0 Cleanup: de-duplicate logic in bpy keyframing logic 2021-09-02 11:41:01 +10:00
6c177838f3 Cleanup: remove redundant alloc argument to SEQ_editing_get
Callers that require lazy initialization can use SEQ_editing_ensure.
2021-09-02 11:29:32 +10:00
baee000001 Fix T90798: calc_loop_triangles is not updated after joining objects 2021-09-02 11:08:38 +10:00
f8dd0d0dba Cleanup: spelling in comments 2021-09-02 11:08:38 +10:00
42546db490 Fix T91054: Editing group custom property gives error
This commit fixes the custom property edit operator for the the case of
editing group properties. Currently this isn't supported very well, the
data is converted to a string, but the operator shouldn't fail anyway.

This allows editing properties created like this:
C.object['abuse'] = {'parent' : ['child1', 'child2']}

These changes reflect some issues with the design of the operator.
Requiring guessing the type of the data does not work well at all, and
makes code more complicated. In the future this operator can be updated
to use a type drop-down.

Differential Revision: https://developer.blender.org/D12364
2021-09-01 11:47:59 -05:00
99c981fd06 Cleanup: Remove redundant property UI data clear
Since the UI data is now stored in the property, and the property is
deleted on the next line, this doesn't need to be called separately.
2021-09-01 11:46:21 -05:00
7cb4665bee new FieldEvaluator utility class 2021-09-01 18:01:48 +02:00
d6bddbef2d add more flexible field evaluation method 2021-09-01 17:00:26 +02:00
083a8921ec Fix strict warning about discarding const qualifier
Solved by using const qualifier for arguments which aren't mutable
in PyC functions.

Differential Revision: https://developer.blender.org/D12369
2021-09-01 17:00:08 +02:00
f62eb8ac16 BPY-Docs: Add missing file context members documentation
Context members of the file space would not be shown in the context API
docs.
2021-09-01 16:28:44 +02:00
2aad8fc7bc PyAPI: GPU Shader: add 'state' parameter to uniform sampler
Now you can choose the state of texture (as a filter and repetition) to
render it.

This is important as the original state is very limited.
2021-09-01 10:39:14 -03:00
7ec839adfa File Browser/BPY: Expose list of selected files in context
Since recently it's possible to query the active file (as object, not
just the name), but it's quite useful for scripting to have access to
all selected files.
This introduces `bpy.context.selected_files`, returning a list of file
objects representing files in the File Browser.
2021-09-01 15:13:18 +02:00
79281336c0 File Browser/BPY: Expose relative path of a file via BPY
There were requests to be able to track the file selection in the File
Browser. Just using the file name for that wouldn't if the file browser
has the recursive display enabled. File names could be duplicated then.
So expose the entire path relative to the currently displayed directory.
2021-09-01 15:12:50 +02:00
8355e3fc77 Unittest: Extend and basic linking tests and add basic append tests.
We could check many more things still, but this should already cover
most basic common cases.
2021-09-01 12:51:07 +02:00
fcfec33cf7 Merge branch 'temp-geometry-nodes-fields--fields-jacques' into temp-geometry-nodes-fields 2021-09-01 11:52:37 +02:00
e338ebb720 Merge branch 'temp-geometry-nodes-fields--anonymous-attributes' into temp-geometry-nodes-fields 2021-09-01 11:52:14 +02:00
741deadff4 Merge branch 'master' into temp-geometry-nodes-fields 2021-09-01 11:51:56 +02:00
c1cab4aa68 add common base class for field input/operation 2021-09-01 11:39:18 +02:00
e04631f44a Cleanup: clang-tidy utfconv 2021-09-01 17:13:33 +10:00
93c6b12df5 Cleanup: use doxygen sections in py_capi_rna.c 2021-09-01 17:00:47 +10:00
0c5f6f9fa7 Cleanup: Better names for eDRWColorManagement.
Names describe better what will be applied. Previous names were
extracted from the original code, that weren't accurately named.
2021-09-01 08:58:06 +02:00
18a4e5d561 Cleanup: Use nullptr. 2021-09-01 08:54:18 +02:00
89fa9aada5 Cleanup: use "pyrna_enum_*" prefix for RNA utility functions 2021-09-01 16:50:48 +10:00
1730829592 Cleanup: move RNA utility functions into a generic module
Avoid having to include bpy_rna.h for enum utility functions,
recently added to idprop_py_ui_api.c.
2021-09-01 16:33:42 +10:00
5352b33598 BLI_string: return string length from BLI_string_flip_side_name
Useful for callers that need the string length.
2021-09-01 15:24:01 +10:00
2914ec571e Fix errors pasting flipped names in the action editor
Use BLI_str_quoted_substr_range instead of in-line
quote extraction to resolve:

- Bone names containing quotes caused flip to fail.
- Missing NULL check if a matching quote could not be found.
2021-09-01 15:23:59 +10:00
f1cdd49a4e BLI_string: add BLI_str_quoted_substr_range
This is a similar funciton to BLI_str_quoted_substrN
that extracts the range of the quoted string
instead of allocating a new string un-escaped string.
2021-09-01 15:23:58 +10:00
90dac47717 Cleanup: remove redundant strstr calls
Rely on BLI_str_quoted_substrN to detect if the prefix exists since
this function exists early there is no need to check before calling.
2021-09-01 15:23:56 +10:00
838b6ec48a Fix: Incorrect versioning for float IDProperty UI data
The code put the value from the "min" property into the "max"
value. This would have crashed if min was null and max wasn't.
2021-08-31 12:17:05 -05:00
60fba8202c Fix T91088: Assigning custom property value in python resets UI data
Assigning a new value to an IDProperty with the Python API would free
the entire contents of the existing property, which unfortunately
happened to include the UI data. The fix is to extract the UI data from
the existing property before freeing its contents. An alternative
would be adding another argument to `IDP_FreePropertyContent_ex`, but
this solution is clearer and doesn't increase complexity elsewhere.
2021-08-31 11:49:12 -05:00
cfc674408e Fix T91084: Missing versioning for object pose bone property UI data
Objects also have a list of "bone" pose channels embedded directly.
These properties are user visible, so their UI data should be versioned.
2021-08-31 11:12:07 -05:00
596f1878b6 Cleanup: Reduce variable scope 2021-08-31 10:19:31 -05:00
37943b00f2 Fix: Output int for precision in UI data as_dict method
This is stored internally and used as an integer, so there is no need
to convert it to a float for "as_dict". This was just an oversight.
2021-08-31 09:05:03 -05:00
99b1e8428d Cleanup: pass value by ref in draw_color_management 2021-08-31 15:45:05 +02:00
b18122451f Fix T88433: no greaspencil depsgraph evaluation with certain drivers
When the same stroke was used as a driver variable, this could make this
stroke already tagged as built in the course of building driver
variables (via `build_gpencil`), but then important stuff from
`build_object_data_geometry_datablock` could be missed later on (because
both of these funtions use `checkIsBuiltAndTag`). Most importantly,
setting up operations such as GEOMETRY_EVAL would be skipped entirely.

`build_object_data_geometry_datablock` seems to cover greasepencil just
fine (does the same as `build_gpencil` and more). Proposed solution is to
remove `build_gpencil` entirely. In `build_id` it would then also call
`build_object_data_geometry_datablock` for `ID_GD` IDs. Now the covered
types that _call_ `build_object_data_geometry_datablock` match exactly
to what is covered _inside_ `build_object_data_geometry_datablock`.

Think this "duplication" of functionality was just overseen in
rB66da2f537ae8 [`build_gpencil` existed long before and said commit made
greasepencil a real object with geometry and such].

thx @JacquesLucke for additional input!

Maniphest Tasks: T88433

Differential Revision: https://developer.blender.org/D12324
2021-08-31 15:20:02 +02:00
84f826ff23 Fix T90989: Annotation opacity must not be animatable
All props of annotations are not animatable by design and opacity must be equal.

As the opacity is reused by gpencil objects, a new prop has been created in order to use different props for annotations and GP objects.
2021-08-31 14:59:55 +02:00
1be598ba68 Cleanup: DRW color management seperated in multiple functions. 2021-08-31 14:12:14 +02:00
bf6b04bf89 destruct all variables that are not outputs 2021-08-31 13:40:45 +02:00
6931a6f3bd Cleanup: Moved DRW_vieport_colormanagement_set to draw_color_management. 2021-08-31 13:26:13 +02:00
63dc286b01 Cleanup: Added const keywork to GPU_viewport_colorspace_set. 2021-08-31 13:24:42 +02:00
a18d88213f Cleanup: Converted draw_color_management to CPP. 2021-08-31 13:24:42 +02:00
3abf56db27 Cleanup: Draw Manager remove do_color_management from drawing context.
The do_color_management option was set, but never read.
2021-08-31 13:24:42 +02:00
9ab31b53b7 Cleanup: Remove unused DRW_state_do_color_management.
Function wasn't used since we migrated to the new color management
pipeline. It is also not expected it would be needed in the current
design.
2021-08-31 13:24:42 +02:00
a275572e0b fix string socket 2021-08-31 13:22:05 +02:00
a7ee49d065 Fix crash in recent commit.
Crash introduced by {rB8e00db42961297facd521139762fe8c42042fc5c}, fixed
with a null check. Object can be null.
2021-08-31 13:14:26 +02:00
b0cb0a7854 Texture Paint: sync changing active texture in the Node Editor to the
Image Editor

When changing to another texture paint slot, the texture displayed in
the viewport changes accordingly (as well as the image displayed
in the Image Editor).

When changing the active texture in the Node Editor though, only the
texture displayed in the viewport changes.

This was mentioned in T88788 and I am not 100% sure this is desired in
all scenarios (or at all), it should be seen in tandem of D11497. This
change makes it so that the Image Editor changes to the image we changed
to in the Node Editor (keeping them in sync).

If this is not desired in all cases, this could be made an option.

ref T88788
ref D11496
ref D11497

Maniphest Tasks: T88788

Differential Revision: https://developer.blender.org/D11498
2021-08-31 12:45:39 +02:00
9ec7e23c44 support modifier inputs again 2021-08-31 12:41:13 +02:00
3c5681c212 support field conversion 2021-08-31 12:40:53 +02:00
3b2a01edf6 Texture Paint: sync changing active texture in the node editor to the
active paint slot

When changing to another texture paint slot, the texture displayed in
the viewport changes accordingly (as well as the image displayed
in the Image Editor).

When changing the active texture in the Node Editor though, only the
texture displayed in the viewport changes.

This _can_ be confusing because you can end up painting on a texture
that you are not looking at in the viewport (so you dont have any
feedback whatsoever). Not 100% sure this is desired in all scenarios,
but this change makes it so that the active paint slot changes to the
one that uses the texture we chaged to in the Node Editor (keeping them
in sync).

If this is not desired in all cases, this could be made an option.

ref T88788
ref D11496

Maniphest Tasks: T88788

Differential Revision: https://developer.blender.org/D11497
2021-08-31 12:29:14 +02:00
d8b445e728 Fix missing render result when using region render
Caused by lazy allocation of passes.
2021-08-31 12:12:34 +02:00
28f1e71e2e fix default values 2021-08-31 12:05:11 +02:00
af7233368d Fix T91060: GPencil Time Offset Modifier breaks evaluation time
Caused by {rBf3bf87e5887c}.

When using a GPencil Time Offset Modifier, the bGPDlayer>actframe can be
NULL. This can be determined though, but above optimization commit
skipped getting the active frame in this case entirely (with the
intention to only get it if framenumbers did not match).

Now also call BKE_gpencil_layer_frame_get() if actframe is NULL in order
to fetch a valid one if present.

Maniphest Tasks: T91060

Differential Revision: https://developer.blender.org/D12355
2021-08-31 11:55:16 +02:00
149fd7b65f initial support for function nodes in evaluator 2021-08-31 11:41:53 +02:00
f6d133e2d2 Fix possible wrongly highlighted tiles
Run into it when was re-working tiles in the Cycles X project.
Make sure the storage of highlighted tiles is emptied when the
render is finished or cancelled).

The error is only possible to happen if the engine did not do
something correct, but is still good to deal with such situations
more gracefully.
2021-08-31 11:05:57 +02:00
a55c230b8a initial support in evaluator 2021-08-31 11:03:38 +02:00
f4eacad48f Fix AssetBrowser UI errors
Steps to reproduce:
- enable Extended Asset Browser
- open a regular File Browser

gives:
"rna_uiItemR: property not found: FileSelectParams.asset_category"

Now do proper poll.

Differential Revision: https://developer.blender.org/D12350
2021-08-31 10:41:12 +02:00
1f0d63b9a1 Cleanup: remove unnecessary obedit argument from ED_space_image_set
This was left over from when changing the image set the faces texture.
2021-08-31 18:29:09 +10:00
1f1dc4ade3 field cpp type 2021-08-31 10:22:43 +02:00
8e00db4296 Fix: Weightpaint overlay not visible when display type wire/boundbox.
When the object display type was set to wireframe or boundbox the depth
buffer wasn't updated resulting in not visible weightpaint overlay.

Thanks to Demeter Dzadik for mentioning it.
2021-08-31 10:02:45 +02:00
d445ee4c73 rename to GField 2021-08-31 09:58:12 +02:00
fa4a35d4c4 Measure tool: Add support to restrict dimension to one axis
Support axis constraints for the measure tool.

Press X, Y or Z to restrict the dimension to that axis,
it's also possible to toggle between orientations matching transform.

Reviewed By: campbellbarton

Ref D10872
2021-08-31 17:21:11 +10:00
fa4f9292e1 Transform: avoid passing the context to extended orientation functions
This makes it possible to calculate orientation from functions
that don't have the context.
2021-08-31 17:02:47 +10:00
d718d6b449 Cleanup: Use C style comments for descriptive text 2021-08-31 14:33:57 +10:00
29590eec6e Fix T91054: List of strings custom property cannot be edited
This commit fixes editing the value of a list of strings custom property
with the "Custom Property Edit" operator. This sort of custom property
isn't very well supported in general, but editing the values should
work properly anyway.

Differential Revision: https://developer.blender.org/D12348
2021-08-30 22:21:11 -05:00
c758b87c5e Cleanup: add CTX_data_pointer_set_ptr & CTX_data_list_add_ptr
Many callers expanded a PointerRNA argument,
so add a version of these functions that takes a PointerRNA.
2021-08-31 13:00:31 +10:00
ea575744b8 Fix assigning shortcuts that include array indices
Assigning a shortcut to bone layers for example,
raised a Python exception when used.
2021-08-31 12:30:45 +10:00
63a5f723d6 Fix T90723: User menus & shortcuts fails for sequences, bones & NLA
Use context members instead of not working well or failing due to:

- Missing "path" functions (in the case of edit-bones).

- Paths containing names (in the case of sequence-strips or pose-bones).

  While technically correct it's not useful for shortcuts or
  menu items to lookup data by name.
2021-08-31 12:07:33 +10:00
3e4d720ae4 Fix logical error resolving RNA paths
Only append RNA_path_from_ID_to_struct to context attributes if those
paths resolve to ID types.

Also simplify creating RNA paths by adding utility functions:

- WM_context_path_resolve_property_full
- WM_context_path_resolve_full

Part of fix for T90723.
2021-08-31 12:06:47 +10:00
aabe6e3b45 Context: add "active_nla_track" & "active_nla_strip" context members
Selection was already accessible but not active.

Add utility functions:

- ANIM_nla_context_track to access the active track,
  following the convention of ANIM_nla_context_strip.

- ANIM_nla_context_*_ptr versions of these functions,
  needed to for creating context members to access the ID pointer.

Part of fix for T90723.
2021-08-31 12:06:47 +10:00
65739ded54 Fix 'WM_window_find_under_cursor'
This function was not working if the window is partially out of screen space.
2021-08-30 22:46:10 -03:00
b08ab49cce Fix T90988: Incorrect speed effect strip math
Math implemented in 929d7597b3 was incorrect, but also inconsistent
with previous behavior.

`SEQ_SPEED_STRETCH` should change length only when right handle is
moved. This is now documented in code.
2021-08-31 03:12:00 +02:00
73e52ab55f Fix index field name for debugging 2021-08-30 17:57:01 -05:00
3fec225931 Cleanup: Rename function, add comments 2021-08-30 17:54:43 -05:00
f0443b8859 Cleanup: Remove incorrect comment 2021-08-30 17:50:47 -05:00
b73f692919 Add a slightly more complicated test 2021-08-30 17:49:38 -05:00
4aeb9dc996 Fix incorrect descruction of output variables 2021-08-30 17:49:20 -05:00
bd67bf4d10 Fix VSE move_to_meta function moving meta strip
API function `move_to_meta` should move strips without changing context
data like `MetaStack` that tells UI which meta strip should be
displayed and operated upon.

`SEQ_time_update_sequence` relied on `MetaStack` to update meta strip
content length. Instead of changing function `SEQ_time_update_sequence`,
use function `SEQ_time_update_meta_strip_range` directly. This is
because caller would have to be aware of parent meta strip that needs
update anyway.
2021-08-31 00:27:19 +02:00
1541fbb4a0 PyDoc: Fix compliation warning 2021-08-30 18:26:07 -04:00
d374ff5b8f PyDoc: Fix compilation after recent contex_member addition
Fixes missing change needed for rB0a8f53a7b847d9c8bdcefc025de70fd2608012b7
2021-08-30 18:17:11 -04:00
3b12594054 Fix broken test because of stupid mistake 2021-08-30 16:41:34 -05:00
0597e93e5e Add TODO comment 2021-08-30 16:41:17 -05:00
fbcb9c5e3f Cleanup: sequencer operators
- Use name 'strip' instead of 's'
- Assign a variable to 'scene' instead of accessing from context.
- Avoid temporary variable for swapping values.
2021-08-31 07:39:03 +10:00
c84d1ad3db Cleanup: use new active_sequence_strip context attribute 2021-08-31 07:27:55 +10:00
0a8f53a7b8 Context: add "active_sequence_strip" context member
This is an alternative to context.scene.sequence_editor.active_strip
which could be verbose, especially with additional None checks.

Part of fix for T90723, extracted from D12297.
2021-08-31 07:13:31 +10:00
5f003515a1 Add a new (failing) test and some comments 2021-08-30 15:25:04 -05:00
26f8647fea Add name to variable outputs from functions 2021-08-30 15:24:30 -05:00
12f296d800 Add TODO comment 2021-08-30 15:24:15 -05:00
b7cb7b78a8 Docs: GPU Shader: improvements
Changes:
- line break
- enum highlighting
- better description
2021-08-30 17:12:31 -03:00
75ec632b61 Fix infinite loop 2021-08-30 14:28:03 -05:00
d6519d4305 Fixes for network traversal, add comments 2021-08-30 14:01:54 -05:00
54cf7eaf92 Cleanup: Make construction of function fields easier to read 2021-08-30 14:01:26 -05:00
af3f744b41 Fix: add virtual destructor to base class 2021-08-30 18:26:55 +02:00
d0b1e739b1 Merge branch 'temp-geometry-nodes-fields' into temp-geometry-nodes-fields--fields 2021-08-30 10:59:03 -05:00
b04e2e8877 Merge branch 'master' into temp-geometry-nodes-fields 2021-08-30 10:58:33 -05:00
171c3bd2b0 Cleanup: clang-tidy
readability-named-parameter
2021-08-30 17:30:04 +02:00
1e69a25043 Nodes: add more flexible method to declare sockets of a node
Previously, built-in nodes had to implement "socket templates"
(`bNodeSocketTemplate`) to tell Blender which sockets they have.
It was nice that this was declarative, but this approach was way
too rigid and was cumbersome to use in many cases.

This commit starts to move us away from this rigid structure
by letting nodes implement a function that declares the sockets
the node has. Right now this is used as a direct replacement
of the "socket template" approach to keep the refactor smaller.
It's just a bit easier to read and write.

In the future we want to support more complex features like
dynamic numbers of sockets and type inferencing. Those features
will be easier to build on this new approach.

This new approach can live side by side with `bNodeSocketTemplate`
for a while. That makes it easier to update nodes one by one.

Note: In `bNodeSocketTemplate` socket identifiers were made
unique automatically. In this new approach, one has to specify
unique identifiers manually (unless the name is unique already).

Differential Revision: https://developer.blender.org/D12335
2021-08-30 17:23:05 +02:00
e8684eff30 Fix T91056: GPencil merge layers doesn't preseve Keyframe type.
Now if the frame does not exist in destination layer, the frame type of merge layer is used. 

For existing frames in destination layer, the existing type is not changed.
2021-08-30 17:04:02 +02:00
fb0d5124f2 support anonymous attributes in foreach_attribute 2021-08-30 16:02:58 +02:00
Henrik Dick
e76f04c870 Fix T90742: Gpencil ghost point on selection
Reviewed By: fclem, filedescriptor

Maniphest Tasks: T90742

Differential Revision: https://developer.blender.org/D12259
2021-08-30 15:17:14 +02:00
6146a679c9 support creating anonymous attributes 2021-08-30 14:24:18 +02:00
9ad56627cf Docs: retitle 'GPU Shader Module' to 'GPU Module'
We already have a module for GPU Shader (`gpu.shader`).

So, remove the name "Shader" from the title to avoid confusion.
2021-08-30 09:21:38 -03:00
Erik Abrahamsson
a71d2b2601 Geometry Nodes: Curve Fill Node
This node takes a curve geometry input and creates a filled mesh at Z=0
using a constrained Delaunay triangulation algorithm. Because of the
choice of algorithm, the results should be higher quality than the
filling for 2D curve objects.

This commit adds an initial fairly simple version of the node, but more
features may be added in the future, like transferring attributes when
necessary, or an index attribute input to break up the calculations
into smaller chunks to improve performance.

Differential Revision: https://developer.blender.org/D11846
2021-08-29 23:27:35 -05:00
41eb33794c Cleanup: Add comment about suspicious O(n^3) loop 2021-08-29 22:12:53 -05:00
Rajesh Advani
b44406f963 Geometry Nodes: Enhance the cube mesh primitive as a cuboid
This mesh primitive enhances the Cube mesh primitive and allows the
creation of a cuboid with a configurable size and number of vertices
in all 3 directions. The Cube primitive is now similar to the Grid
primitive except that it works in 3 dimensions.

Previously it was possible to create a cube and scale it arbitrarily
along each axis. You could also subdivide the mesh, but the number of
subdivisions was equal along all axes. This meant that making the basic
frame for something like modular buildings wasn't trivial.

Inspired by tutorials and files for modular building creation.

The cuboid is created as a `Mesh` so that large meshes with millions of
faces are created quickly. Though edge calculation could be faster if
implemented here, edges are calculated using `BKE_mesh_calc_edges`
to reduce complexity, and in hopes that they may be calculated lazily
for `Mesh` in the future like vertex normals.

See the differential revision for more information.

Differential Revision: https://developer.blender.org/D11810
2021-08-29 22:08:57 -05:00
Mattias Fredriksson
b42354672e Geometry Nodes: Allow for one vertex in grid node
This commit allows setting the number of vertices in either direction
to 1, so that the primitive grid node will create a line instead of a
grid. To avoid confusion the soft limits of the input sockets are not
changed, so this is purely an increase in flexibility for when it is
helpful.

Differential Revision: https://developer.blender.org/D11772
2021-08-29 16:39:42 -05:00
Mattias Fredriksson
084180874c Fix: Circle mesh primitive outer edges do not render
The outer edges created om the circle mesh primitive node
weren't marked with the flags that makes them show in wireframe
mode.

Differential Revision: https://developer.blender.org/D12152
2021-08-29 16:30:17 -05:00
84660c44f0 Refactor procedure building to add proper destructs, to use stacks
This still doesn't really work, but it solves a fundamental problem
with the order I was adding destruct calls for intermediate values.
The current problem is that the variables that a function depends
on (its inputs) are not added first, so basically a problem with the
traversal of the field network.
2021-08-29 12:28:40 -05:00
c398cad059 show procedure parameters in dot graph 2021-08-29 12:46:39 +02:00
35bf6b9790 move dot graph generation into utility class 2021-08-29 12:27:39 +02:00
e5a59e876e slightly improve readability of dot export 2021-08-29 12:09:56 +02:00
d464816c37 Cleanup: Rename variables 2021-08-28 21:20:50 -05:00
007651129a Add comment 2021-08-28 21:18:38 -05:00
1968c9b702 Add another test, add TODO comments 2021-08-28 21:17:21 -05:00
2f7258d618 Fix BLI_strncpy_wchar_from_utf8 result on Windows
This function was documented to return the length but returned an
error value for WIN32. While this doesn't cause any bugs at the moment,
it could cause problems in the future.

Oversight in 5496d8cd36.
2021-08-29 12:11:09 +10:00
eb54741226 Don't destruct reused inputs after a function call 2021-08-28 18:10:38 -05:00
4256eeeec4 UI: Timecodes: Rename "No TC in use" to "None"
Differential Revision: https://developer.blender.org/D12296
2021-08-28 16:38:08 -04:00
ce86a518b9 Fix problem building variables for function inuts 2021-08-28 13:29:22 -05:00
457302b67b BLI_string_utf8: add buffer size arg to BLI_str_utf8_from_unicode
Besides helping to avoid buffer overflow errors this reduces complexity
of BLI_str_utf32_as_utf8 which needed a special loop for the last 6
characters to avoid writing past the buffer bounds.

Also add BLI_str_utf8_from_unicode_len which only returns the length.
2021-08-28 22:50:52 +10:00
079791dc30 Fix error scaling thumbnails to zero dimensions
Follow up to fix for T89868.
2021-08-28 21:33:06 +10:00
0b6be26126 BLF: remove checks for blend file relative paths
This was added in b24712a9ca
but is no longer needed as of efc129bc82.

Further, this wasn't reliable as it could fail on linked library data
which has a different base directory.

Assert when blend file relative paths are passed to BLF
(matching imbuf file loading).
2021-08-28 19:21:54 +10:00
09a5ea059f Add a slightly more complicated test
This one doesn't pass, I'll need to debug it
2021-08-28 00:40:58 -05:00
b3cc26bf35 Add another very simple passing test 2021-08-28 00:21:01 -05:00
5f29552be7 Complete handling of field network inputs 2021-08-28 00:05:14 -05:00
6afa55b7e4 Add short comment 2021-08-28 00:02:49 -05:00
37d717fe14 Add FieldInput for input virtual arrays 2021-08-27 15:53:03 -05:00
f193cf66d4 Merge branch 'temp-geometry-nodes-fields' into temp-geometry-nodes-fields--fields 2021-08-27 15:02:33 -05:00
68efa935da Merge branch 'master' into temp-geometry-nodes-fields 2021-08-27 15:01:30 -05:00
eae4e22518 Cleanup: Remove redundant null check 2021-08-27 14:33:06 -05:00
276a862ebc Fix failing alembic test after IDProperty UI data refactor
The default float IDProperty min value rB8b9a3b94fc148d19 for when there
is no UI data was FLT_MIN instead of -FLT_MAX, which meant that animated
custom property values couldn't be less than zero unless they had their
UI data values edited previously.

That's a mistake I won't make again! Also change the int minimums from
-INT_MAX to INT_MIN to sanitize the whole situation.
2021-08-27 14:31:19 -05:00
400605c3a6 UI: Reduce Node Contents Jiggling When Moved
This patch just clamps and rounds node contents and socket locations
so they don't appear to jiggle around when you move them. This issue
happens because node sizing and positioning are in floats while text
content must be pixel-aligned.

See D11684 for more details and comparisons.

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

Reviewed by Julian Eisel
2021-08-27 11:25:30 -07:00
071007e0ef UI: Fix summary overlay wrong range and overlap in Dopesheet
The overlay was drawn twice on top of each other making it hard to see,
hard to theme, and making it more prominent in the wrong areas (before
frame 0, not even start frame). The comment in the code was also wrong
since it said "frame one" but it was 0.

Checked with the Animation module team that it's better to use start/end
frame range instead of frame 0.

There is a TODO note to de-duplicate this section eventually so I left it there.
This fix is currently done for Grease Pencil and Mask modes, but it should
also be fixed for the regular Dopesheet mode (in line 244 if anyone wants to do it).
2021-08-27 19:49:08 +02:00
1a0fed5d8e Use EXPECT_EQ instead of ASSERT_EQ 2021-08-27 10:55:14 -05:00
c3206bd2a0 Rename Function to FieldFunction 2021-08-27 09:49:36 -05:00
26e7fef920 Merge branch 'temp-geometry-nodes-fields' into temp-geometry-nodes-fields--fields 2021-08-27 09:13:19 -05:00
92e1c8744b Merge branch 'master' into temp-geometry-nodes-fields 2021-08-27 09:12:42 -05:00
8b9a3b94fc Refactor IDProperty UI data storage
The storage of IDProperty UI data (min, max, default value, etc) is
quite complicated. For every property, retrieving a single one of these
values involves three string lookups. First for the "_RNA_UI" group
property, then another for a group with the property's name, then for
the data value name. Not only is this inefficient, it's hard to reason
about, unintuitive, and not at all self-explanatory.

This commit replaces that system with a UI data struct directly in the
IDProperty. If it's not used, the only cost is of a NULL pointer. Beyond
storing the description, name, and RNA subtype, derived structs are used
to store type specific UI data like min and max.

Note that this means that addons using (abusing) the `_RNA_UI` custom
property will have to be changed. A few places in the addons repository
will be changed after this commit with D9919.

**Before**
Before, first the _RNA_UI subgroup is retrieved the _RNA_UI group,
then the subgroup for the original property, then specific UI data
is accessed like any other IDProperty.
```
prop = rna_idprop_ui_prop_get(idproperties_owner, "prop_name", create=True)
prop["min"] = 1.0
```

**After**
After, the `id_properties_ui` function for RNA structs returns a python
object specifically for managing an IDProperty's UI data.
```
ui_data = idproperties_owner.id_properties_ui("prop_name")
ui_data.update(min=1.0)
```
In addition to `update`, there are now other functions:
 - `as_dict`: Returns a dictionary of the property's UI data.
 - `clear`: Removes the property's UI data.
 - `update_from`: Copy UI data between properties,
   even if they have different owners.

Differential Revision: https://developer.blender.org/D9697
2021-08-27 08:27:24 -05:00
3f5e0f7d91 Fix crash sampling render result before any pixel was rendered
Caused by recent lazy render result passes allocation change.
2021-08-27 15:07:26 +02:00
57e8714b38 Fix shadowing in sequencer iterator
The __LINE__ was not properly expanded.
2021-08-27 14:44:12 +02:00
c88ba461cf Fix "toggle shading" op not updating VR view
Reason was that the notifier did not set the NS_VIEW3D_SHADING
subtype, which the VR view listens for for a shading update.

In the case of "toggle xray", a notifier was absent altogether.
2021-08-27 20:05:34 +09:00
59cd9c6da6 VSE: Transform overwrite mode
Add mode to overwrite strips on overlap instead of resolving overlap.

When overlap is created, 3 things can happen:
 - On partial overlap, handles of overlapped strip are moved
 - On complete overlap with smaller strip, overlapped strip is split
 - On complete overlap with larger strip, overlapped strip is removed

This mode can be enabled in header.

Reviewed By: fsiddi, mano-wii

Differential Revision: https://developer.blender.org/D11805
2021-08-27 12:59:46 +02:00
7f7370fa26 Cleanup: quiet maybe-used-uninitialized warning 2021-08-27 11:58:40 +02:00
6845aad1a2 Fix T90907: RNA pointers for material slots are not unique across IDs
Caused by {rB1a81d268a19f}.

This caused e.g. ALT-clicking the 'Link' button to not propagate to
other selected objects (same as the 'Copy To Selected' context menu
entry).

If these are not unique across IDs, checks in ui_selectcontext_begin()
or copy_to_selected_button() could fail.

Now offset by ID pointer.

thx @JacquesLucke for clarification on the POINTER_* macros (and why
not to use them)!

Maniphest Tasks: T90907

Differential Revision: https://developer.blender.org/D12321
2021-08-27 11:02:58 +02:00
7dba879829 Fix XR action map index initialization
This reverts 151eed752b. Originally thought it was necessary to
initialize selected/active indices to -1 to prevent out-of-bounds
list access, but this is not needed since null checks are already
performed after obtaining list members via BLI_findlink().

In addition, leaving indices zero-initialized facilitates use of the
Python API, for example when displaying action map information in a
UI list.
2021-08-27 17:16:35 +09:00
7652ee43ec Cleanup: clang-tidy 2021-08-27 17:29:05 +10:00
89dae554f9 Cleanup: utf8 stepping functions
Various changes to reduce risk of out of bounds errors in utf8 seeking.

- Remove BLI_str_prev_char_utf8
  This function could potentially scan past the beginning of a string.
  Use BLI_str_find_prev_char_utf8 instead which takes a limiting
  string start argument.

- Swap arguments for BLI_str_find_prev_char_utf8 so the stepping
  argument is first and the limiting argument is last.
  This matches BLI_str_find_next_char_utf8.

- Change behavior of these functions to return it the start or end
  pointers instead of NULL, which complicated use of these functions
  to calculate offsets.

  Callers that need to check if the limits were reached can compare
  the return value with the start/end pointers.

- Return 'const char *' from these functions
  so they don't remove const from the input arguments.
2021-08-27 17:02:53 +10:00
cfe8832dd3 Revert "Rename existing boolean node to mesh boolean"
This reverts commit 6a5b048658.

I'm in the wrong branch again!
2021-08-26 23:18:32 -05:00
6a5b048658 Rename existing boolean node to mesh boolean 2021-08-26 23:16:10 -05:00
ad0dbde653 Merge branch 'master' into temp-geometry-nodes-fields 2021-08-26 23:15:27 -05:00
f25c1b4950 Revert "Rename existing boolean node to "Mesh Boolean""
This reverts commit 469f752b80.

I thought I was in a different branch.
2021-08-26 23:15:02 -05:00
469f752b80 Rename existing boolean node to "Mesh Boolean" 2021-08-26 23:12:50 -05:00
55f2867db3 Merge branch 'master' into temp-geometry-nodes-fields--fields 2021-08-26 23:11:03 -05:00
523bc981cf Fix loading packed fonts for sequencer strips 2021-08-27 13:11:36 +10:00
61f9274d07 Cleanup: use early return 2021-08-27 13:05:12 +10:00
efc129bc82 Fix sequencer font loading using an unexpected path
Reuse the existing font loading function which handles this case.
2021-08-27 13:01:19 +10:00
Henrik Dick
20ef771374 Modifier: smooth interpolation support
Add an option to the mask modifier to use the vertex weights to generate
smooth in between geometry, instead of just deleting non complete faces.

This can be used to make all sorts of smooth dissolve animations
directly with geometry, which are usually hacked together with shaders.
It also allows for implicit function plotting using geometry nodes and
boolean like operations on non manifold geometry with the proximity
modifier.

Reviewed By: campbellbarton

Ref D10979
2021-08-27 11:48:18 +10:00
8949eab27e Cleanup: warnings 2021-08-27 11:47:56 +10:00
80429002d7 Add an index input function test
This one fails because `tot_initialized_` is 0 in the procedure
evaluator. I'm not quite sure what that means yet.
2021-08-26 16:32:04 -05:00
0910b76be3 Add a high-level description to the header file 2021-08-26 15:28:41 -05:00
1ccfd6842b Refactor field storage again, to allow reuse of function outputs 2021-08-26 15:23:53 -05:00
2b64b4d90d Fix T90973: GPencil - Add buttons to move up and down vertex groups
These buttons were in Meshes but not for Grease Pencil. This patch add them in order to keep consistency.

Reviewed By: HooglyBoogly

Maniphest Tasks: T90973

Differential Revision: https://developer.blender.org/D12328
2021-08-26 22:00:24 +02:00
e5ed9991ea UI: Consistent Area Move Snapping Locations
Change Area Move snapping locations to even 12ths, rather than current
eights and thirds, so snap distances are consistent sizes. Also adds
snapping at minimum and maximum locations.

see D11938 for details and illustrations.

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

Reviewed by Hans Goudey
2021-08-26 10:52:18 -07:00
Germano Cavalcante
8e5b7ac6e2 Fix error in last commmit 2021-08-26 14:21:45 -03:00
583f694826 Fix T90817: Object Picker Doesn't Work on Second window
Solution similar to the one seen in {rBb94ab93dfb82}.

The idea is to find the window and region under the cursor to use in the
operator.

Reviewed By: brecht

Maniphest Tasks: T90817

Differential Revision: https://developer.blender.org/D12310
2021-08-26 14:13:19 -03:00
aadbdb8048 Cleanup: split eyedropper_color_sample_fl into more specific utilities
The window and region find utility can be used in other eyedropper
operators.
2021-08-26 14:12:21 -03:00
Germano Cavalcante
d7b0567f7c Cleanup: return window in 'WM_window_find_under_cursor'
This better matches other functions like `BKE_screen_find_area_xy`.
2021-08-26 13:49:04 -03:00
0a0360c8cd Fix constant input test 2021-08-26 11:19:58 -05:00
06a60fe9f7 PyAPI: GPU: expose clip distances
Now you can get a shader that uses Clip Planes and set the number of
Clip Distanes with `gpu.state.clip_distances_set(value)`.
2021-08-26 13:03:07 -03:00
be0201259a Merge branch 'temp-geometry-nodes-fields' into temp-geometry-nodes-fields--fields 2021-08-26 10:43:32 -05:00
ef2a48329d Merge branch 'master' into temp-geometry-nodes-fields 2021-08-26 10:41:59 -05:00
edb95b3fcb Cleanup: Use ID_IS_LINKED instead of direct id.lib pointer check. 2021-08-26 15:01:14 +02:00
1bb2077250 Add locking fallback atomics implementation
Is used for platforms for which we do not have native implementation,
such as MIPS, for example.

It is possible to test locking implementation on local computer by
defining `ATOMIC_FORCE_USE_FALLBACK` in the atomic_ops_unix.h file.

Run full regression suit with the locking implementation on amd64
Linux platform and all tests passed.

Having non-optimal but working implementation for odd-ball platforms
seems to be a better choice than failing the build entirely.

Differential Revision: https://developer.blender.org/D12313
2021-08-26 14:36:59 +02:00
2419ffa183 Fix T90959: crash when hovering over empty data block socket 2021-08-26 14:35:10 +02:00
da17692a3d Cleanup: use BLI_UTF8_MAX define 2021-08-26 20:41:02 +10:00
1434ac3767 Cleanup: add ATTR_WARN_UNUSED_RESULT to BLI_string_utf8.h 2021-08-26 20:41:02 +10:00
c52db4c4cf Decouple highlighted tiles from RenderPart
Should be no visible change on user side.
Preparing for render parts removal as part of Cycles X project.

Differential Revision: https://developer.blender.org/D12317
2021-08-26 12:09:03 +02:00
ec66b3ef9b Fix issues with absolute time unit
I think there are the following issues with {rB5fa6cdb77a98}:
- if we introduce a PROP_UNIT_TIME_ABSOLUTE unit, shouldnt it be visible
to RNA as well?
- seems like a double entry sneaked into that commit?

This is in preparation to use this for render time limit in cycles-x.

ref. T90701

Maniphest Tasks: T90701

Differential Revision: https://developer.blender.org/D12315
2021-08-26 11:01:32 +02:00
1f2bf2fd73 Cleanup, quiet compile warnings 2021-08-26 10:36:04 +02:00
fe73778095 Cleanup: unused function from 082ddc9379 2021-08-26 16:10:24 +10:00
d3514cd6a7 ToolSystem: increase the inset tool size
The inset tool requires moving the cursor towards the center of the
selection, making it nearly impossible to use the inset tool
when the view was aligned with the vertical handle.

Use custom settings for VIEW3D_GGT_tool_generic_handle_free
to make it draw hollow, as large as the scale tool.

Resolves T87991.
2021-08-26 16:02:35 +10:00
082ddc9379 ToolSystem: support per-tool gizmo group properties
Also add gizmo group example to the tool-template.
2021-08-26 16:02:31 +10:00
f464cac55a Cleanup: redundant update calls adding objects
These update calls are already performed by
ED_object_add_type_with_obdata.
2021-08-26 13:53:15 +10:00
2fb57685e3 Fix "Text to Object" creating invisible object
Newly created objects would not become visible until
another action forced a depsgraph update.
2021-08-26 12:59:22 +10:00
efcac47155 Cleanup: soft CMake file lists 2021-08-26 12:41:26 +10:00
cec35060f5 Cleanup: sort struct blocks 2021-08-26 12:39:45 +10:00
4e16e8b671 Cleanup: warnings 2021-08-26 12:36:58 +10:00
84f048fda5 Cleanup: use C style comments for descriptive text 2021-08-26 12:36:58 +10:00
42032db1c2 Cleanup: remove deprecated flag use in collada 2021-08-26 12:36:58 +10:00
afcd06e1e1 Cleanup: spelling in comments 2021-08-26 12:36:58 +10:00
ff85ac3009 Cleanup: clang-format 2021-08-26 12:27:13 +10:00
e5a5a251d2 Fix T90915: outliner select behaves as if Ctrl is held
Error in 452cc01932
2021-08-26 11:37:22 +10:00
70fbdcb6bf Cleanup: Refactor proximity node to be more data type agnostic
Before, distances from each component were handled in the same loop,
making it more complicated to add support for more component types
in the future (and probably hurting performance by dealing with two
BVH trees at the same time, though I didn't test that).

Now each component is handled in a separate function, so that adding
support for another component type is much simpler.
2021-08-25 18:03:24 -05:00
81a0c384da Experimental simplification: non-virtual multi-function-only fields
The stupidly simple test doesn't pass anymore.
2021-08-25 17:39:19 -05:00
70eaba3cb1 Basic constant input test passes 2021-08-25 16:23:46 -05:00
5b751c95f4 BLF: Remove ASCII-only Code Paths
Remove redundant code for drawing text strings that contain only ASCII.

See D12293 for much more detail.

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

Reviewed by Campbell Barton
2021-08-25 13:30:00 -07:00
7e39e78259 Merge branch 'master' into temp-geometry-nodes-fields--fields 2021-08-25 14:28:57 -05:00
518b97e674 Windows/Ninja: Optimize linker performance
The /Zc:inline flag is by default off in the MSVC
compiler however when you build with msbuild it adds
it to the build flags on its own.

Ninja however does not decide on its own to add
flags you didn't ask for and was building without
this flag.

This change explicitly adds the compiler flag so
msbuild and ninja builds are once more building
with the same build flags leading to smaller .obj
files when building with ninja and lightening the
workload for the linker.

This flag is available starting MSVC 2013 update 2
so does not need to be guarded with version checks.
2021-08-25 10:55:45 -06:00
05564c8ca6 Fix wrong length value in the header of the Move operator
Missed in {rB0d36439f95c0}.
2021-08-25 13:01:41 -03:00
8fb9155598 Fix T90248: missing depsgraph update tag for node group
The code assumed that when a node group is is at the highest
level in the node editor, then it is embedded into another data
block and can't be referenced by other node groups. This is true
for shader and compositor nodes, but not for geometry nodes.
2021-08-25 18:00:29 +02:00
0d36439f95 Fix T90911: Move along axis does not display real distance units
Variable was wrongly set to 0.
Caused by {rB7192e57d63a5}.
2021-08-25 12:44:35 -03:00
f49d438ced Cleanup and remove SEQ_ALL_BEGIN macro
We now use a for_each function with callback to iterate through all sequences in the scene.

This has the benefit that we now only loop over the sequences in the scene once.
Before we would loop over them twice and allocate memory to store temporary data.

The allocation of temporary data lead to unintentional memory leaks if the code used returns to exit out of the iteration loop.
The new for_each callback method doesn't allocate any temporary data and only iterates though all sequences once.

Reviewed By: Richard Antalik, Bastien Montagne

Differential Revision: http://developer.blender.org/D12278
2021-08-25 17:30:39 +02:00
c2122c39ae Remove GArray, futher improvement 2021-08-25 09:55:34 -05:00
796035ad93 Cleanup: else-after-return 2021-08-25 16:00:48 +02:00
0fd1e6a5f4 T90908: Reduce loading times when extracting thumbnails from Blendfiles.
Previously when loading an thumbnails for an asset the whole file was
read. Reason this was done was perhaps a future idea to load
all thumbnails inside a blendfile in a single go. This was never implemented
and currently unneeded disk and cpu cycles was spend with finding out what
preview to load.

This patch adds an early break when the thumbnail that the caller is
interested in has been found. This improves the thumbnail extraction
when looking into large files.

Reviewed By: mont29

Maniphest Tasks: T90908

Differential Revision: https://developer.blender.org/D12312
2021-08-25 15:59:41 +02:00
5a0ec2302e XR: Enable controller profile extensions
Enables all currently documented OpenXR controller profile
extensions (Reverb G2, Vive Cosmos, Huawei Controller) in order to
support bindings for more VR hardware.

This is necessary because, if these extensions are not enabled, the
OpenXR runtime will return an error when creating a binding with one
of these profiles.

Does not bring about any changes for users at the moment, since
default controller actions have not yet been exposed to users (will
be addressed with D10944, D10948, and D11271).
2021-08-25 21:36:53 +09:00
940ba74024 XR: Improve "Invalid stage ref space" warning
Originally mentioned that absolute tracking was disabled, which is
wrong because absolute tracking (skipping application of eye offsets)
is always available, although it may not give the expected result of
persistent tracking origins across sessions if the stage space is
unavailable (hence the need for a warning).

Now, the warning makes no mention of absolute tracking, instead
informing the user that the local space fallback will be used and
that they should define tracking bounds via the XR runtime if they
wish to use the stage space.
2021-08-25 20:59:53 +09:00
d6ace5a7bb Fix: Crash on file read with active VR session
Add null check for runtime data since it could already have been
freed via wm_xr_exit() (called on file read) prior to the session
exit callback.

Also, fix potential memory leak by freeing session data in
wm_xr_runtime_data_free() instead of session exit callback.
2021-08-25 20:59:37 +09:00
cb9c0aa7d0 Fix: XR action map memory leaks
This fixes two memory leaks related to XR action maps.

1. Freeing of action maps needs to be moved from wm_xr_exit() to
wm_xr_runtime_data_free() since the runtime may have already been
freed when calling wm_xr_exit().

2. Action bindings for action map items were not being freed. This
was mistakenly left out of e844e9e8f3 since the patch needed to be
updated after d3d4be1db3.
2021-08-25 20:57:13 +09:00
a34652d6f8 Fix: Incorrect declaration of XrActionMaps RNA
This fixes a mistake in the XrActionMaps RNA struct declaration.

Originally, the XrActionMaps struct SDNA was set as wmXrData to get
access to wmXrRuntimeData. However, this doesn't give a valid pointer
and the XrSessionState RNA pointer needs to be passed instead.

Since XrSessionState itself does not have SDNA, it is necessary to
pass the XrSessionState pointer to the XrActionMaps struct functions
(new(), new_from_actionmap(), ...) instead of simply using
RNA_def_struct_sdna().
2021-08-25 20:56:52 +09:00
452cc01932 Cleanup: skip saving selection properties set in the keymap
Having settings such as "extend" saved between executions causes
keymaps that don't include this setting to remember the value
between execution.

No longer store this setting for selection operations & remove
redundant values from the key-maps, see: T90275.
2021-08-25 18:10:56 +10:00
8d634c1b27 Cleanup: Mentioning incorrect source file in comment.
Code mentions that ID_* were defined in DNA_ID.h but are actually defined
in DNA_ID_enums.h.
2021-08-25 10:00:55 +02:00
e91fd3b816 Cleanup: separate IMB_thumb_load_blend in multiple functions. 2021-08-25 10:00:55 +02:00
a2597f8b83 Keymap: repeat was disabled for Ctrl-Backspace in the text editor 2021-08-25 17:40:55 +10:00
b98b9354b2 Cleanup: Fixed compile error in debug code. 2021-08-25 09:37:46 +02:00
9df063df19 Fix assert caused by 38630711a0 2021-08-25 17:18:26 +10:00
820d50d3cb Correct error in 38630711a0 2021-08-25 15:36:40 +10:00
38630711a0 BLI_string_utf8: remove unnecessary utf8 decoding functions
Remove BLI_str_utf8_as_unicode_and_size and
BLI_str_utf8_as_unicode_and_size_safe.

Use BLI_str_utf8_as_unicode_step instead since it takes
a buffer bounds argument to prevent buffer over-reading.
2021-08-25 15:28:59 +10:00
be906f44c6 BLI_string_utf8: simplify utf8 stepping logic
There were multiple utf8 functions which treated
errors slightly differently.

Split BLI_str_utf8_as_unicode_step into two functions.

- BLI_str_utf8_as_unicode_step_or_error returns error value
  when decoding fails and doesn't step.

- BLI_str_utf8_as_unicode_step always steps forward at least one
  returning the byte value without decoding
  (needed to display some latin1 file-paths).

Font drawing uses BLI_str_utf8_as_unicode_step and no longer
check for error values.
2021-08-25 15:27:18 +10:00
70f890b510 VSE: Set default sound and video export format
Use video format for export instead of image sequence. Settings are same
as defined in h264_in_MP4 preset.

Sound default is AAC with 256kbit bitrate.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D7916
2021-08-25 06:58:43 +02:00
f80c39b74e Cleanup: Use shorter enum item names 2021-08-24 23:40:13 -05:00
891e3e98eb LineArt: Fix (Unreported) Crash when loading objects.
Fix mesh freeing call for obi->original_me so the address is correct.
2021-08-25 11:05:48 +08:00
a2e0f714f2 Cleanup: Remove unecessary variables
Instead of passing separate booleans for whether to store the locations
and distances, check if the spans are empty. And instead of passing a
separate boolean for whether there is valid tree data, pass a pointer
to the data.
2021-08-24 21:57:45 -05:00
fb26ee8a7e Initial crappy code that doesn't do anything and wouldn't compile 2021-08-24 17:35:46 -05:00
001072721f Merge branch 'master' into temp-geometry-nodes-fields 2021-08-24 13:45:48 -05:00
5ef3afd87c Fix T90900: Crash when rendering geometry nodes created curve
The comment for data_eval mentions that it should contain a mesh for
curve objects, however with geometry nodes, objects can evaluate to
curves as well (though they are only containers for the `CurveEval`.
That is a larger issue, but with the upcoming geometry instancing patch
the situation changes, so this commit does not correct that. I also hope
to remove this code in favor of the new curve to mesh code soon.

Instead, just check the evaluated data type in this case, which prevents
the crash, though it is hacky.
2021-08-24 13:38:53 -05:00
f53cf5141d Cleanup: Make function static, remove unused arguments 2021-08-24 13:27:29 -05:00
19da434e9c Nodes: Improvements to edge panning in the node editor.
- New operator property to toggle edge panning in the keymap:
  This is disabled by default to avoid edge-panning in cases where it
  gets distracting, such as adding a new node. Only the explicit
  translate operator(s) (GKEY or drag) have this enabled now.

- Restore the initial view rect on edge pan cancel:
  The initial view rect is now stored in the edge pan operator data.
  When an operator with edge panning is cancelled it can now call the
  `UI_view2d_edge_pan_cancel` function to restore the original View2D
  rect.

- Less delay in node editor scrolling:
  Delay is useful when scrolling through long lists, such as in the
  outliner, but makes node scrolling feel sluggish and unresponsive.
  The lower scroll speed here makes a faster response the better option.

- Zoom influence feature:
  Somewhat slower scrolling in UI-space when zoomed out. With the 0.5
  zoom influence factor nodes behave as if zoom factor is halved,
  otherwise it gets too fast when zoomed out. Previously scrolling would
  always be constant-speed in UI space, now it's half-way between UI
  space and node (view) space.
2021-08-24 18:00:05 +01:00
Robert Guetzkow
38bdde852f Fix T90715: Remove correct particle modifier through Python API
Before this patch attempting to remove a particle modifier programmatically
through Python would fail, because it deleted the modifier associated with
the currently active particle system instead of the one passed as an argument
to `bpy.types.ObjectModifiers.remove()`.

This fix  adds an additional argument for the particle system to
`object_remove_particle_system`. This allows to specify which particle system
and its associated modifier shall be removed. In case of
`particle_system_remove_exec` it will remain the currently active particle
system, whereas `object_remove_particle_system` passes the particle system
of the modifier. Hence, the correct modifier will be removed.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D12234
2021-08-24 18:41:22 +02:00
65a1ec89ba Merge branch 'temp-geometry-nodes-fields' into temp-geometry-nodes-fields--anonymous-attributes 2021-08-24 17:56:36 +02:00
ef9fbf258b use attribute id in more places 2021-08-24 17:53:15 +02:00
a448949f25 more uses of attribute id 2021-08-24 17:30:56 +02:00
551521cfa4 Cleanup: ID management: Remove useless internal for BKE_lib_id_clear_library_data.
This static internal `_ex` function was not doing anything extra, just
move back whole code to public API `BKE_lib_id_clear_library_data`.
2021-08-24 17:19:41 +02:00
e3232f987a initial attribute id ref 2021-08-24 17:11:24 +02:00
b55c02a206 Cleanup: Remove useless Camera make_local callback.
Not sure why this one was still there, probably just escaped a previous
cleanup somehow.
2021-08-24 17:08:23 +02:00
9327c00f70 Cleanup: Simplify logic 2021-08-24 10:01:08 -05:00
038f9b7f4a Render: Lazily allocate render passes pixels storage
The idea is to only allocate pixel storage only when there is an actual
data to be written to them.

This moves the code forward a better support of high-res rendering when
pixel storage is not allocated until render engine is ready to provide
pixel data.

Is expected to be no functional changes for neither users no external
engines. The only difference is that the motion and depth passes will
be displayed as transparent for until render engine provides any tile
result (at which point the pixels will be allocated and initialized to
infinite depth).

Differential Revision: https://developer.blender.org/D12195
2021-08-24 16:20:57 +02:00
7aff40f410 FFMPEG: Fix building with older versions that need FFMPEG_USE_DURATION_WORKAROUND 2021-08-24 15:15:21 +02:00
3c82725d74 Disable Fade Inactive Geometry overlay by default
This overlay was intended to identify the active objects in modes
like Sculpt Mode, where you don't have any extra visual indication
of what is the current and target object when switching directly
between them.

After having flash on mode transfer on the transfer mode operator,
the visual information this overlays provides is redundant. It is
still available in case some users want to use it like a way of
focusing on the active object.

Reviewed By: JulienKaspar, JacquesLucke

Differential Revision: https://developer.blender.org/D12303
2021-08-24 12:56:36 +02:00
46913bf0a0 Fix T90840: Can't duplicate or copy (Ctrl-C) object from linked file.
We need to separate the flag telling duplicate code to not handle
remapping to new IDs etc., from the one telling the code that we are
currently duplicating a 'root' ID (i.e. not a dependency of another
duplicated ID).

This whole duplicate code/logic is still fairly unsatisfying, think it
will need further refactor, or maybe even re-design, at some point...
2021-08-24 12:23:39 +02:00
4e4ac5a867 Fix invalid mask use for the UV-project modifier
Mistake in a30a817933.
2021-08-24 18:17:54 +10:00
Himanshi Kalra
30d3dd4de1 Added more Geometry Node tests
* Attributes
* Utilities
* Volume

Test folder located in `lib\tests\modeling\geometry_nodes`
It contains around 34 new tests.
* attribute clamp + other attribute nodes
* Curve Primitive nodes
* Mesh Primitive nodes
* delete geometry
* convex hull
* subdivision surface
* boolean intersect
* boolean diff
* volume to mesh

Reviewed By: zazizizou, JacquesLucke

Differential Revision: https://developer.blender.org/D12250
2021-08-24 13:27:36 +05:30
983280b014 PyAPI: remove active area test for script.python_file_run operator
There is no reason running a Python file should require an active area.
2021-08-24 14:53:23 +10:00
de60205f19 Fix buffer size mismatch in SCRIPT_OT_python_file_run
Reading paths over 512 bytes would cause a buffer overrun.
2021-08-24 14:52:02 +10:00
e0a6001a22 Fix reporting Python reference leaks with WITH_PYTHON_SAFETY
Error in f3e26c847b
2021-08-24 14:36:25 +10:00
8b55cda048 Fix BLI_str_utf8_as_unicode_step reading past intended bounds
Add a string length argument to BLI_str_utf8_as_unicode_step to prevent
reading past the buffer bounds or the intended range since some callers
of this function take a string length to operate on part of the string.

Font drawing for example didn't respect the length argument,
potentially causing a buffer over-read with multi-byte characters
that could read past the end of the string.

The following command would read 5 bytes past the end of the input.

`BLF_draw(font_id, (char[]){252}, 1);`

In practice strings are typically null terminated so this didn't crash
reading past buffer bounds.

Nevertheless, this wasn't correct and could cause bugs in the future.

Clamping by the length now has the same behavior as a null byte.

Add test to ensure this is working as intended.
2021-08-24 14:25:15 +10:00
8371df8b1c Cleanup: spelling 2021-08-24 12:49:00 +10:00
a311ab6167 Cleanup: quiet clang-format warnings, unused argument 2021-08-24 12:43:15 +10:00
bffa168157 Fix T90854: Cycles, normal map fails with applied transformations
Prior to rBb8ecdbcd964a normals were stored both in
DeviceScene.tri_vnormal and the float3 attributes buffer. However, the
normals in `DeviceScene.tri_vnormal` might have be transformed to world
space if the object's transformation was applied, while the data in the
float3 attributes buffer were not. This caused shading issues in cases
where the objects did have transformation applied, as the math expects
the normals to be in object space.

To fix this, convert the normals to object space if necessary before
applying the normal map.

Reviewed By: brecht

Maniphest Tasks: T90854

Differential Revision: https://developer.blender.org/D12294
2021-08-24 01:43:57 +02:00
Félix
eec1ea0ccf VSE: Add Sequence.parent_meta() python API function
This function can be used to find metastrip parent of nested strip.

Reviewed By: ISS

Differential Revision: https://developer.blender.org/D11985
2021-08-24 01:21:08 +02:00
929d7597b3 VSE: Cleanup speed effect math
Simplify logic of speed effect frame calculation by using discrete math
where possible. Only `SEQ_SPEED_MULTIPLY` mode with animation requires
frame map to be built. Frame map building was simplified by removing
unused branches.

Functional change: Animating strip in negative range will reverse playback.
I assume this was limitation of previous system, where each frame map item
was limited to be within correct frame range. Now frame map can contain
values that point beyond usable range and they are limited by
`seq_speed_effect_target_frame_get`. This way it is possible to control
playback rate in both directions.

Mostly fixes T89120 apart from offset handling.

Reviewed By: mano-wii

Differential Revision: https://developer.blender.org/D11939
2021-08-24 01:10:12 +02:00
a57ba4147f Fix T88237: Prefetch crash on rendering scene strip
Prefetch needs to avoid rendering scene strips, because

 - Rendering in background needs own dependency graph, which fails to
   initialize from evaluated data.
 - This locks UI and can make it unresponsive for long time periods.

In T88237 prefetch failed to avoid scene strip, because of effect strip
was attached to scene strip.

Ensure, that no effect that is attached to scene strip either directly
or indirectly would be rendered.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D11247
2021-08-24 00:58:01 +02:00
709ce44617 Fix T90407: Split fails on transition strips
When splitting strips, first they are duplicated and then offsets
adjusted. This can fail on cross transitions, because some strips don't
overlap with split frame.

All strips, that relate to each other must be duplicated to ensure
correct relations after splitting, so solution is to delete non
overlapping strips from left or right side respectively.

Since cross transition don't have to overlap with source strips,
splitting such strips would lead to effect being deleted, which
could cause crash when iterating over strips in python. Therefore
splitting of such strips is now forbidden and will generate error.

Splitting of transition will also generate error solely because such
operation is illogical.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D12121
2021-08-24 00:52:24 +02:00
24a3446787 Fix T90646: VSE hangs when strips overlap
When all strips are selected and overlap is caused, this causes VSE to
hang in infinite loop, because such situation should never happen.

To prevent infinite loop, ensure, that strip overlap is not tested
against single overlapping strip itself.

Prevent overlap that can not be handled because of issue described above
by moving overlapping strip between channels.

Reviewed By: campbellbarton

Differential Revision: D12209
2021-08-24 00:46:34 +02:00
a0c8ee057a Fix T90467: Initialize CurveMapping on demand
`CurveMapping.evaluate` function expectes `CurveMapping` to be
initialized, while this wasn't documented.

I don't see any reason for not initializing `CurveMapping` on demand.
Initialization was added in rBf16047c2df1e8be56bf76524f9eb1fa5ecde2176

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D12145
2021-08-24 00:37:32 +02:00
7ebc3140bb Merge branch 'master' into temp-geometry-nodes-fields 2021-08-23 15:12:04 -05:00
Himanshi Kalra
875c2ea5b5 Using relative threshold for floats in mesh comparison
Changes the threshold comparison from absolute to relative.
Removes threshold for MLoopCol comparison.

Adds a compare relative threshold function.

Reviewed By: JacquesLucke

Differential Revision: https://developer.blender.org/D12273
2021-08-24 00:50:03 +05:30
be1891e895 Cleanup: move the buffer list to 'MeshBufferCache'
The cache is used to fill the buffer list.
2021-08-23 13:44:31 -03:00
cbe4036406 Cleanup: Isolate the batch list struct into a struct called MeshBatchList
This allows for a simplification of macros and combines with
`MeshBufferList`.
2021-08-23 13:43:45 -03:00
eb0c50ac78 Cleanup: rename 'MeshBufferExtractionCache' to 'MeshBufferCache'
Matches the existing `MeshBatchCache`.
2021-08-23 13:43:42 -03:00
6e51ef9531 Cleanup: rename 'MeshBufferCache' to 'MeshBufferList'
`MeshBufferList` is more specific and can avoid confusion with
`MeshBufferExtractionCache`.
2021-08-23 13:41:03 -03:00
c42ceef040 initial anonymous attributes implementation 2021-08-23 18:40:29 +02:00
Germano Cavalcante
ebdae75736 Cleanup: Move 'tris_per_mat' member out of 'MeshBufferCache'
`MeshBufferCache` is a struct representing a list of buffers.

As such, `GPUIndexBuf **tris_per_mat` is out of place as it does not
represent one of the buffers in the list.

In fact this member should be close to `GPUBatch **surface_per_mat` as
they are related.

The code for dependencies between buffer and batch had to be reworked
as it relies on the member's position.

Differential Revision: https://developer.blender.org/D12227
2021-08-23 13:37:32 -03:00
7d17f2addf Fix T89998: Cryptomatte node output values doubled with Multi-View
When using a Cryptomatte node and selecting 2 views in Multi-View,
its output values are doubled. When selecting 3 tripled and so on.
This causes incorrect compositing results for all the views.

The node creates an input operation for each rendered cryptomatte
pass. In Multi-View, passes are rendered for each view but compositor
is executed per view and should only create operations for those
corresponding to the current view being executed. Otherwise duplicated
operations add up later in cryptomatte operation.

Reviewed By: jbakker

Maniphest Tasks: T89998

Differential Revision: https://developer.blender.org/D12216
2021-08-23 17:09:59 +02:00
4c6d207343 Compositor: Fix crash enabling buffer groups on full frame
Full frame doesn't support this option as all operations are already
buffered. UI option will be removed in the future.
2021-08-23 17:09:59 +02:00
42f89b9212 Compositor: Fix incorrect copying of uchar buffers
Row stride and the area x coordinate offset were not taken into
account.
2021-08-23 17:09:59 +02:00
153b45037f Compositor: Full frame matte nodes
Adds full frame implementation to Channel Key, Chroma Key, Color Key,
Color Spill, Cryptomatte, Difference Key, Distance Key, Keying,
Keying Screen and Luminance Key nodes. The other nodes
in "Matte" sub-menu are submitted separately.

No functional changes.

Part of T88150.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D12220
2021-08-23 17:09:59 +02:00
daa7c59e38 Compositor: Full frame Bokeh Blur and Blur nodes
Adds full frame implementation to these nodes operations.

When enabling "extend bounds" node option, tiled implementation
result is slightly different because it's using `TranslateOperation`
with bilinear sampling for centering.
Full frame always uses nearest to don't lose image quality.
It has the disadvantage of causing image jiggling on backdrop
when switching size values as it's not pixel perfect.
This is fixed by rounding to even.

No functional changes.

Part of T88150.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D12167
2021-08-23 17:08:45 +02:00
344aca3b1b Compositor: Full frame distort nodes
Adds full frame implementation to "Displace", "Crop", "Flip",
"Plane Track Deform", "Corner Pin", "Movie Distortion",
"Lens Distortion" and "Map UV" nodes.

The other nodes in "Distort" sub-menu are implemented
separately in other commits.

No functional changes.

Part of T88150.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D12166
2021-08-23 17:07:37 +02:00
064167fce7 Compositor: Full frame transform nodes
Adds full frame implementation to "Rotate", "Transform" and
"Stabilize2D" nodes.
To avoid sampling twice when concatenating scale and rotate
operations, a `TransformOperation` is implemented with all
the functionality.
The nodes have no functional changes.

Part of T88150.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D12165
2021-08-23 16:36:09 +02:00
a95e56b741 Compositor: Add sampling methods for full frame
Current sampling methods have off by one issues on full frame:
- Bilinear sampling do not fully sample bottom and left image border,
 creating edges.
- Single elem buffers are not sampled at all when they should be
 at least on the borders to smooth edges.
- EWA filtering is partially implemented on `ReadBufferOperation`, it
 needs to be moved to `MemoryBuffer` on full frame.

In order to not affect tiled implementation, this commit creates
specific sampling methods for full frame needs.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D12164
2021-08-23 16:36:09 +02:00
8f4730e66f Compositor: Full frame convert nodes
Adds full frame implementation to all nodes in "Converter" sub-menu
except "ID Mask" which is implemented separately.
No functional changes.

Part of T88150.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D12095
2021-08-23 16:36:08 +02:00
James Partsafas
21d4a888b8 Fix T88107: rename Convertor to Converter nodes to correct spelling
Differential Revision: https://developer.blender.org/D11198
2021-08-23 16:27:33 +02:00
acc2e8afa9 Merge branch 'master' into temp-geometry-nodes-fields 2021-08-23 15:58:16 +02:00
04bb1bda32 fix comment 2021-08-23 15:57:50 +02:00
Mikhail Matrosov
cd118c5581 Fix T90423: black pixels after shadow terminator geometry offset
Solves an error in the principled diffuse BSDF, where it was not correctly
rejecting directions outside the hemisphere.

Differential Revision: https://developer.blender.org/D12283
2021-08-23 15:47:34 +02:00
27f138f4c8 Cleanup: rename parameter in transform utility
`inv_unit_scale` is not descriptive.
2021-08-23 09:49:01 -03:00
2f0e350ffd Fix T90872: Dopesheet messes up keyframe handles
Y coordinate was not being constrained.

Caused by {rBb0d9e6797fb866e7a58876c7977c98a190070310}
2021-08-23 09:49:01 -03:00
b4b3f518aa GPencil: Fix memory leak in split & trim functions
Authored by Henrik Dick (weasel)

Reviewed By YimingWu (NicksBest), Antonio Vazquez (antoniov)

Differential Revision: https://developer.blender.org/D12284
2021-08-23 20:46:38 +08:00
5aa3167e48 Fix T90772: Image Editor not sampling color from the the currently
selected pass

Caused by {rBebaa3fcedd23}.

Seems this above commit assumed an ImageUser's multi_index is only used
for Multiview/Stereo? This is not the case, multi_index also stores the
index for layer/pass combination.

If we call both BKE_image_multilayer_index and BKE_image_multiview_index
(even though this is not appropriate/needed for multilayer images?), we
might end up overwriting multi_index again.

note: looking at this I was also wondering why we update the ImageUser
in image-buffer-aquiring funnctions [and not from the UI, e.g.
template_image_layers, but that is a whole different story I guess, see
comment in T90772 as well]

note2: this could also use a utility function (this is not the only
place where this is done), this is fo a cleanup commit.

Maniphest Tasks: T90772

Differential Revision: https://developer.blender.org/D12267
2021-08-23 13:54:52 +02:00
8165333de9 Pipeline: Use more explicit cuda versions. 2021-08-23 13:47:40 +02:00
9564b6cf23 Fix T90651: camera reconstruction crash without scene camera
This was working differently in 2.79, tried tracking this down and it
seems this was wrong since the 2.8 beginning in {rB7907dfc40018}.

This would not only crash without an active scene camera, but would also
result in different tracks from different camera's constraints could not
be selected.

So select id depends on corresponding camera, remove the dependency on
scene camera completely.

Maniphest Tasks: T90651

Differential Revision: https://developer.blender.org/D12230
2021-08-23 12:52:23 +02:00
0682af0d63 RNA: add length augmented to RNA_string_get_alloc
This was noted as a TODO as it wraps RNA_property_string_get_alloc
which takes a length return argument.
2021-08-23 15:08:48 +10:00
62f2204d65 Cleanup: rename len to str_len for BLF functions
Make it obvious which variable this is the length of.
2021-08-23 15:08:28 +10:00
aa067bef5e Cleanup: use BLI_str_utf8 prefix
Rename:

- BLI_str_utf8_invalid_byte  (was BLI_utf8_invalid_byte)
- BLI_str_utf8_invalid_strip (was BLI_utf8_invalid_strip)
2021-08-23 15:02:13 +10:00
0de3d4e8c7 Fix T90847: snap to face of Add Primitive tool not working in edit mode
BVHTree was being created but not balanced.
Error introduced in {rBfcc844f8fbd0}.
2021-08-22 23:48:54 -03:00
eed93aaa07 make dot output more compact 2021-08-22 22:34:25 +02:00
fc0bb6cdee avoid allocating index array in some cases 2021-08-22 20:29:52 +02:00
10f2ad1556 add return instruction and initial procedure validation 2021-08-22 20:16:27 +02:00
b477333473 Cleanup: fix comment about compiler support.
Differential Revision: https://developer.blender.org/D12288
2021-08-22 22:15:28 +05:30
a1e91fbef3 BLF: Remove space_userpref.py font_kerning_style
Remove `font_kerning_style` from `space_userpref.py` since this is no
longer valid.

See more details in D12276

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

Reviewed by Campbell Barton
2021-08-22 09:26:06 -07:00
6d77b87b13 support span buffer reuse 2021-08-22 15:07:23 +02:00
2101b46802 fix comment 2021-08-22 12:49:22 +02:00
34f6765630 Merge branch 'master' into temp-multi-function-procedure 2021-08-22 12:21:52 +02:00
721fad37a1 Fix Windows builds after Zstandard commits 2021-08-21 23:31:51 +02:00
67c29bc5a2 Use Zstandard compression for the sequencer cache
Reviewed By: campbellbarton, brecht, mont29

Differential Revision: https://developer.blender.org/D5799
2021-08-21 21:39:06 +02:00
2ea66af742 Add support for Zstandard compression for .blend files
Compressing blendfiles can help save a lot of disk space, but the slowdown
while loading and saving is a major annoyance.
Currently Blender uses Zlib (aka gzip aka Deflate) for compression, but there
are now several more modern algorithms that outperform it in every way.

In this patch, I decided for Zstandard aka Zstd for several reasons:
- It is widely supported, both in other programs and libraries as well as in
  general-purpose compression utilities on Unix
- It is extremely flexible - spanning several orders of magnitude of
  compression speeds depending on the level setting.
- It is pretty much on the Pareto frontier for all of its configurations
  (meaning that no other algorithm is both faster and more efficient).

One downside of course is that older versions of Blender will not be able to
read these files, but one can always just re-save them without compression or
decompress the file manually with an external tool.

The implementation here saves additional metadata into the compressed file in
order to allow for efficient seeking when loading. This is standard-compliant
and will be ignored by other tools that support Zstd.
If the metadata is not present (e.g. because you manually compressed a .blend
file with another tool), Blender will fall back to sequential reading.

Saving is multithreaded to improve performance. Loading is currently not
multithreaded since it's not easy to predict the access patterns of the
loading code when seeking is supported.
In the future, we might want to look into making this more predictable or
disabling seeking for the main .blend file, which would then allow for
multiple background threads that decompress data ahead of time.

The compression level was chosen to get sizes comparable to previous versions
at much higher speeds. In the future, this could be exposed as an option.

Reviewed By: campbellbarton, brecht, mont29

Differential Revision: https://developer.blender.org/D5799
2021-08-21 21:39:06 +02:00
2b170f16d6 Refactor low-level blendfile reading into separate files
Instead of handling mmap, compression etc. all directly in readfile.c, refactor
the code to use a generic FileReader.
This makes it easier to add new compression methods or similar, and allows to
reuse the logic in other places (e.g. thumbnail reading).

Reviewed By: campbellbarton, brecht, mont29

Differential Revision: https://developer.blender.org/D5799
2021-08-21 21:38:57 +02:00
34a05f39be Clang: warn about C++20 designated initializers
With the ongoing transition to C++ files, Windows build
breaks often because of designated initializers.
Now we have two compilers to catch the MSVC build error on.

Reviewed By: #platform_macos, brecht, campbellbarton
Differential Revision: https://developer.blender.org/D11940
2021-08-21 14:02:50 +05:30
0b7947e855 Cleanup: minor changes to blf_font.c
- Use early return when kerning isn't used.
- Remove early return that prevented matching acquire/release calls.
2021-08-21 17:46:50 +10:00
47e68537f8 Cleanup: organize blf_font.c functions using doxy-sections
Functions in this file were scattered and not well organized.
2021-08-21 17:41:40 +10:00
c671bfe14e Cleanup: spelling in comments & minor cleanup
Also hyphenate 'mouse-move' use doxy sections in render_update.c &
move function comment from the header to the source.
2021-08-21 13:26:54 +10:00
aed5a27755 Correct build error from 0d7aab2375 2021-08-21 13:22:47 +10:00
0d7aab2375 Refactor: BLF Kerning Cache After Use
Optimization of font kerning by only caching kerning values after a
pair is encountered. Also saves unscaled values so they don't have to
be rebuilt between font size changes.

See D12274 for more details and speed comparison.

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

Reviewed by Campbell Barton
2021-08-20 17:48:42 -07:00
b6a1bf757d DocPy: Cleanup missing newline resulting in wrong html generation 2021-08-20 14:54:46 -04:00
86622467c5 DocPy: Update Dependancies
Updates sphinx and the theme to the latest version along with any of their dependencies.

Note that we will be sticking to sphinx 4.1.1 until sphinx 4.2 for the same reasons listed in:
https://developer.blender.org/rBM8334
2021-08-20 13:46:38 -04:00
Alaska
cd8d9383e7 Fix T90804: small grammatical error in noise threshold description
Differential Revision: https://developer.blender.org/D12277
2021-08-20 17:43:24 +02:00
1b5f17b867 Cleanup, use BKE_scene_uses_cycles_experimental_features 2021-08-20 15:00:58 +02:00
6a404bc633 Cleanup, remove extra code from previous commit
This got accidentally introduced while revising dependencies between
patches for this feature, did not notice until it was too late.
2021-08-20 14:48:47 +02:00
9bfc47c933 Alembic Procedural: basic cache control settings
This adds a setting to enable data caching, and another one to set the
maximum cache size in megabytes.

When caching is enabled we load the data for the entire animation in
memory, as we already do, however, if the data exceeds the memory limit,
render is aborted.

When caching is disabled, we simply load the data for the current frame
in memory.

Ref D10197

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D11163
2021-08-20 14:34:43 +02:00
c58d1acba8 improve naming 2021-08-20 14:29:01 +02:00
accf3045be Fix memory leak while processing mouse event
Assignment missed.
2021-08-20 09:06:19 -03:00
ef502127dd Fix T90795: Moving keys in Grease Pencil Dopesheet crashes Blender
`td->loc` is referenced but not initialized.
2021-08-20 08:40:37 -03:00
0ee79f304e cleanup 2021-08-20 13:38:38 +02:00
e642de3d6f Merge branch 'master' into temp-multi-function-procedure 2021-08-20 13:37:32 +02:00
0081200812 Functions: remove multi-function network
The multi-function network system was able to compose multiple
multi-functions into a new one and to evaluate that efficiently.
This functionality was heavily used by the particle nodes prototype
a year ago. However, since then we only used multi-functions
without the need to compose them in geometry nodes.

The upcoming "fields" in geometry nodes will need a way to
compose multi-functions again. Unfortunately, the code removed
in this commit was not ideal for this different kind of function
composition. I've been working on an alternative that will be added
separately when it becomes needed.

I've had to update all the function nodes, because their interface
depended on the multi-function network data structure a bit.
The actual multi-function implementations are still the same though.
2021-08-20 13:14:39 +02:00
eca5a8b695 Merge branch 'master' into temp-multi-function-procedure 2021-08-20 12:48:18 +02:00
7d8c71e800 Geometry Nodes: add missing versioning for subdivision surface node
This was missing from rBfecec1644ce54ea386eaeed5ca6748d4a7b2737b.
2021-08-20 12:19:24 +02:00
c1227fd408 Cleanup: remove duplicate line 2021-08-20 12:05:03 +02:00
d217b34214 Functions: add utility methods to parameter builder 2021-08-20 11:48:31 +02:00
fd51b05a02 Functions: add clear method to vector array 2021-08-20 11:48:31 +02:00
2b6f0cc836 BLI: add utility methods to IndexMask 2021-08-20 11:48:31 +02:00
79c79f3c70 cleanup 2021-08-20 11:37:23 +02:00
e95b197e98 Cleanup: Add CLOG to wm_files_link.c 2021-08-20 11:27:42 +02:00
a9970d3cb9 bring back clamping in math node 2021-08-20 10:44:29 +02:00
b812f289f5 Merge branch 'master' into mf-procedure 2021-08-20 10:36:04 +02:00
cea24b4b4a Cleanup: use "free_data" suffix when the argument isn't freed
Avoid API misuse that caused leaks in T90791 &
2788b0261c.
2021-08-20 16:37:50 +10:00
e05db0c26b Cleanup: rename BKE_mesh_free_data -> BKE_mesh_free_data_for_undo
This function only makes sense for undo which doesn't
initialize the meshes ID. Otherwise BKE_id_free should be used.
2021-08-20 16:21:29 +10:00
40f0783d51 Cleanup: remove BKE_mesh_free_data use for lineart mesh copies
Even though this didn't leak memory, BKE_mesh_free_data doesn't
handle freeing data that is part of the ID making it error prone.
2021-08-20 16:08:35 +10:00
15a46a8b72 Cleanup: accidentally included printf 2021-08-20 16:02:39 +10:00
9e2cd6b077 Fix memory leak with building springs in the cloth simulator
Error in 2788b0261c.
2021-08-20 16:00:12 +10:00
a48df97ada Fix T90791: Knife project leaks memory with curve/text cutter 2021-08-20 15:19:58 +10:00
ce3a6d7989 Cleanup: rename BKE_mesh_free -> BKE_mesh_free_data
It wasn't obvious this didn't free the memory of the mesh it's self
leading to memory leaks.
2021-08-20 15:08:27 +10:00
44b25b0ea5 Cleanup: unused warnings 2021-08-20 15:03:32 +10:00
fca6b2780f Cleanup: clang-format 2021-08-19 19:27:49 -07:00
f8637cd8af Alembic Procedural: only subdivide if subsurf modifier is present
As subdivision objects are first class citizens in Alembic, to
differentiate them with non-subdivided polygon meshes, the Alembic
Procedural automatically sets up subdivision properties on the generated
Cycles Mesh.

However, for real-time playback subdivision is far too slow, so this
modifies the detection of a MeshSeqCache modifier used to activate the
procedural to allow for a Subsurf modifier right after the cache one. If
present, the procedural will tag the object for subdivision, if absent, the
object will be treated as a regular mesh.

This is a temporary measure for until subdivision surface settings are part
of the Mesh datablock (see T68891).

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D11162
2021-08-20 02:40:37 +02:00
5b51df0f33 Cleanup, format 2021-08-20 02:30:11 +02:00
962153dbed Cycles: missing case for ignoring subdivision vertex normals
This was missing from rBb8ecdbcd964a.
2021-08-19 20:36:34 +02:00
c0dd6f1164 Fix T90776: Cycles normal map node produces artifacts
This is caused by a typo in rBb8ecdbcd964a `sd->prim` is the primitive
index, but was used to discriminate the primitive type (stored in `sd-
>type`).
2021-08-19 20:36:34 +02:00
72f73c0b71 UI: Use theme's alpha for Summary instead of a hardcoded value 2021-08-19 20:24:46 +02:00
dbc4f6fdc9 Fix error rendering Cycles shader nodes from before 2013
After the recent changes to use socket identifiers instead of names.
2021-08-19 20:12:50 +02:00
871f7f4ad8 GPencil: Cleanup old printf debug lines
These lines were very old debug code and now it's not required because the code is very tested.
2021-08-19 19:23:13 +02:00
215ce0fb57 fix 2021-08-19 18:19:15 +02:00
5154598845 Merge branch 'master' into mf-procedure 2021-08-19 18:11:51 +02:00
1ee80d792c cleanup 2021-08-19 18:09:52 +02:00
95284d2f1e bring back function nodes 2021-08-19 18:07:36 +02:00
3febcb98ed Image blendwrite: Fix handling of packedfiles.
Packedfiles need some special attention when writing Image to disk.

Source: D12242, Jeroen Bakker (@jbakker), thanks.
2021-08-19 18:00:00 +02:00
0896457c59 Partially fix T90593: Image ID wrongly seen as changed on undos.
Several pure runtime data in this ID type were not properly cleared by
write/read processes.

Note that the initial undo step (the one leading back to initial read
file state) is still forcing re-load of image, for some reasons.

Common investigation together with Jeroen Bakker (@jbakker), thanks. See
also D12242.
2021-08-19 18:00:00 +02:00
214e4aac97 Fix Python error in ./benchmark init after recent changes 2021-08-19 17:45:37 +02:00
7281f3eb56 start bringing back function nodes 2021-08-19 17:28:15 +02:00
479cc9a83e UI: Match row color for Summary in Mask animation editor
The back color of the row was missing.
2021-08-19 17:06:49 +02:00
71655ff8df GPencil: Match row color for Summary in Grease Pencil animation editor
The background of the summary row was different in Grease Pencil mode.

Reviewed by: Pablo Vazquez, Matias Mendiola
2021-08-19 17:06:41 +02:00
607ef8f6c5 pull out multi function network 2021-08-19 16:49:00 +02:00
1ce640cc0b test vector processing 2021-08-19 16:24:32 +02:00
7192e57d63 Fix the value in the graphical editor header when transforming
The header did not display the actual value when transforming with snapping
2021-08-19 10:34:13 -03:00
b0d9e6797f Fix T87173: wrong Auto-Snap in animation editors
This was partially broken with {rBde9ea94fc6f}.

The `Frame Step` and `Second Step` snapping options were working as if
they were `Nearest Frame` and `Nearest Second` respectively in the
`Dope Sheet` and `NLA` editors.

In the `Graph Editor` the problem was more serious:
"Second Step: ... The keyframe itself moves along as though in snapping
were active at all, while its handles 'stay behind' until it reaches
the next second boundary, at which point the teleport handles to
'catch up'".

The snapping code for these modes was spread across the transform
mode code and `recalcData` of each data type. Therefore, create a
unified snapping code for these options so that all issues are fixed in
one place.

Differetial Revision: https://developer.blender.org/D12241
2021-08-19 10:34:13 -03:00
119d53263f Transform Convert Action: conventionalize TransData creation
`td2d->loc`, `td2d->loc2d`, `td->loc` and `td->iloc` were not being
initialized as is done with the other conversion types.

This avoids problems with transform modes becoming incompatible.

This avoids problems with incompatible transform modes that could
result in a crash.
2021-08-19 10:34:13 -03:00
Germano Cavalcante
85b044b3ef Fix incremental snap in animation editors
Animation editors have their own snap types and incremental is not
supported.
2021-08-19 10:34:13 -03:00
46aafbbf66 Cleanup: move animation snap utilities to a separate compilation unit
The snap functions of animation editors were scattered in
`transform_mode` and `transform_snap`.
2021-08-19 10:34:13 -03:00
7bed18fdb1 support creating loops with builder 2021-08-19 15:33:35 +02:00
e648e38887 Undo: Clear more ID runtime data on filewrite.
This should help reducing false 'changed' status detection when reading
back a memfile undo step.

Related to T90593 & D12242.
2021-08-19 15:09:33 +02:00
0f49e4832c Cleanup: Blendwrite: Move code deciding if an ID should be written out of ID callbacks.
This was not really useful, and added estra useless steps in case and ID
should not actually be written.

Further more, it prevented clearing the usercount on write, which can be
cause a false positive 'chanhged' detection in undo/redo case.
2021-08-19 15:09:33 +02:00
d5776f4829 LibOverride: Tag all embedded IDs RNA opinters as overridablei, part II.
Not sure how I failed to include those files in rBe5f8db92b696...
2021-08-19 15:09:33 +02:00
51862c8445 Cycles: experimental integration of Alembic procedural in viewport rendering
This patch exposes the Cycles Alembic Procedural through the MeshSequenceCache
modifier in order to use and test it from Blender.

To enable it, one has to switch the render feature set to experimental and
activate the Procedural in the modifier. An Alembic Procedural is then
created for each CacheFile from Blender set to use the Procedural, and each
Blender object having a MeshSequenceCache modifier is added to list of objects
of the right procedural.

The procedural's parameters derive from the CacheFile's properties which are
already exposed in the UI through the modifier, although more Cycles specific
options might be added in the future.

As there is currently no cache controls and since we load all the data at the
beginning of the render session, the procedural is only available during
viewport renders at the moment. When an Alembic procedural is rendered, data
from the archive are not read on the Blender side.

If a Cycles render is not active and the CacheFile is set to use the Cycles Procedural,
bounding boxes are used to display the objects in the scene as a signal that the
objects are not processed by Blender anymore. This is standard in other DCCs.
However this does not reduce the memory usage from Blender as the Alembic data
was already loaded either during an import or during a .blend file read.

This is mostly a hack to test the Cycles Alembic procedural until we have a
better Blender side mechanism for letting renderers load their own geometry,
which will be based on import and export settings on Collections (T68933).

Ref T79174, D3089

Reviewed By: brecht, sybren

Maniphest Tasks: T79174

Differential Revision: https://developer.blender.org/D10197
2021-08-19 14:40:51 +02:00
5b97c00e9f Alembic import: option to always add a cache reader
The current behavior of the Alembic importer is to only create a
`MeshSequenceCache` modifier or a `Transform Cache` constraint to imported
objects if they have some animated properties.

Since static objects do not have a cache reader, when reloading files those
objects are not updated. Currently, the only way to properly reload a file
because of this is to reimport it.

This adds an option to the importer to always add a cache reader, even if
there is no animated data, to ensure that all objects coming from Alembic
archive are linked to them and updated properly upon reloads.

Reviewed by: brecht, sybren

Ref D10197.
2021-08-19 14:29:42 +02:00
c827b50d40 add dummy instruction type 2021-08-19 14:06:43 +02:00
3c7e3c8e44 improve naming 2021-08-19 13:46:19 +02:00
98e38ce4f3 cleanup 2021-08-19 13:44:15 +02:00
132cf268c0 add comments 2021-08-19 13:36:52 +02:00
fd7edc9b05 cleanup 2021-08-19 13:28:15 +02:00
ecf7c90840 remove redundant utilties 2021-08-19 13:15:11 +02:00
d78a530af1 initial procedure builder 2021-08-19 13:09:41 +02:00
3ebe61db9f support evaluation on one 2021-08-19 11:22:57 +02:00
86c2f139c6 cleanup 2021-08-19 10:09:02 +02:00
3596c348eb cleanup 2021-08-19 10:07:51 +02:00
4db4123409 Correct assert from 22ab0159a9 2021-08-19 17:56:25 +10:00
cf72194214 Fix T71137: curve minimum twist producing wrong geometry
Originally D11886 by @ghaspias with minor edits applied.
2021-08-19 17:10:34 +10:00
22ab0159a9 Refactor: BLF Without Kerning Modes
Simplification of BLF code after removal of kerning modes.

See D12262 for more details.

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

Reviewed by Campbell Barton
2021-08-18 20:31:47 -07:00
4734de1093 Cleanup: correction to unused warning removal
This broke building without opensubdiv
2021-08-19 13:18:51 +10:00
594790d8a5 UI: add function to access the buttons text without it's shortcut 2021-08-19 12:50:50 +10:00
7a4ef5256a Cleanup: reduce indentation in loops that check region visibility 2021-08-19 12:50:50 +10:00
feaa61a968 UI: Remove "Unfitted" Kerning Style Option
This patch removes the "Kerning Style" option for UI widget font
drawing and uses only the current default of "Fitted", since the other
option of "Unfitted" is just the result of truncation errors.

see D12231 for much more information.

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

Reviewed by Campbell Barton
2021-08-18 19:48:30 -07:00
ac09411368 Cleanup: unused warning 2021-08-19 12:15:15 +10:00
a217e043be Audaspace: porting PulseAudio fixes from upstream. 2021-08-18 22:22:21 +02:00
55f9014616 Alembic procedural: remove Generated attribute creation
The main reason for this is to speed up updates by avoid unnecessary
copies as the Generated coordinates are a copy of the vertices.

Creating this attribute may become optional in the future, with UI
parameters to select which attribute to use from the Alembic archive as
reference.
2021-08-18 21:27:52 +02:00
6b041ad3d0 Cycles: use object coordinates when generated coordinates are missing
This modifies the attribute lookup to use object coordinates if no
generated coordinates are found on the geometry.

This is useful to avoid creating and copying this attribute, thus saving
a bit of time and memory.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D12238
2021-08-18 21:20:39 +02:00
b8ecdbcd96 Cycles: avoid copying vertex normals attribute twice to the devices
Vertex normals are needed for normals maps and therefore are packed and send
to the device alongside the other float3 attributes. However, we already pack
and send vertex normals through `DeviceScene.tri_vnormal`.

This removes the packing of vertex normals from the attributes buffer, and
reuses `tri_vnormal` in the kernel for normals lookup for normal maps, which
reduces memory usage a bit, and speeds up device updates.

This also fixes potential missing normals updates following rB12a06292af86,
since the need for vertex normals for normals maps was overlooked.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D12237
2021-08-18 21:12:39 +02:00
41a81474e4 refactor procedure executor 2021-08-18 20:19:12 +02:00
aa2822d137 cleanup 2021-08-18 20:18:19 +02:00
e5f8db92b6 LibOverride: Tag all embedded IDs RNA opinters as overridable.
Followup to previous commit, rBfffe219bdb8drBfffe219bdb8d

Again this is only for sake of sane ID/overrides managment for now,
the nodetrees themselves are not overridable from user PoV yet.
2021-08-18 17:05:49 +02:00
fffe219bdb LibOverride: Make nodetree of material overrideable again.
This reverts rB6899dbef77cd and makes the pointer explicitely
processable by override & diffing code.

Previous changes & fixes have fixed the 'driver-workaround' case afaict.

Note that this only enables proper generic handling of overrides and
their ID pointers, no node property is actually overridable currently.
2021-08-18 16:49:20 +02:00
1d06d35034 LibOverride: Do not report embedded IDs as non-overridable in 'foreach_id' code.
Embedded IDs (root nodetrees, master collection, etc.) pointer itself is
not editable, but their content may be overridden.

LibOverride code is supposed to know how to handle those embedded IDs.
2021-08-18 16:49:20 +02:00
ba71eb467e LibOverride: Add several missing 'OVERRIDABLE' flags to NodeTrees RNA.
This should be a no-change commit for now, but is required to enable
initial basic support of nodetrees in library override.

NOTE: Proper full support of liboverrides in nodes is yet to be designed
(has UX unresolved issues, since we likely do not want to expose/make
overridable ALL settings of ALL nodes).
2021-08-18 16:49:20 +02:00
9bfd4ae222 LibOverride: tweak resync detection code at apply phase.
This code checks whether an ID pointer property of an override does not
match its linked reference when it is expected to do so.

This is a goiod indication that a resync is needed.

Previous code would falsy detect overrides of IDs referencing themselves
as needing a resync, when this is not effectively the case.
2021-08-18 16:49:20 +02:00
55b333d3e3 Merge branch 'master' into mf-procedure 2021-08-18 16:14:32 +02:00
Charlie Jolly
04376c3bac Geometry Nodes: Add shader Color Mix node
Port color mix shader node to Geometry Nodes.

Differential Revision: https://developer.blender.org/D10585
2021-08-18 14:50:52 +01:00
787350dde8 Fix T90737: VSE adding nested strips could have non-unique names
Caused by {rBbbb1936411a5}.

When adding strips via the new SEQ_add_XXX_strip functions, the
`Editing->seqbasep` pointer was passed around.
Following in `seq_add_generic_update` this `seqbasep` pointer was used
to ensure a unique name.
But `seqbasep` is the pointer to the current list of seq's being edited
(**which can be limited to the ones within a meta strip**).

We need unique names across all strips though (since these are used for
RNA paths, FCurves as reported), so now use the scene's `Editing-
>seqbase` (**which is the list of the top-most sequences**) instead.

Unfortunately this might have screwed files to a borked state, not sure
if this could easily be fixed...

Maniphest Tasks: T90737

Differential Revision: https://developer.blender.org/D12256
2021-08-18 14:43:16 +02:00
7bffafab7b Fix T90718: Object selection toggle do not work inside edit mode
The object was not deselected as it was expected that it would be
activated.

But this activation does not happen in edit mode.
2021-08-18 09:39:45 -03:00
00cfad8578 add utility method 2021-08-18 10:00:51 +02:00
Jeroen Bakker
c0f600cad1 T73434: Improve Weight Paint Overlay Drawing.
Master multiplied the weight paint on top of the rendered image. This
reduced readability.

This patch removes the multiplication for weight painting and adds a
hint of the geometry below the overlay.

Reviewed By: Mets, pablodp606, campbellbarton

Maniphest Tasks: T73434

Differential Revision: https://developer.blender.org/D12170
2021-08-18 07:32:23 +02:00
400cb25fc7 UDIM: Support tile sets that do not start at 1001
Removes the artificial requirement that UDIM tile sets start at 1001.
Blender was already capable of handling sparse tile sets (non-contiguous
tiles) so the restriction around starting at 1001 was unnecessary in
general.

This required fixing a few UDIM-related python bugs around manually
updating the `tile_number` field on images as well. See the differential
for details. No script changes are necessary but they will now work,
correctly, in many more cases.

Differential Revision: https://developer.blender.org/D11859
2021-08-17 21:44:36 -07:00
f41beca977 Fix T90695: Lower tile splitting limit for lineart
Lowers tile splitting limit so models with extremely dense mesh
portions could still have reasonable performance while for more
common cases the performance impact should be minimal.

Reviewed By: Sebastian Parborg (zeddb), Antonio Vazquez (antoniov)

Differential Revision: https://developer.blender.org/D12236
2021-08-18 12:02:53 +08:00
24c16f5457 Fix wireframe overlay not blending over paint overlay correctly
When using wireframe opacity, the paint overlay needs to be drawn
before the wireframes in order to alpha blend correctly.
Sculpt overlays were also affected by this, so this commit refactors
this part of the code in case other overlays needs to be added in
the future.

Reviewed By: Mets

Differential Revision: https://developer.blender.org/D12235
2021-08-17 23:54:45 +02:00
809dce5bde Cleanup: move 'recalcData' to 'transform_convert.h'
The `recalcData` function is defined in `transform_convert.c`, so the
header is most expected to be `transform_convert.h`.
2021-08-17 17:23:57 -03:00
Henrik Dick
e3098de2a1 GPencil: Fix unreported switch direction not flipping weights
There was an unreported bug that switch direction would not switch the order of the vertex group weights. This caused join to do it wrong as well.

Changed to use `BLI_array_reverse` function here to reverse both the normal points and the weights, therefore simplifying the code.

Differential Revision: https://developer.blender.org/D12251
2021-08-17 22:20:26 +02:00
23132fcdc1 Fix T77307: Particle Info Node Does Not Consider Time Remapping
`frame_current_final()` should be used to access the Scene time after
remapping, which also matches how the particles system handles time.

Reviewed By: brecht

Maniphest Tasks: T77307

Differential Revision: https://developer.blender.org/D12239
2021-08-17 21:41:18 +02:00
60d6333b80 Fix T82336: Cycles standard attributes missing in displacement shaders
Standard attributes are not added to the attributes requests when
shaders only have displacement. This is because nodes are only
considering the case when the surface socket is connected.

To support this, added `Shader.has_surface_link()` which checks for both
cases (`has_surface` and `has_displacement`) and replaces all checks on
`Shader.has_surface`.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D12240
2021-08-17 21:38:04 +02:00
Henrik Dick
88dc274d05 GPencil: Convert from Mesh copying Vertex Groups
This patch adds the missing ability to keep the vertex groups when converting to a grease pencil object. This is increadible useful to create rigged grease pencil objects which move together with rigged meshes.

Differential Revision: https://developer.blender.org/D12249
2021-08-17 20:20:47 +02:00
96d0cd57dc Fix T90719: Boost sources dowload address needed to be updated. 2021-08-17 18:01:42 +02:00
1891c956e5 refactor variable store 2021-08-17 17:24:01 +02:00
e98824d6c4 CMake: add missing headers 2021-08-18 00:37:04 +10:00
7f38872533 RNA: de-duplicate enums in generated source
Reuse existing enums instead of expanding them since it bloats the binary.

The icons enum for example contains over 900 items and was being
expanded 17 times (once for each function that takes an icon argument).
Similar with the event type enum which contains over 200 items and was
duplicated 7 times.

makesrna.c now matches enum definitions from declarations in
RNA_enum_items.h, using their identifiers when found.

The overall space saving on my system is 776kb
(tested with a stripped release build).

Reviewed By: brecht

Ref D12245
2021-08-18 00:23:50 +10:00
0246128b7f Fix wrong Anim Auto-Snap Ctrl toggle
This was not working like elsewhere in both NLA and Graph Editor
(meaning that when snapping was already enabled, {key Ctrl} during
transform did not disable it).

Now use getAnimEdit_SnapMode() for this in NLA and GE as well.

Maniphest Tasks: T87173

Differential Revision: https://developer.blender.org/D12244
2021-08-17 15:52:28 +02:00
249c050757 add single test 2021-08-17 15:27:46 +02:00
a0081046b6 cleanup instruction scheduling 2021-08-17 15:01:27 +02:00
635f73b7f1 fixes after merge 2021-08-17 14:00:06 +02:00
74fcd50e2f Merge branch 'master' into mf-procedure 2021-08-17 13:44:25 +02:00
f8dd0080a9 Cleanup: clang tidy
The parameter name was inconsistent between declaratation
and implementation.
2021-08-17 11:12:59 +02:00
6028ac44a1 Cleanup: unused defines 2021-08-17 17:45:57 +10:00
7304541f66 Edit Mesh: skip unselected meshes for "Tris to Quads"
Also move property assignment out of the object loop.
2021-08-17 17:12:36 +10:00
32844d32c1 Edit Mesh: skip unselected meshes for "Set Normals from Faces" 2021-08-17 17:12:24 +10:00
4443831c6b Edit Mesh: skip normals to vector with unselected meshes for "Delete"
Meshes with unselected elements are skipped but still called
BM_custom_loop_normals_to_vector_layer.
2021-08-17 17:11:49 +10:00
6baa62245f Edit Mesh: skip flipping custom normals for meshes with no selection
Also split out normal calculation into functions.
2021-08-17 17:10:59 +10:00
cb40c7ca1f Fix memory leak in edit-mesh dissolve degenerate 2021-08-17 16:46:52 +10:00
4c8d68c032 Cleanup: replace degenerate check with assert
Use an assert since this should never happen.
2021-08-17 15:16:34 +10:00
736b6a70a4 Docs: improve word wrap comment 2021-08-17 15:11:54 +10:00
nutti
69fdcea978 Docs: add API docs for gpu.capabilities
Adds Python API documentations for gpu.capabilities module.

Ref D12226
2021-08-17 15:04:35 +10:00
ba055493a0 Cleanup: clang-format 2021-08-17 14:46:46 +10:00
nutti
d60e28093f Docs: add API docs for gpu.platform
Adds Python API documentations for gpu.platform module.

Ref D12222
2021-08-17 14:45:40 +10:00
869b84452a Cleanup: compiler warnings 2021-08-17 14:42:12 +10:00
eaa1527385 UDIM: Fix tile number calculation when adding a range of image tiles
When adding a range of tiles, the operator could incorrectly calculate
the end_tile. It would not account for the start_tile itself and the
IMA_UDIM_MAX value was 1 too small. This is most noticeable when
attempting to fill the entire supported range of tiles.

Differential Revision: https://developer.blender.org/D11857
2021-08-16 21:19:39 -07:00
4dba206011 PyAPI: GPUShader: make 'uniform_vector_*' less restricted
Buffers larger than required may be allowed without restriction.
2021-08-16 13:57:25 -03:00
b5117660da PyAPI: GPU Buffer: Buffer protocol support
The code was commented due to lack of testing and short release deadline.
2021-08-16 13:57:25 -03:00
035d4c28ab Add sanity NULL checks when loading sound sequences
Would cause crashes in files that had lingering invalid sound sequences around.
For example our tests/render/volume/fire.blend test file.
2021-08-16 16:52:38 +02:00
df3884d512 Fix T90689, T90705: Cycles math node with 3 inputs broken after recent changes
Thanks Charlie Jolly for finding the fix.
2021-08-16 15:54:18 +02:00
7db3746033 Cleanup: spelling 2021-08-16 23:46:28 +10:00
394a0b0da5 Fix building without audaspace 2021-08-16 23:19:54 +10:00
118946d195 Fix T87967: M2T video seeking is broken
Bug caused by integer overflow in ffmpeg_generic_seek_workaround().
Function max_ii() was used to limit int_64tvalue.

After fixing the issue there was another issue, where near-infinite loop
was caused by requested_pos being very large and stream being cut in a
way, that it was missing keyframe at beginning.
This was fixed by checking if we are reading beyond file content.

Reviewed By: zeddb

Differential Revision: https://developer.blender.org/D11888
2021-08-16 15:12:19 +02:00
2946f72a2a VSE: Use lines to draw waveform
Refactor and improve waveform drawing.

Drawing now can use line strips to draw waveforms instead of only
triangle strips. This makes us able to properly visualize thin waveforms
as they would not be visible before. We now also draw the RMS value of
the waveform.

The waveform drawing is now also properly aligned to the screen pixels
to avoid flickering when transforming the strip.

Reviewed By: Richard Antalik

Differential Revision: https://developer.blender.org/D11184
2021-08-16 15:12:19 +02:00
ded68fb102 VSE: Fix audaspace not reading ffmpeg files with start offset correctly
The duration and start time for audio strips were not correctly read in
audaspace.

Some video files have a "lead in" section of audio that plays before the
video starts playing back. Before this patch, we would play this lead in
audio at the same time as the video started and thus the audio would not
be in sync anymore.

Now the lead in audio is cut off and the duration should be correctly
calculated with this in mind.

If the audio starts after the video, the audio strip is shifted to
account for this, but it will also lead to cut off audio which might not
be wanted. However we don't have a simple way to solve this at this
point.

Differential Revision: http://developer.blender.org/D11917
2021-08-16 15:10:58 +02:00
6df81ddb84 VSE: Fix seeking issues.
The seek pts was not correctly calculated.
In addition to that we were not seeking in the video pts time base.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11921
2021-08-16 14:52:57 +02:00
a01cf90fd8 VSE: Fix video strip duration calculation
The video duration was not read correctly from the video file.

It would use the global duration of the file which does in some cases
not line up with the actual duration of the video stream.
Now we take the video stream duration and start time into account when
calculating the strip duration.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11920
2021-08-16 14:52:57 +02:00
43ad345caa VSE: Fix memory leak when adding bad image/movie strips
If the add strip operator errored out, we wouldn't free custom data allocated

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11919
2021-08-16 14:52:57 +02:00
e314260fa7 VSE: Fix "off by one" error when encoding audio
Before we didn't encode the audio up until the current frame.
This lead to us not encoding the last video frame of audio.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11918
2021-08-16 14:52:57 +02:00
08af3e6e92 VSE: Flush audio encode after finishing video export
We didn't flush audio after encoding finished which lead to audio
packets being lost.

In addition to this the audio timestamps were wrong because we
incremented the current audio time before using it.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11916
2021-08-16 14:52:56 +02:00
Eitan
fecec1644c Geometry Nodes: Add UV Smooth, Boundary Smooth options to subdivision node
Replaces the boolean option with enum menus for consistency
with the subdivision modifier (rB66151b5de3ff,rB3d3b6d94e6e).
Adds all UV interpolation options.
Original patch by Eitan. Updated by Himanshi Kalra <calra>.
{F9883204}

Reviewed By: HooglyBoogly

Differential Revision: https://developer.blender.org/D10417
2021-08-16 14:31:50 +05:30
ddecd7aaca Cleanup: shadow variable warning 2021-08-16 18:06:10 +10:00
Himanshi Kalra
c48a01a88a Add cutom data color property for mesh comparison
Add color data type comparison for meshes, adding it as
part of comparing meshes with geometry nodes applied.

Reviewed By: JacquesLucke

Differential Revision: https://developer.blender.org/D12192
2021-08-16 12:28:12 +05:30
c0016a8581 BLF: avoid unnecessary lookups in blf_kerning_cache_new
blf_kerning_cache_new was performing many unnecessary hash lookups,
calling blf_glyph_search 32768 times. Use a lookup table to reduce this
to the number of ASCII characters (128 calls).
2021-08-16 14:35:38 +10:00
4300050e20 Cleanup: rename kerning table to ascii_table
It wasn't obvious this was only for ASCII characters.
2021-08-16 14:35:38 +10:00
87adcbc94f BLF: use fast ASCII kerning for word-wrap calculations
While this wasn't a bottleneck, using the fast version of this function
removes some duplicate code that doesn't use the look-up table.
2021-08-16 14:35:38 +10:00
6aebbe6a0a Cleanup: replace macros with inline functions for font drawing
Also assert blf_font_ensure_ascii_kerning has been called in
blf_kerning_step_fast.
2021-08-16 14:35:38 +10:00
eb278f5e12 XR: Color Depth Adjustments
This addresses reduced visibility of scenes (as displayed in the VR
headset) that can result from the 8-bit color depth format currently
used for XR swapchain images.

By switching to a swapchain format with higher color depth (RGB10_A2,
RGBA16, RGBA16F) for supported runtimes, visibility in VR should be
noticeably improved.

However, current limitations are lack of support for these higher
color depth formats by some XR runtimes, especially for OpenGL.

Also important to note that GPU_offscreen_create() now explicitly
takes in the texture format (eGPUTextureFormat) instead of a
"high_bitdepth" boolean.

Reviewed By: Julian Eisel, Clément Foucault

Differential Revision: http://developer.blender.org/D9842
2021-08-16 11:46:09 +09:00
899935d5d0 Fix wrong usage of 'sizeof'
The intention was to use `ARRAY_SIZE`.

No functional changes.
2021-08-15 20:08:17 -03:00
3f0d785d23 Fix T90658: selection of some 3D gizmos failing
Small error due to wrong variable usage.

Introduced in rBfcd2d63b644e.
2021-08-15 17:55:09 -03:00
d5261e973b BLF: Do Not Preload Glyph Cache
This patch turns off the preloading of ascii glyphs and instead caches
each glyph the first time it is actually used.

See D12215 for much more detail.

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

Reviewed by Campbell Barton
2021-08-14 13:50:51 -07:00
8f2b60ddbf Cleanup: Variable names, formatting, reduce indentation 2021-08-13 21:46:59 -05:00
6a4533dd02 BLF Cleanup: Size Defines, Comments, etc
This patch makes some non-functional changes to BLF code. Some size
defines added, comments changed, simplification of macro
BLF_KERNING_VARS.

See D12200 for more details.

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

Reviewed by Campbell Barton
2021-08-13 14:31:10 -07:00
ae3472998a Cleanup: rearrange includes
Bring the includes from the same project together.
2021-08-13 17:36:35 -03:00
Germano Cavalcante
0ed2df81cc Fix T90637: Outliner: VSE context menu options are not working
Some of the enum options in the context menu operations are not
supported for all element types.

`TSE_SEQUENCE`, for example, only supports the `Select` option.

So, populate the enum list dynamically depending on the type.

Also add some calls that were missing for the `TSE_SEQUENCE` type.
(`WM_event_add_notifier` and `ED_undo_push`).
2021-08-13 17:28:46 -03:00
5655b3d1c5 Cleanup: fix typos in static variables
_desps --> _deps
2021-08-13 15:45:07 -03:00
5225e459da Fix T86883: Add/fix suport of liboverrides in relocate/reload library case.
There was already some code for that, but it was broken, and proper
resync was completely missing.

There might still be more resync needed in library linking operators
though.
2021-08-13 16:37:29 +02:00
bb0e29c922 Blendloader: Option to reports to skip list of recursively liboverride-resynced libs.
This extra info is not always needed/convinient to use, and requires
special attention to free the list, so allow not generating it.
2021-08-13 16:37:29 +02:00
7772880d69 ViewLayer resync: Add sanity checks for objects/bases mappings.
Add a debug-only check regarding consistency of the cache (mapping from
objects to their bases) for a given ViewLayer.

Issues can happen otherwise when some code does remapping of objects,
and forgets to call `BKE_main_collection_sync_remap()` (which clears
those caches) instead of `BKE_main_collection_sync()`.
2021-08-13 16:37:29 +02:00
77744b581d Fix T90595: some VSE strip properties do not identify strip name in anim
channel names

Working with multiple strips keyframes was unneccessarily difficult in
Animation Editors (since some anim channels could not be distinguished).

Namely `Crop` and `Transform` are nested structs (nested under
`Sequence`), so these were just displaying the raw struct name.
Also strip modifiers did not have their strip name in their channel
names. Now include the strip name for these.

before
{F10277439}

after
{F10277441}

Maniphest Tasks: T90595

Differential Revision: https://developer.blender.org/D12193
2021-08-13 15:17:00 +02:00
Matteo F. Vescovi
0b3c7544b5 Fix FTBFS on mips64el architecture
While trying to get Blender 2.93.x LTS to build fine on all release architectures in Debian, I noticed that the misleading use of "mips" as integer variable caused problems when compiling on mips64el. The patch should fix the issue.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D12194
2021-08-13 14:33:50 +02:00
4cadccebfa Revert "Mesh: replace saacos with acosf for normal calculation"
This reverts commit 41e6509818.

This broke "CubeMaskFirst" test.

Any value even slightly outside the [-1.0..1.0] range
caused the result to be nan, which can happen when calculating
the dot-product between two unit length vectors.
2021-08-13 19:45:01 +10:00
b9486c39bc Cleanup: Unused function parameter warning 2021-08-13 11:16:01 +02:00
fd29a161cc Fix Action Editor unlink button when in tweak mode
When in NLA tweak mode, the action unlink button in the Dopesheet /
Action Editor should be a mere shortcut to exiting tweak mode [nothing
else].

Instead, it was also clearing the action fully, not returning to the
previous edited action before going into tweak mode.

Now dont "flush" by clearing the action, instead exit tweakmode, clear
the scenes SCE_NLA_EDIT_ON flag (if this isnt done some NLA operators
like pushdown were not immediately available because their poll checked
this flag) and send appropriate notifier to have everything update nicely.

Part of T87681 (Bug 4/5/6).

Maniphest Tasks: T87681

Differential Revision: https://developer.blender.org/D11052
2021-08-13 11:07:27 +02:00
00f264ea42 Cleanup: correct comment exiting NLA tweakmode
Comment was pasted from entering tweakmode.
2021-08-13 10:52:53 +02:00
0ae23636e7 Fix missing animation UI update in the Properties Editor
Animation indicators as well as decorators for properties were not
updating correctly in the following cases:
- NLA pushdown (this was reported in T87681)
- NLA enter/exit tweakmode
- Outliner unlinking/setting action

These actions all send a ND_NLA_ACTCHANGE notifier which the Properties
Editor was not listening to [which is now added].

part of T87681.

Maniphest Tasks: T87681

Differential Revision: https://developer.blender.org/D11040
2021-08-13 10:09:12 +02:00
5f6033e091 Keyframe: Reduce GPU context switches.
This change reduces the GPU context switches when drawing keyframes.
In the previous situation the keyframe blocks and keyframe keys were
drawn per channel. With this patch first all the keyframe blocks are
drawn for all channels and after that the keyframe keys are collected
for all channels and send to the GPU in a single draw call.
2021-08-13 09:37:38 +02:00
7b5acc8009 Cleanup: remove unused draw_gpencil_channel.
Code is integrated with draw_scene_channel since 2.80.
2021-08-13 08:34:10 +02:00
160d57d33c Docs: tooltip update missing from 3e775a4fc5 2021-08-13 16:01:45 +10:00
3e775a4fc5 PyAPI: remove the .py extension requirement for startup registration
This was left over from when these scripts were loaded as modules,
where their names needed to be compatible with Pythons module naming.

Version patch existing files so text with register enabled
without a `.py` extension wont start executing on startup.

Resolves T89532.
2021-08-13 15:51:08 +10:00
41e6509818 Mesh: replace saacos with acosf for normal calculation
The clamped version of acos isn't needed as degenerate (nan) coordinates
result in zeroed vectors which don't need clamping.
2021-08-13 15:39:39 +10:00
8fa05efe0a Docs: note that normalize_v# functions zero out input containing nan 2021-08-13 15:15:54 +10:00
92f4abc37f Cleanup: remove unused BKE_mesh_calc_normals_mapping functions
This supported calculating normals for MPoly array which was copied to
an MFace aligned array.

Remove the functions entirely since MFace use is being phased out and
these function isn't used anywhere.
2021-08-13 14:41:42 +10:00
b51a473e29 Cleanup: remove use of BKE_mesh_calc_normals_mapping_simple
Use BKE_mesh_calc_normals instead of
BKE_mesh_calc_normals_mapping_simple for curve modifier calculation.

This only made sense for derived-mesh which is no longer used.
2021-08-13 14:37:30 +10:00
ab344775c2 Cleanup: code-comments
Use capitalization, remove unnecessary ellipsis.
2021-08-13 13:55:25 +10:00
ed38d0c25d Cleanup: split BKE_mesh_calc_normals_poly function in two
Remove the 'only_face_normals' argument.

- BKE_mesh_calc_normals_poly for polygon normals.
- BKE_mesh_calc_normals_poly_and_vertex for poly and vertex normals.

Order arguments logically:

- Pair array and length arguments.
- Position normal array arguments (to be filled) last.
2021-08-13 13:33:03 +10:00
399b6ec76c Mesh: optimize normal calculation
Optimize mesh normal calculation.

- Remove the intermediate `lnors_weighted` array, accumulate directly
  into the normal array using a spin-lock for thread safety.
- Remove single threaded iteration over loops
  (normal calculation is now fully multi-threaded).
- Remove stack array (alloca) for pre-calculating edge-directions.

Summary of Performance Characteristics:

- The largest gains are for single high poly meshes, with isolated
  normal-calculation benchmarks of meshes over ~1.5 million showing
  2x+ speedup, ~25 million polygons are ~2.85x faster.

- Single lower poly meshes (250k polys) can be ~2x slower.

  Since these meshes aren't normally a bottleneck,
  and this problem isn't noticeable on large scenes,
  we considered the performance trade-off reasonable.

- The performance difference reduces with larger scenes,
  tests with production files from "Sprite Fight" showing
  the same or slightly better overall performance.

NOTE: tested on a AMD Ryzen TR 3970X 32-Core.

For more details & benchmarking scripts, see the patch description.

Reviewed By: mont29

Ref D11993
2021-08-13 10:21:30 +10:00
1275ce61b1 Cleanup: Remove unused includes
I noticed this file was recompiling when adding a node.
2021-08-12 14:12:14 -05:00
e0fd5fef12 Geometry Nodes: tag normals dirty after join
Under some circumstances the normals were not tagged dirty
even though they are.
2021-08-12 17:36:53 +02:00
f801d40daf Fix T89241: 3D Text "Scale to Fit" wraps onto the second line
Disable wrapping when "scale to fit" is used, assert the error is
small so an invalid scale-to-fit value wont go by unnoticed.
2021-08-13 01:07:30 +10:00
3930b8c69e Fix NLA action cannot be unlinked in certain cases
The poll for unlinking calls `nla_panel_context` without providing an
adt pointer, and there is a check for this pointer in
`nla_panel_context` leading to never returning true if it is not
provided. (this is fine if there are tracks already, poll would succeed
in this case, `nla_panel_context` goes a different code path then)

Same call to `nla_panel_context` is also done in the beginning of the
corresponding unlink exec function (but this time providing the pointer
because it is used later), so it makes sense to do the same thing in the
poll function. Equal check is also done in the panel poll function, so
now these are all in sync.

Part of T87681.

Maniphest Tasks: T87681

Differential Revision: https://developer.blender.org/D11041
2021-08-12 16:46:28 +02:00
333c3c92ab Fix T89805: NLA crash without active track
Was reported for a file which does not have an active track set in
AnimData even though it was in strip twek mode (but this was accessed in
is_nlatrack_evaluatable()).

Root cause for this is not totally clear, but I assume the situation is
described as part T87681 (and is fixed in D11052).

This patch here just prevents the crash for files that are already in the
borked state.

Reviewers: sybren

Maniphest Tasks: T89805

Differential Revision: https://developer.blender.org/D12085
2021-08-12 16:41:49 +02:00
dc8844f8ef Fix T88498: 'Clear Parent' does not clear parent_bone
Clearing the parent from the UI using the X (or from python) clears the
`parsubstr` and set `partype` back to `PAROBJECT`.

Using the Clear Parent operator would leave the `parsubstr` (and thus
`parent_bone`) untouched even though this operator claims to "clear
parenting relationship completely" (it also removes parent deform
modifiers for example).

So now, also clear `parsubstr` and set back to `PAROBJECT` [which is
default].

Maniphest Tasks: T88498

Differential Revision: https://developer.blender.org/D11503
2021-08-12 16:33:20 +02:00
Henrik Dick
d6891d9bee Add Extras Dropdown Menu to Constraints
Add Apply Constraint, Duplicate Constraint, and Copy To Selected
operators, and include them in a menu similar to the menu for modifiers.
The shortcuts in the extras menu are also matched to modifiers.

All the here added operators are intended to work exactly like the
analogous ones for modifiers. That means the apply operator should apply
a constraint as if it was first in the list, just like modifiers do. I
have added the same warning message as for modifiers when that happens.

The decision to use this approach of appling the constraint as if it was
first, was made for consistency with modifiers. People are already used
to how it works there. Is also provides more intricate control over the
applied transforms, then just applying all constraints up to that one.
Apply all constraints is already kinda implemented in Bake Animation.

Reviewed By: HooglyBoogly, sybren, #user_interface

Differential Revision: https://developer.blender.org/D10914
2021-08-12 14:24:27 +02:00
215734bc52 Fix T88386: Continuous Grab occasionally jumping on Arm64 MacOS
During the processing of a continuous drag event, other mouse move
events may be in the queue waiting to be processed.

But when a mouse wrapping happens, these waiting mouse move events
become out of date as they report a mouse position prior to wrapping.

The current code ignores these events by comparing their `timestamp` to
the time recorded in the last mouse wrapping.

The bug happens because the computed value in
`mach_absolute_time() * 1e-9` for some reason is incompatible with the
value of `[event timestamp]`.

Since macOS 10.6, we have a new way to get the amount of time the
system has been awake. `[[NSProcessInfo processInfo] systemUptime]`.

Using this updated method fixed the problem.

Differential Revision: https://developer.blender.org/D12202
2021-08-12 08:52:50 -03:00
6293cf6131 Fix T90630: Crash loading certain user preferences
Clearing the window was done in wm_file_read_post which was deferred.

This was needed as it left the context in an invalid state
where the window was set but the screen wasn't.

Crashing when setting up keymaps that attempted to access the
scene from the window in the property update function.

Regression in 497bc4d199
2021-08-12 20:43:16 +10:00
ad2fb92e9c Cleanup: remove redundant variable 2021-08-12 17:42:04 +10:00
04ef718226 RNA: include base types in RNA_struct_type_find_property search
Add RNA_struct_type_find_property_no_base for use in the rare situations
when this isn't desired.

Resolves T90617, where sequence strip sub-types weren't detecting
properties that exist in the base "Sequence" types.
2021-08-12 17:14:15 +10:00
806bf3f452 datadoc: add newlines to generated source files 2021-08-12 16:23:08 +10:00
83603ba26a Cleanup: comments/disabled code
- Remove old comment for editors with weak syntax highlighting.
- Remove disabled code to initialize Blender with a file path.
- Remove file name references to function names since these
  were outdated, modern development environments can look up this info.
2021-08-12 16:15:01 +10:00
497bc4d199 Fix T89046: Startup file with Python drivers crashes on load
Resolve order of initialization error reading startup file,
support postponing running wm_file_read_post until Blender
has been initialized.

Deferring updates allows duplicate initialization
to be removed from WM_init.

Reviewed By: mont29

Ref D12184
2021-08-12 14:59:08 +10:00
216414c65a Cleanup: use parameters struct for wm_homefile_read
Also add wm_homefile_read_ex which is only needed for the first
execution at startup.
2021-08-12 14:38:58 +10:00
c741558509 Cleanup: spelling in comments 2021-08-12 14:34:43 +10:00
1ef275963d Cleanup: use C++ style comments for disabled code 2021-08-12 14:34:41 +10:00
4f61843a7e Cleanup: remove *.orig file from 6a9d7139f7 2021-08-12 14:34:39 +10:00
45d100208e Makesdna: Fix detecting 32 bit padding issues.
Makesdna fails to detect issues in 32 bit code that can
only be resolved by adding a padding pointer.

We never noticed since we ourselves no longer build for
32 bit, but debian's 32 bit builds got bitten by this

A rather extensive explanation on why this is alignment
requirement is there can be found in this comment:

https://developer.blender.org/D9389#233034

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

Reviewed by: sergey, campbellbarton
2021-08-11 19:20:51 -06:00
48c8f9fc9a Fix: DNA struct alignment on 32 bit
Some of the dna structs were not properly
aligned for 32 bit builds causing issues
for some of the 32 platforms Debian builds
for.

Reviewed By: sergey, brecht
Differential Revision: https://developer.blender.org/D9389
2021-08-11 16:57:56 -06:00
cd1bb63159 BLF: Do Not Cache Unused Rendered Glyphs
The loading of a font size or style renders bitmaps of the characters
0-255 and stores them in a cache. But glyphs 128-255 in this cache are
not accessible. What used to be ansi high-bit characters are now multi-
byte UTF-8 sequences.

Therefore this patch reduces the glyph_ascii_table size to 128 and
only caches characters 32-127, the visible portion of ASCII, which
greatly reduces the time to load a font.

See D12189 for more details.

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

Reviewed by Campbell Barton
2021-08-11 13:55:58 -07:00
Jeroen Bakker
bb487bc2bc Fix T89984: Improve Icon previews reflective and transmissive materials.
Before this commit rendering material icons the floor will is hidden.
This reduces the readability of reflective/refractive materials.

check patch for additional screenshots and notes.

This patch will switch the floor material that uses ray visibility tricks to render a floor for reflective rays.

Eevee uses screen space reflections that makes this a different problem. There is nothing else drawn in
the scene in screen space so we need a different trick. Using math we convert a reflective ray to UV space
and generate a world that projects a checker pattern to infinity.

As now the floor is in the world it is being reflected via
a cubemap. As the film is transparent the background (including the floor isn't rendered)

In the future when Eevee supports vulkan raytracing we can re-evaluate and perhaps remove this
approximation.

We tried lightprobes but that wasn't able to do the trick.
Using the compositor would lead to more memory usage (render layers and intermediate buffers) and slower performance.
Solution has been validated with Simon

Reviewed By: sybren, Severin

Differential Revision: https://developer.blender.org/D11988
2021-08-11 16:59:57 +02:00
e53afad241 Cleanup: moved keyframe drawing to a draw list.
In preparation to do threaded drawing preparation. There should not be any
functional changes.
2021-08-11 16:47:12 +02:00
c9a9d5332b PyAPI: GPU: Expose builtin shaders
Expose `3D_POLYLINE_SMOOTH_COLOR` and
`3D_POLYLINE_FLAT_COLOR` builtins.

Requested by addon developers.
2021-08-11 11:39:51 -03:00
Pedro A
e6bbbd965a Cycles: OSL metadata support for UI labels and checkboxes
To improve the presentation of nodes in the node editor. Recognize the
following metadata from the OSL specification:

* [[ string label = "UI Label" ]]
* [[ string widget = "checkBox" ]]
* [[ string widget = "boolean" ]]

Ref T89741

Differential Revision: https://developer.blender.org/D12074
2021-08-11 16:12:27 +02:00
6d24017529 Cleanup: use socket identifier instead of names in Cycles shader export
Will be required when we support setting different names and identifiers
for OSL.

Ref D12074
2021-08-11 16:12:27 +02:00
6a9d7139f7 Cleanup: ID management: remove unused old BKE_libblock_copy_for_localize function. 2021-08-11 14:49:56 +02:00
Michael Kowalski
bbcb60fb22 Fix T90519: USD Exporter Error
Fixes: `Error: metersPerUnit does not match retrieved type float`
2021-08-11 09:40:27 -03:00
62cb5c5c4a Enable Asset Browser by default for poses, rest stays experimental
Idea for 3.0 is to disable all functionality that isn't well polished
and focus on those parts first. Starting with poses.

* Adds a new experimental option "Extended Asset Browser", replacing
  "Asset Browser".
* Unlike the previous option, this isn't enabled by default anymore.
  This didn't work well in practice and caused plenty of confusion.
* "Mark as Asset" and "Clear Asset" are hidden if the option is
  disabled.
* Same for the category selection in the Asset Browser.
* Always show display the "Only Assets" option in the File Browser while
  browing inside .blend files. That way you can hide data-blocks that
  are not pose assets.
* The Asset Library setup UI in the Preferences is always visible now,
  it's needed for pose library access.

Addresses T90181, T90180 and T90300.

Differential Revision: https://developer.blender.org/D12120
2021-08-11 14:32:07 +02:00
48ba341d15 Cleanup: Keylist Drawing - Split up in multiple functions. 2021-08-11 13:34:11 +02:00
6aae140278 Cleanup: Minor comment update on LIB_TAG_NEW. 2021-08-11 11:23:31 +02:00
f3e26c847b PyAPI: report unreleased ID's with WITH_PYTHON_SAFETY enabled
This would have made T88033 more straightforward to track down.
2021-08-11 17:37:38 +10:00
cbc671947a Fix T88033: Python reference memory leaks for non main data-blocks
ID data-blocks that could be accessed from Python and weren't freed
using BKE_id_free_ex did not release the Python reference count.

Add BKE_libblock_free_data_py function to clear the Python reference
in this case.

Add asserts to ensure no Python reference is held in situations
when ID's are copied for internal use (not exposed through the RNA API),
to ensure these kinds of leaks don't go by unnoticed again.
2021-08-11 17:10:02 +10:00
18fbcaf7b9 Cleanup: rename BKE_collection_{free => free_data}
This function doesn't free the collection, only it's memory.
2021-08-11 16:09:23 +10:00
Henrik Dick
2f39f7f815 Modifier: use high quality normals for vertex offset
Using high quality normals for vertex offset when set
for higher precision offsets.

This was only used for calculating even-offset.

Reviewed By: campbellbarton

Ref D12176
2021-08-11 10:26:49 +10:00
d480f03952 Cleanup: clang-format 2021-08-11 10:11:12 +10:00
55615e2600 Cleanup: trailing space, remove BOM 2021-08-11 10:11:11 +10:00
fcd2d63b64 Fix 'GPU_matrix_unproject_3fv' not working with out-of-bounds points
To solve this, the unproject code was redone in order to simplify and optimize.
2021-08-10 18:06:52 -03:00
8652e69d8b Fix T90447: 3D view transform locks do not use driver colors
Caused by rB6942dd9f4900.
2021-08-10 12:33:47 -05:00
32c687b5ec Clean-up: Remove UTF8-BOM markers
Done at the request of Sergey.
2021-08-10 11:27:18 -06:00
946da86e02 Win32 IME: Replace Usage of Language IDs
This is a slight refactoring of the Win32 IME code to remove the use of
Language IDs, which is now strongly deprecated. Instead this uses the
new recommended Locale Names, ie ISO-639-1 2-letter abbreviated names
like "en" for English rather than ID 0x09.

See D12143 for more details.

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

Reviewed by Ray Molenkamp
2021-08-10 08:54:03 -07:00
6806459246 UI: hide Viewport Display Bounds for object types that dont have
bounding boxes

These are namely 'LIGHT', 'CAMERA', 'EMPTY', 'SPEAKER' and 'LIGHTPROBE'.

Note that Empties are included here despite the fact that they have
instancing capabilities ('Display As' can be 'Bounds' for example which
then displays all instanced geometry with boundingboxes -- this however
is not meant to work with the 'Bounds' checkbox and the display bounds
type, these are only affective for the object itself, not its instances)

Issue came up in T88443.

Maniphest Tasks: T88443

Differential Revision: https://developer.blender.org/D11344
2021-08-10 17:30:43 +02:00
b6538e1492 Fix T90572: "Render Region" is broken due to compositing
It was using viewer instead of render border. A copy-paste error.
2021-08-10 16:16:23 +02:00
eb03529ab9 Compositor: Full frame output nodes
Adds full frame implementation to "Composite", "File Output" and
"Split Viewer" nodes.
The other nodes in "Output" submenu are implemented separately.
No functional changes.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D12091
2021-08-10 16:16:23 +02:00
d481c6651d Compositor: Full frame color nodes
Adds full frame implementation to "Alpha Over",
"Hue Saturation Value", "Invert", "Tonemap" and "ZCombine" nodes.
The other nodes in "Color" submenu are implemented separately.
No functional changes.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D12092
2021-08-10 16:16:23 +02:00
8f6cc16490 Compositor: Full frame curve nodes
Adds full frame implementation to "RGB Curves",
"Vector Curves" and "Hue Correct" nodes.
No functional changes.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D12093
2021-08-10 16:16:23 +02:00
b81d88a8e2 Compositor: Fix memory leaks when initializing tiles multi-threaded
It was only affecting tiled fallback on full frame mode. If tiles from a
constant operation were multi-thread initialized, its buffer
was inflated multiple times.
2021-08-10 16:16:23 +02:00
1a9b9dd64d Compositor: Full frame input nodes
Adds full frame implementation to "Bokeh Image" node, "Track Position"
node, `SetVectorOperation` and `MovieClipAttribute`.
The other nodes in "Input" submenu are implemented separately.

`MovieClipAttribute` needs resolution to calculate its constant value, it can't be constant folded,
which requires it to be a `ConstantOperation`. Now `ConstantOperation` contemplate this case
and any operation that is always constant without depending on inputs should implement it.
If in the future an operation needs to get an input constant element during
`determineResolution` it must first determine its input resolution.

The nodes have no functional changes.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D12090
2021-08-10 16:16:22 +02:00
5deb3229a0 Compositor: Full frame Mask node
Adds full frame implementation to this node operations.
No functional changes.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D11751
2021-08-10 16:16:22 +02:00
079f35572b Compositor: Full frame Bilateral Blur node
Adds full frame implementation to this node operation.
No functional changes.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D11634
2021-08-10 16:16:22 +02:00
0116a567dd Compositor: Full frame Sun Beams node
Adds full frame implementation to this node operation.
No functional changes.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D11694
2021-08-10 16:16:22 +02:00
6c0c766bca UI: hide instancing options for empties which cannot be used
Empties can only instance a collection, instancing on "Vertices" or
"Faces" does not make sense for empties, make that clear in the UI.

ref D11348

Maniphest Tasks: T88443

Differential Revision: https://developer.blender.org/D11349
2021-08-10 16:05:01 +02:00
4599748962 UI: hide object instancing panel for object types that dont support instancing
Basically, only meshes, empties and pointclouds support direct
instancing atm., no need to have the panel for other types.

note: prior to rB2eca054e14b1, collection instancing was possible on all
types (but that was removed in said commit)

note2: for empties, rna_Object_instance_type_itemf should also be
tweaked so we dont get "Vertices" and "Faces" options, but that can be
done in a separate commit

Maniphest Tasks: T88443

Differential Revision: https://developer.blender.org/D11348
2021-08-10 16:04:45 +02:00
Himanshi Kalra
e38de11f05 Refactor: Custom data comparison in meshes
Added the comparison of non-generic attributes with generic
attributes in the same loop to avoid issues with different
order in layer->types of the two meshes.

Reviewed By: JacquesLucke

Differential Revision: https://developer.blender.org/D12149
2021-08-10 19:22:29 +05:30
9c0f11344e Fix T90564: Crash when linking 2 node inputs
Caused by {rB37570a73170e}.

Above commit wasnt taking into account that at this point the link could
still be NULL.

Maniphest Tasks: T90564

Differential Revision: https://developer.blender.org/D12180
2021-08-10 15:44:53 +02:00
05879f2c36 File/Asset Browser: Select/Activate File on Right Click for Context Menu
Right clicking would spawn the context menu under the cursor, but some
operators would actually act on the active asset/file which wasn't
the one clicked on.

When multiple files are selected and one of them is right-clicked on,
selection is not changed to allow operations on multiple files. E.g.
deletion.

This makes the File/Asset Browser match the Outliner (in behavior, not
implementation).

For the right-click selection keymap:
* The context menu still only spawns on W.
* Bonus: Right click now does something, it actually selects files!
  I could have done additional changes here to avoid this, but it seems
  like a good addition.

This is also a better alternative to rB5edfde58fe60, which didn't work
properly either. Using rename from the context menu would only work if
the clicked on file was also active...

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

Reviewed by: Campbell Barton
2021-08-10 13:04:49 +02:00
fe1740ae6a Cleanup: use give_object_under_cursor when dragging materials.
It used to invoke give_base_under_cursor, but only accessed the `object` from the base.
2021-08-10 12:07:13 +02:00
aab7540b7a Fix crash: mouse is over file space during startup.
When blender starts and the mouse is over a file/asset browser it
crashes. This is because blender wants to highlight a file, but the
layout isn't initialized yet.
2021-08-10 12:03:40 +02:00
895d3cd11e Fix T89253: template_list allows arbitrary data changes
Blender forbids property changes in .draw() methods. But they weren't
caught after a call to .template_list() with a custom list type.

Support nested calls that disallow writes.
2021-08-10 19:53:08 +10:00
182edd4c35 Fix T89284: Greasepencil top bar draw tool settings missing
Caused by {rBe3faef686d38}.

Error was getting the preview [which wasnt there yet]
These only appeared once the material tab in the Properties Editor was
used (since this ensured a valid preview icon).

Above commit changed behavior for RNA icon getter (this does not create
data anymore), so ensure the preview by hand here.

Maniphest Tasks: T89284

Differential Revision: https://developer.blender.org/D12178
2021-08-10 11:37:03 +02:00
76d52cbcb4 Cleanup: Comment COW/LOCALIZED ID tags.
This was really missing there (some COW tags behavior was also
documented in some code using them, like in `sound.c`, but not in their
definition).

Ref. T88555.
2021-08-10 10:07:10 +02:00
7c2c66cdb8 Fix T90268: Mesh.from_pydata error using numpy array for edges/faces
Technically not a bug but worth supporting.
2021-08-10 17:51:48 +10:00
61040a36aa PyDoc: fix for renamed context member
Missing change from 9cff9f9f5d.
2021-08-10 17:28:09 +10:00
128ca8c7f6 Fix T90551: Dopesheet displays keyframes differently.
Regression introduced by {rB73b047bcd431}. Missing a check when
converting the file to use LISTBASE_FOREACH.
2021-08-10 08:42:06 +02:00
692e926b18 Silensed compilation warning in gpu test case. 2021-08-10 07:57:41 +02:00
49ea8e4fea Edit Mesh: multi-object edit-mode support for knife project 2021-08-10 15:10:20 +10:00
b83ee724a4 Fix T90418: macOS codesign fails with dylib next to executable
Change the dylib folder relative to `Blender` executable to be
the same as before rB652fbc200500497a67bd11d18b786587ba34e3d9 and same
as bpy.so : `@loader_path/../Resources/${BLENDER_VERSION}/lib`
2021-08-10 10:30:55 +05:30
4ca19c7153 Fix T90493: Undo a knife-project operation crashes
The crash occurred calling because mesh_get_eval_final in edit-mode
freed all derived mesh data without tagging the object for updating.

However meshes in edit-mode weren't meant to be used as knife-project
source-data, adding support for multi object edit-mode  caused this.
2021-08-10 14:44:36 +10:00
3335f852a1 Cleanup: mixing enum/non-enum type warning in conditional expression 2021-08-10 12:04:17 +10:00
26fea4de63 Cleanup: unused function warning 2021-08-10 11:57:33 +10:00
d9930cddfd Fix invalid string comparison in cd692c6954 2021-08-10 11:47:09 +10:00
cb7b4064d6 VSE: Fix cache invalidation
Blend mode replace is done in preprocessing stage, but property update
function invalidated composite cache.
2021-08-10 01:26:49 +02:00
Wannes Malfait
cd692c6954 Geometry Nodes: Add labels for switch node texture sockets
This makes texture sockets have a label by default. This can be changed
by adding the SOCK_HIDE_LABEL flag to the socket. With this change the
switch node now shows the labels "True" and "False" like for the other
types of sockets.
2021-08-09 17:30:44 -05:00
3b87fd376a Cleanup: Remove unecessary RNA get and set functions 2021-08-09 15:25:05 -05:00
Rob Ranieri
8e3dea27ec Docs: Blend-File: Fix typo
Reviewed By: Blendify

Differential Revision: https://developer.blender.org/D12162
2021-08-09 15:36:42 -04:00
2d867426b1 UI: Clip Editor: Expose 2D Cursor Location to RNA and UI
To be consistent with the image editors and 3D viewport
the cursor location can be changed from the sidebar.
This was missing from the clip editor, but support has been added in this commit.
Previously, the only way to precisely set the cursor was
to call the set cursor operator then use the redo panel to adjust the value.
2021-08-09 15:33:06 -04:00
ce95a2b148 UI: Clip Editor: Move Annotation Panel to new View tab
To be consistent with all other editors the annotation
layers pannel should be placed in a "View Tab".
In my next commit, this tab will be expanded to include other options.
2021-08-09 15:33:06 -04:00
b04997cca4 Fix T90547: Add node errors when compiled without OpenVDB or Bullet
These were added in other places but were overlooked here.
2021-08-09 13:42:19 -05:00
fddd5eb692 UI: Image Editor: Fix missing 2D cursor in mask edit mode
The 2D cursor should be visible in both mask and uv edit modes.

This was likely and oversight when splitting the image editor
into the UV and Image editors
2021-08-09 11:53:28 -04:00
ff594715b8 Build: macOS library upgrade fixes
* Revert back to OpenMP 9.0.1 due to bug causing cloth physics test to fail.
* Skip flex build on macOS to avoid link error, only reason we build this is
  due to old flex version on Linux CentOS 7.
* Fix PNG cmake argument that expects lowercase on instead of ON.

 Ref T90507, T88438
2021-08-09 16:50:31 +02:00
71e2c366f7 Cleanup: Fix compiler warning 2021-08-09 15:28:12 +02:00
6fe00939b0 PyAPI: resolve build error with Python 3.10
Resolves T89931
2021-08-09 22:55:41 +10:00
6deb37474e Cleanup: spelling in comments 2021-08-09 22:55:38 +10:00
e2a411570e Cleanup/fixes in UI messages. 2021-08-09 14:42:47 +02:00
3886ab05b4 Cleanup: Spelling and typos in comment 2021-08-09 14:32:12 +02:00
73b047bcd4 Cleanup: Changed keyframe_keylist to CPP.
Just a straight-forward change. Not utilizing CPP features.
2021-08-09 13:00:30 +02:00
22ed1c7b61 Cleanup: filelist, pass FileListReadJob to job functions
Pass `FileListReadJob` to the `read_job_fn` callback, instead of exploding
the struct into its individual fields, passing those as parameters, and
marking a bunch of those as unused again.

No functional changes.
2021-08-09 12:37:23 +02:00
0e4a250279 Fix invalid helps and description of session UUID verification
A copy-paste error.
2021-08-09 12:09:02 +02:00
7ea577eef3 Fix depsgraph check for tag during evaluation
- Only do print when asked for tags debugging.
- Add missing newline to the message.
2021-08-09 12:09:02 +02:00
d6f162dfa9 Fix T90540: NoneType object error with entering grease pencil draw mode
The preview was not ready when the panel was displayed.

Just need to check if None.
2021-08-09 12:08:08 +02:00
0986992dbd Cleanup: document FileListReadJob::tmp_filelist
Add a comment to document what `FileListReadJob::tmp_filelist` is for,
and how it's freed.

No functional changes.
2021-08-09 11:32:16 +02:00
909e0819ae Fix T90532: Crash editing meshes with auto-smooth
Caused by fix for T90256 and a misunderstanding in D11928.

Don't skip tagging edges when the auto-smooth angle is 180 degrees
since this skips topology checks which are needed for properly
calculating edge loop normals.
2021-08-09 18:32:53 +10:00
52c349cfcd Fix T90511: Cycles preview does not update once preview is done
Caused by 4f64fa4f86.

Was a bad backport from the Cycles X branch: the fact that CPU and GPU
has different reset code paths was not taken into account.
2021-08-09 10:28:54 +02:00
b417fb9251 Cleanup: return True/False from gpencil toolbar function
This was returning None/False which could cause problems in the future.
2021-08-09 15:05:04 +10:00
64d750fb73 Cleanup: indentation 2021-08-09 15:03:47 +10:00
d3a699925d Cleanup: use 'cls' for class methods first argument 2021-08-09 15:03:32 +10:00
eb165f574b Cleanup: remove redundant imports
The module was importing it's own functions.
2021-08-09 15:02:31 +10:00
Yuki Hashimoto
8830cfe541 Fix text object inserting multiple characters with a selection
`bpy.ops.font.text_insert(text="multiple characters")` wasn't working.

When the text is selected does not correctly insert multiple characters.

- When the text was selected from left to right,
  the cursor only move one position next to the selected text.
- When the text is selected from right to left,
  a part of the selected text remain.

Ref D12161
2021-08-09 14:31:57 +10:00
ff9bc901f4 Cleanup: grease pencil app-template versioning
- Remove check for screens being None as this would raise an error.
- Replace loop over `area.spaces` with `area.spaces.active`.
- Loop over grease pencil data directly instead of accessing
  through the scenes objects.
- Split versioning into functions.
- Use `update_factory_startup_*` prefix for function names
  as this isn't versioning existing files.
2021-08-09 12:45:06 +10:00
3ea6cf7d41 Cleanup: avoid using context in versioning code
Also extract versioning into a function that makes it's purpose clear.
2021-08-09 12:01:11 +10:00
4c26bb0232 UI: Show Mask Display Options Conistently
This commit makes the display options for mask only show in the header for the clip and image editors.
Prior to this change they would display in the header for the clip editor and in the sidebar for the image editors.
2021-08-08 16:09:23 -04:00
Aaron Carlisle
0be26f563e UI: Sequencer: Fix placement of display options in sequencer & preview mode
This commit does two things, first it removes the proportional editing tool settings.
This is not accessible code and is has not been used since the grease pencil/annotations changes in 2.8.

Second, this patch reorders the if statements so that the display options are always shown on the rightside.

Reviewed By: antoniov

Differential Revision: https://developer.blender.org/D12163
2021-08-08 13:30:52 -04:00
76e24609fd Cleanup: Remove stale/dead code
This seems to be really old code from 2.4 or earlier.
I was unable to find when it was removed gitk and git blame both couldnt find anything.
However, it is safe to say that this code is long gone.
2021-08-08 13:29:29 -04:00
3f1873111e Cleanup: Fix comment typo 2021-08-08 15:11:50 +02:00
b541b5f875 GPencil: Fix memory leak in previous commit 2021-08-08 15:09:34 +02:00
a7aeec2655 GPencil: New Select Random operator
Select strokes or points randomly (similar to meshes).

Reviewed By: pepeland

Differential Revision: https://developer.blender.org/D12157
2021-08-08 14:56:33 +02:00
a7bb537a61 Cleanup: unnecessary double pointers in XR module
No functional changes.
2021-08-07 21:30:15 +09:00
nutti
b33b70ed07 PyDoc: Fix poll_message_set API documentation to consistent with Python style
Fix poll_message_set API documentation to consistent with Python style

Reviewed By: Blendify

Differential Revision: https://developer.blender.org/D12150
2021-08-06 20:18:31 -04:00
d245782b80 Windows: Add support to compile python api docs from make file
This adds support to compile the html python api docs from the command line by running `make doc_py` matching support between windows and unix.

This patch also makes it so the compiler is not needed if you set the `blender_bin` variable, this affects icon generation as well.

In the future, I want to move away from generating the build output in the build directory but that can come in a later change.

Reviewed By: LazyDodo

Differential Revision: https://developer.blender.org/D12144
2021-08-06 13:55:14 -04:00
3fab16fe8e Fix T90477: Cursor vertex snapping not working in UV editor
`t->obedit_type` is read to indicate if we are in uv edit mode.

Also fixes a crash introduced in {rBdd14ea18190ff27082009f73a556569a43377a71}.
2021-08-06 11:44:26 -03:00
4f64fa4f86 Cycles: Fix for possible viewport dead-lock
This is a backport of recent development in the Cycles X branch.

Fixes possible dead-lock in viewport rendering when exiting at an
exact bad moment (couldn't reproduce in master branch, but in the
cycles-x branch it was happening every now and then).

Differential Revision: https://developer.blender.org/D12154
2021-08-06 16:26:51 +02:00
69c9363e39 Cleanup: Use conventional naming for private Session members
Makes it consistent with the guidelines and the Cycles X branch, and
allows to backport fix for the viewport update from the branch. Will
cause a merge conflict, which should be simple accept-ours in the
branch.
2021-08-06 15:56:00 +02:00
335379d8fc Cleanup: Add missing newline at end of file 2021-08-06 15:32:28 +02:00
3fbe6f513d Move NanoSVG lib to extern
The library has some modifications and it has been included in a diff.

Reviewed By: campbellbarton

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

(Some minor changes done in the patch)
2021-08-06 15:29:54 +02:00
9cff9f9f5d Cleanup: rename FileList::asset_libraryasset_library_ref
In the `FileList` struct, rename the `AssetLibraryReference
*asset_library` field to `asset_library_ref` -- it's a description of
which asset library is used, and not the asset library itself.

This is to make space for a future `AssetLibrary *asset_library` field,
which will point to an actual asset library struct/class.

No functional changes.

Reviewed by: Severin

Differential Revision: https://developer.blender.org/D12151
2021-08-06 15:20:39 +02:00
2796ee7da0 Fix error setting the ID name in disabled alembic nurbs importe
This corrects code that's currently disabled, see `USE_NURBS` define.

The name passed to `BKE_curve_add` was overwritten,
bypassing uniqueness and utf8 encoding checks.

Longer names would cause a buffer overrun as the length of the source
data was passed to `BLI_strncpy` instead of the destination.

Reviewed By: sybren

Ref D12125
2021-08-06 23:01:57 +10:00
01c1b1e82e Fix shortcut for Asset Details not showing in Asset Browser pulldown
The shortcut wouldn't show up in the Asset Browser's "View" pulldown for
the "Asset Details" item. It's the "N" key to toggle the right sidebar.
2021-08-06 14:39:09 +02:00
f4adb35f28 Fix T90476: intermittent wrong generated texture coordinates with modifiers
This caused Cycles texture_space_mesh_modifier and panorama_dicing tests to
randomly fail.

The issue was introduced with D11377, due to a missing dependency. Now ensure
we first copy the texture space parameters, and only then use or recompute then.

In general it seems like this dependency should have already been there, since
parameter evaluation includes animation and drivers, and geometry evaluation
may depend on that (even if you would not typically animate e.g. an autosmooth
angle).

Thanks Campbell for tracking this one down.
2021-08-06 13:59:25 +02:00
b0df8f53ba Cleanup: rna_xr.c
- Rename functions to use RNA identifiers
- Use SET_FLAG_FROM_TEST macro
- Specify max string length for relevant function params
2021-08-06 17:56:06 +09:00
4c675bc356 Fix missing function param definition in rna_xr.c
Was accidentally left out in rBe844e9e8f3bb.
2021-08-06 17:55:32 +09:00
151eed752b Fix invalid XR action map indices after alloc
Although the relevant structs (wmXrRuntime/XrActionMap/
XrActionMapItem) are zero-allocated, the selected and active action
map indices need to be initialized to -1 to prevent potential
out-of-bounds list access.
2021-08-06 17:55:00 +09:00
d98791a106 Cleanup: clang tidy
`bugprone-signed-char-misuse`
2021-08-06 10:20:24 +02:00
6188c29603 Cleanup: use const result in ED_keyframes_find_* functions. 2021-08-06 09:54:56 +02:00
1ab75c1d49 Cleanup: use range2f in ED_keylist_find_any_between. 2021-08-06 09:46:36 +02:00
bb8ce95b5e Cleanup: const pass keyframes_keylist. 2021-08-06 09:10:28 +02:00
bc97d78329 Cleanup: use MEM_SAFE_FREE macro 2021-08-06 14:24:16 +10:00
99738fbfdc Fix memory leak from rB263fa406cd2b 2021-08-05 21:10:54 -05:00
1f8485ae82 Geometry Nodes: Select by Handle Type Node
Just like the "Select by Material" node, this node outputs a
boolean attribute for control points that have a matching handle
type. By default left and right handles are considered, but it's
possible to only check one side with the toggle in the node.

Differential Revision: https://developer.blender.org/D12135
2021-08-05 18:42:20 -05:00
Mattias Fredriksson
bc0d55e724 Fix: Avoid floating point error in some mesh primitive nodes
Some mesh primitives created using geometry nodes use loops to create
vertices and accumulates positions/angles in FP variables. This allows
rounding errors to accumulate and can introduce significant errors.

To minimize changes from original implementation, variables allowing
errors to accumulate are replaced by: delta * index. Affected Mesh
Primitives nodes are Line, Grid, Cylinder, Circle, Cone, and UV-Sphere.

Differential Revision: https://developer.blender.org/D12136
2021-08-05 18:34:32 -05:00
263fa406cd Fix T90087: Assigning object data doesn't copy vertex groups
Assigning a mesh seems to do its own parameter copying, which
means we need to manual copy its vertex groups here, which was
just overlooked in rB3b6ee8cee708.

Differential Revision: https://developer.blender.org/D12110
2021-08-05 18:27:07 -05:00
Himanshi Kalra
92edf37997 Add custom data comparison for generic attributes
Generic attributes CD_PROP_* comparison is added in customdata_compare
Checks for built-in as well as user created attributes.

Reviewed By: JacquesLucke

Differential Revision: https://developer.blender.org/D12137
2021-08-06 00:07:40 +05:30
Germano Cavalcante
89014b51f1 Xcode: support cmake options for grouping in folders
The Xcode IDE can also benefit from the options:
- WINDOWS_USE_VISUAL_STUDIO_SOURCE_FOLDERS
- WINDOWS_USE_VISUAL_STUDIO_PROJECT_FOLDERS

So add suport to these options and also renames them as they are no
longer limited to just Windows and Visual Studio.

Reviewed By: brecht, ankitm

Differential Revision: https://developer.blender.org/D12132
2021-08-05 15:31:41 -03:00
cf10eb54cc Action Constraint: add Split Channels Mix choices from Copy Transforms
Practice shows that when combining actions and direct animation
it is usually best to combine location, rotation and scale
separately, which is implemented by the Split Channels modes
recently introduced in D9469 for Copy Transforms. This completes
the same set of 6 choices for the Action Constraint.

The default for new constraints is changed to the newly
added Before Original (Split Channels) mode.

The original patch is motivated by Loic Pinsard, who created
an addon that does the equivalent of this feature by splitting
the action into two, separating location and rotation+scale.

Differential Revision: https://developer.blender.org/D7547
2021-08-05 21:21:29 +03:00
d01781129f Fix T90235: Smooth Brush not working with interior vertices with two adjacent edges
The exception to automatically pin vertices of grid corners also
has to take into account that the vertex is in a boundary.

Reviewed By: JacquesLucke

Maniphest Tasks: T90235

Differential Revision: https://developer.blender.org/D12044
2021-08-05 20:10:02 +02:00
4dd6c9ad45 Fix T90236: Sculpt automasking failing when the stroke does not start over the mesh
The active geometry element are usually updated by the cursor drawing
code (as they are needed for the cursor preview) and when an sculpt
operator starts. For brushes, this was not happening. This was making
brushes rely by default on the last cursor drawing update, which can
be incorrect if the mouse moved after starting the stroke without
hovering the active geometry.

Reviewed By: JacquesLucke

Maniphest Tasks: T90236

Differential Revision: https://developer.blender.org/D12045
2021-08-05 20:08:36 +02:00
b04a2a7be7 add utility 2021-06-13 14:42:22 +02:00
083671e8ac progress 2021-06-13 14:25:23 +02:00
78ea401e19 Merge branch 'master' into mf-procedure 2021-06-13 14:13:22 +02:00
f3ca987bce start constructing procedure from node tree 2021-06-11 13:39:38 +02:00
2245add9f8 Merge branch 'master' into mf-procedure 2021-06-11 12:59:12 +02:00
31004d7fac start with creating procedure for node tree 2021-05-31 10:51:34 +02:00
3d3f66ed41 fix merge conflicts 2021-05-29 12:14:48 +02:00
c9c0195da5 Merge branch 'master' into mf-procedure 2021-05-29 12:07:13 +02:00
70c0403858 fixes 2021-03-27 22:58:44 +01:00
8d4de82c7f initial network to procedure 2021-03-27 22:30:53 +01:00
22c51c2d51 cleanup 2021-03-27 21:22:28 +01:00
158bd7c6a0 cleanup 2021-03-27 21:18:48 +01:00
4a28d0b583 another check 2021-03-27 15:52:13 +01:00
0501e6e693 fix memory leak in test 2021-03-27 15:45:59 +01:00
8450ac09c1 comment containing things to check 2021-03-27 15:36:08 +01:00
1af00015e8 initial destruct support 2021-03-27 15:29:02 +01:00
b44c3a3125 count initializations 2021-03-27 15:12:36 +01:00
d729f1ca37 cleanup 2021-03-27 15:08:21 +01:00
0fc9f00c14 start extracting container 2021-03-27 14:53:39 +01:00
6c9b339af7 refactor variable store 2021-03-27 14:46:53 +01:00
b7a976af01 branch test 2021-03-27 14:07:23 +01:00
a689037917 initial branch instruction 2021-03-27 13:48:18 +01:00
313403c1f1 support mutable params 2021-03-27 13:33:42 +01:00
60409b8823 simplify 2021-03-27 13:19:46 +01:00
773dc2ec94 improve dot graph 2021-03-27 13:14:19 +01:00
2a98c5d06b initial execution 2021-03-27 13:06:50 +01:00
6d1b4ce3c6 simplify 2021-03-27 12:06:40 +01:00
0b2d961b70 move executor to separate file 2021-03-27 11:55:51 +01:00
d553b70470 Merge branch 'master' into mf-procedure 2021-03-27 11:52:12 +01:00
6954f2cdd7 dot export 2021-03-24 18:46:17 +01:00
8cc832110a more 2021-03-24 18:23:36 +01:00
7b8c54b5a1 more 2021-03-24 17:51:37 +01:00
e850d175b5 more 2021-03-24 17:42:18 +01:00
326f79d59b more 2021-03-24 17:39:22 +01:00
ec4954ece2 destructor 2021-03-24 17:34:14 +01:00
b30e782c82 more stuff 2021-03-24 17:30:53 +01:00
e34fe5d28e add destruct instruction 2021-03-24 16:49:52 +01:00
8581a062f1 Merge branch 'master' into mf-procedure 2021-03-24 16:47:48 +01:00
b43971e5e9 add executor class 2021-03-23 16:20:40 +01:00
855382170e initial mf procedure data structure 2021-03-23 16:18:23 +01:00
1304 changed files with 39291 additions and 20102 deletions

View File

@@ -612,12 +612,6 @@ 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)
mark_as_advanced(WINDOWS_USE_VISUAL_STUDIO_PROJECT_FOLDERS)
option(WINDOWS_USE_VISUAL_STUDIO_SOURCE_FOLDERS "Organize the source files in filters matching the source folders." ON)
mark_as_advanced(WINDOWS_USE_VISUAL_STUDIO_SOURCE_FOLDERS)
option(WINDOWS_PYTHON_DEBUG "Include the files needed for debugging python scripts with visual studio 2017+." OFF)
mark_as_advanced(WINDOWS_PYTHON_DEBUG)
@@ -635,6 +629,18 @@ if(WIN32)
endif()
if(WIN32 OR XCODE)
option(IDE_GROUP_SOURCES_IN_FOLDERS "Organize the source files in filters matching the source folders." ON)
mark_as_advanced(IDE_GROUP_SOURCES_IN_FOLDERS)
option(IDE_GROUP_PROJECTS_IN_FOLDERS "Organize the projects according to source folder structure." ON)
mark_as_advanced(IDE_GROUP_PROJECTS_IN_FOLDERS)
if (IDE_GROUP_PROJECTS_IN_FOLDERS)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
endif()
endif()
if(UNIX)
# See WITH_WINDOWS_SCCACHE for Windows.
option(WITH_COMPILER_CCACHE "Use ccache to improve rebuild times (Works with Ninja, Makefiles and Xcode)" OFF)
@@ -1592,6 +1598,9 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
# Using C++20 features while having C++17 as the project language isn't allowed by MSVC.
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_CXX20_DESIGNATOR -Wc++20-designator)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)

View File

@@ -84,7 +84,7 @@ include(cmake/openimageio.cmake)
include(cmake/tiff.cmake)
if(WIN32)
include(cmake/flexbison.cmake)
else()
elseif(UNIX AND NOT APPLE)
include(cmake/flex.cmake)
endif()
include(cmake/osl.cmake)

View File

@@ -29,13 +29,13 @@ elseif(APPLE)
if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "arm64")
set(ISPC_EXTRA_ARGS_APPLE
-DBISON_EXECUTABLE=/opt/homebrew/opt/bison/bin/bison
-DFLEX_EXECUTABLE=${LIBDIR}/flex/bin/flex
-DFLEX_EXECUTABLE=/opt/homebrew/opt/flex/bin/flex
-DARM_ENABLED=On
)
else()
set(ISPC_EXTRA_ARGS_APPLE
-DBISON_EXECUTABLE=/usr/local/opt/bison/bin/bison
-DFLEX_EXECUTABLE=${LIBDIR}/flex/bin/flex
-DFLEX_EXECUTABLE=/usr/local/opt/flex/bin/flex
-DARM_ENABLED=Off
)
endif()
@@ -84,7 +84,7 @@ if(WIN32)
external_ispc
external_flexbison
)
else()
elseif(UNIX AND NOT APPLE)
add_dependencies(
external_ispc
external_flex

View File

@@ -16,12 +16,18 @@
#
# ***** END GPL LICENSE BLOCK *****
if(APPLE)
set(OPENMP_PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/openmp/src/external_openmp < ${PATCH_DIR}/openmp.diff)
else()
set(OPENMP_PATCH_COMMAND)
endif()
ExternalProject_Add(external_openmp
URL file://${PACKAGE_DIR}/${OPENMP_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${OPENMP_HASH_TYPE}=${OPENMP_HASH}
PREFIX ${BUILD_DIR}/openmp
PATCH_COMMAND ${OPENMP_PATCH_COMMAND}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openmp ${DEFAULT_CMAKE_FLAGS}
INSTALL_COMMAND cd ${BUILD_DIR}/openmp/src/external_openmp-build && install_name_tool -id @rpath/libomp.dylib runtime/src/libomp.dylib && make install
INSTALL_DIR ${LIBDIR}/openmp

View File

@@ -96,7 +96,7 @@ if(WIN32)
external_osl
external_flexbison
)
else()
elseif(UNIX AND NOT APPLE)
add_dependencies(
external_osl
external_flex

View File

@@ -23,7 +23,7 @@ set(PNG_EXTRA_ARGS
)
if(BLENDER_PLATFORM_ARM)
set(PNG_EXTRA_ARGS ${PNG_EXTRA_ARGS} -DPNG_HARDWARE_OPTIMIZATIONS=ON -DPNG_ARM_NEON=ON -DCMAKE_SYSTEM_PROCESSOR="aarch64")
set(PNG_EXTRA_ARGS ${PNG_EXTRA_ARGS} -DPNG_HARDWARE_OPTIMIZATIONS=ON -DPNG_ARM_NEON=on -DCMAKE_SYSTEM_PROCESSOR="aarch64")
endif()
ExternalProject_Add(external_png

View File

@@ -158,10 +158,18 @@ set(LLVM_HASH 5a4fab4d7fc84aefffb118ac2c8a4fc0)
set(LLVM_HASH_TYPE MD5)
set(LLVM_FILE llvm-project-${LLVM_VERSION}.src.tar.xz)
set(OPENMP_URI https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/openmp-${LLVM_VERSION}.src.tar.xz)
set(OPENMP_HASH ac48ce3e4582ccb82f81ab59eb3fc9dc)
if(APPLE)
# Cloth physics test is crashing due to this bug:
# https://bugs.llvm.org/show_bug.cgi?id=50579
set(OPENMP_VERSION 9.0.1)
set(OPENMP_HASH 6eade16057edbdecb3c4eef9daa2bfcf)
else()
set(OPENMP_VERSION ${LLVM_VERSION})
set(OPENMP_HASH ac48ce3e4582ccb82f81ab59eb3fc9dc)
endif()
set(OPENMP_URI https://github.com/llvm/llvm-project/releases/download/llvmorg-${OPENMP_VERSION}/openmp-${OPENMP_VERSION}.src.tar.xz)
set(OPENMP_HASH_TYPE MD5)
set(OPENMP_FILE openmp-${LLVM_VERSION}.src.tar.xz)
set(OPENMP_FILE openmp-${OPENMP_VERSION}.src.tar.xz)
set(OPENIMAGEIO_VERSION 2.2.15.1)
set(OPENIMAGEIO_URI https://github.com/OpenImageIO/oiio/archive/Release-${OPENIMAGEIO_VERSION}.tar.gz)

View File

@@ -1019,7 +1019,7 @@ PRINT ""
PYTHON_SOURCE=( "https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz" )
_boost_version_nodots=`echo "$BOOST_VERSION" | sed -r 's/\./_/g'`
BOOST_SOURCE=( "https://dl.bintray.com/boostorg/release/$BOOST_VERSION/source/boost_$_boost_version_nodots.tar.bz2" )
BOOST_SOURCE=( "https://boostorg.jfrog.io/artifactory/main/release/$BOOST_VERSION/source/boost_$_boost_version_nodots.tar.bz2" )
BOOST_BUILD_MODULES="--with-system --with-filesystem --with-thread --with-regex --with-locale --with-date_time --with-wave --with-iostreams --with-python --with-program_options --with-serialization --with-atomic"
TBB_SOURCE=( "https://github.com/oneapi-src/oneTBB/archive/$TBB_VERSION$TBB_VERSION_UPDATE.tar.gz" )

View File

@@ -0,0 +1,23 @@
diff --git a/runtime/src/z_Linux_asm.S b/runtime/src/z_Linux_asm.S
index 0d8885e..42aa5ad 100644
--- a/runtime/src/z_Linux_asm.S
+++ b/runtime/src/z_Linux_asm.S
@@ -1540,10 +1540,12 @@ __kmp_unnamed_critical_addr:
.comm .gomp_critical_user_,32,8
.data
.align 8
- .global __kmp_unnamed_critical_addr
-__kmp_unnamed_critical_addr:
+ .global ___kmp_unnamed_critical_addr
+___kmp_unnamed_critical_addr:
.8byte .gomp_critical_user_
- .size __kmp_unnamed_critical_addr,8
+# if !(KMP_OS_DARWIN)
+ .size ___kmp_unnamed_critical_addr,8
+# endif
#endif /* KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 */
#if KMP_OS_LINUX

View File

@@ -0,0 +1,66 @@
# - Find Zstd library
# Find the native Zstd includes and library
# This module defines
# ZSTD_INCLUDE_DIRS, where to find zstd.h, Set when
# ZSTD_INCLUDE_DIR is found.
# ZSTD_LIBRARIES, libraries to link against to use Zstd.
# ZSTD_ROOT_DIR, The base directory to search for Zstd.
# This can also be an environment variable.
# ZSTD_FOUND, If false, do not try to use Zstd.
#
# also defined, but not for general use are
# ZSTD_LIBRARY, where to find the Zstd library.
#=============================================================================
# Copyright 2019 Blender Foundation.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# If ZSTD_ROOT_DIR was defined in the environment, use it.
IF(NOT ZSTD_ROOT_DIR AND NOT $ENV{ZSTD_ROOT_DIR} STREQUAL "")
SET(ZSTD_ROOT_DIR $ENV{ZSTD_ROOT_DIR})
ENDIF()
SET(_zstd_SEARCH_DIRS
${ZSTD_ROOT_DIR}
)
FIND_PATH(ZSTD_INCLUDE_DIR
NAMES
zstd.h
HINTS
${_zstd_SEARCH_DIRS}
PATH_SUFFIXES
include
)
FIND_LIBRARY(ZSTD_LIBRARY
NAMES
zstd
HINTS
${_zstd_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set ZSTD_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Zstd DEFAULT_MSG
ZSTD_LIBRARY ZSTD_INCLUDE_DIR)
IF(ZSTD_FOUND)
SET(ZSTD_LIBRARIES ${ZSTD_LIBRARY})
SET(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR})
ENDIF()
MARK_AS_ADVANCED(
ZSTD_INCLUDE_DIR
ZSTD_LIBRARY
)

View File

@@ -208,7 +208,7 @@ function(blender_source_group
)
# if enabled, use the sources directories as filters.
if(WINDOWS_USE_VISUAL_STUDIO_SOURCE_FOLDERS)
if(IDE_GROUP_SOURCES_IN_FOLDERS)
foreach(_SRC ${sources})
# remove ../'s
get_filename_component(_SRC_DIR ${_SRC} REALPATH)
@@ -240,8 +240,8 @@ function(blender_source_group
endforeach()
endif()
# if enabled, set the FOLDER property for visual studio projects
if(WINDOWS_USE_VISUAL_STUDIO_PROJECT_FOLDERS)
# if enabled, set the FOLDER property for the projects
if(IDE_GROUP_PROJECTS_IN_FOLDERS)
get_filename_component(FolderDir ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
string(REPLACE ${CMAKE_SOURCE_DIR} "" FolderDir ${FolderDir})
set_target_properties(${name} PROPERTIES FOLDER ${FolderDir})

View File

@@ -441,6 +441,9 @@ if(WITH_HARU)
endif()
endif()
set(ZSTD_ROOT_DIR ${LIBDIR}/zstd)
find_package(Zstd REQUIRED)
if(EXISTS ${LIBDIR})
without_system_libs_end()
endif()
@@ -500,17 +503,10 @@ endif()
# makesdna, tests, etc.), we add an rpath to the OpenMP library dir through
# CMAKE_BUILD_RPATH. This avoids having to make many copies of the dylib next to each binary.
#
# For the installed Blender executable, CMAKE_INSTALL_RPATH will be used
# to locate the dylibs at @executable_path, next to the Blender executable.
#
# For the installed Python module, CMAKE_INSTALL_RPATH is modified to find the
# dylib in an adjacent folder.
# For the installed Python module and installed Blender executable, CMAKE_INSTALL_RPATH
# is modified to find the dylib in an adjacent folder. Install step puts the libraries there.
set(CMAKE_SKIP_BUILD_RPATH FALSE)
list(APPEND CMAKE_BUILD_RPATH "${OpenMP_LIBRARY_DIR}")
set(CMAKE_SKIP_INSTALL_RPATH FALSE)
list(APPEND CMAKE_INSTALL_RPATH "@executable_path")
if(WITH_PYTHON_MODULE)
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/../Resources/${BLENDER_VERSION}/lib")
endif()
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/../Resources/${BLENDER_VERSION}/lib")

View File

@@ -99,6 +99,7 @@ endif()
find_package_wrapper(JPEG REQUIRED)
find_package_wrapper(PNG REQUIRED)
find_package_wrapper(ZLIB REQUIRED)
find_package_wrapper(Zstd REQUIRED)
find_package_wrapper(Freetype REQUIRED)
if(WITH_PYTHON)

View File

@@ -57,8 +57,6 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
endif()
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ${WINDOWS_USE_VISUAL_STUDIO_PROJECT_FOLDERS})
if(NOT WITH_PYTHON_MODULE)
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT blender)
endif()
@@ -153,8 +151,8 @@ if(MSVC_CLANG) # Clangs version of cl doesn't support all flags
string(APPEND CMAKE_CXX_FLAGS " ${CXX_WARN_FLAGS} /nologo /J /Gd /EHsc -Wno-unused-command-line-argument -Wno-microsoft-enum-forward-reference ")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /nologo /J /Gd -Wno-unused-command-line-argument -Wno-microsoft-enum-forward-reference")
else()
string(APPEND CMAKE_CXX_FLAGS " /nologo /J /Gd /MP /EHsc /bigobj")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /nologo /J /Gd /MP /bigobj")
string(APPEND CMAKE_CXX_FLAGS " /nologo /J /Gd /MP /EHsc /bigobj /Zc:inline")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /nologo /J /Gd /MP /bigobj /Zc:inline")
endif()
# X64 ASAN is available and usable on MSVC 16.9 preview 4 and up)
@@ -875,3 +873,6 @@ if(WITH_HARU)
set(WITH_HARU OFF)
endif()
endif()
set(ZSTD_INCLUDE_DIRS ${LIBDIR}/zstd/include)
set(ZSTD_LIBRARIES ${LIBDIR}/zstd/lib/zstd_static.lib)

View File

@@ -51,9 +51,9 @@ buildbot:
gcc:
version: '9.0.0'
cuda10:
version: '10.1.0'
version: '10.1.243'
cuda11:
version: '11.4.0'
version: '11.4.1'
optix:
version: '7.1.0'
cmake:

View File

@@ -31,6 +31,7 @@ def parse_arguments():
parser.add_argument("--no-submodules", action="store_true")
parser.add_argument("--use-tests", action="store_true")
parser.add_argument("--svn-command", default="svn")
parser.add_argument("--svn-branch", default=None)
parser.add_argument("--git-command", default="git")
parser.add_argument("--use-centos-libraries", action="store_true")
return parser.parse_args()
@@ -46,7 +47,7 @@ def svn_update(args, release_version):
svn_non_interactive = [args.svn_command, '--non-interactive']
lib_dirpath = os.path.join(get_blender_git_root(), '..', 'lib')
svn_url = make_utils.svn_libraries_base_url(release_version)
svn_url = make_utils.svn_libraries_base_url(release_version, args.svn_branch)
# Checkout precompiled libraries
if sys.platform == 'darwin':
@@ -170,26 +171,28 @@ def submodules_update(args, release_version, branch):
sys.stderr.write("git not found, can't update code\n")
sys.exit(1)
# Update submodules to latest master or appropriate release branch.
if not release_version:
branch = "master"
# Update submodules to appropriate given branch,
# falling back to master if none is given and/or found in a sub-repository.
branch_fallback = "master"
if not branch:
branch = branch_fallback
submodules = [
("release/scripts/addons", branch),
("release/scripts/addons_contrib", branch),
("release/datafiles/locale", branch),
("source/tools", branch),
("release/scripts/addons", branch, branch_fallback),
("release/scripts/addons_contrib", branch, branch_fallback),
("release/datafiles/locale", branch, branch_fallback),
("source/tools", branch, branch_fallback),
]
# Initialize submodules only if needed.
for submodule_path, submodule_branch in submodules:
for submodule_path, submodule_branch, submodule_branch_fallback in submodules:
if not os.path.exists(os.path.join(submodule_path, ".git")):
call([args.git_command, "submodule", "update", "--init", "--recursive"])
break
# Checkout appropriate branch and pull changes.
skip_msg = ""
for submodule_path, submodule_branch in submodules:
for submodule_path, submodule_branch, submodule_branch_fallback in submodules:
cwd = os.getcwd()
try:
os.chdir(submodule_path)
@@ -201,6 +204,11 @@ def submodules_update(args, release_version, branch):
call([args.git_command, "fetch", "origin"])
call([args.git_command, "checkout", submodule_branch])
call([args.git_command, "pull", "--rebase", "origin", submodule_branch])
# If we cannot find the specified branch for this submodule, fallback to default one (aka master).
if make_utils.git_branch(args.git_command) != submodule_branch:
call([args.git_command, "fetch", "origin"])
call([args.git_command, "checkout", submodule_branch_fallback])
call([args.git_command, "pull", "--rebase", "origin", submodule_branch_fallback])
finally:
os.chdir(cwd)

View File

@@ -70,9 +70,11 @@ def git_branch_release_version(branch, tag):
return release_version
def svn_libraries_base_url(release_version):
def svn_libraries_base_url(release_version, branch):
if release_version:
svn_branch = "tags/blender-" + release_version + "-release"
elif branch:
svn_branch = "branches/" + branch
else:
svn_branch = "trunk"
return "https://svn.blender.org/svnroot/bf-blender/" + svn_branch + "/lib/"

View File

@@ -0,0 +1,34 @@
set SOURCEDIR=%BLENDER_DIR%/doc/python_api/sphinx-in
set BUILDDIR=%BLENDER_DIR%/doc/python_api/sphinx-out
if "%BF_LANG%" == "" set BF_LANG=en
set SPHINXOPTS=-j auto -D language=%BF_LANG%
call "%~dp0\find_sphinx.cmd"
if EXIST "%SPHINX_BIN%" (
goto detect_sphinx_done
)
echo unable to locate sphinx-build, run "set sphinx_BIN=full_path_to_sphinx-build.exe"
exit /b 1
:detect_sphinx_done
call "%~dp0\find_blender.cmd"
if EXIST "%BLENDER_BIN%" (
goto detect_blender_done
)
echo unable to locate blender, run "set BLENDER_BIN=full_path_to_blender.exe"
exit /b 1
:detect_blender_done
%BLENDER_BIN% ^
--background -noaudio --factory-startup ^
--python %BLENDER_DIR%/doc/python_api/sphinx_doc_gen.py
"%SPHINX_BIN%" -b html %SPHINXOPTS% %O% %SOURCEDIR% %BUILDDIR%
:EOF

View File

@@ -0,0 +1,23 @@
REM First see if there is an environment variable set
if EXIST "%SPHINX_BIN%" (
goto detect_sphinx_done
)
REM Then see if inkscape is available in the path
for %%X in (sphinx-build.exe) do (set SPHINX_BIN=%%~$PATH:X)
if EXIST "%SPHINX_BIN%" (
goto detect_sphinx_done
)
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINX_BIN environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
REM If still not found clear the variable
set SPHINX_BIN=
:detect_sphinx_done

View File

@@ -1,4 +1,4 @@
if EXIST %PYTHON% (
if EXIST "%PYTHON%" (
goto detect_python_done
)

View File

@@ -113,6 +113,9 @@ if NOT "%1" == "" (
) else if "%1" == "icons_geom" (
set ICONS_GEOM=1
goto EOF
) else if "%1" == "doc_py" (
set DOC_PY=1
goto EOF
) else (
echo Command "%1" unknown, aborting!
goto ERR

View File

@@ -32,4 +32,5 @@ set FORMAT=
set TEST=
set BUILD_WITH_SCCACHE=
set ICONS=
set ICONS_GEOM=
set ICONS_GEOM=
set DOC_PY=

View File

@@ -31,6 +31,10 @@ echo - 2019 ^(build with visual studio 2019^)
echo - 2019pre ^(build with visual studio 2019 pre-release^)
echo - 2019b ^(build with visual studio 2019 Build Tools^)
echo.
echo Documentation Targets ^(Not associated with building^)
echo - doc_py ^(Generate sphinx python api docs^)
echo.
echo Experimental options
echo - with_opengl_tests ^(enable both the render and draw opengl test suites^)

View File

@@ -123,7 +123,7 @@ def Align(handle):
class BlendFile:
'''
Reads a blendfile and store the header, all the fileblocks, and catalogue
structs foound in the DNA fileblock
structs found in the DNA fileblock
- BlendFile.Header (BlendFileHeader instance)
- BlendFile.Blocks (list of BlendFileBlock instances)

View File

@@ -1,13 +1,13 @@
sphinx==3.5.4
sphinx==4.1.1
# Sphinx dependencies that are important
Jinja2==2.11.3
Pygments==2.9.0
docutils==0.16
Jinja2==3.0.1
Pygments==2.10.0
docutils==0.17.1
snowballstemmer==2.1.0
babel==2.9.1
requests==2.25.1
requests==2.26.0
# Only needed to match the theme used for the official documentation.
# Without this theme, the default theme will be used.
sphinx_rtd_theme==0.5.2
sphinx_rtd_theme==1.0.0rc1

View File

@@ -254,6 +254,8 @@ else:
"gpu.shader",
"gpu.state",
"gpu.texture",
"gpu.platform",
"gpu.capabilities",
"gpu_extras",
"idprop.types",
"mathutils",
@@ -1037,17 +1039,21 @@ context_type_map = {
# context_member: (RNA type, is_collection)
"active_annotation_layer": ("GPencilLayer", False),
"active_bone": ("EditBone", False),
"active_file": ("FileSelectEntry", False),
"active_gpencil_frame": ("GreasePencilLayer", True),
"active_gpencil_layer": ("GPencilLayer", True),
"active_node": ("Node", False),
"active_object": ("Object", False),
"active_operator": ("Operator", False),
"active_pose_bone": ("PoseBone", False),
"active_sequence_strip": ("Sequence", False),
"active_editable_fcurve": ("FCurve", False),
"active_nla_strip": ("NlaStrip", False),
"active_nla_track": ("NlaTrack", False),
"annotation_data": ("GreasePencil", False),
"annotation_data_owner": ("ID", False),
"armature": ("Armature", False),
"asset_library": ("AssetLibraryReference", False),
"asset_library_ref": ("AssetLibraryReference", False),
"bone": ("Bone", False),
"brush": ("Brush", False),
"camera": ("Camera", False),
@@ -1072,6 +1078,7 @@ context_type_map = {
"gpencil_data": ("GreasePencil", False),
"gpencil_data_owner": ("ID", False),
"hair": ("Hair", False),
"id": ("ID", False),
"image_paint_object": ("Object", False),
"lattice": ("Lattice", False),
"light": ("Light", False),
@@ -1100,6 +1107,7 @@ context_type_map = {
"selected_editable_keyframes": ("Keyframe", True),
"selected_editable_objects": ("Object", True),
"selected_editable_sequences": ("Sequence", True),
"selected_files": ("FileSelectEntry", True),
"selected_nla_strips": ("NlaStrip", True),
"selected_nodes": ("Node", True),
"selected_objects": ("Object", True),
@@ -1196,6 +1204,7 @@ def pycontext2sphinx(basepath):
"text_context_dir",
"clip_context_dir",
"sequencer_context_dir",
"file_context_dir",
)
unique = set()
@@ -1993,13 +2002,15 @@ def write_rst_importable_modules(basepath):
"blf": "Font Drawing",
"imbuf": "Image Buffer",
"imbuf.types": "Image Buffer Types",
"gpu": "GPU Shader Module",
"gpu": "GPU Module",
"gpu.types": "GPU Types",
"gpu.matrix": "GPU Matrix Utilities",
"gpu.select": "GPU Select Utilities",
"gpu.shader": "GPU Shader Utilities",
"gpu.state": "GPU State Utilities",
"gpu.texture": "GPU Texture Utilities",
"gpu.platform": "GPU Platform Utilities",
"gpu.capabilities": "GPU Capabilities Utilities",
"bmesh": "BMesh Module",
"bmesh.ops": "BMesh Operators",
"bmesh.types": "BMesh Types",

View File

@@ -86,6 +86,7 @@ AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
info.specs.channels = AUD_CHANNELS_INVALID;
info.specs.rate = AUD_RATE_INVALID;
info.length = 0.0f;
info.start_offset = 0.0f;
try
{
@@ -95,6 +96,7 @@ AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
{
info.specs = convSpecToC(reader->getSpecs());
info.length = reader->getLength() / (float) info.specs.rate;
info.start_offset = reader->getStartOffset();
}
}
catch(Exception&)
@@ -245,7 +247,7 @@ AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, int sampl
buffer[i * 3] = min;
buffer[i * 3 + 1] = max;
buffer[i * 3 + 2] = sqrt(power) / len;
buffer[i * 3 + 2] = sqrt(power / len); // RMS
if(overallmax < max)
overallmax = max;

View File

@@ -176,4 +176,5 @@ typedef struct
{
AUD_Specs specs;
float length;
double start_offset;
} AUD_SoundInfo;

View File

@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import sys
import os

View File

@@ -70,6 +70,12 @@ public:
*/
virtual int getPosition() const=0;
/**
* Returns the start offset the sound should have to line up with related sources.
* \return The required start offset in seconds.
*/
virtual double getStartOffset() const { return 0.0;}
/**
* Returns the specification of the reader.
* \return The Specs structure.

View File

@@ -67,4 +67,4 @@ public:
virtual void read(int& length, bool& eos, sample_t* buffer);
};
AUD_NAMESPACE_END
AUD_NAMESPACE_END

View File

@@ -68,7 +68,7 @@ int FFMPEGReader::decode(AVPacket& packet, Buffer& buffer)
for(int i = 0; i < m_frame->nb_samples; i++)
{
std::memcpy(((data_t*)buffer.getBuffer()) + buf_pos + ((m_codecCtx->channels * i) + channel) * single_size,
m_frame->data[channel] + i * single_size, single_size);
m_frame->data[channel] + i * single_size, single_size);
}
}
}
@@ -109,7 +109,7 @@ int FFMPEGReader::decode(AVPacket& packet, Buffer& buffer)
for(int i = 0; i < m_frame->nb_samples; i++)
{
std::memcpy(((data_t*)buffer.getBuffer()) + buf_pos + ((m_codecCtx->channels * i) + channel) * single_size,
m_frame->data[channel] + i * single_size, single_size);
m_frame->data[channel] + i * single_size, single_size);
}
}
}
@@ -126,7 +126,10 @@ int FFMPEGReader::decode(AVPacket& packet, Buffer& buffer)
void FFMPEGReader::init()
{
m_position = 0;
m_start_offset = 0.0f;
m_pkgbuf_left = 0;
m_st_time = 0;
m_duration = 0;
if(avformat_find_stream_info(m_formatCtx, nullptr) < 0)
AUD_THROW(FileException, "File couldn't be read, ffmpeg couldn't find the stream info.");
@@ -134,15 +137,41 @@ void FFMPEGReader::init()
// find audio stream and codec
m_stream = -1;
double dur_sec = 0;
for(unsigned int i = 0; i < m_formatCtx->nb_streams; i++)
{
#ifdef FFMPEG_OLD_CODE
if((m_formatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
if(m_formatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
#else
if((m_formatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
if(m_formatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
#endif
&& (m_stream < 0))
{
AVStream *audio_stream = m_formatCtx->streams[i];
double audio_timebase = av_q2d(audio_stream->time_base);
if (audio_stream->start_time != AV_NOPTS_VALUE)
{
m_st_time = audio_stream->start_time;
}
int64_t ctx_start_time = 0;
if (m_formatCtx->start_time != AV_NOPTS_VALUE) {
ctx_start_time = m_formatCtx->start_time;
}
m_start_offset = m_st_time * audio_timebase - (double)ctx_start_time / AV_TIME_BASE;
if(audio_stream->duration != AV_NOPTS_VALUE)
{
dur_sec = audio_stream->duration * audio_timebase;
}
else
{
/* If the audio starts after the stream start time, subract this from the total duration. */
dur_sec = (double)m_formatCtx->duration / AV_TIME_BASE - m_start_offset;
}
m_stream=i;
break;
}
@@ -213,6 +242,7 @@ void FFMPEGReader::init()
}
m_specs.rate = (SampleRate) m_codecCtx->sample_rate;
m_duration = lround(dur_sec * m_codecCtx->sample_rate);
}
FFMPEGReader::FFMPEGReader(std::string filename) :
@@ -338,21 +368,17 @@ void FFMPEGReader::seek(int position)
{
if(position >= 0)
{
uint64_t st_time = m_formatCtx->start_time;
uint64_t seek_pos = ((uint64_t)position) * ((uint64_t)AV_TIME_BASE) / ((uint64_t)m_specs.rate);
double pts_time_base =
av_q2d(m_formatCtx->streams[m_stream]->time_base);
if(st_time != AV_NOPTS_VALUE) {
seek_pos += st_time;
uint64_t seek_pts = (((uint64_t)position) / ((uint64_t)m_specs.rate)) / pts_time_base;
if(m_st_time != AV_NOPTS_VALUE) {
seek_pts += m_st_time;
}
double pts_time_base =
av_q2d(m_formatCtx->streams[m_stream]->time_base);
uint64_t pts_st_time =
((st_time != AV_NOPTS_VALUE) ? st_time : 0)
/ pts_time_base / (uint64_t) AV_TIME_BASE;
// a value < 0 tells us that seeking failed
if(av_seek_frame(m_formatCtx, -1, seek_pos,
if(av_seek_frame(m_formatCtx, m_stream, seek_pts,
AVSEEK_FLAG_BACKWARD | AVSEEK_FLAG_ANY) >= 0)
{
avcodec_flush_buffers(m_codecCtx);
@@ -374,7 +400,7 @@ void FFMPEGReader::seek(int position)
if(packet.pts != AV_NOPTS_VALUE)
{
// calculate real position, and read to frame!
m_position = (packet.pts - pts_st_time) * pts_time_base * m_specs.rate;
m_position = (packet.pts - m_st_time) * pts_time_base * m_specs.rate;
if(m_position < position)
{
@@ -405,8 +431,7 @@ void FFMPEGReader::seek(int position)
int FFMPEGReader::getLength() const
{
// return approximated remaning size
return (int)((m_formatCtx->duration * m_codecCtx->sample_rate)
/ AV_TIME_BASE)-m_position;
return m_duration - m_position;
}
int FFMPEGReader::getPosition() const
@@ -414,6 +439,11 @@ int FFMPEGReader::getPosition() const
return m_position;
}
double FFMPEGReader::getStartOffset() const
{
return m_start_offset;
}
Specs FFMPEGReader::getSpecs() const
{
return m_specs.specs;
@@ -450,11 +480,13 @@ void FFMPEGReader::read(int& length, bool& eos, sample_t* buffer)
// decode the package
pkgbuf_pos = decode(packet, m_pkgbuf);
// copy to output buffer
data_size = std::min(pkgbuf_pos, left * sample_size);
m_convert((data_t*) buf, (data_t*) m_pkgbuf.getBuffer(), data_size / AUD_FORMAT_SIZE(m_specs.format));
buf += data_size / AUD_FORMAT_SIZE(m_specs.format);
left -= data_size / sample_size;
if (packet.pts >= m_st_time) {
// copy to output buffer
data_size = std::min(pkgbuf_pos, left * sample_size);
m_convert((data_t*) buf, (data_t*) m_pkgbuf.getBuffer(), data_size / AUD_FORMAT_SIZE(m_specs.format));
buf += data_size / AUD_FORMAT_SIZE(m_specs.format);
left -= data_size / sample_size;
}
}
av_packet_unref(&packet);
}

View File

@@ -54,6 +54,22 @@ private:
*/
int m_position;
/**
* The start offset in seconds relative to the media container start time.
* IE how much the sound should be delayed to be kept in sync with the rest of the containter streams.
*/
double m_start_offset;
/**
* The start time pts of the stream. All packets before this timestamp shouldn't be played back (only decoded).
*/
int64_t m_st_time;
/**
* The duration of the audio stream in samples.
*/
int64_t m_duration;
/**
* The specification of the audio data.
*/
@@ -182,6 +198,7 @@ public:
virtual void seek(int position);
virtual int getLength() const;
virtual int getPosition() const;
virtual double getStartOffset() const;
virtual Specs getSpecs() const;
virtual void read(int& length, bool& eos, sample_t* buffer);
};

View File

@@ -32,17 +32,24 @@ void PulseAudioDevice::PulseAudio_state_callback(pa_context *context, void *data
device->m_state = AUD_pa_context_get_state(context);
}
void PulseAudioDevice::PulseAudio_request(pa_stream *stream, size_t num_bytes, void *data)
void PulseAudioDevice::PulseAudio_request(pa_stream *stream, size_t total_bytes, void *data)
{
PulseAudioDevice* device = (PulseAudioDevice*)data;
void* buffer;
AUD_pa_stream_begin_write(stream, &buffer, &num_bytes);
while(total_bytes > 0)
{
size_t num_bytes = total_bytes;
device->mix((data_t*)buffer, num_bytes / AUD_DEVICE_SAMPLE_SIZE(device->m_specs));
AUD_pa_stream_begin_write(stream, &buffer, &num_bytes);
AUD_pa_stream_write(stream, buffer, num_bytes, nullptr, 0, PA_SEEK_RELATIVE);
device->mix((data_t*)buffer, num_bytes / AUD_DEVICE_SAMPLE_SIZE(device->m_specs));
AUD_pa_stream_write(stream, buffer, num_bytes, nullptr, 0, PA_SEEK_RELATIVE);
total_bytes -= num_bytes;
}
}
void PulseAudioDevice::PulseAudio_underflow(pa_stream *stream, void *data)
@@ -96,7 +103,6 @@ void PulseAudioDevice::runMixingThread()
PulseAudioDevice::PulseAudioDevice(std::string name, DeviceSpecs specs, int buffersize) :
m_state(PA_CONTEXT_UNCONNECTED),
m_buffersize(buffersize),
m_underflows(0)
{
m_mainloop = AUD_pa_mainloop_new();
@@ -187,6 +193,9 @@ PulseAudioDevice::PulseAudioDevice(std::string name, DeviceSpecs specs, int buff
AUD_pa_stream_set_write_callback(m_stream, PulseAudio_request, this);
AUD_pa_stream_set_underflow_callback(m_stream, PulseAudio_underflow, this);
buffersize *= AUD_DEVICE_SAMPLE_SIZE(m_specs);
m_buffersize = buffersize;
pa_buffer_attr buffer_attr;
buffer_attr.fragsize = -1U;

View File

@@ -59,7 +59,7 @@ private:
* \param num_bytes The length in bytes to be supplied.
* \param data The PulseAudio device.
*/
AUD_LOCAL static void PulseAudio_request(pa_stream* stream, size_t num_bytes, void* data);
AUD_LOCAL static void PulseAudio_request(pa_stream* stream, size_t total_bytes, void* data);
/**
* Reports an underflow from the PulseAudio server.

View File

@@ -57,4 +57,4 @@ void VolumeReader::read(int& length, bool& eos, sample_t* buffer)
buffer[i] = buffer[i] * m_volumeStorage->getVolume();
}
AUD_NAMESPACE_END
AUD_NAMESPACE_END

View File

@@ -8,7 +8,7 @@
# YOUR INSTALLATION PATHS GO HERE:
MANTA_INSTALLATION=/Users/sebbas/Developer/Mantaflow/mantaflowDevelop
BLENDER_INSTALLATION=/Users/sebbas/Developer/Blender/fluid-mantaflow
BLENDER_INSTALLATION=/Users/sebbas/Developer/Blender
# Try to check out Mantaflow repository before building?
CLEAN_REPOSITORY=0

View File

@@ -28,11 +28,13 @@ extern PyTypeObject PbVec3Type;
extern PyTypeObject PbVec4Type;
struct PbVec3 {
PyObject_HEAD float data[3];
PyObject_HEAD
float data[3];
};
struct PbVec4 {
PyObject_HEAD float data[4];
PyObject_HEAD
float data[4];
};
PyObject *getPyNone()

View File

@@ -25,7 +25,8 @@ namespace Manta {
extern PyTypeObject PbVec3Type;
struct PbVec3 {
PyObject_HEAD float data[3];
PyObject_HEAD
float data[3];
};
static void PbVec3Dealloc(PbVec3 *self)
@@ -293,7 +294,8 @@ inline PyObject *castPy(PyTypeObject *p)
extern PyTypeObject PbVec4Type;
struct PbVec4 {
PyObject_HEAD float data[4];
PyObject_HEAD
float data[4];
};
static PyMethodDef PbVec4Methods[] = {

View File

@@ -76,7 +76,8 @@ struct ClassData {
};
struct PbObject {
PyObject_HEAD Manta::PbClass *instance;
PyObject_HEAD
Manta::PbClass *instance;
ClassData *classdef;
};

View File

@@ -874,6 +874,136 @@ static const Vec3i nb[6] = {Vec3i(1, 0, 0),
Vec3i(0, 0, 1),
Vec3i(0, 0, -1)};
struct knMarkSkipCells : public KernelBase {
knMarkSkipCells(Grid<Real> &phi, Grid<int> &tmp, bool inside)
: KernelBase(&phi, 1), phi(phi), tmp(tmp), inside(inside)
{
runMessage();
run();
}
inline void op(int i, int j, int k, Grid<Real> &phi, Grid<int> &tmp, bool inside) const
{
if (!inside && phi(i, j, k) < 0.) {
tmp(i, j, k) = 1;
}
if (inside && phi(i, j, k) > 0.) {
tmp(i, j, k) = 1;
}
}
inline Grid<Real> &getArg0()
{
return phi;
}
typedef Grid<Real> type0;
inline Grid<int> &getArg1()
{
return tmp;
}
typedef Grid<int> type1;
inline bool &getArg2()
{
return inside;
}
typedef bool type2;
void runMessage()
{
debMsg("Executing kernel knMarkSkipCells ", 3);
debMsg("Kernel range"
<< " x " << maxX << " y " << maxY << " z " << minZ << " - " << maxZ << " ",
4);
};
void operator()(const tbb::blocked_range<IndexInt> &__r) const
{
const int _maxX = maxX;
const int _maxY = maxY;
if (maxZ > 1) {
for (int k = __r.begin(); k != (int)__r.end(); k++)
for (int j = 1; j < _maxY; j++)
for (int i = 1; i < _maxX; i++)
op(i, j, k, phi, tmp, inside);
}
else {
const int k = 0;
for (int j = __r.begin(); j != (int)__r.end(); j++)
for (int i = 1; i < _maxX; i++)
op(i, j, k, phi, tmp, inside);
}
}
void run()
{
if (maxZ > 1)
tbb::parallel_for(tbb::blocked_range<IndexInt>(minZ, maxZ), *this);
else
tbb::parallel_for(tbb::blocked_range<IndexInt>(1, maxY), *this);
}
Grid<Real> &phi;
Grid<int> &tmp;
bool inside;
};
struct knSetFirstLayer : public KernelBase {
knSetFirstLayer(Grid<int> &tmp, int dim) : KernelBase(&tmp, 1), tmp(tmp), dim(dim)
{
runMessage();
run();
}
inline void op(int i, int j, int k, Grid<int> &tmp, int dim) const
{
Vec3i p(i, j, k);
if (tmp(p))
return;
for (int n = 0; n < 2 * dim; ++n) {
if (tmp(p + nb[n]) == 1) {
tmp(i, j, k) = 2;
break;
}
}
}
inline Grid<int> &getArg0()
{
return tmp;
}
typedef Grid<int> type0;
inline int &getArg1()
{
return dim;
}
typedef int type1;
void runMessage()
{
debMsg("Executing kernel knSetFirstLayer ", 3);
debMsg("Kernel range"
<< " x " << maxX << " y " << maxY << " z " << minZ << " - " << maxZ << " ",
4);
};
void operator()(const tbb::blocked_range<IndexInt> &__r) const
{
const int _maxX = maxX;
const int _maxY = maxY;
if (maxZ > 1) {
for (int k = __r.begin(); k != (int)__r.end(); k++)
for (int j = 1; j < _maxY; j++)
for (int i = 1; i < _maxX; i++)
op(i, j, k, tmp, dim);
}
else {
const int k = 0;
for (int j = __r.begin(); j != (int)__r.end(); j++)
for (int i = 1; i < _maxX; i++)
op(i, j, k, tmp, dim);
}
}
void run()
{
if (maxZ > 1)
tbb::parallel_for(tbb::blocked_range<IndexInt>(minZ, maxZ), *this);
else
tbb::parallel_for(tbb::blocked_range<IndexInt>(1, maxY), *this);
}
Grid<int> &tmp;
int dim;
};
template<class S> struct knExtrapolateLsSimple : public KernelBase {
knExtrapolateLsSimple(Grid<S> &val, int distance, Grid<int> &tmp, const int d, S direction)
: KernelBase(&val, 1), val(val), distance(distance), tmp(tmp), d(d), direction(direction)
@@ -1043,39 +1173,12 @@ void extrapolateLsSimple(Grid<Real> &phi, int distance = 4, bool inside = false)
tmp.clear();
const int dim = (phi.is3D() ? 3 : 2);
// by default, march outside
Real direction = 1.;
if (!inside) {
// mark all inside
FOR_IJK_BND(phi, 1)
{
if (phi(i, j, k) < 0.) {
tmp(i, j, k) = 1;
}
}
}
else {
direction = -1.;
FOR_IJK_BND(phi, 1)
{
if (phi(i, j, k) > 0.) {
tmp(i, j, k) = 1;
}
}
}
// by default, march outside (ie mark all inside to be skipped)
Real direction = (inside) ? -1. : 1.;
knMarkSkipCells(phi, tmp, inside);
// + first layer around
FOR_IJK_BND(phi, 1)
{
Vec3i p(i, j, k);
if (tmp(p))
continue;
for (int n = 0; n < 2 * dim; ++n) {
if (tmp(p + nb[n]) == 1) {
tmp(i, j, k) = 2;
n = 2 * dim;
}
}
}
knSetFirstLayer(tmp, dim);
// extrapolate for distance
for (int d = 2; d < 1 + distance; ++d) {
@@ -1126,37 +1229,12 @@ void extrapolateVec3Simple(Grid<Vec3> &vel, Grid<Real> &phi, int distance = 4, b
tmp.clear();
const int dim = (vel.is3D() ? 3 : 2);
// mark initial cells, by default, march outside
if (!inside) {
// mark all inside
FOR_IJK_BND(phi, 1)
{
if (phi(i, j, k) < 0.) {
tmp(i, j, k) = 1;
}
}
}
else {
FOR_IJK_BND(phi, 1)
{
if (phi(i, j, k) > 0.) {
tmp(i, j, k) = 1;
}
}
}
// mark initial cells, by default, march outside (ie mark all inside to be skipped)
Real direction = (inside) ? -1. : 1.;
knMarkSkipCells(phi, tmp, inside);
// + first layer next to initial cells
FOR_IJK_BND(vel, 1)
{
Vec3i p(i, j, k);
if (tmp(p))
continue;
for (int n = 0; n < 2 * dim; ++n) {
if (tmp(p + nb[n]) == 1) {
tmp(i, j, k) = 2;
n = 2 * dim;
}
}
}
knSetFirstLayer(tmp, dim);
for (int d = 2; d < 1 + distance; ++d) {
knExtrapolateLsSimple<Vec3>(vel, distance, tmp, d, Vec3(0.));

View File

@@ -1,3 +1,3 @@
#define MANTA_GIT_VERSION "commit 8fbebe02459b7f72575872c20961f7cb757db408"
#define MANTA_GIT_VERSION "commit d5d9a6c28daa8f21426d7a285f48639c0d8fd13f"

7
extern/nanosvg/README.blender vendored Normal file
View File

@@ -0,0 +1,7 @@
Project: NanoSVG
URL: https://github.com/memononen/nanosvg
License: zlib
Upstream version:
Local modifications: Added some functionality to manage grease pencil layers
Added a fix to SVG import arc and float errors (https://developer.blender.org/rB11dc674c78b49fc4e0b7c134c375b6c8b8eacbcc)

86
extern/nanosvg/patches/NanoSVG.diff vendored Normal file
View File

@@ -0,0 +1,86 @@
diff --git a/c:/tmp/nanosvg_original.h b/c:/tmp/nanosvg_modif.h
index 24a01a86d3d..eca0d07e79d 100644
--- a/c:/tmp/nanosvg_original.h
+++ b/c:/tmp/nanosvg_modif.h
@@ -24,7 +24,8 @@
*
* Bounding box calculation based on http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
*
- */
+ * This is a modified version for Blender used by importers.
+ **/
#ifndef NANOSVG_H
#define NANOSVG_H
@@ -148,6 +149,8 @@ extern "C" {
typedef struct NSVGshape
{
char id[64]; // Optional 'id' attr of the shape or its group
+ /* Blender: Parent ID used for layer creation. */
+ char id_parent[64];
NSVGpaint fill; // Fill paint
NSVGpaint stroke; // Stroke paint
float opacity; // Opacity of the shape.
@@ -370,6 +373,7 @@ int nsvg__parseXML(char* input,
/* Simple SVG parser. */
#define NSVG_MAX_ATTR 128
+#define NSVG_MAX_BREADCRUMB 5
enum NSVGgradientUnits
{
@@ -471,6 +475,10 @@ typedef struct NSVGparser
float dpi;
char pathFlag;
char defsFlag;
+ /** Blender breadcrumb for layers. */
+ char breadcrumb[NSVG_MAX_BREADCRUMB][64];
+ /** Blender number of elements in breadcrumb. */
+ int breadcrumb_len;
} NSVGparser;
static void nsvg__xformIdentity(float* t)
@@ -980,6 +988,14 @@ static void nsvg__addShape(NSVGparser* p)
memset(shape, 0, sizeof(NSVGshape));
memcpy(shape->id, attr->id, sizeof shape->id);
+ /* Copy parent id from breadcrumb. */
+ if (p->breadcrumb_len > 0) {
+ memcpy(shape->id_parent, p->breadcrumb[0], sizeof shape->id_parent);
+ }
+ else {
+ memcpy(shape->id_parent, attr->id, sizeof shape->id_parent);
+ }
+
scale = nsvg__getAverageScale(attr->xform);
shape->strokeWidth = attr->strokeWidth * scale;
shape->strokeDashOffset = attr->strokeDashOffset * scale;
@@ -2814,6 +2830,14 @@ static void nsvg__startElement(void* ud, const char* el, const char** attr)
if (strcmp(el, "g") == 0) {
nsvg__pushAttr(p);
nsvg__parseAttribs(p, attr);
+
+ /* Save the breadcrumb of groups. */
+ if (p->breadcrumb_len < NSVG_MAX_BREADCRUMB) {
+ NSVGattrib *attr_id = nsvg__getAttr(p);
+ memcpy(
+ p->breadcrumb[p->breadcrumb_len], attr_id->id, sizeof(p->breadcrumb[p->breadcrumb_len]));
+ p->breadcrumb_len++;
+ }
}
else if (strcmp(el, "path") == 0) {
if (p->pathFlag) // Do not allow nested paths.
@@ -2874,7 +2898,12 @@ static void nsvg__endElement(void* ud, const char* el)
NSVGparser* p = (NSVGparser*)ud;
if (strcmp(el, "g") == 0) {
- nsvg__popAttr(p);
+ /* Remove the breadcrumb level. */
+ if (p->breadcrumb_len > 0) {
+ p->breadcrumb[p->breadcrumb_len - 1][0] = '\0';
+ p->breadcrumb_len--;
+ }
+ nsvg__popAttr(p);
}
else if (strcmp(el, "path") == 0) {
p->pathFlag = 0;

View File

@@ -60,9 +60,108 @@
# define JE_FORCE_SYNC_COMPARE_AND_SWAP_8
#endif
/******************************************************************************/
/* 64-bit operations. */
#if (defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) || defined(JE_FORCE_SYNC_COMPARE_AND_SWAP_8))
/* Define the `ATOMIC_FORCE_USE_FALLBACK` to force lock-based fallback implementation to be used
* (even on platforms where there is native implementation available via compiler.
* Useful for development purposes. */
#undef ATOMIC_FORCE_USE_FALLBACK
/* -------------------------------------------------------------------- */
/** \name Spin-lock implementation
*
* Used to implement atomics on unsupported platforms.
* The spin implementation is shared for all platforms to make sure it compiles and tested.
* \{ */
typedef struct AtomicSpinLock {
volatile int lock;
/* Pad the structure size to a cache-line, to avoid unwanted sharing with other data. */
int pad[32 - sizeof(int)];
} __attribute__((aligned(32))) AtomicSpinLock;
ATOMIC_INLINE void atomic_spin_lock(volatile AtomicSpinLock *lock)
{
while (__sync_lock_test_and_set(&lock->lock, 1)) {
while (lock->lock) {
}
}
}
ATOMIC_INLINE void atomic_spin_unlock(volatile AtomicSpinLock *lock)
{
__sync_lock_release(&lock->lock);
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Common part of locking fallback implementation
* \{ */
/* Global lock, shared by all atomic operations implementations.
*
* Could be split into per-size locks, although added complexity and being more error-proone does
* not seem to worth it for a fall-back implementation. */
static _ATOMIC_MAYBE_UNUSED AtomicSpinLock _atomic_global_lock = {0};
#define ATOMIC_LOCKING_OP_AND_FETCH_DEFINE(_type, _op_name, _op) \
ATOMIC_INLINE _type##_t atomic_##_op_name##_and_fetch_##_type(_type##_t *p, _type##_t x) \
{ \
atomic_spin_lock(&_atomic_global_lock); \
const _type##_t original_value = *(p); \
const _type##_t new_value = original_value _op(x); \
*(p) = new_value; \
atomic_spin_unlock(&_atomic_global_lock); \
return new_value; \
}
#define ATOMIC_LOCKING_FETCH_AND_OP_DEFINE(_type, _op_name, _op) \
ATOMIC_INLINE _type##_t atomic_fetch_and_##_op_name##_##_type(_type##_t *p, _type##_t x) \
{ \
atomic_spin_lock(&_atomic_global_lock); \
const _type##_t original_value = *(p); \
*(p) = original_value _op(x); \
atomic_spin_unlock(&_atomic_global_lock); \
return original_value; \
}
#define ATOMIC_LOCKING_ADD_AND_FETCH_DEFINE(_type) \
ATOMIC_LOCKING_OP_AND_FETCH_DEFINE(_type, add, +)
#define ATOMIC_LOCKING_SUB_AND_FETCH_DEFINE(_type) \
ATOMIC_LOCKING_OP_AND_FETCH_DEFINE(_type, sub, -)
#define ATOMIC_LOCKING_FETCH_AND_ADD_DEFINE(_type) \
ATOMIC_LOCKING_FETCH_AND_OP_DEFINE(_type, add, +)
#define ATOMIC_LOCKING_FETCH_AND_SUB_DEFINE(_type) \
ATOMIC_LOCKING_FETCH_AND_OP_DEFINE(_type, sub, -)
#define ATOMIC_LOCKING_FETCH_AND_OR_DEFINE(_type) ATOMIC_LOCKING_FETCH_AND_OP_DEFINE(_type, or, |)
#define ATOMIC_LOCKING_FETCH_AND_AND_DEFINE(_type) \
ATOMIC_LOCKING_FETCH_AND_OP_DEFINE(_type, and, &)
#define ATOMIC_LOCKING_CAS_DEFINE(_type) \
ATOMIC_INLINE _type##_t atomic_cas_##_type(_type##_t *v, _type##_t old, _type##_t _new) \
{ \
atomic_spin_lock(&_atomic_global_lock); \
const _type##_t original_value = *v; \
if (*v == old) { \
*v = _new; \
} \
atomic_spin_unlock(&_atomic_global_lock); \
return original_value; \
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name 64-bit operations
* \{ */
#if !defined(ATOMIC_FORCE_USE_FALLBACK) && \
(defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) || defined(JE_FORCE_SYNC_COMPARE_AND_SWAP_8))
/* Unsigned */
ATOMIC_INLINE uint64_t atomic_add_and_fetch_uint64(uint64_t *p, uint64_t x)
{
@@ -115,7 +214,7 @@ ATOMIC_INLINE int64_t atomic_cas_int64(int64_t *v, int64_t old, int64_t _new)
return __sync_val_compare_and_swap(v, old, _new);
}
#elif (defined(__amd64__) || defined(__x86_64__))
#elif !defined(ATOMIC_FORCE_USE_FALLBACK) && (defined(__amd64__) || defined(__x86_64__))
/* Unsigned */
ATOMIC_INLINE uint64_t atomic_fetch_and_add_uint64(uint64_t *p, uint64_t x)
{
@@ -190,12 +289,36 @@ ATOMIC_INLINE int64_t atomic_cas_int64(int64_t *v, int64_t old, int64_t _new)
return ret;
}
#else
# error "Missing implementation for 64-bit atomic operations"
/* Unsigned */
ATOMIC_LOCKING_ADD_AND_FETCH_DEFINE(uint64)
ATOMIC_LOCKING_SUB_AND_FETCH_DEFINE(uint64)
ATOMIC_LOCKING_FETCH_AND_ADD_DEFINE(uint64)
ATOMIC_LOCKING_FETCH_AND_SUB_DEFINE(uint64)
ATOMIC_LOCKING_CAS_DEFINE(uint64)
/* Signed */
ATOMIC_LOCKING_ADD_AND_FETCH_DEFINE(int64)
ATOMIC_LOCKING_SUB_AND_FETCH_DEFINE(int64)
ATOMIC_LOCKING_FETCH_AND_ADD_DEFINE(int64)
ATOMIC_LOCKING_FETCH_AND_SUB_DEFINE(int64)
ATOMIC_LOCKING_CAS_DEFINE(int64)
#endif
/******************************************************************************/
/* 32-bit operations. */
#if (defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) || defined(JE_FORCE_SYNC_COMPARE_AND_SWAP_4))
/** \} */
/* -------------------------------------------------------------------- */
/** \name 32-bit operations
* \{ */
#if !defined(ATOMIC_FORCE_USE_FALLBACK) && \
(defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) || defined(JE_FORCE_SYNC_COMPARE_AND_SWAP_4))
/* Unsigned */
ATOMIC_INLINE uint32_t atomic_add_and_fetch_uint32(uint32_t *p, uint32_t x)
{
@@ -228,7 +351,8 @@ ATOMIC_INLINE int32_t atomic_cas_int32(int32_t *v, int32_t old, int32_t _new)
return __sync_val_compare_and_swap(v, old, _new);
}
#elif (defined(__i386__) || defined(__amd64__) || defined(__x86_64__))
#elif !defined(ATOMIC_FORCE_USE_FALLBACK) && \
(defined(__i386__) || defined(__amd64__) || defined(__x86_64__))
/* Unsigned */
ATOMIC_INLINE uint32_t atomic_add_and_fetch_uint32(uint32_t *p, uint32_t x)
{
@@ -286,10 +410,25 @@ ATOMIC_INLINE int32_t atomic_cas_int32(int32_t *v, int32_t old, int32_t _new)
}
#else
# error "Missing implementation for 32-bit atomic operations"
/* Unsigned */
ATOMIC_LOCKING_ADD_AND_FETCH_DEFINE(uint32)
ATOMIC_LOCKING_SUB_AND_FETCH_DEFINE(uint32)
ATOMIC_LOCKING_CAS_DEFINE(uint32)
/* Signed */
ATOMIC_LOCKING_ADD_AND_FETCH_DEFINE(int32)
ATOMIC_LOCKING_SUB_AND_FETCH_DEFINE(int32)
ATOMIC_LOCKING_CAS_DEFINE(int32)
#endif
#if (defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) || defined(JE_FORCE_SYNC_COMPARE_AND_SWAP_4))
#if !defined(ATOMIC_FORCE_USE_FALLBACK) && \
(defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) || defined(JE_FORCE_SYNC_COMPARE_AND_SWAP_4))
/* Unsigned */
ATOMIC_INLINE uint32_t atomic_fetch_and_add_uint32(uint32_t *p, uint32_t x)
{
@@ -323,12 +462,27 @@ ATOMIC_INLINE int32_t atomic_fetch_and_and_int32(int32_t *p, int32_t x)
}
#else
# error "Missing implementation for 32-bit atomic operations"
/* Unsigned */
ATOMIC_LOCKING_FETCH_AND_ADD_DEFINE(uint32)
ATOMIC_LOCKING_FETCH_AND_OR_DEFINE(uint32)
ATOMIC_LOCKING_FETCH_AND_AND_DEFINE(uint32)
/* Signed */
ATOMIC_LOCKING_FETCH_AND_ADD_DEFINE(int32)
ATOMIC_LOCKING_FETCH_AND_OR_DEFINE(int32)
ATOMIC_LOCKING_FETCH_AND_AND_DEFINE(int32)
#endif
/******************************************************************************/
/* 16-bit operations. */
#if (defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) || defined(JE_FORCE_SYNC_COMPARE_AND_SWAP_2))
/** \} */
/* -------------------------------------------------------------------- */
/** \name 16-bit operations
* \{ */
#if !defined(ATOMIC_FORCE_USE_FALLBACK) && \
(defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) || defined(JE_FORCE_SYNC_COMPARE_AND_SWAP_2))
/* Signed */
ATOMIC_INLINE int16_t atomic_fetch_and_and_int16(int16_t *p, int16_t b)
@@ -341,12 +495,21 @@ ATOMIC_INLINE int16_t atomic_fetch_and_or_int16(int16_t *p, int16_t b)
}
#else
# error "Missing implementation for 16-bit atomic operations"
ATOMIC_LOCKING_FETCH_AND_AND_DEFINE(int16)
ATOMIC_LOCKING_FETCH_AND_OR_DEFINE(int16)
#endif
/******************************************************************************/
/* 8-bit operations. */
#if (defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1) || defined(JE_FORCE_SYNC_COMPARE_AND_SWAP_1))
/** \} */
/* -------------------------------------------------------------------- */
/** \name 8-bit operations
* \{ */
#if !defined(ATOMIC_FORCE_USE_FALLBACK) && \
(defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1) || defined(JE_FORCE_SYNC_COMPARE_AND_SWAP_1))
/* Unsigned */
ATOMIC_INLINE uint8_t atomic_fetch_and_and_uint8(uint8_t *p, uint8_t b)
{
@@ -368,7 +531,27 @@ ATOMIC_INLINE int8_t atomic_fetch_and_or_int8(int8_t *p, int8_t b)
}
#else
# error "Missing implementation for 8-bit atomic operations"
/* Unsigned */
ATOMIC_LOCKING_FETCH_AND_AND_DEFINE(uint8)
ATOMIC_LOCKING_FETCH_AND_OR_DEFINE(uint8)
/* Signed */
ATOMIC_LOCKING_FETCH_AND_AND_DEFINE(int8)
ATOMIC_LOCKING_FETCH_AND_OR_DEFINE(int8)
#endif
/** \} */
#undef ATOMIC_LOCKING_OP_AND_FETCH_DEFINE
#undef ATOMIC_LOCKING_FETCH_AND_OP_DEFINE
#undef ATOMIC_LOCKING_ADD_AND_FETCH_DEFINE
#undef ATOMIC_LOCKING_SUB_AND_FETCH_DEFINE
#undef ATOMIC_LOCKING_FETCH_AND_ADD_DEFINE
#undef ATOMIC_LOCKING_FETCH_AND_SUB_DEFINE
#undef ATOMIC_LOCKING_FETCH_AND_OR_DEFINE
#undef ATOMIC_LOCKING_FETCH_AND_AND_DEFINE
#undef ATOMIC_LOCKING_CAS_DEFINE
#endif /* __ATOMIC_OPS_UNIX_H__ */

View File

@@ -64,9 +64,11 @@
#ifdef __GNUC__
# define _ATOMIC_LIKELY(x) __builtin_expect(!!(x), 1)
# define _ATOMIC_UNLIKELY(x) __builtin_expect(!!(x), 0)
# define _ATOMIC_MAYBE_UNUSED __attribute__((unused))
#else
# define _ATOMIC_LIKELY(x) (x)
# define _ATOMIC_UNLIKELY(x) (x)
# define _ATOMIC_MAYBE_UNUSED
#endif
#if defined(__SIZEOF_POINTER__)

View File

@@ -115,6 +115,16 @@ if(WITH_OPENVDB)
)
endif()
if(WITH_ALEMBIC)
add_definitions(-DWITH_ALEMBIC)
list(APPEND INC_SYS
${ALEMBIC_INCLUDE_DIRS}
)
list(APPEND LIB
${ALEMBIC_LIBRARIES}
)
endif()
if(WITH_OPENIMAGEDENOISE)
add_definitions(-DWITH_OPENIMAGEDENOISE)
list(APPEND INC_SYS

View File

@@ -61,6 +61,7 @@ class CyclesRender(bpy.types.RenderEngine):
bl_use_save_buffers = True
bl_use_spherical_stereo = True
bl_use_custom_freestyle = True
bl_use_alembic_procedural = True
def __init__(self):
self.session = None

View File

@@ -227,6 +227,11 @@ def update_render_passes(self, context):
view_layer.update_render_passes()
def update_render_engine(self, context):
scene = context.scene
scene.update_render_engine()
class CyclesRenderSettings(bpy.types.PropertyGroup):
device: EnumProperty(
@@ -240,6 +245,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
description="Feature set to use for rendering",
items=enum_feature_set,
default='SUPPORTED',
update=update_render_engine,
)
shading_system: BoolProperty(
name="Open Shading Language",
@@ -402,7 +408,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
adaptive_threshold: FloatProperty(
name="Adaptive Sampling Threshold",
description="Noise level step to stop sampling at, lower values reduce noise the cost of render time. Zero for automatic setting based on number of AA samples",
description="Noise level step to stop sampling at, lower values reduce noise at the cost of render time. Zero for automatic setting based on number of AA samples",
min=0.0, max=1.0,
default=0.0,
precision=4,

View File

@@ -526,8 +526,13 @@ bool BlenderSync::object_has_particle_hair(BL::Object b_ob)
/* Old particle hair. */
void BlenderSync::sync_particle_hair(
Hair *hair, BL::Mesh &b_mesh, BL::Object &b_ob, bool motion, int motion_step)
Hair *hair, BL::Mesh &b_mesh, BObjectInfo &b_ob_info, bool motion, int motion_step)
{
if (!b_ob_info.is_real_object_data()) {
return;
}
BL::Object b_ob = b_ob_info.real_object;
/* obtain general settings */
if (b_ob.mode() == b_ob.mode_PARTICLE_EDIT || b_ob.mode() == b_ob.mode_EDIT) {
return;
@@ -788,10 +793,10 @@ static void export_hair_curves_motion(Hair *hair, BL::Hair b_hair, int motion_st
}
/* Hair object. */
void BlenderSync::sync_hair(Hair *hair, BL::Object &b_ob, bool motion, int motion_step)
void BlenderSync::sync_hair(Hair *hair, BObjectInfo &b_ob_info, bool motion, int motion_step)
{
/* Convert Blender hair to Cycles curves. */
BL::Hair b_hair(b_ob.data());
BL::Hair b_hair(b_ob_info.object_data);
if (motion) {
export_hair_curves_motion(hair, b_hair, motion_step);
}
@@ -800,16 +805,16 @@ void BlenderSync::sync_hair(Hair *hair, BL::Object &b_ob, bool motion, int motio
}
}
#else
void BlenderSync::sync_hair(Hair *hair, BL::Object &b_ob, bool motion, int motion_step)
void BlenderSync::sync_hair(Hair *hair, BObjectInfo &b_ob_info, bool motion, int motion_step)
{
(void)hair;
(void)b_ob;
(void)b_ob_info;
(void)motion;
(void)motion_step;
}
#endif
void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph, BL::Object b_ob, Hair *hair)
void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph, BObjectInfo &b_ob_info, Hair *hair)
{
/* make a copy of the shaders as the caller in the main thread still need them for syncing the
* attributes */
@@ -819,19 +824,19 @@ void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph, BL::Object b_ob, Hair *ha
new_hair.set_used_shaders(used_shaders);
if (view_layer.use_hair) {
if (b_ob.type() == BL::Object::type_HAIR) {
if (b_ob_info.object_data.is_a(&RNA_Hair)) {
/* Hair object. */
sync_hair(&new_hair, b_ob, false);
sync_hair(&new_hair, b_ob_info, false);
}
else {
/* Particle hair. */
bool need_undeformed = new_hair.need_attribute(scene, ATTR_STD_GENERATED);
BL::Mesh b_mesh = object_to_mesh(
b_data, b_ob, b_depsgraph, need_undeformed, Mesh::SUBDIVISION_NONE);
b_data, b_ob_info, b_depsgraph, need_undeformed, Mesh::SUBDIVISION_NONE);
if (b_mesh) {
sync_particle_hair(&new_hair, b_mesh, b_ob, false);
free_object_to_mesh(b_data, b_ob, b_mesh);
sync_particle_hair(&new_hair, b_mesh, b_ob_info, false);
free_object_to_mesh(b_data, b_ob_info, b_mesh);
}
}
}
@@ -859,7 +864,7 @@ void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph, BL::Object b_ob, Hair *ha
}
void BlenderSync::sync_hair_motion(BL::Depsgraph b_depsgraph,
BL::Object b_ob,
BObjectInfo &b_ob_info,
Hair *hair,
int motion_step)
{
@@ -869,18 +874,19 @@ void BlenderSync::sync_hair_motion(BL::Depsgraph b_depsgraph,
}
/* Export deformed coordinates. */
if (ccl::BKE_object_is_deform_modified(b_ob, b_scene, preview)) {
if (b_ob.type() == BL::Object::type_HAIR) {
if (ccl::BKE_object_is_deform_modified(b_ob_info, b_scene, preview)) {
if (b_ob_info.object_data.is_a(&RNA_Hair)) {
/* Hair object. */
sync_hair(hair, b_ob, true, motion_step);
sync_hair(hair, b_ob_info, true, motion_step);
return;
}
else {
/* Particle hair. */
BL::Mesh b_mesh = object_to_mesh(b_data, b_ob, b_depsgraph, false, Mesh::SUBDIVISION_NONE);
BL::Mesh b_mesh = object_to_mesh(
b_data, b_ob_info, b_depsgraph, false, Mesh::SUBDIVISION_NONE);
if (b_mesh) {
sync_particle_hair(hair, b_mesh, b_ob, true, motion_step);
free_object_to_mesh(b_data, b_ob, b_mesh);
sync_particle_hair(hair, b_mesh, b_ob_info, true, motion_step);
free_object_to_mesh(b_data, b_ob_info, b_mesh);
return;
}
}

View File

@@ -29,13 +29,15 @@
CCL_NAMESPACE_BEGIN
static Geometry::Type determine_geom_type(BL::Object &b_ob, bool use_particle_hair)
static Geometry::Type determine_geom_type(BObjectInfo &b_ob_info, bool use_particle_hair)
{
if (b_ob.type() == BL::Object::type_HAIR || use_particle_hair) {
if (b_ob_info.object_data.is_a(&RNA_Hair) || use_particle_hair) {
return Geometry::HAIR;
}
if (b_ob.type() == BL::Object::type_VOLUME || object_fluid_gas_domain_find(b_ob)) {
if (b_ob_info.object_data.is_a(&RNA_Volume) ||
(b_ob_info.object_data == b_ob_info.real_object.data() &&
object_fluid_gas_domain_find(b_ob_info.real_object))) {
return Geometry::VOLUME;
}
@@ -71,20 +73,17 @@ array<Node *> BlenderSync::find_used_shaders(BL::Object &b_ob)
}
Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,
BL::Object &b_ob,
BL::Object &b_ob_instance,
BObjectInfo &b_ob_info,
bool object_updated,
bool use_particle_hair,
TaskPool *task_pool)
{
/* Test if we can instance or if the object is modified. */
BL::ID b_ob_data = b_ob.data();
BL::ID b_key_id = (BKE_object_is_modified(b_ob)) ? b_ob_instance : b_ob_data;
Geometry::Type geom_type = determine_geom_type(b_ob, use_particle_hair);
GeometryKey key(b_key_id.ptr.data, geom_type);
Geometry::Type geom_type = determine_geom_type(b_ob_info, use_particle_hair);
GeometryKey key(b_ob_info.object_data, geom_type);
/* Find shader indices. */
array<Node *> used_shaders = find_used_shaders(b_ob);
array<Node *> used_shaders = find_used_shaders(b_ob_info.iter_object);
/* Ensure we only sync instanced geometry once. */
Geometry *geom = geometry_map.find(key);
@@ -111,7 +110,7 @@ Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,
}
else {
/* Test if we need to update existing geometry. */
sync = geometry_map.update(geom, b_key_id);
sync = geometry_map.update(geom, b_ob_info.object_data);
}
if (!sync) {
@@ -144,7 +143,7 @@ Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,
geometry_synced.insert(geom);
geom->name = ustring(b_ob_data.name().c_str());
geom->name = ustring(b_ob_info.object_data.name().c_str());
/* Store the shaders immediately for the object attribute code. */
geom->set_used_shaders(used_shaders);
@@ -153,19 +152,19 @@ Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,
if (progress.get_cancel())
return;
progress.set_sync_status("Synchronizing object", b_ob.name());
progress.set_sync_status("Synchronizing object", b_ob_info.real_object.name());
if (geom_type == Geometry::HAIR) {
Hair *hair = static_cast<Hair *>(geom);
sync_hair(b_depsgraph, b_ob, hair);
sync_hair(b_depsgraph, b_ob_info, hair);
}
else if (geom_type == Geometry::VOLUME) {
Volume *volume = static_cast<Volume *>(geom);
sync_volume(b_ob, volume);
sync_volume(b_ob_info, volume);
}
else {
Mesh *mesh = static_cast<Mesh *>(geom);
sync_mesh(b_depsgraph, b_ob, mesh);
sync_mesh(b_depsgraph, b_ob_info, mesh);
}
};
@@ -181,7 +180,7 @@ Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,
}
void BlenderSync::sync_geometry_motion(BL::Depsgraph &b_depsgraph,
BL::Object &b_ob,
BObjectInfo &b_ob_info,
Object *object,
float motion_time,
bool use_particle_hair,
@@ -210,16 +209,17 @@ void BlenderSync::sync_geometry_motion(BL::Depsgraph &b_depsgraph,
if (progress.get_cancel())
return;
if (b_ob.type() == BL::Object::type_HAIR || use_particle_hair) {
if (b_ob_info.object_data.is_a(&RNA_Hair) || use_particle_hair) {
Hair *hair = static_cast<Hair *>(geom);
sync_hair_motion(b_depsgraph, b_ob, hair, motion_step);
sync_hair_motion(b_depsgraph, b_ob_info, hair, motion_step);
}
else if (b_ob.type() == BL::Object::type_VOLUME || object_fluid_gas_domain_find(b_ob)) {
else if (b_ob_info.object_data.is_a(&RNA_Volume) ||
object_fluid_gas_domain_find(b_ob_info.real_object)) {
/* No volume motion blur support yet. */
}
else {
Mesh *mesh = static_cast<Mesh *>(geom);
sync_mesh_motion(b_depsgraph, b_ob, mesh, motion_step);
sync_mesh_motion(b_depsgraph, b_ob_info, mesh, motion_step);
}
};

View File

@@ -27,15 +27,14 @@ CCL_NAMESPACE_BEGIN
void BlenderSync::sync_light(BL::Object &b_parent,
int persistent_id[OBJECT_PERSISTENT_ID_SIZE],
BL::Object &b_ob,
BL::Object &b_ob_instance,
BObjectInfo &b_ob_info,
int random_id,
Transform &tfm,
bool *use_portal)
{
/* test if we need to sync */
ObjectKey key(b_parent, persistent_id, b_ob_instance, false);
BL::Light b_light(b_ob.data());
ObjectKey key(b_parent, persistent_id, b_ob_info.real_object, false);
BL::Light b_light(b_ob_info.object_data);
Light *light = light_map.find(key);
@@ -44,7 +43,7 @@ void BlenderSync::sync_light(BL::Object &b_parent,
const bool tfm_updated = (light && light->get_tfm() != tfm);
/* Update if either object or light data changed. */
if (!light_map.add_or_update(&light, b_ob, b_parent, key) && !tfm_updated) {
if (!light_map.add_or_update(&light, b_ob_info.real_object, b_parent, key) && !tfm_updated) {
Shader *shader;
if (!shader_map.add_or_update(&shader, b_light)) {
if (light->get_is_portal())
@@ -139,11 +138,11 @@ void BlenderSync::sync_light(BL::Object &b_parent,
light->set_max_bounces(get_int(clight, "max_bounces"));
if (b_ob != b_ob_instance) {
if (b_ob_info.real_object != b_ob_info.iter_object) {
light->set_random_id(random_id);
}
else {
light->set_random_id(hash_uint2(hash_string(b_ob.name().c_str()), 0));
light->set_random_id(hash_uint2(hash_string(b_ob_info.real_object.name().c_str()), 0));
}
if (light->get_light_type() == LIGHT_AREA)
@@ -155,7 +154,7 @@ void BlenderSync::sync_light(BL::Object &b_parent,
*use_portal = true;
/* visibility */
uint visibility = object_ray_visibility(b_ob);
uint visibility = object_ray_visibility(b_ob_info.real_object);
light->set_use_diffuse((visibility & PATH_RAY_DIFFUSE) != 0);
light->set_use_glossy((visibility & PATH_RAY_GLOSSY) != 0);
light->set_use_transmission((visibility & PATH_RAY_TRANSMIT) != 0);

View File

@@ -999,12 +999,14 @@ static void create_mesh(Scene *scene,
static void create_subd_mesh(Scene *scene,
Mesh *mesh,
BL::Object &b_ob,
BObjectInfo &b_ob_info,
BL::Mesh &b_mesh,
const array<Node *> &used_shaders,
float dicing_rate,
int max_subdivisions)
{
BL::Object b_ob = b_ob_info.real_object;
BL::SubsurfModifier subsurf_mod(b_ob.modifiers[b_ob.modifiers.length() - 1]);
bool subdivide_uvs = subsurf_mod.uv_smooth() != BL::SubsurfModifier::uv_smooth_NONE;
@@ -1038,29 +1040,12 @@ static void create_subd_mesh(Scene *scene,
/* Sync */
static BL::MeshSequenceCacheModifier object_mesh_cache_find(BL::Object &b_ob)
{
if (b_ob.modifiers.length() > 0) {
BL::Modifier b_mod = b_ob.modifiers[b_ob.modifiers.length() - 1];
if (b_mod.type() == BL::Modifier::type_MESH_SEQUENCE_CACHE) {
BL::MeshSequenceCacheModifier mesh_cache = BL::MeshSequenceCacheModifier(b_mod);
if (MeshSequenceCacheModifier_has_velocity_get(&mesh_cache.ptr)) {
return mesh_cache;
}
}
}
return BL::MeshSequenceCacheModifier(PointerRNA_NULL);
}
/* Check whether some of "built-in" motion-related attributes are needed to be exported (includes
* things like velocity from cache modifier, fluid simulation).
*
* NOTE: This code is run prior to object motion blur initialization. so can not access properties
* set by `sync_object_motion_init()`. */
static bool mesh_need_motion_attribute(BL::Object &b_ob, Scene *scene)
static bool mesh_need_motion_attribute(BObjectInfo &b_ob_info, Scene *scene)
{
const Scene::MotionType need_motion = scene->need_motion();
if (need_motion == Scene::MOTION_NONE) {
@@ -1077,7 +1062,7 @@ static bool mesh_need_motion_attribute(BL::Object &b_ob, Scene *scene)
* - Motion attribute expects non-zero time steps.
*
* Avoid adding motion attributes if the motion blur will enforce 0 motion steps. */
PointerRNA cobject = RNA_pointer_get(&b_ob.ptr, "cycles");
PointerRNA cobject = RNA_pointer_get(&b_ob_info.real_object.ptr, "cycles");
const bool use_motion = get_boolean(cobject, "use_motion_blur");
if (!use_motion) {
return false;
@@ -1089,13 +1074,14 @@ static bool mesh_need_motion_attribute(BL::Object &b_ob, Scene *scene)
return true;
}
static void sync_mesh_cached_velocities(BL::Object &b_ob, Scene *scene, Mesh *mesh)
static void sync_mesh_cached_velocities(BObjectInfo &b_ob_info, Scene *scene, Mesh *mesh)
{
if (!mesh_need_motion_attribute(b_ob, scene)) {
if (!mesh_need_motion_attribute(b_ob_info, scene)) {
return;
}
BL::MeshSequenceCacheModifier b_mesh_cache = object_mesh_cache_find(b_ob);
BL::Object b_ob = b_ob_info.real_object;
BL::MeshSequenceCacheModifier b_mesh_cache = object_mesh_cache_find(b_ob, true, nullptr);
if (!b_mesh_cache) {
return;
@@ -1135,12 +1121,16 @@ static void sync_mesh_cached_velocities(BL::Object &b_ob, Scene *scene, Mesh *me
}
}
static void sync_mesh_fluid_motion(BL::Object &b_ob, Scene *scene, Mesh *mesh)
static void sync_mesh_fluid_motion(BObjectInfo &b_ob_info, Scene *scene, Mesh *mesh)
{
if (!mesh_need_motion_attribute(b_ob, scene)) {
if (!b_ob_info.is_real_object_data()) {
return;
}
if (!mesh_need_motion_attribute(b_ob_info, scene)) {
return;
}
BL::Object b_ob = b_ob_info.real_object;
BL::FluidDomainSettings b_fluid_domain = object_fluid_liquid_domain_find(b_ob);
if (!b_fluid_domain)
@@ -1174,7 +1164,7 @@ static void sync_mesh_fluid_motion(BL::Object &b_ob, Scene *scene, Mesh *mesh)
}
}
void BlenderSync::sync_mesh(BL::Depsgraph b_depsgraph, BL::Object b_ob, Mesh *mesh)
void BlenderSync::sync_mesh(BL::Depsgraph b_depsgraph, BObjectInfo &b_ob_info, Mesh *mesh)
{
/* make a copy of the shaders as the caller in the main thread still need them for syncing the
* attributes */
@@ -1187,20 +1177,21 @@ void BlenderSync::sync_mesh(BL::Depsgraph b_depsgraph, BL::Object b_ob, Mesh *me
/* Adaptive subdivision setup. Not for baking since that requires
* exact mapping to the Blender mesh. */
if (!scene->bake_manager->get_baking()) {
new_mesh.set_subdivision_type(object_subdivision_type(b_ob, preview, experimental));
new_mesh.set_subdivision_type(
object_subdivision_type(b_ob_info.real_object, preview, experimental));
}
/* For some reason, meshes do not need this... */
bool need_undeformed = new_mesh.need_attribute(scene, ATTR_STD_GENERATED);
BL::Mesh b_mesh = object_to_mesh(
b_data, b_ob, b_depsgraph, need_undeformed, new_mesh.get_subdivision_type());
b_data, b_ob_info, b_depsgraph, need_undeformed, new_mesh.get_subdivision_type());
if (b_mesh) {
/* Sync mesh itself. */
if (new_mesh.get_subdivision_type() != Mesh::SUBDIVISION_NONE)
create_subd_mesh(scene,
&new_mesh,
b_ob,
b_ob_info,
b_mesh,
new_mesh.get_used_shaders(),
dicing_rate,
@@ -1208,15 +1199,15 @@ void BlenderSync::sync_mesh(BL::Depsgraph b_depsgraph, BL::Object b_ob, Mesh *me
else
create_mesh(scene, &new_mesh, b_mesh, new_mesh.get_used_shaders(), false);
free_object_to_mesh(b_data, b_ob, b_mesh);
free_object_to_mesh(b_data, b_ob_info, b_mesh);
}
}
/* cached velocities (e.g. from alembic archive) */
sync_mesh_cached_velocities(b_ob, scene, &new_mesh);
sync_mesh_cached_velocities(b_ob_info, scene, &new_mesh);
/* mesh fluid motion mantaflow */
sync_mesh_fluid_motion(b_ob, scene, &new_mesh);
sync_mesh_fluid_motion(b_ob_info, scene, &new_mesh);
/* update original sockets */
@@ -1247,18 +1238,19 @@ void BlenderSync::sync_mesh(BL::Depsgraph b_depsgraph, BL::Object b_ob, Mesh *me
}
void BlenderSync::sync_mesh_motion(BL::Depsgraph b_depsgraph,
BL::Object b_ob,
BObjectInfo &b_ob_info,
Mesh *mesh,
int motion_step)
{
/* Fluid motion blur already exported. */
BL::FluidDomainSettings b_fluid_domain = object_fluid_liquid_domain_find(b_ob);
BL::FluidDomainSettings b_fluid_domain = object_fluid_liquid_domain_find(b_ob_info.real_object);
if (b_fluid_domain) {
return;
}
/* Cached motion blur already exported. */
BL::MeshSequenceCacheModifier mesh_cache = object_mesh_cache_find(b_ob);
BL::MeshSequenceCacheModifier mesh_cache = object_mesh_cache_find(
b_ob_info.real_object, true, nullptr);
if (mesh_cache) {
return;
}
@@ -1272,11 +1264,13 @@ void BlenderSync::sync_mesh_motion(BL::Depsgraph b_depsgraph,
/* Skip objects without deforming modifiers. this is not totally reliable,
* would need a more extensive check to see which objects are animated. */
BL::Mesh b_mesh(PointerRNA_NULL);
if (ccl::BKE_object_is_deform_modified(b_ob, b_scene, preview)) {
if (ccl::BKE_object_is_deform_modified(b_ob_info, b_scene, preview)) {
/* get derived mesh */
b_mesh = object_to_mesh(b_data, b_ob, b_depsgraph, false, Mesh::SUBDIVISION_NONE);
b_mesh = object_to_mesh(b_data, b_ob_info, b_depsgraph, false, Mesh::SUBDIVISION_NONE);
}
const std::string ob_name = b_ob_info.real_object.name();
/* TODO(sergey): Perform preliminary check for number of vertices. */
if (b_mesh) {
/* Export deformed coordinates. */
@@ -1312,17 +1306,17 @@ void BlenderSync::sync_mesh_motion(BL::Depsgraph b_depsgraph,
memcmp(mP, &mesh->get_verts()[0], sizeof(float3) * numverts) == 0) {
/* no motion, remove attributes again */
if (b_mesh.vertices.length() != numverts) {
VLOG(1) << "Topology differs, disabling motion blur for object " << b_ob.name();
VLOG(1) << "Topology differs, disabling motion blur for object " << ob_name;
}
else {
VLOG(1) << "No actual deformation motion for object " << b_ob.name();
VLOG(1) << "No actual deformation motion for object " << ob_name;
}
mesh->attributes.remove(ATTR_STD_MOTION_VERTEX_POSITION);
if (attr_mN)
mesh->attributes.remove(ATTR_STD_MOTION_VERTEX_NORMAL);
}
else if (motion_step > 0) {
VLOG(1) << "Filling deformation motion for object " << b_ob.name();
VLOG(1) << "Filling deformation motion for object " << ob_name;
/* motion, fill up previous steps that we might have skipped because
* they had no motion, but we need them anyway now */
float3 *P = &mesh->get_verts()[0];
@@ -1336,8 +1330,8 @@ void BlenderSync::sync_mesh_motion(BL::Depsgraph b_depsgraph,
}
else {
if (b_mesh.vertices.length() != numverts) {
VLOG(1) << "Topology differs, discarding motion blur for object " << b_ob.name()
<< " at time " << motion_step;
VLOG(1) << "Topology differs, discarding motion blur for object " << ob_name << " at time "
<< motion_step;
memcpy(mP, &mesh->get_verts()[0], sizeof(float3) * numverts);
if (mN != NULL) {
memcpy(mN, attr_N->data_float3(), sizeof(float3) * numverts);
@@ -1345,7 +1339,7 @@ void BlenderSync::sync_mesh_motion(BL::Depsgraph b_depsgraph,
}
}
free_object_to_mesh(b_data, b_ob, b_mesh);
free_object_to_mesh(b_data, b_ob_info, b_mesh);
return;
}

View File

@@ -14,6 +14,7 @@
* limitations under the License.
*/
#include "render/alembic.h"
#include "render/camera.h"
#include "render/graph.h"
#include "render/integrator.h"
@@ -153,7 +154,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
const bool is_instance = b_instance.is_instance();
BL::Object b_ob = b_instance.object();
BL::Object b_parent = is_instance ? b_instance.parent() : b_instance.object();
BL::Object b_ob_instance = is_instance ? b_instance.instance_object() : b_ob;
BObjectInfo b_ob_info{b_ob, is_instance ? b_instance.instance_object() : b_ob, b_ob.data()};
const bool motion = motion_time != 0.0f;
/*const*/ Transform tfm = get_transform(b_ob.matrix_world());
int *persistent_id = NULL;
@@ -177,8 +178,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
{
sync_light(b_parent,
persistent_id,
b_ob,
b_ob_instance,
b_ob_info,
is_instance ? b_instance.random_id() : 0,
tfm,
use_portal);
@@ -230,7 +230,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
TaskPool *object_geom_task_pool = (is_instance) ? NULL : geom_task_pool;
/* key to lookup object */
ObjectKey key(b_parent, persistent_id, b_ob_instance, use_particle_hair);
ObjectKey key(b_parent, persistent_id, b_ob_info.real_object, use_particle_hair);
Object *object;
/* motion vector case */
@@ -248,12 +248,8 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
/* mesh deformation */
if (object->get_geometry())
sync_geometry_motion(b_depsgraph,
b_ob_instance,
object,
motion_time,
use_particle_hair,
object_geom_task_pool);
sync_geometry_motion(
b_depsgraph, b_ob_info, object, motion_time, use_particle_hair, object_geom_task_pool);
}
return object;
@@ -264,15 +260,8 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
(tfm != object->get_tfm());
/* mesh sync */
/* b_ob is owned by the iterator and will go out of scope at the end of the block.
* b_ob_instance is the original object and will remain valid for deferred geometry
* sync. */
Geometry *geometry = sync_geometry(b_depsgraph,
b_ob_instance,
b_ob_instance,
object_updated,
use_particle_hair,
object_geom_task_pool);
Geometry *geometry = sync_geometry(
b_depsgraph, b_ob_info, object_updated, use_particle_hair, object_geom_task_pool);
object->set_geometry(geometry);
/* special case not tracked by object update flags */
@@ -375,7 +364,7 @@ static bool lookup_property(BL::ID b_id, const string &name, float4 *r_value)
if (type == PROP_FLOAT)
value = RNA_property_float_get(&ptr, prop);
else if (type == PROP_INT)
value = RNA_property_int_get(&ptr, prop);
value = static_cast<float>(RNA_property_int_get(&ptr, prop));
else
return false;
@@ -484,6 +473,72 @@ bool BlenderSync::sync_object_attributes(BL::DepsgraphObjectInstance &b_instance
/* Object Loop */
void BlenderSync::sync_procedural(BL::Object &b_ob,
BL::MeshSequenceCacheModifier &b_mesh_cache,
bool has_subdivision_modifier)
{
#ifdef WITH_ALEMBIC
BL::CacheFile cache_file = b_mesh_cache.cache_file();
void *cache_file_key = cache_file.ptr.data;
AlembicProcedural *procedural = static_cast<AlembicProcedural *>(
procedural_map.find(cache_file_key));
if (procedural == nullptr) {
procedural = scene->create_node<AlembicProcedural>();
procedural_map.add(cache_file_key, procedural);
}
else {
procedural_map.used(procedural);
}
float current_frame = static_cast<float>(b_scene.frame_current());
if (cache_file.override_frame()) {
current_frame = cache_file.frame();
}
if (!cache_file.override_frame()) {
procedural->set_start_frame(static_cast<float>(b_scene.frame_start()));
procedural->set_end_frame(static_cast<float>(b_scene.frame_end()));
}
procedural->set_frame(current_frame);
procedural->set_frame_rate(b_scene.render().fps() / b_scene.render().fps_base());
procedural->set_frame_offset(cache_file.frame_offset());
string absolute_path = blender_absolute_path(b_data, b_ob, b_mesh_cache.cache_file().filepath());
procedural->set_filepath(ustring(absolute_path));
procedural->set_scale(cache_file.scale());
procedural->set_use_prefetch(cache_file.use_prefetch());
procedural->set_prefetch_cache_size(cache_file.prefetch_cache_size());
/* create or update existing AlembicObjects */
ustring object_path = ustring(b_mesh_cache.object_path());
AlembicObject *abc_object = procedural->get_or_create_object(object_path);
array<Node *> used_shaders = find_used_shaders(b_ob);
abc_object->set_used_shaders(used_shaders);
PointerRNA cobj = RNA_pointer_get(&b_ob.ptr, "cycles");
const float subd_dicing_rate = max(0.1f, RNA_float_get(&cobj, "dicing_rate") * dicing_rate);
abc_object->set_subd_dicing_rate(subd_dicing_rate);
abc_object->set_subd_max_level(max_subdivisions);
abc_object->set_ignore_subdivision(!has_subdivision_modifier);
if (abc_object->is_modified() || procedural->is_modified()) {
procedural->tag_update(scene);
}
#else
(void)b_ob;
(void)b_mesh_cache;
(void)has_subdivision_modifier;
#endif
}
void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph,
BL::SpaceView3D &b_v3d,
float motion_time)
@@ -499,6 +554,7 @@ void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph,
light_map.pre_sync();
geometry_map.pre_sync();
object_map.pre_sync();
procedural_map.pre_sync();
particle_system_map.pre_sync();
motion_times.clear();
}
@@ -539,15 +595,39 @@ void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph,
/* Object itself. */
if (b_instance.show_self()) {
sync_object(b_depsgraph,
b_view_layer,
b_instance,
motion_time,
false,
show_lights,
culling,
&use_portal,
sync_hair ? NULL : &geom_task_pool);
#ifdef WITH_ALEMBIC
bool use_procedural = false;
bool has_subdivision_modifier = false;
BL::MeshSequenceCacheModifier b_mesh_cache(PointerRNA_NULL);
/* Experimental as Blender does not have good support for procedurals at the moment, also
* only available in preview renders since currently do not have a good cache policy, the
* data being loaded at once for all the frames. */
if (experimental && b_v3d) {
b_mesh_cache = object_mesh_cache_find(b_ob, false, &has_subdivision_modifier);
use_procedural = b_mesh_cache && b_mesh_cache.cache_file().use_render_procedural();
}
if (use_procedural) {
/* Skip in the motion case, as generating motion blur data will be handled in the
* procedural. */
if (!motion) {
sync_procedural(b_ob, b_mesh_cache, has_subdivision_modifier);
}
}
else
#endif
{
sync_object(b_depsgraph,
b_view_layer,
b_instance,
motion_time,
false,
show_lights,
culling,
&use_portal,
sync_hair ? NULL : &geom_task_pool);
}
}
/* Particle hair as separate object. */
@@ -580,6 +660,7 @@ void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph,
object_map.post_sync();
geometry_map.post_sync();
particle_system_map.post_sync();
procedural_map.post_sync();
}
if (motion)

View File

@@ -71,7 +71,7 @@ bool BlenderSync::sync_dupli_particle(BL::Object &b_ob,
Particle pa;
pa.index = persistent_id[0];
pa.age = b_scene.frame_current() - b_pa.birth_time();
pa.age = b_scene.frame_current_final() - b_pa.birth_time();
pa.lifetime = b_pa.lifetime();
pa.location = get_float3(b_pa.location());
pa.rotation = get_float4(b_pa.rotation());

View File

@@ -487,6 +487,24 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
if (param->varlenarray || param->isstruct || param->type.arraylen > 1)
continue;
/* Read metadata. */
bool is_bool_param = false;
ustring param_label = param->name;
for (const OSL::OSLQuery::Parameter &metadata : param->metadata) {
if (metadata.type == TypeDesc::STRING) {
if (metadata.name == "widget") {
/* Boolean socket. */
if (metadata.sdefault[0] == "boolean" || metadata.sdefault[0] == "checkBox") {
is_bool_param = true;
}
}
else if (metadata.name == "label") {
/* Socket label. */
param_label = metadata.sdefault[0];
}
}
}
/* determine socket type */
string socket_type;
BL::NodeSocket::type_enum data_type = BL::NodeSocket::type_VALUE;
@@ -494,6 +512,7 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
float default_float = 0.0f;
int default_int = 0;
string default_string = "";
bool default_boolean = false;
if (param->isclosure) {
socket_type = "NodeSocketShader";
@@ -523,10 +542,19 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
}
else if (param->type.aggregate == TypeDesc::SCALAR) {
if (param->type.basetype == TypeDesc::INT) {
socket_type = "NodeSocketInt";
data_type = BL::NodeSocket::type_INT;
if (param->validdefault)
default_int = param->idefault[0];
if (is_bool_param) {
socket_type = "NodeSocketBool";
data_type = BL::NodeSocket::type_BOOLEAN;
if (param->validdefault) {
default_boolean = (bool)param->idefault[0];
}
}
else {
socket_type = "NodeSocketInt";
data_type = BL::NodeSocket::type_INT;
if (param->validdefault)
default_int = param->idefault[0];
}
}
else if (param->type.basetype == TypeDesc::FLOAT) {
socket_type = "NodeSocketFloat";
@@ -546,33 +574,57 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
else
continue;
/* find socket socket */
BL::NodeSocket b_sock(PointerRNA_NULL);
/* Update existing socket. */
bool found_existing = false;
if (param->isoutput) {
b_sock = b_node.outputs[param->name.string()];
/* remove if type no longer matches */
if (b_sock && b_sock.bl_idname() != socket_type) {
b_node.outputs.remove(b_data, b_sock);
b_sock = BL::NodeSocket(PointerRNA_NULL);
for (BL::NodeSocket &b_sock : b_node.outputs) {
if (b_sock.identifier() == param->name) {
if (b_sock.bl_idname() != socket_type) {
/* Remove if type no longer matches. */
b_node.outputs.remove(b_data, b_sock);
}
else {
/* Reuse and update label. */
if (b_sock.name() != param_label) {
b_sock.name(param_label.string());
}
used_sockets.insert(b_sock.ptr.data);
found_existing = true;
}
break;
}
}
}
else {
b_sock = b_node.inputs[param->name.string()];
/* remove if type no longer matches */
if (b_sock && b_sock.bl_idname() != socket_type) {
b_node.inputs.remove(b_data, b_sock);
b_sock = BL::NodeSocket(PointerRNA_NULL);
for (BL::NodeSocket &b_sock : b_node.inputs) {
if (b_sock.identifier() == param->name) {
if (b_sock.bl_idname() != socket_type) {
/* Remove if type no longer matches. */
b_node.inputs.remove(b_data, b_sock);
}
else {
/* Reuse and update label. */
if (b_sock.name() != param_label) {
b_sock.name(param_label.string());
}
used_sockets.insert(b_sock.ptr.data);
found_existing = true;
}
break;
}
}
}
if (!b_sock) {
/* create new socket */
if (param->isoutput)
b_sock = b_node.outputs.create(
b_data, socket_type.c_str(), param->name.c_str(), param->name.c_str());
else
b_sock = b_node.inputs.create(
b_data, socket_type.c_str(), param->name.c_str(), param->name.c_str());
if (!found_existing) {
/* Create new socket. */
BL::NodeSocket b_sock = (param->isoutput) ? b_node.outputs.create(b_data,
socket_type.c_str(),
param_label.c_str(),
param->name.c_str()) :
b_node.inputs.create(b_data,
socket_type.c_str(),
param_label.c_str(),
param->name.c_str());
/* set default value */
if (data_type == BL::NodeSocket::type_VALUE) {
@@ -590,9 +642,12 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
else if (data_type == BL::NodeSocket::type_STRING) {
set_string(b_sock.ptr, "default_value", default_string);
}
}
else if (data_type == BL::NodeSocket::type_BOOLEAN) {
set_boolean(b_sock.ptr, "default_value", default_boolean);
}
used_sockets.insert(b_sock.ptr.data);
used_sockets.insert(b_sock.ptr.data);
}
}
/* remove unused parameters */

View File

@@ -149,7 +149,7 @@ BlenderAttributeType blender_attribute_name_split_type(ustring name, string *r_r
static BL::NodeSocket get_node_output(BL::Node &b_node, const string &name)
{
for (BL::NodeSocket &b_out : b_node.outputs) {
if (b_out.name() == name) {
if (b_out.identifier() == name) {
return b_out;
}
}
@@ -215,7 +215,12 @@ static void set_default_value(ShaderInput *input,
break;
}
case SocketType::INT: {
node->set(socket, get_int(b_sock.ptr, "default_value"));
if (b_sock.type() == BL::NodeSocket::type_BOOLEAN) {
node->set(socket, get_boolean(b_sock.ptr, "default_value"));
}
else {
node->set(socket, get_int(b_sock.ptr, "default_value"));
}
break;
}
case SocketType::COLOR: {
@@ -1002,71 +1007,59 @@ static bool node_use_modified_socket_name(ShaderNode *node)
return true;
}
static ShaderInput *node_find_input_by_name(ShaderNode *node,
BL::Node &b_node,
BL::NodeSocket &b_socket)
static ShaderInput *node_find_input_by_name(ShaderNode *node, BL::NodeSocket &b_socket)
{
string name = b_socket.name();
string name = b_socket.identifier();
ShaderInput *input = node->input(name.c_str());
if (node_use_modified_socket_name(node)) {
bool found = false;
int counter = 0, total = 0;
if (!input && node_use_modified_socket_name(node)) {
/* Different internal name for shader. */
if (string_startswith(name, "Shader")) {
string_replace(name, "Shader", "Closure");
}
input = node->input(name.c_str());
for (BL::NodeSocket &b_input : b_node.inputs) {
if (b_input.name() == name) {
if (!found) {
counter++;
}
total++;
if (!input) {
/* Different internal numbering of two sockets with same name.
* Note that the Blender convention for unique socket names changed
* from . to _ at some point, so we check both to handle old files. */
if (string_endswith(name, "_001")) {
string_replace(name, "_001", "2");
}
else if (string_endswith(name, ".001")) {
string_replace(name, ".001", "2");
}
else if (string_endswith(name, "_002")) {
string_replace(name, "_002", "3");
}
else if (string_endswith(name, ".002")) {
string_replace(name, ".002", "3");
}
else {
name += "1";
}
if (b_input.ptr.data == b_socket.ptr.data)
found = true;
input = node->input(name.c_str());
}
/* rename if needed */
if (name == "Shader")
name = "Closure";
if (total > 1)
name = string_printf("%s%d", name.c_str(), counter);
}
return node->input(name.c_str());
return input;
}
static ShaderOutput *node_find_output_by_name(ShaderNode *node,
BL::Node &b_node,
BL::NodeSocket &b_socket)
static ShaderOutput *node_find_output_by_name(ShaderNode *node, BL::NodeSocket &b_socket)
{
string name = b_socket.name();
string name = b_socket.identifier();
ShaderOutput *output = node->output(name.c_str());
if (node_use_modified_socket_name(node)) {
bool found = false;
int counter = 0, total = 0;
for (BL::NodeSocket &b_output : b_node.outputs) {
if (b_output.name() == name) {
if (!found) {
counter++;
}
total++;
}
if (b_output.ptr.data == b_socket.ptr.data) {
found = true;
}
}
/* rename if needed */
if (name == "Shader")
if (!output && node_use_modified_socket_name(node)) {
/* Different internal name for shader. */
if (name == "Shader") {
name = "Closure";
if (total > 1)
name = string_printf("%s%d", name.c_str(), counter);
output = node->output(name.c_str());
}
}
return node->output(name.c_str());
return output;
}
static void add_nodes(Scene *scene,
@@ -1209,7 +1202,7 @@ static void add_nodes(Scene *scene,
if (node) {
/* map node sockets for linking */
for (BL::NodeSocket &b_input : b_node.inputs) {
ShaderInput *input = node_find_input_by_name(node, b_node, b_input);
ShaderInput *input = node_find_input_by_name(node, b_input);
if (!input) {
/* XXX should not happen, report error? */
continue;
@@ -1219,7 +1212,7 @@ static void add_nodes(Scene *scene,
set_default_value(input, b_input, b_data, b_ntree);
}
for (BL::NodeSocket &b_output : b_node.outputs) {
ShaderOutput *output = node_find_output_by_name(node, b_node, b_output);
ShaderOutput *output = node_find_output_by_name(node, b_output);
if (!output) {
/* XXX should not happen, report error? */
continue;

View File

@@ -59,6 +59,7 @@ BlenderSync::BlenderSync(BL::RenderEngine &b_engine,
b_scene(b_scene),
shader_map(scene),
object_map(scene),
procedural_map(scene),
geometry_map(scene),
light_map(scene),
particle_system_map(scene),

View File

@@ -23,6 +23,7 @@
#include "RNA_types.h"
#include "blender/blender_id_map.h"
#include "blender/blender_util.h"
#include "blender/blender_viewport.h"
#include "render/scene.h"
@@ -151,21 +152,31 @@ class BlenderSync {
TaskPool *geom_task_pool);
void sync_object_motion_init(BL::Object &b_parent, BL::Object &b_ob, Object *object);
void sync_procedural(BL::Object &b_ob,
BL::MeshSequenceCacheModifier &b_mesh_cache,
bool has_subdivision);
bool sync_object_attributes(BL::DepsgraphObjectInstance &b_instance, Object *object);
/* Volume */
void sync_volume(BL::Object &b_ob, Volume *volume);
void sync_volume(BObjectInfo &b_ob_info, Volume *volume);
/* Mesh */
void sync_mesh(BL::Depsgraph b_depsgraph, BL::Object b_ob, Mesh *mesh);
void sync_mesh_motion(BL::Depsgraph b_depsgraph, BL::Object b_ob, Mesh *mesh, int motion_step);
void sync_mesh(BL::Depsgraph b_depsgraph, BObjectInfo &b_ob_info, Mesh *mesh);
void sync_mesh_motion(BL::Depsgraph b_depsgraph,
BObjectInfo &b_ob_info,
Mesh *mesh,
int motion_step);
/* Hair */
void sync_hair(BL::Depsgraph b_depsgraph, BL::Object b_ob, Hair *hair);
void sync_hair_motion(BL::Depsgraph b_depsgraph, BL::Object b_ob, Hair *hair, int motion_step);
void sync_hair(Hair *hair, BL::Object &b_ob, bool motion, int motion_step = 0);
void sync_hair(BL::Depsgraph b_depsgraph, BObjectInfo &b_ob_info, Hair *hair);
void sync_hair_motion(BL::Depsgraph b_depsgraph,
BObjectInfo &b_ob_info,
Hair *hair,
int motion_step);
void sync_hair(Hair *hair, BObjectInfo &b_ob_info, bool motion, int motion_step = 0);
void sync_particle_hair(
Hair *hair, BL::Mesh &b_mesh, BL::Object &b_ob, bool motion, int motion_step = 0);
Hair *hair, BL::Mesh &b_mesh, BObjectInfo &b_ob_info, bool motion, int motion_step = 0);
bool object_has_particle_hair(BL::Object b_ob);
/* Camera */
@@ -174,14 +185,13 @@ class BlenderSync {
/* Geometry */
Geometry *sync_geometry(BL::Depsgraph &b_depsgrpah,
BL::Object &b_ob,
BL::Object &b_ob_instance,
BObjectInfo &b_ob_info,
bool object_updated,
bool use_particle_hair,
TaskPool *task_pool);
void sync_geometry_motion(BL::Depsgraph &b_depsgraph,
BL::Object &b_ob,
BObjectInfo &b_ob_info,
Object *object,
float motion_time,
bool use_particle_hair,
@@ -190,8 +200,7 @@ class BlenderSync {
/* Light */
void sync_light(BL::Object &b_parent,
int persistent_id[OBJECT_PERSISTENT_ID_SIZE],
BL::Object &b_ob,
BL::Object &b_ob_instance,
BObjectInfo &b_ob_info,
int random_id,
Transform &tfm,
bool *use_portal);
@@ -221,6 +230,7 @@ class BlenderSync {
id_map<void *, Shader> shader_map;
id_map<ObjectKey, Object> object_map;
id_map<void *, Procedural> procedural_map;
id_map<GeometryKey, Geometry> geometry_map;
id_map<ObjectKey, Light> light_map;
id_map<ParticleSystemKey, ParticleSystem> particle_system_map;

View File

@@ -40,6 +40,28 @@ float *BKE_image_get_float_pixels_for_frame(void *image, int frame, int tile);
CCL_NAMESPACE_BEGIN
struct BObjectInfo {
/* Object directly provided by the depsgraph iterator. This object is only valid during one
* iteration and must not be accessed afterwards. Transforms and visibility should be checked on
* this object. */
BL::Object iter_object;
/* This object remains alive even after the object iterator is done. It corresponds to one
* original object. It is the object that owns the object data below. */
BL::Object real_object;
/* The object-data referenced by the iter object. This is still valid after the depsgraph
* iterator is done. It might have a different type compared to real_object.data(). */
BL::ID object_data;
/* True when the current geometry is the data of the referenced object. False when it is a
* geometry instance that does not have a 1-to-1 relationship with an object. */
bool is_real_object_data() const
{
return const_cast<BL::Object &>(real_object).data() == object_data;
}
};
typedef BL::ShaderNodeAttribute::attribute_type_enum BlenderAttributeType;
BlenderAttributeType blender_attribute_name_split_type(ustring name, string *r_real_name);
@@ -47,7 +69,7 @@ void python_thread_state_save(void **python_thread_state);
void python_thread_state_restore(void **python_thread_state);
static inline BL::Mesh object_to_mesh(BL::BlendData & /*data*/,
BL::Object &object,
BObjectInfo &b_ob_info,
BL::Depsgraph & /*depsgraph*/,
bool /*calc_undeformed*/,
Mesh::SubdivisionType subdivision_type)
@@ -69,9 +91,9 @@ static inline BL::Mesh object_to_mesh(BL::BlendData & /*data*/,
#endif
BL::Mesh mesh(PointerRNA_NULL);
if (object.type() == BL::Object::type_MESH) {
if (b_ob_info.object_data.is_a(&RNA_Mesh)) {
/* TODO: calc_undeformed is not used. */
mesh = BL::Mesh(object.data());
mesh = BL::Mesh(b_ob_info.object_data);
/* Make a copy to split faces if we use autosmooth, otherwise not needed.
* Also in edit mode do we need to make a copy, to ensure data layers like
@@ -79,12 +101,15 @@ static inline BL::Mesh object_to_mesh(BL::BlendData & /*data*/,
if (mesh.is_editmode() ||
(mesh.use_auto_smooth() && subdivision_type == Mesh::SUBDIVISION_NONE)) {
BL::Depsgraph depsgraph(PointerRNA_NULL);
mesh = object.to_mesh(false, depsgraph);
assert(b_ob_info.is_real_object_data());
mesh = b_ob_info.real_object.to_mesh(false, depsgraph);
}
}
else {
BL::Depsgraph depsgraph(PointerRNA_NULL);
mesh = object.to_mesh(false, depsgraph);
if (b_ob_info.is_real_object_data()) {
mesh = b_ob_info.real_object.to_mesh(false, depsgraph);
}
}
#if 0
@@ -108,10 +133,14 @@ static inline BL::Mesh object_to_mesh(BL::BlendData & /*data*/,
}
static inline void free_object_to_mesh(BL::BlendData & /*data*/,
BL::Object &object,
BObjectInfo &b_ob_info,
BL::Mesh &mesh)
{
if (!b_ob_info.is_real_object_data()) {
return;
}
/* Free mesh if we didn't just use the existing one. */
BL::Object object = b_ob_info.real_object;
if (object.data().ptr.data != mesh.ptr.data) {
object.to_mesh_clear();
}
@@ -145,7 +174,7 @@ static inline void curvemapping_minmax(/*const*/ BL::CurveMapping &cumap,
float *min_x,
float *max_x)
{
/* const int num_curves = cumap.curves.length(); */ /* Gives linking error so far. */
// const int num_curves = cumap.curves.length(); /* Gives linking error so far. */
const int num_curves = rgb_curve ? 4 : 3;
*min_x = FLT_MAX;
*max_x = -FLT_MAX;
@@ -219,9 +248,13 @@ static inline bool BKE_object_is_modified(BL::Object &self, BL::Scene &scene, bo
return self.is_modified(scene, (preview) ? (1 << 0) : (1 << 1)) ? true : false;
}
static inline bool BKE_object_is_deform_modified(BL::Object &self, BL::Scene &scene, bool preview)
static inline bool BKE_object_is_deform_modified(BObjectInfo &self, BL::Scene &scene, bool preview)
{
return self.is_deform_modified(scene, (preview) ? (1 << 0) : (1 << 1)) ? true : false;
if (!self.is_real_object_data()) {
return false;
}
return self.real_object.is_deform_modified(scene, (preview) ? (1 << 0) : (1 << 1)) ? true :
false;
}
static inline int render_resolution_x(BL::RenderSettings &b_render)
@@ -246,7 +279,11 @@ static inline string image_user_file_path(BL::ImageUser &iuser,
string filepath_str = string(filepath);
if (load_tiled && ima.source() == BL::Image::source_TILED) {
string_replace(filepath_str, "1001", "<UDIM>");
string udim;
if (ima.tiles.length() > 0) {
udim = to_string(ima.tiles[0].number());
}
string_replace(filepath_str, udim, "<UDIM>");
}
return filepath_str;
}
@@ -420,7 +457,7 @@ static inline void set_enum(PointerRNA &ptr, const char *name, const string &ide
static inline string get_string(PointerRNA &ptr, const char *name)
{
char cstrbuf[1024];
char *cstr = RNA_string_get_alloc(&ptr, name, cstrbuf, sizeof(cstrbuf));
char *cstr = RNA_string_get_alloc(&ptr, name, cstrbuf, sizeof(cstrbuf), NULL);
string str(cstr);
if (cstr != cstrbuf)
MEM_freeN(cstr);
@@ -568,6 +605,45 @@ static inline BL::FluidDomainSettings object_fluid_gas_domain_find(BL::Object &b
return BL::FluidDomainSettings(PointerRNA_NULL);
}
static inline BL::MeshSequenceCacheModifier object_mesh_cache_find(BL::Object &b_ob,
bool check_velocity,
bool *has_subdivision_modifier)
{
for (int i = b_ob.modifiers.length() - 1; i >= 0; --i) {
BL::Modifier b_mod = b_ob.modifiers[i];
if (b_mod.type() == BL::Modifier::type_MESH_SEQUENCE_CACHE) {
BL::MeshSequenceCacheModifier mesh_cache = BL::MeshSequenceCacheModifier(b_mod);
if (check_velocity) {
if (!MeshSequenceCacheModifier_has_velocity_get(&mesh_cache.ptr)) {
return BL::MeshSequenceCacheModifier(PointerRNA_NULL);
}
}
return mesh_cache;
}
/* Skip possible particles system modifiers as they do not modify the geometry. */
if (b_mod.type() == BL::Modifier::type_PARTICLE_SYSTEM) {
continue;
}
/* Only skip the subsurf modifier if we are not checking for the mesh sequence cache modifier
* for motion blur. */
if (b_mod.type() == BL::Modifier::type_SUBSURF && !check_velocity) {
if (has_subdivision_modifier) {
*has_subdivision_modifier = true;
}
continue;
}
break;
}
return BL::MeshSequenceCacheModifier(PointerRNA_NULL);
}
static inline Mesh::SubdivisionType object_subdivision_type(BL::Object &b_ob,
bool preview,
bool experimental)

View File

@@ -181,9 +181,12 @@ class BlenderSmokeLoader : public ImageLoader {
AttributeStandard attribute;
};
static void sync_smoke_volume(Scene *scene, BL::Object &b_ob, Volume *volume, float frame)
static void sync_smoke_volume(Scene *scene, BObjectInfo &b_ob_info, Volume *volume, float frame)
{
BL::FluidDomainSettings b_domain = object_fluid_gas_domain_find(b_ob);
if (!b_ob_info.is_real_object_data()) {
return;
}
BL::FluidDomainSettings b_domain = object_fluid_gas_domain_find(b_ob_info.real_object);
if (!b_domain) {
return;
}
@@ -206,7 +209,7 @@ static void sync_smoke_volume(Scene *scene, BL::Object &b_ob, Volume *volume, fl
Attribute *attr = volume->attributes.add(std);
ImageLoader *loader = new BlenderSmokeLoader(b_ob, std);
ImageLoader *loader = new BlenderSmokeLoader(b_ob_info.real_object, std);
ImageParams params;
params.frame = frame;
@@ -244,11 +247,11 @@ class BlenderVolumeLoader : public VDBImageLoader {
};
static void sync_volume_object(BL::BlendData &b_data,
BL::Object &b_ob,
BObjectInfo &b_ob_info,
Scene *scene,
Volume *volume)
{
BL::Volume b_volume(b_ob.data());
BL::Volume b_volume(b_ob_info.object_data);
b_volume.grids.load(b_data.ptr.data);
BL::VolumeRender b_render(b_volume.render());
@@ -296,19 +299,19 @@ static void sync_volume_object(BL::BlendData &b_data,
}
}
void BlenderSync::sync_volume(BL::Object &b_ob, Volume *volume)
void BlenderSync::sync_volume(BObjectInfo &b_ob_info, Volume *volume)
{
volume->clear(true);
if (view_layer.use_volumes) {
if (b_ob.type() == BL::Object::type_VOLUME) {
if (b_ob_info.object_data.is_a(&RNA_Volume)) {
/* Volume object. Create only attributes, bounding mesh will then
* be automatically generated later. */
sync_volume_object(b_data, b_ob, scene, volume);
sync_volume_object(b_data, b_ob_info, scene, volume);
}
else {
/* Smoke domain. */
sync_smoke_volume(scene, b_ob, volume, b_scene.frame_current());
sync_smoke_volume(scene, b_ob_info, volume, b_scene.frame_current());
}
}

View File

@@ -13,7 +13,7 @@
# limitations under the License.
function(cycles_set_solution_folder target)
if(WINDOWS_USE_VISUAL_STUDIO_FOLDERS)
if(IDE_GROUP_PROJECTS_IN_FOLDERS)
get_filename_component(folderdir ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
string(REPLACE ${CMAKE_SOURCE_DIR} "" folderdir ${folderdir})
set_target_properties(${target} PROPERTIES FOLDER ${folderdir})

View File

@@ -1050,7 +1050,7 @@ ccl_device int bsdf_microfacet_beckmann_sample(KernelGlobals *kg,
float D, G1i;
if (alpha_x == alpha_y) {
/* istropic distribution */
/* Isotropic distribution. */
float cosThetaM2 = cosThetaM * cosThetaM;
float cosThetaM4 = cosThetaM2 * cosThetaM2;
float tanThetaM2 = 1 / (cosThetaM2)-1;

View File

@@ -36,10 +36,10 @@ static_assert(sizeof(ShaderClosure) >= sizeof(PrincipledDiffuseBsdf),
ccl_device float3 calculate_principled_diffuse_brdf(
const PrincipledDiffuseBsdf *bsdf, float3 N, float3 V, float3 L, float3 H, float *pdf)
{
float NdotL = max(dot(N, L), 0.0f);
float NdotV = max(dot(N, V), 0.0f);
float NdotL = dot(N, L);
float NdotV = dot(N, V);
if (NdotL < 0 || NdotV < 0) {
if (NdotL <= 0 || NdotV <= 0) {
*pdf = 0.0f;
return make_float3(0.0f, 0.0f, 0.0f);
}

View File

@@ -107,6 +107,27 @@ triangle_smooth_normal(KernelGlobals *kg, float3 Ng, int prim, float u, float v)
return is_zero(N) ? Ng : N;
}
ccl_device_inline float3 triangle_smooth_normal_unnormalized(
KernelGlobals *kg, ShaderData *sd, float3 Ng, int prim, float u, float v)
{
/* load triangle vertices */
const uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, prim);
float3 n0 = float4_to_float3(kernel_tex_fetch(__tri_vnormal, tri_vindex.x));
float3 n1 = float4_to_float3(kernel_tex_fetch(__tri_vnormal, tri_vindex.y));
float3 n2 = float4_to_float3(kernel_tex_fetch(__tri_vnormal, tri_vindex.z));
/* ensure that the normals are in object space */
if (sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED) {
object_inverse_normal_transform(kg, sd, &n0);
object_inverse_normal_transform(kg, sd, &n1);
object_inverse_normal_transform(kg, sd, &n2);
}
float3 N = (1.0f - u - v) * n2 + u * n0 + v * n1;
return is_zero(N) ? Ng : N;
}
/* Ray differentials on triangle */
ccl_device_inline void triangle_dPdudv(KernelGlobals *kg,

View File

@@ -58,7 +58,9 @@ shader node_texture_coordinate(
getattribute("geom:uv", UV);
}
else {
getattribute("geom:generated", Generated);
if (!getattribute("geom:generated", Generated)) {
Generated = transform("object", P);
}
getattribute("geom:uv", UV);
}

View File

@@ -72,6 +72,22 @@ ccl_device void svm_node_attr(KernelGlobals *kg, ShaderData *sd, float *stack, u
}
#endif
if (node.y == ATTR_STD_GENERATED && desc.element == ATTR_ELEMENT_NONE) {
/* No generated attribute, fall back to object coordinates. */
float3 f = sd->P;
object_inverse_position_transform(kg, sd, &f);
if (type == NODE_ATTR_OUTPUT_FLOAT) {
stack_store_float(stack, out_offset, average(f));
}
else if (type == NODE_ATTR_OUTPUT_FLOAT3) {
stack_store_float3(stack, out_offset, f);
}
else {
stack_store_float(stack, out_offset, 1.0f);
}
return;
}
/* Surface. */
if (desc.type == NODE_ATTR_FLOAT) {
float f = primitive_surface_attribute_float(kg, sd, desc, NULL, NULL);
@@ -145,6 +161,22 @@ ccl_device void svm_node_attr_bump_dx(KernelGlobals *kg, ShaderData *sd, float *
}
#endif
if (node.y == ATTR_STD_GENERATED && desc.element == ATTR_ELEMENT_NONE) {
/* No generated attribute, fall back to object coordinates. */
float3 f = sd->P + sd->dP.dx;
object_inverse_position_transform(kg, sd, &f);
if (type == NODE_ATTR_OUTPUT_FLOAT) {
stack_store_float(stack, out_offset, average(f));
}
else if (type == NODE_ATTR_OUTPUT_FLOAT3) {
stack_store_float3(stack, out_offset, f);
}
else {
stack_store_float(stack, out_offset, 1.0f);
}
return;
}
/* Surface */
if (desc.type == NODE_ATTR_FLOAT) {
float dx;
@@ -222,6 +254,22 @@ ccl_device void svm_node_attr_bump_dy(KernelGlobals *kg, ShaderData *sd, float *
}
#endif
if (node.y == ATTR_STD_GENERATED && desc.element == ATTR_ELEMENT_NONE) {
/* No generated attribute, fall back to object coordinates. */
float3 f = sd->P + sd->dP.dy;
object_inverse_position_transform(kg, sd, &f);
if (type == NODE_ATTR_OUTPUT_FLOAT) {
stack_store_float(stack, out_offset, average(f));
}
else if (type == NODE_ATTR_OUTPUT_FLOAT3) {
stack_store_float3(stack, out_offset, f);
}
else {
stack_store_float(stack, out_offset, 1.0f);
}
return;
}
/* Surface */
if (desc.type == NODE_ATTR_FLOAT) {
float dy;

View File

@@ -267,7 +267,7 @@ ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *st
if (space == NODE_NORMAL_MAP_TANGENT) {
/* tangent space */
if (sd->object == OBJECT_NONE) {
if (sd->object == OBJECT_NONE || (sd->type & PRIMITIVE_ALL_TRIANGLE) == 0) {
/* Fallback to unperturbed normal. */
stack_store_float3(stack, normal_offset, sd->N);
return;
@@ -276,10 +276,8 @@ ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *st
/* first try to get tangent attribute */
const AttributeDescriptor attr = find_attribute(kg, sd, node.z);
const AttributeDescriptor attr_sign = find_attribute(kg, sd, node.w);
const AttributeDescriptor attr_normal = find_attribute(kg, sd, ATTR_STD_VERTEX_NORMAL);
if (attr.offset == ATTR_STD_NOT_FOUND || attr_sign.offset == ATTR_STD_NOT_FOUND ||
attr_normal.offset == ATTR_STD_NOT_FOUND) {
if (attr.offset == ATTR_STD_NOT_FOUND || attr_sign.offset == ATTR_STD_NOT_FOUND) {
/* Fallback to unperturbed normal. */
stack_store_float3(stack, normal_offset, sd->N);
return;
@@ -291,7 +289,7 @@ ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *st
float3 normal;
if (sd->shader & SHADER_SMOOTH_NORMAL) {
normal = primitive_surface_attribute_float3(kg, sd, attr_normal, NULL, NULL);
normal = triangle_smooth_normal_unnormalized(kg, sd, sd->Ng, sd->prim, sd->u, sd->v);
}
else {
normal = sd->Ng;

View File

@@ -25,6 +25,7 @@
#include "render/shader.h"
#include "util/util_foreach.h"
#include "util/util_logging.h"
#include "util/util_progress.h"
#include "util/util_transform.h"
#include "util/util_vector.h"
@@ -211,6 +212,35 @@ void CachedData::set_time_sampling(TimeSampling time_sampling)
}
}
size_t CachedData::memory_used() const
{
size_t mem_used = 0;
mem_used += curve_first_key.memory_used();
mem_used += curve_keys.memory_used();
mem_used += curve_radius.memory_used();
mem_used += curve_shader.memory_used();
mem_used += num_ngons.memory_used();
mem_used += shader.memory_used();
mem_used += subd_creases_edge.memory_used();
mem_used += subd_creases_weight.memory_used();
mem_used += subd_face_corners.memory_used();
mem_used += subd_num_corners.memory_used();
mem_used += subd_ptex_offset.memory_used();
mem_used += subd_smooth.memory_used();
mem_used += subd_start_corner.memory_used();
mem_used += transforms.memory_used();
mem_used += triangles.memory_used();
mem_used += uv_loops.memory_used();
mem_used += vertices.memory_used();
for (const CachedAttribute &attr : attributes) {
mem_used += attr.data.memory_used();
}
return mem_used;
}
static M44d convert_yup_zup(const M44d &mtx, float scale_mult)
{
V3d scale, shear, rotation, translation;
@@ -385,6 +415,8 @@ NODE_DEFINE(AlembicObject)
SOCKET_STRING(path, "Alembic Path", ustring());
SOCKET_NODE_ARRAY(used_shaders, "Used Shaders", Shader::get_node_type());
SOCKET_BOOLEAN(ignore_subdivision, "Ignore Subdivision", true);
SOCKET_INT(subd_max_level, "Max Subdivision Level", 1);
SOCKET_FLOAT(subd_dicing_rate, "Subdivision Dicing Rate", 1.0f);
@@ -470,6 +502,33 @@ void AlembicObject::load_data_in_cache(CachedData &cached_data,
cached_data.clear();
if (this->get_ignore_subdivision()) {
PolyMeshSchemaData data;
data.topology_variance = schema.getTopologyVariance();
data.time_sampling = schema.getTimeSampling();
data.positions = schema.getPositionsProperty();
data.face_counts = schema.getFaceCountsProperty();
data.face_indices = schema.getFaceIndicesProperty();
data.num_samples = schema.getNumSamples();
data.velocities = schema.getVelocitiesProperty();
data.shader_face_sets = parse_face_sets_for_shader_assignment(schema, get_used_shaders());
read_geometry_data(proc, cached_data, data, progress);
if (progress.get_cancel()) {
return;
}
/* Use the schema as the base compound property to also be able to look for top level
* properties. */
read_attributes(
proc, cached_data, schema, schema.getUVsParam(), get_requested_attributes(), progress);
cached_data.invalidate_last_loaded_time(true);
data_loaded = true;
return;
}
SubDSchemaData data;
data.time_sampling = schema.getTimeSampling();
data.num_samples = schema.getNumSamples();
@@ -677,6 +736,9 @@ NODE_DEFINE(AlembicProcedural)
SOCKET_NODE_ARRAY(objects, "Objects", AlembicObject::get_node_type());
SOCKET_BOOLEAN(use_prefetch, "Use Prefetch", true);
SOCKET_INT(prefetch_cache_size, "Prefetch Cache Size", 4096);
return type;
}
@@ -781,6 +843,43 @@ void AlembicProcedural::generate(Scene *scene, Progress &progress)
const chrono_t frame_time = (chrono_t)((frame - frame_offset) / frame_rate);
/* Clear the subdivision caches as the data is stored differently. */
for (Node *node : objects) {
AlembicObject *object = static_cast<AlembicObject *>(node);
if (object->schema_type != AlembicObject::SUBD) {
continue;
}
if (object->ignore_subdivision_is_modified()) {
object->clear_cache();
}
}
if (use_prefetch_is_modified()) {
if (!use_prefetch) {
for (Node *node : objects) {
AlembicObject *object = static_cast<AlembicObject *>(node);
object->clear_cache();
}
}
}
if (prefetch_cache_size_is_modified()) {
/* Check whether the current memory usage fits in the new requested size,
* abort the render if it is any higher. */
size_t memory_used = 0ul;
for (Node *node : objects) {
AlembicObject *object = static_cast<AlembicObject *>(node);
memory_used += object->get_cached_data().memory_used();
}
if (memory_used > get_prefetch_cache_size_in_bytes()) {
progress.set_error("Error: Alembic Procedural memory limit reached");
return;
}
}
build_caches(progress);
foreach (Node *node, objects) {
@@ -959,14 +1058,6 @@ void AlembicProcedural::read_mesh(AlembicObject *abc_object, Abc::chrono_t frame
update_attributes(mesh->attributes, cached_data, frame_time);
/* we don't yet support arbitrary attributes, for now add vertex
* coordinates as generated coordinates if requested */
if (mesh->need_attribute(scene_, ATTR_STD_GENERATED)) {
Attribute *attr = mesh->attributes.add(ATTR_STD_GENERATED);
memcpy(
attr->data_float3(), mesh->get_verts().data(), sizeof(float3) * mesh->get_verts().size());
}
if (mesh->is_modified()) {
bool need_rebuild = mesh->triangles_is_modified();
mesh->tag_update(scene_, need_rebuild);
@@ -975,13 +1066,13 @@ void AlembicProcedural::read_mesh(AlembicObject *abc_object, Abc::chrono_t frame
void AlembicProcedural::read_subd(AlembicObject *abc_object, Abc::chrono_t frame_time)
{
CachedData &cached_data = abc_object->get_cached_data();
if (abc_object->subd_max_level_is_modified() || abc_object->subd_dicing_rate_is_modified()) {
/* need to reset the current data is something changed */
cached_data.invalidate_last_loaded_time();
if (abc_object->get_ignore_subdivision()) {
read_mesh(abc_object, frame_time);
return;
}
CachedData &cached_data = abc_object->get_cached_data();
/* Update sockets. */
Object *object = abc_object->get_object();
@@ -996,6 +1087,11 @@ void AlembicProcedural::read_subd(AlembicObject *abc_object, Abc::chrono_t frame
return;
}
if (abc_object->subd_max_level_is_modified() || abc_object->subd_dicing_rate_is_modified()) {
/* need to reset the current data is something changed */
cached_data.invalidate_last_loaded_time();
}
Mesh *mesh = static_cast<Mesh *>(object->get_geometry());
/* Make sure shader ids are also updated. */
@@ -1053,14 +1149,6 @@ void AlembicProcedural::read_subd(AlembicObject *abc_object, Abc::chrono_t frame
update_attributes(mesh->subd_attributes, cached_data, frame_time);
/* we don't yet support arbitrary attributes, for now add vertex
* coordinates as generated coordinates if requested */
if (mesh->need_attribute(scene_, ATTR_STD_GENERATED)) {
Attribute *attr = mesh->attributes.add(ATTR_STD_GENERATED);
memcpy(
attr->data_float3(), mesh->get_verts().data(), sizeof(float3) * mesh->get_verts().size());
}
if (mesh->is_modified()) {
bool need_rebuild = (mesh->triangles_is_modified()) ||
(mesh->subd_num_corners_is_modified()) ||
@@ -1110,17 +1198,6 @@ void AlembicProcedural::read_curves(AlembicObject *abc_object, Abc::chrono_t fra
update_attributes(hair->attributes, cached_data, frame_time);
/* we don't yet support arbitrary attributes, for now add first keys as generated coordinates if
* requested */
if (hair->need_attribute(scene_, ATTR_STD_GENERATED)) {
Attribute *attr_generated = hair->attributes.add(ATTR_STD_GENERATED);
float3 *generated = attr_generated->data_float3();
for (size_t i = 0; i < hair->num_curves(); i++) {
generated[i] = hair->get_curve_keys()[hair->get_curve(i).first_key];
}
}
const bool rebuild = (hair->curve_keys_is_modified() || hair->curve_radius_is_modified());
hair->tag_update(scene_, rebuild);
}
@@ -1280,6 +1357,8 @@ void AlembicProcedural::walk_hierarchy(
void AlembicProcedural::build_caches(Progress &progress)
{
size_t memory_used = 0;
for (Node *node : objects) {
AlembicObject *object = static_cast<AlembicObject *>(node);
@@ -1333,7 +1412,18 @@ void AlembicProcedural::build_caches(Progress &progress)
if (scale_is_modified() || object->get_cached_data().transforms.size() == 0) {
object->setup_transform_cache(object->get_cached_data(), scale);
}
memory_used += object->get_cached_data().memory_used();
if (use_prefetch) {
if (memory_used > get_prefetch_cache_size_in_bytes()) {
progress.set_error("Error: Alembic Procedural memory limit reached");
return;
}
}
}
VLOG(1) << "AlembicProcedural memory usage : " << string_human_readable_size(memory_used);
}
CCL_NAMESPACE_END

View File

@@ -272,6 +272,21 @@ template<typename T> class DataStore {
node->set(*socket, value);
}
size_t memory_used() const
{
if constexpr (is_array<T>::value) {
size_t mem_used = 0;
for (const T &array : data) {
mem_used += array.size() * sizeof(array[0]);
}
return mem_used;
}
return data.size() * sizeof(T);
}
private:
const TimeIndexPair &get_index_for_time(double time) const
{
@@ -332,6 +347,8 @@ struct CachedData {
void invalidate_last_loaded_time(bool attributes_only = false);
void set_time_sampling(Alembic::AbcCoreAbstract::TimeSampling time_sampling);
size_t memory_used() const;
};
/* Representation of an Alembic object for the AlembicProcedural.
@@ -353,6 +370,10 @@ class AlembicObject : public Node {
/* Shaders used for rendering. */
NODE_SOCKET_API_ARRAY(array<Node *>, used_shaders)
/* Treat this subdivision object as a regular polygon mesh, so no subdivision will be performed.
*/
NODE_SOCKET_API(bool, ignore_subdivision)
/* Maximum number of subdivisions for ISubD objects. */
NODE_SOCKET_API(int, subd_max_level)
@@ -416,6 +437,11 @@ class AlembicObject : public Node {
return cached_data_.is_constant();
}
void clear_cache()
{
cached_data_.clear();
}
Object *object = nullptr;
bool data_loaded = false;
@@ -473,6 +499,13 @@ class AlembicProcedural : public Procedural {
* software. */
NODE_SOCKET_API(float, scale)
/* Cache controls */
NODE_SOCKET_API(bool, use_prefetch)
/* Memory limit for the cache, if the data does not fit within this limit, rendering is aborted.
*/
NODE_SOCKET_API(int, prefetch_cache_size)
AlembicProcedural();
~AlembicProcedural();
@@ -522,6 +555,12 @@ class AlembicProcedural : public Procedural {
void read_subd(AlembicObject *abc_object, Alembic::AbcGeom::Abc::chrono_t frame_time);
void build_caches(Progress &progress);
size_t get_prefetch_cache_size_in_bytes() const
{
/* prefetch_cache_size is in megabytes, so convert to bytes. */
return static_cast<size_t>(prefetch_cache_size) * 1024 * 1024;
}
};
CCL_NAMESPACE_END

View File

@@ -44,9 +44,19 @@ static set<chrono_t> get_relevant_sample_times(AlembicProcedural *proc,
return result;
}
// load the data for the entire animation
const double start_frame = static_cast<double>(proc->get_start_frame());
const double end_frame = static_cast<double>(proc->get_end_frame());
double start_frame;
double end_frame;
if (proc->get_use_prefetch()) {
// load the data for the entire animation
start_frame = static_cast<double>(proc->get_start_frame());
end_frame = static_cast<double>(proc->get_end_frame());
}
else {
// load the data for the current frame
start_frame = static_cast<double>(proc->get_frame());
end_frame = start_frame;
}
const double frame_rate = static_cast<double>(proc->get_frame_rate());
const double start_time = start_frame / frame_rate;

View File

@@ -788,6 +788,11 @@ void GeometryManager::device_update_attributes(Device *device,
foreach (AttributeRequest &req, attributes.requests) {
Attribute *attr = geom->attributes.find(req);
/* Vertex normals are stored in DeviceScene.tri_vnormal. */
if (attr && attr->std == ATTR_STD_VERTEX_NORMAL) {
continue;
}
update_attribute_element_size(geom,
attr,
ATTR_PRIM_GEOMETRY,
@@ -800,6 +805,11 @@ void GeometryManager::device_update_attributes(Device *device,
Mesh *mesh = static_cast<Mesh *>(geom);
Attribute *subd_attr = mesh->subd_attributes.find(req);
/* Vertex normals are stored in DeviceScene.tri_vnormal. */
if (subd_attr && subd_attr->std == ATTR_STD_VERTEX_NORMAL) {
continue;
}
update_attribute_element_size(mesh,
subd_attr,
ATTR_PRIM_SUBD,
@@ -854,6 +864,11 @@ void GeometryManager::device_update_attributes(Device *device,
Attribute *attr = geom->attributes.find(req);
if (attr) {
/* Vertex normals are stored in DeviceScene.tri_vnormal. */
if (attr->std == ATTR_STD_VERTEX_NORMAL) {
continue;
}
/* force a copy if we need to reallocate all the data */
attr->modified |= attributes_need_realloc[Attribute::kernel_type(*attr)];
}
@@ -877,6 +892,11 @@ void GeometryManager::device_update_attributes(Device *device,
Attribute *subd_attr = mesh->subd_attributes.find(req);
if (subd_attr) {
/* Vertex normals are stored in DeviceScene.tri_vnormal. */
if (subd_attr->std == ATTR_STD_VERTEX_NORMAL) {
continue;
}
/* force a copy if we need to reallocate all the data */
subd_attr->modified |= attributes_need_realloc[Attribute::kernel_type(*subd_attr)];
}

View File

@@ -158,13 +158,13 @@ void ShaderNode::attributes(Shader *shader, AttributeRequestSet *attributes)
foreach (ShaderInput *input, inputs) {
if (!input->link) {
if (input->flags() & SocketType::LINK_TEXTURE_GENERATED) {
if (shader->has_surface)
if (shader->has_surface_link())
attributes->add(ATTR_STD_GENERATED);
if (shader->has_volume)
attributes->add(ATTR_STD_GENERATED_TRANSFORM);
}
else if (input->flags() & SocketType::LINK_TEXTURE_UV) {
if (shader->has_surface)
if (shader->has_surface_link())
attributes->add(ATTR_STD_UV);
}
}

View File

@@ -410,38 +410,39 @@ void LightManager::device_update_distribution(Device *,
}
float trianglearea = totarea;
/* point lights */
float lightarea = (totarea > 0.0f) ? totarea / num_lights : 1.0f;
bool use_lamp_mis = false;
int light_index = 0;
foreach (Light *light, scene->lights) {
if (!light->is_enabled)
continue;
if (num_lights > 0) {
float lightarea = (totarea > 0.0f) ? totarea / num_lights : 1.0f;
foreach (Light *light, scene->lights) {
if (!light->is_enabled)
continue;
distribution[offset].totarea = totarea;
distribution[offset].prim = ~light_index;
distribution[offset].lamp.pad = 1.0f;
distribution[offset].lamp.size = light->size;
totarea += lightarea;
distribution[offset].totarea = totarea;
distribution[offset].prim = ~light_index;
distribution[offset].lamp.pad = 1.0f;
distribution[offset].lamp.size = light->size;
totarea += lightarea;
if (light->light_type == LIGHT_DISTANT) {
use_lamp_mis |= (light->angle > 0.0f && light->use_mis);
}
else if (light->light_type == LIGHT_POINT || light->light_type == LIGHT_SPOT) {
use_lamp_mis |= (light->size > 0.0f && light->use_mis);
}
else if (light->light_type == LIGHT_AREA) {
use_lamp_mis |= light->use_mis;
}
else if (light->light_type == LIGHT_BACKGROUND) {
num_background_lights++;
background_mis |= light->use_mis;
}
if (light->light_type == LIGHT_DISTANT) {
use_lamp_mis |= (light->angle > 0.0f && light->use_mis);
}
else if (light->light_type == LIGHT_POINT || light->light_type == LIGHT_SPOT) {
use_lamp_mis |= (light->size > 0.0f && light->use_mis);
}
else if (light->light_type == LIGHT_AREA) {
use_lamp_mis |= light->use_mis;
}
else if (light->light_type == LIGHT_BACKGROUND) {
num_background_lights++;
background_mis |= light->use_mis;
}
light_index++;
offset++;
light_index++;
offset++;
}
}
/* normalize cumulative distribution functions */

View File

@@ -350,7 +350,7 @@ void ImageTextureNode::attributes(Shader *shader, AttributeRequestSet *attribute
#ifdef WITH_PTEX
/* todo: avoid loading other texture coordinates when using ptex,
* and hide texture coordinate socket in the UI */
if (shader->has_surface && string_endswith(filename, ".ptx")) {
if (shader->has_surface_link() && string_endswith(filename, ".ptx")) {
/* ptex */
attributes->add(ATTR_STD_PTEX_FACE_ID);
attributes->add(ATTR_STD_PTEX_UV);
@@ -552,7 +552,7 @@ ImageParams EnvironmentTextureNode::image_params() const
void EnvironmentTextureNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
#ifdef WITH_PTEX
if (shader->has_surface && string_endswith(filename, ".ptx")) {
if (shader->has_surface_link() && string_endswith(filename, ".ptx")) {
/* ptex */
attributes->add(ATTR_STD_PTEX_FACE_ID);
attributes->add(ATTR_STD_PTEX_UV);
@@ -2319,7 +2319,7 @@ AnisotropicBsdfNode::AnisotropicBsdfNode() : BsdfNode(get_node_type())
void AnisotropicBsdfNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
if (shader->has_surface) {
if (shader->has_surface_link()) {
ShaderInput *tangent_in = input("Tangent");
if (!tangent_in->link)
@@ -2843,7 +2843,7 @@ bool PrincipledBsdfNode::has_surface_bssrdf()
void PrincipledBsdfNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
if (shader->has_surface) {
if (shader->has_surface_link()) {
ShaderInput *tangent_in = input("Tangent");
if (!tangent_in->link)
@@ -3684,7 +3684,7 @@ GeometryNode::GeometryNode() : ShaderNode(get_node_type())
void GeometryNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
if (shader->has_surface) {
if (shader->has_surface_link()) {
if (!output("Tangent")->links.empty()) {
attributes->add(ATTR_STD_GENERATED);
}
@@ -3830,7 +3830,7 @@ TextureCoordinateNode::TextureCoordinateNode() : ShaderNode(get_node_type())
void TextureCoordinateNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
if (shader->has_surface) {
if (shader->has_surface_link()) {
if (!from_dupli) {
if (!output("Generated")->links.empty())
attributes->add(ATTR_STD_GENERATED);
@@ -4388,7 +4388,7 @@ HairInfoNode::HairInfoNode() : ShaderNode(get_node_type())
void HairInfoNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
if (shader->has_surface) {
if (shader->has_surface_link()) {
ShaderOutput *intercept_out = output("Intercept");
if (!intercept_out->links.empty())
@@ -6744,7 +6744,7 @@ NormalMapNode::NormalMapNode() : ShaderNode(get_node_type())
void NormalMapNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
if (shader->has_surface && space == NODE_NORMAL_MAP_TANGENT) {
if (shader->has_surface_link() && space == NODE_NORMAL_MAP_TANGENT) {
if (attribute.empty()) {
attributes->add(ATTR_STD_UV_TANGENT);
attributes->add(ATTR_STD_UV_TANGENT_SIGN);
@@ -6838,7 +6838,7 @@ TangentNode::TangentNode() : ShaderNode(get_node_type())
void TangentNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
if (shader->has_surface) {
if (shader->has_surface_link()) {
if (direction_type == NODE_TANGENT_UVMAP) {
if (attribute.empty())
attributes->add(ATTR_STD_UV_TANGENT);
@@ -7021,7 +7021,7 @@ void VectorDisplacementNode::constant_fold(const ConstantFolder &folder)
void VectorDisplacementNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
if (shader->has_surface && space == NODE_NORMAL_MAP_TANGENT) {
if (shader->has_surface_link() && space == NODE_NORMAL_MAP_TANGENT) {
if (attribute.empty()) {
attributes->add(ATTR_STD_UV_TANGENT);
attributes->add(ATTR_STD_UV_TANGENT_SIGN);

View File

@@ -57,23 +57,26 @@ Session::Session(const SessionParams &params_)
stats(),
profiler()
{
device_use_gl = ((params.device.type != DEVICE_CPU) && !params.background);
device_use_gl_ = ((params.device.type != DEVICE_CPU) && !params.background);
TaskScheduler::init(params.threads);
session_thread = NULL;
session_thread_ = NULL;
scene = NULL;
reset_time = 0.0;
last_update_time = 0.0;
reset_time_ = 0.0;
last_update_time_ = 0.0;
delayed_reset.do_reset = false;
delayed_reset.samples = 0;
delayed_reset_.do_reset = false;
delayed_reset_.samples = 0;
display_outdated = false;
gpu_draw_ready = false;
gpu_need_display_buffer_update = false;
pause = false;
display_outdated_ = false;
gpu_draw_ready_ = false;
gpu_need_display_buffer_update_ = false;
pause_ = false;
cancel_ = false;
new_work_added_ = false;
buffers = NULL;
display = NULL;
@@ -127,25 +130,26 @@ Session::~Session()
void Session::start()
{
if (!session_thread) {
session_thread = new thread(function_bind(&Session::run, this));
if (!session_thread_) {
session_thread_ = new thread(function_bind(&Session::run, this));
}
}
void Session::cancel()
{
if (session_thread) {
if (session_thread_) {
/* wait for session thread to end */
progress.set_cancel("Exiting");
gpu_need_display_buffer_update = false;
gpu_need_display_buffer_update_cond.notify_all();
gpu_need_display_buffer_update_ = false;
gpu_need_display_buffer_update_cond_.notify_all();
{
thread_scoped_lock pause_lock(pause_mutex);
pause = false;
thread_scoped_lock pause_lock(pause_mutex_);
pause_ = false;
cancel_ = true;
}
pause_cond.notify_all();
pause_cond_.notify_all();
wait();
}
@@ -153,9 +157,9 @@ void Session::cancel()
bool Session::ready_to_reset()
{
double dt = time_dt() - reset_time;
double dt = time_dt() - reset_time_;
if (!display_outdated)
if (!display_outdated_)
return (dt > params.reset_timeout);
else
return (dt > params.cancel_timeout);
@@ -165,48 +169,50 @@ bool Session::ready_to_reset()
void Session::reset_gpu(BufferParams &buffer_params, int samples)
{
thread_scoped_lock pause_lock(pause_mutex);
thread_scoped_lock pause_lock(pause_mutex_);
/* block for buffer access and reset immediately. we can't do this
* in the thread, because we need to allocate an OpenGL buffer, and
* that only works in the main thread */
thread_scoped_lock display_lock(display_mutex);
thread_scoped_lock buffers_lock(buffers_mutex);
thread_scoped_lock display_lock(display_mutex_);
thread_scoped_lock buffers_lock(buffers_mutex_);
display_outdated = true;
reset_time = time_dt();
display_outdated_ = true;
reset_time_ = time_dt();
reset_(buffer_params, samples);
gpu_need_display_buffer_update = false;
gpu_need_display_buffer_update_cond.notify_all();
gpu_need_display_buffer_update_ = false;
gpu_need_display_buffer_update_cond_.notify_all();
pause_cond.notify_all();
new_work_added_ = true;
pause_cond_.notify_all();
}
bool Session::draw_gpu(BufferParams &buffer_params, DeviceDrawParams &draw_params)
{
/* block for buffer access */
thread_scoped_lock display_lock(display_mutex);
thread_scoped_lock display_lock(display_mutex_);
/* first check we already rendered something */
if (gpu_draw_ready) {
if (gpu_draw_ready_) {
/* then verify the buffers have the expected size, so we don't
* draw previous results in a resized window */
if (buffer_params.width == display->params.width &&
buffer_params.height == display->params.height) {
/* for CUDA we need to do tone-mapping still, since we can
* only access GL buffers from the main thread. */
if (gpu_need_display_buffer_update) {
thread_scoped_lock buffers_lock(buffers_mutex);
if (gpu_need_display_buffer_update_) {
thread_scoped_lock buffers_lock(buffers_mutex_);
copy_to_display_buffer(tile_manager.state.sample);
gpu_need_display_buffer_update = false;
gpu_need_display_buffer_update_cond.notify_all();
gpu_need_display_buffer_update_ = false;
gpu_need_display_buffer_update_cond_.notify_all();
}
display->draw(device, draw_params);
if (display_outdated && (time_dt() - reset_time) > params.text_timeout)
if (display_outdated_ && (time_dt() - reset_time_) > params.text_timeout)
return false;
return true;
@@ -220,9 +226,9 @@ void Session::run_gpu()
{
bool tiles_written = false;
reset_time = time_dt();
last_update_time = time_dt();
last_display_time = last_update_time;
reset_time_ = time_dt();
last_update_time_ = time_dt();
last_display_time_ = last_update_time_;
progress.set_render_start_time();
@@ -255,7 +261,7 @@ void Session::run_gpu()
/* buffers mutex is locked entirely while rendering each
* sample, and released/reacquired on each iteration to allow
* reset and draw in between */
thread_scoped_lock buffers_lock(buffers_mutex);
thread_scoped_lock buffers_lock(buffers_mutex_);
/* update status and timing */
update_status_time();
@@ -273,17 +279,17 @@ void Session::run_gpu()
/* update status and timing */
update_status_time();
gpu_need_display_buffer_update = !delayed_denoise;
gpu_draw_ready = true;
gpu_need_display_buffer_update_ = !delayed_denoise;
gpu_draw_ready_ = true;
progress.set_update();
/* wait for until display buffer is updated */
if (!params.background) {
while (gpu_need_display_buffer_update) {
while (gpu_need_display_buffer_update_) {
if (progress.get_cancel())
break;
gpu_need_display_buffer_update_cond.wait(buffers_lock);
gpu_need_display_buffer_update_cond_.wait(buffers_lock);
}
}
@@ -305,23 +311,23 @@ void Session::run_gpu()
void Session::reset_cpu(BufferParams &buffer_params, int samples)
{
thread_scoped_lock reset_lock(delayed_reset.mutex);
thread_scoped_lock pause_lock(pause_mutex);
thread_scoped_lock reset_lock(delayed_reset_.mutex);
thread_scoped_lock pause_lock(pause_mutex_);
display_outdated = true;
reset_time = time_dt();
display_outdated_ = true;
reset_time_ = time_dt();
delayed_reset.params = buffer_params;
delayed_reset.samples = samples;
delayed_reset.do_reset = true;
delayed_reset_.params = buffer_params;
delayed_reset_.samples = samples;
delayed_reset_.do_reset = true;
device->task_cancel();
pause_cond.notify_all();
pause_cond_.notify_all();
}
bool Session::draw_cpu(BufferParams &buffer_params, DeviceDrawParams &draw_params)
{
thread_scoped_lock display_lock(display_mutex);
thread_scoped_lock display_lock(display_mutex_);
/* first check we already rendered something */
if (display->draw_ready()) {
@@ -331,7 +337,7 @@ bool Session::draw_cpu(BufferParams &buffer_params, DeviceDrawParams &draw_param
buffer_params.height == display->params.height) {
display->draw(device, draw_params);
if (display_outdated && (time_dt() - reset_time) > params.text_timeout)
if (display_outdated_ && (time_dt() - reset_time_) > params.text_timeout)
return false;
return true;
@@ -345,46 +351,46 @@ bool Session::steal_tile(RenderTile &rtile, Device *tile_device, thread_scoped_l
{
/* Devices that can get their tiles stolen don't steal tiles themselves.
* Additionally, if there are no stealable tiles in flight, give up here. */
if (tile_device->info.type == DEVICE_CPU || stealable_tiles == 0) {
if (tile_device->info.type == DEVICE_CPU || stealable_tiles_ == 0) {
return false;
}
/* Wait until no other thread is trying to steal a tile. */
while (tile_stealing_state != NOT_STEALING && stealable_tiles > 0) {
while (tile_stealing_state_ != NOT_STEALING && stealable_tiles_ > 0) {
/* Someone else is currently trying to get a tile.
* Wait on the condition variable and try later. */
tile_steal_cond.wait(tile_lock);
tile_steal_cond_.wait(tile_lock);
}
/* If another thread stole the last stealable tile in the meantime, give up. */
if (stealable_tiles == 0) {
if (stealable_tiles_ == 0) {
return false;
}
/* There are stealable tiles in flight, so signal that one should be released. */
tile_stealing_state = WAITING_FOR_TILE;
tile_stealing_state_ = WAITING_FOR_TILE;
/* Wait until a device notices the signal and releases its tile. */
while (tile_stealing_state != GOT_TILE && stealable_tiles > 0) {
tile_steal_cond.wait(tile_lock);
while (tile_stealing_state_ != GOT_TILE && stealable_tiles_ > 0) {
tile_steal_cond_.wait(tile_lock);
}
/* If the last stealable tile finished on its own, give up. */
if (tile_stealing_state != GOT_TILE) {
tile_stealing_state = NOT_STEALING;
if (tile_stealing_state_ != GOT_TILE) {
tile_stealing_state_ = NOT_STEALING;
return false;
}
/* Successfully stole a tile, now move it to the new device. */
rtile = stolen_tile;
rtile = stolen_tile_;
rtile.buffers->buffer.move_device(tile_device);
rtile.buffer = rtile.buffers->buffer.device_pointer;
rtile.stealing_state = RenderTile::NO_STEALING;
rtile.num_samples -= (rtile.sample - rtile.start_sample);
rtile.start_sample = rtile.sample;
tile_stealing_state = NOT_STEALING;
tile_stealing_state_ = NOT_STEALING;
/* Poke any threads which might be waiting for NOT_STEALING above. */
tile_steal_cond.notify_one();
tile_steal_cond_.notify_one();
return true;
}
@@ -394,7 +400,7 @@ bool Session::get_tile_stolen()
/* If tile_stealing_state is WAITING_FOR_TILE, atomically set it to RELEASING_TILE
* and return true. */
TileStealingState expected = WAITING_FOR_TILE;
return tile_stealing_state.compare_exchange_weak(expected, RELEASING_TILE);
return tile_stealing_state_.compare_exchange_weak(expected, RELEASING_TILE);
}
bool Session::acquire_tile(RenderTile &rtile, Device *tile_device, uint tile_types)
@@ -406,7 +412,7 @@ bool Session::acquire_tile(RenderTile &rtile, Device *tile_device, uint tile_typ
}
}
thread_scoped_lock tile_lock(tile_mutex);
thread_scoped_lock tile_lock(tile_mutex_);
/* get next tile from manager */
Tile *tile;
@@ -423,7 +429,7 @@ bool Session::acquire_tile(RenderTile &rtile, Device *tile_device, uint tile_typ
/* Wait for denoising tiles to become available */
if ((tile_types & RenderTile::DENOISE) && !progress.get_cancel() && tile_manager.has_tiles()) {
denoising_cond.wait(tile_lock);
denoising_cond_.wait(tile_lock);
continue;
}
@@ -446,7 +452,7 @@ bool Session::acquire_tile(RenderTile &rtile, Device *tile_device, uint tile_typ
}
else {
if (tile_device->info.type == DEVICE_CPU) {
stealable_tiles++;
stealable_tiles_++;
rtile.stealing_state = RenderTile::CAN_BE_STOLEN;
}
@@ -515,7 +521,7 @@ bool Session::acquire_tile(RenderTile &rtile, Device *tile_device, uint tile_typ
/* This will read any passes needed as input for baking. */
if (tile_manager.state.sample == tile_manager.range_start_sample) {
{
thread_scoped_lock tile_lock(tile_mutex);
thread_scoped_lock tile_lock(tile_mutex_);
read_bake_tile_cb(rtile);
}
rtile.buffers->buffer.copy_to_device();
@@ -533,7 +539,7 @@ bool Session::acquire_tile(RenderTile &rtile, Device *tile_device, uint tile_typ
void Session::update_tile_sample(RenderTile &rtile)
{
thread_scoped_lock tile_lock(tile_mutex);
thread_scoped_lock tile_lock(tile_mutex_);
if (update_render_tile_cb) {
if (params.progressive_refine == false) {
@@ -548,25 +554,25 @@ void Session::update_tile_sample(RenderTile &rtile)
void Session::release_tile(RenderTile &rtile, const bool need_denoise)
{
thread_scoped_lock tile_lock(tile_mutex);
thread_scoped_lock tile_lock(tile_mutex_);
if (rtile.stealing_state != RenderTile::NO_STEALING) {
stealable_tiles--;
stealable_tiles_--;
if (rtile.stealing_state == RenderTile::WAS_STOLEN) {
/* If the tile is being stolen, don't release it here - the new device will pick up where
* the old one left off. */
assert(tile_stealing_state == RELEASING_TILE);
assert(tile_stealing_state_ == RELEASING_TILE);
assert(rtile.sample < rtile.start_sample + rtile.num_samples);
tile_stealing_state = GOT_TILE;
stolen_tile = rtile;
tile_steal_cond.notify_all();
tile_stealing_state_ = GOT_TILE;
stolen_tile_ = rtile;
tile_steal_cond_.notify_all();
return;
}
else if (stealable_tiles == 0) {
else if (stealable_tiles_ == 0) {
/* If this was the last stealable tile, wake up any threads still waiting for one. */
tile_steal_cond.notify_all();
tile_steal_cond_.notify_all();
}
}
@@ -595,12 +601,12 @@ void Session::release_tile(RenderTile &rtile, const bool need_denoise)
update_status_time();
/* Notify denoising thread that a tile was finished. */
denoising_cond.notify_all();
denoising_cond_.notify_all();
}
void Session::map_neighbor_tiles(RenderTileNeighbors &neighbors, Device *tile_device)
{
thread_scoped_lock tile_lock(tile_mutex);
thread_scoped_lock tile_lock(tile_mutex_);
const int4 image_region = make_int4(
tile_manager.state.buffer.full_x,
@@ -677,7 +683,7 @@ void Session::map_neighbor_tiles(RenderTileNeighbors &neighbors, Device *tile_de
void Session::unmap_neighbor_tiles(RenderTileNeighbors &neighbors, Device *tile_device)
{
thread_scoped_lock tile_lock(tile_mutex);
thread_scoped_lock tile_lock(tile_mutex_);
device->unmap_neighbor_tiles(tile_device, neighbors);
}
@@ -685,8 +691,8 @@ void Session::run_cpu()
{
bool tiles_written = false;
last_update_time = time_dt();
last_display_time = last_update_time;
last_update_time_ = time_dt();
last_display_time_ = last_update_time_;
while (!progress.get_cancel()) {
const bool no_tiles = !run_update_for_next_iteration();
@@ -718,7 +724,7 @@ void Session::run_cpu()
/* buffers mutex is locked entirely while rendering each
* sample, and released/reacquired on each iteration to allow
* reset and draw in between */
thread_scoped_lock buffers_lock(buffers_mutex);
thread_scoped_lock buffers_lock(buffers_mutex_);
/* update status and timing */
update_status_time();
@@ -741,14 +747,14 @@ void Session::run_cpu()
device->task_wait();
{
thread_scoped_lock reset_lock(delayed_reset.mutex);
thread_scoped_lock buffers_lock(buffers_mutex);
thread_scoped_lock display_lock(display_mutex);
thread_scoped_lock reset_lock(delayed_reset_.mutex);
thread_scoped_lock buffers_lock(buffers_mutex_);
thread_scoped_lock display_lock(display_mutex_);
if (delayed_reset.do_reset) {
if (delayed_reset_.do_reset) {
/* reset rendering if request from main thread */
delayed_reset.do_reset = false;
reset_(delayed_reset.params, delayed_reset.samples);
delayed_reset_.do_reset = false;
reset_(delayed_reset_.params, delayed_reset_.samples);
}
else if (need_copy_to_display_buffer) {
/* Only copy to display_buffer if we do not reset, we don't
@@ -783,7 +789,7 @@ void Session::run()
/* reset number of rendered samples */
progress.reset_sample();
if (device_use_gl)
if (device_use_gl_)
run_gpu();
else
run_cpu();
@@ -801,12 +807,12 @@ void Session::run()
bool Session::run_update_for_next_iteration()
{
thread_scoped_lock scene_lock(scene->mutex);
thread_scoped_lock reset_lock(delayed_reset.mutex);
thread_scoped_lock reset_lock(delayed_reset_.mutex);
if (delayed_reset.do_reset) {
thread_scoped_lock buffers_lock(buffers_mutex);
reset_(delayed_reset.params, delayed_reset.samples);
delayed_reset.do_reset = false;
if (delayed_reset_.do_reset) {
thread_scoped_lock buffers_lock(buffers_mutex_);
reset_(delayed_reset_.params, delayed_reset_.samples);
delayed_reset_.do_reset = false;
}
const bool have_tiles = tile_manager.next();
@@ -829,35 +835,43 @@ bool Session::run_wait_for_work(bool no_tiles)
return false;
}
thread_scoped_lock pause_lock(pause_mutex);
thread_scoped_lock pause_lock(pause_mutex_);
if (!pause && !no_tiles) {
if (!pause_ && !no_tiles) {
/* Rendering is not paused and there is work to be done. No need to wait for anything. */
return false;
}
update_status_time(pause, no_tiles);
update_status_time(pause_, no_tiles);
while (true) {
/* Only leave the loop when rendering is not paused. But even if the current render is un-paused
* but there is nothing to render keep waiting until new work is added. */
while (!cancel_) {
scoped_timer pause_timer;
pause_cond.wait(pause_lock);
if (pause) {
if (!pause_ && (!no_tiles || new_work_added_ || delayed_reset_.do_reset)) {
break;
}
/* Wait for either pause state changed, or extra samples added to render. */
pause_cond_.wait(pause_lock);
if (pause_) {
progress.add_skip_time(pause_timer, params.background);
}
update_status_time(pause, no_tiles);
update_status_time(pause_, no_tiles);
progress.set_update();
if (!pause) {
break;
}
}
new_work_added_ = false;
return no_tiles;
}
bool Session::draw(BufferParams &buffer_params, DeviceDrawParams &draw_params)
{
if (device_use_gl)
if (device_use_gl_)
return draw_gpu(buffer_params, draw_params);
else
return draw_cpu(buffer_params, draw_params);
@@ -866,7 +880,7 @@ bool Session::draw(BufferParams &buffer_params, DeviceDrawParams &draw_params)
void Session::reset_(BufferParams &buffer_params, int samples)
{
if (buffers && buffer_params.modified(tile_manager.params)) {
gpu_draw_ready = false;
gpu_draw_ready_ = false;
buffers->reset(buffer_params);
if (display) {
display->reset(buffer_params);
@@ -874,8 +888,8 @@ void Session::reset_(BufferParams &buffer_params, int samples)
}
tile_manager.reset(buffer_params, samples);
stealable_tiles = 0;
tile_stealing_state = NOT_STEALING;
stealable_tiles_ = 0;
tile_stealing_state_ = NOT_STEALING;
progress.reset_sample();
bool show_progress = params.background || tile_manager.get_num_effective_samples() != INT_MAX;
@@ -888,7 +902,7 @@ void Session::reset_(BufferParams &buffer_params, int samples)
void Session::reset(BufferParams &buffer_params, int samples)
{
if (device_use_gl)
if (device_use_gl_)
reset_gpu(buffer_params, samples);
else
reset_cpu(buffer_params, samples);
@@ -896,30 +910,37 @@ void Session::reset(BufferParams &buffer_params, int samples)
void Session::set_samples(int samples)
{
if (samples != params.samples) {
params.samples = samples;
tile_manager.set_samples(samples);
pause_cond.notify_all();
if (samples == params.samples) {
return;
}
params.samples = samples;
tile_manager.set_samples(samples);
{
thread_scoped_lock pause_lock(pause_mutex_);
new_work_added_ = true;
}
pause_cond_.notify_all();
}
void Session::set_pause(bool pause_)
void Session::set_pause(bool pause)
{
bool notify = false;
{
thread_scoped_lock pause_lock(pause_mutex);
thread_scoped_lock pause_lock(pause_mutex_);
if (pause != pause_) {
pause = pause_;
pause_ = pause;
notify = true;
}
}
if (session_thread) {
if (session_thread_) {
if (notify) {
pause_cond.notify_all();
pause_cond_.notify_all();
}
}
else if (pause_) {
@@ -932,7 +953,7 @@ void Session::set_denoising(const DenoiseParams &denoising)
bool need_denoise = denoising.need_denoising_task();
/* Lock buffers so no denoising operation is triggered while the settings are changed here. */
thread_scoped_lock buffers_lock(buffers_mutex);
thread_scoped_lock buffers_lock(buffers_mutex_);
params.denoising = denoising;
if (!(params.device.denoisers & denoising.type)) {
@@ -957,18 +978,18 @@ void Session::set_denoising_start_sample(int sample)
if (sample != params.denoising.start_sample) {
params.denoising.start_sample = sample;
pause_cond.notify_all();
pause_cond_.notify_all();
}
}
void Session::wait()
{
if (session_thread) {
session_thread->join();
delete session_thread;
if (session_thread_) {
session_thread_->join();
delete session_thread_;
}
session_thread = NULL;
session_thread_ = NULL;
}
bool Session::update_scene()
@@ -1099,7 +1120,7 @@ bool Session::render_need_denoise(bool &delayed)
/* Avoid excessive denoising in viewport after reaching a certain amount of samples. */
delayed = (tile_manager.state.sample >= 20 &&
(time_dt() - last_display_time) < params.progressive_update_timeout);
(time_dt() - last_display_time_) < params.progressive_update_timeout);
return !delayed;
}
@@ -1197,10 +1218,10 @@ void Session::copy_to_display_buffer(int sample)
/* set display to new size */
display->draw_set(task.w, task.h);
last_display_time = time_dt();
last_display_time_ = time_dt();
}
display_outdated = false;
display_outdated_ = false;
}
bool Session::update_progressive_refine(bool cancel)
@@ -1210,7 +1231,7 @@ bool Session::update_progressive_refine(bool cancel)
double current_time = time_dt();
if (current_time - last_update_time < params.progressive_update_timeout) {
if (current_time - last_update_time_ < params.progressive_update_timeout) {
/* If last sample was processed, we need to write buffers anyway. */
if (!write && sample != 1)
return false;
@@ -1241,7 +1262,7 @@ bool Session::update_progressive_refine(bool cancel)
}
}
last_update_time = current_time;
last_update_time_ = current_time;
return write;
}

View File

@@ -174,7 +174,7 @@ class Session {
bool do_reset;
BufferParams params;
int samples;
} delayed_reset;
} delayed_reset_;
void run();
@@ -207,38 +207,41 @@ class Session {
void map_neighbor_tiles(RenderTileNeighbors &neighbors, Device *tile_device);
void unmap_neighbor_tiles(RenderTileNeighbors &neighbors, Device *tile_device);
bool device_use_gl;
bool device_use_gl_;
thread *session_thread;
thread *session_thread_;
volatile bool display_outdated;
volatile bool display_outdated_;
volatile bool gpu_draw_ready;
volatile bool gpu_need_display_buffer_update;
thread_condition_variable gpu_need_display_buffer_update_cond;
volatile bool gpu_draw_ready_;
volatile bool gpu_need_display_buffer_update_;
thread_condition_variable gpu_need_display_buffer_update_cond_;
bool pause;
thread_condition_variable pause_cond;
thread_mutex pause_mutex;
thread_mutex tile_mutex;
thread_mutex buffers_mutex;
thread_mutex display_mutex;
thread_condition_variable denoising_cond;
thread_condition_variable tile_steal_cond;
bool pause_;
bool cancel_;
bool new_work_added_;
double reset_time;
double last_update_time;
double last_display_time;
thread_condition_variable pause_cond_;
thread_mutex pause_mutex_;
thread_mutex tile_mutex_;
thread_mutex buffers_mutex_;
thread_mutex display_mutex_;
thread_condition_variable denoising_cond_;
thread_condition_variable tile_steal_cond_;
RenderTile stolen_tile;
double reset_time_;
double last_update_time_;
double last_display_time_;
RenderTile stolen_tile_;
typedef enum {
NOT_STEALING, /* There currently is no tile stealing in progress. */
WAITING_FOR_TILE, /* A device is waiting for another device to release a tile. */
RELEASING_TILE, /* A device has releasing a stealable tile. */
GOT_TILE /* A device has released a stealable tile, which is now stored in stolen_tile. */
} TileStealingState;
std::atomic<TileStealingState> tile_stealing_state;
int stealable_tiles;
std::atomic<TileStealingState> tile_stealing_state_;
int stealable_tiles_;
/* progressive refine */
bool update_progressive_refine(bool cancel);

View File

@@ -154,6 +154,14 @@ class Shader : public Node {
void tag_update(Scene *scene);
void tag_used(Scene *scene);
/* Return true when either of the surface or displacement socket of the output node is linked.
* This should be used to ensure that surface attributes are also requested even when only the
* displacement socket is linked. */
bool has_surface_link() const
{
return has_surface || has_displacement;
}
bool need_update_geometry() const;
};

View File

@@ -1102,7 +1102,7 @@ int GHOST_XrSyncActions(GHOST_XrContextHandle xr_context, const char *action_set
int GHOST_XrApplyHapticAction(GHOST_XrContextHandle xr_context,
const char *action_set_name,
const char *action_name,
const char **subaction_path,
const char *subaction_path,
const int64_t *duration,
const float *frequency,
const float *amplitude);
@@ -1113,7 +1113,7 @@ int GHOST_XrApplyHapticAction(GHOST_XrContextHandle xr_context,
void GHOST_XrStopHapticAction(GHOST_XrContextHandle xr_context,
const char *action_set_name,
const char *action_name,
const char **subaction_path);
const char *subaction_path);
/**
* Get action set custom data (owned by Blender, not GHOST).

View File

@@ -32,10 +32,10 @@ class GHOST_IWindow;
/**
* Interface class for events received from GHOST.
* You should not need to inherit this class. The system will pass these events
* to the GHOST_IEventConsumer::processEvent() method of event consumers.<br>
* Use the getType() method to retrieve the type of event and the getData()
* to the #GHOST_IEventConsumer::processEvent() method of event consumers.<br>
* Use the #getType() method to retrieve the type of event and the #getData()
* method to get the event data out. Using the event type you can cast the
* event data to the correct event dat structure.
* event data to the correct event data structure.
* \see GHOST_IEventConsumer#processEvent
* \see GHOST_TEventType
*/

View File

@@ -669,6 +669,14 @@ typedef struct {
void *exit_customdata;
} GHOST_XrSessionBeginInfo;
/** Texture format for XR swapchain. */
typedef enum GHOST_TXrSwapchainFormat {
GHOST_kXrSwapchainFormatRGBA8,
GHOST_kXrSwapchainFormatRGBA16,
GHOST_kXrSwapchainFormatRGBA16F,
GHOST_kXrSwapchainFormatRGB10_A2,
} GHOST_TXrSwapchainFormat;
typedef struct GHOST_XrDrawViewInfo {
int ofsx, ofsy;
int width, height;
@@ -681,6 +689,7 @@ typedef struct GHOST_XrDrawViewInfo {
float angle_up, angle_down;
} fov;
GHOST_TXrSwapchainFormat swapchain_format;
/** Set if the buffer should be submitted with a SRGB transfer applied. */
char expects_srgb_buffer;

View File

@@ -1005,7 +1005,7 @@ int GHOST_XrSyncActions(GHOST_XrContextHandle xr_contexthandle, const char *acti
int GHOST_XrApplyHapticAction(GHOST_XrContextHandle xr_contexthandle,
const char *action_set_name,
const char *action_name,
const char **subaction_path,
const char *subaction_path,
const int64_t *duration,
const float *frequency,
const float *amplitude)
@@ -1022,7 +1022,7 @@ int GHOST_XrApplyHapticAction(GHOST_XrContextHandle xr_contexthandle,
void GHOST_XrStopHapticAction(GHOST_XrContextHandle xr_contexthandle,
const char *action_set_name,
const char *action_name,
const char **subaction_path)
const char *subaction_path)
{
GHOST_IXrContext *xr_context = (GHOST_IXrContext *)xr_contexthandle;
GHOST_XrSession *xr_session = xr_context->getSession();

View File

@@ -132,6 +132,7 @@ class GHOST_SharedOpenGLResource {
ID3D11DeviceContext *device_ctx,
unsigned int width,
unsigned int height,
DXGI_FORMAT format,
ID3D11RenderTargetView *render_target = nullptr)
: m_device(device), m_device_ctx(device_ctx), m_cur_width(width), m_cur_height(height)
{
@@ -144,7 +145,7 @@ class GHOST_SharedOpenGLResource {
texDesc.Width = width;
texDesc.Height = height;
texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
texDesc.Format = format;
texDesc.SampleDesc.Count = 1;
texDesc.ArraySize = 1;
texDesc.MipLevels = 1;
@@ -321,7 +322,10 @@ class GHOST_SharedOpenGLResource {
};
GHOST_SharedOpenGLResource *GHOST_ContextD3D::createSharedOpenGLResource(
unsigned int width, unsigned int height, ID3D11RenderTargetView *render_target)
unsigned int width,
unsigned int height,
DXGI_FORMAT format,
ID3D11RenderTargetView *render_target)
{
if (!(WGL_NV_DX_interop && WGL_NV_DX_interop2)) {
fprintf(stderr,
@@ -330,14 +334,15 @@ GHOST_SharedOpenGLResource *GHOST_ContextD3D::createSharedOpenGLResource(
return nullptr;
}
GHOST_SharedOpenGLResource *shared_res = new GHOST_SharedOpenGLResource(
m_device, m_device_ctx, width, height, render_target);
m_device, m_device_ctx, width, height, format, render_target);
return shared_res;
}
GHOST_SharedOpenGLResource *GHOST_ContextD3D::createSharedOpenGLResource(unsigned int width,
unsigned int height)
unsigned int height,
DXGI_FORMAT format)
{
return createSharedOpenGLResource(width, height, nullptr);
return createSharedOpenGLResource(width, height, format, nullptr);
}
void GHOST_ContextD3D::disposeSharedOpenGLResource(GHOST_SharedOpenGLResource *shared_res)

View File

@@ -106,9 +106,13 @@ class GHOST_ContextD3D : public GHOST_Context {
}
class GHOST_SharedOpenGLResource *createSharedOpenGLResource(
unsigned int width, unsigned int height, ID3D11RenderTargetView *render_target);
unsigned int width,
unsigned int height,
DXGI_FORMAT format,
ID3D11RenderTargetView *render_target);
class GHOST_SharedOpenGLResource *createSharedOpenGLResource(unsigned int width,
unsigned int height);
unsigned int height,
DXGI_FORMAT format);
void disposeSharedOpenGLResource(class GHOST_SharedOpenGLResource *shared_res);
GHOST_TSuccess blitFromOpenGLContext(class GHOST_SharedOpenGLResource *shared_res,
unsigned int width,

View File

@@ -60,6 +60,7 @@ class GHOST_IXrGraphicsBinding {
std::string *r_requirement_info) const = 0;
virtual void initFromGhostContext(class GHOST_Context &ghost_ctx) = 0;
virtual std::optional<int64_t> chooseSwapchainFormat(const std::vector<int64_t> &runtime_formats,
GHOST_TXrSwapchainFormat &r_format,
bool &r_is_rgb_format) const = 0;
virtual std::vector<XrSwapchainImageBaseHeader *> createSwapchainImages(
uint32_t image_count) = 0;

View File

@@ -30,9 +30,15 @@
# include "GHOST_WindowWin32.h"
# include "utfconv.h"
/* ISO_639-1 2-Letter Abbreviations. */
# define IMELANG_ENGLISH "en"
# define IMELANG_CHINESE "zh"
# define IMELANG_JAPANESE "ja"
# define IMELANG_KOREAN "ko"
GHOST_ImeWin32::GHOST_ImeWin32()
: is_composing_(false),
input_language_id_(LANG_USER_DEFAULT),
language_(IMELANG_ENGLISH),
conversion_modes_(IME_CMODE_ALPHANUMERIC),
sentence_mode_(IME_SMODE_NONE),
system_caret_(false),
@@ -48,16 +54,21 @@ GHOST_ImeWin32::~GHOST_ImeWin32()
void GHOST_ImeWin32::UpdateInputLanguage()
{
/**
* Store the current input language.
*/
HKL input_locale = ::GetKeyboardLayout(0);
input_language_id_ = LOWORD(input_locale);
/* Get the current input locale full name. */
WCHAR locale[LOCALE_NAME_MAX_LENGTH];
LCIDToLocaleName(
MAKELCID(LOWORD(::GetKeyboardLayout(0)), SORT_DEFAULT), locale, LOCALE_NAME_MAX_LENGTH, 0);
/* Get the 2-letter ISO-63901 abbreviation of the input locale name. */
WCHAR language_u16[W32_ISO639_LEN];
GetLocaleInfoEx(locale, LOCALE_SISO639LANGNAME, language_u16, W32_ISO639_LEN);
/* Store this as a UTF-8 string. */
WideCharToMultiByte(
CP_UTF8, 0, language_u16, W32_ISO639_LEN, language_, W32_ISO639_LEN, NULL, NULL);
}
WORD GHOST_ImeWin32::GetInputLanguage()
BOOL GHOST_ImeWin32::IsLanguage(const char name[W32_ISO639_LEN])
{
return input_language_id_;
return (strcmp(name, language_) == 0);
}
void GHOST_ImeWin32::UpdateConversionStatus(HWND window_handle)
@@ -92,21 +103,11 @@ bool GHOST_ImeWin32::IsImeKeyEvent(char ascii)
if ((ascii >= 'A' && ascii <= 'Z') || (ascii >= 'a' && ascii <= 'z')) {
return true;
}
switch (PRIMARYLANGID(GetInputLanguage())) {
/* In Japanese, all symbolic characters are also processed by IME. */
case LANG_JAPANESE: {
if (ascii >= ' ' && ascii <= '~') {
return true;
}
break;
}
/* In Chinese, some symbolic characters are also processed by IME. */
case LANG_CHINESE: {
if (ascii && strchr("!\"$'(),.:;<>?[\\]^_`", ascii)) {
return true;
}
break;
}
if (IsLanguage(IMELANG_JAPANESE) && (ascii >= ' ' && ascii <= '~')) {
return true;
}
else if (IsLanguage(IMELANG_CHINESE) && ascii && strchr("!\"$'(),.:;<>?[\\]^_`", ascii)) {
return true;
}
}
return false;
@@ -126,13 +127,8 @@ void GHOST_ImeWin32::CreateImeWindow(HWND window_handle)
* Since some third-party Japanese IME also uses ::GetCaretPos() to determine
* their window position, we also create a caret for Japanese IMEs.
*/
if (PRIMARYLANGID(input_language_id_) == LANG_CHINESE ||
PRIMARYLANGID(input_language_id_) == LANG_JAPANESE) {
if (!system_caret_) {
if (::CreateCaret(window_handle, NULL, 1, 1)) {
system_caret_ = true;
}
}
if (!system_caret_ && (IsLanguage(IMELANG_CHINESE) || IsLanguage(IMELANG_JAPANESE))) {
system_caret_ = ::CreateCaret(window_handle, NULL, 1, 1);
}
/* Restore the positions of the IME windows. */
UpdateImeWindow(window_handle);
@@ -185,16 +181,9 @@ void GHOST_ImeWin32::MoveImeWindow(HWND window_handle, HIMC imm_context)
CANDIDATEFORM candidate_position = {0, CFS_CANDIDATEPOS, {x, y}, {0, 0, 0, 0}};
::ImmSetCandidateWindow(imm_context, &candidate_position);
if (system_caret_) {
switch (PRIMARYLANGID(input_language_id_)) {
case LANG_JAPANESE:
::SetCaretPos(x, y + caret_rect_.getHeight());
break;
default:
::SetCaretPos(x, y);
break;
}
::SetCaretPos(x, y);
}
if (PRIMARYLANGID(input_language_id_) == LANG_KOREAN) {
if (IsLanguage(IMELANG_KOREAN)) {
/**
* Chinese IMEs and Japanese IMEs require the upper-left corner of
* the caret to move the position of their candidate windows.
@@ -284,83 +273,79 @@ void GHOST_ImeWin32::GetCaret(HIMC imm_context, LPARAM lparam, ImeComposition *c
*/
int target_start = -1;
int target_end = -1;
switch (PRIMARYLANGID(input_language_id_)) {
case LANG_KOREAN:
if (lparam & CS_NOMOVECARET) {
target_start = 0;
target_end = 1;
}
break;
case LANG_CHINESE: {
int clause_size = ImmGetCompositionStringW(imm_context, GCS_COMPCLAUSE, NULL, 0);
if (clause_size) {
static std::vector<unsigned long> clauses;
clause_size = clause_size / sizeof(clauses[0]);
clauses.resize(clause_size);
ImmGetCompositionStringW(
imm_context, GCS_COMPCLAUSE, &clauses[0], sizeof(clauses[0]) * clause_size);
if (composition->cursor_position == composition->ime_string.size()) {
target_start = clauses[clause_size - 2];
target_end = clauses[clause_size - 1];
}
else {
for (int i = 0; i < clause_size - 1; i++) {
if (clauses[i] == composition->cursor_position) {
target_start = clauses[i];
target_end = clauses[i + 1];
break;
}
}
}
if (IsLanguage(IMELANG_KOREAN)) {
if (lparam & CS_NOMOVECARET) {
target_start = 0;
target_end = 1;
}
}
else if (IsLanguage(IMELANG_CHINESE)) {
int clause_size = ImmGetCompositionStringW(imm_context, GCS_COMPCLAUSE, NULL, 0);
if (clause_size) {
static std::vector<unsigned long> clauses;
clause_size = clause_size / sizeof(clauses[0]);
clauses.resize(clause_size);
ImmGetCompositionStringW(
imm_context, GCS_COMPCLAUSE, &clauses[0], sizeof(clauses[0]) * clause_size);
if (composition->cursor_position == composition->ime_string.size()) {
target_start = clauses[clause_size - 2];
target_end = clauses[clause_size - 1];
}
else {
if (composition->cursor_position != -1) {
target_start = composition->cursor_position;
target_end = composition->ime_string.size();
}
}
break;
}
case LANG_JAPANESE:
/**
* For Japanese IMEs, the robustest way to retrieve the caret
* is scanning the attribute of the latest composition string and
* retrieving the beginning and the end of the target clause, i.e.
* a clause being converted.
*/
if (lparam & GCS_COMPATTR) {
int attribute_size = ::ImmGetCompositionStringW(imm_context, GCS_COMPATTR, NULL, 0);
if (attribute_size > 0) {
char *attribute_data = new char[attribute_size];
if (attribute_data) {
::ImmGetCompositionStringW(imm_context, GCS_COMPATTR, attribute_data, attribute_size);
for (target_start = 0; target_start < attribute_size; ++target_start) {
if (IsTargetAttribute(attribute_data[target_start]))
break;
}
for (target_end = target_start; target_end < attribute_size; ++target_end) {
if (!IsTargetAttribute(attribute_data[target_end]))
break;
}
if (target_start == attribute_size) {
/**
* This composition clause does not contain any target clauses,
* i.e. this clauses is an input clause.
* We treat whole this clause as a target clause.
*/
target_end = target_start;
target_start = 0;
}
if (target_start != -1 && target_start < attribute_size &&
attribute_data[target_start] == ATTR_TARGET_NOTCONVERTED) {
composition->cursor_position = target_start;
}
for (int i = 0; i < clause_size - 1; i++) {
if (clauses[i] == composition->cursor_position) {
target_start = clauses[i];
target_end = clauses[i + 1];
break;
}
delete[] attribute_data;
}
}
break;
}
else {
if (composition->cursor_position != -1) {
target_start = composition->cursor_position;
target_end = composition->ime_string.size();
}
}
}
else if (IsLanguage(IMELANG_JAPANESE)) {
/**
* For Japanese IMEs, the robustest way to retrieve the caret
* is scanning the attribute of the latest composition string and
* retrieving the beginning and the end of the target clause, i.e.
* a clause being converted.
*/
if (lparam & GCS_COMPATTR) {
int attribute_size = ::ImmGetCompositionStringW(imm_context, GCS_COMPATTR, NULL, 0);
if (attribute_size > 0) {
char *attribute_data = new char[attribute_size];
if (attribute_data) {
::ImmGetCompositionStringW(imm_context, GCS_COMPATTR, attribute_data, attribute_size);
for (target_start = 0; target_start < attribute_size; ++target_start) {
if (IsTargetAttribute(attribute_data[target_start]))
break;
}
for (target_end = target_start; target_end < attribute_size; ++target_end) {
if (!IsTargetAttribute(attribute_data[target_end]))
break;
}
if (target_start == attribute_size) {
/**
* This composition clause does not contain any target clauses,
* i.e. this clauses is an input clause.
* We treat whole this clause as a target clause.
*/
target_end = target_start;
target_start = 0;
}
if (target_start != -1 && target_start < attribute_size &&
attribute_data[target_start] == ATTR_TARGET_NOTCONVERTED) {
composition->cursor_position = target_start;
}
}
delete[] attribute_data;
}
}
}
composition->target_start = target_start;
composition->target_end = target_end;

View File

@@ -36,6 +36,9 @@
# include "GHOST_Rect.h"
# include <vector>
/* MSDN LOCALE_SISO639LANGNAME states maximum length of 9, including terminating null. */
# define W32_ISO639_LEN 9
class GHOST_EventIME : public GHOST_Event {
public:
/**
@@ -146,13 +149,10 @@ class GHOST_ImeWin32 {
return is_composing_;
}
/**
* Retrieves the input language from Windows and update it.
*/
/* Retrieve the input language from Windows and store it. */
void UpdateInputLanguage();
/* Returns the current input language id. */
WORD GetInputLanguage();
BOOL IsLanguage(const char name[W32_ISO639_LEN]);
/* Saves the current conversion status. */
void UpdateConversionStatus(HWND window_handle);
@@ -345,29 +345,8 @@ class GHOST_ImeWin32 {
*/
bool is_composing_;
/**
* The current input Language ID retrieved from Windows, which consists of:
* * Primary Language ID (bit 0 to bit 9), which shows a natural language
* (English, Korean, Chinese, Japanese, etc.) and;
* * Sub-Language ID (bit 10 to bit 15), which shows a geometrical region
* the language is spoken (For English, United States, United Kingdom,
* Australia, Canada, etc.)
* The following list enumerates some examples for the Language ID:
* * "en-US" (0x0409)
* MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US);
* * "ko-KR" (0x0412)
* MAKELANGID(LANG_KOREAN, SUBLANG_KOREAN);
* * "zh-TW" (0x0404)
* MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL);
* * "zh-CN" (0x0804)
* MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED);
* * "ja-JP" (0x0411)
* MAKELANGID(LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN), etc.
* (See `winnt.h` for other available values.)
* This Language ID is used for processing language-specific operations in
* IME functions.
*/
LANGID input_language_id_;
/* Abbreviated ISO 639-1 name of the input language, such as "en" for English. */
char language_[W32_ISO639_LEN];
/* Current Conversion Mode Values. Retrieved with ImmGetConversionStatus. */
DWORD conversion_modes_;

View File

@@ -424,7 +424,7 @@ extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
{
/* TODO: implement graceful termination through Cocoa mechanism
* to avoid session log off to be canceled. */
/* Note that Cmd+Q is already handled by keyhandler. */
/* Note that Cmd+Q is already handled by key-handler. */
systemCocoa->handleQuitRequest();
return NSTerminateCancel;
}
@@ -1629,7 +1629,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
y_accum + (y_mouse - warped_y_mouse));
/* This is the current time that matches NSEvent timestamp. */
m_last_warp_timestamp = mach_absolute_time() * 1e-9;
m_last_warp_timestamp = [[NSProcessInfo processInfo] systemUptime];
}
// Generate event

View File

@@ -1741,7 +1741,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
case WM_MOUSELEAVE: {
window->m_mousePresent = false;
if (window->getTabletData().Active == GHOST_kTabletModeNone) {
processCursorEvent(window);
event = processCursorEvent(window);
}
GHOST_Wintab *wt = window->getWintab();
if (wt) {

View File

@@ -1922,7 +1922,7 @@ static GHOST_TKey ghost_key_from_keycode(const XkbDescPtr xkb_descr, const KeyCo
#undef MAKE_ID
/* from xclip.c xcout() v0.11 */
/* From `xclip.c` #xcout() v0.11. */
#define XCLIB_XCOUT_NONE 0 /* no context */
#define XCLIB_XCOUT_SENTCONVSEL 1 /* sent a request */

View File

@@ -375,7 +375,7 @@ void GHOST_XrAction::updateState(XrSession session,
void GHOST_XrAction::applyHapticFeedback(XrSession session,
const char *action_name,
const char **subaction_path_str,
const char *subaction_path_str,
const int64_t &duration,
const float &frequency,
const float &amplitude)
@@ -390,7 +390,7 @@ void GHOST_XrAction::applyHapticFeedback(XrSession session,
haptic_info.action = m_action;
if (subaction_path_str != nullptr) {
SubactionIndexMap::iterator it = m_subaction_indices.find(*subaction_path_str);
SubactionIndexMap::iterator it = m_subaction_indices.find(subaction_path_str);
if (it != m_subaction_indices.end()) {
haptic_info.subactionPath = m_subaction_paths[it->second];
CHECK_XR(
@@ -410,13 +410,13 @@ void GHOST_XrAction::applyHapticFeedback(XrSession session,
void GHOST_XrAction::stopHapticFeedback(XrSession session,
const char *action_name,
const char **subaction_path_str)
const char *subaction_path_str)
{
XrHapticActionInfo haptic_info{XR_TYPE_HAPTIC_ACTION_INFO};
haptic_info.action = m_action;
if (subaction_path_str != nullptr) {
SubactionIndexMap::iterator it = m_subaction_indices.find(*subaction_path_str);
SubactionIndexMap::iterator it = m_subaction_indices.find(subaction_path_str);
if (it != m_subaction_indices.end()) {
haptic_info.subactionPath = m_subaction_paths[it->second];
CHECK_XR(xrStopHapticFeedback(session, &haptic_info),

View File

@@ -103,11 +103,11 @@ class GHOST_XrAction {
const XrTime &predicted_display_time);
void applyHapticFeedback(XrSession session,
const char *action_name,
const char **subaction_path,
const char *subaction_path,
const int64_t &duration,
const float &frequency,
const float &amplitude);
void stopHapticFeedback(XrSession session, const char *action_name, const char **subaction_path);
void stopHapticFeedback(XrSession session, const char *action_name, const char *subaction_path);
void *getCustomdata();
void getBindings(std::map<XrPath, std::vector<XrActionSuggestedBinding>> &r_bindings) const;

View File

@@ -410,6 +410,11 @@ void GHOST_XrContext::getExtensionsToEnable(
try_ext.push_back(XR_EXT_DEBUG_UTILS_EXTENSION_NAME);
}
/* Try enabling interaction profile extensions. */
try_ext.push_back(XR_EXT_HP_MIXED_REALITY_CONTROLLER_EXTENSION_NAME);
try_ext.push_back(XR_HTC_VIVE_COSMOS_CONTROLLER_INTERACTION_EXTENSION_NAME);
try_ext.push_back(XR_HUAWEI_CONTROLLER_INTERACTION_EXTENSION_NAME);
r_ext_names.reserve(try_ext.size() + graphics_binding_types.size());
/* Add graphics binding extensions (may be multiple ones, we'll settle for one to use later, once

View File

@@ -38,6 +38,7 @@
# include "GHOST_SystemWin32.h"
#endif
#include "GHOST_C-api.h"
#include "GHOST_XrException.h"
#include "GHOST_Xr_intern.h"
#include "GHOST_IXrGraphicsBinding.h"
@@ -160,16 +161,41 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding {
}
std::optional<int64_t> chooseSwapchainFormat(const std::vector<int64_t> &runtime_formats,
GHOST_TXrSwapchainFormat &r_format,
bool &r_is_srgb_format) const override
{
std::vector<int64_t> gpu_binding_formats = {
GL_RGB10_A2,
GL_RGBA16,
GL_RGBA16F,
GL_RGBA8,
GL_SRGB8_ALPHA8,
};
std::optional result = choose_swapchain_format_from_candidates(gpu_binding_formats,
runtime_formats);
r_is_srgb_format = result ? (*result == GL_SRGB8_ALPHA8) : false;
if (result) {
switch (*result) {
case GL_RGB10_A2:
r_format = GHOST_kXrSwapchainFormatRGB10_A2;
break;
case GL_RGBA16:
r_format = GHOST_kXrSwapchainFormatRGBA16;
break;
case GL_RGBA16F:
r_format = GHOST_kXrSwapchainFormatRGBA16F;
break;
case GL_RGBA8:
case GL_SRGB8_ALPHA8:
r_format = GHOST_kXrSwapchainFormatRGBA8;
break;
}
r_is_srgb_format = (*result == GL_SRGB8_ALPHA8);
}
else {
r_format = GHOST_kXrSwapchainFormatRGBA8;
r_is_srgb_format = false;
}
return result;
}
@@ -228,6 +254,33 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding {
};
#ifdef WIN32
static void ghost_format_to_dx_format(GHOST_TXrSwapchainFormat ghost_format,
bool expects_srgb_buffer,
DXGI_FORMAT &r_dx_format)
{
r_dx_format = DXGI_FORMAT_UNKNOWN;
switch (ghost_format) {
case GHOST_kXrSwapchainFormatRGBA8:
r_dx_format = expects_srgb_buffer ? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB :
DXGI_FORMAT_R8G8B8A8_UNORM;
break;
case GHOST_kXrSwapchainFormatRGBA16:
r_dx_format = DXGI_FORMAT_R16G16B16A16_UNORM;
break;
case GHOST_kXrSwapchainFormatRGBA16F:
r_dx_format = DXGI_FORMAT_R16G16B16A16_FLOAT;
break;
case GHOST_kXrSwapchainFormatRGB10_A2:
r_dx_format = DXGI_FORMAT_R10G10B10A2_UNORM;
break;
}
if (r_dx_format == DXGI_FORMAT_UNKNOWN) {
throw GHOST_XrException("No supported DirectX swapchain format found.");
}
}
class GHOST_XrGraphicsBindingD3D : public GHOST_IXrGraphicsBinding {
public:
GHOST_XrGraphicsBindingD3D(GHOST_Context &ghost_ctx)
@@ -284,16 +337,48 @@ class GHOST_XrGraphicsBindingD3D : public GHOST_IXrGraphicsBinding {
}
std::optional<int64_t> chooseSwapchainFormat(const std::vector<int64_t> &runtime_formats,
GHOST_TXrSwapchainFormat &r_format,
bool &r_is_srgb_format) const override
{
std::vector<int64_t> gpu_binding_formats = {
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
# if 0 /* RGB10A2 doesn't seem to work with Oculus head-sets, \
* so move it after RGB16AF for the time being. */
DXGI_FORMAT_R10G10B10A2_UNORM,
# endif
DXGI_FORMAT_R16G16B16A16_UNORM,
DXGI_FORMAT_R16G16B16A16_FLOAT,
# if 1
DXGI_FORMAT_R10G10B10A2_UNORM,
# endif
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
};
std::optional result = choose_swapchain_format_from_candidates(gpu_binding_formats,
runtime_formats);
r_is_srgb_format = result ? (*result == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB) : false;
if (result) {
switch (*result) {
case DXGI_FORMAT_R10G10B10A2_UNORM:
r_format = GHOST_kXrSwapchainFormatRGB10_A2;
break;
case DXGI_FORMAT_R16G16B16A16_UNORM:
r_format = GHOST_kXrSwapchainFormatRGBA16;
break;
case DXGI_FORMAT_R16G16B16A16_FLOAT:
r_format = GHOST_kXrSwapchainFormatRGBA16F;
break;
case DXGI_FORMAT_R8G8B8A8_UNORM:
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
r_format = GHOST_kXrSwapchainFormatRGBA8;
break;
}
r_is_srgb_format = (*result == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB);
}
else {
r_format = GHOST_kXrSwapchainFormatRGBA8;
r_is_srgb_format = false;
}
return result;
}
@@ -334,14 +419,18 @@ class GHOST_XrGraphicsBindingD3D : public GHOST_IXrGraphicsBinding {
m_ghost_ctx->m_device->CreateRenderTargetView(d3d_swapchain_image.texture, &rtv_desc, &rtv);
if (!m_shared_resource) {
DXGI_FORMAT format;
ghost_format_to_dx_format(draw_info.swapchain_format, draw_info.expects_srgb_buffer, format);
m_shared_resource = m_ghost_ctx->createSharedOpenGLResource(
draw_info.width, draw_info.height, rtv);
draw_info.width, draw_info.height, format, rtv);
}
m_ghost_ctx->blitFromOpenGLContext(m_shared_resource, draw_info.width, draw_info.height);
# else
if (!m_shared_resource) {
m_shared_resource = m_ghost_d3d_ctx->createSharedOpenGLResource(draw_info.width,
draw_info.height);
DXGI_FORMAT format;
ghost_format_to_dx_format(draw_info.swapchain_format, draw_info.expects_srgb_buffer, format);
m_shared_resource = m_ghost_d3d_ctx->createSharedOpenGLResource(
draw_info.width, draw_info.height, format);
}
m_ghost_d3d_ctx->blitFromOpenGLContext(m_shared_resource, draw_info.width, draw_info.height);

View File

@@ -148,13 +148,12 @@ static void create_reference_spaces(OpenXRSessionData &oxr, const GHOST_XrPose &
if (XR_FAILED(result)) {
/* One of the rare cases where we don't want to immediately throw an exception on failure,
* since run-times are not required to support the stage reference space. Although we need the
* stage reference space for absolute tracking, if the runtime doesn't support it then just
* fallback to the local space. */
* since runtimes are not required to support the stage reference space. If the runtime
* doesn't support it then just fall back to the local space. */
if (result == XR_ERROR_REFERENCE_SPACE_UNSUPPORTED) {
printf(
"Warning: XR runtime does not support stage reference space, disabling absolute "
"tracking.\n");
"Warning: XR runtime does not support stage reference space, falling back to local "
"reference space.\n");
create_info.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_LOCAL;
CHECK_XR(xrCreateReferenceSpace(oxr.session, &create_info, &oxr.reference_space),
@@ -172,8 +171,9 @@ static void create_reference_spaces(OpenXRSessionData &oxr, const GHOST_XrPose &
"Failed to get stage reference space bounds.");
if (extents.width == 0.0f || extents.height == 0.0f) {
printf(
"Warning: Invalid stage reference space bounds, disabling absolute tracking. To enable "
"absolute tracking, please define a tracking space via the XR runtime.\n");
"Warning: Invalid stage reference space bounds, falling back to local reference space. "
"To use the stage reference space, please define a tracking space via the XR "
"runtime.\n");
/* Fallback to local space. */
if (oxr.reference_space != XR_NULL_HANDLE) {
@@ -422,6 +422,7 @@ void GHOST_XrSession::drawView(GHOST_XrSwapchain &swapchain,
assert(view_idx < 256);
draw_view_info.view_idx = (char)view_idx;
draw_view_info.swapchain_format = swapchain.getFormat();
draw_view_info.expects_srgb_buffer = swapchain.isBufferSRGB();
draw_view_info.ofsx = r_proj_layer_view.subImage.imageRect.offset.x;
draw_view_info.ofsy = r_proj_layer_view.subImage.imageRect.offset.y;
@@ -754,7 +755,7 @@ bool GHOST_XrSession::syncActions(const char *action_set_name)
bool GHOST_XrSession::applyHapticAction(const char *action_set_name,
const char *action_name,
const char **subaction_path,
const char *subaction_path,
const int64_t &duration,
const float &frequency,
const float &amplitude)
@@ -777,7 +778,7 @@ bool GHOST_XrSession::applyHapticAction(const char *action_set_name,
void GHOST_XrSession::stopHapticAction(const char *action_set_name,
const char *action_name,
const char **subaction_path)
const char *subaction_path)
{
GHOST_XrActionSet *action_set = find_action_set(m_oxr.get(), action_set_name);
if (action_set == nullptr) {

View File

@@ -76,13 +76,13 @@ class GHOST_XrSession {
bool syncActions(const char *action_set_name = nullptr);
bool applyHapticAction(const char *action_set_name,
const char *action_name,
const char **subaction_path,
const char *subaction_path,
const int64_t &duration,
const float &frequency,
const float &amplitude);
void stopHapticAction(const char *action_set_name,
const char *action_name,
const char **subaction_path);
const char *subaction_path);
/* Custom data (owned by Blender, not GHOST) accessors. */
void *getActionSetCustomdata(const char *action_set_name);

View File

@@ -67,8 +67,8 @@ GHOST_XrSwapchain::GHOST_XrSwapchain(GHOST_IXrGraphicsBinding &gpu_binding,
"Failed to get swapchain image formats.");
assert(swapchain_formats.size() == format_count);
std::optional chosen_format = gpu_binding.chooseSwapchainFormat(swapchain_formats,
m_is_srgb_buffer);
std::optional chosen_format = gpu_binding.chooseSwapchainFormat(
swapchain_formats, m_format, m_is_srgb_buffer);
if (!chosen_format) {
throw GHOST_XrException(
"Error: No format matching OpenXR runtime supported swapchain formats found.");
@@ -97,6 +97,7 @@ GHOST_XrSwapchain::GHOST_XrSwapchain(GHOST_XrSwapchain &&other)
: m_oxr(std::move(other.m_oxr)),
m_image_width(other.m_image_width),
m_image_height(other.m_image_height),
m_format(other.m_format),
m_is_srgb_buffer(other.m_is_srgb_buffer)
{
/* Prevent xrDestroySwapchain call for the moved out item. */
@@ -134,7 +135,12 @@ void GHOST_XrSwapchain::updateCompositionLayerProjectViewSubImage(XrSwapchainSub
r_sub_image.imageRect.extent = {m_image_width, m_image_height};
}
bool GHOST_XrSwapchain::isBufferSRGB()
GHOST_TXrSwapchainFormat GHOST_XrSwapchain::getFormat() const
{
return m_format;
}
bool GHOST_XrSwapchain::isBufferSRGB() const
{
return m_is_srgb_buffer;
}

View File

@@ -37,10 +37,12 @@ class GHOST_XrSwapchain {
void updateCompositionLayerProjectViewSubImage(XrSwapchainSubImage &r_sub_image);
bool isBufferSRGB();
GHOST_TXrSwapchainFormat getFormat() const;
bool isBufferSRGB() const;
private:
std::unique_ptr<OpenXRSwapchainData> m_oxr; /* Could use stack, but PImpl is preferable. */
int32_t m_image_width, m_image_height;
GHOST_TXrSwapchainFormat m_format;
bool m_is_srgb_buffer = false;
};

View File

@@ -871,7 +871,7 @@ void MEM_guarded_freeN(void *vmemh)
if (memh == NULL) {
MemorY_ErroR("free", "attempt to free NULL pointer");
/* print_error(err_stream, "%d\n", (memh+4000)->tag1); */
// print_error(err_stream, "%d\n", (memh+4000)->tag1);
return;
}

Some files were not shown because too many files have changed in this diff Show More