Skip to content

Commit

Permalink
Merge pull request #4 from kazimuth/meshopt
Browse files Browse the repository at this point in the history
Use dirty flag for mesh visibility
  • Loading branch information
RosaryMala committed Mar 22, 2015
2 parents 596fea3 + 5b77939 commit 1193ba7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Assets/MapGen/GameMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class GameMap : MonoBehaviour
public int posX = 0;
public int posY = 0;
public int posZ = 0;
public bool posZDirty = true; // Set in GetViewInfo if z changes, and reset in HideMeshes after meshes hidden.
public int map_x;
public int map_y;
public Text genStatus;
Expand Down Expand Up @@ -863,7 +864,15 @@ void GetUnitList()
}
void GetViewInfo()
{
connectionState.ViewInfoCall.execute(null, out connectionState.net_view_info);
if (connectionState.net_view_info == null) {
connectionState.ViewInfoCall.execute (null, out connectionState.net_view_info);
} else {
int oldZ = connectionState.net_view_info.view_pos_z;
connectionState.ViewInfoCall.execute (null, out connectionState.net_view_info);
if (oldZ != connectionState.net_view_info.view_pos_z) {
posZDirty = true;
}
}
}

void PositionCamera()
Expand Down Expand Up @@ -915,6 +924,8 @@ void ClearMap()

void HideMeshes()
{
if (!posZDirty) return;
posZDirty = false;
for (int zz = 0; zz < blocks.GetLength(2); zz++)
for (int yy = 0; yy < blocks.GetLength(1); yy++)
for (int xx = 0; xx < blocks.GetLength(0); xx++)
Expand Down

0 comments on commit 1193ba7

Please sign in to comment.