Commit Graph

21262 Commits

Author SHA1 Message Date
Campbell Barton f5679838bc Docs: document all Global (G) struct members 2021-12-13 14:05:31 +11:00
Hans Goudey 03015a9b22 Cleanup/docs: Add comment to spline lookup factor method 2021-12-12 18:03:30 -06:00
Ankit Meel 9df13fba69 macOS: add tilde-based path expander
Replaces `HOME` environment variable usage for user
directories like in D12802.

Reviewed By: #platform_macos, brecht
Differential Revision: https://developer.blender.org/D13212
2021-12-11 22:29:53 +05:30
Hans Goudey 23be5fd449 Cleanup: Use const arguments
Also remove unnecessary function to set a node type's
label function that duplicated its definition, and make
another function static.
2021-12-11 09:51:53 -06:00
Hans Goudey 1a02c0d7dd Cleanup: Return early for null check 2021-12-10 16:42:34 -06:00
Hans Goudey a8b730e04c Cleanup: Use const argument, rename variables
The const argument makes sense because these are the "source"
sockets, even though a const cast is necessary at one point.
The name "interface_socket" is an improvement over "stemp"
because the latter sounds like "temporary", or it confuses
the old socket template system with a node group's interface.
2021-12-10 14:54:32 -06:00
Hans Goudey 5ca38fd612 Cleanup/Docs: Add comments to Mesh header, rearrange fields
Most of the fields in Mesh had no comments, or outdated misleading
comments. For example, "BMESH ONLY" referred to the BMesh project,
not the data structure. Given how much these structs are used, it should
save a lot of time to have proper comments.

I also rearranged the fields in mesh to have a more logical order. Now
the most important fields come first. In the process I was able to
remove 19 bytes of unnecessary padding (31->12). I just had to
change a `short` flag to `char`.

Differential Revision: https://developer.blender.org/D13454
2021-12-10 10:42:28 -06:00
Campbell Barton bd2b48e98d Cleanup: move public doc-strings into headers for various API's
Some doc-strings were skipped because of blank-lines between
the doc-string and the symbol and needed to be moved manually.

- Added space below non doc-string comments to make it clear
  these aren't comments for the symbols directly below them.
- Use doxy sections for some headers.

Ref T92709
2021-12-10 21:42:06 +11:00
Hans Goudey dffd032bc9 Geometry Nodes: Remove unnecessary copy when replacing data
In the `replace_mesh`/`replace_curve` etc. methods, the component
was retrieved with write access. Retrieving with write access will
duplicate the data if the component has another user. This means that
the replaced geometry data was often duplicated just to be deleted
a moment later.

I expect this would have a large impact in performance in some specific
situations when dealing with large geometry. In a scene with many small
meshes though, I didn't observe a significant difference.

This also makes replacing a geometry set's data with the same data
that's already in the set safe. It would be valid to assert for that
case instead, but this seems safer.

Differential Revision: https://developer.blender.org/D13530
2021-12-09 17:43:30 -06:00
Hans Goudey 74a566d211 Cleanup: Return early in null check
I'm planning to make these functions slightly more complicated,
and it makes sense to return early when checking one of the parameters
for null anyway.
2021-12-09 14:34:15 -06:00
Johnny Matthews bd3bd776c8 Geometry Nodes: Scene Time Node
This node outputs the current scene time in seconds or in frames.
Use of this node eliminates the need to use drivers to control values
in the node tree that are driven by the scene time.
Frame is a float value to provide for subframe rendering for motion
blur.

Differential Revision: https://developer.blender.org/D13455
2021-12-09 11:50:25 -06:00
Brecht Van Lommel e427e4dbb1 Fix T93871: Image.has_data returns True for images that failed to load 2021-12-09 17:36:19 +01:00
Campbell Barton 8ef8f3a60a Cleanup: spelling in comments 2021-12-09 20:21:26 +11:00
Erik 3753a0b72b Fix T93523: Memory leak in Menu Search
Fixes a memory leak introduced by D13225.
Caused by not freeing the hash-map in some cases.

Differential Revision: https://developer.blender.org/D13432
2021-12-09 01:48:11 +01:00
Johnny Matthews 069d63561a Geometry Nodes: Mesh Island Node
This node is a field input that outputs a separate index for each mesh island.
The indices are based on the order of the lowest-numbered vertex in each island.

Authoring help from @hooglyboogly

Differential Revision: https://developer.blender.org/D13504
2021-12-08 10:14:03 -06:00
Jeroen Bakker a7b64a714d Cleanup: Silence clang-tidy warnings. 2021-12-08 09:52:38 +01:00
Aaron Carlisle c1279768a7 Cleanup: Clang-Tidy modernize-redundant-void-arg 2021-12-08 00:31:20 -05:00
Campbell Barton 2964c4e1d0 Cleanup: spelling in comments 2021-12-08 13:31:19 +11:00
Hans Goudey 5568455d63 Cleanup: Extend a few comments in BKE_spline.hh 2021-12-07 15:17:10 -05:00
Hans Goudey 7fbb767259 Docs: Add more comments to geometry set header
This adds a bit more information to `GeometrySet` and each of the
geometry components. There is probably still more that can be written,
but this includes the most important information that I could think of.

