Skip to content

Commit

Permalink
optimizing generation + new title image
Browse files Browse the repository at this point in the history
  • Loading branch information
maxilevi committed Nov 12, 2017
1 parent 371722d commit c9aeded
Show file tree
Hide file tree
Showing 14 changed files with 208 additions and 194 deletions.
95 changes: 58 additions & 37 deletions Assets/Game.unity
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ MonoBehaviour:
ScoreCenter: {fileID: 1241284409}
Lost: 0
GameOver: {fileID: 1444885959}
Title: {fileID: 802837269}
Title: {fileID: 889690357}
RestartBtn: {fileID: 289241848}
StartBtn: {fileID: 787871392}
PlayerPrefab: {fileID: 1487220595160186, guid: de0cf47d47318e94483f1669ea325fe5,
Expand Down Expand Up @@ -593,7 +593,7 @@ RectTransform:
m_LocalPosition: {x: 347.5, y: 298.5, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 802837268}
- {fileID: 889690356}
- {fileID: 1328003669}
- {fileID: 1987698361}
- {fileID: 99839167}
Expand Down Expand Up @@ -683,80 +683,73 @@ CanvasRenderer:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 787871390}
--- !u!1 &802837267
--- !u!1 &889690355
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 802837268}
- component: {fileID: 802837270}
- component: {fileID: 802837269}
- component: {fileID: 889690356}
- component: {fileID: 889690358}
- component: {fileID: 889690357}
m_Layer: 0
m_Name: Title
m_Name: TitleImage
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &802837268
--- !u!224 &889690356
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 802837267}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 174, z: 0}
m_LocalScale: {x: 0.49999997, y: 0.5, z: 0.5}
m_GameObject: {fileID: 889690355}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 189, z: 0}
m_LocalScale: {x: 0.5, y: 0.5, z: 0.5}
m_Children: []
m_Father: {fileID: 747117607}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 174}
m_SizeDelta: {x: 697.8, y: 1085.5}
m_AnchoredPosition: {x: 0, y: 189}
m_SizeDelta: {x: 670, y: 67}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &802837269
--- !u!114 &889690357
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 802837267}
m_GameObject: {fileID: 889690355}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Script: {fileID: -98529514, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 12800000, guid: 04a842e316b6f44bf8da702de26a8ed6, type: 3}
m_FontSize: 45
m_FontStyle: 0
m_BestFit: 1
m_MinSize: 4
m_MaxSize: 300
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: NEON SKYLINES
--- !u!222 &802837270
m_Texture: {fileID: 2800000, guid: c32b5e23bb054254f9d1a8637f36aac3, type: 3}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
--- !u!222 &889690358
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 802837267}
m_GameObject: {fileID: 889690355}
--- !u!1 &1036811556
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -845,7 +838,7 @@ AudioSource:
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: 649e4aa8ec6dc36409789a1a233bc387, type: 3}
m_PlayOnAwake: 1
m_PlayOnAwake: 0
m_Volume: 0.605
m_Pitch: 1
Loop: 1
Expand Down Expand Up @@ -1059,7 +1052,7 @@ ParticleSystem:
moveWithTransform: 0
moveWithCustomTransform: {fileID: 0}
scalingMode: 1
randomSeed: 1480670832
randomSeed: -1789946895
InitialModule:
serializedVersion: 3
enabled: 1
Expand Down Expand Up @@ -4656,6 +4649,34 @@ CanvasRenderer:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1328003668}
--- !u!1 &1329095920
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1329095921}
m_Layer: 0
m_Name: Debris
m_TagString: Debris
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1329095921
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1329095920}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1444885957
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -4777,7 +4798,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Color: {r: 1, g: 1, b: 1, a: 0}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
Expand Down
2 changes: 1 addition & 1 deletion Assets/Generation/Chunk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void Build()
_mesh.SetNormals (BlockData.Normals);
_mesh.SetColors (BlockData.Colors);
_mesh.SetIndices (BlockData.Indices.ToArray (), MeshTopology.Triangles, 0);
this.GetComponent<MeshCollider> ().sharedMesh = _mesh;
//this.GetComponent<MeshCollider> ().sharedMesh = _mesh;
});
}

Expand Down
24 changes: 12 additions & 12 deletions Assets/Generation/ChunkLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ private IEnumerator LoadChunks()

if(Stop) break;

if (!Enabled || World.Discard)

if (!Enabled)
goto SLEEP;

Offset = World.ToChunkSpace(_playerPosition);
Expand All @@ -92,25 +93,26 @@ private IEnumerator LoadChunks()

if (Offset != _lastOffset)
{

for (int _x = -GraphicsOptions.ChunkLoaderRadius / 2; _x < GraphicsOptions.ChunkLoaderRadius / 2; _x++)
{
for (int _z = -GraphicsOptions.ChunkLoaderRadius / 2; _z < GraphicsOptions.ChunkLoaderRadius / 2; _z++)
{
for (int _y = -2; _y < 2; _y++)
for (int _y = -4; _y < 4; _y++)
{
int x = _x, y = _y ,z = _z;

if (World.GetChunkByOffset(Offset + Vector3.Scale(new Vector3(x, y, z), new Vector3(Chunk.ChunkSize, Chunk.ChunkSize, Chunk.ChunkSize)) ) == null)
{

Vector3 chunkPos = Offset + Vector3.Scale(new Vector3(x, y, z), new Vector3(Chunk.ChunkSize, Chunk.ChunkSize, Chunk.ChunkSize));
GameObject NewChunk = new GameObject("Chunk "+ (chunkPos.x) + " "+ (chunkPos.y) + " "+ (chunkPos.z) );
NewChunk.transform.position = chunkPos;
NewChunk.transform.SetParent(World.gameObject.transform);
NewChunk.AddComponent<MeshFilter>();
NewChunk.AddComponent<MeshRenderer>();
NewChunk.AddComponent<MeshCollider> ();
MeshRenderer Renderer = NewChunk.AddComponent<MeshRenderer>();
Renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
Renderer.receiveShadows = false;
Chunk chunk = NewChunk.AddComponent<Chunk>();
chunk.Init(chunkPos, World);
World.AddChunk(chunkPos, chunk);
Expand Down Expand Up @@ -144,10 +146,10 @@ private IEnumerator ManageChunksMesh()
Chunks = World.Chunks.Values.ToList().ToArray();
}
yield return null;
_left += 0.25f;
//_left += 0.25f;

if (_left >= 1.5f)
{
//if (_left >= 1.5f)
//{
_activeChunks = 0;
for (int i = Chunks.Length - 1; i > -1; i--)
{
Expand Down Expand Up @@ -185,14 +187,12 @@ private IEnumerator ManageChunksMesh()

if (Chunks[i] != null && Chunks[i].IsGenerated && !World.ContainsMeshQueue(Chunks[i]) && Chunks[i].ShouldBuild)
{
yield return null;

World.AddToQueue(Chunks[i], true);
}

}
_left = 0f;
}
// _left = 0f;
//}
if (_activeChunks != _prevChunkCount)
{
_prevChunkCount = _activeChunks;
Expand Down
Binary file modified Assets/Generation/GenerationQueue.cs
Binary file not shown.
61 changes: 0 additions & 61 deletions Assets/Generation/GenerationThread.cs

This file was deleted.

13 changes: 0 additions & 13 deletions Assets/Generation/GenerationThread.cs.meta

This file was deleted.

Loading

0 comments on commit c9aeded

Please sign in to comment.