forked from mirrors/NBTExplorer
Bugfixes and more relighting control
This commit is contained in:
parent
6fa2538130
commit
0657cf5bd3
7 changed files with 48 additions and 25 deletions
|
@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Skyscraper", "Skyscraper\Sk
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Relight", "Relight\Relight.csproj", "{EBDD447B-01FA-4A29-B4AB-380EC4379B5F}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Relight", "Relight\Relight.csproj", "{EBDD447B-01FA-4A29-B4AB-380EC4379B5F}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Maze", "Maze\Maze.csproj", "{62D70576-FE3A-4530-B283-889C14B52E9E}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -49,6 +51,10 @@ Global
|
||||||
{EBDD447B-01FA-4A29-B4AB-380EC4379B5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{EBDD447B-01FA-4A29-B4AB-380EC4379B5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{EBDD447B-01FA-4A29-B4AB-380EC4379B5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{EBDD447B-01FA-4A29-B4AB-380EC4379B5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{EBDD447B-01FA-4A29-B4AB-380EC4379B5F}.Release|Any CPU.Build.0 = Release|Any CPU
|
{EBDD447B-01FA-4A29-B4AB-380EC4379B5F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{62D70576-FE3A-4530-B283-889C14B52E9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{62D70576-FE3A-4530-B283-889C14B52E9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{62D70576-FE3A-4530-B283-889C14B52E9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{62D70576-FE3A-4530-B283-889C14B52E9E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace Substrate
|
||||||
|
|
||||||
protected ChunkRef _cache;
|
protected ChunkRef _cache;
|
||||||
|
|
||||||
private bool _autoLight;
|
private bool _autoLight = true;
|
||||||
|
|
||||||
public bool AutoRecalcLight
|
public bool AutoRecalcLight
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,8 +18,8 @@ namespace Substrate
|
||||||
new NBTArrayNode("SkyLight", 16384),
|
new NBTArrayNode("SkyLight", 16384),
|
||||||
new NBTArrayNode("BlockLight", 16384),
|
new NBTArrayNode("BlockLight", 16384),
|
||||||
new NBTArrayNode("HeightMap", 256),
|
new NBTArrayNode("HeightMap", 256),
|
||||||
new NBTListNode("Entities", TagType.TAG_COMPOUND),
|
new NBTListNode("Entities", TagType.TAG_COMPOUND, 0, NBTOptions.CREATE_ON_MISSING),
|
||||||
new NBTListNode("TileEntities", TagType.TAG_COMPOUND, TileEntity.BaseSchema),
|
new NBTListNode("TileEntities", TagType.TAG_COMPOUND, TileEntity.BaseSchema, NBTOptions.CREATE_ON_MISSING),
|
||||||
new NBTScalerNode("LastUpdate", TagType.TAG_LONG, NBTOptions.CREATE_ON_MISSING),
|
new NBTScalerNode("LastUpdate", TagType.TAG_LONG, NBTOptions.CREATE_ON_MISSING),
|
||||||
new NBTScalerNode("xPos", TagType.TAG_INT),
|
new NBTScalerNode("xPos", TagType.TAG_INT),
|
||||||
new NBTScalerNode("zPos", TagType.TAG_INT),
|
new NBTScalerNode("zPos", TagType.TAG_INT),
|
||||||
|
@ -633,7 +633,8 @@ namespace Substrate
|
||||||
|
|
||||||
public bool ValidateTree (TagValue tree)
|
public bool ValidateTree (TagValue tree)
|
||||||
{
|
{
|
||||||
return new NBTVerifier(tree, LevelSchema).Verify();
|
NBTVerifier v = new NBTVerifier(tree, LevelSchema);
|
||||||
|
return v.Verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -736,30 +737,12 @@ namespace Substrate
|
||||||
|
|
||||||
public void ResetBlockLight ()
|
public void ResetBlockLight ()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _blocks.Length; i++) {
|
_blockLight.Clear();
|
||||||
//BlockInfo info = BlockInfo.BlockTable[_blocks[i]];
|
|
||||||
_blockLight[i] = 0; // Math.Max(info.Luminance - info.Opacity, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetSkyLight ()
|
public void ResetSkyLight ()
|
||||||
{
|
{
|
||||||
for (int x = 0; x < XDim; x++) {
|
_skyLight.Clear();
|
||||||
for (int z = 0; z < ZDim; z++) {
|
|
||||||
int height = GetHeight(x, z);
|
|
||||||
int ystride = x << 11 | z << 7;
|
|
||||||
for (int y = 0; y < YDim; y++ ) {
|
|
||||||
int index = ystride + y;
|
|
||||||
|
|
||||||
if (y >= height) {
|
|
||||||
_skyLight[index] = BlockInfo.MIN_LUMINANCE;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_skyLight[index] = BlockInfo.MIN_LUMINANCE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int Timestamp ()
|
private int Timestamp ()
|
||||||
|
|
|
@ -179,6 +179,31 @@ namespace Substrate
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RelightDirtyChunks ()
|
||||||
|
{
|
||||||
|
List<ChunkRef> dirty = new List<ChunkRef>();
|
||||||
|
|
||||||
|
IEnumerator<ChunkRef> en = _cache.GetDirtyEnumerator();
|
||||||
|
while (en.MoveNext()) {
|
||||||
|
dirty.Add(en.Current);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (ChunkRef chunk in dirty) {
|
||||||
|
chunk.ResetBlockLight();
|
||||||
|
chunk.ResetSkyLight();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (ChunkRef chunk in dirty) {
|
||||||
|
chunk.RebuildBlockLight();
|
||||||
|
chunk.RebuildSkyLight();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (ChunkRef chunk in dirty) {
|
||||||
|
chunk.UpdateEdgeBlockLight();
|
||||||
|
chunk.UpdateEdgeSkyLight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public RegionManager GetRegionManager ()
|
public RegionManager GetRegionManager ()
|
||||||
{
|
{
|
||||||
return _regionMan;
|
return _regionMan;
|
||||||
|
|
|
@ -775,12 +775,14 @@ namespace Substrate
|
||||||
|
|
||||||
public void UpdateEdgeBlockLight ()
|
public void UpdateEdgeBlockLight ()
|
||||||
{
|
{
|
||||||
|
GetChunk();
|
||||||
QueueChunkEdges();
|
QueueChunkEdges();
|
||||||
UpdateBlockLight();
|
UpdateBlockLight();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateEdgeSkyLight ()
|
public void UpdateEdgeSkyLight ()
|
||||||
{
|
{
|
||||||
|
GetChunk();
|
||||||
QueueChunkEdges();
|
QueueChunkEdges();
|
||||||
UpdateSkyLight();
|
UpdateSkyLight();
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,7 @@ namespace Substrate.NBT
|
||||||
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
if ((node.Options & NBTOptions.CREATE_ON_MISSING) == NBTOptions.CREATE_ON_MISSING) {
|
if ((node.Options & NBTOptions.CREATE_ON_MISSING) == NBTOptions.CREATE_ON_MISSING) {
|
||||||
_scratch[node.Name] = schema.BuildDefaultTree();
|
_scratch[node.Name] = node.BuildDefaultTree();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if ((node.Options & NBTOptions.OPTIONAL) == NBTOptions.OPTIONAL) {
|
else if ((node.Options & NBTOptions.OPTIONAL) == NBTOptions.OPTIONAL) {
|
||||||
|
|
|
@ -47,6 +47,13 @@ namespace Substrate.Utility
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Clear ()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _data.Length; i++) {
|
||||||
|
_data[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region ICopyable<NibbleArray> Members
|
#region ICopyable<NibbleArray> Members
|
||||||
|
|
||||||
public NibbleArray Copy ()
|
public NibbleArray Copy ()
|
||||||
|
|
Loading…
Reference in a new issue