CompoundShapeEntry validation suggestion

Post and discuss features you'd like to see in the BEPUphysics library.
Post Reply
ecosky
Posts: 69
Joined: Fri Nov 04, 2011 7:13 am
Contact:

CompoundShapeEntry validation suggestion

Post by ecosky » Sat Apr 20, 2013 5:27 pm

Hi Norbo,

I recently had a problem that was due to my own error, but to find the cause I wound up adding some more validation to the CompoundShapeEntry which you may want to consider keeping around.

The first type is the validation of the transforms provided to the ctors. Higher level code had been providing invalid transforms to these and I was able to finally trap my bug by adding Validate calls to the inputs that would be used to create the local transforms.

The second type of validation is in the ComputeCenter methods, which currently do not check for a zero weight object. Since the ctors do not verify there is at least one shape in the CompoundShape that has weight, it's possible these methods will divide by zero. Personally, I think it would be most flexible if every shape in the compound isn't required to have mass so long as at least one does. It would probably make sense to consider other places that a weight of zero might cause similar problems.

I've attached my changes in case you want to check them out or use them.

Thanks again for Bepu!
Attachments
CompoundShape.cs
(19.78 KiB) Downloaded 268 times

ecosky
Posts: 69
Joined: Fri Nov 04, 2011 7:13 am
Contact:

Re: CompoundShapeEntry validation suggestion

Post by ecosky » Sat Apr 20, 2013 5:39 pm

Also I was wondering, it seems like it would make sense for the Matrix.Validate methods to use the Vector.Validate for each of the axes since they will typically (always?) be used for transform math that would rely on the LengthSquared() being in range. It also seems likely the LengthSquared of each axis along with M44 would need to be larger than some minimum to be safely invertible? I'm curious what your thoughts are there, thanks.

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

Re: CompoundShapeEntry validation suggestion

Post by Norbo » Sat Apr 20, 2013 6:26 pm

CompoundShape/Matrix axis validation added.

While a determinant validation could be inserted to verify that a matrix is invertible, that is not an operation which should be applied universally because singular matrices can be valid. A context specific validator could be added, though its usefulness would be limited. Inverting a singular matrix will produce values which should get detected pretty rapidly by other validations anyway.

ecosky
Posts: 69
Joined: Fri Nov 04, 2011 7:13 am
Contact:

Re: CompoundShapeEntry validation suggestion

Post by ecosky » Sat Apr 20, 2013 7:36 pm

Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest