@@ -42,9 +42,9 @@ class EdgeShapeConf: public ShapeBuilder<EdgeShapeConf>
42
42
{
43
43
public:
44
44
// / @brief Gets the default vertex radius.
45
- static PLAYRHO_CONSTEXPR inline Length GetDefaultVertexRadius () noexcept
45
+ static PLAYRHO_CONSTEXPR inline NonNegative< Length> GetDefaultVertexRadius () noexcept
46
46
{
47
- return DefaultLinearSlop * Real{2 };
47
+ return NonNegative<Length>{ DefaultLinearSlop * Real{2 } };
48
48
}
49
49
50
50
// / @brief Gets the default configuration.
@@ -53,14 +53,17 @@ class EdgeShapeConf: public ShapeBuilder<EdgeShapeConf>
53
53
return EdgeShapeConf{};
54
54
}
55
55
56
- EdgeShapeConf ();
56
+ EdgeShapeConf () = default ;
57
57
58
58
// / @brief Initializing constructor.
59
59
EdgeShapeConf (Length2 vA, Length2 vB, const EdgeShapeConf& conf = GetDefaultConf()) noexcept ;
60
60
61
61
// / @brief Sets both vertices in one call.
62
62
EdgeShapeConf& Set (Length2 vA, Length2 vB) noexcept ;
63
63
64
+ // / @brief Uses the given vertex radius.
65
+ EdgeShapeConf& UseVertexRadius (NonNegative<Length> value) noexcept ;
66
+
64
67
// / @brief Gets vertex A.
65
68
Length2 GetVertexA () const noexcept
66
69
{
@@ -79,11 +82,30 @@ class EdgeShapeConf: public ShapeBuilder<EdgeShapeConf>
79
82
return DistanceProxy{vertexRadius, 2 , m_vertices, m_normals};
80
83
}
81
84
85
+ // / @brief Vertex radius.
86
+ // /
87
+ // / @details This is the radius from the vertex that the shape's "skin" should
88
+ // / extend outward by. While any edges — line segments between multiple
89
+ // / vertices — are straight, corners between them (the vertices) are
90
+ // / rounded and treated as rounded. Shapes with larger vertex radiuses compared
91
+ // / to edge lengths therefore will be more prone to rolling or having other
92
+ // / shapes more prone to roll off of them.
93
+ // /
94
+ // / @note This should be a non-negative value.
95
+ // /
96
+ NonNegative<Length> vertexRadius = GetDefaultVertexRadius();
97
+
82
98
private:
83
99
Length2 m_vertices[2 ] = {Length2{}, Length2{}}; // /< Vertices
84
100
UnitVec m_normals[2 ] = {UnitVec{}, UnitVec{}}; // /< Normals.
85
101
};
86
102
103
+ inline EdgeShapeConf& EdgeShapeConf::UseVertexRadius (NonNegative<Length> value) noexcept
104
+ {
105
+ vertexRadius = value;
106
+ return *this ;
107
+ }
108
+
87
109
// Free functions...
88
110
89
111
// / @brief Equality operator.
@@ -117,6 +139,18 @@ inline DistanceProxy GetChild(const EdgeShapeConf& arg, ChildCounter index)
117
139
return arg.GetChild ();
118
140
}
119
141
142
+ // / @brief Gets the vertex radius of the given shape configuration.
143
+ inline NonNegative<Length> GetVertexRadius (const EdgeShapeConf& arg) noexcept
144
+ {
145
+ return arg.vertexRadius ;
146
+ }
147
+
148
+ // / @brief Gets the vertex radius of the given shape configuration.
149
+ inline NonNegative<Length> GetVertexRadius (const EdgeShapeConf& arg, ChildCounter) noexcept
150
+ {
151
+ return GetVertexRadius (arg);
152
+ }
153
+
120
154
// / @brief Gets the mass data for the given shape configuration.
121
155
inline MassData GetMassData (const EdgeShapeConf& arg) noexcept
122
156
{
0 commit comments