diff options
author | Howard Trickey <howard.trickey@gmail.com> | 2022-09-08 17:04:20 +0300 |
---|---|---|
committer | Howard Trickey <howard.trickey@gmail.com> | 2022-09-08 17:04:20 +0300 |
commit | 3b2bc5d1463a10c445fb74e9a7888ef4d59e368c (patch) | |
tree | d55f1cf39d1ce9be038d8d221e91932548ca6b57 /source/blender/blenlib/BLI_mesh_inset.hh | |
parent | 81341d1e94c0ab320e15536f93e3032ef695bffb (diff) |
Added a mesh_inset Blenlib function.
Based on python code from Henrik Dick, this libray function
calculates a Straight Skeleton, and hence, deals properly
with cases where the advancing inset geometry would overlap
or pass through opposite edges. It still needs work but the
basic tests pass.
This function will be used for edge and face bevels but is
not yet hooked up for that.
Diffstat (limited to 'source/blender/blenlib/BLI_mesh_inset.hh')
-rw-r--r-- | source/blender/blenlib/BLI_mesh_inset.hh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_mesh_inset.hh b/source/blender/blenlib/BLI_mesh_inset.hh new file mode 100644 index 00000000000..cd7dfcb57df --- /dev/null +++ b/source/blender/blenlib/BLI_mesh_inset.hh @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#pragma once + +/** \file + * \ingroup bli + * + * This header file contains a C++ interface to a 3D mesh inset algorithm + * which is based on a 2D Straight Skeleton construction. + */ + +#include "BLI_array.hh" +#include "BLI_math_vec_types.hh" +#include "BLI_span.hh" +#include "BLI_vector.hh" + + +namespace blender::meshinset { + +class MeshInset_Input { +public: + /** The vertices. Can be a superset of the needed vertices. */ + Span<float3> vert; + /** The faces, each a CCW ordering of vertex indices. */ + Span<Vector<int>> face; + /** The contours to inset; ints are vert indices; contour is on left side of implied edges. */ + Span<Vector<int>> contour; + float inset_amount; + bool need_ids; +}; + +class MeshInset_Result { +public: + /** The output vertices. A subset (perhaps) of input vertices, plus some new ones. */ + Array<float3> vert; + /** The output faces, each a CCW ordering of the output vertices. */ + Array<Vector<int>> face; + /** The output contours -- where the input contours ended up. */ + Array<Vector<int>> contour; + /** Maps output vertex indices to input vertex indices, -1 if there is none. */ + Array<int> orig_vert; + /** Maps output faces tot input faces that they were part of. */ + Array<int> orig_face; +}; + +MeshInset_Result mesh_inset_calc(const MeshInset_Input &input); + +} // namespace blender::meshinset |