PropertyBlendMethod

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
-=Magic=-
Posts: 41
Joined: Thu Jun 30, 2011 11:32 am

PropertyBlendMethod

Post 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).
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: PropertyBlendMethod

Post 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);
                };
Post Reply