[Bf-blender-cvs] [d5f8d9380fb] soc-2021-adaptive-cloth: adaptive_cloth: mesh: initial class setup
ishbosamiya
noreply at git.blender.org
Fri Jun 18 11:22:45 CEST 2021
Commit: d5f8d9380fb62554d459ad57bb7a330c9813256b
Author: ishbosamiya
Date: Fri Jun 18 14:52:22 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rBd5f8d9380fb62554d459ad57bb7a330c9813256b
adaptive_cloth: mesh: initial class setup
===================================================================
M source/blender/blenkernel/BKE_cloth_remesh.hh
===================================================================
diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh
index 5927ae2537a..236f2b87404 100644
--- a/source/blender/blenkernel/BKE_cloth_remesh.hh
+++ b/source/blender/blenkernel/BKE_cloth_remesh.hh
@@ -42,3 +42,190 @@ void BKE_cloth_remesh(const struct Object *ob,
#ifdef __cplusplus
}
#endif
+
+#ifdef __cplusplus
+
+# include <tuple>
+
+# include "BLI_float2.hh"
+# include "BLI_float3.hh"
+# include "BLI_generational_arena.hh"
+# include "BLI_vector.hh"
+
+namespace blender::bke::internal {
+
+namespace ga = blender::generational_arena;
+
+using NodeIndex = ga::Index;
+using VertIndex = ga::Index;
+using EdgeIndex = ga::Index;
+using FaceIndex = ga::Index;
+using IncidentVerts = blender::Vector<VertIndex>;
+using IncidentEdges = blender::Vector<EdgeIndex>;
+using IncidentFaces = blender::Vector<FaceIndex>;
+using AdjacentVerts = IncidentVerts;
+using EdgeVerts = std::tuple<VertIndex, VertIndex>;
+
+/**
+ * `Node`: Stores the worldspace/localspace coordinates of the
+ * `Mesh`. Commonly called the vertex of the mesh (note: in this mesh
+ * structure `Vert` is not the commonly known vertex of the mesh, `Node` is).
+ *
+ * Stores information about `Vert`(s) that refer to this `Node`.
+ */
+template<typename T> class Node {
+ NodeIndex self_index;
+ IncidentVerts verts;
+
+ float3 pos;
+ float3 normal;
+ std::optional<T> extra_data;
+
+ public:
+ Node(NodeIndex self_index, float3 pos, float3 normal)
+ {
+ this->self_index = self_index;
+ this->pos = pos;
+ this->normal = normal;
+ }
+
+ void set_extra_data(T extra_data)
+ {
+ this->extra_data = extra_data;
+ }
+};
+
+/**
+ * `Vert`: Stores the UV (2D) coordinates of the mesh. Acts as the glue
+ * between the faces and the position of the vertices. This is needed
+ * because each face can have distinct UV (2D) coordinates but same
+ * position (3D) coordinations.
+ *
+ * Stores information about which `Edge`(s) refer to this `Vert`.
+ *
+ * Stores information about which `Node` to point to. This is needed
+ * for the 3D coordinates of the vertices of the mesh. Refer above for
+ * information about why `Vert` and `Node` are needed.
+ */
+template<typename T> class Vert {
+ VertIndex self_index;
+ IncidentEdges edges;
+ std::optional<NodeIndex> node;
+
+ float2 uv;
+ std::optional<T> extra_data;
+
+ public:
+ Vert(VertIndex self_index, float2 uv)
+ {
+ this->self_index = self_index;
+ this->uv = uv;
+ }
+
+ void set_extra_data(T extra_data)
+ {
+ this->extra_data = extra_data;
+ }
+};
+
+/**
+ * `Edge`: Acts as the glue between the `Face` and the `Vert`(s).
+ *
+ * TODO(ish): might be possible to remove this entirely to save space
+ * or directly store `Node` instead of `Vert`.
+ *
+ * Stores information about which `Face`(s) refer to this
+ * `Edge`. (note: this is a one way relation, it is possible to
+ * indirectly get the `Edge` from the `Face` from the `Vert`
+ * information stored in the `Face`.)
+ *
+ * Stores information about which `Vert`(s) (as a tuple of 2
+ * `VertIndex`) refer to this `Edge`.
+ */
+template<typename T> class Edge {
+ EdgeIndex self_index;
+ IncidentFaces faces;
+ std::optional<EdgeVerts> verts;
+
+ std::optional<T> extra_data;
+
+ public:
+ Edge(EdgeIndex self_index)
+ {
+ this->self_index = self_index;
+ }
+
+ void set_extra_data(T extra_data)
+ {
+ this->extra_data = extra_data;
+ }
+};
+
+/**
+ * `Face`: Stores the connectivity of the `Mesh`.
+ *
+ * Stores information about which `Vert`(s) make up this face. (note:
+ * it is `Vert` instead of `Node` since there need to be seams to UV
+ * unwrap the mesh and this leads to vertices of the face having
+ * different UV (2D) coordinates but same position (3D) coordinates,
+ * so this is split into `Vert` and `Node` respectively.)
+
+ * Stores the face normal. This must be recomputed after any changes
+ * to the Mesh. Assume dirty always.
+ */
+template<typename T> class Face {
+ FaceIndex self_index;
+ AdjacentVerts verts;
+
+ float3 normal;
+ std::optional<T> extra_data;
+
+ public:
+ Face(FaceIndex self_index, float3 normal)
+ {
+ this->self_index = self_index;
+ this->normal = normal;
+ }
+
+ void set_extra_data(T extra_data)
+ {
+ this->extra_data = extra_data;
+ }
+};
+
+template<typename END, typename EVD, typename EED, typename EFD> class Mesh {
+ /* using declarations */
+ /* static data members */
+ /* non-static data members */
+ ga::Arena<Node<END>> nodes;
+ ga::Arena<Vert<EVD>> verts;
+ ga::Arena<Edge<EED>> edges;
+ ga::Arena<Face<EFD>> faces;
+
+ public:
+ /* default constructor */
+ Mesh() = default;
+ /* other constructors */
+ /* copy constructor */
+ /* move constructor */
+
+ /* destructor */
+
+ /* copy assignment operator */
+ /* move assignment operator */
+ /* other operator overloads */
+
+ /* all public static methods */
+ /* all public non-static methods */
+
+ protected:
+ /* all protected static methods */
+ /* all protected non-static methods */
+
+ private:
+ /* all private static methods */
+ /* all private non-static methods */
+};
+} /* namespace blender::bke::internal */
+
+#endif /* __cplusplus */
More information about the Bf-blender-cvs
mailing list