Add Margin property to ConvexHullCollider
Is your feature request related to a problem? Please describe. Bullet allows specifying a margin for colliders which can be especially useful in case of ConvexHull. Reported as missing by @mathmb1986 in #1574
Suggested code changes in the thread mentioned above: https://github.com/stride3d/stride/blob/master/sources/engine/Stride.Assets/Physics/ColliderShapeAssetCompiler.cs L135
ConvexHullColliderShapeDesc convexHullDescClone = new ConvexHullColliderShapeDesc
{
Scaling = convexHullDesc.Scaling,
+ Margin = convexHullDesc.Margin,
LocalOffset = convexHullDesc.LocalOffset,
LocalRotation = convexHullDesc.LocalRotation,
Decomposition = convexHullDesc.Decomposition,
};
https://github.com/stride3d/stride/blob/master/sources/engine/Stride.Physics/Shapes/ConvexHullColliderShape.cs L40
+ public float Margin
+ {
+ get { return InternalShape.Margin; }
+ set { InternalShape.Margin = value; }
+ }
+
https://github.com/stride3d/stride/blob/master/sources/engine/Stride.Physics/Data/ConvexHullColliderShapeDesc.cs L51
+ /// <userdoc>
+ /// The Margin of the generated convex hull.
+ /// </userdoc>
+ [DataMember(48)]
+ public float Margin { get; set; }
+
L84
shape = new ConvexHullColliderShape(ConvexHulls[0][0], ConvexHullsIndices[0][0], Scaling)
{
NeedsCustomCollisionCallback = true,
+ Margin = Margin,
};
L109
var subHull = new ConvexHullColliderShape(verts, indices, Scaling);
+ subHull.Margin = Margin;
L136
var subHull = new ConvexHullColliderShape(verts[0], indices[0], Scaling);
+ subHull.Margin = Margin;
L151
var subHull = new ConvexHullColliderShape(subVerts, subIndex, Scaling);
+ subHull.Margin = Margin;
A closer look should be placed on application of margin to all subHull components to see if this makes sense. Also, maybe it would make more sense to add Margin property on the base class ColliderShape - which is where Margin is defined in Bullet - this way all collider shapes could benefit.
Hi, as a newcomer to the engine I was wondering if this issue is being worked on by anyone. If not, I would like to try this issue to get more familiar with the code base. Thanks!
I'd say go for it if you want to learn the engine it will be very usefull info. AFAIK no one is working on new features for Bullet specifically right now, @Eideren, @Nicogo1705 and I are doing some unrelated work with Bepu in this PR since the future goal is to move on to Bepu but there is still a lot of work to do before that happens.