Skip to content

Commit 665a05e

Browse files
authored
docs: XML Comments added for Bepu Constraints (#2633)
* docs: XML Comments added * docs: XML comments added for CenterDistanceLimitConstraintComponent.cs * fix: XML comment wording corrected * docs: XML comment added for CenterDistanceConstraintComponent * feat: XML comments added for BallSocketConstraintComponent.cs * docs: XML comments improvements * docs: XML comment updated * fix: Duplicated summary removed * docs: XML comments improvements * docs: XML comments improvements * docs: XML comments improvements
1 parent 7b77b00 commit 665a05e

File tree

6 files changed

+118
-4
lines changed

6 files changed

+118
-4
lines changed

sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Constraints/BallSocketConstraintComponent.cs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
33

44
using BepuPhysics.Constraints;
5-
using Stride.BepuPhysics.Definitions;
65
using Stride.BepuPhysics.Systems;
76
using Stride.Core;
87
using Stride.Core.Mathematics;
@@ -11,13 +10,33 @@
1110

1211
namespace Stride.BepuPhysics.Constraints;
1312

13+
/// <summary>
14+
/// Creates a spherical joint (also known as a ball and socket joint) that constrains two bodies to share a connection point.
15+
/// <para>
16+
/// This constraint keeps a specific point on body A (defined by <see cref="LocalOffsetA"/>) coincident with a specific point
17+
/// on body B (defined by <see cref="LocalOffsetB"/>), while still allowing full rotational freedom around the connection point.
18+
/// </para>
19+
/// <para>
20+
/// Common uses include:
21+
/// <list type="bullet">
22+
/// <item>Character joint connections (shoulders, hips, etc.)</item>
23+
/// <item>Chain links</item>
24+
/// <item>Pendulums</item>
25+
/// <item>Rag doll physics</item>
26+
/// <item>Cloth and soft body simulation</item>
27+
/// </list>
28+
/// </para>
29+
/// </summary>
1430
[DataContract]
1531
[DefaultEntityComponentProcessor(typeof(ConstraintProcessor), ExecutionMode = ExecutionMode.Runtime)]
1632
[ComponentCategory("Physics - Bepu Constraint")]
1733
public sealed class BallSocketConstraintComponent : TwoBodyConstraintComponent<BallSocket>
1834
{
1935
public BallSocketConstraintComponent() => BepuConstraint = new() { SpringSettings = new SpringSettings(30, 5) };
2036

37+
/// <summary>
38+
/// Offset from the center of body A to its attachment in A's local space.
39+
/// </summary>
2140
public Vector3 LocalOffsetA
2241
{
2342
get
@@ -31,6 +50,9 @@ public Vector3 LocalOffsetA
3150
}
3251
}
3352

53+
/// <summary>
54+
/// Offset from the center of body B to its attachment in B's local space.
55+
/// </summary>
3456
public Vector3 LocalOffsetB
3557
{
3658
get
@@ -44,6 +66,10 @@ public Vector3 LocalOffsetB
4466
}
4567
}
4668

69+
/// <summary>
70+
/// Gets or sets the target number of undamped oscillations per unit of time.
71+
/// Higher frequency values create stiffer connections, while lower values allow more elasticity in the joint.
72+
/// </summary>
4773
public float SpringFrequency
4874
{
4975
get
@@ -57,6 +83,10 @@ public float SpringFrequency
5783
}
5884
}
5985