I'd like to include some more general information about the
attribute API in a separate patch.

Differential Revision: https://developer.blender.org/D13501
2021-12-07 13:04:32 -05:00
Johnny Matthews c4cee2e221 Geometry Nodes: Edge Neighbors Node
Creates a new Edge Neighbors node which outputs a field
containing the number of faces connected to each edge.

Differential Revision: https://developer.blender.org/D13493
2021-12-07 10:07:24 -06:00
Jacques Lucke 565b33c0ad Geometry Nodes: new Geometry to Instance node
This adds a new Geometry to Instance node that turns every
connected input geometry into an instance. Those instances
can for example be used in the Instance on Points node.

Differential Revision: https://developer.blender.org/D13500
2021-12-07 15:37:12 +01:00
Jacques Lucke a8e0fe6a54 Geometry Nodes: move type conversions to blenkernel
The type conversions do not depend on other files in the nodes
module. Furthermore we want to use the conversions in the
geometry module without creating a dependency to the
nodes module there.
2021-12-07 15:22:08 +01:00
Hans Goudey 2309fa20af Cleanup: Add macro and functions for node storage
The `node_storage` functions to retrieve const and mutable structs
from a node are generated by a short macro that can be placed at the
top of each relevant file. I use this in D8286 to make code snippets
in the socket declarations much shorter, but I thought it would be
good to use it consistently everywhere else too.

The functions are also useful to avoid copy and paste errors,
like the one corrected in the cylinder node in this commit.

Differential Revision: https://developer.blender.org/D13491
2021-12-07 09:09:30 -05:00
Jacques Lucke 0f48b37aae Revert moving all shader nodes to c++
This reverts to following commits:
* rB5cad004d716da02f511bd34983ac7da820308676
* rB97e3a2d935ba9b21b127eda7ca104d4bcf4e48bd
* rBf60b95b5320f8d6abe6a629fe8fc4f1b94d0d91c
* rB0bd3cad04edf4bf9b9d3b1353f955534aa5e6740
* rBf72cc47d8edf849af98e196f721022bacf86a5e7
* rB3f7014ecc9d523997062eadd62888af5fc70a2b6
* rB0578921063fbb081239439062215f2538a31af4b
* rBc20098e6ec6adee874a12e510aa4a56d89f92838
* rBd5efda72f501ad95679d7ac554086a1fb18c1ac0

The original move to c++ that the other commits depended upon had some issues
that should be fixed before committing it again. The issues were reported in
T93797, T93809 and T93798.

We should also find a better rule for not using c-style casts going forward,
although that wouldn't have been reason enough to revert the commits.
Introducing something like a `MEM_new<T>` and `MEM_delete<T>`
function might help with the the most common case of casting the return
type of `MEM_malloc`.

Going forward, I recommend first committing the changes that don't
require converting files to c++. Then convert the shading node files
in smaller chunks. Especially don't mix fairly low risk changes like
moving some simple nodes, with higher risk changes.
2021-12-07 13:26:39 +01:00
Campbell Barton 1de3636624 Cleanup: note that functions in BKE_node.h aren't part of blenkernel 2021-12-07 18:55:57 +11:00
Campbell Barton 512a560cde Cleanup: remove BKE_ptcache_remove
No longer needed as the temporary directory is cleared on exit.
2021-12-07 18:47:01 +11:00
Campbell Barton 1e7ef83e46 Cleanup: clarify source/destination args for BKE_spacedata_copylist 2021-12-07 18:26:35 +11:00
Campbell Barton a37a6fb445 Cleanup: remove incorrect/unhelpful comments 2021-12-07 18:23:57 +11:00
Campbell Barton 6483dee141 Cleanup: replace int with bool type 2021-12-07 18:15:15 +11:00
Campbell Barton ffc4c126f5 Cleanup: move public doc-strings into headers for 'blenkernel'
- Added space below non doc-string comments to make it clear
  these aren't comments for the symbols directly below them.
- Use doxy sections for some headers.
- Minor improvements to doc-strings.

Ref T92709
2021-12-07 17:38:48 +11:00
luzpaz f159d49f56 Cleanup: Fix various source typos
This is a continuation of D13462 to clean up source typos.

Differential Revision: https://developer.blender.org/D13471
2021-12-06 22:39:52 -05:00
Hans Goudey aa23e870ec Cleanup: Remove unused includes 2021-12-06 16:50:44 -05:00
Aaron Carlisle f60b95b532 Shader Nodes: Split each node into own file
This improves both code finding,  for example "color ramp" now has its own file.
And now each node has its own namespace so function names can be simplified
similar to rBfab39440e94

This commit also makes all file names use snake case instead of camel case.

Reviewed By: HooglyBoogly

Differential Revision: https://developer.blender.org/D13482
2021-12-06 14:47:49 -05:00
Jacques Lucke 2d4c7fa896 Geometry Nodes: reduce code duplication with new GeometyrFieldInput
Most of our field inputs are currently specific to geometry. This patch introduces
a new `GeometryFieldInput` that reduces the overhead of adding new geometry
field input.

