Process only animated tiles
Trying to make copies of static tiles and animating them has bad results on some GLES devices
This commit is contained in:
		
							parent
							
								
									bcdd187f69
								
							
						
					
					
						commit
						0f4de4b5f7
					
				
					 4 changed files with 52 additions and 14 deletions
				
			
		| 
						 | 
				
			
			@ -520,6 +520,13 @@ TilemapShader::TilemapShader()
 | 
			
		|||
	ShaderBase::init();
 | 
			
		||||
 | 
			
		||||
	GET_U(aniIndex);
 | 
			
		||||
	GET_U(t1Ani);
 | 
			
		||||
	GET_U(t2Ani);
 | 
			
		||||
	GET_U(t3Ani);
 | 
			
		||||
	GET_U(t4Ani);
 | 
			
		||||
	GET_U(t5Ani);
 | 
			
		||||
	GET_U(t6Ani);
 | 
			
		||||
	GET_U(t7Ani);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TilemapShader::setAniIndex(int value)
 | 
			
		||||
| 
						 | 
				
			
			@ -527,6 +534,16 @@ void TilemapShader::setAniIndex(int value)
 | 
			
		|||
	gl.Uniform1f(u_aniIndex, value);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TilemapShader::setAniIndices(int value[])
 | 
			
		||||
{
 | 
			
		||||
	gl.Uniform1f(u_t1Ani, value[0]);
 | 
			
		||||
	gl.Uniform1f(u_t2Ani, value[1]);
 | 
			
		||||
	gl.Uniform1f(u_t3Ani, value[2]);
 | 
			
		||||
	gl.Uniform1f(u_t4Ani, value[3]);
 | 
			
		||||
	gl.Uniform1f(u_t5Ani, value[4]);
 | 
			
		||||
	gl.Uniform1f(u_t6Ani, value[5]);
 | 
			
		||||
	gl.Uniform1f(u_t7Ani, value[6]);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
FlashMapShader::FlashMapShader()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -219,9 +219,17 @@ public:
 | 
			
		|||
	TilemapShader();
 | 
			
		||||
 | 
			
		||||
	void setAniIndex(int value);
 | 
			
		||||
	void setAniIndices(int value[]);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	GLint u_aniIndex;
 | 
			
		||||
	GLint u_t1Ani;
 | 
			
		||||
	GLint u_t2Ani;
 | 
			
		||||
	GLint u_t3Ani;
 | 
			
		||||
	GLint u_t4Ani;
 | 
			
		||||
	GLint u_t5Ani;
 | 
			
		||||
	GLint u_t6Ani;
 | 
			
		||||
	GLint u_t7Ani;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class FlashMapShader : public ShaderBase
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -281,6 +281,7 @@ struct TilemapPrivate
 | 
			
		|||
		/* Animation state */
 | 
			
		||||
		uint8_t frameIdx;
 | 
			
		||||
		uint8_t aniIdx;
 | 
			
		||||
		int aniIndices[7];
 | 
			
		||||
	} tiles;
 | 
			
		||||
 | 
			
		||||
	FlashMap flashMap;
 | 
			
		||||
| 
						 | 
				
			
			@ -432,8 +433,12 @@ struct TilemapPrivate
 | 
			
		|||
 | 
			
		||||
			usableATs.push_back(i);
 | 
			
		||||
 | 
			
		||||
			if (autotiles[i]->width() > autotileW)
 | 
			
		||||
			if (autotiles[i]->width() > autotileW) {
 | 
			
		||||
				animatedATs.push_back(i);
 | 
			
		||||
				tiles.aniIndices[i] = 2;
 | 
			
		||||
			} else {
 | 
			
		||||
				tiles.aniIndices[i] = 0;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		tiles.animated = !animatedATs.empty();
 | 
			
		||||
| 
						 | 
				
			
			@ -514,19 +519,8 @@ struct TilemapPrivate
 | 
			
		|||
 | 
			
		||||
			GLMeta::blitSource(autotile->getGLTypes());
 | 
			
		||||
 | 
			
		||||
			if (blitW <= autotileW && tiles.animated)
 | 
			
		||||
			{
 | 
			
		||||
				/* Static autotile */
 | 
			
		||||
				for (int j = 0; j < 4; ++j)
 | 
			
		||||
					GLMeta::blitRectangle(IntRect(0, 0, blitW, blitH),
 | 
			
		||||
					                      Vec2i(autotileW*j, atInd*autotileH));
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				/* Animated autotile */
 | 
			
		||||
				GLMeta::blitRectangle(IntRect(0, 0, blitW, blitH),
 | 
			
		||||
				                      Vec2i(0, atInd*autotileH));
 | 
			
		||||
			}
 | 
			
		||||
			GLMeta::blitRectangle(IntRect(0, 0, blitW, blitH),
 | 
			
		||||
			                      Vec2i(0, atInd*autotileH));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		GLMeta::blitEnd();
 | 
			
		||||
| 
						 | 
				
			
			@ -771,6 +765,7 @@ struct TilemapPrivate
 | 
			
		|||
			TilemapShader &tilemapShader = shState->shaders().tilemap;
 | 
			
		||||
			tilemapShader.bind();
 | 
			
		||||
			tilemapShader.setAniIndex(tiles.frameIdx);
 | 
			
		||||
			tilemapShader.setAniIndices(tiles.aniIndices);
 | 
			
		||||
			shaderVar = &tilemapShader;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue