mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
fix: "sunlight leakage" when GlobalLightLevel was changed, premature lightmap rendering on leftmost side of screen where no pre-calculated light value was given
Former-commit-id: bf628e9bde44858f641998e65bf5fef847060791 Former-commit-id: b32fec30a112a7b5868e51ba1394454d5740c5d9
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,46 +1,49 @@
|
|||||||
"id";"name" ;"opacity";"strength";"fluid";"viscosity";"solid";"wall";"lumcolor";"opaque";"drop";"fall";"friction"
|
"id";"name" ;"opacity";"strength";"fluid";"viscosity";"solid";"wall";"lumcolor";"opaque";"drop";"fall";"friction"
|
||||||
# Friction: 0: frictionless, <16: slippery, 16: regular, >16: sticky | Opacity/Lumcolor: 40-step RGB | Opaque: whether the tile completely hides wall behind
|
"0";"TILE_AIR" ; "1641"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0";"16"
|
||||||
"0";"TILE_AIR" ; "1641"; "0"; "0"; "N/A"; "0"; "0"; "0"; "0"; "0"; "0";"16"
|
"1";"TILE_STONE" ; "8205"; "25"; "0"; "0"; "1"; "1"; "0"; "1"; "1"; "0";"16"
|
||||||
"1";"TILE_STONE" ; "8205"; "25"; "0"; "N/A"; "1"; "1"; "0"; "1"; "1"; "0";"16"
|
"2";"TILE_DIRT" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "2"; "0";"16"
|
||||||
"2";"TILE_DIRT" ; "8205"; "6"; "0"; "N/A"; "1"; "1"; "0"; "1"; "2"; "0";"16"
|
"3";"TILE_GRASS" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "2"; "0";"16"
|
||||||
"3";"TILE_GRASS" ; "8205"; "6"; "0"; "N/A"; "1"; "1"; "0"; "1"; "2"; "0";"16"
|
"4";"TILE_PLANK_NORMAL" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "4"; "0";"16"
|
||||||
"4";"TILE_PLANK_NORMAL" ; "8205"; "12"; "0"; "N/A"; "1"; "1"; "0"; "1"; "4"; "0";"16"
|
"5";"TILE_PLANK_EBONY" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "5"; "0";"16"
|
||||||
"5";"TILE_PLANK_EBONY" ; "8205"; "12"; "0"; "N/A"; "1"; "1"; "0"; "1"; "5"; "0";"16"
|
"6";"TILE_PLANK_BIRCH" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "6"; "0";"16"
|
||||||
"6";"TILE_PLANK_BIRCH" ; "8205"; "12"; "0"; "N/A"; "1"; "1"; "0"; "1"; "6"; "0";"16"
|
"7";"TILE_PLANK_BLOODROSE" ; "8205"; "12"; "0"; "0"; "1"; "1"; "0"; "1"; "7"; "0";"16"
|
||||||
"7";"TILE_PLANK_BLOODROSE" ; "8205"; "12"; "0"; "N/A"; "1"; "1"; "0"; "1"; "7"; "0";"16"
|
"8";"TILE_TRUNK_NORMAL" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "8"; "0";"16"
|
||||||
"8";"TILE_TRUNK_NORMAL" ; "8205"; "12"; "0"; "N/A"; "1"; "0"; "0"; "1"; "8"; "0";"16"
|
"9";"TILE_TRUNK_EBONY" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "9"; "0";"16"
|
||||||
"9";"TILE_TRUNK_EBONY" ; "8205"; "12"; "0"; "N/A"; "1"; "0"; "0"; "1"; "9"; "0";"16"
|
"10";"TILE_TRUNK_BIRCH" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "10"; "0";"16"
|
||||||
"10";"TILE_TRUNK_BIRCH" ; "8205"; "12"; "0"; "N/A"; "1"; "0"; "0"; "1"; "10"; "0";"16"
|
"11";"TILE_TRUNK_BLOODROSE" ; "8205"; "12"; "0"; "0"; "1"; "0"; "0"; "1"; "11"; "0";"16"
|
||||||
"11";"TILE_TRUNK_BLOODROSE" ; "8205"; "12"; "0"; "N/A"; "1"; "0"; "0"; "1"; "11"; "0";"16"
|
"12";"TILE_STONE_QUARRIED" ; "8205"; "25"; "0"; "0"; "1"; "1"; "0"; "1"; "12"; "0";"16"
|
||||||
"12";"TILE_STONE_QUARRIED" ; "8205"; "25"; "0"; "N/A"; "1"; "1"; "0"; "1"; "12"; "0";"16"
|
"13";"TILE_SAND" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "13"; "1";"16"
|
||||||
"13";"TILE_SAND" ; "8205"; "6"; "0"; "N/A"; "1"; "1"; "0"; "1"; "13"; "1";"16"
|
"14";"TILE_GRAVEL" ; "8205"; "6"; "0"; "0"; "1"; "0"; "0"; "1"; "14"; "1";"16"
|
||||||
"14";"TILE_GRAVEL" ; "8205"; "6"; "0"; "N/A"; "1"; "0"; "0"; "1"; "14"; "1";"16"
|
|
||||||
|
|
||||||
"15";"TILE_ORE_MALACHITE" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "15"; "0";"16"
|
"15";"TILE_ORE_MALACHITE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "15"; "0";"16"
|
||||||
"16";"TILE_ORE_HEMATITE" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "16"; "0";"16"
|
"16";"TILE_ORE_HEMATITE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "16"; "0";"16"
|
||||||
"17";"TILE_ORE_NATURAL_GOLD" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "17"; "0";"16"
|
"17";"TILE_ORE_NATURAL_GOLD" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "17"; "0";"16"
|
||||||
"18";"TILE_ORE_NATURAL_SILVER" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "18"; "0";"16"
|
"18";"TILE_ORE_NATURAL_SILVER" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "18"; "0";"16"
|
||||||
"19";"TILE_ORE_RUTILE" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "19"; "0";"16"
|
"19";"TILE_ORE_RUTILE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "19"; "0";"16"
|
||||||
"20";"TILE_ORE_AURICHALCUMITE" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "20"; "0";"16"
|
"20";"TILE_ORE_AURICHALCUMITE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "20"; "0";"16"
|
||||||
"21";"TILE_GEM_RUBY" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "21"; "0";"16"
|
"21";"TILE_GEM_RUBY" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "21"; "0";"16"
|
||||||
"22";"TILE_GEM_EMERALD" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "22"; "0";"16"
|
"22";"TILE_GEM_EMERALD" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "22"; "0";"16"
|
||||||
"23";"TILE_GEM_SAPPHIRE" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "23"; "0";"16"
|
"23";"TILE_GEM_SAPPHIRE" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "23"; "0";"16"
|
||||||
"24";"TILE_GEM_TOPAZ" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "24"; "0";"16"
|
"24";"TILE_GEM_TOPAZ" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "24"; "0";"16"
|
||||||
"25";"TILE_GEM_DIAMOND" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "25"; "0";"16"
|
"25";"TILE_GEM_DIAMOND" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "25"; "0";"16"
|
||||||
"26";"TILE_GEM_AMETHYST" ; "8205"; "25"; "0"; "N/A"; "1"; "0"; "0"; "1"; "26"; "0";"16"
|
"26";"TILE_GEM_AMETHYST" ; "8205"; "25"; "0"; "0"; "1"; "0"; "0"; "1"; "26"; "0";"16"
|
||||||
|
|
||||||
"27";"TILE_SNOW" ; "8205"; "6"; "0"; "N/A"; "1"; "1"; "0"; "1"; "27"; "0";"16"
|
"27";"TILE_SNOW" ; "8205"; "6"; "0"; "0"; "1"; "1"; "0"; "1"; "27"; "0";"16"
|
||||||
"28";"TILE_ICE_FRAGILE" ; "3282"; "1"; "0"; "N/A"; "1"; "0"; "0"; "0"; "28"; "0";"16"
|
"28";"TILE_ICE_FRAGILE" ; "3282"; "1"; "0"; "0"; "1"; "0"; "0"; "0"; "28"; "0";"16"
|
||||||
"29";"TILE_ICE_NATURAL" ; "6564"; "25"; "0"; "N/A"; "1"; "1"; "0"; "1"; "29"; "0"; "8"
|
"29";"TILE_ICE_NATURAL" ; "6564"; "25"; "0"; "0"; "1"; "1"; "0"; "1"; "29"; "0"; "8"
|
||||||
"30";"TILE_ICE_CLEAR_MAGICAL" ; "8205"; "25"; "0"; "N/A"; "1"; "1"; "5009"; "0"; "30"; "0"; "8"
|
"30";"TILE_ICE_CLEAR_MAGICAL" ; "8205"; "25"; "0"; "0"; "1"; "1"; "5009"; "0"; "30"; "0"; "8"
|
||||||
# see scandinavian name set female of this tile id!
|
# see scandinavian name set female of this tile id!
|
||||||
"31";"TILE_PLATFORM_STONE" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "0"; "31"; "0";"16"
|
"31";"TILE_PLATFORM_STONE" ; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "31"; "0";"16"
|
||||||
"32";"TILE_PLATFORM_WOODEN" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "0"; "32"; "0";"16"
|
"32";"TILE_PLATFORM_WOODEN" ; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "32"; "0";"16"
|
||||||
"33";"TILE_PLATFORM_EBONY" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "0"; "33"; "0";"16"
|
"33";"TILE_PLATFORM_EBONY" ; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "33"; "0";"16"
|
||||||
"34";"TILE_PLATFORM_BIRCH" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "0"; "34"; "0";"16"
|
"34";"TILE_PLATFORM_BIRCH" ; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "34"; "0";"16"
|
||||||
"35";"TILE_PLATFORM_BLOODROSE" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "0"; "0"; "35"; "0";"16"
|
"35";"TILE_PLATFORM_BLOODROSE" ; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "35"; "0";"16"
|
||||||
|
|
||||||
"36";"TILE_TORCH" ; "0"; "0"; "0"; "N/A"; "0"; "0"; "63412"; "0"; "36"; "0";"16"
|
"36";"TILE_TORCH" ; "0"; "0"; "0"; "0"; "0"; "0"; "63412"; "0"; "36"; "0";"16"
|
||||||
# 63412 (ffa44e) : real candlelight colour taken from properly configured camera.
|
# 63412 (ffa44e) : real candlelight colour taken from properly configured camera.
|
||||||
"239";"TILE_WATER" ; "6522"; "100"; "1"; "2"; "0"; "0"; "0"; "0"; "239"; "0";"16"
|
"239";"TILE_WATER" ; "6522"; "100"; "1"; "16"; "0"; "0"; "0"; "0"; "239"; "0";"16"
|
||||||
"255";"TILE_LAVA" ; "62358"; "100"; "1"; "2"; "0"; "0"; "48320"; "0"; "239"; "0";"16"
|
"255";"TILE_LAVA" ; "62358"; "100"; "1"; "16"; "0"; "0"; "48320"; "0"; "239"; "0";"16"
|
||||||
|
# Friction: 0: frictionless, <16: slippery, 16: regular, >16: sticky
|
||||||
|
# Opacity/Lumcolor: 40-step RGB
|
||||||
|
# Opaque: whether the tile completely hides wall behind
|
||||||
|
# Viscosity: (walkspeedmax) * (1 + (n/16))
|
||||||
|
Can't render this file because it contains an unexpected character in line 1 and column 12.
|
@@ -47,6 +47,7 @@ public class LightmapRenderer {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static void addLantern(int x, int y, char intensity) {
|
public static void addLantern(int x, int y, char intensity) {
|
||||||
LightmapLantern thisLantern = new LightmapLantern(x, y, intensity);
|
LightmapLantern thisLantern = new LightmapLantern(x, y, intensity);
|
||||||
|
|
||||||
@@ -64,6 +65,7 @@ public class LightmapRenderer {
|
|||||||
lanterns.add(thisLantern);
|
lanterns.add(thisLantern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static void removeLantern(int x, int y) {
|
public static void removeLantern(int x, int y) {
|
||||||
for (int i = lanterns.size() - 1; i >= 0; i--) {
|
for (int i = lanterns.size() - 1; i >= 0; i--) {
|
||||||
LightmapLantern lantern = lanterns.get(i);
|
LightmapLantern lantern = lanterns.get(i);
|
||||||
@@ -85,11 +87,11 @@ public class LightmapRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int for_y_start = div16(MapCamera.getCameraY()) - MUL;
|
int for_y_start = div16(MapCamera.getCameraY()) - 1;
|
||||||
int for_x_start = div16(MapCamera.getCameraX()) - MUL;
|
int for_x_start = div16(MapCamera.getCameraX()) - 1;
|
||||||
|
|
||||||
int for_y_end = clampHTile(for_y_start + div16(MapCamera.getRenderHeight()) + 2) + MUL;
|
int for_y_end = clampHTile(for_y_start + div16(MapCamera.getRenderHeight()) + 2) + 1;
|
||||||
int for_x_end = clampWTile(for_x_start + div16(MapCamera.getRenderWidth()) + 2) + MUL;
|
int for_x_end = clampWTile(for_x_start + div16(MapCamera.getRenderWidth()) + 2) + 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updating order:
|
* Updating order:
|
||||||
@@ -102,13 +104,12 @@ public class LightmapRenderer {
|
|||||||
* for all staticLightMap[y][x]
|
* for all staticLightMap[y][x]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Round 1
|
purgePartOfLightmap(for_x_start - 1, for_y_start - 1, for_x_end + 1, for_y_end + 1);
|
||||||
purgePartOfLightmap(for_x_start, for_y_start, for_x_end, for_y_end);
|
// if wider purge were not applied, GL changing (sunset, sunrise) will behave incorrectly
|
||||||
|
// ("leakage" of non-updated sunlight)
|
||||||
//System.out.println(for_x_start);
|
|
||||||
//System.out.println(for_x_end);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Round 1
|
||||||
for (int y = for_y_start; y < for_y_end; y++) {
|
for (int y = for_y_start; y < for_y_end; y++) {
|
||||||
for (int x = for_x_start; x < for_x_end; x++) {
|
for (int x = for_x_start; x < for_x_end; x++) {
|
||||||
staticLightMap[y][x] = calculate(x, y);
|
staticLightMap[y][x] = calculate(x, y);
|
||||||
@@ -140,117 +141,132 @@ public class LightmapRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void draw(Graphics g) {
|
public static void draw(Graphics g) {
|
||||||
int for_x_start = MapCamera.getRenderStartX();
|
int for_x_start = MapCamera.getRenderStartX() - 1;
|
||||||
int for_y_start = MapCamera.getRenderStartY();
|
int for_y_start = MapCamera.getRenderStartY() - 1;
|
||||||
int for_x_end = MapCamera.getRenderEndX();
|
int for_x_end = MapCamera.getRenderEndX();
|
||||||
int for_y_end = MapCamera.getRenderEndY();
|
int for_y_end = MapCamera.getRenderEndY();
|
||||||
|
|
||||||
// draw
|
// draw
|
||||||
for (int y = for_y_start; y < for_y_end; y++) {
|
try {
|
||||||
for (int x = for_x_start; x < for_x_end; x++) {
|
for (int y = for_y_start; y < for_y_end; y++) {
|
||||||
// smooth
|
for (int x = for_x_start; x < for_x_end; x++) {
|
||||||
if (Terrarum.game.screenZoom >= 1 && ((boolean) Terrarum.game.gameConfig.get("smoothlighting"))) {
|
// smooth
|
||||||
char thisLightLevel = staticLightMap[y][x];
|
if (Terrarum.game.screenZoom >= 1 && ((boolean) Terrarum.game.gameConfig.get(
|
||||||
if (y > 0 && x < for_x_end && thisLightLevel == 0 && staticLightMap[y - 1][x] == 0) {
|
"smoothlighting"))) {
|
||||||
try {
|
char thisLightLevel = staticLightMap[y][x];
|
||||||
// coalesce zero intensity blocks to one
|
if (y > 0 && x < for_x_end && thisLightLevel == 0 && staticLightMap[y - 1][x] == 0) {
|
||||||
int zeroLevelCounter = 1;
|
try {
|
||||||
while (staticLightMap[y][x + zeroLevelCounter] == 0
|
// coalesce zero intensity blocks to one
|
||||||
&& staticLightMap[y - 1][x + zeroLevelCounter] == 0) {
|
int zeroLevelCounter = 1;
|
||||||
zeroLevelCounter += 1;
|
while (staticLightMap[y][x + zeroLevelCounter] == 0
|
||||||
|
&& staticLightMap[y - 1][x + zeroLevelCounter] == 0) {
|
||||||
|
zeroLevelCounter += 1;
|
||||||
|
|
||||||
if (x + zeroLevelCounter >= for_x_end) break;
|
if (x + zeroLevelCounter >= for_x_end) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
g.setColor(new Color(0));
|
||||||
|
g.fillRect(
|
||||||
|
Math.round(x * TSIZE * Terrarum.game.screenZoom)
|
||||||
|
, Math.round(y * TSIZE * Terrarum.game.screenZoom)
|
||||||
|
, FastMath.ceil(
|
||||||
|
TSIZE * Terrarum.game.screenZoom) * zeroLevelCounter
|
||||||
|
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom)
|
||||||
|
);
|
||||||
|
|
||||||
|
x += (zeroLevelCounter - 1);
|
||||||
|
}
|
||||||
|
catch (ArrayIndexOutOfBoundsException e) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/** a
|
||||||
|
* +-+-+
|
||||||
|
* |i|j|
|
||||||
|
* b +-+-+ c
|
||||||
|
* |k|l|
|
||||||
|
* +-+-+
|
||||||
|
* d
|
||||||
|
*/
|
||||||
|
char a = (y == 0) ? thisLightLevel
|
||||||
|
: (y == Terrarum.game.map.height - 1) ? thisLightLevel
|
||||||
|
: maximiseRGB(
|
||||||
|
staticLightMap[y][x]
|
||||||
|
,
|
||||||
|
staticLightMap[y - 1][x]);
|
||||||
|
char d = (y == 0) ? thisLightLevel
|
||||||
|
: (y == Terrarum.game.map.height - 1) ? thisLightLevel
|
||||||
|
: maximiseRGB(
|
||||||
|
staticLightMap[y][x]
|
||||||
|
,
|
||||||
|
staticLightMap[y + 1][x]);
|
||||||
|
char b = (x == 0) ? thisLightLevel
|
||||||
|
: (x == Terrarum.game.map.width - 1) ? thisLightLevel
|
||||||
|
: maximiseRGB(
|
||||||
|
staticLightMap[y][x]
|
||||||
|
,
|
||||||
|
staticLightMap[y][x - 1]);
|
||||||
|
char c = (x == 0) ? thisLightLevel
|
||||||
|
: (x == Terrarum.game.map.width - 1) ? thisLightLevel
|
||||||
|
: maximiseRGB(
|
||||||
|
staticLightMap[y][x]
|
||||||
|
,
|
||||||
|
staticLightMap[y][x + 1]);
|
||||||
|
char[] colourMapItoL = new char[4];
|
||||||
|
colourMapItoL[0] = colourLinearMix(a, b);
|
||||||
|
colourMapItoL[1] = colourLinearMix(a, c);
|
||||||
|
colourMapItoL[2] = colourLinearMix(b, d);
|
||||||
|
colourMapItoL[3] = colourLinearMix(c, d);
|
||||||
|
|
||||||
|
for (int iy = 0; iy < 2; iy++) {
|
||||||
|
for (int ix = 0; ix < 2; ix++) {
|
||||||
|
g.setColor(toTargetColour(colourMapItoL[iy * 2 + ix]));
|
||||||
|
|
||||||
|
g.fillRect(
|
||||||
|
Math.round(
|
||||||
|
x * TSIZE * Terrarum.game.screenZoom) + (ix * TSIZE / 2 * Terrarum.game.screenZoom)
|
||||||
|
, Math.round(
|
||||||
|
y * TSIZE * Terrarum.game.screenZoom) + (iy * TSIZE / 2 * Terrarum.game.screenZoom)
|
||||||
|
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom / 2)
|
||||||
|
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom / 2)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Retro
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
int thisLightLevel = staticLightMap[y][x];
|
||||||
|
|
||||||
|
// coalesce identical intensity blocks to one
|
||||||
|
int sameLevelCounter = 1;
|
||||||
|
while (staticLightMap[y][x + sameLevelCounter] == thisLightLevel) {
|
||||||
|
sameLevelCounter += 1;
|
||||||
|
|
||||||
|
if (x + sameLevelCounter >= for_x_end) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
g.setColor(new Color(0));
|
g.setColor(toTargetColour(staticLightMap[y][x]));
|
||||||
g.fillRect(
|
g.fillRect(
|
||||||
Math.round(x * TSIZE * Terrarum.game.screenZoom)
|
Math.round(x * TSIZE * Terrarum.game.screenZoom)
|
||||||
, Math.round(y * TSIZE * Terrarum.game.screenZoom)
|
, Math.round(y * TSIZE * Terrarum.game.screenZoom)
|
||||||
, FastMath.ceil(
|
, FastMath.ceil(
|
||||||
TSIZE * Terrarum.game.screenZoom) * zeroLevelCounter
|
TSIZE * Terrarum.game.screenZoom) * sameLevelCounter
|
||||||
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom)
|
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom)
|
||||||
);
|
);
|
||||||
|
|
||||||
x += (zeroLevelCounter - 1);
|
x += (sameLevelCounter - 1);
|
||||||
}
|
}
|
||||||
catch (ArrayIndexOutOfBoundsException e) {
|
catch (ArrayIndexOutOfBoundsException e) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
/** a
|
|
||||||
* +-+-+
|
|
||||||
* |i|j|
|
|
||||||
* b +-+-+ c
|
|
||||||
* |k|l|
|
|
||||||
* +-+-+
|
|
||||||
* d
|
|
||||||
*/
|
|
||||||
char a = (y == 0) ? thisLightLevel
|
|
||||||
: (y == Terrarum.game.map.height - 1) ? thisLightLevel
|
|
||||||
: maximiseRGB(staticLightMap[y][x]
|
|
||||||
, staticLightMap[y - 1][x]);
|
|
||||||
char d = (y == 0) ? thisLightLevel
|
|
||||||
: (y == Terrarum.game.map.height - 1) ? thisLightLevel
|
|
||||||
: maximiseRGB(staticLightMap[y][x]
|
|
||||||
, staticLightMap[y + 1][x]);
|
|
||||||
char b = (x == 0) ? thisLightLevel
|
|
||||||
: (x == Terrarum.game.map.width - 1) ? thisLightLevel
|
|
||||||
: maximiseRGB(staticLightMap[y][x]
|
|
||||||
, staticLightMap[y][x - 1]);
|
|
||||||
char c = (x == 0) ? thisLightLevel
|
|
||||||
: (x == Terrarum.game.map.width - 1) ? thisLightLevel
|
|
||||||
: maximiseRGB(staticLightMap[y][x]
|
|
||||||
, staticLightMap[y][x + 1]);
|
|
||||||
char[] colourMapItoL = new char[4];
|
|
||||||
colourMapItoL[0] = colourLinearMix(a, b);
|
|
||||||
colourMapItoL[1] = colourLinearMix(a, c);
|
|
||||||
colourMapItoL[2] = colourLinearMix(b, d);
|
|
||||||
colourMapItoL[3] = colourLinearMix(c, d);
|
|
||||||
|
|
||||||
for (int iy = 0; iy < 2; iy++) {
|
|
||||||
for (int ix = 0; ix < 2; ix++) {
|
|
||||||
g.setColor(toTargetColour(colourMapItoL[iy * 2 + ix]));
|
|
||||||
|
|
||||||
g.fillRect(
|
|
||||||
Math.round(x * TSIZE * Terrarum.game.screenZoom) + (ix * TSIZE / 2 * Terrarum.game.screenZoom)
|
|
||||||
, Math.round(y * TSIZE * Terrarum.game.screenZoom) + (iy * TSIZE / 2 * Terrarum.game.screenZoom)
|
|
||||||
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom / 2)
|
|
||||||
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom / 2)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Retro
|
|
||||||
else {
|
|
||||||
try {
|
|
||||||
int thisLightLevel = staticLightMap[y][x];
|
|
||||||
|
|
||||||
// coalesce identical intensity blocks to one
|
|
||||||
int sameLevelCounter = 1;
|
|
||||||
while (staticLightMap[y][x + sameLevelCounter] == thisLightLevel) {
|
|
||||||
sameLevelCounter += 1;
|
|
||||||
|
|
||||||
if (x + sameLevelCounter >= for_x_end) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
g.setColor(toTargetColour(staticLightMap[y][x]));
|
|
||||||
g.fillRect(
|
|
||||||
Math.round(x * TSIZE * Terrarum.game.screenZoom)
|
|
||||||
, Math.round(y * TSIZE * Terrarum.game.screenZoom)
|
|
||||||
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom) * sameLevelCounter
|
|
||||||
, FastMath.ceil(TSIZE * Terrarum.game.screenZoom)
|
|
||||||
);
|
|
||||||
|
|
||||||
x += (sameLevelCounter - 1);
|
|
||||||
}
|
|
||||||
catch (ArrayIndexOutOfBoundsException e) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (ArrayIndexOutOfBoundsException e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Color toTargetColour(char raw) {
|
private static Color toTargetColour(char raw) {
|
||||||
@@ -561,10 +577,6 @@ public class LightmapRenderer {
|
|||||||
return (i < 0) ? 0 : (i > 1) ? 1 : i;
|
return (i < 0) ? 0 : (i > 1) ? 1 : i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static char[][] getStaticLightMap() {
|
|
||||||
return staticLightMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static char getValueFromMap(int x, int y) {
|
public static char getValueFromMap(int x, int y) {
|
||||||
return staticLightMap[y][x];
|
return staticLightMap[y][x];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user