mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 03:25:14 -04:00
Minor performance optimisations.
This commit is contained in:
parent
b673944a61
commit
69a8d761bf
13
Map.cs
13
Map.cs
@ -93,25 +93,22 @@ namespace ClassicalSharp {
|
||||
|
||||
public int GetLightHeight( int x, int z ) {
|
||||
int index = ( x * Length ) + z;
|
||||
int height = heightmap[index];
|
||||
|
||||
if( height == short.MaxValue ) {
|
||||
height = CalcHeightAt( x, maxY, z, index );
|
||||
}
|
||||
return height;
|
||||
int height = heightmap[index];
|
||||
return height == short.MaxValue ? CalcHeightAt( x, maxY, z, index ) : height;
|
||||
}
|
||||
|
||||
int CalcHeightAt( int x, int maxY, int z, int index ) {
|
||||
heightmap[index] = -1;
|
||||
int mapIndex = ( maxY * Length + z ) * Width + x;
|
||||
for( int y = maxY; y >= 0; y-- ) {
|
||||
byte block = GetBlock( mapIndex );
|
||||
byte block = mapData[mapIndex];
|
||||
if( Window.BlockInfo.BlocksLight( block ) ) {
|
||||
heightmap[index] = (short)y;
|
||||
return y;
|
||||
}
|
||||
mapIndex -= oneY;
|
||||
}
|
||||
|
||||
heightmap[index] = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -102,15 +102,13 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
int GetLightHeight( int x, int z ) {
|
||||
int y = map.GetLightHeight( x, z );
|
||||
if( y == -1 ) return -1;
|
||||
return y;
|
||||
return map.GetLightHeight( x, z );
|
||||
}
|
||||
|
||||
int GetLightHeightAdj( int x, int z ) {
|
||||
int y = map.GetLightHeight( x, z );
|
||||
if( y == -1 ) return -1;
|
||||
return BlockInfo.BlockHeight( map.GetBlock( x, y, z ) ) == 1 ? y : y - 1;
|
||||
return y == -1 ? -1 :
|
||||
( BlockInfo.BlockHeight( map.GetBlock( x, y, z ) ) == 1 ? y : y - 1 );
|
||||
}
|
||||
|
||||
protected override ChunkDrawInfo GetChunkInfo( int x, int y, int z ) {
|
||||
|
@ -3,13 +3,10 @@ using ClassicalSharp.GraphicsAPI;
|
||||
using OpenTK;
|
||||
|
||||
namespace ClassicalSharp {
|
||||
|
||||
|
||||
|
||||
// TODO: optimise chunk rendering
|
||||
// --> reduce the two passes: liquid pass only needs 1 small texture
|
||||
// |--> divide into 'solid', 'transparent', 'translucent passes'
|
||||
// |--> don't render solid back facing polygons. may help with low performance computers.
|
||||
// |--> use indices.
|
||||
// --> use indices.
|
||||
public class MapRenderer : IDisposable {
|
||||
|
||||
struct Point3S {
|
||||
|
Loading…
x
Reference in New Issue
Block a user