Page 1 of 1

PropertyBlendMethod

Posted: Fri Oct 17, 2014 9:15 am
by -=Magic=-
I'm updating my engine, with the lastest BEPU release. And I'm getting some strange "effect" :P

I noticed that the MaterialManager lost some functions. May I know why?

Actually there's only a default blender, which give as result a multply between material factors:

Bounciness = a.bounciness * b.bounciness,
KineticFriction = a.kineticFriction * b.kineticFriction,
StaticFriction = a.staticFriction * b.staticFriction

but with an older version (I don't know when the changes has been done) I can select how to blend each properties using PropertyBlendMethod (Average, Max, Min, BiasLow, BiasHigh).

Re: PropertyBlendMethod

Posted: Fri Oct 17, 2014 8:26 pm
by Norbo
The enums were discarded in favor of supplying arbitrary blending logic. It's more flexible and a little bit faster in the usual case.

To change the behavior, just provide a different blender delegate. For example, from the CoefficientsDemo:

Code: Select all

            //The material blender defines how the friction and bounciness values are computed between objects.
            //It defaults to multiplicative, but for the purposes of this demo, we'll switch it to use the smaller friction and the larger bounciness.
            MaterialManager.MaterialBlender = delegate(Material a, Material b, out InteractionProperties properties)
                {
                    properties.KineticFriction = MathHelper.Min(a.KineticFriction, b.KineticFriction);
                    properties.StaticFriction = MathHelper.Min(a.StaticFriction, b.StaticFriction);
                    properties.Bounciness = MathHelper.Max(a.Bounciness, b.Bounciness);
                };