Sprite: Fix visibility calculation
The previous code assumed the scene origin to always be 0,0.
This commit is contained in:
		
							parent
							
								
									e339964076
								
							
						
					
					
						commit
						4864f63c6c
					
				
					 1 changed files with 5 additions and 2 deletions
				
			
		| 
						 | 
					@ -58,6 +58,7 @@ struct SpritePrivate
 | 
				
			||||||
	BlendType blendType;
 | 
						BlendType blendType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SDL_Rect sceneRect;
 | 
						SDL_Rect sceneRect;
 | 
				
			||||||
 | 
						Vec2i sceneOrig;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Would this sprite be visible on
 | 
						/* Would this sprite be visible on
 | 
				
			||||||
	 * the screen if drawn? */
 | 
						 * the screen if drawn? */
 | 
				
			||||||
| 
						 | 
					@ -183,8 +184,8 @@ struct SpritePrivate
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		SDL_Rect self;
 | 
							SDL_Rect self;
 | 
				
			||||||
		self.x = trans.getPosition().x - trans.getOrigin().x;
 | 
							self.x = trans.getPosition().x - (trans.getOrigin().x + sceneOrig.x);
 | 
				
			||||||
		self.y = trans.getPosition().y - trans.getOrigin().y;
 | 
							self.y = trans.getPosition().y - (trans.getOrigin().y + sceneOrig.y);
 | 
				
			||||||
		self.w = bitmap->width();
 | 
							self.w = bitmap->width();
 | 
				
			||||||
		self.h = bitmap->height();
 | 
							self.h = bitmap->height();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -583,6 +584,8 @@ void Sprite::onGeometryChange(const Scene::Geometry &geo)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	p->sceneRect.w = geo.rect.w;
 | 
						p->sceneRect.w = geo.rect.w;
 | 
				
			||||||
	p->sceneRect.h = geo.rect.h;
 | 
						p->sceneRect.h = geo.rect.h;
 | 
				
			||||||
 | 
						p->sceneOrig.x = geo.xOrigin;
 | 
				
			||||||
 | 
						p->sceneOrig.y = geo.yOrigin;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Sprite::releaseResources()
 | 
					void Sprite::releaseResources()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue