1
1

Compare commits

...

165 Commits

Author SHA1 Message Date
f83bb9abe4 LineArt: Fix edge index type 2022-04-07 09:31:49 +08:00
1d2e25cca4 LineArt: Face mark filtering for new object loading code. 2022-04-07 09:07:55 +08:00
36288aa5ae LineArt: Working fix for new object loading 2022-04-05 23:01:20 +08:00
ddc1fb197e Merge remote-tracking branch 'origin/master' into temp-lineart-embree 2022-04-03 18:06:25 +08:00
74d3ea8a33 LineArt: Crease in new object loading working correctly. 2022-04-03 18:05:53 +08:00
ff213e7135 LineArt: Crease by sharp 2022-04-03 18:05:51 +08:00
7cee9205eb Merge remote-tracking branch 'origin/master' into temp-lineart-embree 2022-04-02 23:27:30 +08:00
368a6cb364 LineArt: Timing for embree intersection 2022-04-02 21:09:03 +08:00
4ace978f62 LineArt: Crease support for new loading 2022-04-02 21:09:03 +08:00
517fd6eac7 Depsgraph: minor optimization in order of checks
Checking BKE_image_user_id_has_animation loops over ID users
which never needs to run for material & world data-blocks.
2022-04-02 21:09:03 +08:00
e25e808601 Cleanup: spelling, trailing space for comment-blocks 2022-04-02 21:09:03 +08:00
6de880fce3 Cleanup: Remove unnecessary namespace specification 2022-04-02 21:09:03 +08:00
840e73ca39 Cleanup: Avoid storing pointers for attribute search callback
It's better to use some local/stable identifiier to avoid relying on
the data not being freed in between creating the search menu and
the exec function. This is similar to c473b2ce8b.
2022-04-02 21:09:03 +08:00
Gilberto Rodrigues
420fae926c UI: Fix outliner and buttons icons alignment
029cf23d71 changed some icons alignment, but after 9be49a1069
the icons don't align anymore. This commit reverts 029cf23d71 and
also makes a couple of other outliner icons left aligned, instead of
right aligned, for consistency and general alignment.

Differential Revision: https://developer.blender.org/D14501
2022-04-02 21:09:03 +08:00
223e2e04dd Cleanup: Curves draw cache renaming, use references
Also change some remaining cases of "hair object" to "curves object".
2022-04-02 21:09:02 +08:00
f3152de429 Nodes: Cut hidden links when creating node groups
Add a check to the creation of node groups to remove hidden links
that are connected to the outside of the node group. This avoids
creating sockets in the group's interface that aren't (visibly)
connected to anything within the node group.

Reviewed By: Jacques Lucke, Hans Goudey

Differential Revision: https://developer.blender.org/D14249
2022-04-02 21:09:02 +08:00
d259052468 UI: Improve node editor dot background
This commit makes the dot grid used as background in the node editor
more visually stable when zooming in and out.

The dot grid now uses a continuously subdividing pattern, where
each level of subdivision divides the previous five times, similar to
the line grid in the 3D viewport.

The maximum for the "Grid Levels" theme setting is changed to 3, since
any further subdivisions are too small to be visible.
The "Grid Levels" value for the default themes "Blender Dark" and
"Blender Light" is therefore changed to 3, as well.

Reviewed By: Hans Goudey, Pablo Vazquez

Differential Revision: http://developer.blender.org/D13302
2022-04-02 21:09:02 +08:00
Jason Fielder
7337346821 Metal: Adding alternative support for GPU_PRIM_TRI_FAN/LINE_LOOP For Metal backend.
- Metal uniform array compatibility in DRW module.
- Guard OpenGL-specific workarounds and flushes behind GPU_type_matches_ex API guard. Add further render boundaries for render paths called outside of the main loop.

Authored by Apple: Michael Parkin-White

Ref: T96261

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D14438
2022-04-02 21:09:02 +08:00
cc4eb3c980 Fix T85689: Assume Win32 Volumes are Valid
Skip validation when inserting items into the Win32 "Volumes" list.
This fixes some long hangs when launching Blender with disconnected
network shares.

See D14506 for more details.

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

Reviewed by Brecht Van Lommel
2022-04-02 21:09:02 +08:00
Jason Fielder
633ff138a1 Metal: GLSL Shader compatibility 5
MSL does not have an implicit global scope, this is emulated via macro's adding an indirection for uniforms, attributes, shader stage inputs and outputs such as:

#define roughness shaderinst->roughness.

Variables in GLSL which exist within uniform blocks can be directly referenced via the global scope, unlike standard C++. This means that variable name pollution occurs if subsequent local variables in the code use the same name, resulting in compilation errors.

A number of these conflicting names have been renamed to ensure unique naming and no further scope pollution.

Ref T96261

Reviewed By: fclem

Maniphest Tasks: T96261

Differential Revision: https://developer.blender.org/D14452
2022-04-02 21:09:02 +08:00
Jason Fielder
7d9c570736 Metal: GLSL Compatibility - explicit mat4_to_mat3 conversion
Explicit constructor for mat3 from a mat4 is not valid and cannot be overloaded.

Adding explicit texture resource type flags for depth textures. This is an explicit requirement for Metal Shading language. This is a temporary compatibility, as this path is already supported in GPU_SHADER_CREATE_INFO under ImageType::DEPTH_2D, though required in shader source for MSL shaders which do not have create info.

Authored by Apple: Michael Parkin-White

Ref T96261

Reviewed By: fclem

Maniphest Tasks: T96261

Differential Revision: https://developer.blender.org/D14418
2022-04-02 21:09:02 +08:00
f273ed7123 Curves: Port resample node to the new data-block
This commit re-implements the resample curve node to use the new curves
type instead of CurveEval. The largest changes come from the need to
keep track of offsets into the point attribute arrays, and the fact
that the attributes for all curves are stored in a flat array.

Another difference is that a bit more of the logic is handled by
building of the field network inputs. The idea is to let the field
evaluator handle potential optimizations while making the rest of the
code simpler.

When resampling 1 million small poly curves,the node is about 6
times faster compared to 3.1 on my hardware (500ms to 80ms).

This also adds support for Catmull Rom curve inputs.

Differential Revision: https://developer.blender.org/D14435
2022-04-02 21:09:02 +08:00
2c1a79df3e Fix T96344: edit mode GPU subdivision crashes with X-ray mode and modifiers
The crash happens because the origindex layers created as part of
the modifier stack evaluation are not set in the `MeshRenderData` when
they should have been.

This is because when selecting in X-ray mode, a subdivision wrapper
is created to ensure that selection happens with a subdivided
geometry, and this replaces the `MDATA` wrapper which is also used to
setup the `MeshRenderData`.

As we do not seemingly have an `MDATA` wrapper, the draw code decides
that we can extract draw buffers directly from the BMesh, instead of
the mapped Mesh with origin indices layers.

To fix this, we should also consider to use mapped extraction if a
subdivision wrapper exists on the mesh.

Differential Revision: https://developer.blender.org/D14485
2022-04-02 21:09:02 +08:00
f40372aaf9 Overlay: Port Armature shader to ShaderCreateInfo
Should have no regression.
2022-04-02 21:09:02 +08:00
26037971e8 GL: Fix Invalid enum error on Apple Silicon
Guard shader storage related gets and bypass a buggy enum.

