MeshLib C++ Docs
Loading...
Searching...
No Matches
MRRelaxParams.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRVector3.h"
4#include "MRVectorTraits.h"
5#include "MRPch/MRBindingMacros.h"
6#include <cassert>
7
8namespace MR
9{
10
11struct RelaxParams
12{
14 int iterations = 1;
15
17 const VertBitSet *region = nullptr;
18
20 float force = 0.5f;
21
23 bool limitNearInitial = false;
24
26 float maxInitialDist = 0;
27
28 // Fixes ABI incompatibility. Without this GCC 12+ warns here with `-Wabi=16`.
29 // Read our `cmake/Modules/CompilerOptions.cmake` (the part about `-Wabi=16`) for details.
30 // This is enabled for GCC 11 and older because they're buggy, and for GCC 12 because for it we enable the warning to catch other similar cases.
31 // For other compilers it's disabled for clarity, but should have no effect on struct layout.
32 MR_BIND_IGNORE int _padding;
33};
34
35enum class RelaxApproxType
36{
37 Planar,
38 Quadric,
39};
40
43template <typename V>
44[[nodiscard]] inline V getLimitedPos( const V & pos, const V & guidePos, typename VectorTraits<V>::BaseType maxGuideDistSq )
45{
46 assert( maxGuideDistSq > 0 );
47 const auto d = pos - guidePos;
48 float distSq = sqr( d );
49 if ( distSq <= maxGuideDistSq )
50 return pos;
51 return guidePos + std::sqrt( maxGuideDistSq / distSq ) * d;
52}
53
54} // namespace MR
new unsafe MR.? Const_VertBitSet region
new unsafe ref int iterations
new unsafe ref bool limitNearInitial
new unsafe ref float force
new unsafe ref float maxInitialDist
Definition MRCameraOrientationPlugin.h:8
constexpr T sqr(T x) noexcept
squared value
Definition MRMeshFwd.h:752
V getLimitedPos(const V &pos, const V &guidePos, typename VectorTraits< V >::BaseType maxGuideDistSq)
Definition MRRelaxParams.h:44
T BaseType
Definition MRMesh/MRVectorTraits.h:18