More performance tweaks, add missing Override annotations
This commit is contained in:
parent
3a95556132
commit
70f93cdd11
4 changed files with 109 additions and 63 deletions
83
CLAUDE.md
83
CLAUDE.md
|
|
@ -15,7 +15,10 @@ Dynmap is a dynamic web mapping plugin/mod for Minecraft servers. It's a multi-p
|
||||||
# Build outputs go to /target directory
|
# Build outputs go to /target directory
|
||||||
|
|
||||||
# Build specific module (for faster iteration, but NOT for PR submissions)
|
# Build specific module (for faster iteration, but NOT for PR submissions)
|
||||||
./gradlew :fabric-1.18:build
|
./gradlew :DynmapCore:build
|
||||||
|
|
||||||
|
# Run unit tests (DynmapCore only — JUnit 4)
|
||||||
|
./gradlew :DynmapCore:test
|
||||||
|
|
||||||
# Forge 1.12.2 (requires JDK 8 - set JAVA_HOME accordingly)
|
# Forge 1.12.2 (requires JDK 8 - set JAVA_HOME accordingly)
|
||||||
cd oldgradle
|
cd oldgradle
|
||||||
|
|
@ -27,20 +30,24 @@ cd oldgradle
|
||||||
- Forge 1.12.2 (oldgradle): JDK 8 strictly required
|
- Forge 1.12.2 (oldgradle): JDK 8 strictly required
|
||||||
- Runtime targets: JDK 8 (1.16-), JDK 16 (1.17.x), JDK 17 (1.18-1.20.4), JDK 21 (1.20.5+)
|
- Runtime targets: JDK 8 (1.16-), JDK 16 (1.17.x), JDK 17 (1.18-1.20.4), JDK 21 (1.20.5+)
|
||||||
|
|
||||||
|
**Build notes:**
|
||||||
|
- `gradle.properties` sets `org.gradle.parallel=false` and `org.gradle.daemon=false` — do not change these
|
||||||
|
- `snakeyaml` is pinned at 1.23 intentionally — newer versions break on Windows-encoded config files
|
||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
### Module Structure (71 modules total)
|
### Module Structure
|
||||||
|
|
||||||
**Core Shared Modules:**
|
**Core Shared Modules:**
|
||||||
- `DynmapCoreAPI/` - Stable public API for external plugins/mods (markers, mod support, rendering)
|
- `DynmapCoreAPI/` - Stable public API for external plugins/mods (markers, mod support, rendering). Published to `repo.mikeprimm.com`. The `org.dynmap.renderer` package here defines `DynmapBlockState` — the central block state abstraction used everywhere.
|
||||||
- `DynmapCore/` - Internal shared implementation (NOT stable - subject to breaking changes)
|
- `DynmapCore/` - Internal shared implementation (NOT stable - subject to breaking changes)
|
||||||
- `dynmap-api/` - Bukkit-specific public API
|
- `dynmap-api/` - Bukkit-specific public API
|
||||||
|
|
||||||
**Platform Implementations:**
|
**Platform Implementations:**
|
||||||
- `spigot/` - Bukkit/PaperMC implementation
|
- `spigot/` - Bukkit/PaperMC implementation (`DynmapPlugin.java`)
|
||||||
- `bukkit-helper-*` - Version-specific NMS code (25 versions: 1.13-1.21)
|
- `bukkit-helper-*` - Version-specific NMS code (one per MC version: 1.13-1.21)
|
||||||
- `fabric-*` - Fabric mod implementations (14 versions: 1.14.4-1.21.11)
|
- `fabric-*` - Fabric mod implementations (1.14.4-1.21.x)
|
||||||
- `forge-*` - Forge mod implementations (14 versions: 1.14.4-1.21.11)
|
- `forge-*` - Forge mod implementations (1.14.4-1.21.x); `forge-1.12.2` lives in `oldgradle/`
|
||||||
|
|
||||||
### Dependency Flow
|
### Dependency Flow
|
||||||
```
|
```
|
||||||
|
|
@ -54,31 +61,47 @@ Platform-specific modules (Spigot, Fabric, Forge)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Key Components in DynmapCore
|
### Key Components in DynmapCore
|
||||||
- `MapManager` - Tile/map rendering orchestration
|
|
||||||
- `DynmapCore.java` - Main coordination hub (~3,100 lines)
|
- `DynmapCore.java` — Main coordination hub (~3,100 lines); bootstrapped by each platform
|
||||||
- `storage/` - Storage backends (FileTree, MySQL, PostgreSQL, SQLite, S3)
|
- `MapManager.java` — Tile rendering orchestration; owns the render thread pool and `FullWorldRenderState` queue
|
||||||
- `hdmap/` - HD map rendering (block models, shaders, textures)
|
- `hdmap/` — HD map rendering pipeline:
|
||||||
- `web/` - Embedded Jetty server with servlets
|
- `IsoHDPerspective` — Isometric raytrace engine (the hot rendering path)
|
||||||
- `markers/` - Marker system implementation
|
- `HDBlockModels` / `HDScaledBlockModels` — Block geometry (patch/volumetric/scaled models)
|
||||||
|
- `TexturePack` / `TexturePackLoader` — Texture resolution from resource packs
|
||||||
|
- `hdmap/renderer/` — Custom block renderers (stairs, fences, doors, etc.) implementing `CustomRenderer`
|
||||||
|
- Shaders (`DefaultHDShader`, `CaveHDShader`, `TopoHDShader`, etc.) — post-process pixel color
|
||||||
|
- Lighting (`DefaultHDLighting`, `ShadowHDLighting`, etc.) — light level calculation
|
||||||
|
- `storage/` — Storage backends (FileTree, MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, AWS S3)
|
||||||
|
- `web/` — Embedded Jetty 9 server with custom HTTP routing (no standard servlet container)
|
||||||
|
- `markers/impl/` — Full marker system implementation; public interface is in `DynmapCoreAPI`
|
||||||
|
- `utils/MapChunkCache` + `utils/MapIterator` — Abstract interfaces that each platform implements to feed world data into the renderer
|
||||||
|
|
||||||
|
### Platform Integration Pattern
|
||||||
|
|
||||||
|
Each platform module (Spigot `bukkit-helper-*`, Fabric, Forge) must implement:
|
||||||
|
- `MapChunkCache` — Loads and caches chunk data for a tile's required chunks
|
||||||
|
- `MapIterator` — Block-by-block iteration over the loaded chunk cache
|
||||||
|
- A platform entry point (e.g., `DynmapPlugin` for Spigot) that bootstraps `DynmapCore`
|
||||||
|
|
||||||
|
The `bukkit-helper-*` modules contain version-specific NMS code; `spigot/` delegates to the appropriate helper at runtime via reflection.
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
Unit tests exist in `DynmapCore/src/test/` (JUnit 4) covering `Matrix3D`, `Vector3D`, `IpAddressMatcher`, `DynIntHashMap`, and `BufferInputStream`. Run with `./gradlew :DynmapCore:test`.
|
||||||
|
|
||||||
|
Full verification requires:
|
||||||
|
1. Building all platforms: `./gradlew setup build` AND `cd oldgradle && ./gradlew setup build`
|
||||||
|
2. Manual testing on target Minecraft server platforms
|
||||||
|
|
||||||
## Critical Contribution Rules
|
## Critical Contribution Rules
|
||||||
|
|
||||||
**PRs must build and test on ALL platforms including oldgradle. Changes to DynmapCore/DynmapCoreAPI require testing on all platforms.**
|
**PRs must build and test on ALL platforms including oldgradle. Changes to DynmapCore/DynmapCoreAPI require testing on all platforms.**
|
||||||
|
|
||||||
- **Java 8 compatibility required** - Code must compile and run on Java 8
|
- **Java 8 compatibility required** — Code must compile and run on Java 8
|
||||||
- **Java only** - No Kotlin, Scala, or other JVM languages
|
- **Java only** — No Kotlin, Scala, or other JVM languages
|
||||||
- **No dependency updates** - Library versions are tied to platform compatibility
|
- **No dependency updates** — Library versions are tied to platform compatibility
|
||||||
- **No platform-specific code** - Must work on Windows, Linux (x86/ARM), macOS, Docker
|
- **No platform-specific code** — Must work on Windows, Linux (x86/ARM), macOS, Docker
|
||||||
- **Small PRs only** - One feature per PR, no style/formatting changes
|
- **Small PRs only** — One feature per PR, no style/formatting changes
|
||||||
- **No mod-specific code** - Use Dynmap APIs instead; external mods should depend on DynmapCoreAPI
|
- **No mod-specific code** — Use Dynmap APIs instead; external mods should depend on DynmapCoreAPI
|
||||||
- **Apache License v2** - All code must be compatible
|
- **Apache License v2** — All code must be compatible
|
||||||
|
- **DynmapCoreAPI is the only stable API** — Do not add external dependencies on DynmapCore internals
|
||||||
## Testing
|
|
||||||
|
|
||||||
No automated tests exist. Verification is done by:
|
|
||||||
1. Building all platforms successfully (`./gradlew setup build` AND `cd oldgradle && ./gradlew setup build`)
|
|
||||||
2. Manual testing on target Minecraft server platforms
|
|
||||||
|
|
||||||
## Storage Backends
|
|
||||||
|
|
||||||
Dynmap supports: FileTree (default), MySQL/MariaDB, PostgreSQL, SQLite, MS SQL Server, AWS S3
|
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,13 @@ public class HDMapTile extends MapTile {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return tx ^ ty ^ perspective.hashCode() ^ world.hashCode() ^ boostzoom ^ tilescale;
|
int h = perspective.hashCode();
|
||||||
|
h = h * 31 + world.hashCode();
|
||||||
|
h = h * 31 + tx;
|
||||||
|
h = h * 31 + ty;
|
||||||
|
h = h * 31 + boostzoom;
|
||||||
|
h = h * 31 + tilescale;
|
||||||
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -87,19 +93,24 @@ public class HDMapTile extends MapTile {
|
||||||
@Override
|
@Override
|
||||||
public boolean isBlockTypeDataNeeded() { return MapManager.mapman.hdmapman.isBlockTypeDataNeeded(this); }
|
public boolean isBlockTypeDataNeeded() { return MapManager.mapman.hdmapman.isBlockTypeDataNeeded(this); }
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean render(MapChunkCache cache, String mapname) {
|
public boolean render(MapChunkCache cache, String mapname) {
|
||||||
return perspective.render(cache, this, mapname);
|
return perspective.render(cache, this, mapname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<DynmapChunk> getRequiredChunks() {
|
public List<DynmapChunk> getRequiredChunks() {
|
||||||
return perspective.getRequiredChunks(this);
|
return perspective.getRequiredChunks(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MapTile[] getAdjecentTiles() {
|
public MapTile[] getAdjecentTiles() {
|
||||||
return perspective.getAdjecentTiles(this);
|
return perspective.getAdjecentTiles(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int tileOrdinalX() { return tx; }
|
public int tileOrdinalX() { return tx; }
|
||||||
|
@Override
|
||||||
public int tileOrdinalY() { return ty; }
|
public int tileOrdinalY() { return ty; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ public class IsoHDPerspective implements HDPerspective {
|
||||||
/* Scaled models for non-cube blocks */
|
/* Scaled models for non-cube blocks */
|
||||||
private final HDScaledBlockModels scalemodels;
|
private final HDScaledBlockModels scalemodels;
|
||||||
private final int modscale;
|
private final int modscale;
|
||||||
|
private final int modscale2; /* modscale * modscale, precomputed for raytraceSubblock */
|
||||||
|
|
||||||
/* Section-level raytrace variables */
|
/* Section-level raytrace variables */
|
||||||
int sx, sy, sz;
|
int sx, sy, sz;
|
||||||
|
|
@ -153,6 +154,7 @@ public class IsoHDPerspective implements HDPerspective {
|
||||||
custom_meshes = new DynLongHashMap(4096);
|
custom_meshes = new DynLongHashMap(4096);
|
||||||
custom_fluid_meshes = new DynLongHashMap(4096);
|
custom_fluid_meshes = new DynLongHashMap(4096);
|
||||||
modscale = basemodscale << scaled;
|
modscale = basemodscale << scaled;
|
||||||
|
modscale2 = modscale * modscale;
|
||||||
scalemodels = HDBlockModels.getModelsForScale(basemodscale << scaled);
|
scalemodels = HDBlockModels.getModelsForScale(basemodscale << scaled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -250,18 +252,22 @@ public class IsoHDPerspective implements HDPerspective {
|
||||||
/**
|
/**
|
||||||
* Get pixel X coordinate
|
* Get pixel X coordinate
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final int getPixelX() { return px; }
|
public final int getPixelX() { return px; }
|
||||||
/**
|
/**
|
||||||
* Get pixel Y coordinate
|
* Get pixel Y coordinate
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final int getPixelY() { return py; }
|
public final int getPixelY() { return py; }
|
||||||
/**
|
/**
|
||||||
* Get map iterator
|
* Get map iterator
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final MapIterator getMapIterator() { return mapiter; }
|
public final MapIterator getMapIterator() { return mapiter; }
|
||||||
/**
|
/**
|
||||||
* Return submodel alpha value (-1 if no submodel rendered)
|
* Return submodel alpha value (-1 if no submodel rendered)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getSubmodelAlpha() {
|
public int getSubmodelAlpha() {
|
||||||
return subalpha;
|
return subalpha;
|
||||||
}
|
}
|
||||||
|
|
@ -283,9 +289,9 @@ public class IsoHDPerspective implements HDPerspective {
|
||||||
n = 1;
|
n = 1;
|
||||||
|
|
||||||
/* Initial section coord */
|
/* Initial section coord */
|
||||||
sx = fastFloor(top.x/16.0);
|
sx = fastFloor(top.x * 0.0625);
|
||||||
sy = fastFloor(top.y/16.0);
|
sy = fastFloor(top.y * 0.0625);
|
||||||
sz = fastFloor(top.z/16.0);
|
sz = fastFloor(top.z * 0.0625);
|
||||||
/* Compute parametric step (dt) per step on each axis */
|
/* Compute parametric step (dt) per step on each axis */
|
||||||
sdt_dx = 16.0 / dx;
|
sdt_dx = 16.0 / dx;
|
||||||
sdt_dy = 16.0 / dy;
|
sdt_dy = 16.0 / dy;
|
||||||
|
|
@ -302,7 +308,7 @@ public class IsoHDPerspective implements HDPerspective {
|
||||||
else if (bottom.x > top.x) {
|
else if (bottom.x > top.x) {
|
||||||
x_inc = 1;
|
x_inc = 1;
|
||||||
n += fastFloor(bottom.x) - x;
|
n += fastFloor(bottom.x) - x;
|
||||||
st_next_x = (fastFloor(top.x/16.0) + 1 - (top.x/16.0)) * sdt_dx;
|
st_next_x = (fastFloor(top.x * 0.0625) + 1 - (top.x * 0.0625)) * sdt_dx;
|
||||||
stepx = BlockStep.X_PLUS;
|
stepx = BlockStep.X_PLUS;
|
||||||
mxout = modscale;
|
mxout = modscale;
|
||||||
}
|
}
|
||||||
|
|
@ -310,7 +316,7 @@ public class IsoHDPerspective implements HDPerspective {
|
||||||
else {
|
else {
|
||||||
x_inc = -1;
|
x_inc = -1;
|
||||||
n += x - fastFloor(bottom.x);
|
n += x - fastFloor(bottom.x);
|
||||||
st_next_x = ((top.x/16.0) - fastFloor(top.x/16.0)) * sdt_dx;
|
st_next_x = ((top.x * 0.0625) - fastFloor(top.x * 0.0625)) * sdt_dx;
|
||||||
stepx = BlockStep.X_MINUS;
|
stepx = BlockStep.X_MINUS;
|
||||||
mxout = -1;
|
mxout = -1;
|
||||||
}
|
}
|
||||||
|
|
@ -325,7 +331,7 @@ public class IsoHDPerspective implements HDPerspective {
|
||||||
else if (bottom.y > top.y) {
|
else if (bottom.y > top.y) {
|
||||||
y_inc = 1;
|
y_inc = 1;
|
||||||
n += fastFloor(bottom.y) - y;
|
n += fastFloor(bottom.y) - y;
|
||||||
st_next_y = (fastFloor(top.y/16.0) + 1 - (top.y/16.0)) * sdt_dy;
|
st_next_y = (fastFloor(top.y * 0.0625) + 1 - (top.y * 0.0625)) * sdt_dy;
|
||||||
stepy = BlockStep.Y_PLUS;
|
stepy = BlockStep.Y_PLUS;
|
||||||
myout = modscale;
|
myout = modscale;
|
||||||
}
|
}
|
||||||
|
|
@ -333,7 +339,7 @@ public class IsoHDPerspective implements HDPerspective {
|
||||||
else {
|
else {
|
||||||
y_inc = -1;
|
y_inc = -1;
|
||||||
n += y - fastFloor(bottom.y);
|
n += y - fastFloor(bottom.y);
|
||||||
st_next_y = ((top.y/16.0) - fastFloor(top.y/16.0)) * sdt_dy;
|
st_next_y = ((top.y * 0.0625) - fastFloor(top.y * 0.0625)) * sdt_dy;
|
||||||
stepy = BlockStep.Y_MINUS;
|
stepy = BlockStep.Y_MINUS;
|
||||||
myout = -1;
|
myout = -1;
|
||||||
}
|
}
|
||||||
|
|
@ -348,7 +354,7 @@ public class IsoHDPerspective implements HDPerspective {
|
||||||
else if (bottom.z > top.z) {
|
else if (bottom.z > top.z) {
|
||||||
z_inc = 1;
|
z_inc = 1;
|
||||||
n += fastFloor(bottom.z) - z;
|
n += fastFloor(bottom.z) - z;
|
||||||
st_next_z = (fastFloor(top.z/16.0) + 1 - (top.z/16.0)) * sdt_dz;
|
st_next_z = (fastFloor(top.z * 0.0625) + 1 - (top.z * 0.0625)) * sdt_dz;
|
||||||
stepz = BlockStep.Z_PLUS;
|
stepz = BlockStep.Z_PLUS;
|
||||||
mzout = modscale;
|
mzout = modscale;
|
||||||
}
|
}
|
||||||
|
|
@ -356,7 +362,7 @@ public class IsoHDPerspective implements HDPerspective {
|
||||||
else {
|
else {
|
||||||
z_inc = -1;
|
z_inc = -1;
|
||||||
n += z - fastFloor(bottom.z);
|
n += z - fastFloor(bottom.z);
|
||||||
st_next_z = ((top.z/16.0) - fastFloor(top.z/16.0)) * sdt_dz;
|
st_next_z = ((top.z * 0.0625) - fastFloor(top.z * 0.0625)) * sdt_dz;
|
||||||
stepz = BlockStep.Z_MINUS;
|
stepz = BlockStep.Z_MINUS;
|
||||||
mzout = -1;
|
mzout = -1;
|
||||||
}
|
}
|
||||||
|
|
@ -810,7 +816,7 @@ public class IsoHDPerspective implements HDPerspective {
|
||||||
while(mt <= mtend) {
|
while(mt <= mtend) {
|
||||||
if(!skip) {
|
if(!skip) {
|
||||||
try {
|
try {
|
||||||
int blkalpha = model[modscale*modscale*my + modscale*mz + mx];
|
int blkalpha = model[modscale2*my + modscale*mz + mx];
|
||||||
if(blkalpha > 0) {
|
if(blkalpha > 0) {
|
||||||
subalpha = blkalpha;
|
subalpha = blkalpha;
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -857,6 +863,7 @@ public class IsoHDPerspective implements HDPerspective {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final int[] getSubblockCoord() {
|
public final int[] getSubblockCoord() {
|
||||||
if(cur_patch >= 0) { /* If patch hit */
|
if(cur_patch >= 0) { /* If patch hit */
|
||||||
double tt = cur_patch_t;
|
double tt = cur_patch_t;
|
||||||
|
|
@ -885,6 +892,7 @@ public class IsoHDPerspective implements HDPerspective {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is the hit on a cullable face?
|
// Is the hit on a cullable face?
|
||||||
|
@Override
|
||||||
public final boolean isOnFace() {
|
public final boolean isOnFace() {
|
||||||
double tt;
|
double tt;
|
||||||
if(cur_patch >= 0) { /* If patch hit */
|
if(cur_patch >= 0) { /* If patch hit */
|
||||||
|
|
@ -1294,11 +1302,14 @@ public class IsoHDPerspective implements HDPerspective {
|
||||||
miny = tile.getDynmapWorld().minY;
|
miny = tile.getDynmapWorld().minY;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = 0; x < tileSize * sizescale; x++) {
|
final int tilePixelSize = tileSize * sizescale;
|
||||||
|
final double invSizescale = 1.0 / sizescale;
|
||||||
|
for(int x = 0; x < tilePixelSize; x++) {
|
||||||
ps.px = x;
|
ps.px = x;
|
||||||
for(int y = 0; y < tileSize * sizescale; y++) {
|
final double px_center = xbase + (x + 0.5) * invSizescale;
|
||||||
ps.top.x = ps.bottom.x = xbase + (x + 0.5) / sizescale; /* Start at center of pixel at Y=height+0.5, bottom at Y=-0.5 */
|
for(int y = 0; y < tilePixelSize; y++) {
|
||||||
ps.top.y = ps.bottom.y = ybase + (y + 0.5) / sizescale;
|
ps.top.x = ps.bottom.x = px_center;
|
||||||
|
ps.top.y = ps.bottom.y = ybase + (y + 0.5) * invSizescale;
|
||||||
ps.top.z = height + 0.5; ps.bottom.z = miny - 0.5;
|
ps.top.z = height + 0.5; ps.bottom.z = miny - 0.5;
|
||||||
map_to_world.transform(ps.top); /* Transform to world coordinates */
|
map_to_world.transform(ps.top); /* Transform to world coordinates */
|
||||||
map_to_world.transform(ps.bottom);
|
map_to_world.transform(ps.bottom);
|
||||||
|
|
@ -1314,6 +1325,7 @@ public class IsoHDPerspective implements HDPerspective {
|
||||||
Log.severe("Error while raytracing tile: perspective=" + this.name + ", coord=" + mapiter.getX() + "," + mapiter.getY() + "," + mapiter.getZ() + ", blockid=" + mapiter.getBlockType() + ", lighting=" + mapiter.getBlockSkyLight() + ":" + mapiter.getBlockEmittedLight() + ", biome=" + mapiter.getBiome().toString(), ex);
|
Log.severe("Error while raytracing tile: perspective=" + this.name + ", coord=" + mapiter.getX() + "," + mapiter.getY() + "," + mapiter.getZ() + ", blockid=" + mapiter.getBlockType() + ", lighting=" + mapiter.getBlockSkyLight() + ":" + mapiter.getBlockEmittedLight() + ", biome=" + mapiter.getBiome().toString(), ex);
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
final int rowOffset = (tilePixelSize - y - 1) * tilePixelSize + x;
|
||||||
for(int i = 0; i < numshaders; i++) {
|
for(int i = 0; i < numshaders; i++) {
|
||||||
if(shaderdone[i] == false) {
|
if(shaderdone[i] == false) {
|
||||||
shaderstate[i].rayFinished(ps);
|
shaderstate[i].rayFinished(ps);
|
||||||
|
|
@ -1325,21 +1337,11 @@ public class IsoHDPerspective implements HDPerspective {
|
||||||
shaderstate[i].getRayColor(rslt, 0);
|
shaderstate[i].getRayColor(rslt, 0);
|
||||||
int c_argb = rslt.getARGB();
|
int c_argb = rslt.getARGB();
|
||||||
if (c_argb != 0) rendered[i] = true;
|
if (c_argb != 0) rendered[i] = true;
|
||||||
if (isOpaque[i] && (c_argb == 0)) {
|
argb_buf[i][rowOffset] = (isOpaque[i] && (c_argb == 0)) ? bgnight[i] : c_argb;
|
||||||
argb_buf[i][(tileSize*sizescale-y-1)*tileSize*sizescale + x] = bgnight[i];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
argb_buf[i][(tileSize*sizescale-y-1)*tileSize*sizescale + x] = c_argb;
|
|
||||||
}
|
|
||||||
if (day_argb_buf[i] != null) {
|
if (day_argb_buf[i] != null) {
|
||||||
shaderstate[i].getRayColor(rslt, 1);
|
shaderstate[i].getRayColor(rslt, 1);
|
||||||
c_argb = rslt.getARGB();
|
c_argb = rslt.getARGB();
|
||||||
if (isOpaque[i] && (c_argb == 0)) {
|
day_argb_buf[i][rowOffset] = (isOpaque[i] && (c_argb == 0)) ? bgday[i] : c_argb;
|
||||||
day_argb_buf[i][(tileSize*sizescale-y-1)*tileSize*sizescale + x] = bgday[i];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
day_argb_buf[i][(tileSize*sizescale-y-1)*tileSize*sizescale + x] = c_argb;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -181,6 +181,7 @@ public class TexturePackHDShader implements HDShader {
|
||||||
* Process next ray step - called for each block on route
|
* Process next ray step - called for each block on route
|
||||||
* @return true if ray is done, false if ray needs to continue
|
* @return true if ray is done, false if ray needs to continue
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean processBlock(HDPerspectiveState ps) {
|
public boolean processBlock(HDPerspectiveState ps) {
|
||||||
DynmapBlockState blocktype = ps.getBlockState();
|
DynmapBlockState blocktype = ps.getBlockState();
|
||||||
if ((hiddenids != null) && hiddenids.get(blocktype.globalStateIndex)) {
|
if ((hiddenids != null) && hiddenids.get(blocktype.globalStateIndex)) {
|
||||||
|
|
@ -265,7 +266,7 @@ public class TexturePackHDShader implements HDShader {
|
||||||
if(color[0].isTransparent()) {
|
if(color[0].isTransparent()) {
|
||||||
for(int i = 0; i < color.length; i++)
|
for(int i = 0; i < color.length; i++)
|
||||||
color[i].setColor(tmpcolor[i]);
|
color[i].setColor(tmpcolor[i]);
|
||||||
return (color[0].getAlpha() == 255);
|
return (tmpcolor[0].getAlpha() == 255);
|
||||||
}
|
}
|
||||||
/* Else, blend and generate new alpha */
|
/* Else, blend and generate new alpha */
|
||||||
else {
|
else {
|
||||||
|
|
@ -273,14 +274,18 @@ public class TexturePackHDShader implements HDShader {
|
||||||
int alpha2 = tmpcolor[0].getAlpha() * (255-alpha) / 255;
|
int alpha2 = tmpcolor[0].getAlpha() * (255-alpha) / 255;
|
||||||
int talpha = alpha + alpha2;
|
int talpha = alpha + alpha2;
|
||||||
if(talpha > 0)
|
if(talpha > 0)
|
||||||
for(int i = 0; i < color.length; i++)
|
for(int i = 0; i < color.length; i++) {
|
||||||
color[i].setRGBA((tmpcolor[i].getRed()*alpha2 + color[i].getRed()*alpha) / talpha,
|
int tc = tmpcolor[i].getARGB();
|
||||||
(tmpcolor[i].getGreen()*alpha2 + color[i].getGreen()*alpha) / talpha,
|
int cc = color[i].getARGB();
|
||||||
(tmpcolor[i].getBlue()*alpha2 + color[i].getBlue()*alpha) / talpha, talpha);
|
color[i].setARGB((talpha << 24)
|
||||||
|
| (((((tc >> 16) & 0xFF) * alpha2 + ((cc >> 16) & 0xFF) * alpha) / talpha) << 16)
|
||||||
|
| (((((tc >> 8) & 0xFF) * alpha2 + ((cc >> 8) & 0xFF) * alpha) / talpha) << 8)
|
||||||
|
| ((( tc & 0xFF) * alpha2 + ( cc & 0xFF) * alpha) / talpha));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
for(int i = 0; i < color.length; i++)
|
for(int i = 0; i < color.length; i++)
|
||||||
color[i].setTransparent();
|
color[i].setTransparent();
|
||||||
|
|
||||||
return (talpha >= 254); /* If only one short, no meaningful contribution left */
|
return (talpha >= 254); /* If only one short, no meaningful contribution left */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -290,6 +295,7 @@ public class TexturePackHDShader implements HDShader {
|
||||||
/**
|
/**
|
||||||
* Ray ended - used to report that ray has exited map (called if renderer has not reported complete)
|
* Ray ended - used to report that ray has exited map (called if renderer has not reported complete)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void rayFinished(HDPerspectiveState ps) {
|
public void rayFinished(HDPerspectiveState ps) {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
@ -297,12 +303,14 @@ public class TexturePackHDShader implements HDShader {
|
||||||
* @param c - object to store color value in
|
* @param c - object to store color value in
|
||||||
* @param index - index of color to request (renderer specific - 0=default, 1=day for night/day renderer
|
* @param index - index of color to request (renderer specific - 0=default, 1=day for night/day renderer
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void getRayColor(Color c, int index) {
|
public void getRayColor(Color c, int index) {
|
||||||
c.setColor(color[index]);
|
c.setColor(color[index]);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Clean up state object - called after last ray completed
|
* Clean up state object - called after last ray completed
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void cleanup() {
|
public void cleanup() {
|
||||||
if (ctm_cache != null) {
|
if (ctm_cache != null) {
|
||||||
ctm_cache.clear();
|
ctm_cache.clear();
|
||||||
|
|
@ -338,11 +346,13 @@ public class TexturePackHDShader implements HDShader {
|
||||||
* @param scale - scale of perspective
|
* @param scale - scale of perspective
|
||||||
* @return state object to use for all rays in tile
|
* @return state object to use for all rays in tile
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public HDShaderState getStateInstance(HDMap map, MapChunkCache cache, MapIterator mapiter, int scale) {
|
public HDShaderState getStateInstance(HDMap map, MapChunkCache cache, MapIterator mapiter, int scale) {
|
||||||
return new ShaderState(mapiter, map, cache, scale);
|
return new ShaderState(mapiter, map, cache, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add shader's contributions to JSON for map object */
|
/* Add shader's contributions to JSON for map object */
|
||||||
|
@Override
|
||||||
public void addClientConfiguration(JSONObject mapObject) {
|
public void addClientConfiguration(JSONObject mapObject) {
|
||||||
s(mapObject, "shader", name);
|
s(mapObject, "shader", name);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue