mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 18:15:28 -04:00
Treat pixel as solid if its alpha is not 0 when calculating sprite bounds, don't redraw CPE player list names unless necessary.
This commit is contained in:
parent
30a70638e1
commit
17d54a09d5
@ -42,12 +42,13 @@ namespace ClassicalSharp {
|
|||||||
+ new Vector3( 0.5f, 0, 0.5f );
|
+ new Vector3( 0.5f, 0, 0.5f );
|
||||||
}
|
}
|
||||||
|
|
||||||
const int alphaTest = unchecked( (int)0x80000000 );
|
const int alphaTest = unchecked( (int)0xFF000000 );
|
||||||
unsafe float GetSpriteBB_TopY( int size, int tileX, int tileY, FastBitmap fastBmp ) {
|
unsafe float GetSpriteBB_TopY( int size, int tileX, int tileY, FastBitmap fastBmp ) {
|
||||||
for( int y = 0; y < size; y++ ) {
|
for( int y = 0; y < size; y++ ) {
|
||||||
int* row = fastBmp.GetRowPtr( tileY * size + y ) + (tileX * size);
|
int* row = fastBmp.GetRowPtr( tileY * size + y ) + (tileX * size);
|
||||||
for( int x = 0; x < size; x++ ) {
|
for( int x = 0; x < size; x++ ) {
|
||||||
if( (row[x] & alphaTest) != 0 )
|
byte alpha = (byte)((row[x] & alphaTest) >> 24);
|
||||||
|
if( alpha != 0 )
|
||||||
return 1 - (float)y / size;
|
return 1 - (float)y / size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,7 +59,8 @@ namespace ClassicalSharp {
|
|||||||
for( int y = size - 1; y >= 0; y-- ) {
|
for( int y = size - 1; y >= 0; y-- ) {
|
||||||
int* row = fastBmp.GetRowPtr( tileY * size + y ) + (tileX * size);
|
int* row = fastBmp.GetRowPtr( tileY * size + y ) + (tileX * size);
|
||||||
for( int x = 0; x < size; x++ ) {
|
for( int x = 0; x < size; x++ ) {
|
||||||
if( (row[x] & alphaTest) != 0 )
|
byte alpha = (byte)((row[x] & alphaTest) >> 24);
|
||||||
|
if( alpha != 0 )
|
||||||
return 1 - (float)(y + 1) / size;
|
return 1 - (float)(y + 1) / size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -69,7 +71,8 @@ namespace ClassicalSharp {
|
|||||||
for( int x = 0; x < size; x++ ) {
|
for( int x = 0; x < size; x++ ) {
|
||||||
for( int y = 0; y < size; y++ ) {
|
for( int y = 0; y < size; y++ ) {
|
||||||
int* row = fastBmp.GetRowPtr( tileY * size + y ) + (tileX * size);
|
int* row = fastBmp.GetRowPtr( tileY * size + y ) + (tileX * size);
|
||||||
if( (row[x] & alphaTest) != 0 )
|
byte alpha = (byte)((row[x] & alphaTest) >> 24);
|
||||||
|
if( alpha != 0 )
|
||||||
return (float)x / size;
|
return (float)x / size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,7 +83,8 @@ namespace ClassicalSharp {
|
|||||||
for( int x = size - 1; x >= 0; x-- ) {
|
for( int x = size - 1; x >= 0; x-- ) {
|
||||||
for( int y = 0; y < size; y++ ) {
|
for( int y = 0; y < size; y++ ) {
|
||||||
int* row = fastBmp.GetRowPtr( tileY * size + y ) + (tileX * size);
|
int* row = fastBmp.GetRowPtr( tileY * size + y ) + (tileX * size);
|
||||||
if( (row[x] & alphaTest) != 0 )
|
byte alpha = (byte)((row[x] & alphaTest) >> 24);
|
||||||
|
if( alpha != 0 )
|
||||||
return (float)(x + 1) / size;
|
return (float)(x + 1) / size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,11 @@ namespace ClassicalSharp {
|
|||||||
game.CpePlayersList[nameId] = info;
|
game.CpePlayersList[nameId] = info;
|
||||||
|
|
||||||
if( oldInfo != null ) {
|
if( oldInfo != null ) {
|
||||||
game.Events.RaiseCpeListInfoChanged( (byte)nameId );
|
// Only redraw the CPE player list info if something changed.
|
||||||
|
if( info.PlayerName != oldInfo.PlayerName || info.ListName != oldInfo.ListName ||
|
||||||
|
info.GroupName != oldInfo.GroupName || info.GroupRank != oldInfo.GroupRank ) {
|
||||||
|
game.Events.RaiseCpeListInfoChanged( (byte)nameId );
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
game.Events.RaiseCpeListInfoAdded( (byte)nameId );
|
game.Events.RaiseCpeListInfoAdded( (byte)nameId );
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<ProjectGuid>{3E84ACC1-27B4-401B-A359-6AAE4DF6C9B5}</ProjectGuid>
|
<ProjectGuid>{3E84ACC1-27B4-401B-A359-6AAE4DF6C9B5}</ProjectGuid>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<RootNamespace>Launcher2</RootNamespace>
|
<RootNamespace>Launcher2</RootNamespace>
|
||||||
<AssemblyName>Launcher2</AssemblyName>
|
<AssemblyName>Launcher2</AssemblyName>
|
||||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user