86+
/// <summary>
87+
/// Gets or sets the ratio of the spring's actual damping to its critical damping. 0 is undamped, 1 is critically damped, and higher values are overdamped.
88+
/// Higher damping ratios reduce oscillations and make the connection less elastic.
89+
/// </summary>
6090
public float SpringDampingRatio
6191
{
6292
get

sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Constraints/CenterDistanceConstraintComponent.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,27 @@
99

1010
namespace Stride.BepuPhysics.Constraints;
1111

12+
/// <summary>
13+
/// Constrains the center of two bodies to be separated by a target distance.
14+
/// This constraint ensures that the distance between the center points of two bodies
15+
/// attempts to match a specific target value. Unlike <see cref="DistanceServoConstraintComponent"/>,
16+
/// this constraint operates directly on the body centers rather than on specific points on the bodies.
17+
/// </summary>
18+
/// <remarks>
19+
/// This is a specialized variant of <see cref="DistanceServoConstraintComponent"/> that works with body centers.
20+
/// Use this when you need to constrain the distance between bodies without specifying exact attachment points.
21+
/// For a version that allows a range of distances rather than a single target value, see <see cref="CenterDistanceLimitConstraintComponent"/>.
22+
/// </remarks>
1223
[DataContract]
1324
[DefaultEntityComponentProcessor(typeof(ConstraintProcessor), ExecutionMode = ExecutionMode.Runtime)]
1425
[ComponentCategory("Physics - Bepu Constraint")]
1526
public sealed class CenterDistanceConstraintComponent : TwoBodyConstraintComponent<CenterDistanceConstraint>
1627
{
1728
public CenterDistanceConstraintComponent() => BepuConstraint = new() { SpringSettings = new SpringSettings(30, 5) };
1829

30+
/// <summary>
31+
/// Target distance between the body centers.
32+
/// </summary>
1933
public float TargetDistance
2034
{
2135
get

sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Constraints/CenterDistanceLimitConstraintComponent.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,26 @@
99

1010
namespace Stride.BepuPhysics.Constraints;
1111

12+
/// <summary>
13+
/// Constrains the center of two bodies to be separated by a distance within a range.
14+
/// This constraint ensures that the distance between the center points of two bodies remains within
15+
/// a minimum and maximum range. Unlike <see cref="DistanceLimitConstraintComponent"/>, this constraint
16+
/// operates directly on the body centers rather than on specific points on the bodies.
17+
/// </summary>
18+
/// <remarks>
19+
/// This is a specialized variant of <see cref="DistanceLimitConstraintComponent"/> that works with body centers.
20+
/// Use this when you need to constrain the overall distance between bodies without specifying exact attachment points.
21+
/// </remarks>
1222
[DataContract]
1323
[DefaultEntityComponentProcessor(typeof(ConstraintProcessor), ExecutionMode = ExecutionMode.Runtime)]
1424
[ComponentCategory("Physics - Bepu Constraint")]
1525
public sealed class CenterDistanceLimitConstraintComponent : TwoBodyConstraintComponent<CenterDistanceLimit>
1626
{
1727
public CenterDistanceLimitConstraintComponent() => BepuConstraint = new() { SpringSettings = new SpringSettings(30, 5) };
1828

29+
/// <summary>
30+
/// Minimum distance between the body centers.
31+
/// </summary>
1932
public float MinimumDistance
2033
{
2134
get { return BepuConstraint.MinimumDistance; }
@@ -26,6 +39,9 @@ public float MinimumDistance
2639
}
2740
}
2841

42+
/// <summary>
43+
/// Maximum distance between the body centers.
44+
/// </summary>
2945
public float MaximumDistance
3046
{
3147
get { return BepuConstraint.MaximumDistance; }

sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Constraints/DistanceLimitConstraintComponent.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
33

44
using BepuPhysics.Constraints;
5-
using Stride.BepuPhysics.Definitions;
65
using Stride.BepuPhysics.Systems;
76
using Stride.Core;
87
using Stride.Core.Mathematics;
@@ -11,13 +10,27 @@
1110

1211
namespace Stride.BepuPhysics.Constraints;
1312

13+
/// <summary>
14+
/// Constrains points on two bodies to be separated by a distance within a specified range.
15+
/// This constraint ensures that the distance between two points on two bodies remains within
16+
/// a minimum and maximum range. It is useful for creating elastic or flexible connections
17+
/// between bodies, where the distance can vary within the specified limits.
18+
/// </summary>
19+
/// <remarks>
20+
/// Unlike <see cref="CenterDistanceLimitConstraintComponent"/>, this constraint allows you to specify
21+
/// exact attachment points on each body using <see cref="LocalOffsetA"/> and <see cref="LocalOffsetB"/> properties. If you need to
22+
/// constrain only the centers of bodies, use <see cref="CenterDistanceLimitConstraintComponent"/> instead.
23+
/// </remarks>
1424
[DataContract]
1525
[DefaultEntityComponentProcessor(typeof(ConstraintProcessor), ExecutionMode = ExecutionMode.Runtime)]
1626
[ComponentCategory("Physics - Bepu Constraint")]
1727
public sealed class DistanceLimitConstraintComponent : TwoBodyConstraintComponent<DistanceLimit>
1828
{
1929
public DistanceLimitConstraintComponent() => BepuConstraint = new() { SpringSettings = new SpringSettings(30, 5) };
2030

31+
/// <summary>
32+
/// Local offset from the center of body A to its attachment point.
33+
/// </summary>
2134
public Vector3 LocalOffsetA
2235
{
2336
get
@@ -31,6 +44,9 @@ public Vector3 LocalOffsetA
3144
}
3245
}
3346

47+
/// <summary>
48+
/// Local offset from the center of body B to its attachment point.
49+
/// </summary>
3450
public Vector3 LocalOffsetB
3551
{
3652
get
@@ -44,6 +60,9 @@ public Vector3 LocalOffsetB
4460
}
4561
}
4662

63+
/// <summary>
64+
/// Minimum distance permitted between the point on A and the point on B.
65+
/// </summary>
4766
public float MinimumDistance
4867
{
4968
get
@@ -57,6 +76,9 @@ public float MinimumDistance
5776
}
5877
}
5978

79+
/// <summary>
80+
/// Maximum distance permitted between the point on A and the point on B.
81+
/// </summary>
6082
public float MaximumDistance
6183
{
6284
get

sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Constraints/DistanceServoConstraintComponent.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
33

44
using BepuPhysics.Constraints;
5-
using Stride.BepuPhysics.Definitions;
65
using Stride.BepuPhysics.Systems;
76
using Stride.Core;
87
using Stride.Core.Mathematics;
@@ -11,6 +10,18 @@
1110

1211
namespace Stride.BepuPhysics.Constraints;
1312

13+
/// <summary>
14+
/// Constrains points on two bodies to be separated by a target distance using servo settings.
15+
/// This constraint attempts to maintain a specific distance between two points on two bodies
16+
/// by applying forces to reach the target distance. It uses servo settings to control the speed
17+
/// and force applied to achieve the target distance.
18+
/// </summary>
19+
/// <remarks>
20+
/// Unlike <see cref="CenterDistanceConstraintComponent"/>, this constraint allows you to specify
21+
/// exact attachment points on each body using <see cref="LocalOffsetA"/> and <see cref="LocalOffsetB"/> properties. If you need to
22+
/// constrain only the centers of bodies, use <see cref="CenterDistanceConstraintComponent"/> instead.
23+
/// For a version that allows a range of distances rather than a single target value, see <see cref="DistanceLimitConstraintComponent"/>.
24+
/// </remarks>
1425
[DataContract]
1526
[DefaultEntityComponentProcessor(typeof(ConstraintProcessor), ExecutionMode = ExecutionMode.Runtime)]
1627
[ComponentCategory("Physics - Bepu Constraint")]
@@ -22,6 +33,9 @@ public sealed class DistanceServoConstraintComponent : TwoBodyConstraintComponen
2233
ServoSettings = new ServoSettings(10, 1, 1000)
2334
};
2435

36+
/// <summary>
37+
/// Local offset from the center of body A to its attachment point.
38+
/// </summary>
2539
public Vector3 LocalOffsetA
2640
{
2741
get
@@ -35,6 +49,9 @@ public Vector3 LocalOffsetA
3549
}
3650
}
3751

52+
/// <summary>
53+
/// Local offset from the center of body B to its attachment point.
54+
/// </summary>
3855
public Vector3 LocalOffsetB
3956
{
4057
get
@@ -48,6 +65,9 @@ public Vector3 LocalOffsetB
4865
}
4966
}
5067

