-fixes to animatedsprite used with atlas

This commit is contained in:
Juan Linietsky 2015-11-11 17:39:06 -03:00
parent 61c4c5795f
commit 1d7e9c4ba5
2 changed files with 10 additions and 5 deletions

View File

@ -165,7 +165,8 @@ void AnimatedSprite::_notification(int p_what) {
if (vflip)
dst_rect.size.y=-dst_rect.size.y;
texture->draw_rect(ci,dst_rect,false,modulate);
//texture->draw_rect(ci,dst_rect,false,modulate);
texture->draw_rect_region(ci,dst_rect,Rect2(Vector2(),texture->get_size()),modulate);
// VisualServer::get_singleton()->canvas_item_add_texture_rect_region(ci,dst_rect,texture->get_rid(),src_rect,modulate);
} break;

View File

@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_atlas.h"
#include "print_string.h"
struct _EditorAtlasWorkRect {
@ -83,6 +83,7 @@ void EditorAtlas::fit(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, S
//place them
int ofs=0;
int limit_h=0;
for(int j=0;j<wrects.size();j++) {
@ -100,6 +101,9 @@ void EditorAtlas::fit(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, S
wrects[j].p.x=ofs;
wrects[j].p.y=from_y;
int end_h = from_y+wrects[j].s.height;
int end_w = ofs+wrects[j].s.width;
if (ofs==0)
@ -116,7 +120,7 @@ void EditorAtlas::fit(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, S
if (end_w > max_w)
max_w=end_w;
if (ofs==0 || end_h>limit_h ) //while h limit not reched, keep stacking
//if (ofs==0 || end_h>limit_h ) //while h limit not reched, keep stacking
ofs+=wrects[j].s.width;
}
@ -136,8 +140,8 @@ void EditorAtlas::fit(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, S
for(int i=0;i<results.size();i++) {
float h = nearest_power_of_2(results[i].max_h);
float w = nearest_power_of_2(results[i].max_w);
float h = results[i].max_h;
float w = results[i].max_w;
float aspect = h>w ? h/w : w/h;
if (aspect < best_aspect) {
best=i;