本文整理汇总了C#中BulletSharp.RigidBody.ComputeImpulseDenominator方法的典型用法代码示例。如果您正苦于以下问题:C# RigidBody.ComputeImpulseDenominator方法的具体用法?C# RigidBody.ComputeImpulseDenominator怎么用?C# RigidBody.ComputeImpulseDenominator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BulletSharp.RigidBody
的用法示例。
在下文中一共展示了RigidBody.ComputeImpulseDenominator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalcRollingFriction
float CalcRollingFriction(RigidBody body0, RigidBody body1, Vector3 contactPosWorld, Vector3 frictionDirectionWorld, float maxImpulse)
{
float denom0 = body0.ComputeImpulseDenominator(contactPosWorld, frictionDirectionWorld);
float denom1 = body1.ComputeImpulseDenominator(contactPosWorld, frictionDirectionWorld);
const float relaxation = 1.0f;
float jacDiagABInv = relaxation / (denom0 + denom1);
float j1;
Vector3 rel_pos1 = contactPosWorld - body0.CenterOfMassPosition;
Vector3 rel_pos2 = contactPosWorld - body1.CenterOfMassPosition;
Vector3 vel1 = body0.GetVelocityInLocalPoint(rel_pos1);
Vector3 vel2 = body1.GetVelocityInLocalPoint(rel_pos2);
Vector3 vel = vel1 - vel2;
float vrel = Vector3.Dot(frictionDirectionWorld, vel);
// calculate j that moves us to zero relative velocity
j1 = -vrel * jacDiagABInv;
j1 = Math.Min(j1, maxImpulse);
j1 = Math.Max(j1, -maxImpulse);
return j1;
}