Skip to content

Loading…

Some lighting changes #1891

Merged
merged 1 commit into from

2 participants

@bergerkiller

Signed-off-by: berger killer bergerkiller@gmail.com

One of the changes make sure that lighting you set is actually the right block, as the component-setting for the nibble previously failed.

@bergerkiller bergerkiller More lighting changes
Signed-off-by: berger killer <bergerkiller@gmail.com>
63f3eef
@Raphfrk Raphfrk merged commit 214b541 into SpoutDev:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 26, 2012
  1. @bergerkiller

    More lighting changes

    bergerkiller committed
    Signed-off-by: berger killer <bergerkiller@gmail.com>
This page is out of date. Refresh to see the latest.
View
38 src/main/java/org/spout/engine/world/SpoutChunk.java
@@ -259,18 +259,22 @@ public boolean setBlockLight(int x, int y, int z, byte light, Source source) {
if (source == null) {
throw new NullPointerException("Source can not be null");
}
- light &= 0xFF;
-
+ light &= 0xF;
+ x &= BASE_MASK;
+ y &= BASE_MASK;
+ z &= BASE_MASK;
+
checkChunkLoaded();
int index = getBlockIndex(x, y, z);
- byte old = blockLight[index / 2];
byte oldLight;
if ((index & 1) == 0) {
- oldLight = NibblePairHashed.key1(old);
- blockLight[index / 2] = NibblePairHashed.key(light, old);
+ index >>= 1;
+ oldLight = NibblePairHashed.key1(blockLight[index]);
+ blockLight[index] = NibblePairHashed.setKey1(blockLight[index], light);
} else {
- oldLight = NibblePairHashed.key2(old);
- blockLight[index / 2] = NibblePairHashed.key(old, light);
+ index >>= 1;
+ oldLight = NibblePairHashed.key2(blockLight[index]);
+ blockLight[index] = NibblePairHashed.setKey2(blockLight[index], light);
}
if (light > oldLight) {
//light increased
@@ -289,7 +293,7 @@ public boolean setBlockLight(int x, int y, int z, byte light, Source source) {
public byte getBlockLight(int x, int y, int z) {
checkChunkLoaded();
int index = getBlockIndex(x, y, z);
- byte light = blockLight[index / 2];
+ byte light = blockLight[index >> 1];
if ((index & 1) == 0) {
return NibblePairHashed.key1(light);
} else {
@@ -303,19 +307,23 @@ public boolean setBlockSkyLight(int x, int y, int z, byte light, Source source)
throw new NullPointerException("Source can not be null");
}
light &= 0xF;
+ x &= BASE_MASK;
+ y &= BASE_MASK;
+ z &= BASE_MASK;
checkChunkLoaded();
int index = getBlockIndex(x, y, z);
- byte old = skyLight[index / 2];
byte oldLight;
-
if ((index & 1) == 1) {
- oldLight = NibblePairHashed.key1(old);
- skyLight[index / 2] = NibblePairHashed.key(light, old);
+ index >>= 1;
+ oldLight = NibblePairHashed.key1(skyLight[index]);
+ skyLight[index] = NibblePairHashed.setKey1(skyLight[index], light);
} else {
- oldLight = NibblePairHashed.key2(old);
- skyLight[index / 2] = NibblePairHashed.key(old, light);
+ index >>= 1;
+ oldLight = NibblePairHashed.key2(skyLight[index]);
+ skyLight[index] = NibblePairHashed.setKey2(skyLight[index], light);
}
+
if (light > oldLight) {
//light increased
getWorld().getLightingManager().skyLightGreater.add(x + this.getBlockX(), y + this.getBlockY(), z + this.getBlockZ());
@@ -333,7 +341,7 @@ public boolean setBlockSkyLight(int x, int y, int z, byte light, Source source)
public byte getBlockSkyLight(int x, int y, int z) {
checkChunkLoaded();
int index = getBlockIndex(x, y, z);
- byte light = skyLight[index / 2];
+ byte light = skyLight[index >> 1];
if ((index & 1) == 1) {
return NibblePairHashed.key1(light);
} else {
View
6 src/main/java/org/spout/engine/world/SpoutWorldLighting.java
@@ -18,9 +18,9 @@
private TLongIterator iter; //temporary
public void add(int x, int y, int z) {
- synchronized (updates) {
- //updates.add(x, y, z);
- }
+ //synchronized (updates) {
+ // updates.add(x, y, z);
+ //}
}
public boolean transfer(TLongList list) {
Something went wrong with that request. Please try again.