Fix T95592 OpenGL Invalid Enum
2022-04-02 21:09:02 +08:00
33b218a5f3 Overlay: Port Edit Mode shaders to ShaderCreateInfo
This should have no regression.
2022-04-02 21:09:02 +08:00
acf817e85b DRW: Port draw_common.c to use shared definition with GLSL
# Conflicts:
#	source/blender/draw/intern/draw_common_shader_shared.h
#	source/blender/draw/intern/shaders/draw_view_info.hh
2022-04-02 21:09:02 +08:00
cfa79f2a3f GPUShaderCreateInfo: Add DepthWrite option
This option lets specify explicitely how the fragment shader will change
the fragment's depth.
2022-04-02 21:09:02 +08:00
e705523404 GPU: ShaderBuilder: Remove do_static_compilation_ inheritance
This is because the inheritance is not done before checking if the shader
should be statically compiled. Also some inheritance scheme
might have intermediate permutation that are not compilable.
2022-04-02 21:09:02 +08:00
Pratik Borhade
430542c1ae Add soft limit for Bevel segments in modifier.
The recent change to allow a max segments of 1000 in the modifier
causes a lag when dragging or wheeling in the segments box.
This change makes the soft limit back to 100, but you can still
type numbers up to 1000 in the box.

Reviewed By: Howard Trickey
Differential Revision: https://developer.blender.org/D14477
2022-04-02 21:09:02 +08:00
e3524a5815 GPU: ShaderBuilder: Fix compilation on non-Mac platform
Regression introduced in rB664eb1936946a077498a17c22576763c664e3186
2022-04-02 21:09:02 +08:00
ecf7b1a92f Compositor: Fix Missing output UI for Normal node
There were multiple issues at hand here:

- The default value has been changed to `{0, 0, 1}` see: rB25f1783673de636a6f0ca4457df8c05bc685981a
- The output needs the subtype set `PROP_DIRECTION`
- The noder properties were missing in `node_composit_set_butfunc`

Fixes T96860
2022-04-02 21:09:02 +08:00
0708af357b Curves: support converting curves to legacy hair system
This adds a new operator that converts all selected curves objects
into hair particle systems on their respective surface objects. Existing
particle systems with the correct name are updated, otherwise a new
particle system is added.

The purpose of the operator is the make the new curve sculpting tools
useful even before all functionality is ported over from the old hair system.

The operator can be found in the `Object > Convert` menu in object mode,
when a curves object is active.

Differential Revision: https://developer.blender.org/D14441
2022-04-02 21:09:02 +08:00
d9a9dd77c5 Cleanup: Left over from review of apply transform
I miss the review notes about this for the
8621fdb10d commit.
2022-04-02 21:09:02 +08:00
46f0ef1f0b GPencil: Fix double-free issue in update cache
When a `GPencilUpdateCacheNode` is created, it always allocates the
`children` pointer. This should not be freed until the whole cache is
deleted.
The `cache_node_update` would free the `children` pointer in a specific
case, causing a double-free later when the cache was removed.
2022-04-02 21:09:02 +08:00
f32fb5f25c Apply Object Transform: Multi-user data support
The current behaviour is to prevent multi-user data from having its
transformation applied.

However in some particular cases it is possible to apply them:
* If all the users of the multi-user data are part of the selection.
* If not all the users are in the selection but the selection is made
single-user.

The active object is used as reference to set the transformation of the
other selected objects.

Note: For simplicity sake, this new behaviour is only available if all
the selection is using the same data.

Differential Revision: https://developer.blender.org/D14377
2022-04-02 21:09:02 +08:00
f1b782db11 Modifiers: Support applying modifiers for multi-user data
The current behaviour is to prevent multi-user data from having its
modifier applied.

Instead, with this patch, we now warn the user that if they want to
proceed the object will be made single-user.

Note that this only makes the object data single-user. Not the material
or actions.

As a future step we can apply the same behaviour for the Grease Pencil modifiers

Differential Revision: https://developer.blender.org/D14381
2022-04-02 21:09:02 +08:00
da39a7681a Iterator to loop over objects based on a flag 2022-04-02 21:09:02 +08:00
e6564648ef Cleanup: clang-format 2022-04-02 21:09:02 +08:00
51e48c24f8 Cleanup: use "num" as a suffix in: source/blender/blenlib
Also replace "num" with:
- "number" when it's not used to denote the number of items.
- "digits" when digits in a string are being manipulated.
2022-04-02 21:09:02 +08:00
0be5367c78 Cleanup: use "num" as a suffix in: source/blender/gpencil_modifiers 2022-04-02 21:09:02 +08:00
6a6d7c79d1 Fix: Failing curves test after recent commit
87e9451d66 missed updating the behavior for Catmull Rom curves.
2022-04-02 21:09:02 +08:00
6614dc359e Cleanup: use utility function to initialize SelectPick_Params 2022-04-02 21:09:02 +08:00
3e96c155d6 Fix leak transforming in the node-editor without a selection 2022-04-02 21:09:02 +08:00
533d05a86f Cleanup: remove redundant lattice de-selection 2022-04-02 21:09:02 +08:00
Aleksi Juvani
7eb2b3ab3a Cleanup: Move UV edit parameterize code to geometry module
This will allow reusing it elsewhere, such as in a geometry node.

Differential Revision: https://developer.blender.org/D14453
2022-04-02 21:09:02 +08:00
09691b524f Geometry Nodes: Remove soft min from extrude node scale
Extusion with a negative offset is possible and expected.
2022-04-02 21:09:01 +08:00
717892d288 Keymap: "Mouse Select & Move" now uses click to de-select others
While it's useful for click-drag to leave the selection as-is
(when clicking on items that are already selected), it's useful
for a single click to de-select all other elements.

This also removes the need for the initial selection to set the object
as active since this is possible by clicking on it.
2022-04-02 21:09:01 +08:00
4d0ddfe38d Curves: Port curves total length node to the new data-block
Ref T95443
2022-04-02 21:09:01 +08:00
c6eb6c26be Curves: Port length node to the new data-block
Ref T95443
2022-04-02 21:09:01 +08:00
29848f9bb2 Curves: Port parameter node to the new data-block
Using the evaluated lengths cache from 72d25fa41d, re-implement
the curve parameter node with the new data structure. Conceptually
it works the same way, but the code is restructured and cleaned up
a bit as well. This also adds support for Catmull Rom curves.

Differential Revision: https://developer.blender.org/D14461
2022-04-02 21:09:01 +08:00
a688f30bd3 Fix: Remove special case from curve segment size function
The idea that curves with two points cannot be cyclic came from some
existing code, but there's not fundamental reason for it, so remove the
check in this function. The case can be handled elsewhere if necessary.
2022-04-02 21:09:01 +08:00
08dee1408b Curves: Add length cache, length paramerterize utility
This commit adds calculation of lengths along the curve for each
evaluated point. This is used for sampling, resampling, the "curve
parameter" node, and potentially more places in the future.

This commit also includes a utility for calculation of uniform samples
in blenlib. It can find evenlyspaced samples along a sequence of points
and use linear interpolation to move data from those points to the
samples. Making the utility more general aligns better with the more
functional approach of the new curves code and makes the behavior
available elsewhere.

