diff options
author | Clay John <claynjohn@gmail.com> | 2021-10-08 10:28:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-08 10:28:02 -0700 |
commit | 58aa020a19162becc9a00fed8a240eb12b0ab964 (patch) | |
tree | 35720ecbf3c231606efecb3c01fc603fb3a193a0 /scene/main | |
parent | a5a52233bc1327d8943c0a2a3866aa314371edec (diff) | |
parent | 73c6e19acc69b7367c4fa67cd4377e2207faf898 (diff) |
Merge pull request #52215 from Calinou/scale-3d-use-float-value
Allow any floating-point value as a 3D rendering scale option
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/viewport.cpp | 22 | ||||
-rw-r--r-- | scene/main/viewport.h | 15 |
2 files changed, 12 insertions, 25 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index e88bb3b952..3ab6e12e01 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -3443,13 +3443,16 @@ bool Viewport::is_using_xr() { return use_xr; } -void Viewport::set_scale_3d(const Scale3D p_scale_3d) { - scale_3d = p_scale_3d; +void Viewport::set_scale_3d(float p_scale_3d) { + // Clamp to reasonable values that are actually useful. + // Values above 2.0 don't serve a practical purpose since the viewport + // isn't displayed with mipmaps. + scale_3d = CLAMP(p_scale_3d, 0.1, 2.0); - RS::get_singleton()->viewport_set_scale_3d(viewport, RS::ViewportScale3D(scale_3d)); + RS::get_singleton()->viewport_set_scale_3d(viewport, scale_3d); } -Viewport::Scale3D Viewport::get_scale_3d() const { +float Viewport::get_scale_3d() const { return scale_3d; } @@ -3582,7 +3585,7 @@ void Viewport::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disable_3d"), "set_disable_3d", "is_3d_disabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_xr"), "set_use_xr", "is_using_xr"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "scale_3d", PROPERTY_HINT_ENUM, String::utf8("Disabled,75%,50%,33%,25%")), "set_scale_3d", "get_scale_3d"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "scale_3d", PROPERTY_HINT_RANGE, "0.25,2.0,0.01"), "set_scale_3d", "get_scale_3d"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "audio_listener_enable_3d"), "set_as_audio_listener_3d", "is_audio_listener_3d"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "own_world_3d"), "set_use_own_world_3d", "is_using_own_world_3d"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_3d", PROPERTY_HINT_RESOURCE_TYPE, "World3D"), "set_world_3d", "get_world_3d"); @@ -3626,12 +3629,6 @@ void Viewport::_bind_methods() { ADD_SIGNAL(MethodInfo("size_changed")); ADD_SIGNAL(MethodInfo("gui_focus_changed", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Control"))); - BIND_ENUM_CONSTANT(SCALE_3D_DISABLED); - BIND_ENUM_CONSTANT(SCALE_3D_75_PERCENT); - BIND_ENUM_CONSTANT(SCALE_3D_50_PERCENT); - BIND_ENUM_CONSTANT(SCALE_3D_33_PERCENT); - BIND_ENUM_CONSTANT(SCALE_3D_25_PERCENT); - BIND_ENUM_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_DISABLED); BIND_ENUM_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_1); BIND_ENUM_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_4); @@ -3744,8 +3741,7 @@ Viewport::Viewport() { ProjectSettings::get_singleton()->set_custom_property_info("gui/timers/tooltip_delay_sec", PropertyInfo(Variant::FLOAT, "gui/timers/tooltip_delay_sec", PROPERTY_HINT_RANGE, "0,5,0.01,or_greater")); // No negative numbers #ifndef _3D_DISABLED - int scale = GLOBAL_GET("rendering/3d/viewport/scale"); - set_scale_3d((Scale3D)scale); + set_scale_3d(GLOBAL_GET("rendering/3d/viewport/scale")); #endif // _3D_DISABLED set_sdf_oversize(sdf_oversize); // Set to server. diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 3732f9cfd1..1f19ff04c9 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -89,14 +89,6 @@ class Viewport : public Node { GDCLASS(Viewport, Node); public: - enum Scale3D { - SCALE_3D_DISABLED, - SCALE_3D_75_PERCENT, - SCALE_3D_50_PERCENT, - SCALE_3D_33_PERCENT, - SCALE_3D_25_PERCENT - }; - enum ShadowAtlasQuadrantSubdiv { SHADOW_ATLAS_QUADRANT_SUBDIV_DISABLED, SHADOW_ATLAS_QUADRANT_SUBDIV_1, @@ -592,7 +584,7 @@ public: #ifndef _3D_DISABLED bool use_xr = false; - Scale3D scale_3d = SCALE_3D_DISABLED; + float scale_3d = 1.0; friend class AudioListener3D; AudioListener3D *audio_listener_3d = nullptr; Set<AudioListener3D *> audio_listener_3d_set; @@ -664,8 +656,8 @@ public: void set_use_xr(bool p_use_xr); bool is_using_xr(); - void set_scale_3d(const Scale3D p_scale_3d); - Scale3D get_scale_3d() const; + void set_scale_3d(float p_scale_3d); + float get_scale_3d() const; #endif // _3D_DISABLED Viewport(); @@ -724,7 +716,6 @@ VARIANT_ENUM_CAST(SubViewport::UpdateMode); VARIANT_ENUM_CAST(Viewport::ShadowAtlasQuadrantSubdiv); VARIANT_ENUM_CAST(Viewport::MSAA); VARIANT_ENUM_CAST(Viewport::ScreenSpaceAA); -VARIANT_ENUM_CAST(Viewport::Scale3D); VARIANT_ENUM_CAST(Viewport::DebugDraw); VARIANT_ENUM_CAST(Viewport::SDFScale); VARIANT_ENUM_CAST(Viewport::SDFOversize); |