[libgdx] Still compute RegionAttachment offsets when the region is null.

This lets computeWorldVertices work even when there is no region, which can be useful.
This commit is contained in:
Nathan Sweet 2025-07-14 23:44:21 -04:00
parent 30d4cb9820
commit a012479fc4

View File

@ -81,18 +81,6 @@ public class RegionAttachment extends Attachment implements HasTextureRegion {
/** Calculates the {@link #offset} and {@link #uvs} using the region and the attachment's transform. Must be called if the
* region, the region's properties, or the transform are changed. */
public void updateRegion () {
if (region == null) {
uvs[BLX] = 0;
uvs[BLY] = 0;
uvs[ULX] = 0;
uvs[ULY] = 1;
uvs[URX] = 1;
uvs[URY] = 1;
uvs[BRX] = 1;
uvs[BRY] = 0;
return;
}
float width = getWidth(), height = getHeight();
float localX2 = width / 2;
float localY2 = height / 2;
@ -137,7 +125,16 @@ public class RegionAttachment extends Attachment implements HasTextureRegion {
offset[BRY] = localYCos + localX2Sin;
float[] uvs = this.uvs;
if (rotated) {
if (region == null) {
uvs[BLX] = 0;
uvs[BLY] = 0;
uvs[ULX] = 0;
uvs[ULY] = 1;
uvs[URX] = 1;
uvs[URY] = 1;
uvs[BRX] = 1;
uvs[BRY] = 0;
} else if (rotated) {
uvs[BLX] = region.getU2();
uvs[BLY] = region.getV();
uvs[ULX] = region.getU2();