2016-06-18 14:46:12 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* polygon_2d.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* http://www.godotengine.org */
|
|
|
|
/*************************************************************************/
|
2017-01-01 22:01:57 +01:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2016-06-18 14:46:12 +02:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2014-07-07 22:44:21 +02:00
|
|
|
#include "polygon_2d.h"
|
|
|
|
|
|
|
|
Rect2 Polygon2D::get_item_rect() const {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (rect_cache_dirty) {
|
|
|
|
int l = polygon.size();
|
2014-07-07 22:44:21 +02:00
|
|
|
DVector<Vector2>::Read r = polygon.read();
|
2017-03-19 00:36:26 +01:00
|
|
|
item_rect = Rect2();
|
|
|
|
for (int i = 0; i < l; i++) {
|
2014-07-07 22:44:21 +02:00
|
|
|
Vector2 pos = r[i] + offset;
|
2017-03-19 00:36:26 +01:00
|
|
|
if (i == 0)
|
|
|
|
item_rect.pos = pos;
|
2014-07-07 22:44:21 +02:00
|
|
|
else
|
|
|
|
item_rect.expand_to(pos);
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
item_rect = item_rect.grow(20);
|
|
|
|
rect_cache_dirty = false;
|
2014-07-07 22:44:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return item_rect;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void Polygon2D::edit_set_pivot(const Point2 &p_pivot) {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
|
|
|
set_offset(p_pivot);
|
|
|
|
}
|
|
|
|
|
|
|
|
Point2 Polygon2D::edit_get_pivot() const {
|
|
|
|
|
|
|
|
return get_offset();
|
|
|
|
}
|
|
|
|
bool Polygon2D::edit_has_pivot() const {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Polygon2D::_notification(int p_what) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
switch (p_what) {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
|
|
|
case NOTIFICATION_DRAW: {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (polygon.size() < 3)
|
2014-07-07 22:44:21 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
Vector<Vector2> points;
|
|
|
|
Vector<Vector2> uvs;
|
|
|
|
|
|
|
|
points.resize(polygon.size());
|
|
|
|
|
|
|
|
int len = points.size();
|
|
|
|
{
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
DVector<Vector2>::Read polyr = polygon.read();
|
|
|
|
for (int i = 0; i < len; i++) {
|
|
|
|
points[i] = polyr[i] + offset;
|
2014-07-07 22:44:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (invert) {
|
|
|
|
|
|
|
|
Rect2 bounds;
|
2017-03-19 00:36:26 +01:00
|
|
|
int highest_idx = -1;
|
|
|
|
float highest_y = -1e20;
|
|
|
|
float sum = 0;
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < len; i++) {
|
|
|
|
if (i == 0)
|
|
|
|
bounds.pos = points[i];
|
2014-07-07 22:44:21 +02:00
|
|
|
else
|
|
|
|
bounds.expand_to(points[i]);
|
2017-03-19 00:36:26 +01:00
|
|
|
if (points[i].y > highest_y) {
|
|
|
|
highest_idx = i;
|
|
|
|
highest_y = points[i].y;
|
2014-07-07 22:44:21 +02:00
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
int ni = (i + 1) % len;
|
|
|
|
sum += (points[ni].x - points[i].x) * (points[ni].y + points[i].y);
|
2014-07-07 22:44:21 +02:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
bounds = bounds.grow(invert_border);
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
Vector2 ep[7] = {
|
|
|
|
Vector2(points[highest_idx].x, points[highest_idx].y + invert_border),
|
|
|
|
Vector2(bounds.pos + bounds.size),
|
|
|
|
Vector2(bounds.pos + Vector2(bounds.size.x, 0)),
|
2014-07-07 22:44:21 +02:00
|
|
|
Vector2(bounds.pos),
|
2017-03-19 00:36:26 +01:00
|
|
|
Vector2(bounds.pos + Vector2(0, bounds.size.y)),
|
|
|
|
Vector2(points[highest_idx].x - CMP_EPSILON, points[highest_idx].y + invert_border),
|
|
|
|
Vector2(points[highest_idx].x - CMP_EPSILON, points[highest_idx].y),
|
2014-07-07 22:44:21 +02:00
|
|
|
};
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (sum > 0) {
|
|
|
|
SWAP(ep[1], ep[4]);
|
|
|
|
SWAP(ep[2], ep[3]);
|
|
|
|
SWAP(ep[5], ep[0]);
|
|
|
|
SWAP(ep[6], points[highest_idx]);
|
2014-07-07 22:44:21 +02:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
points.resize(points.size() + 7);
|
|
|
|
for (int i = points.size() - 1; i >= highest_idx + 7; i--) {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
points[i] = points[i - 7];
|
2014-07-07 22:44:21 +02:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < 7; i++) {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
points[highest_idx + i + 1] = ep[i];
|
2014-07-07 22:44:21 +02:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
len = points.size();
|
2014-07-07 22:44:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (texture.is_valid()) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
Matrix32 texmat(tex_rot, tex_ofs);
|
2014-07-07 22:44:21 +02:00
|
|
|
texmat.scale(tex_scale);
|
2017-03-19 00:36:26 +01:00
|
|
|
Size2 tex_size = Vector2(1, 1);
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
tex_size = texture->get_size();
|
2014-07-07 22:44:21 +02:00
|
|
|
uvs.resize(points.size());
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (points.size() == uv.size()) {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
|
|
|
DVector<Vector2>::Read uvr = uv.read();
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < len; i++) {
|
|
|
|
uvs[i] = texmat.xform(uvr[i]) / tex_size;
|
2014-07-07 22:44:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < len; i++) {
|
|
|
|
uvs[i] = texmat.xform(points[i]) / tex_size;
|
2014-07-07 22:44:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector<Color> colors;
|
2017-03-19 00:36:26 +01:00
|
|
|
int color_len = vertex_colors.size();
|
2016-05-23 03:40:45 +02:00
|
|
|
colors.resize(len);
|
|
|
|
{
|
2017-03-19 00:36:26 +01:00
|
|
|
DVector<Color>::Read color_r = vertex_colors.read();
|
|
|
|
for (int i = 0; i < color_len && i < len; i++) {
|
|
|
|
colors[i] = color_r[i];
|
2016-05-23 03:40:45 +02:00
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = color_len; i < len; i++) {
|
|
|
|
colors[i] = color;
|
2016-05-23 03:40:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-07 22:44:21 +02:00
|
|
|
Vector<int> indices = Geometry::triangulate_polygon(points);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, texture.is_valid() ? texture->get_rid() : RID());
|
2014-07-07 22:44:21 +02:00
|
|
|
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void Polygon2D::set_polygon(const DVector<Vector2> &p_polygon) {
|
|
|
|
polygon = p_polygon;
|
|
|
|
rect_cache_dirty = true;
|
2014-07-07 22:44:21 +02:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
DVector<Vector2> Polygon2D::get_polygon() const {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
|
|
|
return polygon;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void Polygon2D::set_uv(const DVector<Vector2> &p_uv) {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
uv = p_uv;
|
2014-07-07 22:44:21 +02:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
DVector<Vector2> Polygon2D::get_uv() const {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
|
|
|
return uv;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void Polygon2D::set_color(const Color &p_color) {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
color = p_color;
|
2014-07-07 22:44:21 +02:00
|
|
|
update();
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
Color Polygon2D::get_color() const {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void Polygon2D::set_vertex_colors(const DVector<Color> &p_colors) {
|
2016-05-23 03:40:45 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
vertex_colors = p_colors;
|
2016-05-23 03:40:45 +02:00
|
|
|
update();
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
DVector<Color> Polygon2D::get_vertex_colors() const {
|
2016-05-23 03:40:45 +02:00
|
|
|
|
|
|
|
return vertex_colors;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void Polygon2D::set_texture(const Ref<Texture> &p_texture) {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
texture = p_texture;
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2015-04-29 03:05:01 +02:00
|
|
|
/*if (texture.is_valid()) {
|
2014-07-07 22:44:21 +02:00
|
|
|
uint32_t flags=texture->get_flags();
|
|
|
|
flags&=~Texture::FLAG_REPEAT;
|
|
|
|
if (tex_tile)
|
|
|
|
flags|=Texture::FLAG_REPEAT;
|
|
|
|
|
|
|
|
texture->set_flags(flags);
|
2015-04-29 03:05:01 +02:00
|
|
|
}*/
|
2014-07-07 22:44:21 +02:00
|
|
|
update();
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
Ref<Texture> Polygon2D::get_texture() const {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
|
|
|
return texture;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void Polygon2D::set_texture_offset(const Vector2 &p_offset) {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
tex_ofs = p_offset;
|
2014-07-07 22:44:21 +02:00
|
|
|
update();
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
Vector2 Polygon2D::get_texture_offset() const {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
|
|
|
return tex_ofs;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void Polygon2D::set_texture_rotation(float p_rot) {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
tex_rot = p_rot;
|
2014-07-07 22:44:21 +02:00
|
|
|
update();
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
float Polygon2D::get_texture_rotation() const {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
|
|
|
return tex_rot;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void Polygon2D::_set_texture_rotationd(float p_rot) {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
|
|
|
set_texture_rotation(Math::deg2rad(p_rot));
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
float Polygon2D::_get_texture_rotationd() const {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
|
|
|
return Math::rad2deg(get_texture_rotation());
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void Polygon2D::set_texture_scale(const Size2 &p_scale) {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
tex_scale = p_scale;
|
2014-07-07 22:44:21 +02:00
|
|
|
update();
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
Size2 Polygon2D::get_texture_scale() const {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
|
|
|
return tex_scale;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void Polygon2D::set_invert(bool p_invert) {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
invert = p_invert;
|
2014-07-07 22:44:21 +02:00
|
|
|
update();
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
bool Polygon2D::get_invert() const {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
|
|
|
return invert;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void Polygon2D::set_invert_border(float p_invert_border) {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
invert_border = p_invert_border;
|
2014-07-07 22:44:21 +02:00
|
|
|
update();
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
float Polygon2D::get_invert_border() const {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
|
|
|
return invert_border;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void Polygon2D::set_offset(const Vector2 &p_offset) {
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
offset = p_offset;
|
|
|
|
rect_cache_dirty = true;
|
2014-07-07 22:44:21 +02:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector2 Polygon2D::get_offset() const {
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Polygon2D::_bind_methods() {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ObjectTypeDB::bind_method(_MD("set_polygon", "polygon"), &Polygon2D::set_polygon);
|
|
|
|
ObjectTypeDB::bind_method(_MD("get_polygon"), &Polygon2D::get_polygon);
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ObjectTypeDB::bind_method(_MD("set_uv", "uv"), &Polygon2D::set_uv);
|
|
|
|
ObjectTypeDB::bind_method(_MD("get_uv"), &Polygon2D::get_uv);
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ObjectTypeDB::bind_method(_MD("set_color", "color"), &Polygon2D::set_color);
|
|
|
|
ObjectTypeDB::bind_method(_MD("get_color"), &Polygon2D::get_color);
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ObjectTypeDB::bind_method(_MD("set_vertex_colors", "vertex_colors"), &Polygon2D::set_vertex_colors);
|
|
|
|
ObjectTypeDB::bind_method(_MD("get_vertex_colors"), &Polygon2D::get_vertex_colors);
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ObjectTypeDB::bind_method(_MD("set_texture", "texture"), &Polygon2D::set_texture);
|
|
|
|
ObjectTypeDB::bind_method(_MD("get_texture"), &Polygon2D::get_texture);
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ObjectTypeDB::bind_method(_MD("set_texture_offset", "texture_offset"), &Polygon2D::set_texture_offset);
|
|
|
|
ObjectTypeDB::bind_method(_MD("get_texture_offset"), &Polygon2D::get_texture_offset);
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ObjectTypeDB::bind_method(_MD("set_texture_rotation", "texture_rotation"), &Polygon2D::set_texture_rotation);
|
|
|
|
ObjectTypeDB::bind_method(_MD("get_texture_rotation"), &Polygon2D::get_texture_rotation);
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ObjectTypeDB::bind_method(_MD("_set_texture_rotationd", "texture_rotation"), &Polygon2D::_set_texture_rotationd);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_get_texture_rotationd"), &Polygon2D::_get_texture_rotationd);
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ObjectTypeDB::bind_method(_MD("set_texture_scale", "texture_scale"), &Polygon2D::set_texture_scale);
|
|
|
|
ObjectTypeDB::bind_method(_MD("get_texture_scale"), &Polygon2D::get_texture_scale);
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ObjectTypeDB::bind_method(_MD("set_invert", "invert"), &Polygon2D::set_invert);
|
|
|
|
ObjectTypeDB::bind_method(_MD("get_invert"), &Polygon2D::get_invert);
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ObjectTypeDB::bind_method(_MD("set_invert_border", "invert_border"), &Polygon2D::set_invert_border);
|
|
|
|
ObjectTypeDB::bind_method(_MD("get_invert_border"), &Polygon2D::get_invert_border);
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ObjectTypeDB::bind_method(_MD("set_offset", "offset"), &Polygon2D::set_offset);
|
|
|
|
ObjectTypeDB::bind_method(_MD("get_offset"), &Polygon2D::get_offset);
|
2014-07-07 22:44:21 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2_ARRAY, "polygon"), _SCS("set_polygon"), _SCS("get_polygon"));
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2_ARRAY, "uv"), _SCS("set_uv"), _SCS("get_uv"));
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), _SCS("set_color"), _SCS("get_color"));
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::COLOR_ARRAY, "vertex_colors"), _SCS("set_vertex_colors"), _SCS("get_vertex_colors"));
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), _SCS("set_offset"), _SCS("get_offset"));
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture/texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"), _SCS("get_texture"));
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture/offset"), _SCS("set_texture_offset"), _SCS("get_texture_offset"));
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture/scale"), _SCS("set_texture_scale"), _SCS("get_texture_scale"));
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "texture/rotation", PROPERTY_HINT_RANGE, "-1440,1440,0.1"), _SCS("_set_texture_rotationd"), _SCS("_get_texture_rotationd"));
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "invert/enable"), _SCS("set_invert"), _SCS("get_invert"));
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "invert/border", PROPERTY_HINT_RANGE, "0.1,16384,0.1"), _SCS("set_invert_border"), _SCS("get_invert_border"));
|
2014-07-07 22:44:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Polygon2D::Polygon2D() {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
invert = 0;
|
|
|
|
invert_border = 100;
|
|
|
|
tex_rot = 0;
|
|
|
|
tex_tile = true;
|
|
|
|
tex_scale = Vector2(1, 1);
|
|
|
|
color = Color(1, 1, 1);
|
|
|
|
rect_cache_dirty = true;
|
2014-07-07 22:44:21 +02:00
|
|
|
}
|