Skip to content

Commit

Permalink
Merge remote-tracking branch 'mindustry-antigrief/master' into client
Browse files Browse the repository at this point in the history
  • Loading branch information
buthed010203 committed Oct 30, 2024
2 parents b082c69 + a68d566 commit 213a104
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[![](https://github.com/Anuken/Arc/workflows/Java%20CI/badge.svg)](https://github.com/Anuken/Arc/actions)
Wow a fork of a fork of libgdx no way
Wow a fork of a fork of libgdx no way.
4 changes: 2 additions & 2 deletions arc-core/src/arc/graphics/Pixmap.java
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,9 @@ public void draw(Pixmap pixmap, int srcx, int srcy, int srcWidth, int srcHeight,
ByteBuffer pixels = this.pixels, otherPixels = pixmap.pixels;
int
startY = Math.max(dsty, 0),
endY = Math.min(dsty + Math.min(dstHeight, oheight), height),
endY = Math.min(Math.min(dsty + Math.min(dstHeight, oheight), height), dsty - srcy + oheight),
startX = Math.max(dstx, 0),
endX = Math.min(dstx + Math.min(dstWidth, owidth), width),
endX = Math.min(Math.min(dstx + Math.min(dstWidth, owidth), width), dstx - srcx + owidth),
offsetY = dsty - srcy,
scanX = Math.max(Math.max(srcx, -dstx), 0),
scanWidth = (endX - startX) * 4;
Expand Down
3 changes: 2 additions & 1 deletion arc-core/src/arc/graphics/g2d/Lines.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ private static void preparePointyJoin(Vec2 A, Vec2 B, Vec2 C, Vec2 D, Vec2 E, fl
prepareStraightJoin(B, D, E, halfLineWidth);
return;
}
float len = (float)(halfLineWidth / Math.sin(angle));
//clamps length to avoid super sharp edges. this looks pretty bad, but it's better than the alternative of a 1-pixel line to infinity
float len = Mathf.clamp((float)(halfLineWidth / Math.sin(angle)), -halfLineWidth*10f, halfLineWidth*10f);
boolean bendsLeft = angle < 0;
AB.setLength(len);
BC.setLength(len);
Expand Down
15 changes: 12 additions & 3 deletions arc-core/src/arc/scene/ui/TextField.java
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,11 @@ protected void moveCursor(boolean forward, boolean jump){
int limit = forward ? text.length() : 0;
int charOffset = forward ? 0 : -1;
while((forward ? ++cursor < limit : --cursor > limit) && jump){
if(!continueCursor(cursor, charOffset)) break;
if(forward != continueCursor(cursor, charOffset)) break;
}
if(!jump || (forward && cursor >= limit) || (!forward && cursor <= limit)) return;
while((forward ? ++cursor < limit : --cursor > limit)){
if(forward == continueCursor(cursor, charOffset)) break;
}
}

Expand Down Expand Up @@ -1133,12 +1137,17 @@ public boolean keyTyped(InputEvent event, char character){
if(hasSelection)
cursor = delete(false);
else{
boolean ctrl = Core.input.ctrl() && !Core.input.alt();
boolean jump = ctrl && !passwordMode;
if(backspace && cursor > 0){
text = text.substring(0, cursor - 1) + text.substring(cursor--);
moveCursor(false, jump);
text = text.substring(0, cursor) + text.substring(oldCursor);
renderOffset = 0;
}
if(delete && cursor < text.length()){
text = text.substring(0, cursor) + text.substring(cursor + 1);
moveCursor(true, jump);
text = text.substring(0, oldCursor) + text.substring(cursor);
cursor = oldCursor;
}
}
if(add && !remove){
Expand Down
40 changes: 40 additions & 0 deletions arc-core/test/PixmapTest.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import arc.graphics.*;
import arc.math.*;
import arc.math.geom.*;
import arc.util.*;
import org.junit.*;

Expand Down Expand Up @@ -27,6 +29,44 @@ public void pixmapCreate(){
assertEquals(0, pix.get(0, 0));
}

@Test
public void pixmapBounds(){
int x = 176;

Pixmap base = new Pixmap(176, 269);
Pixmap crop = new Pixmap(176, 176);

crop.draw(base, 0, 176, x, x, 0, 0, x, x, true);
}

static Rect rect = new Rect();
static Vec2 v1 = new Vec2(), v2 = new Vec2();

static void randomize(){
rect.set(Mathf.random(30f), Mathf.random(30f), 8f, 8f);
v1.set(Mathf.random(30f), Mathf.random(30f));
v2.set(Mathf.random(30f), Mathf.random(30f));
}

// @Test
// public void raycasts(){
//
// Vec2 hole = new Vec2();
// int[] results = {0};
//
// bench(() -> {
// randomize();
//
// results[0] += Intersector.intersectSegmentRectangle(v1, v2, rect) ? 1 : 0;
// }, () -> {
// randomize();
//
// results[0] += Intersector.intersectSegmentRectangleFast(v1.x, v1.y, v2.x, v2.y, rect.x, rect.y, rect.width, rect.height) ? 1 : 0;
// }, 100_000_000);
//
// Log.info(results[0]);
// }

/*
@Test
public void normals(){
Expand Down

0 comments on commit 213a104

Please sign in to comment.