Differential Revision: https://developer.blender.org/D13489
2021-12-06 19:13:24 +01:00
Johnny Matthews 2814740f5b Geometry Nodes: 4 Field Inputs for Mesh Topology Data
Creates 4 new nodes which provide topology information
for the mesh. Values are interpolated from the primary
domain in each case using basic attribute interpolation.

Vertex Neighbors
  - Vertex Count
  - Face Count
Face Neighbors
  - Vertex Count
  - Neighboring Face Count
Edge Vertices
  - Vertex Index 1
  - Vertex Index 2
  - Position 1
  - Position 2
Face Area
  - Face Area

Differential Revision: https://developer.blender.org/D13343
2021-12-06 11:58:08 -06:00
Jacques Lucke c2292b2cd6 Cleanup: remove unnecessary extern template implementations
This technique isn't really necessary anymore, because unity builds
avoid instantiating the same template too many times already.
2021-12-06 17:31:42 +01:00
Sybren A. Stüvel b9c6ef4e8f Fix T93707: Dragging the tweaked NLA strip causes crash
Earlier code assumed that the active strip was on the active track. This
commit detects when this assumption doesn't hold, and adds a more thorough
search of the active strip.
2021-12-06 15:50:21 +01:00
Bastien Montagne 989d510e3e Cleanup: remove some temp dev asserts in new link/append code.
No longer needed now that all code uses that new
BKE_blendfile_link_append module, and that instantiation code in
BLO_readfile has been removed.
2021-12-06 11:29:27 +01:00
Hans Goudey 0a8a22fc04 Cleanup: Remove unused next and prev pointers in bNodeType 2021-12-05 17:15:21 -05:00
Hans Goudey 9a312ba192 Cleanup: Remove unnecesary node type draw callback
As a followup to 338c1060d5, apply the same change to the node
drawing callback. This helps to simplify code when the complexity
of a callback isn't necessary right now.
2021-12-05 17:12:25 -05:00
Hans Goudey 338c1060d5 Cleanup: Remove unnecessary node type callbacks for drawing
Currently there are a few callbacks on `bNodeType` that do the same
thing for every node type except reroutes and frame nodes. Having a
callback for basic things complicates code and makes it harder to
understand, and reroutes and frames are special cases in larger way.

Arguably frame nodes shouldn't even be drawn like regular nodes,
given that it adds a case of O(N^2) looping through all nodes.
"Unrolling" the callbacks makes it easier to see what's happening,
and therefore easier to optimize.

Differential Revision: https://developer.blender.org/D13463
2021-12-05 16:45:41 -05:00
Jacques Lucke b32f9bf801 Geometry Nodes: use array instead of map in GeometrySet
`GeometrySet` contains at most one component of each type.
Previously, a map was used to make sure that each component
type only exists once. The overhead of a map (especially with
inline storage) is rather large though. Since all component types
are known at compile time and the number of types is low,
a simple `std::array` works as well.

Some benefits of using `std::array` here:
* Looking up the component of a specific type is a bit faster.
* The size of `GeometrySet` becomes much smaller from 192 to 40 bytes.
* Debugging a `GeometrySet` in many tools becomes simpler because
  one can  easily see which components exists and which don't
2021-12-05 15:10:11 +01:00
Hans Goudey 2d8606b360 Cleanup: Use references in node editor, other improvements
This helps to tell when a pointer is expected to be null, and avoid
overly verbose code when dereferencing. This commit also includes
a few other cleanups in this area:
 - Use const in a few places
 - Use `float2` instead of `float[2]`
 - Remove some unnecessary includes and old code
The change can be continued further in the future.
2021-12-03 16:25:17 -05:00
Hans Goudey cb0fbe1fde Cleanup: Use typed enum for node resize direction 2021-12-03 11:05:59 -05:00
Jeroen Bakker ab927f5ca7 ImBuf: Made Wrapping and Cropping optional in IMB_transform.
`IMB_transform` is used in VSE. It had a required crop parameter
for cropping the source buffer. This is not always needed.

In the image engine we want to use the use the `IMB_transform`
with wrap repeat. Both options are mutual exclusive and due
to performance reasons the wrap repeat is only available when
performing a nearest interpolation.
2021-12-03 13:48:00 +01:00
Hans Goudey 27b70428c1 Cleanup: Avoid using C++ keyword as variable name 2021-12-02 11:20:22 -05:00
Jacques Lucke aec56e562a Fix (unreported): incorrect custom data layer created
Without this fix `CustomDataAttributes::create_by_move`
did not work on named attributes.
2021-12-02 15:32:19 +01:00
Hans Goudey a1f0f2eacb Cleanup: Move public docs to BKE_spline.hh header 2021-12-02 09:24:21 -05:00
Sybren A. Stüvel 23ffcb242d Merge remote-tracking branch 'origin/blender-v3.0-release' 2021-12-02 14:40:20 +01:00