-fix forced texture repeat in Polygon2D, now depends on texture.
-added a new function, Camera::is_position_behind to aid to unproject(), fixes #1725
This commit is contained in:
parent
c6dce44dd8
commit
98c086edaf
|
@ -192,14 +192,14 @@ void Polygon2D::set_texture(const Ref<Texture>& p_texture){
|
|||
|
||||
texture=p_texture;
|
||||
|
||||
if (texture.is_valid()) {
|
||||
/*if (texture.is_valid()) {
|
||||
uint32_t flags=texture->get_flags();
|
||||
flags&=~Texture::FLAG_REPEAT;
|
||||
if (tex_tile)
|
||||
flags|=Texture::FLAG_REPEAT;
|
||||
|
||||
texture->set_flags(flags);
|
||||
}
|
||||
}*/
|
||||
update();
|
||||
}
|
||||
Ref<Texture> Polygon2D::get_texture() const{
|
||||
|
@ -228,22 +228,6 @@ float Polygon2D::get_texture_rotation() const{
|
|||
return tex_rot;
|
||||
}
|
||||
|
||||
void Polygon2D::set_texture_repeat(bool p_enable){
|
||||
|
||||
tex_tile=p_enable;
|
||||
if (texture.is_valid()) {
|
||||
uint32_t flags=texture->get_flags();
|
||||
flags&=~Texture::FLAG_REPEAT;
|
||||
if (p_enable)
|
||||
flags|=Texture::FLAG_REPEAT;
|
||||
texture->set_flags(flags);
|
||||
}
|
||||
update();
|
||||
}
|
||||
bool Polygon2D::get_texture_repeat() const{
|
||||
|
||||
return tex_tile;
|
||||
}
|
||||
|
||||
void Polygon2D::_set_texture_rotationd(float p_rot){
|
||||
|
||||
|
@ -324,8 +308,6 @@ void Polygon2D::_bind_methods() {
|
|||
ObjectTypeDB::bind_method(_MD("set_texture_scale","texture_scale"),&Polygon2D::set_texture_scale);
|
||||
ObjectTypeDB::bind_method(_MD("get_texture_scale"),&Polygon2D::get_texture_scale);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_texture_repeat","enable"),&Polygon2D::set_texture_repeat);
|
||||
ObjectTypeDB::bind_method(_MD("get_texture_repeat"),&Polygon2D::get_texture_repeat);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_invert","invert"),&Polygon2D::set_invert);
|
||||
ObjectTypeDB::bind_method(_MD("get_invert"),&Polygon2D::get_invert);
|
||||
|
@ -346,7 +328,6 @@ void Polygon2D::_bind_methods() {
|
|||
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,"texture/repeat"),_SCS("set_texture_repeat"),_SCS("get_texture_repeat"));
|
||||
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"));
|
||||
|
||||
|
|
|
@ -52,9 +52,6 @@ public:
|
|||
void set_texture_scale(const Vector2& p_scale);
|
||||
Vector2 get_texture_scale() const;
|
||||
|
||||
void set_texture_repeat(bool p_rot);
|
||||
bool get_texture_repeat() const;
|
||||
|
||||
void set_invert(bool p_rot);
|
||||
bool get_invert() const;
|
||||
|
||||
|
|
|
@ -552,6 +552,13 @@ Vector3 Camera::project_ray_origin(const Point2& p_pos) const {
|
|||
};
|
||||
};
|
||||
|
||||
bool Camera::is_position_behind(const Vector3& p_pos) const {
|
||||
|
||||
Transform t = get_global_transform();
|
||||
Vector3 eyedir = -get_global_transform().basis.get_axis(2).normalized();
|
||||
return eyedir.dot(p_pos) < (eyedir.dot(t.origin)+near);
|
||||
}
|
||||
|
||||
Point2 Camera::unproject_position(const Vector3& p_pos) const {
|
||||
|
||||
if (!is_inside_tree()) {
|
||||
|
@ -666,6 +673,7 @@ void Camera::_bind_methods() {
|
|||
ObjectTypeDB::bind_method( _MD("project_local_ray_normal","screen_point"), &Camera::project_local_ray_normal);
|
||||
ObjectTypeDB::bind_method( _MD("project_ray_origin","screen_point"), &Camera::project_ray_origin);
|
||||
ObjectTypeDB::bind_method( _MD("unproject_position","world_point"), &Camera::unproject_position);
|
||||
ObjectTypeDB::bind_method( _MD("is_position_behind","world_point"), &Camera::is_position_behind);
|
||||
ObjectTypeDB::bind_method( _MD("project_position","screen_point"), &Camera::project_position);
|
||||
ObjectTypeDB::bind_method( _MD("set_perspective","fov","z_near","z_far"),&Camera::set_perspective );
|
||||
ObjectTypeDB::bind_method( _MD("set_orthogonal","size","z_near","z_far"),&Camera::set_orthogonal );
|
||||
|
|
|
@ -126,6 +126,7 @@ public:
|
|||
Vector3 project_ray_origin(const Point2& p_point) const;
|
||||
Vector3 project_local_ray_normal(const Point2& p_point) const;
|
||||
Point2 unproject_position(const Vector3& p_pos) const;
|
||||
bool is_position_behind(const Vector3& p_pos) const;
|
||||
Vector3 project_position(const Point2& p_point) const;
|
||||
|
||||
void set_visible_layers(uint32_t p_layers);
|
||||
|
|
Loading…
Reference in New Issue