Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorishbosamiya <ishbosamiya@gmail.com>2021-08-09 14:06:57 +0300
committerishbosamiya <ishbosamiya@gmail.com>2021-08-09 14:06:57 +0300
commitbe8d07b34915e63c34aa800a2875513a461acd85 (patch)
treecc27dda96229e6f29073e82431a6ab14c7e6fd0f /source/blender
parent3aca3d8ad311d079ff3aecaf35248cdc36cf43ce (diff)
adaptive_cloth: AdaptiveMesh: preserve vert
Need to mark verts that should be preserves, ones that are on seams or boundaries at the beginning of the remeshing process so that the initial state is not altered. Collapse edges should not collapse a vert that should be preserved into another vert.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/cloth_remesh.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/cloth_remesh.cc b/source/blender/blenkernel/intern/cloth_remesh.cc
index eb38620dc57..0fd6e29f59b 100644
--- a/source/blender/blenkernel/intern/cloth_remesh.cc
+++ b/source/blender/blenkernel/intern/cloth_remesh.cc
@@ -223,6 +223,7 @@ enum VertFlags {
VERT_NONE = 0,
VERT_SELECTED_FOR_SPLIT = 1 << 0,
VERT_SELECTED_FOR_FLIP = 1 << 1,
+ VERT_PRESERVE = 1 << 2,
};
class VertData {
@@ -230,6 +231,10 @@ class VertData {
int flag;
public:
+ VertData() : sizing(float2x2::identity())
+ {
+ }
+
VertData(Sizing sizing) : sizing(sizing)
{
this->flag = VERT_NONE;
@@ -344,6 +349,26 @@ class AdaptiveMesh : public Mesh<NodeData<END>, VertData, EdgeData, internal::Em
}
/**
+ * Marks verts which are on a seam or boundary for preserve
+ */
+ void mark_verts_for_preserve()
+ {
+ for (auto &vert : this->get_verts_mut()) {
+ if (this->is_vert_on_seam_or_boundary(vert)) {
+ auto &op_vert_data = vert.get_extra_data_mut();
+ if (op_vert_data) {
+ auto &vert_data = op_vert_data.value();
+ vert_data.get_flag_mut() |= VERT_PRESERVE;
+ }
+ else {
+ vert.set_extra_data(VertData());
+ vert.get_extra_data_mut().value().get_flag_mut() |= VERT_PRESERVE;
+ }
+ }
+ }
+ }
+
+ /**
* Flip edges of the `active_faces` if needed.
*
* Updates the active_faces in place
@@ -778,6 +803,14 @@ class AdaptiveMesh : public Mesh<NodeData<END>, VertData, EdgeData, internal::Em
const auto [v1, v2] = this->get_checked_verts_of_edge(edge, verts_swapped);
+ /* If v1 is supposed to be preserved, cannot collapse the edge */
+ {
+ BLI_assert(v1.get_extra_data());
+ if (v1.get_extra_data().value().get_flag() & VERT_PRESERVE) {
+ return false;
+ }
+ }
+
/* If v1 is on a seam or boundary, v2 should also be on a seam or boundary */
if (this->is_vert_on_seam_or_boundary(v1) == true &&
this->is_vert_on_seam_or_boundary(v2) == false) {
@@ -1018,6 +1051,11 @@ Mesh *adaptive_remesh(const AdaptiveRemeshParams<END, ExtraData> &params,
params.post_extra_data_to_end(extra_data);
}
+ /* Important to not mess with the panel boundaries so if a vert is
+ * marked for preserve it will not be removed and this takes care of
+ * that. */
+ adaptive_mesh.mark_verts_for_preserve();
+
/* Actual Remeshing Part */
{
float size_min = params.size_min;