private bool _solState; // m_solState public FlipperMover(FlipperData data, FlipperState state, EventProxy events, Table.Table table) { _data = data; _state = state; _events = events; _tableData = table.Data; if (data.FlipperRadiusMin > 0 && data.FlipperRadiusMax > data.FlipperRadiusMin) { data.FlipperRadius = data.FlipperRadiusMax - (data.FlipperRadiusMax - data.FlipperRadiusMin) /* m_ptable->m_globalDifficulty*/; data.FlipperRadius = MathF.Max(data.FlipperRadius, data.BaseRadius - data.EndRadius + 0.05f); } else { data.FlipperRadius = data.FlipperRadiusMax; } EndRadius = MathF.Max(data.EndRadius, 0.01f); // radius of flipper end FlipperRadius = MathF.Max(data.FlipperRadius, 0.01f); // radius of flipper arc, center-to-center radius AngleStart = MathF.DegToRad(data.StartAngle); AngleEnd = MathF.DegToRad(data.EndAngle); if (AngleEnd == AngleStart) { // otherwise hangs forever in collisions/updates AngleEnd += 0.0001f; } var height = table.GetSurfaceHeight(data.Surface, data.Center.X, data.Center.Y); var baseRadius = MathF.Max(data.BaseRadius, 0.01f); HitCircleBase = new HitCircle(data.Center, baseRadius, height, height + data.Height, ItemType.Flipper); IsInContact = false; EnableRotateEvent = 0; AngleSpeed = 0; _direction = AngleEnd >= AngleStart; _solState = false; _curTorque = 0.0f; _state.Angle = AngleStart; _angularMomentum = 0; _angularAcceleration = 0; var ratio = (baseRadius - EndRadius) / FlipperRadius; // model inertia of flipper as that of rod of length flipr around its end var mass = _data.GetFlipperMass(_tableData); Inertia = (float)(1.0 / 3.0) * mass * (FlipperRadius * FlipperRadius); LastHitFace = false; // used to optimize hit face search order // F2 Norm, used in Green's transform, in FPM time search // = sinf(faceNormOffset) ZeroAngNorm.X = MathF.Sqrt(1.0f - ratio * ratio); // F1 norm, change sign of x component, i.E -zeroAngNorm.X // = -cosf(faceNormOffset) ZeroAngNorm.Y = -ratio; }
private uint _lastHitTime; // m_last_hittime public FlipperHit(FlipperData data, FlipperState state, EventProxy events, Table.Table table) { data.UpdatePhysicsSettings(table); _events = events; _mover = new FlipperMover(data, state, events, table); _data = data; _state = state; _tableData = table.Data; UpdatePhysicsFromFlipper(); }
public Flipper(FlipperData data) : base(data) { _meshGenerator = new FlipperMeshGenerator(Data); State = new FlipperState(Data.Name, data.IsVisible, data.StartAngle, data.Center.Clone(), data.Material, data.Image, data.RubberMaterial); }