Skip to content

Commit

Permalink
改正小错误,更新README
Browse files Browse the repository at this point in the history
  • Loading branch information
Lixue9jiu committed Mar 16, 2018
1 parent a65ca4f commit 51aa0ac
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 41 deletions.
Binary file modified Assets/_Scenes/MainManu.unity
Binary file not shown.
77 changes: 41 additions & 36 deletions Assets/_Scripts/Core/TerrainManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,52 +39,57 @@ void Start()

void StartChunkUpdateThread()
{
thread = new Thread(new ThreadStart(delegate
thread = new Thread(new ThreadStart(ChunkUpdateWork));
thread.Priority = System.Threading.ThreadPriority.Lowest;
thread.Start();
}

void ChunkUpdateWork()
{
while (threadRunning)
{
while (threadRunning)
Stopwatch.Reset();
Stopwatch.Start();
if (chunkQueue.TerrainCount != 0)
{
Stopwatch.Reset();
Stopwatch.Start();
if (chunkQueue.TerrainCount != 0)
int count = chunkQueue.TerrainCount;
for (int i = 0; i < count; i++)
{
int count = chunkQueue.TerrainCount;
for (int i = 0; i < count; i++)
int index = chunkQueue.PopTerrain();
BlockTerrain.Chunk chunk = Terrain.GetChunk(index);
if (chunk == null)
continue;
lock (chunk)
{
int index = chunkQueue.PopTerrain();
BlockTerrain.Chunk chunk = Terrain.GetChunk(index);
lock (chunk)
switch (Terrain.chunkStats.Get(index).state)
{
switch (Terrain.chunkStats.Get(index).state)
{
case 3:
terrainGenerator.MeshFromChunk(chunk, out chunk.mesh[0]);
terrainGenerator.MeshFromTransparent(chunk, out chunk.mesh[2]);
break;
case 1:
terrainGenerator.MeshFromChunk(chunk, out chunk.mesh[0]);
break;
case 2:
terrainGenerator.MeshFromTransparent(chunk, out chunk.mesh[2]);
break;
}
case 3:
terrainGenerator.MeshFromChunk(chunk, out chunk.mesh[0]);
terrainGenerator.MeshFromTransparent(chunk, out chunk.mesh[2]);
break;
case 1:
terrainGenerator.MeshFromChunk(chunk, out chunk.mesh[0]);
break;
case 2:
terrainGenerator.MeshFromTransparent(chunk, out chunk.mesh[2]);
break;
}
chunkQueue.AddMain(index);
}
chunkQueue.AddMain(index);
}
if (needTerrainUpdate)
{
UpdateTerrain(centerChunk.X, centerChunk.Y);
}
if (needTerrainUpdate)
{
UpdateTerrain(centerChunk.X, centerChunk.Y);

needTerrainUpdate = false;
}
if (Stopwatch.ElapsedMilliseconds < updateMili)
{
Thread.Sleep(updateMili - (int)Stopwatch.ElapsedMilliseconds);
}
needTerrainUpdate = false;
}
Debug.Log("chunk loading thread closed");
}));
thread.Start();
if (Stopwatch.ElapsedMilliseconds < updateMili)
{
Thread.Sleep(updateMili - (int)Stopwatch.ElapsedMilliseconds);
}
}
Debug.Log("chunk loading thread closed");
}

void OnDisable()
Expand Down
5 changes: 2 additions & 3 deletions Assets/_Scripts/FPSDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ public class FPSDisplay : MonoBehaviour
void Update()
{
deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f;

}

void OnGUI()
Expand All @@ -24,12 +23,12 @@ void OnGUI()
style.normal.textColor = new Color (1.0f, 1.0f, 1.0f, 1.0f);
float msec = deltaTime * 1000.0f;
float fps = 1.0f / deltaTime;
string text = string.Format("{0:0.0} ms ({1:0.} fps)\ncurrent chunk: {2}\n按ESC键暂停", msec, fps, TerrainManager.CurrentChunk ());
string text = string.Format("{0:0.0} ms ({1:0.} fps)\ncurrent chunk: {2}\n按ESC键暂停\n按P键截图", msec, fps, TerrainManager.CurrentChunk ());
TerrainRaycast.RaycastResult? r = GetComponent<TerrainRaycast> ().LookingAt;
if (r.HasValue) {
//text += string.Format ("\nlooking at {0}", BlocksData.GetBlock(BlockTerrain.GetContent(r.Value.BlockValue)).Name);
text += string.Format("\nlooking at {0}", BlockTerrain.GetContent(r.Value.BlockValue));
}
GUI.Label (rect, text, style);
}
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Fancy SurvivalCraft Editor, inspired by [SCFE-Unity](https://github.com/khohryak
* ~English support~
* ~Multi-thread chunk loading~
* ~Load Project.xml~
* Setting panel
* ~Setting panel~
* Create a selection of blocks
* Fill a selection with certain block
* Save and Load selections
Expand Down
2 changes: 1 addition & 1 deletion README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Fancy SurvivalCraft Editor,可以翻译成“很棒的生存战争存档编辑
* ~英文版~
* ~多线程区块加载~
* ~加载Project.xml~
* 设置界面
* ~设置界面~
* 创建选区
* 填充选区
* 保存,导入选区
Expand Down

0 comments on commit 51aa0ac

Please sign in to comment.