-A little More control about pixel snapping in 2D
This commit is contained in:
parent
b3cda43a0f
commit
79e5ced7e6
|
@ -516,6 +516,7 @@ OS::OS() {
|
|||
_target_fps=0;
|
||||
_render_thread_mode=RENDER_THREAD_SAFE;
|
||||
_time_scale=1.0;
|
||||
_pixel_snap=false;
|
||||
Math::seed(1234567);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ class OS {
|
|||
float _fps;
|
||||
int _target_fps;
|
||||
float _time_scale;
|
||||
bool _pixel_snap;
|
||||
|
||||
char *last_error;
|
||||
|
||||
|
@ -393,7 +394,7 @@ public:
|
|||
void set_time_scale(float p_scale);
|
||||
float get_time_scale() const;
|
||||
|
||||
|
||||
_FORCE_INLINE_ bool get_use_pixel_snap() const { return _pixel_snap; }
|
||||
|
||||
OS();
|
||||
virtual ~OS();
|
||||
|
|
|
@ -4145,7 +4145,7 @@ void RasterizerGLES2::begin_frame() {
|
|||
|
||||
//fragment_lighting=Globals::get_singleton()->get("rasterizer/use_fragment_lighting");
|
||||
#ifdef TOOLS_ENABLED
|
||||
canvas_shader.set_conditional(CanvasShaderGLES2::USE_PIXEL_SNAP,GLOBAL_DEF("rasterizer/use_pixel_snap",false));
|
||||
canvas_shader.set_conditional(CanvasShaderGLES2::USE_PIXEL_SNAP,GLOBAL_DEF("display/use_2d_pixel_snap",false));
|
||||
shadow_filter=ShadowFilterTechnique(int(Globals::get_singleton()->get("rasterizer/shadow_filter")));
|
||||
#endif
|
||||
|
||||
|
@ -10807,7 +10807,7 @@ void RasterizerGLES2::init() {
|
|||
copy_shader.set_conditional(CopyShaderGLES2::USE_8BIT_HDR,!use_fp16_fb);
|
||||
canvas_shader.set_conditional(CanvasShaderGLES2::USE_DEPTH_SHADOWS,read_depth_supported);
|
||||
|
||||
canvas_shader.set_conditional(CanvasShaderGLES2::USE_PIXEL_SNAP,GLOBAL_DEF("rasterizer/use_pixel_snap",false));
|
||||
canvas_shader.set_conditional(CanvasShaderGLES2::USE_PIXEL_SNAP,GLOBAL_DEF("display/use_2d_pixel_snap",false));
|
||||
|
||||
npo2_textures_available=true;
|
||||
//fragment_lighting=false;
|
||||
|
|
|
@ -701,6 +701,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
|
|||
GLOBAL_DEF("display/resizable",video_mode.resizable);
|
||||
GLOBAL_DEF("display/test_width",0);
|
||||
GLOBAL_DEF("display/test_height",0);
|
||||
OS::get_singleton()->_pixel_snap=GLOBAL_DEF("display/use_2d_pixel_snap",false);
|
||||
if (rtm==-1) {
|
||||
rtm=GLOBAL_DEF("render/thread_model",OS::RENDER_THREAD_SAFE);
|
||||
if (rtm>=1) //hack for now
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
/*************************************************************************/
|
||||
#include "animated_sprite.h"
|
||||
#include "scene/scene_string_names.h"
|
||||
#include "os/os.h"
|
||||
|
||||
void AnimatedSprite::edit_set_pivot(const Point2& p_pivot) {
|
||||
|
||||
set_offset(p_pivot);
|
||||
|
@ -153,6 +155,9 @@ void AnimatedSprite::_notification(int p_what) {
|
|||
if (centered)
|
||||
ofs-=s/2;
|
||||
|
||||
if (OS::get_singleton()->get_use_pixel_snap()) {
|
||||
ofs=ofs.floor();
|
||||
}
|
||||
Rect2 dst_rect(ofs,s);
|
||||
|
||||
if (hflip)
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "core/core_string_names.h"
|
||||
#include "scene/scene_string_names.h"
|
||||
#include "scene/main/viewport.h"
|
||||
#include "os/os.h"
|
||||
|
||||
void Sprite::edit_set_pivot(const Point2& p_pivot) {
|
||||
|
||||
|
@ -85,6 +86,9 @@ void Sprite::_notification(int p_what) {
|
|||
Point2 ofs=offset;
|
||||
if (centered)
|
||||
ofs-=s/2;
|
||||
if (OS::get_singleton()->get_use_pixel_snap()) {
|
||||
ofs=ofs.floor();
|
||||
}
|
||||
|
||||
Rect2 dst_rect(ofs,s);
|
||||
|
||||
|
@ -422,6 +426,9 @@ void ViewportSprite::_notification(int p_what) {
|
|||
if (centered)
|
||||
ofs-=s/2;
|
||||
|
||||
if (OS::get_singleton()->get_use_pixel_snap()) {
|
||||
ofs=ofs.floor();
|
||||
}
|
||||
Rect2 dst_rect(ofs,s);
|
||||
texture->draw_rect_region(ci,dst_rect,src_rect,modulate);
|
||||
|
||||
|
|
Loading…
Reference in New Issue