issue with small transformable entities

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
PauloPereira
Posts: 1
Joined: Fri Oct 18, 2019 6:58 pm

issue with small transformable entities

Post by PauloPereira »

Hi,

I am trying to create small boxes using a Transformable entity using a box shape with the following code:

Code: Select all

            Matrix3x3 transform = Matrix3x3.CreateFromAxisAngle(new Vector3(1,0,0), PI / 4);
            var transformable = new TransformableEntity (new Vector3 (0, 0, 0), new BoxShape (0.1f, 0.1f, 0.1f), transform, 0.1f);
            Space.Add (transformable);
The transformable shape is throwing an exception "System.ArgumentException: " Point set is degenerate; convex hulls must have volume" " in the function UpdateConvexShapeInfo().

Code: Select all

public void UpdateConvexShapeInfo()
        {
            //Compute the volume distribution.
            var samples = CommonResources.GetVectorList();
            if (samples.Capacity < InertiaHelper.SampleDirections.Length)
                samples.Capacity = InertiaHelper.SampleDirections.Length;
            samples.Count = InertiaHelper.SampleDirections.Length;
            for (int i = 0; i < InertiaHelper.SampleDirections.Length; ++i)
            {
                shape.GetLocalExtremePointWithoutMargin(ref InertiaHelper.SampleDirections[i], out samples.Elements[i]);
            }

            var triangles = CommonResources.GetIntList();
            ConvexHullHelper.GetConvexHull(samples, triangles);

            float volume;
            InertiaHelper.ComputeShapeDistribution(samples, triangles, out volume, out volumeDistribution);
            Volume = volume;

            //Estimate the minimum radius based on the surface mesh.
            MinimumRadius = InertiaHelper.ComputeMinimumRadius(samples, triangles, ref Toolbox.ZeroVector) + collisionMargin;
            MaximumRadius = ComputeMaximumRadius();
            CommonResources.GiveBack(samples);
            CommonResources.GiveBack(triangles);


        }

This problem only happens when using a boxshape with small dimensions. Is it a bug or am I missing something?

Thanks
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: issue with small transformable entities

Post by Norbo »

v1 makes some assumptions about scale. The volume of that box is smaller than Toolbox.BigEpsilon's default value of 1e-5, so it gets flagged as invalid.

You could modify the BigEpsilon value, the ConvexHullHelper's error check, or use something like the demos ConfigurationHelper.ApplyScale function to adjust all the tuning knobs at the same time if the simulation needs to handle smaller shapes like that.

(v2 tends to be way better about this sort of stuff.)
Post Reply