Gras (Textur) Pinsel Bugs behoben

This commit is contained in:
2026-08-21 15:47:31 +02:00
parent 03dcfb4187
commit 08e1df06d4
3 changed files with 63 additions and 11 deletions

View File

@@ -147,6 +147,33 @@ public class PlacedObjectState extends BaseAppState {
grassNode = new Node("grassNode");
((SimpleApplication) app).getRootNode().attachChild(grassNode);
applyAllSlotMaterials();
initAspectRatios();
}
private void initAspectRatios() {
String[] allPaths = new String[8];
allPaths[0] = input.grassTexturePath != null ? input.grassTexturePath : "";
String[] slots = input.grassTextureSlots;
for (int i = 0; i < 7; i++) {
allPaths[i + 1] = (i < slots.length && slots[i] != null) ? slots[i] : "";
}
float[] ars = input.grassAspectRatios.clone();
for (int s = 0; s < 8; s++) {
String p = allPaths[s];
if (p == null || p.isEmpty()) continue;
try {
com.jme3.texture.Texture tex = assetManager.loadTexture(
new com.jme3.asset.TextureKey(p, false));
if (tex != null && tex.getImage() != null) {
int w = tex.getImage().getWidth();
int h = tex.getImage().getHeight();
if (w > 0 && h > 0) ars[s] = (float) w / h;
}
} catch (Exception e) {
log.debug("[PlacedObjectState] Aspect-Ratio nicht lesbar für Slot {}: {}", s, e.getMessage());
}
}
input.grassAspectRatios = ars;
}
@Override