mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-10 16:03:15 -04:00
Don't recreate block textures unless necessary, combine MakeEdgeTexture and MakeSideTexture into MakeTexture.
This commit is contained in:
parent
df4c6b4b32
commit
9e341c875e
@ -115,10 +115,6 @@ namespace ClassicalSharp {
|
|||||||
8, 86, 2, 4, 66, 69, 2, 8, 138,
|
8, 86, 2, 4, 66, 69, 2, 8, 138,
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Finish implementing CPE
|
|
||||||
// === CPE support list ===
|
|
||||||
// TextHotKey : unlikely
|
|
||||||
// ExtPlayerList : yes (only version 1, not 2)
|
|
||||||
static string[] clientExtensions = new string[] {
|
static string[] clientExtensions = new string[] {
|
||||||
"EmoteFix", "ClickDistance", "HeldBlock", "BlockPermissions",
|
"EmoteFix", "ClickDistance", "HeldBlock", "BlockPermissions",
|
||||||
"SelectionCuboid", "MessageTypes", "CustomBlocks", "EnvColors",
|
"SelectionCuboid", "MessageTypes", "CustomBlocks", "EnvColors",
|
||||||
|
@ -35,8 +35,8 @@ namespace ClassicalSharp {
|
|||||||
Window.TerrainAtlasChanged += ResetTextures;
|
Window.TerrainAtlasChanged += ResetTextures;
|
||||||
|
|
||||||
Graphics = Window.Graphics;
|
Graphics = Window.Graphics;
|
||||||
MakeEdgeTexture();
|
MakeTexture( ref edgeTexId, ref lastEdgeTexLoc, Map.EdgeBlock );
|
||||||
MakeSideTexture();
|
MakeTexture( ref sideTexId, ref lastSideTexLoc, Map.SidesBlock );
|
||||||
ResetSidesAndEdges( null, null );
|
ResetSidesAndEdges( null, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,8 +78,8 @@ namespace ClassicalSharp {
|
|||||||
Graphics.DeleteVb( sidesVboId );
|
Graphics.DeleteVb( sidesVboId );
|
||||||
Graphics.DeleteVb( edgesVboId );
|
Graphics.DeleteVb( edgesVboId );
|
||||||
sidesVboId = edgesVboId = -1;
|
sidesVboId = edgesVboId = -1;
|
||||||
MakeEdgeTexture();
|
MakeTexture( ref edgeTexId, ref lastEdgeTexLoc, Map.EdgeBlock );
|
||||||
MakeSideTexture();
|
MakeTexture( ref sideTexId, ref lastSideTexLoc, Map.SidesBlock );
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnNewMapLoaded( object sender, EventArgs e ) {
|
void OnNewMapLoaded( object sender, EventArgs e ) {
|
||||||
@ -89,17 +89,18 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
void EnvVariableChanged( object sender, EnvVariableEventArgs e ) {
|
void EnvVariableChanged( object sender, EnvVariableEventArgs e ) {
|
||||||
if( e.Variable == EnvVariable.EdgeBlock ) {
|
if( e.Variable == EnvVariable.EdgeBlock ) {
|
||||||
MakeEdgeTexture();
|
MakeTexture( ref edgeTexId, ref lastEdgeTexLoc, Map.EdgeBlock );
|
||||||
} else if( e.Variable == EnvVariable.SidesBlock ) {
|
} else if( e.Variable == EnvVariable.SidesBlock ) {
|
||||||
MakeSideTexture();
|
MakeTexture( ref sideTexId, ref lastSideTexLoc, Map.SidesBlock );
|
||||||
} else if( e.Variable == EnvVariable.WaterLevel ) {
|
} else if( e.Variable == EnvVariable.WaterLevel ) {
|
||||||
ResetSidesAndEdges( null, null );
|
ResetSidesAndEdges( null, null );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResetTextures( object sender, EventArgs e ) {
|
void ResetTextures( object sender, EventArgs e ) {
|
||||||
MakeEdgeTexture();
|
lastEdgeTexLoc = lastSideTexLoc = -1;
|
||||||
MakeSideTexture();
|
MakeTexture( ref edgeTexId, ref lastEdgeTexLoc, Map.EdgeBlock );
|
||||||
|
MakeTexture( ref sideTexId, ref lastSideTexLoc, Map.SidesBlock );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResetSidesAndEdges( object sender, EventArgs e ) {
|
void ResetSidesAndEdges( object sender, EventArgs e ) {
|
||||||
@ -256,17 +257,15 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
void MakeEdgeTexture() {
|
int lastEdgeTexLoc, lastSideTexLoc;
|
||||||
int texLoc = Window.BlockInfo.GetOptimTextureLoc( (byte)Map.EdgeBlock, TileSide.Top );
|
void MakeTexture( ref int texId, ref int lastTexLoc, Block block ) {
|
||||||
Window.Graphics.DeleteTexture( ref edgeTexId );
|
int texLoc = Window.BlockInfo.GetOptimTextureLoc( (byte)block, TileSide.Top );
|
||||||
edgeTexId = Window.TerrainAtlas.LoadTextureElement( texLoc );
|
if( texLoc != lastTexLoc ) {
|
||||||
}
|
lastTexLoc = texLoc;
|
||||||
|
Window.Graphics.DeleteTexture( ref texId );
|
||||||
void MakeSideTexture() {
|
texId = Window.TerrainAtlas.LoadTextureElement( texLoc );
|
||||||
int texLoc = Window.BlockInfo.GetOptimTextureLoc( (byte)Map.SidesBlock, TileSide.Top );
|
}
|
||||||
Window.Graphics.DeleteTexture( ref sideTexId );
|
}
|
||||||
sideTexId = Window.TerrainAtlas.LoadTextureElement( texLoc );
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawXPlane( int x, int z1, int z2, int y1, int y2, FastColour col, VertexPos3fTex2fCol4b[] vertices ) {
|
void DrawXPlane( int x, int z1, int z2, int y1, int y2, FastColour col, VertexPos3fTex2fCol4b[] vertices ) {
|
||||||
TextureRectangle rec = new TextureRectangle( 0, 0, z2 - z1, y2 - y1 );
|
TextureRectangle rec = new TextureRectangle( 0, 0, z2 - z1, y2 - y1 );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user