private void OnActorTransformChanged(object sender, TransformChangedEventArgs e) { ActorBase actor = e.Component.GameObj as ActorBase; actor.UpdateAABB(); collisions.MoveProxy(actor, ref actor.AABB, actor.Speed.Xy); collisionsCountA++; }
/// <summary> /// Updates the drag point position based on the transform translation /// </summary> private void OnTransformChanged(object sender, TransformChangedEventArgs e) { foreach (Transform dragPoint in dragPoints) { dragPoint.transform.position += e.translation; } UpdateDragPositions(); }
private void OnTransformChanged(object sender, TransformChangedEventArgs e) { // Don't react to events triggered by this Component, or while no physics body is available if (sender == this) return; if (this.body == null) return; // Apply transform changes to the physics body Transform t = e.Component as Transform; if ((e.Changes & Transform.DirtyFlags.Pos) != Transform.DirtyFlags.None) { this.body.Position = PhysicsUnit.LengthToPhysical * t.Pos.Xy; } if ((e.Changes & Transform.DirtyFlags.Angle) != Transform.DirtyFlags.None) { this.body.Rotation = t.Angle; } if ((e.Changes & Transform.DirtyFlags.Scale) != Transform.DirtyFlags.None) { float scale = t.Scale; if (scale == 0.0f || this.lastScale == 0.0f) { this.FlagBodyShape(); } else { const float pixelLimit = 2; float boundRadius = this.BoundRadius; float upper = (boundRadius + pixelLimit) / boundRadius; float lower = (boundRadius - pixelLimit) / boundRadius; if (scale / this.lastScale >= upper || scale / this.lastScale <= lower) { this.FlagBodyShape(); } } } // Make sure we're simulating this body, if something has changed if (e.Changes != Transform.DirtyFlags.None) { this.body.Awake = true; } }
private void OnTransformChanged(object sender, TransformChangedEventArgs e) { if (sender == this) return; if (this.body == null) return; Transform t = e.Component as Transform; if ((e.Changes & Transform.DirtyFlags.Pos) != Transform.DirtyFlags.None) this.body.Position = PhysicsConvert.ToPhysicalUnit(t.Pos.Xy); if ((e.Changes & Transform.DirtyFlags.Angle) != Transform.DirtyFlags.None) this.body.Rotation = t.Angle; if ((e.Changes & Transform.DirtyFlags.Scale) != Transform.DirtyFlags.None) { float scale = t.Scale; if (scale == 0.0f || this.lastScale == 0.0f) { this.FlagBodyShape(); } else { const float pixelLimit = 2; float boundRadius = this.BoundRadius; float upper = (boundRadius + pixelLimit) / boundRadius; float lower = (boundRadius - pixelLimit) / boundRadius; if (scale / this.lastScale >= upper || scale / this.lastScale <= lower) { this.FlagBodyShape(); } } } if (e.Changes != Transform.DirtyFlags.None) this.body.Awake = true; }
private void OnTransformChanged(object sender, TransformChangedEventArgs e) { if (sender == this) return; if (this.body == null) return; Transform t = e.Component as Transform; if ((e.Changes & Transform.DirtyFlags.Pos) != Transform.DirtyFlags.None) this.body.Position = PhysicsConvert.ToPhysicalUnit(t.Pos.Xy); if ((e.Changes & Transform.DirtyFlags.Angle) != Transform.DirtyFlags.None) this.body.Rotation = t.Angle; if ((e.Changes & Transform.DirtyFlags.Scale) != Transform.DirtyFlags.None) this.FlagBodyShape(); if (e.Changes != Transform.DirtyFlags.None) this.body.Awake = true; }