Skip to content

Commit

Permalink
add voxel debug
Browse files Browse the repository at this point in the history
  • Loading branch information
tomba committed Mar 11, 2016
1 parent e834d34 commit ef9de49
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Client/MapControl3D/DebugWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,9 @@
</UniformGrid>
</GroupBox>

<GroupBox Header="Voxel">
<TextBox Text="{Binding VoxelData, Mode=OneWay}" IsReadOnly="True" />
</GroupBox>

</StackPanel>
</Window>
21 changes: 20 additions & 1 deletion Client/MapControl3D/DebugWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal void SetGame(MyGame game)

m_timer = new DispatcherTimer();
m_timer.Tick += m_data.Update;
m_timer.Interval = TimeSpan.FromSeconds(1);
m_timer.Interval = TimeSpan.FromSeconds(0.25);
m_timer.IsEnabled = true;

var m_scene = m_game.TerrainRenderer;
Expand Down Expand Up @@ -173,6 +173,25 @@ public int ViewY2
set { m_game.ViewGridProvider.ViewCorner2 = m_game.ViewGridProvider.ViewCorner2.SetY(value); }
}

public string VoxelData
{
get
{
var mln = m_game.MousePositionService.MapLocation;

if (mln.HasValue)
{
var ml = mln.Value;

return m_game.TerrainRenderer.ChunkManager.GetChunkDebug(ml);
}
else
{
return "";
}
}
}

public event PropertyChangedEventHandler PropertyChanged;

public void Update(object sender, EventArgs e)
Expand Down
10 changes: 10 additions & 0 deletions Client/MapControl3D/VoxelTerrain/Chunk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ public Chunk(EnvironmentObject map, IntVector3 chunkPosition)
public bool IsAllEmpty { get; private set; } // XXX public for OutlineRenderer
public bool IsAllUndefined { get; private set; } // XXX public for OutlineRenderer

public string GetVoxelDebug(IntVector3 mp)
{
if (m_voxelMap == null)
return "no voxelmap";

var voxel = m_voxelMap.GetVoxel(mp - this.ChunkOffset);

return string.Format("{0}: visible {1}", mp, voxel.VisibleFaces);
}

void ScanForAllEmptyOrUndefined()
{
m_scanned = true;
Expand Down
7 changes: 7 additions & 0 deletions Client/MapControl3D/VoxelTerrain/ChunkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ public string ChunkCountDebug
}
}

public string GetChunkDebug(IntVector3 mp)
{
var cp = mp / Chunk.CHUNK_SIZE;
var chunk = GetChunk(cp);
return chunk.GetVoxelDebug(mp);
}

TerrainRenderer m_scene;

public int VerticesRendered { get; private set; }
Expand Down

0 comments on commit ef9de49

Please sign in to comment.