Working TileMap tile transpose transform.
This commit is contained in:
parent
a8b318871c
commit
c5bf43f6eb
16 changed files with 110 additions and 89 deletions
|
@ -8076,7 +8076,7 @@ void RasterizerGLES2::_draw_gui_primitive2(int p_points, const Vector2 *p_vertic
|
|||
_rinfo.ci_draw_commands++;
|
||||
}
|
||||
|
||||
void RasterizerGLES2::_draw_textured_quad(const Rect2& p_rect, const Rect2& p_src_region, const Size2& p_tex_size,bool p_h_flip, bool p_v_flip ) {
|
||||
void RasterizerGLES2::_draw_textured_quad(const Rect2& p_rect, const Rect2& p_src_region, const Size2& p_tex_size,bool p_h_flip, bool p_v_flip, bool p_transpose ) {
|
||||
|
||||
Vector2 texcoords[4]= {
|
||||
Vector2( p_src_region.pos.x/p_tex_size.width,
|
||||
|
@ -8100,6 +8100,9 @@ void RasterizerGLES2::_draw_textured_quad(const Rect2& p_rect, const Rect2& p_sr
|
|||
SWAP( texcoords[1], texcoords[2] );
|
||||
SWAP( texcoords[0], texcoords[3] );
|
||||
}
|
||||
if (p_transpose) {
|
||||
SWAP( texcoords[1], texcoords[3] );
|
||||
}
|
||||
|
||||
Vector2 coords[4]= {
|
||||
Vector2( p_rect.pos.x, p_rect.pos.y ),
|
||||
|
@ -8139,11 +8142,11 @@ void RasterizerGLES2::canvas_draw_rect(const Rect2& p_rect, int p_flags, const R
|
|||
if (!(p_flags&CANVAS_RECT_REGION)) {
|
||||
|
||||
Rect2 region = Rect2(0,0,texture->width,texture->height);
|
||||
_draw_textured_quad(p_rect,region,region.size,p_flags&CANVAS_RECT_FLIP_H,p_flags&CANVAS_RECT_FLIP_V);
|
||||
_draw_textured_quad(p_rect,region,region.size,p_flags&CANVAS_RECT_FLIP_H,p_flags&CANVAS_RECT_FLIP_V,p_flags&CANVAS_RECT_TRANSPOSE);
|
||||
|
||||
} else {
|
||||
|
||||
_draw_textured_quad(p_rect, p_source, Size2(texture->width,texture->height),p_flags&CANVAS_RECT_FLIP_H,p_flags&CANVAS_RECT_FLIP_V );
|
||||
_draw_textured_quad(p_rect, p_source, Size2(texture->width,texture->height),p_flags&CANVAS_RECT_FLIP_H,p_flags&CANVAS_RECT_FLIP_V,p_flags&CANVAS_RECT_TRANSPOSE);
|
||||
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1218,7 +1218,7 @@ class RasterizerGLES2 : public Rasterizer {
|
|||
void _draw_primitive(int p_points, const Vector3 *p_vertices, const Vector3 *p_normals, const Color* p_colors, const Vector3 *p_uvs,const Plane *p_tangents=NULL,int p_instanced=1);
|
||||
_FORCE_INLINE_ void _draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color* p_colors, const Vector2 *p_uvs);
|
||||
_FORCE_INLINE_ void _draw_gui_primitive2(int p_points, const Vector2 *p_vertices, const Color* p_colors, const Vector2 *p_uvs, const Vector2 *p_uvs2);
|
||||
void _draw_textured_quad(const Rect2& p_rect, const Rect2& p_src_region, const Size2& p_tex_size,bool p_h_flip=false, bool p_v_flip=false );
|
||||
void _draw_textured_quad(const Rect2& p_rect, const Rect2& p_src_region, const Size2& p_tex_size,bool p_h_flip=false, bool p_v_flip=false, bool p_transpose=false );
|
||||
void _draw_quad(const Rect2& p_rect);
|
||||
void _copy_screen_quad();
|
||||
void _copy_to_texscreen();
|
||||
|
|
|
@ -511,7 +511,7 @@ void CanvasItem::draw_texture(const Ref<Texture>& p_texture,const Point2& p_pos)
|
|||
p_texture->draw(canvas_item,p_pos);
|
||||
}
|
||||
|
||||
void CanvasItem::draw_texture_rect(const Ref<Texture>& p_texture,const Rect2& p_rect, bool p_tile,const Color& p_modulate) {
|
||||
void CanvasItem::draw_texture_rect(const Ref<Texture>& p_texture,const Rect2& p_rect, bool p_tile,const Color& p_modulate, bool p_transpose) {
|
||||
|
||||
if (!drawing) {
|
||||
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
|
||||
|
@ -519,17 +519,17 @@ void CanvasItem::draw_texture_rect(const Ref<Texture>& p_texture,const Rect2& p_
|
|||
}
|
||||
|
||||
ERR_FAIL_COND(p_texture.is_null());
|
||||
p_texture->draw_rect(canvas_item,p_rect,p_tile,p_modulate);
|
||||
p_texture->draw_rect(canvas_item,p_rect,p_tile,p_modulate,p_transpose);
|
||||
|
||||
}
|
||||
void CanvasItem::draw_texture_rect_region(const Ref<Texture>& p_texture,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate) {
|
||||
void CanvasItem::draw_texture_rect_region(const Ref<Texture>& p_texture,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate, bool p_transpose) {
|
||||
|
||||
if (!drawing) {
|
||||
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
|
||||
ERR_FAIL();
|
||||
}
|
||||
ERR_FAIL_COND(p_texture.is_null());
|
||||
p_texture->draw_rect_region(canvas_item,p_rect,p_src_rect,p_modulate);
|
||||
p_texture->draw_rect_region(canvas_item,p_rect,p_src_rect,p_modulate,p_transpose);
|
||||
}
|
||||
|
||||
void CanvasItem::draw_style_box(const Ref<StyleBox>& p_style_box,const Rect2& p_rect) {
|
||||
|
|
|
@ -170,8 +170,8 @@ public:
|
|||
void draw_rect(const Rect2& p_rect, const Color& p_color);
|
||||
void draw_circle(const Point2& p_pos, float p_radius, const Color& p_color);
|
||||
void draw_texture(const Ref<Texture>& p_texture,const Point2& p_pos);
|
||||
void draw_texture_rect(const Ref<Texture>& p_texture, const Rect2& p_rect, bool p_tile=false,const Color& p_modulate=Color(1,1,1));
|
||||
void draw_texture_rect_region(const Ref<Texture>& p_texture,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1));
|
||||
void draw_texture_rect(const Ref<Texture>& p_texture, const Rect2& p_rect, bool p_tile=false,const Color& p_modulate=Color(1,1,1), bool p_transpose=false);
|
||||
void draw_texture_rect_region(const Ref<Texture>& p_texture,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1), bool p_transpose=false);
|
||||
void draw_style_box(const Ref<StyleBox>& p_style_box,const Rect2& p_rect);
|
||||
void draw_primitive(const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, Ref<Texture> p_texture=Ref<Texture>(),float p_width=1);
|
||||
void draw_polygon(const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs=Vector<Point2>(), Ref<Texture> p_texture=Ref<Texture>());
|
||||
|
|
|
@ -222,19 +222,13 @@ void TileMap::_update_dirty_quadrants() {
|
|||
rect.size.x=-rect.size.x;
|
||||
if (c.flip_v)
|
||||
rect.size.y=-rect.size.y;
|
||||
if (c.transpose) {
|
||||
//TODO
|
||||
}
|
||||
|
||||
|
||||
|
||||
rect.pos+=tile_ofs;
|
||||
if (r==Rect2()) {
|
||||
|
||||
tex->draw_rect(q.canvas_item,rect);
|
||||
tex->draw_rect(q.canvas_item,rect,false,Color(1,1,1),c.transpose);
|
||||
} else {
|
||||
|
||||
tex->draw_rect_region(q.canvas_item,rect,r);
|
||||
tex->draw_rect_region(q.canvas_item,rect,r,Color(1,1,1),c.transpose);
|
||||
}
|
||||
|
||||
Vector< Ref<Shape2D> > shapes = tile_set->tile_get_shapes(c.id);
|
||||
|
@ -250,22 +244,19 @@ void TileMap::_update_dirty_quadrants() {
|
|||
xform.set_origin(offset.floor());
|
||||
if (c.flip_h) {
|
||||
xform.elements[0]=-xform.elements[0];
|
||||
xform.elements[2].x+=s.x-shape_ofs.x;
|
||||
} else {
|
||||
|
||||
xform.elements[2].x+=shape_ofs.x;
|
||||
shape_ofs.x=s.x-shape_ofs.x;
|
||||
}
|
||||
if (c.flip_v) {
|
||||
xform.elements[1]=-xform.elements[1];
|
||||
xform.elements[2].y+=s.y-shape_ofs.y;
|
||||
} else {
|
||||
|
||||
xform.elements[2].y+=shape_ofs.y;
|
||||
shape_ofs.y=s.y-shape_ofs.y;
|
||||
}
|
||||
if (c.transpose) {
|
||||
//TODO
|
||||
} else {
|
||||
SWAP(xform.elements[0].x, xform.elements[0].y);
|
||||
SWAP(xform.elements[1].x, xform.elements[1].y);
|
||||
SWAP(shape_ofs.x, shape_ofs.y);
|
||||
}
|
||||
xform.elements[2].x+=shape_ofs.x;
|
||||
xform.elements[2].y+=shape_ofs.y;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -38,19 +38,19 @@ Size2 Texture::get_size() const {
|
|||
}
|
||||
|
||||
|
||||
void Texture::draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate) const {
|
||||
void Texture::draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate, bool p_transpose) const {
|
||||
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item,Rect2( p_pos, get_size()),get_rid(),false,p_modulate);
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item,Rect2( p_pos, get_size()),get_rid(),false,p_modulate,p_transpose);
|
||||
|
||||
}
|
||||
void Texture::draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile,const Color& p_modulate) const {
|
||||
void Texture::draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile,const Color& p_modulate, bool p_transpose) const {
|
||||
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item,p_rect,get_rid(),p_tile,p_modulate);
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item,p_rect,get_rid(),p_tile,p_modulate,p_transpose);
|
||||
|
||||
}
|
||||
void Texture::draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate) const{
|
||||
void Texture::draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate, bool p_transpose) const{
|
||||
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item,p_rect,get_rid(),p_src_rect,p_modulate);
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item,p_rect,get_rid(),p_src_rect,p_modulate,p_transpose);
|
||||
}
|
||||
|
||||
bool Texture::get_rect_region(const Rect2& p_rect, const Rect2& p_src_rect,Rect2& r_rect,Rect2& r_src_rect) const {
|
||||
|
@ -70,9 +70,9 @@ void Texture::_bind_methods() {
|
|||
ObjectTypeDB::bind_method(_MD("has_alpha"),&Texture::has_alpha);
|
||||
ObjectTypeDB::bind_method(_MD("set_flags","flags"),&Texture::set_flags);
|
||||
ObjectTypeDB::bind_method(_MD("get_flags"),&Texture::get_flags);
|
||||
ObjectTypeDB::bind_method(_MD("draw","canvas_item","pos","modulate"),&Texture::draw,DEFVAL(Color(1,1,1)));
|
||||
ObjectTypeDB::bind_method(_MD("draw_rect","canvas_item","rect","tile","modulate"),&Texture::draw_rect,DEFVAL(Color(1,1,1)));
|
||||
ObjectTypeDB::bind_method(_MD("draw_rect_region","canvas_item","rect","src_rect","modulate"),&Texture::draw_rect_region,DEFVAL(Color(1,1,1)));
|
||||
ObjectTypeDB::bind_method(_MD("draw","canvas_item","pos","modulate"),&Texture::draw,DEFVAL(Color(1,1,1)),DEFVAL(false));
|
||||
ObjectTypeDB::bind_method(_MD("draw_rect","canvas_item","rect","tile","modulate"),&Texture::draw_rect,DEFVAL(Color(1,1,1)),DEFVAL(false));
|
||||
ObjectTypeDB::bind_method(_MD("draw_rect_region","canvas_item","rect","src_rect","modulate"),&Texture::draw_rect_region,DEFVAL(Color(1,1,1)),DEFVAL(false));
|
||||
|
||||
BIND_CONSTANT( FLAG_MIPMAPS );
|
||||
BIND_CONSTANT( FLAG_REPEAT );
|
||||
|
@ -327,28 +327,27 @@ bool ImageTexture::has_alpha() const {
|
|||
}
|
||||
|
||||
|
||||
void ImageTexture::draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate) const {
|
||||
void ImageTexture::draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate, bool p_transpose) const {
|
||||
|
||||
if ((w|h)==0)
|
||||
return;
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item,Rect2( p_pos, Size2(w,h)),texture,false,p_modulate);
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item,Rect2( p_pos, Size2(w,h)),texture,false,p_modulate,p_transpose);
|
||||
|
||||
}
|
||||
void ImageTexture::draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile,const Color& p_modulate) const {
|
||||
void ImageTexture::draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile,const Color& p_modulate, bool p_transpose) const {
|
||||
|
||||
if ((w|h)==0)
|
||||
return;
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item,p_rect,texture,p_tile,p_modulate);
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item,p_rect,texture,p_tile,p_modulate,p_transpose);
|
||||
|
||||
}
|
||||
void ImageTexture::draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate) const{
|
||||
void ImageTexture::draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate, bool p_transpose) const{
|
||||
|
||||
if ((w|h)==0)
|
||||
return;
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item,p_rect,texture,p_src_rect,p_modulate);
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item,p_rect,texture,p_src_rect,p_modulate,p_transpose);
|
||||
}
|
||||
|
||||
|
||||
void ImageTexture::set_size_override(const Size2& p_size) {
|
||||
|
||||
Size2 s=p_size;
|
||||
|
@ -546,7 +545,7 @@ void AtlasTexture::_bind_methods() {
|
|||
|
||||
|
||||
|
||||
void AtlasTexture::draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate) const {
|
||||
void AtlasTexture::draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate, bool p_transpose) const {
|
||||
|
||||
Rect2 rc=region;
|
||||
|
||||
|
@ -561,10 +560,10 @@ void AtlasTexture::draw(RID p_canvas_item, const Point2& p_pos, const Color& p_m
|
|||
rc.size.height=atlas->get_height();
|
||||
}
|
||||
|
||||
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item,Rect2(p_pos+margin.pos,rc.size),atlas->get_rid(),rc,p_modulate);
|
||||
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item,Rect2(p_pos+margin.pos,rc.size),atlas->get_rid(),rc,p_modulate,p_transpose);
|
||||
}
|
||||
|
||||
void AtlasTexture::draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile,const Color& p_modulate) const {
|
||||
void AtlasTexture::draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile,const Color& p_modulate, bool p_transpose) const {
|
||||
|
||||
Rect2 rc=region;
|
||||
|
||||
|
@ -582,10 +581,10 @@ void AtlasTexture::draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile,
|
|||
Vector2 scale = p_rect.size / (region.size+margin.size);
|
||||
Rect2 dr( p_rect.pos+margin.pos*scale,rc.size*scale );
|
||||
|
||||
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item,dr,atlas->get_rid(),rc,p_modulate);
|
||||
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item,dr,atlas->get_rid(),rc,p_modulate,p_transpose);
|
||||
|
||||
}
|
||||
void AtlasTexture::draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate) const {
|
||||
void AtlasTexture::draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate, bool p_transpose) const {
|
||||
|
||||
//this might not necesarily work well if using a rect, needs to be fixed properly
|
||||
Rect2 rc=region;
|
||||
|
@ -615,7 +614,7 @@ void AtlasTexture::draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const
|
|||
}
|
||||
Rect2 dr( p_rect.pos+ofs*scale,src_c.size*scale );
|
||||
|
||||
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item,dr,atlas->get_rid(),src_c,p_modulate);
|
||||
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item,dr,atlas->get_rid(),src_c,p_modulate,p_transpose);
|
||||
}
|
||||
|
||||
bool AtlasTexture::get_rect_region(const Rect2& p_rect, const Rect2& p_src_rect,Rect2& r_rect,Rect2& r_src_rect) const {
|
||||
|
@ -801,15 +800,16 @@ void LargeTexture::_bind_methods() {
|
|||
|
||||
|
||||
|
||||
void LargeTexture::draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate) const {
|
||||
void LargeTexture::draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate, bool p_transpose) const {
|
||||
|
||||
for(int i=0;i<pieces.size();i++) {
|
||||
|
||||
pieces[i].texture->draw(p_canvas_item,pieces[i].offset+p_pos,p_modulate);
|
||||
// TODO
|
||||
pieces[i].texture->draw(p_canvas_item,pieces[i].offset+p_pos,p_modulate,p_transpose);
|
||||
}
|
||||
}
|
||||
|
||||
void LargeTexture::draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile,const Color& p_modulate) const {
|
||||
void LargeTexture::draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile,const Color& p_modulate, bool p_transpose) const {
|
||||
|
||||
//tiling not supported for this
|
||||
if (size.x==0 || size.y==0)
|
||||
|
@ -819,11 +819,11 @@ void LargeTexture::draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile,
|
|||
|
||||
for(int i=0;i<pieces.size();i++) {
|
||||
|
||||
pieces[i].texture->draw_rect(p_canvas_item,Rect2(pieces[i].offset*scale+p_rect.pos,pieces[i].texture->get_size()*scale),false,p_modulate);
|
||||
// TODO
|
||||
pieces[i].texture->draw_rect(p_canvas_item,Rect2(pieces[i].offset*scale+p_rect.pos,pieces[i].texture->get_size()*scale),false,p_modulate,p_transpose);
|
||||
}
|
||||
|
||||
}
|
||||
void LargeTexture::draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate) const {
|
||||
void LargeTexture::draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate, bool p_transpose) const {
|
||||
|
||||
|
||||
//tiling not supported for this
|
||||
|
@ -834,6 +834,7 @@ void LargeTexture::draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const
|
|||
|
||||
for(int i=0;i<pieces.size();i++) {
|
||||
|
||||
// TODO
|
||||
Rect2 rect( pieces[i].offset, pieces[i].texture->get_size());
|
||||
if (!p_src_rect.intersects(rect))
|
||||
continue;
|
||||
|
@ -842,7 +843,7 @@ void LargeTexture::draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const
|
|||
target.size*=scale;
|
||||
target.pos=p_rect.pos+(p_src_rect.pos+rect.pos)*scale;
|
||||
local.pos-=rect.pos;
|
||||
pieces[i].texture->draw_rect_region(p_canvas_item,target,local,p_modulate);
|
||||
pieces[i].texture->draw_rect_region(p_canvas_item,target,local,p_modulate,p_transpose);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -69,9 +69,9 @@ public:
|
|||
virtual void set_flags(uint32_t p_flags)=0;
|
||||
virtual uint32_t get_flags() const=0;
|
||||
|
||||
virtual void draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate=Color(1,1,1)) const;
|
||||
virtual void draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile=false,const Color& p_modulate=Color(1,1,1)) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1)) const;
|
||||
virtual void draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
|
||||
virtual void draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile=false,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
|
||||
virtual bool get_rect_region(const Rect2& p_rect, const Rect2& p_src_rect,Rect2& r_rect,Rect2& r_src_rect) const;
|
||||
|
||||
|
||||
|
@ -135,10 +135,9 @@ public:
|
|||
virtual RID get_rid() const;
|
||||
|
||||
bool has_alpha() const;
|
||||
virtual void draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate=Color(1,1,1)) const;
|
||||
virtual void draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile=false,const Color& p_modulate=Color(1,1,1)) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1)) const;
|
||||
|
||||
virtual void draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
|
||||
virtual void draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile=false,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
|
||||
void set_storage(Storage p_storage);
|
||||
Storage get_storage() const;
|
||||
|
||||
|
@ -191,9 +190,9 @@ public:
|
|||
void set_margin(const Rect2& p_margin);
|
||||
Rect2 get_margin() const ;
|
||||
|
||||
virtual void draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate=Color(1,1,1)) const;
|
||||
virtual void draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile=false,const Color& p_modulate=Color(1,1,1)) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1)) const;
|
||||
virtual void draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
|
||||
virtual void draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile=false,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
|
||||
virtual bool get_rect_region(const Rect2& p_rect, const Rect2& p_src_rect,Rect2& r_rect,Rect2& r_src_rect) const;
|
||||
|
||||
|
||||
|
@ -241,9 +240,9 @@ public:
|
|||
Vector2 get_piece_offset(int p_idx) const;
|
||||
Ref<Texture> get_piece_texture(int p_idx) const;
|
||||
|
||||
virtual void draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate=Color(1,1,1)) const;
|
||||
virtual void draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile=false,const Color& p_modulate=Color(1,1,1)) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1)) const;
|
||||
virtual void draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
|
||||
virtual void draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile=false,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
|
||||
|
||||
|
||||
LargeTexture();
|
||||
|
|
|
@ -564,7 +564,8 @@ public:
|
|||
CANVAS_RECT_REGION=1,
|
||||
CANVAS_RECT_TILE=2,
|
||||
CANVAS_RECT_FLIP_H=4,
|
||||
CANVAS_RECT_FLIP_V=8
|
||||
CANVAS_RECT_FLIP_V=8,
|
||||
CANVAS_RECT_TRANSPOSE=16
|
||||
};
|
||||
|
||||
struct CanvasItem {
|
||||
|
|
|
@ -3470,7 +3470,7 @@ void VisualServerRaster::canvas_item_add_circle(RID p_item, const Point2& p_pos,
|
|||
|
||||
}
|
||||
|
||||
void VisualServerRaster::canvas_item_add_texture_rect(RID p_item, const Rect2& p_rect, RID p_texture,bool p_tile,const Color& p_modulate) {
|
||||
void VisualServerRaster::canvas_item_add_texture_rect(RID p_item, const Rect2& p_rect, RID p_texture,bool p_tile,const Color& p_modulate,bool p_transpose) {
|
||||
VS_CHANGED;
|
||||
CanvasItem *canvas_item = canvas_item_owner.get( p_item );
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
|
@ -3493,12 +3493,16 @@ void VisualServerRaster::canvas_item_add_texture_rect(RID p_item, const Rect2& p
|
|||
rect->flags|=Rasterizer::CANVAS_RECT_FLIP_V;
|
||||
rect->rect.size.y = -rect->rect.size.y;
|
||||
}
|
||||
if (p_transpose) {
|
||||
rect->flags|=Rasterizer::CANVAS_RECT_TRANSPOSE;
|
||||
SWAP(rect->rect.size.x, rect->rect.size.y);
|
||||
}
|
||||
rect->texture=p_texture;
|
||||
canvas_item->rect_dirty=true;
|
||||
canvas_item->commands.push_back(rect);
|
||||
}
|
||||
|
||||
void VisualServerRaster::canvas_item_add_texture_rect_region(RID p_item, const Rect2& p_rect, RID p_texture,const Rect2& p_src_rect,const Color& p_modulate) {
|
||||
void VisualServerRaster::canvas_item_add_texture_rect_region(RID p_item, const Rect2& p_rect, RID p_texture,const Rect2& p_src_rect,const Color& p_modulate,bool p_transpose) {
|
||||
VS_CHANGED;
|
||||
CanvasItem *canvas_item = canvas_item_owner.get( p_item );
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
|
@ -3521,12 +3525,17 @@ void VisualServerRaster::canvas_item_add_texture_rect_region(RID p_item, const R
|
|||
rect->flags|=Rasterizer::CANVAS_RECT_FLIP_V;
|
||||
rect->rect.size.y = -rect->rect.size.y;
|
||||
}
|
||||
if (p_transpose) {
|
||||
rect->flags|=Rasterizer::CANVAS_RECT_TRANSPOSE;
|
||||
SWAP(rect->rect.size.x, rect->rect.size.y);
|
||||
}
|
||||
|
||||
canvas_item->rect_dirty=true;
|
||||
|
||||
canvas_item->commands.push_back(rect);
|
||||
|
||||
}
|
||||
|
||||
void VisualServerRaster::canvas_item_add_style_box(RID p_item, const Rect2& p_rect, RID p_texture,const Vector2& p_topleft, const Vector2& p_bottomright, bool p_draw_center,const Color& p_modulate) {
|
||||
|
||||
VS_CHANGED;
|
||||
|
|
|
@ -1102,8 +1102,8 @@ public:
|
|||
virtual void canvas_item_add_line(RID p_item, const Point2& p_from, const Point2& p_to,const Color& p_color,float p_width=1.0);
|
||||
virtual void canvas_item_add_rect(RID p_item, const Rect2& p_rect, const Color& p_color);
|
||||
virtual void canvas_item_add_circle(RID p_item, const Point2& p_pos, float p_radius,const Color& p_color);
|
||||
virtual void canvas_item_add_texture_rect(RID p_item, const Rect2& p_rect, RID p_texture,bool p_tile=false,const Color& p_modulate=Color(1,1,1));
|
||||
virtual void canvas_item_add_texture_rect_region(RID p_item, const Rect2& p_rect, RID p_texture,const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1));
|
||||
virtual void canvas_item_add_texture_rect(RID p_item, const Rect2& p_rect, RID p_texture,bool p_tile=false,const Color& p_modulate=Color(1,1,1),bool p_transpose=false);
|
||||
virtual void canvas_item_add_texture_rect_region(RID p_item, const Rect2& p_rect, RID p_texture,const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1),bool p_transpose=false);
|
||||
virtual void canvas_item_add_style_box(RID p_item, const Rect2& p_rect, RID p_texture,const Vector2& p_topleft, const Vector2& p_bottomright, bool p_draw_center=true,const Color& p_modulate=Color(1,1,1));
|
||||
virtual void canvas_item_add_primitive(RID p_item, const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, RID p_texture,float p_width=1.0);
|
||||
virtual void canvas_item_add_polygon(RID p_item, const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs=Vector<Point2>(), RID p_texture=RID());
|
||||
|
|
|
@ -1116,9 +1116,8 @@ public:
|
|||
FUNC5(canvas_item_add_line,RID, const Point2& , const Point2& ,const Color& ,float );
|
||||
FUNC3(canvas_item_add_rect,RID, const Rect2& , const Color& );
|
||||
FUNC4(canvas_item_add_circle,RID, const Point2& , float ,const Color& );
|
||||
FUNC5(canvas_item_add_texture_rect,RID, const Rect2& , RID ,bool ,const Color& );
|
||||
FUNC5(canvas_item_add_texture_rect_region,RID, const Rect2& , RID ,const Rect2& ,const Color& );
|
||||
|
||||
FUNC6(canvas_item_add_texture_rect,RID, const Rect2& , RID ,bool ,const Color&,bool );
|
||||
FUNC6(canvas_item_add_texture_rect_region,RID, const Rect2& , RID ,const Rect2& ,const Color&,bool );
|
||||
FUNC7(canvas_item_add_style_box,RID, const Rect2& , RID ,const Vector2& ,const Vector2&, bool ,const Color& );
|
||||
FUNC6(canvas_item_add_primitive,RID, const Vector<Point2>& , const Vector<Color>& ,const Vector<Point2>& , RID ,float );
|
||||
FUNC5(canvas_item_add_polygon,RID, const Vector<Point2>& , const Vector<Color>& ,const Vector<Point2>& , RID );
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
/*************************************************************************/
|
||||
#include "visual_server.h"
|
||||
#include "globals.h"
|
||||
#include "method_bind_ext.inc"
|
||||
|
||||
VisualServer *VisualServer::singleton=NULL;
|
||||
VisualServer* (*VisualServer::create_func)()=NULL;
|
||||
|
@ -510,8 +511,9 @@ void VisualServer::_bind_methods() {
|
|||
|
||||
ObjectTypeDB::bind_method(_MD("canvas_item_add_line"),&VisualServer::canvas_item_add_line, DEFVAL(1.0));
|
||||
ObjectTypeDB::bind_method(_MD("canvas_item_add_rect"),&VisualServer::canvas_item_add_rect);
|
||||
ObjectTypeDB::bind_method(_MD("canvas_item_add_texture_rect"),&VisualServer::canvas_item_add_texture_rect, DEFVAL(Color(1,1,1)));
|
||||
ObjectTypeDB::bind_method(_MD("canvas_item_add_texture_rect_region"),&VisualServer::canvas_item_add_texture_rect_region, DEFVAL(Color(1,1,1)));
|
||||
ObjectTypeDB::bind_method(_MD("canvas_item_add_texture_rect"),&VisualServer::canvas_item_add_texture_rect, DEFVAL(Color(1,1,1)), DEFVAL(false));
|
||||
ObjectTypeDB::bind_method(_MD("canvas_item_add_texture_rect_region"),&VisualServer::canvas_item_add_texture_rect_region, DEFVAL(Color(1,1,1)), DEFVAL(false));
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("canvas_item_add_style_box"),&VisualServer::_canvas_item_add_style_box, DEFVAL(Color(1,1,1)));
|
||||
// ObjectTypeDB::bind_method(_MD("canvas_item_add_primitive"),&VisualServer::canvas_item_add_primitive,DEFVAL(Vector<Vector2>()),DEFVAL(RID()));
|
||||
ObjectTypeDB::bind_method(_MD("canvas_item_add_circle"),&VisualServer::canvas_item_add_circle);
|
||||
|
|
|
@ -974,8 +974,8 @@ public:
|
|||
virtual void canvas_item_add_line(RID p_item, const Point2& p_from, const Point2& p_to,const Color& p_color,float p_width=1.0)=0;
|
||||
virtual void canvas_item_add_rect(RID p_item, const Rect2& p_rect, const Color& p_color)=0;
|
||||
virtual void canvas_item_add_circle(RID p_item, const Point2& p_pos, float p_radius,const Color& p_color)=0;
|
||||
virtual void canvas_item_add_texture_rect(RID p_item, const Rect2& p_rect, RID p_texture,bool p_tile=false,const Color& p_modulate=Color(1,1,1))=0;
|
||||
virtual void canvas_item_add_texture_rect_region(RID p_item, const Rect2& p_rect, RID p_texture,const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1))=0;
|
||||
virtual void canvas_item_add_texture_rect(RID p_item, const Rect2& p_rect, RID p_texture,bool p_tile=false,const Color& p_modulate=Color(1,1,1),bool p_transpose=false)=0;
|
||||
virtual void canvas_item_add_texture_rect_region(RID p_item, const Rect2& p_rect, RID p_texture,const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1),bool p_transpose=false)=0;
|
||||
virtual void canvas_item_add_style_box(RID p_item, const Rect2& p_rect, RID p_texture,const Vector2& p_topleft, const Vector2& p_bottomright, bool p_draw_center=true,const Color& p_modulate=Color(1,1,1))=0;
|
||||
virtual void canvas_item_add_primitive(RID p_item, const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, RID p_texture,float p_width=1.0)=0;
|
||||
virtual void canvas_item_add_polygon(RID p_item, const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs=Vector<Point2>(), RID p_texture=RID())=0;
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 258 B After Width: | Height: | Size: 244 B |
|
@ -99,7 +99,7 @@ void TileMapEditor::_set_cell(const Point2i& p_pos,int p_value,bool p_flip_h, bo
|
|||
bool prev_transpose=node->is_cell_transposed(p_pos.x,p_pos.y);
|
||||
int prev_val=node->get_cell(p_pos.x,p_pos.y);
|
||||
|
||||
if (p_value==prev_val && p_flip_h==prev_flip_h && p_flip_v==prev_transpose && p_flip_v==prev_transpose)
|
||||
if (p_value==prev_val && p_flip_h==prev_flip_h && p_flip_v==prev_flip_v && p_transpose==prev_transpose)
|
||||
return; //check that it's actually different
|
||||
|
||||
|
||||
|
@ -127,7 +127,7 @@ void TileMapEditor::_update_palette() {
|
|||
|
||||
|
||||
TreeItem *root = palette->create_item();
|
||||
palette->set_hide_root(true);
|
||||
//palette->set_hide_root(true);
|
||||
List<int> tiles;
|
||||
tileset->get_tile_list(&tiles);
|
||||
|
||||
|
@ -211,6 +211,7 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) {
|
|||
tcd.cell=node->get_cell(j,i);
|
||||
tcd.flip_h=node->is_cell_x_flipped(j,i);
|
||||
tcd.flip_v=node->is_cell_y_flipped(j,i);
|
||||
tcd.transpose=node->is_cell_transposed(j,i);
|
||||
dupdata.push_back(tcd);
|
||||
|
||||
|
||||
|
@ -638,15 +639,12 @@ void TileMapEditor::_canvas_draw() {
|
|||
sc.x*=-1.0;
|
||||
if (mirror_y->is_pressed())
|
||||
sc.y*=-1.0;
|
||||
if (transpose->is_pressed()) {
|
||||
//TODO
|
||||
}
|
||||
if (r==Rect2()) {
|
||||
|
||||
canvas_item_editor->draw_texture_rect(t,Rect2(from,t->get_size()*sc),false,Color(1,1,1,0.5));
|
||||
canvas_item_editor->draw_texture_rect(t,Rect2(from,t->get_size()*sc),false,Color(1,1,1,0.5),transpose->is_pressed());
|
||||
} else {
|
||||
|
||||
canvas_item_editor->draw_texture_rect_region(t,Rect2(from,r.get_size()*sc),r,Color(1,1,1,0.5));
|
||||
canvas_item_editor->draw_texture_rect_region(t,Rect2(from,r.get_size()*sc),r,Color(1,1,1,0.5),transpose->is_pressed());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -713,6 +711,7 @@ void TileMapEditor::_bind_methods() {
|
|||
ObjectTypeDB::bind_method(_MD("_canvas_mouse_enter"),&TileMapEditor::_canvas_mouse_enter);
|
||||
ObjectTypeDB::bind_method(_MD("_canvas_mouse_exit"),&TileMapEditor::_canvas_mouse_exit);
|
||||
ObjectTypeDB::bind_method(_MD("_tileset_settings_changed"),&TileMapEditor::_tileset_settings_changed);
|
||||
ObjectTypeDB::bind_method(_MD("_update_transform_buttons"),&TileMapEditor::_update_transform_buttons);
|
||||
|
||||
}
|
||||
|
||||
|
@ -725,10 +724,19 @@ TileMapEditor::CellOp TileMapEditor::_get_op_from_cell(const Point2i& p_pos)
|
|||
op.xf=true;
|
||||
if (node->is_cell_y_flipped(p_pos.x,p_pos.y))
|
||||
op.yf=true;
|
||||
if (node->is_cell_transposed(p_pos.x,p_pos.y))
|
||||
op.tr=true;
|
||||
}
|
||||
return op;
|
||||
}
|
||||
|
||||
void TileMapEditor::_update_transform_buttons(Object *p_button) {
|
||||
ERR_FAIL_NULL(p_button);
|
||||
ToolButton *b=p_button->cast_to<ToolButton>();
|
||||
ERR_FAIL_COND(!b);
|
||||
|
||||
}
|
||||
|
||||
TileMapEditor::TileMapEditor(EditorNode *p_editor) {
|
||||
|
||||
node=NULL;
|
||||
|
@ -754,37 +762,44 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
|
|||
mirror_x->set_toggle_mode(true);
|
||||
mirror_x->set_tooltip("Mirror X (A)");
|
||||
mirror_x->set_focus_mode(FOCUS_NONE);
|
||||
mirror_x->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_x));
|
||||
canvas_item_editor_hb->add_child(mirror_x);
|
||||
mirror_y = memnew( ToolButton );
|
||||
mirror_y->set_toggle_mode(true);
|
||||
mirror_y->set_tooltip("Mirror Y (S)");
|
||||
mirror_y->set_focus_mode(FOCUS_NONE);
|
||||
mirror_y->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_y));
|
||||
canvas_item_editor_hb->add_child(mirror_y);
|
||||
transpose = memnew( ToolButton );
|
||||
transpose->set_toggle_mode(true);
|
||||
transpose->set_tooltip("Transpose");
|
||||
transpose->set_focus_mode(FOCUS_NONE);
|
||||
transpose->connect("pressed", this, "_update_transform_buttons", make_binds(transpose));
|
||||
canvas_item_editor_hb->add_child(transpose);
|
||||
canvas_item_editor_hb->add_child(memnew(VSeparator));
|
||||
rotate_0 = memnew( ToolButton );
|
||||
rotate_0->set_toggle_mode(true);
|
||||
rotate_0->set_tooltip("Rotate 0 degrees");
|
||||
rotate_0->set_focus_mode(FOCUS_NONE);
|
||||
rotate_0->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_0));
|
||||
canvas_item_editor_hb->add_child(rotate_0);
|
||||
rotate_90 = memnew( ToolButton );
|
||||
rotate_90->set_toggle_mode(true);
|
||||
rotate_90->set_tooltip("Rotate 90 degrees");
|
||||
rotate_90->set_focus_mode(FOCUS_NONE);
|
||||
rotate_90->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_90));
|
||||
canvas_item_editor_hb->add_child(rotate_90);
|
||||
rotate_180 = memnew( ToolButton );
|
||||
rotate_180->set_toggle_mode(true);
|
||||
rotate_180->set_tooltip("Rotate 180 degrees");
|
||||
rotate_180->set_focus_mode(FOCUS_NONE);
|
||||
rotate_180->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_180));
|
||||
canvas_item_editor_hb->add_child(rotate_180);
|
||||
rotate_270 = memnew( ToolButton );
|
||||
rotate_270->set_toggle_mode(true);
|
||||
rotate_270->set_tooltip("Rotate 270 degrees");
|
||||
rotate_270->set_focus_mode(FOCUS_NONE);
|
||||
rotate_270->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_270));
|
||||
canvas_item_editor_hb->add_child(rotate_270);
|
||||
canvas_item_editor_hb->hide();
|
||||
|
||||
|
|
|
@ -111,6 +111,7 @@ protected:
|
|||
void _node_removed(Node *p_node);
|
||||
static void _bind_methods();
|
||||
CellOp _get_op_from_cell(const Point2i& p_pos);
|
||||
void _update_transform_buttons(Object *p_button);
|
||||
public:
|
||||
|
||||
HBoxContainer *get_canvas_item_editor_hb() const { return canvas_item_editor_hb; }
|
||||
|
|
Loading…
Reference in a new issue