← Back to team overview

widelands-dev team mailing list archive

Re: [Merge] lp:~widelands-dev/widelands/animation_scaling into lp:widelands

 

>  I'd like to finish the spritemaps first though. 

agreed.

> I also think it will only be worth our effort once we have the bigger textures exported from Blender.

No, I think the benefits will be immediately visible once you use downscaled textures. It just looks better. 

> [representative image]

okay, as long as you have it on the radar and we agree that it has to die eventually :)

About this change: I am still unhappy about it... Sorry :/. Now we have a circular dependency between RenderTarget and Surface.

I feel the semantics break down in animation::get_width() and height. We have two dimensions now: the "perceived" (logical) one and the images on disk ones (physical) - the drawing code only knows about the first, and Animation should be the only knowing about the other. 

Can we not simply scale the source rect whenever blit_data() is requested? Other solution would be to not expose Animation width/height and instead deal in all code with relative quantities - i.e. a source rect of {w:0.5, h:1, x:0.25, y:0.} would mean: use the full height of the texture, but only 50% of the width starting at 25%. 





Diff comments:

> 
> === modified file 'src/graphic/animation.cc'
> --- src/graphic/animation.cc	2016-10-26 10:56:02 +0000
> +++ src/graphic/animation.cc	2016-11-16 08:32:51 +0000
> @@ -144,9 +146,19 @@
>  				throw wexception("Animation is missing player color file: %s", image_file.c_str());
>  			}
>  		}
> +
> +		if (table.has_key("scale")) {
> +			scale_ = table.get_double("scale");
> +			if (scale_ <= 0.0f) {
> +				throw wexception(
> +				   "Animation scale %f needs to be > 0.0f. First image of this animation is %s", scale_,

s/First image of/This animation has/

> +				   image_files_[0].c_str());
> +			}
> +		}
> +
>  		assert(!image_files_.empty());
>  		assert(pc_mask_image_files_.size() == image_files_.size() || pc_mask_image_files_.empty());
> -
> +		assert(scale_ > 0);
>  	} catch (const LuaError& e) {
>  		throw wexception("Error in animation table: %s", e.what());
>  	}
> 
> === modified file 'src/graphic/rendertarget.h'
> --- src/graphic/rendertarget.h	2016-10-17 20:39:15 +0000
> +++ src/graphic/rendertarget.h	2016-11-16 08:32:51 +0000
> @@ -130,9 +130,10 @@
>  		return offset_;
>  	}
>  
> +	bool to_surface_geometry(Rectf* destination_rect, Rectf* source_rect) const;

Add a comment what this does?

> +
>  protected:
>  	bool clip(Rectf& r) const;
> -	bool to_surface_geometry(Rectf* destination_rect, Rectf* source_rect) const;
>  
>  	// Does the actual blitting.
>  	void do_blit_animation(const Vector2f& dst,


-- 
https://code.launchpad.net/~widelands-dev/widelands/animation_scaling/+merge/310718
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/animation_scaling.


References