protected virtual void updateMatrixes() { if (!_areMatrixesDirty) { return; } Matrix2D tempMat; _transformMatrix = Matrix2D.CreateTranslation(-entity.transform.position.X, -entity.transform.position.Y, 0f); // position if (_zoom != 1f) { Matrix2D.CreateScale(_zoom, _zoom, out tempMat); // scale -> Matrix2D.Multiply(ref _transformMatrix, ref tempMat, out _transformMatrix); } if (entity.transform.rotation != 0f) { Matrix2D.CreateRotationZ(entity.transform.rotation, out tempMat); // rotation Matrix2D.Multiply(ref _transformMatrix, ref tempMat, out _transformMatrix); } Matrix2D.CreateTranslation((int)_origin.X, (int)_origin.Y, out tempMat); // translate -origin Matrix2D.Multiply(ref _transformMatrix, ref tempMat, out _transformMatrix); // calculate our inverse as well Matrix2D.Invert(ref _transformMatrix, out _inverseTransformMatrix); // whenever the matrix changes the bounds are then invalid _areBoundsDirty = true; _areMatrixesDirty = false; }