68+
/// <summary>
69+
/// Distance that the constraint will try to reach between the attachment points.
70+
/// </summary>
5171
public float TargetDistance
5272
{
5373
get

sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Constraints/OneBodyAngularServoConstraintComponent.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
33

44
using BepuPhysics.Constraints;
5-
using Stride.BepuPhysics.Definitions;
65
using Stride.BepuPhysics.Systems;
76
using Stride.Core;
87
using Stride.Core.Mathematics;
@@ -11,6 +10,19 @@
1110

1211
namespace Stride.BepuPhysics.Constraints;
1312

13+
/// <summary>
14+
/// Constrains a single body to a target orientation in space, controlling both rotation and tilt.
15+
/// <para>This constraint applies torque to make a body gradually align with a specific target orientation.
16+
/// It works like a spring system that pulls the body's orientation (rotation around any axis, including tilt)
17+
/// toward the specified target orientation.</para>
18+
/// <para>Common uses include:</para>
19+
/// <list type="bullet">
20+
/// <item>Stabilizing objects to maintain a specific orientation</item>
21+
/// <item>Creating motorized joints that rotate/tilt objects to desired angles</item>
22+
/// <item>Simulating gyroscopic or magnetic orientation control</item>
23+
/// </list>
24+
/// <para>The spring and servo settings control how quickly and forcefully the body moves toward the target orientation.</para>
25+
/// </summary>
1426
[DataContract]
1527
[DefaultEntityComponentProcessor(typeof(ConstraintProcessor), ExecutionMode = ExecutionMode.Runtime)]
1628
[ComponentCategory("Physics - Bepu Constraint")]

0 commit comments

Comments
 (0)