oωo (owo-lib)

oωo (owo-lib)

29M Downloads

OwoUIDrawContext#intersectsScissor(PositionRectangle) not respecting MatrixStack transformation

Closed this issue · 1 comments

commented

Minecraft's DrawContext#enableScissor(int, int, int, int) transformes the Scissor according to the MatrixStack:
(Snipper)

public void enableScissor(int x1, int y1, int x2, int y2) {
  ScreenRect screenRect = (new ScreenRect(x1, y1, x2 - x1, y2 - y1)).transform(this.matrices);
  this.scissorStack.push(screenRect);
}

However, owo's intersectsScissor does not respect that transformation:

public boolean intersectsScissor(PositionedRectangle other) {
var rect = this.scissorStack.peekLast();
if (rect == null) return true;
var pos = rect.position();
return other.x() < pos.x() + rect.width()
&& other.x() + other.width() >= pos.x()
&& other.y() < pos.y() + rect.height()
&& other.y() + other.height() >= pos.y();
}

This is fine as long as the translation is 0,0.
When rendering a toast for example, then it is not possible to use OwoUIAdapter, because it scissors the entire screen (which isn't an issue):

context.enableScissor(0, 0, window.getFramebufferWidth(), window.getFramebufferHeight());
this.rootComponent.draw(owoContext, mouseX, mouseY, partialTicks, delta);
context.disableScissor();

But then BaseParentComponent checks for the scissor intersection before drawing:
if (!context.intersectsScissor(child)) continue;

The scissor intersection returns false, even though it should return true. And the toast won't render.

commented

Should be fixed in 93380d5