Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ public SdfGraphics segment(
var width = Math.abs(x1 - x0);
var height = Math.abs(y1 - y0);

var halfWidth = width * 0.5f;
var halfHeight = height * 0.5f;
var halfWidth = (x1 - x0) * 0.5f;
var halfHeight = (y1 - y0) * 0.5f;

this.parameters .getRect()
.set(left, top, width, height);
.set(left + width / 2, top + height / 2, width, height);
this.parameters .segment( -halfWidth, -halfHeight, +halfWidth, +halfHeight);

return this;
Expand Down Expand Up @@ -318,12 +318,16 @@ private static void _draw(
var slice = ubo.slice(offset, SDF_PARAMETER_SIZE);
var state = new RenderState(
pose,
x0, y0,
x1, y1,
parameters.getColor(),
index,
ubo.slice(),
null
graphics.peekScissorStack(),
LibGuiElementRenderState.getBounds(
new Matrix3x2f(graphics.pose()),
x0, y0,
x1, y1,
graphics.peekScissorStack()
)
);

if (debug) {
Expand Down Expand Up @@ -353,41 +357,13 @@ private static boolean _collide(

private record RenderState(
Matrix3x2f pose,
float x0,
float y0,
float x1,
float y1,
int color,
int index,
GpuBufferSlice sdfParametersUbo,
@Nullable ScreenRectangle scissorArea,
@Nullable ScreenRectangle bounds
) implements LibGuiElementRenderState {

private RenderState(
Matrix3x2f pose,
float x0,
float y0,
float x1,
float y1,
int color,
int index,
GpuBufferSlice sdfParametersUbo,
@Nullable ScreenRectangle scissorArea
) {
this(
pose,
x0,
y0,
x1,
y1,
color,
index,
sdfParametersUbo, scissorArea,
LibGuiElementRenderState.getBounds(pose, x0, y0, x1, y1, scissorArea)
);
}

@Override
public void buildVertices(VertexConsumer consumer) {
consumer.addVertexWith2DPose(this.pose(), -0.5f, -0.5f).setUv(0, 0).setUv1(this.index(), 0).setColor(this.color());
Expand Down
Loading