A "color math" header is added to allow very basic interpolation
between two colors in the `blender::math` namespace.

Differential Revision: https://developer.blender.org/D14382
2022-04-02 21:09:01 +08:00
bd0d641056 Cleanup: quiet warning for description ending with a full stop 2022-04-02 21:09:01 +08:00
08e679ca76 Cleanup: spelling in comments 2022-04-02 21:09:01 +08:00
0807d348bd Cleanup: use equality instead of contains for single-item sets 2022-04-02 21:09:01 +08:00
962a3c92f5 Cleanup: unbalanced doxy sections 2022-04-02 21:09:01 +08:00
47712d689c UI: Fix cosmetic papercuts of the reroute node
Fix small cosmetic issues with the reroute node:
1. Remove special case that allowed curved links to attach vertically.
2. Center align the reroute node's label.

The vertically attached node links could lead to kinks in the otherwise
smooth curves. This would break the visual flow and make the link
potentially intersect the node's label.

The center alignment of the label gives more consistent results for
different label lengths and also reduces the chance of the label
interfering with the node links.

Reviewed By: Hans Goudey, Pablo Vazquez

Differential Revision: D14457
2022-04-02 21:09:01 +08:00
ac7fc777cb Geometry Nodes: Don't create node tree when adding nodes modifier
Don't always create a new geometry nodes node tree when adding a
geometry nodes modifier.

This avoids files getting cluttered with empty and unused geometry node
trees that are created every time a nodes modifier is added to an
object - even if only to apply an already existing.
This is also more consistent with other modifiers that also don't
automatically create new data blocks.

The new modifier still automatically gets populated with a new node
tree when adding it via the "New" button in the header of the
geometry nodes editor.

Reviewed By: Hans Goudey, Dalai Felinto, Pablo Vazquez

Differential Revision: D14458
2022-04-02 21:09:01 +08:00
dec78a6330 GPencil: Remove UI prefix Use in Dot-Dash modifier
The "Use" word must not be used in UI.
2022-04-02 21:09:01 +08:00
7e89a1ca57 Fix: incorrect assert in new code 2022-04-02 21:09:01 +08:00
d3b0382a67 GPencil: Fix Windows compiler errors
For non trivial data must be used `MEM_new`
2022-04-02 21:09:01 +08:00
607188afb1 LibOverride: Massive edits to 'editable' IDs checks in editors code.
Add new `BKE_id_is_editable` helper in `BKE_lib_id.h`, that supercedes
previous check (simple `ID_IS_LINKED()` macro) for many editing cases.

This allows to also take into account 'system override' (aka
non-editable override) case.

Ref: {T95707}.
2022-04-02 21:09:01 +08:00
b3a3ae88c4 LibOverride: Rename 'delete hierarchy' to 'clear hierarchy', add 'clear single' operations.
'Delete' was a confusing name, even though it would delete the overrides
it would replace them by linked data.

Adding the 'single' version of that operation made it even more
confusing, since often it has to keep the override ID for sakes of
hierarchy, and just reset it and turn it back into a non-editable system
override.

Ref: {T95707}.
2022-04-02 21:09:01 +08:00
d5b57eb12a LibOverride: Implement default 'user override' behavior.
Implement default behavior to decide which overrides remain 'system'
ones, and which become 'user editable' ones, when creating hierarchy
override from 3DView or the Outliner.

3DView:
If from an Empty-instanced collection, only Armature objects in
that collection are user overrides.
If from a set of selected objects, all overrides created from selected
objects are user overrides.

Outliner:
All override IDs created from selected elements in the Outliner are user
overrides.
There is one special case: When a collection is selected, and is
'closed' in the outliner, all its inner armature objects are also user
overrides.

Ref: {T95707}.
2022-04-02 21:09:01 +08:00
0e39e046e0 LibOverride: Add initial handling of system overrides in creation/duplication/resync code, and some basic do_version.
When creating with hierarchies, core code only generates system
overrides, responsibility to define 'user overrides' is then for the
higher-level calling code (Editor/Operator-level).

do_version code uses fairly basic euristics, should be good enough here
though in most cases. and can always be refined later if needed.

Ref: {T95707}.
2022-04-02 21:09:01 +08:00
c8f8dd4513 LibOverride: make some override properties 'overridable'.
The whole liboverride data is still ignored by override diffing etc.,
but some of their flags should be editable (from script and/or advanced
technical/debug UI). So using a weird combination of flags to achieve
this.

Ref: {T95707}.
2022-04-02 21:09:01 +08:00
b94b9861ad LibOverride: Add a new 'virtual' non-editable override icon and use it in Outliner.
Ref: {T95707}.
2022-04-02 21:09:01 +08:00
a67e7ace30 LibOverride: Add initial System Override flag.
This merely adds the flag, exposes it in RMA, and uses it in some of the
most common 'is editable' checks (RNA, `BASE_EDITABLE` macro...).

Next step: do_version and defining systemoverrides at creation.

Ref: {T95707}.
2022-04-02 21:09:01 +08:00
f1365bb6c9 GPencil: Small UI tweaks to Build modifier
Changes in some names.
2022-04-02 21:09:01 +08:00
294c879f87 Cover DNA_gpencil_types.h with C++ structure methods
Ref T96847

Maniphest Tasks: T96847

Differential Revision: https://developer.blender.org/D14487
2022-04-02 21:09:01 +08:00
4ea52582df Cleanup: Remove legacy dupli system from point cloud object
The "dupli" system now has a faster, more powerful, and more flexible
alternative with geometry nodes. Since the point cloud objects haven't
been exposed in the non-experimental UI yet, we can remove the dupli
implementation and the panel for the object type.

Differential Revision: https://developer.blender.org/D14482
2022-04-02 21:09:01 +08:00
590ffb8c3c GPencil: Fading for build modifier.
Adds fading support for build modifier so it's not a hard cut off

Reviewed By: Antonio Vazquez (antoniov), Matias Mendiola (mendio)

Differential Revision: https://developer.blender.org/D14309
2022-04-02 21:09:01 +08:00
Henrik Dick
f32a1f12b2 GPencil: Fix sculpt mask ignoring one point strokes
The check for the selected status was missing in the case
where the stroke one has one point.

