[Bf-blender-cvs] [b5f262b3e0e] soc-2021-adaptive-cloth: adaptive_cloth: adaptive_remesh: create an "Empty" remesh function
ishbosamiya
noreply at git.blender.org
Mon Jul 26 08:17:41 CEST 2021
Commit: b5f262b3e0ebdbbac688515fd0531400921d7240
Author: ishbosamiya
Date: Wed Jul 21 23:23:22 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rBb5f262b3e0ebdbbac688515fd0531400921d7240
adaptive_cloth: adaptive_remesh: create an "Empty" remesh function
It is useful to call `adaptive_remesh()` outside of the cloth
simulator mainly for testing purposes. Now because the use of
templates for the function `adaptive_remesh()` and it being defined
not in the same header file (this isn't possible in this case because
of other reasons), it requires a template instantiation needs to
happen because the function is called or something like that. This
leads to problems when `adaptive_remesh()` is called from some other
file.
The easiest fix was to create a new wrapper function without templates
and call this from other files.
===================================================================
M source/blender/blenkernel/BKE_cloth_remesh.hh
M source/blender/blenkernel/intern/cloth_remesh.cc
===================================================================
diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh
index 8b7b5f59f19..3ed058f04a1 100644
--- a/source/blender/blenkernel/BKE_cloth_remesh.hh
+++ b/source/blender/blenkernel/BKE_cloth_remesh.hh
@@ -2737,4 +2737,16 @@ template<typename END, typename EVD, typename EED, typename EFD> class MeshDiff
} /* namespace blender::bke::internal */
+/* TODO(ish): Probably want to remove this later since it is mainly
+ * for testing */
+namespace blender::bke {
+
+struct TempEmptyAdaptiveRemeshParams {
+ float size_min;
+};
+
+Mesh *__temp_empty_adaptive_remesh(const TempEmptyAdaptiveRemeshParams ¶ms, Mesh *mesh);
+
+} /* namespace blender::bke */
+
#endif /* __cplusplus */
diff --git a/source/blender/blenkernel/intern/cloth_remesh.cc b/source/blender/blenkernel/intern/cloth_remesh.cc
index b22e7245f72..ed6686aa72a 100644
--- a/source/blender/blenkernel/intern/cloth_remesh.cc
+++ b/source/blender/blenkernel/intern/cloth_remesh.cc
@@ -459,10 +459,15 @@ Mesh *adaptive_remesh(const AdaptiveRemeshParams<END, ExtraData> ¶ms,
* reference:
* https://isocpp.org/wiki/faq/templates#separate-template-fn-defn-from-decl
*/
-template Mesh *adaptive_remesh<internal::ClothNodeData, Cloth>(
- const AdaptiveRemeshParams<internal::ClothNodeData, Cloth> ¶ms,
- Mesh *mesh,
- Cloth &extra_data);
+template<>
+Mesh *adaptive_remesh<internal::ClothNodeData, Cloth>(
+ const AdaptiveRemeshParams<internal::ClothNodeData, Cloth> &, Mesh *, Cloth const &);
+
+template<>
+Mesh *adaptive_remesh<internal::EmptyExtraData, internal::EmptyExtraData>(
+ AdaptiveRemeshParams<internal::EmptyExtraData, internal::EmptyExtraData> const &,
+ Mesh *,
+ internal::EmptyExtraData const &);
Mesh *BKE_cloth_remesh(Object *ob, ClothModifierData *clmd, Mesh *mesh)
{
@@ -504,4 +509,24 @@ Mesh *BKE_cloth_remesh(Object *ob, ClothModifierData *clmd, Mesh *mesh)
return adaptive_remesh(params, mesh, *clmd->clothObject);
}
+Mesh *__temp_empty_adaptive_remesh(const TempEmptyAdaptiveRemeshParams &input_params, Mesh *mesh)
+{
+ using EmptyData = internal::EmptyExtraData;
+
+ EmptyData empty_data;
+
+ AdaptiveRemeshParams<EmptyData, EmptyData> params;
+ params.size_min = input_params.size_min;
+ params.extra_data_to_end = [](const EmptyData &UNUSED(data), size_t UNUSED(index)) {
+ return internal::EmptyExtraData();
+ };
+ params.post_extra_data_to_end = [](EmptyData &UNUSED(cloth)) {};
+
+ params.end_to_extra_data =
+ [](EmptyData &UNUSED(data), EmptyData UNUSED(node_data), size_t UNUSED(index)) {};
+ params.pre_end_to_extra_data = [](EmptyData &UNUSED(data), size_t UNUSED(num_nodes)) {};
+
+ return adaptive_remesh(params, mesh, empty_data);
+}
+
} // namespace blender::bke
More information about the Bf-blender-cvs
mailing list