2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2005 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2019-12-11 22:31:20 -03:00
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
|
* \ingroup modifiers
|
|
|
|
|
*
|
|
|
|
|
* Weld modifier: Remove doubles.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* TODOs:
|
|
|
|
|
* - Review weight and vertex color interpolation.;
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
2021-12-18 13:42:48 -06:00
|
|
|
#include "BLI_array.hh"
|
2021-12-20 18:03:06 -06:00
|
|
|
#include "BLI_index_range.hh"
|
2021-12-18 13:42:48 -06:00
|
|
|
#include "BLI_span.hh"
|
|
|
|
|
#include "BLI_vector.hh"
|
2019-12-11 22:31:20 -03:00
|
|
|
|
2024-02-09 18:59:42 +01:00
|
|
|
#include "BLT_translation.hh"
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2020-10-01 09:38:00 -05:00
|
|
|
#include "DNA_defaults.h"
|
2019-12-11 22:31:20 -03:00
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
|
#include "DNA_meshdata_types.h"
|
2020-02-12 08:35:27 -03:00
|
|
|
#include "DNA_modifier_types.h"
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "DNA_screen_types.h"
|
2019-12-11 22:31:20 -03:00
|
|
|
|
2023-11-16 11:41:55 +01:00
|
|
|
#include "BKE_context.hh"
|
2023-12-26 23:21:19 -05:00
|
|
|
#include "BKE_customdata.hh"
|
2024-01-29 18:57:16 -05:00
|
|
|
#include "BKE_deform.hh"
|
2023-11-14 09:30:40 +01:00
|
|
|
#include "BKE_modifier.hh"
|
2023-09-25 17:48:21 -04:00
|
|
|
#include "BKE_screen.hh"
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "UI_interface.hh"
|
|
|
|
|
#include "UI_resources.hh"
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2023-08-10 22:40:27 +02:00
|
|
|
#include "RNA_access.hh"
|
2024-07-10 18:30:02 +02:00
|
|
|
#include "RNA_prototypes.hh"
|
2019-12-11 22:31:20 -03:00
|
|
|
|
2023-09-22 03:18:17 +02:00
|
|
|
#include "DEG_depsgraph.hh"
|
2019-12-11 22:31:20 -03:00
|
|
|
|
2023-05-04 18:35:37 +02:00
|
|
|
#include "MOD_modifiertypes.hh"
|
|
|
|
|
#include "MOD_ui_common.hh"
|
2020-02-11 12:01:29 +11:00
|
|
|
|
2022-01-25 11:07:12 -06:00
|
|
|
#include "GEO_mesh_merge_by_distance.hh"
|
|
|
|
|
|
2021-12-18 13:42:48 -06:00
|
|
|
using blender::Array;
|
2022-01-25 11:07:12 -06:00
|
|
|
using blender::IndexMask;
|
BLI: refactor IndexMask for better performance and memory usage
Goals of this refactor:
* Reduce memory consumption of `IndexMask`. The old `IndexMask` uses an
`int64_t` for each index which is more than necessary in pretty much all
practical cases currently. Using `int32_t` might still become limiting
in the future in case we use this to index e.g. byte buffers larger than
a few gigabytes. We also don't want to template `IndexMask`, because
that would cause a split in the "ecosystem", or everything would have to
be implemented twice or templated.
* Allow for more multi-threading. The old `IndexMask` contains a single
array. This is generally good but has the problem that it is hard to fill
from multiple-threads when the final size is not known from the beginning.
This is commonly the case when e.g. converting an array of bool to an
index mask. Currently, this kind of code only runs on a single thread.
* Allow for efficient set operations like join, intersect and difference.
It should be possible to multi-thread those operations.
* It should be possible to iterate over an `IndexMask` very efficiently.
The most important part of that is to avoid all memory access when iterating
over continuous ranges. For some core nodes (e.g. math nodes), we generate
optimized code for the cases of irregular index masks and simple index ranges.
To achieve these goals, a few compromises had to made:
* Slicing of the mask (at specific indices) and random element access is
`O(log #indices)` now, but with a low constant factor. It should be possible
to split a mask into n approximately equally sized parts in `O(n)` though,
making the time per split `O(1)`.
* Using range-based for loops does not work well when iterating over a nested
data structure like the new `IndexMask`. Therefor, `foreach_*` functions with
callbacks have to be used. To avoid extra code complexity at the call site,
the `foreach_*` methods support multi-threading out of the box.
The new data structure splits an `IndexMask` into an arbitrary number of ordered
`IndexMaskSegment`. Each segment can contain at most `2^14 = 16384` indices. The
indices within a segment are stored as `int16_t`. Each segment has an additional
`int64_t` offset which allows storing arbitrary `int64_t` indices. This approach
has the main benefits that segments can be processed/constructed individually on
multiple threads without a serial bottleneck. Also it reduces the memory
requirements significantly.
For more details see comments in `BLI_index_mask.hh`.
I did a few tests to verify that the data structure generally improves
performance and does not cause regressions:
* Our field evaluation benchmarks take about as much as before. This is to be
expected because we already made sure that e.g. add node evaluation is
vectorized. The important thing here is to check that changes to the way we
iterate over the indices still allows for auto-vectorization.
* Memory usage by a mask is about 1/4 of what it was before in the average case.
That's mainly caused by the switch from `int64_t` to `int16_t` for indices.
In the worst case, the memory requirements can be larger when there are many
indices that are very far away. However, when they are far away from each other,
that indicates that there aren't many indices in total. In common cases, memory
usage can be way lower than 1/4 of before, because sub-ranges use static memory.
* For some more specific numbers I benchmarked `IndexMask::from_bools` in
`index_mask_from_selection` on 10.000.000 elements at various probabilities for
`true` at every index:
```
Probability Old New
0 4.6 ms 0.8 ms
0.001 5.1 ms 1.3 ms
0.2 8.4 ms 1.8 ms
0.5 15.3 ms 3.0 ms
0.8 20.1 ms 3.0 ms
0.999 25.1 ms 1.7 ms
1 13.5 ms 1.1 ms
```
Pull Request: https://projects.blender.org/blender/blender/pulls/104629
2023-05-24 18:11:41 +02:00
|
|
|
using blender::IndexMaskMemory;
|
2021-12-18 13:42:48 -06:00
|
|
|
using blender::Span;
|
|
|
|
|
using blender::Vector;
|
|
|
|
|
|
2022-01-25 11:07:12 -06:00
|
|
|
static Span<MDeformVert> get_vertex_group(const Mesh &mesh, const int defgrp_index)
|
2019-12-11 22:31:20 -03:00
|
|
|
{
|
2022-01-25 11:07:12 -06:00
|
|
|
if (defgrp_index == -1) {
|
|
|
|
|
return {};
|
2019-12-11 22:31:20 -03:00
|
|
|
}
|
2022-01-25 11:07:12 -06:00
|
|
|
const MDeformVert *vertex_group = static_cast<const MDeformVert *>(
|
2023-07-25 21:15:52 +02:00
|
|
|
CustomData_get_layer(&mesh.vert_data, CD_MDEFORMVERT));
|
2022-01-25 11:07:12 -06:00
|
|
|
if (!vertex_group) {
|
|
|
|
|
return {};
|
2019-12-11 22:31:20 -03:00
|
|
|
}
|
2023-12-20 02:21:48 +01:00
|
|
|
return {vertex_group, mesh.verts_num};
|
2019-12-11 22:31:20 -03:00
|
|
|
}
|
|
|
|
|
|
BLI: refactor IndexMask for better performance and memory usage
Goals of this refactor:
* Reduce memory consumption of `IndexMask`. The old `IndexMask` uses an
`int64_t` for each index which is more than necessary in pretty much all
practical cases currently. Using `int32_t` might still become limiting
in the future in case we use this to index e.g. byte buffers larger than
a few gigabytes. We also don't want to template `IndexMask`, because
that would cause a split in the "ecosystem", or everything would have to
be implemented twice or templated.
* Allow for more multi-threading. The old `IndexMask` contains a single
array. This is generally good but has the problem that it is hard to fill
from multiple-threads when the final size is not known from the beginning.
This is commonly the case when e.g. converting an array of bool to an
index mask. Currently, this kind of code only runs on a single thread.
* Allow for efficient set operations like join, intersect and difference.
It should be possible to multi-thread those operations.
* It should be possible to iterate over an `IndexMask` very efficiently.
The most important part of that is to avoid all memory access when iterating
over continuous ranges. For some core nodes (e.g. math nodes), we generate
optimized code for the cases of irregular index masks and simple index ranges.
To achieve these goals, a few compromises had to made:
* Slicing of the mask (at specific indices) and random element access is
`O(log #indices)` now, but with a low constant factor. It should be possible
to split a mask into n approximately equally sized parts in `O(n)` though,
making the time per split `O(1)`.
* Using range-based for loops does not work well when iterating over a nested
data structure like the new `IndexMask`. Therefor, `foreach_*` functions with
callbacks have to be used. To avoid extra code complexity at the call site,
the `foreach_*` methods support multi-threading out of the box.
The new data structure splits an `IndexMask` into an arbitrary number of ordered
`IndexMaskSegment`. Each segment can contain at most `2^14 = 16384` indices. The
indices within a segment are stored as `int16_t`. Each segment has an additional
`int64_t` offset which allows storing arbitrary `int64_t` indices. This approach
has the main benefits that segments can be processed/constructed individually on
multiple threads without a serial bottleneck. Also it reduces the memory
requirements significantly.
For more details see comments in `BLI_index_mask.hh`.
I did a few tests to verify that the data structure generally improves
performance and does not cause regressions:
* Our field evaluation benchmarks take about as much as before. This is to be
expected because we already made sure that e.g. add node evaluation is
vectorized. The important thing here is to check that changes to the way we
iterate over the indices still allows for auto-vectorization.
* Memory usage by a mask is about 1/4 of what it was before in the average case.
That's mainly caused by the switch from `int64_t` to `int16_t` for indices.
In the worst case, the memory requirements can be larger when there are many
indices that are very far away. However, when they are far away from each other,
that indicates that there aren't many indices in total. In common cases, memory
usage can be way lower than 1/4 of before, because sub-ranges use static memory.
* For some more specific numbers I benchmarked `IndexMask::from_bools` in
`index_mask_from_selection` on 10.000.000 elements at various probabilities for
`true` at every index:
```
Probability Old New
0 4.6 ms 0.8 ms
0.001 5.1 ms 1.3 ms
0.2 8.4 ms 1.8 ms
0.5 15.3 ms 3.0 ms
0.8 20.1 ms 3.0 ms
0.999 25.1 ms 1.7 ms
1 13.5 ms 1.1 ms
```
Pull Request: https://projects.blender.org/blender/blender/pulls/104629
2023-05-24 18:11:41 +02:00
|
|
|
static IndexMask selected_indices_from_vertex_group(Span<MDeformVert> vertex_group,
|
|
|
|
|
const int index,
|
|
|
|
|
const bool invert,
|
|
|
|
|
IndexMaskMemory &memory)
|
2019-12-11 22:31:20 -03:00
|
|
|
{
|
BLI: refactor IndexMask for better performance and memory usage
Goals of this refactor:
* Reduce memory consumption of `IndexMask`. The old `IndexMask` uses an
`int64_t` for each index which is more than necessary in pretty much all
practical cases currently. Using `int32_t` might still become limiting
in the future in case we use this to index e.g. byte buffers larger than
a few gigabytes. We also don't want to template `IndexMask`, because
that would cause a split in the "ecosystem", or everything would have to
be implemented twice or templated.
* Allow for more multi-threading. The old `IndexMask` contains a single
array. This is generally good but has the problem that it is hard to fill
from multiple-threads when the final size is not known from the beginning.
This is commonly the case when e.g. converting an array of bool to an
index mask. Currently, this kind of code only runs on a single thread.
* Allow for efficient set operations like join, intersect and difference.
It should be possible to multi-thread those operations.
* It should be possible to iterate over an `IndexMask` very efficiently.
The most important part of that is to avoid all memory access when iterating
over continuous ranges. For some core nodes (e.g. math nodes), we generate
optimized code for the cases of irregular index masks and simple index ranges.
To achieve these goals, a few compromises had to made:
* Slicing of the mask (at specific indices) and random element access is
`O(log #indices)` now, but with a low constant factor. It should be possible
to split a mask into n approximately equally sized parts in `O(n)` though,
making the time per split `O(1)`.
* Using range-based for loops does not work well when iterating over a nested
data structure like the new `IndexMask`. Therefor, `foreach_*` functions with
callbacks have to be used. To avoid extra code complexity at the call site,
the `foreach_*` methods support multi-threading out of the box.
The new data structure splits an `IndexMask` into an arbitrary number of ordered
`IndexMaskSegment`. Each segment can contain at most `2^14 = 16384` indices. The
indices within a segment are stored as `int16_t`. Each segment has an additional
`int64_t` offset which allows storing arbitrary `int64_t` indices. This approach
has the main benefits that segments can be processed/constructed individually on
multiple threads without a serial bottleneck. Also it reduces the memory
requirements significantly.
For more details see comments in `BLI_index_mask.hh`.
I did a few tests to verify that the data structure generally improves
performance and does not cause regressions:
* Our field evaluation benchmarks take about as much as before. This is to be
expected because we already made sure that e.g. add node evaluation is
vectorized. The important thing here is to check that changes to the way we
iterate over the indices still allows for auto-vectorization.
* Memory usage by a mask is about 1/4 of what it was before in the average case.
That's mainly caused by the switch from `int64_t` to `int16_t` for indices.
In the worst case, the memory requirements can be larger when there are many
indices that are very far away. However, when they are far away from each other,
that indicates that there aren't many indices in total. In common cases, memory
usage can be way lower than 1/4 of before, because sub-ranges use static memory.
* For some more specific numbers I benchmarked `IndexMask::from_bools` in
`index_mask_from_selection` on 10.000.000 elements at various probabilities for
`true` at every index:
```
Probability Old New
0 4.6 ms 0.8 ms
0.001 5.1 ms 1.3 ms
0.2 8.4 ms 1.8 ms
0.5 15.3 ms 3.0 ms
0.8 20.1 ms 3.0 ms
0.999 25.1 ms 1.7 ms
1 13.5 ms 1.1 ms
```
Pull Request: https://projects.blender.org/blender/blender/pulls/104629
2023-05-24 18:11:41 +02:00
|
|
|
return IndexMask::from_predicate(
|
|
|
|
|
vertex_group.index_range(), blender::GrainSize(512), memory, [&](const int i) {
|
|
|
|
|
return (BKE_defvert_find_weight(&vertex_group[i], index) > 0.0f) != invert;
|
|
|
|
|
});
|
2019-12-11 22:31:20 -03:00
|
|
|
}
|
|
|
|
|
|
2022-01-25 11:07:12 -06:00
|
|
|
static Array<bool> selection_array_from_vertex_group(Span<MDeformVert> vertex_group,
|
|
|
|
|
const int index,
|
|
|
|
|
const bool invert)
|
2019-12-11 22:31:20 -03:00
|
|
|
{
|
2022-01-25 11:07:12 -06:00
|
|
|
Array<bool> selection(vertex_group.size());
|
|
|
|
|
for (const int i : vertex_group.index_range()) {
|
|
|
|
|
const bool found = BKE_defvert_find_weight(&vertex_group[i], index) > 0.0f;
|
|
|
|
|
selection[i] = (found != invert);
|
2019-12-11 22:31:20 -03:00
|
|
|
}
|
2022-01-25 11:07:12 -06:00
|
|
|
return selection;
|
2019-12-11 22:31:20 -03:00
|
|
|
}
|
|
|
|
|
|
2022-01-25 11:07:12 -06:00
|
|
|
static std::optional<Mesh *> calculate_weld(const Mesh &mesh, const WeldModifierData &wmd)
|
2019-12-11 22:31:20 -03:00
|
|
|
{
|
2022-01-25 11:07:12 -06:00
|
|
|
const int defgrp_index = BKE_id_defgroup_name_index(&mesh.id, wmd.defgrp_name);
|
|
|
|
|
Span<MDeformVert> vertex_group = get_vertex_group(mesh, defgrp_index);
|
|
|
|
|
const bool invert = (wmd.flag & MOD_WELD_INVERT_VGROUP) != 0;
|
2019-12-11 22:31:20 -03:00
|
|
|
|
2022-01-25 11:07:12 -06:00
|
|
|
if (wmd.mode == MOD_WELD_MODE_ALL) {
|
|
|
|
|
if (!vertex_group.is_empty()) {
|
BLI: refactor IndexMask for better performance and memory usage
Goals of this refactor:
* Reduce memory consumption of `IndexMask`. The old `IndexMask` uses an
`int64_t` for each index which is more than necessary in pretty much all
practical cases currently. Using `int32_t` might still become limiting
in the future in case we use this to index e.g. byte buffers larger than
a few gigabytes. We also don't want to template `IndexMask`, because
that would cause a split in the "ecosystem", or everything would have to
be implemented twice or templated.
* Allow for more multi-threading. The old `IndexMask` contains a single
array. This is generally good but has the problem that it is hard to fill
from multiple-threads when the final size is not known from the beginning.
This is commonly the case when e.g. converting an array of bool to an
index mask. Currently, this kind of code only runs on a single thread.
* Allow for efficient set operations like join, intersect and difference.
It should be possible to multi-thread those operations.
* It should be possible to iterate over an `IndexMask` very efficiently.
The most important part of that is to avoid all memory access when iterating
over continuous ranges. For some core nodes (e.g. math nodes), we generate
optimized code for the cases of irregular index masks and simple index ranges.
To achieve these goals, a few compromises had to made:
* Slicing of the mask (at specific indices) and random element access is
`O(log #indices)` now, but with a low constant factor. It should be possible
to split a mask into n approximately equally sized parts in `O(n)` though,
making the time per split `O(1)`.
* Using range-based for loops does not work well when iterating over a nested
data structure like the new `IndexMask`. Therefor, `foreach_*` functions with
callbacks have to be used. To avoid extra code complexity at the call site,
the `foreach_*` methods support multi-threading out of the box.
The new data structure splits an `IndexMask` into an arbitrary number of ordered
`IndexMaskSegment`. Each segment can contain at most `2^14 = 16384` indices. The
indices within a segment are stored as `int16_t`. Each segment has an additional
`int64_t` offset which allows storing arbitrary `int64_t` indices. This approach
has the main benefits that segments can be processed/constructed individually on
multiple threads without a serial bottleneck. Also it reduces the memory
requirements significantly.
For more details see comments in `BLI_index_mask.hh`.
I did a few tests to verify that the data structure generally improves
performance and does not cause regressions:
* Our field evaluation benchmarks take about as much as before. This is to be
expected because we already made sure that e.g. add node evaluation is
vectorized. The important thing here is to check that changes to the way we
iterate over the indices still allows for auto-vectorization.
* Memory usage by a mask is about 1/4 of what it was before in the average case.
That's mainly caused by the switch from `int64_t` to `int16_t` for indices.
In the worst case, the memory requirements can be larger when there are many
indices that are very far away. However, when they are far away from each other,
that indicates that there aren't many indices in total. In common cases, memory
usage can be way lower than 1/4 of before, because sub-ranges use static memory.
* For some more specific numbers I benchmarked `IndexMask::from_bools` in
`index_mask_from_selection` on 10.000.000 elements at various probabilities for
`true` at every index:
```
Probability Old New
0 4.6 ms 0.8 ms
0.001 5.1 ms 1.3 ms
0.2 8.4 ms 1.8 ms
0.5 15.3 ms 3.0 ms
0.8 20.1 ms 3.0 ms
0.999 25.1 ms 1.7 ms
1 13.5 ms 1.1 ms
```
Pull Request: https://projects.blender.org/blender/blender/pulls/104629
2023-05-24 18:11:41 +02:00
|
|
|
IndexMaskMemory memory;
|
|
|
|
|
const IndexMask selected_indices = selected_indices_from_vertex_group(
|
|
|
|
|
vertex_group, defgrp_index, invert, memory);
|
2022-01-25 11:07:12 -06:00
|
|
|
return blender::geometry::mesh_merge_by_distance_all(
|
|
|
|
|
mesh, IndexMask(selected_indices), wmd.merge_dist);
|
2019-12-11 22:31:20 -03:00
|
|
|
}
|
2022-01-25 11:07:12 -06:00
|
|
|
return blender::geometry::mesh_merge_by_distance_all(
|
2023-12-20 02:21:48 +01:00
|
|
|
mesh, IndexMask(mesh.verts_num), wmd.merge_dist);
|
2019-12-11 22:31:20 -03:00
|
|
|
}
|
2022-01-25 11:07:12 -06:00
|
|
|
if (wmd.mode == MOD_WELD_MODE_CONNECTED) {
|
|
|
|
|
const bool only_loose_edges = (wmd.flag & MOD_WELD_LOOSE_EDGES) != 0;
|
|
|
|
|
if (!vertex_group.is_empty()) {
|
|
|
|
|
Array<bool> selection = selection_array_from_vertex_group(
|
|
|
|
|
vertex_group, defgrp_index, invert);
|
|
|
|
|
return blender::geometry::mesh_merge_by_distance_connected(
|
|
|
|
|
mesh, selection, wmd.merge_dist, only_loose_edges);
|
2019-12-11 22:31:20 -03:00
|
|
|
}
|
2023-12-20 02:21:48 +01:00
|
|
|
Array<bool> selection(mesh.verts_num, true);
|
2022-01-25 11:07:12 -06:00
|
|
|
return blender::geometry::mesh_merge_by_distance_connected(
|
|
|
|
|
mesh, selection, wmd.merge_dist, only_loose_edges);
|
2019-12-11 22:31:20 -03:00
|
|
|
}
|
|
|
|
|
|
2022-01-25 11:07:12 -06:00
|
|
|
BLI_assert_unreachable();
|
|
|
|
|
return nullptr;
|
2019-12-11 22:31:20 -03:00
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext * /*ctx*/, Mesh *mesh)
|
2019-12-11 22:31:20 -03:00
|
|
|
{
|
2022-01-25 11:07:12 -06:00
|
|
|
const WeldModifierData &wmd = reinterpret_cast<WeldModifierData &>(*md);
|
2019-12-11 22:31:20 -03:00
|
|
|
|
2022-01-25 11:07:12 -06:00
|
|
|
std::optional<Mesh *> result = calculate_weld(*mesh, wmd);
|
|
|
|
|
if (!result) {
|
2021-12-28 15:36:16 -06:00
|
|
|
return mesh;
|
|
|
|
|
}
|
2022-01-25 11:07:12 -06:00
|
|
|
return *result;
|
2019-12-11 22:31:20 -03:00
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static void init_data(ModifierData *md)
|
2019-12-11 22:31:20 -03:00
|
|
|
{
|
|
|
|
|
WeldModifierData *wmd = (WeldModifierData *)md;
|
|
|
|
|
|
2020-10-01 09:38:00 -05:00
|
|
|
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(wmd, modifier));
|
|
|
|
|
|
|
|
|
|
MEMCPY_STRUCT_AFTER(wmd, DNA_struct_default_get(WeldModifierData), modifier);
|
2019-12-11 22:31:20 -03:00
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static void required_data_mask(ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
|
2020-03-02 18:44:47 -03:00
|
|
|
{
|
|
|
|
|
WeldModifierData *wmd = (WeldModifierData *)md;
|
|
|
|
|
|
2023-05-05 09:25:45 +10:00
|
|
|
/* Ask for vertex-groups if we need them. */
|
2020-03-02 18:44:47 -03:00
|
|
|
if (wmd->defgrp_name[0] != '\0') {
|
|
|
|
|
r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-03 17:37:25 -05:00
|
|
|
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
2020-06-05 10:41:03 -04:00
|
|
|
{
|
|
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
|
|
|
|
|
PointerRNA ob_ptr;
|
2020-09-02 14:13:26 -05:00
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr);
|
2021-07-23 18:46:19 -03:00
|
|
|
int weld_mode = RNA_enum_get(ptr, "mode");
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
|
2023-07-29 15:06:33 +10:00
|
|
|
uiItemR(layout, ptr, "mode", UI_ITEM_NONE, nullptr, ICON_NONE);
|
|
|
|
|
uiItemR(layout, ptr, "merge_threshold", UI_ITEM_NONE, IFACE_("Distance"), ICON_NONE);
|
2021-07-23 18:46:19 -03:00
|
|
|
if (weld_mode == MOD_WELD_MODE_CONNECTED) {
|
2023-07-29 15:06:33 +10:00
|
|
|
uiItemR(layout, ptr, "loose_edges", UI_ITEM_NONE, nullptr, ICON_NONE);
|
2021-07-23 18:46:19 -03:00
|
|
|
}
|
2021-12-18 13:42:48 -06:00
|
|
|
modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
modifier_panel_end(layout, ptr);
|
2020-06-05 10:41:03 -04:00
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static void panel_register(ARegionType *region_type)
|
2020-06-05 10:41:03 -04:00
|
|
|
{
|
|
|
|
|
modifier_panel_register(region_type, eModifierType_Weld, panel_draw);
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-11 22:31:20 -03:00
|
|
|
ModifierTypeInfo modifierType_Weld = {
|
2023-07-26 17:08:14 +02:00
|
|
|
/*idname*/ "Weld",
|
2023-01-16 12:41:11 +11:00
|
|
|
/*name*/ N_("Weld"),
|
2023-07-27 12:04:18 +10:00
|
|
|
/*struct_name*/ "WeldModifierData",
|
|
|
|
|
/*struct_size*/ sizeof(WeldModifierData),
|
2023-01-16 12:41:11 +11:00
|
|
|
/*srna*/ &RNA_WeldModifier,
|
2023-11-14 10:03:56 +01:00
|
|
|
/*type*/ ModifierTypeType::Constructive,
|
2023-01-16 12:41:11 +11:00
|
|
|
/*flags*/
|
2021-12-18 13:42:48 -06:00
|
|
|
(ModifierTypeFlag)(eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsMapping |
|
|
|
|
|
eModifierTypeFlag_SupportsEditmode | eModifierTypeFlag_EnableInEditmode |
|
|
|
|
|
eModifierTypeFlag_AcceptsCVs),
|
2023-01-16 12:41:11 +11:00
|
|
|
/*icon*/ ICON_AUTOMERGE_OFF, /* TODO: Use correct icon. */
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
/*copy_data*/ BKE_modifier_copydata_generic,
|
|
|
|
|
|
|
|
|
|
/*deform_verts*/ nullptr,
|
|
|
|
|
/*deform_matrices*/ nullptr,
|
|
|
|
|
/*deform_verts_EM*/ nullptr,
|
|
|
|
|
/*deform_matrices_EM*/ nullptr,
|
|
|
|
|
/*modify_mesh*/ modify_mesh,
|
|
|
|
|
/*modify_geometry_set*/ nullptr,
|
|
|
|
|
|
|
|
|
|
/*init_data*/ init_data,
|
|
|
|
|
/*required_data_mask*/ required_data_mask,
|
|
|
|
|
/*free_data*/ nullptr,
|
|
|
|
|
/*is_disabled*/ nullptr,
|
|
|
|
|
/*update_depsgraph*/ nullptr,
|
|
|
|
|
/*depends_on_time*/ nullptr,
|
|
|
|
|
/*depends_on_normals*/ nullptr,
|
|
|
|
|
/*foreach_ID_link*/ nullptr,
|
|
|
|
|
/*foreach_tex_link*/ nullptr,
|
|
|
|
|
/*free_runtime_data*/ nullptr,
|
|
|
|
|
/*panel_register*/ panel_register,
|
|
|
|
|
/*blend_write*/ nullptr,
|
|
|
|
|
/*blend_read*/ nullptr,
|
2024-01-18 22:51:30 +01:00
|
|
|
/*foreach_cache*/ nullptr,
|
2019-12-11 22:31:20 -03:00
|
|
|
};
|