Differential Revision: http://developer.blender.org/D14490
2022-04-02 21:09:01 +08:00
0c24362e95 Assets: Support automatic collection previews
Adds supports for collection previews that are rendered automatically when
collections are marked as assets. (Or when preview rendering is triggered
differently, e.g. through the //Refresh Data-Block Previews// operator).

Idea in this patch is to create a collection instance empty outside of main for
the collection, and then reuse the object rendering code to render the preview.
This keeps things very simple and works just fine.

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

Reviewed by: Bastien Montagne
2022-04-02 21:09:01 +08:00
Yuki Hashimoto
bf946f224f Fix T63795: Display custom properties with brackets in info
When custom properties are changed, they are displayed with brackets in
info.

Ref D14380
2022-04-02 21:09:01 +08:00
3132e012d5 Fix T96844: Crash when switching workspaces and outliner modes
Error exposed by ba49345705. Code just assumed that the tree-element
pointed to a real ID, but this is often not the case, and the ID pointer
contains completely different data. E.g. before ba49345705, it would
be a pointer to one of the `Main` listbases, so this code would have
undefined behavior. Now the pointer is null for elements in the "Current
File" element, causing a null-pointer dereference rather than undefined
behavior (that just happened to virtually always result in the intended
code path).
2022-04-02 21:09:01 +08:00
5924e6a957 Curves: improve Snake Hook brush
This implements the spherical brush and different falloff
modes for the Snake Hook brush.

Differential Revision: https://developer.blender.org/D14408
2022-04-02 21:09:00 +08:00
46efebfd74 Icons: Programmatically create indirect library icon, remove from SVG
The indirect library data icon was just a grayed out version of the
regular one. This graying out is now done in code, so the icon can be
removed from the SVG. Note that the icon is still defined as
`ICON_LIBRARY_DATA_INDIRECT` (or `LIBRARY_DATA_INDIRECT` in BPY).
2022-04-02 21:09:00 +08:00
bede8d0a7f Fix T96835: Grease pencil tweak tool selects but doesn't drag
Use the pass-through matching the view3d.select operator.
2022-04-02 21:09:00 +08:00
b44e8d4ff2 Fix T96356: artefacts with GPU subdivision and vertex paint mask
The lines paint mask IBO extraction was not implemented for GPU subdivision.
For it to work, we also now need to preserve the subdivision loop to
subdivision edge map, which until now was overwritten to store coarse edges
(the map to coarse edges is still preserved).

Also the paint flag stored in the 4th dimension of the loop normal buffer
was not properly set for flat shaded faces, leading to other kind of
artefacts and render issues.
2022-04-02 21:09:00 +08:00
9fe8ee61d8 Cleanup: Remove commented lines of previous commit 2022-04-02 21:09:00 +08:00
eaea68ddb5 Fix T96799: GPencil weight_get API cannot retrieve weights
The problem was when the stroke had less weights that the total number of vertex groups.

The API checked the total number of groups, but this is not required because `BKE_defvert_find_index` returns NULL is the vertex group index does not exist.
2022-04-02 21:09:00 +08:00
7e6f987d80 Fix (unreported) LibOverride: re-creation of overrides in consecutive partial overrides of a same hierarchy.
If creating partial hierarchy overrides (from the outliner e.g.), that
need to create extra overrides, those could be re-created everytime,
leading to very bad situation where there would be several overrides of
the same reference ID in the same override hierarchy.

This fix makes it so that existing overrides in a given hierarchy will
always be re-used in case other overrides are added to the hierarchy.
2022-04-02 21:09:00 +08:00
afec7fff3c Cleanup: Use higher level semantic for zeroing DNA objects in C++
Replaces old-style memzero-style of call with zero-initializer.
Allows to shorten typical initialization code to a single line:

  Object foo = blender:🧬:shallow_zero_initialize<Object>()

This will allow to more easily convert designated initializer
which is often used to fill object with zeroes to the explicit
function calls:

  MyDNAStruct foo = {};

will be translated to

  MyDNAStruct foo = blender:🧬:shallow_zero_initialize<MyDNAStruct>();

Differential Revision: https://developer.blender.org/D14486
2022-04-02 21:09:00 +08:00
6f50d1b2b2 BLI: optimize Map/Set/VectorSet.clear methods
Previously, those methods would destruct and reconstruct
the data structure. While that was more simple in initial
implementation, it has some downsides which are not resolved:
* Already allocated memory is lost. So new memory would have
  to be allocated when the data structure is refilled.
* The clearing process itself was slower because it did unnecessary
  work.
2022-04-02 21:09:00 +08:00
f05eead2da Cleanup: Remove redundant DNA C++ helper function
Use shallow_copy, no need in copy_memory.

The latter appeared as some last minute solution for a compilation
warning on Friday.
2022-04-02 21:09:00 +08:00
5b93e6e353 Functions: move loops into function builders
This simplifies debugging, and can help improve performance
by making it easier for the compiler.

More optimization might still be possible by using `__restrict` in
a few places.
2022-04-02 21:09:00 +08:00
2869d77e99 BLI: add utility to convert IndexMask to best mask type 2022-04-02 21:09:00 +08:00
c89befe6bf Cleanup: use value initialization instead of copying default value
Value-initialization has the potential to be more efficient.
Also, the code becomes simpler.
2022-04-02 21:09:00 +08:00
fc208f70d6 BLI: support value initialization in CPPType
Value initialization differs from default-construction in that it
also zero-initializes trivial types.
2022-04-02 21:09:00 +08:00
66b6b1e8a0 Fix T96701: RMB select fails to show gizmo on mouse button release
Regression in [0] which removed a special check when tweak events ended.
Add a similar check for drag events that runs drag is disabled in the
main event handling loop.

[0]: 4986f71848
2022-04-02 21:09:00 +08:00
fab9685238 Fix T96582: Wipe effect not working
Caused by oversight in 0e38002dd5. Constant x/y value was used to
calculate transition instead of pixel x/y coords.
2022-04-02 21:09:00 +08:00
3a226ca396 Fix T96699: Splitting strip does not copy animation
Since e49bf4019b, animation is handled explicitly. Split operator
wasn't updated.

Re-use backup-duplicate-restore animation functions, that other
operators use for splitting.
2022-04-02 21:09:00 +08:00
5d6567754f Fix T96347: Pose gizmo shown at wrong location with multiple objects
Regression in [0] error iterating over pose bones which only used the
active-object, also follow the same logic as edit-mode for using the
local-matrix.

[0]: d052169e7e
2022-04-02 21:09:00 +08:00
f87d832ca0 Fix T96691: Heap corruption in file_browse_exec
Regression in [0], also use pad buffer by 1 instead of 2 which is no
longer needed as the trailing slash is no longer added
after allocating the string.

0682af0d63
2022-04-02 21:09:00 +08:00
fa8feefed4 Cleanup: Move two grease pencil files to C++
This is meant to allow using C++ data structures in this file
as a performance improvement. Particularly `Vector` instead
of `ListBase` for `duplilist`. This changes builds on all
platforms on the buildbot.
2022-04-02 21:09:00 +08:00
a008df9c1b Cleanup: Move scene.c to C++
This is meant to allow using C++ data structures in this file
as a performance improvement. Particularly `Vector` instead
of `ListBase` for `duplilist`. This change builds and passes
tests on all platforms on the buildbot.
2022-04-02 21:09:00 +08:00
93f5232593 Cleanup: Use const mesh arguments
Also correct an enum value from review of D14475.
2022-04-02 21:09:00 +08:00
7619e45f10 Cleanup: Move transform_snap_object.c to C++
This is meant to allow using C++ data structures in this file
as a performance improvement. Particularly `Vector` instead
of `ListBase` for `duplilist`.

Differential Revision: https://developer.blender.org/D14475
2022-04-02 21:09:00 +08:00
59272e0b89 Fix T96728: 'Automatic Constraint' using the wrong orientation
If the `Automatic Constraint` modifier was activated while an axis
constraint was already set, the orientation used would be the default
orientation of the mode and not that of the scene.

This was because the `initSelectConstraint` function was not called in
this case and the `Automatic Constraint` mode was enabled by other
indirect means.

So the solution is to call `initSelectConstraint` in either case and
remove these "indirect means" of enabling `Automatic Constraint`.
2022-04-02 21:09:00 +08:00
84430192b9 Transform: avoid excessive recalculation with 'TREDRAW_SOFT'
Contrary to the initial intention (in rB9916e0193c36), `TREDRAW_SOFT`
flag, when isolated, is not cleared in `transformApply` and therefore is
used in the `drawTransformApply` callback which basically recalculates
the `transformation` which finally clears the flag.

So remove the `drawTransformApply` callback so `transformApply` is not
called when unnecessary.

Differential Revision: https://developer.blender.org/D14430
2022-04-02 21:09:00 +08:00
e88cd959e4 Cleanup/Refactor: remove unused 'SNAP_ONLY_ACTIVE' enum parameter
`SNAP_ONLY_ACTIVE` was implemented in order to be used in the Knife tool,
but the project did not go ahead.
2022-04-02 21:09:00 +08:00
2a14bd1179 Transform: Improve 'absolute grid snap' support detection
The solution supposedly listed all cases that `absolute grid snapping`
was supported. But it ignored some occasions like: Editing Surface
objects, Texture Space.

List now only the cases where this feature should not be supported.
2022-04-02 21:09:00 +08:00
4771ee0e72 Cleanup: transform, use early returns
This makes the flow clearer and avoids many `else` conditions.
2022-04-02 21:09:00 +08:00
22c638170c Outliner: Don't show indirectly linked Library Overrides properties
The Library Overrides display mode is meant to show overridden
properties from the current file only, not library overrides in
data-blocks that just were linked in. The upcoming Hierarchies view mode
for Library Overrides will also display linked in data-blocks that have
overrides in the source file (but not the individual overridden
properties), see T95802.
2022-04-02 21:09:00 +08:00
d03253240f Fix T96812: Regression: Snapping is broken with proportional editing
This was a mistake in the conditional structure introduced in 4b35d6950d

This commit also adds a new type of snap exclusion: `SNAP_NOT_EDITED`.

Thanks to @Ethan1080 for pointing out the error.
2022-04-02 21:09:00 +08:00
25687cc7f4 Fix T96828: GPencil primitives handlers not working
Following the logic is not necessary to check the mouse button because the status has changed before.
2022-04-02 21:09:00 +08:00
68a1a3bc47 Cleanup: Use bool literals in return statements of text editor poll functions. 2022-04-02 21:09:00 +08:00
a1147fedd9 Fix various UI messages issues. 2022-04-02 21:09:00 +08:00
43e556c08d Fix (unreported) crash in some mesh-from-object code.
Crashed e.g. FBX exporter.

Mistake in rB0c33e84020deca.
2022-04-02 21:08:59 +08:00
d03a601996 Fix T96670: bake from multires not reflected in the Image Editor. 2022-04-02 21:08:59 +08:00
9ac508311f Cleanup: return success from python_script_error_jump
Relying on checks for the assignment of return arguments isn't so
clear especially when there are multiple return arguments.
2022-04-02 21:08:59 +08:00
7b197eb98e Python: select the start-end range of syntax errors
Python 3.10's syntax errors can specify a range.
Use this for text editor error selection.
2022-04-02 21:08:59 +08:00
af09e7fe84 Cleanup: variable/argument naming for Python exception access
Names filename/filepath/fn were used interchangeably.
2022-04-02 21:08:59 +08:00
2c21a9a88d Fix text editor failure to move the cursor for syntax errors
This broke between 3.0 and 3.1, upgrading to Python 3.10 seems the
likely cause as this code didn't change.
2022-04-02 21:08:59 +08:00
28ade2e4bb Cleanup: early exit when there is no exception
Reduces noise in D9752, no functional change as PyErr_NormalizeException
doesn't do anything when there is no exception set.
2022-04-02 21:08:59 +08:00
6ee54a69ae Cleanup: use "num" as a suffix in: source/blender/modifiers
Also rename DNA struct members.
2022-04-02 21:08:59 +08:00
b7b774d464 Cleanup: use "num" as a suffix in: source/blender/nodes 2022-04-02 21:08:59 +08:00
8715fffcd1 Cleanup: use "num" as a suffix in: source/blender/render
See T85728
2022-04-02 21:08:59 +08:00
56bf11091b Cleanup: use "num" as a suffix in: source/blender/python
See T85728
2022-04-02 21:08:59 +08:00
166645ee19 Cleanup: Reduce duplication to prepare for UDIM packing
In preparation for supporting packing of UDIM tiled textures, this patch
refactors a small portion of image.cc. The refactor should lead to less
duplicate code now and when Tiled images are added in the near future.

This patch is based on the prior work done for D6492 where it was
requested this part be split and can be summarized as follows:
 - `load_sequence_single` is removed and merged with `load_image_single`
 - `image_load_sequence_file` is removed and merged with `image_load_image_file`

Reviewed By: lukasstockner97

Differential Revision: https://developer.blender.org/D14327
2022-04-02 21:08:59 +08:00
349ec7cbe4 OBJ: use fmt library instead of sprintf for faster formatting
On Windows/MSVC this gives a minor (~20%) speedup presumably due to a faster float/int formatter. On macOS (Xcode13), this gives a massive speedup, since snprintf that is in system libraries ends up spending almost all the time inside some locale-related mutex lock.

The actual exporter code becomes quite a bit smaller too, since it does not have to do any juggling to support std::string arguments, and the buffer handling code is smaller as well.

Windows (VS2022 release build, Ryzen 5950X 32 threads) timings:
- Blender 3.0 splash scene (2.4GB obj): 4.57s -> 3.86s
- Monkey subdivided level 6 (330MB obj): 1.10s -> 0.99s

macOS (Xcode 13 release build, Apple M1Max) timings:
- Blender 3.0 splash scene (2.4GB obj): 21.03s -> 5.52s
- Monkey subdivided level 6 (330MB obj): 3.28s -> 1.20s

Linux (ThreadRipper 3960X 48 threads) timings:
- Blender 3.0 splash scene (2.4GB obj): 10.10s -> 4.40s
- Monkey subdivided level 6 (330MB obj): 2.16s -> 1.37s

The produced obj/mtl files are identical to before.

Reviewed By: Howard Trickey, Dalai Felinto

Differential Revision: https://developer.blender.org/D13998
2022-04-02 21:08:59 +08:00
6a0b663467 Cleanup: Remove frameserver cmake definition
Left over from rBaab5ac25f2c2e6fbc50f9fb352e71ef0ae0ba2f1
2022-04-02 21:08:59 +08:00
Lictex Steaven
f38b058d56 GPencil: Add an xray toggle for each annotation layer
so a layer can be occluded by the scene instead of always showing in front

---

{F12827163}

Reviewed By: fclem, antoniov

Differential Revision: https://developer.blender.org/D13931
2022-04-02 21:08:59 +08:00
d32c3c4ee6 Increase bevel segment limit in modifier from 100 to 1000.
A user asked for this increase. The performance lags when reaching
the upper limit of this number of segments, but if you need that
many segments, I guess you are willing to wait.
2022-04-02 21:08:59 +08:00
7df2e83f80 LineArt: Use reserve() before merging occlusion results. 2022-03-31 11:33:46 +08:00
e0e14daa3d Revert "LineArt: Trying out moller tri-tri functions."
This reverts commit 6ffe5a545b.

It doesn't really work.
2022-03-31 11:28:30 +08:00
6ffe5a545b LineArt: Trying out moller tri-tri functions. 2022-03-29 21:58:47 +08:00
0a7b664fdc LineArt: Correctly working multithread object loading. 2022-03-28 11:06:42 +08:00
5f3fb636a0 Merge remote-tracking branch 'origin/master' into temp-lineart-embree 2022-03-27 00:06:53 +08:00
de21b26a74 LineArt: Fix cmake include path 2022-03-27 00:06:24 +08:00
ea051e96b6 Fix T96790: Gpencil Inverted Fill makes extra stroke at origin
The problem was the stroke was created in the inverted loop before checking if the total of points is 0 and exit the loop.

Also some code Cleanup.
2022-03-27 00:06:24 +08:00
84463317c6 DRW: Port draw_common.c to use shared definition with GLSL 2022-03-27 00:06:24 +08:00
2e6d1150a7 GPU: ShaderBuilder: Skip shader compilation for unsupported shaders. 2022-03-27 00:06:24 +08:00
b7bd42db89 GL: Fix shader error logging on Apple M1 hardware 2022-03-27 00:06:24 +08:00
ba6e349991 GPU: ShaderBuilder: Fix compilation on Mac
This is less than ideal as it seems to link against all
of blender disregarding the stubs.
2022-03-27 00:06:24 +08:00
9745a50bb5 Cleanup: move eFileSel_Action from DNA to WM_api.h
This isn't stored in blend files so it can be moved out of DNA.

Also use an enum for `WM_FILESEL_*` members.
2022-03-27 00:06:24 +08:00
ab9d448be6 Fix incorrect argument for rigid-body world export 2022-03-27 00:06:24 +08:00
6bcebe7d74 Cleanup: use "use_" prefix for booleans 2022-03-27 00:06:24 +08:00
4cb412a25f Cleanup: quiet compiler warning 2022-03-27 00:06:24 +08:00
a313533f33 Windows/Installer: Fix capital B in shortcut
the shortcut placed on the desktop and in the start
menu on windows were labelled `blender` rather than `Blender`

spotted by @Severin
2022-03-27 00:06:24 +08:00
bf3e2656ac CMake: Give some extra space to info_cfg_option
WITH_PYTHON_INSTALL_ZSTANDARD was too long and
didn't align very well compared to the other
items in the list.
2022-03-27 00:06:24 +08:00
5bfa7e48f4 Fix Outliner highlighting multiple base elements in different libraries
In the Blender File display mode of the Outliner, mouse hovering a
"base" element (e.g. "Objects", "Materials", ...) would also highlight
that same base element in other libraries linked into the scene. In fact
operations like (un)collapsing would be applied to both too.
Issue was that we'd always use the listbase containing the data-blocks
from the current main as a way to identify the tree element. So for the
same data-block types we'd use the same listbase pointers. Instead use
the the library pointer + a per library index.
2022-03-27 00:06:24 +08:00
cac7a0e2c5 MSVC: Fix linker issue with USD
USD requires to be linked with /WHOLEARCHIVE so
the linker won't remove their static initializers.

This strangely has never worked for MSVC since
the flags were set on the LINK_FLAGS property
which is only used to link .dll and .exe files,
given this is a static lib, the flags were not
used, nor did CMake propagate the link directive
to the final targets that did link. Not quite sure
how this has not lead to more problems in the past.

Setting the link directive on the INTERFACE_LINK_OPTIONS
makes cmake do the right thing.

Differential Revision: https://developer.blender.org/D14394
Reviewed by: sybren
2022-03-27 00:06:24 +08:00
56cf70ad64 USD I/O: explicitly set or clear the OPTYPE_UNDO flag
Exporting USD cannot be undone, but importing should be undo'able.
2022-03-27 00:06:23 +08:00
42960aed3c Image editor: not updating after image operation.
Fixes T96324, T96312, T96323
2022-03-27 00:06:23 +08:00
f079fae863 USD: Support building against USD 21.11+
For 3.2 USD will be bumped to a newer version with some
slight API changes, however since we cannot simultaneously
land the libs for all platforms as well as these code changes,
we'll have to support both 21.02 and 21.11+ for at least a
short period of time making the code slightly more messy than
it could have been.

Differential Revision: https://developer.blender.org/D14184
Reviewed by: sybren
2022-03-27 00:06:23 +08:00
880eecac68 BLI: Adjust interpolation to support integers, other tweaks
In order to allow interpolation of integers with a float, add a separate
template parameter for the factor and multiplication types.
Also move some helper constexpr variables to the "base" header
(reversing the dependency to "base" -> "vector").

This also adds a distance function for scalar types, which is
helpful to allow sharing code between vectors and basic types.

Differential Revision: https://developer.blender.org/D14446
2022-03-27 00:06:23 +08:00
25e8f30467 Cleanup: Add asserts, remove default case 2022-03-27 00:06:23 +08:00
ba22fa4dd9 Curves: Bezier and general interpolate to evaluated utility
This commit implements generic evaluation for Bezier curves (which is
really just linear interpolation, since attributes are not stored on
Bezier handles). For complete parity with the old curve type, we would
have to add options for this (RNA: `Spline.radius_interpolation`),
but it's not clear that we want to do that.

This also adds a generic `interpolate_to_evaluate` utility on curves
that hides the implementation details. Though there is theoretically
a performance cost to that, without some abstraction calling code
would usually be too complex.

Differential Revision: https://developer.blender.org/D14447
2022-03-27 00:06:23 +08:00
13bafb91b9 Curves: Add a utility to count curves of each type
This commit adds a utility that returns an array with the number
of curves of every type. One use case for this is detecting whether
to remove handle or NURBS attributes when changing curve types.
It's best to avoid using this when it's not necessary, but sometimes
it can't really be avoided, and having a utility at least makes using
an optimized version simple.

In the future, this information can be cached in the curves runtime.

Differential Revision: https://developer.blender.org/D14448
2022-03-27 00:06:23 +08:00
4597592d65 MSVC: Fix build issue with webp
The webp variables should only be set if
the libs actually exist in the lib folder
2022-03-27 00:06:23 +08:00
b6a4a8d5cd GPencil: Cyclic flag for dot dash modifier
Cyclic option per segment, allows interesting "loop" visual effects.

Reviewed by: Antonio Vazquez (antoniov)

Differential Revision: https://developer.blender.org/D14439
2022-03-27 00:06:23 +08:00
f8fd64052e LineArt: embree put occlusion detection inside collider 2022-03-26 21:28:50 +08:00
beb4dd5de5 Merge remote-tracking branch 'origin/master' into temp-lineart-embree 2022-03-25 19:38:31 +08:00
51b467afe3 LineArt: Use thread local stroage for occlusion pair results 2022-03-25 19:22:31 +08:00
7393e1bc94 LineArt: Embree working demo. 2022-03-19 16:18:49 +08:00
2c1ecc6aa6 LineArt: embree mesh index aligning fix wip 2022-03-18 14:07:01 +08:00
da02b2ed5b LineArt: Embree wip runnable 2022-03-15 21:53:22 +08:00
e9c8e616b5 LineArt: Embree wip. 2022-03-14 22:51:23 +08:00
3f9a040e45 LineArt: [NOT WORKING] Embree virtual triangle WIP 2022-03-13 21:37:05 +08:00
ea8e95cc78 Merge remote-tracking branch 'origin/master' into temp-lineart-embree 2022-03-13 15:06:37 +08:00
d80c888baa Merge remote-tracking branch 'origin/master' into temp-lineart-embree 2022-01-17 17:30:03 +08:00
82e0783f60 LineArt: Workable embree intersection stage. 2022-01-16 21:14:18 +08:00
12 changed files with 1701 additions and 63 deletions

View File

@@ -355,32 +355,7 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr)
{
BLI_freenode *newhead = addr;
#ifndef NDEBUG
{
BLI_mempool_chunk *chunk;
bool found = false;
for (chunk = pool->chunks; chunk; chunk = chunk->next) {
if (ARRAY_HAS_ITEM((char *)addr, (char *)CHUNK_DATA(chunk), pool->csize)) {
found = true;
break;
}
}
if (!found) {
BLI_assert_msg(0, "Attempt to free data which is not in pool.\n");
}
}
/* Enable for debugging. */
if (UNLIKELY(mempool_debug_memset)) {
memset(addr, 255, pool->esize);
}
#endif
if (pool->flag & BLI_MEMPOOL_ALLOW_ITER) {
#ifndef NDEBUG
/* This will detect double free's. */
BLI_assert(newhead->freeword != FREEWORD);
#endif
newhead->freeword = FREEWORD;
}

View File

@@ -636,6 +636,9 @@ static void draw_subdiv_cache_extra_coarse_face_data_mesh(Mesh *mesh, uint32_t *
if ((mesh->mpoly[i].flag & ME_FACE_SEL) != 0) {
flag |= SUBDIV_COARSE_FACE_FLAG_SELECT;
}
if ((mesh->mpoly[i].flag & ME_FACE_SEL) != 0) {
flag = SUBDIV_COARSE_FACE_FLAG_SELECT;
}
flags_data[i] = (uint)(mesh->mpoly[i].loopstart) | (flag << SUBDIV_COARSE_FACE_FLAG_OFFSET);
}
}

View File

@@ -615,9 +615,9 @@ static void drw_call_obinfos_init(DRWObjectInfos *ob_infos, Object *ob)
/* Random float value. */
uint random = (DST.dupli_source) ?
DST.dupli_source->random_id :
/* TODO(fclem): this is rather costly to do at runtime. Maybe we can
* put it in ob->runtime and make depsgraph ensure it is up to date. */
BLI_hash_int_2d(BLI_hash_string(ob->id.name + 2), 0);
/* TODO(fclem): this is rather costly to do at runtime. Maybe we can
* put it in ob->runtime and make depsgraph ensure it is up to date. */
BLI_hash_int_2d(BLI_hash_string(ob->id.name + 2), 0);
ob_infos->ob_random = random * (1.0f / (float)0xFFFFFFFF);
/* Object State. */
ob_infos->ob_flag = 1.0f; /* Required to have a correct sign */

View File

@@ -1,6 +1,18 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright 2018 Blender Foundation. All rights reserved.
if(WITH_TBB)
add_definitions(-DWITH_TBB)
list(APPEND INC_SYS
${TBB_INCLUDE_DIRS}
)
list(APPEND LIB
${TBB_LIBRARIES}
)
endif()
set(INC
.
intern
@@ -24,10 +36,19 @@ set(INC
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
set(INC_SYS
list(APPEND INC_SYS
${ZLIB_INCLUDE_DIRS}
)
if(WITH_CYCLES_EMBREE)
add_definitions(-DWITH_EMBREE)
add_definitions(-DEMBREE_STATIC_LIB)
include_directories(
SYSTEM
${EMBREE_INCLUDE_DIRS}
)
endif()
set(SRC
intern/MOD_gpencil_ui_common.c
@@ -64,6 +85,7 @@ set(SRC
intern/MOD_gpencil_util.h
# Lineart code
intern/lineart/lineart_cpp_bridge.cpp
intern/lineart/lineart_chain.c
intern/lineart/lineart_cpu.c
intern/lineart/lineart_ops.c

View File

@@ -12,8 +12,18 @@
#include "BLI_math.h" /* Needed here for inline functions. */
#include "BLI_threads.h"
#include <embree3/rtcore.h>
#include <math.h>
typedef struct EdgeFacePair {
int v1;
int v2;
int f1;
int f2;
uint16_t eflag;
} EdgeFacePair;
typedef struct LineartStaticMemPoolNode {
Link item;
size_t size;
@@ -66,6 +76,7 @@ typedef enum eLineArtElementNodeFlag {
LRT_ELEMENT_IS_ADDITIONAL = (1 << 0),
LRT_ELEMENT_BORDER_ONLY = (1 << 1),
LRT_ELEMENT_NO_INTERSECTION = (1 << 2),
LRT_ELEMENT_IS_EDGE = (1 << 3),
} eLineArtElementNodeFlag;
typedef struct LineartElementLinkNode {
@@ -77,6 +88,9 @@ typedef struct LineartElementLinkNode {
/** Per object value, always set, if not enabled by #ObjectLineArt, then it's set to global. */
float crease_threshold;
/** Occlusion virtual triangle needs this postion as the 3rd point. */
double *cam_pos;
} LineartElementLinkNode;
typedef struct LineartEdgeSegment {
@@ -129,6 +143,7 @@ typedef struct LineartEdge {
int v1_obindex, v2_obindex;
struct LineartTriangle *t1, *t2;
ListBase segments;
char lock_id;
char min_occ;
/** Also for line type determination on chaining. */
@@ -200,6 +215,56 @@ enum eLineArtTileRecursiveLimit {
#define LRT_TILE_SPLITTING_TRIANGLE_LIMIT 100
#define LRT_TILE_EDGE_COUNT_INITIAL 32
struct MLoopTri;
struct MLoop;
struct LineartRenderBuffer;
typedef struct LineartPointArrayFinal {
// float *points;
// int numpoints;
// struct MLoopTri *looptri; /* Refernce to original_me->runtime->looptri; */
// struct MLoop *loop; /* Refernce to original_me->mloop; */
LineartElementLinkNode *eln_triangle;
struct LineartRenderBuffer *rb;
} LineartPointArrayFinal;
typedef struct LineartIntersectionRecord {
double p1[3];
double p2[3];
struct LineartTriangle *t1;
struct LineartTriangle *t2;
} LineartIntersectionRecord;
typedef struct LineartMeshRecord {
LineartPointArrayFinal *array;
uint32_t next;
uint32_t max_length;
struct LineartIntersectionRecord *intersection_record;
uint32_t intersection_pair_max;
uint32_t intersection_pair_next;
} LineartMeshRecord;
typedef struct LineartOcclusionPair {
LineartElementLinkNode *eln_edge;
LineartElementLinkNode *eln_triangle;
LineartEdge *e;
LineartTriangle *t;
double cut_l;
double cut_r;
} LineartOcclusionPair;
typedef struct LineartOcclusionPairRecord {
LineartOcclusionPair *array;
uint32_t next;
uint32_t max_length;
uint32_t scheduled_next;
} LineartOcclusionPairRecord;
typedef struct LineartThreadOcclusionData LineartThreadOcclusionData;
typedef struct LineartThreadOcclusionDataCombined LineartThreadOcclusionDataCombined;
#define LRT_LOCK_COUNT_OCCLUSION 100
typedef struct LineartRenderBuffer {
struct LineartRenderBuffer *prev, *next;
@@ -244,6 +309,18 @@ typedef struct LineartRenderBuffer {
int triangle_size;
RTCDevice rtcdevice;
/* According to embree manual, geometries and buffers are destroyed when their reference count
* drops to 0, so in principle we don't need to retain pointers to them if we destroy the scene
* at once. */
RTCScene rtcscene_geom;
RTCScene rtcscene_view;
struct LineartThreadOcclusionData *thread_occlusion_data;
struct LineartThreadOcclusionDataCombined *thread_occlusion_data_storage;
LineartMeshRecord mesh_record;
LineartOcclusionPairRecord occlusion_record;
/* Although using ListBase here, LineartEdge is single linked list.
* list.last is used to store worker progress along the list.
* See lineart_main_occlusion_begin() for more info. */
@@ -259,6 +336,9 @@ typedef struct LineartRenderBuffer {
/* For managing calculation tasks for multiple threads. */
SpinLock lock_task;
/* A series of locks to give threads more breathing room while applying occlusion results. */
SpinLock lock_occlusion[100];
/* settings */
int max_occlusion_level;
@@ -367,6 +447,10 @@ typedef struct LineartRenderTaskInfo {
ListBase edge_mark;
ListBase floating;
/* Range: [start, end) */
size_t ocpair_index_start;
size_t ocpair_index_end;
} LineartRenderTaskInfo;
typedef struct LineartObjectInfo {
@@ -381,6 +465,8 @@ typedef struct LineartObjectInfo {
uint8_t override_intersection_mask;
int global_i_offset;
uint32_t embree_geom_id;
bool free_use_mesh;
/* Threads will add lines inside here, when all threads are done, we combine those into the
@@ -396,7 +482,7 @@ typedef struct LineartObjectInfo {
typedef struct LineartObjectLoadTaskInfo {
struct LineartRenderBuffer *rb;
struct Depsgraph *dg;
int thread_id;
/* LinkNode styled list */
LineartObjectInfo *pending;
/* Used to spread the load across several threads. This can not overflow. */
@@ -715,3 +801,26 @@ void MOD_lineart_gpencil_generate(LineartCache *cache,
float MOD_lineart_chain_compute_length(LineartEdgeChain *ec);
void ED_operatortypes_lineart(void);
#ifdef __cplusplus
extern "C" {
#endif
LineartThreadOcclusionData *lineart_thread_init_occlusion_result(void);
void lineart_thread_add_occlusion_pair(LineartThreadOcclusionData *data,
LineartElementLinkNode *eln_edge,
LineartElementLinkNode *eln_triangle,
LineartEdge *e,
LineartTriangle *t,
double cut_l,
double cut_r);
LineartOcclusionPair *lineart_thread_finalize_occlusion_result(
LineartThreadOcclusionData *data,
int *result_count,
LineartThreadOcclusionDataCombined **r_combined_storage);
void lineart_thread_clear_occlusion_result(LineartThreadOcclusionData *data,
LineartThreadOcclusionDataCombined *combined_storage);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,73 @@
#include "MOD_lineart.h"
#include "lineart_intern.h"
#include "BLI_enumerable_thread_specific.hh"
#include "BLI_task.h"
#include "BLI_utildefines.h"
#include "BLI_vector.hh"
using blender::Vector;
using blender::threading::EnumerableThreadSpecific;
typedef EnumerableThreadSpecific<Vector<LineartOcclusionPair>> _LineartThreadOcclusionData;
typedef struct LineartThreadOcclusionData LineartThreadOcclusionData;
typedef Vector<LineartOcclusionPair> _LineartThreadOcclusionDataCombined;
typedef struct LineartThreadOcclusionDataCombined LineartThreadOcclusionDataCombined;
LineartThreadOcclusionData *lineart_thread_init_occlusion_result()
{
_LineartThreadOcclusionData *result = new _LineartThreadOcclusionData;
return (LineartThreadOcclusionData *)result;
};
void lineart_thread_add_occlusion_pair(LineartThreadOcclusionData *data,
LineartElementLinkNode *eln_edge,
LineartElementLinkNode *eln_triangle,
LineartEdge *e,
LineartTriangle *t,
double cut_l,
double cut_r)
{
LineartOcclusionPair op;
op.e = e;
op.t = t;
op.eln_edge = eln_edge;
op.eln_triangle = eln_triangle;
op.cut_l = cut_l;
op.cut_r = cut_r;
((_LineartThreadOcclusionData *)data)->local().append(op);
}
/* Memory returned by this needs to be freed manually. */
LineartOcclusionPair *lineart_thread_finalize_occlusion_result(
LineartThreadOcclusionData *data,
int *result_count,
LineartThreadOcclusionDataCombined **r_combined_storage)
{
Vector<LineartOcclusionPair> *result = new Vector<LineartOcclusionPair>;
int count = 0;
for (const Vector<LineartOcclusionPair> &local : (*(_LineartThreadOcclusionData *)data)) {
count += local.size();
}
/* Reserve once so it's faster to extend. */
result->reserve(count);
for (const Vector<LineartOcclusionPair> &local : (*(_LineartThreadOcclusionData *)data)) {
result->extend(local);
}
*result_count = count;
*r_combined_storage = (LineartThreadOcclusionDataCombined *)result;
return (LineartOcclusionPair *)result->data();
};
void lineart_thread_clear_occlusion_result(LineartThreadOcclusionData *data,
LineartThreadOcclusionDataCombined *combined_storage)
{
_LineartThreadOcclusionData *occlusion_data = (_LineartThreadOcclusionData *)data;
_LineartThreadOcclusionDataCombined *combined = (_LineartThreadOcclusionDataCombined *)
combined_storage;
delete occlusion_data;
delete combined;
};

File diff suppressed because it is too large Load Diff

View File

@@ -316,7 +316,7 @@ class FormatHandler : NonCopyable, NonMovable {
* `eFileType::MTL`.
*/
template<typename FileTypeTraits<filetype>::SyntaxType key, typename... T>
constexpr void write(T &&...args)
constexpr void write(T &&... args)
{
/* Get format syntax, number of arguments expected and whether types of given arguments are
* valid.
@@ -340,7 +340,7 @@ class FormatHandler : NonCopyable, NonMovable {
}
}
template<typename... T> void write_impl(const char *fmt, T &&...args)
template<typename... T> void write_impl(const char *fmt, T &&... args)
{
/* Format into a local buffer. */
fmt::memory_buffer buf;

View File

@@ -50,6 +50,9 @@ typedef enum eLineartEdgeFlag {
LRT_EDGE_FLAG_CHAIN_PICKED = (1 << 6),
LRT_EDGE_FLAG_CLIPPED = (1 << 7),
/** Limited to 8 bits, DON'T ADD ANYMORE until improvements on the data structure. */
/** For object loading code to use only. */
LRT_EDGE_FLAG_INHIBIT = (1 << 14),
} eLineartEdgeFlag;
#define LRT_EDGE_FLAG_ALL_TYPE 0x3f