diff options
78 files changed, 736 insertions, 666 deletions
diff --git a/SConstruct b/SConstruct index 4fd1b86f54..705ef4881c 100644 --- a/SConstruct +++ b/SConstruct @@ -189,7 +189,17 @@ for k in platform_opts.keys(): opts.Add(o) for x in module_list: - opts.Add(BoolVariable('module_' + x + '_enabled', "Enable module '%s'" % (x, ), True)) + module_enabled = True + tmppath = "./modules/" + x + sys.path.append(tmppath) + try: + import config + if (not config.is_enabled()): + module_enabled = False + except: + pass + sys.path.remove(tmppath) + opts.Add(BoolVariable('module_' + x + '_enabled', "Enable module '%s'" % (x, ), module_enabled)) opts.Update(env_base) # update environment Help(opts.GenerateHelpText(env_base)) # generate help diff --git a/doc/classes/AudioEffectAmplify.xml b/doc/classes/AudioEffectAmplify.xml index 8497042b53..35d7991833 100644 --- a/doc/classes/AudioEffectAmplify.xml +++ b/doc/classes/AudioEffectAmplify.xml @@ -1,10 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AudioEffectAmplify" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> <brief_description> - Amplifies the volume of an audio source. + Adds a Amplify audio effect to an Audio bus. + Increases or decreases the volume of the selected audio bus. </brief_description> <description> - Amplifies the volume of an audio source. Increase gain of the audio being routed through the bus. + Increases or decreases the volume being routed through the audio bus. </description> <tutorials> </tutorials> @@ -15,7 +16,6 @@ <return type="float"> </return> <description> - Returns the set maximum volume. </description> </method> <method name="set_volume_db"> @@ -24,13 +24,12 @@ <argument index="0" name="volume" type="float"> </argument> <description> - Sets the maximum volume. </description> </method> </methods> <members> <member name="volume_db" type="float" setter="set_volume_db" getter="get_volume_db"> - The effect's volume limit. + Amount of amplification. Positive values make the sound louder, negative values make it quieter. Value can range from -80 to 24. Default value: [code]0[/code]. </member> </members> <constants> diff --git a/doc/classes/AudioEffectCompressor.xml b/doc/classes/AudioEffectCompressor.xml index 5a7a91ede0..9d7e25dbf2 100644 --- a/doc/classes/AudioEffectCompressor.xml +++ b/doc/classes/AudioEffectCompressor.xml @@ -1,8 +1,16 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AudioEffectCompressor" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> <brief_description> + Adds a Compressor audio effect to an Audio bus. + Reduces sounds that exceed a certain threshold level, smooths out the dynamics and increases the overall volume. </brief_description> <description> + Dynamic range compressor reduces the level of the sound when the amplitude goes over a certain threshold in Decibels. One of the main uses of a compressor is to increase the dynamic range by clipping as little as possible (when sound goes over 0dB). + Compressor has many uses in the mix: + - In the Master bus to compress the whole output (Although a [AudioEffectLimiter] is probably better) + - In voice channels to ensure they sound as balanced as possible. + - Sidechained. Sidechained, which can reduce the sound level sidechained with another audio bus for threshold detection.. This technique is very common in video game mixing to download the level of Music/SFX while voices are being heard. + - Accentuates transients by using a wider attack, making effects sound more punchy. </description> <tutorials> </tutorials> @@ -110,18 +118,25 @@ </methods> <members> <member name="attack_us" type="float" setter="set_attack_us" getter="get_attack_us"> + Compressor's reaction time when the signal exceeds the threshold. Value can range from 20 to 2000. Default value: [code]20ms[/code]. </member> <member name="gain" type="float" setter="set_gain" getter="get_gain"> + Gain applied to the output signal. </member> <member name="mix" type="float" setter="set_mix" getter="get_mix"> + Balance between original signal and effect signal. Value can range from 0 (totally dry) to 1 (totally wet). Default value: [code]1[/code]. </member> <member name="ratio" type="float" setter="set_ratio" getter="get_ratio"> + Amount of compression applied to the audio once it passes the threshold level. The higher the ratio the more the loud parts of the audio will be compressed. Value can range from 1 to 48. Default value: [code]4[/code]. </member> <member name="release_ms" type="float" setter="set_release_ms" getter="get_release_ms"> + Compressor's delay time to stop reducing the signal after the signal level falls below the threshold. Value can range from 20 to 2000. Default value: [code]250ms[/code]. </member> <member name="sidechain" type="String" setter="set_sidechain" getter="get_sidechain"> + Reduce the sound level using another audio bus for threshold detection. </member> <member name="threshold" type="float" setter="set_threshold" getter="get_threshold"> + The level above which compression is applied to the audio. Value can range from -60 to 0. Default value: [code]0[/code]. </member> </members> <constants> diff --git a/doc/classes/AudioEffectDelay.xml b/doc/classes/AudioEffectDelay.xml index 8d317b3c46..9dc61883ab 100644 --- a/doc/classes/AudioEffectDelay.xml +++ b/doc/classes/AudioEffectDelay.xml @@ -1,8 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AudioEffectDelay" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> <brief_description> + Adds a Delay audio effect to an Audio bus. Plays input signal back after a period of time. + Two tap delay and feedback options. </brief_description> <description> + Plays input signal back after a period of time. The delayed signal may be played back multiple times to create the sound of a repeating, decaying echo. Delay effects range from a subtle echo effect to a pronounced blending of previous sounds with new sounds. </description> <tutorials> </tutorials> @@ -194,30 +197,43 @@ </methods> <members> <member name="dry" type="float" setter="set_dry" getter="get_dry"> + Output percent of original sound. At 0, only delayed sounds are output. Value can range from 0 to 1. Default value: [code]1[/code]. </member> <member name="feedback/active" type="bool" setter="set_feedback_active" getter="is_feedback_active"> + If [code]true[/code] feedback is enabled. Default value: [code]false[/code]. </member> <member name="feedback/delay_ms" type="float" setter="set_feedback_delay_ms" getter="get_feedback_delay_ms"> + Feedback delay time in milliseconds. Default value: [code]340[/code]. </member> <member name="feedback/level_db" type="float" setter="set_feedback_level_db" getter="get_feedback_level_db"> + Sound level for [code]tap1[/code]. Default value: [code]-6 dB[/code]. </member> <member name="feedback/lowpass" type="float" setter="set_feedback_lowpass" getter="get_feedback_lowpass"> + Low-pass filter for feedback. Frequencies below the Low Cut value are filtered out of the source signal. Default value: [code]16000[/code]. </member> <member name="tap1/active" type="bool" setter="set_tap1_active" getter="is_tap1_active"> + If [code]true[/code], [code]tap1[/code] will be enabled. Default value: [code]true[/code]. </member> <member name="tap1/delay_ms" type="float" setter="set_tap1_delay_ms" getter="get_tap1_delay_ms"> + [b]Tap1[/b] delay time in milliseconds. Default value: [code]250ms[/code]. </member> <member name="tap1/level_db" type="float" setter="set_tap1_level_db" getter="get_tap1_level_db"> + Sound level for [code]tap1[/code]. Default value: [code]-6 dB[/code]. </member> <member name="tap1/pan" type="float" setter="set_tap1_pan" getter="get_tap1_pan"> + Pan position for [code]tap1[/code]. Value can range from -1 (fully left) to 1 (fully right). Default value: [code]0.2[/code]. </member> <member name="tap2/active" type="bool" setter="set_tap2_active" getter="is_tap2_active"> + If [code]true[/code], [code]tap2[/code] will be enabled. Default value: [code]true[/code]. </member> <member name="tap2/delay_ms" type="float" setter="set_tap2_delay_ms" getter="get_tap2_delay_ms"> + [b]Tap2[/b] delay time in milliseconds. Default value: [code]500ms[/code]. </member> <member name="tap2/level_db" type="float" setter="set_tap2_level_db" getter="get_tap2_level_db"> + Sound level for [code]tap2[/code]. Default value: [code]-12 dB[/code]. </member> <member name="tap2/pan" type="float" setter="set_tap2_pan" getter="get_tap2_pan"> + Pan position for [code]tap2[/code]. Value can range from -1 (fully left) to 1 (fully right). Default value: [code]-0.4[/code]. </member> </members> <constants> diff --git a/doc/classes/AudioEffectDistortion.xml b/doc/classes/AudioEffectDistortion.xml index e5c5a3b50e..1a6aa1d2b6 100644 --- a/doc/classes/AudioEffectDistortion.xml +++ b/doc/classes/AudioEffectDistortion.xml @@ -1,8 +1,12 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AudioEffectDistortion" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> <brief_description> + Adds a Distortion audio effect to an Audio bus. + Modify the sound to make it dirty. </brief_description> <description> + Modify the sound and make it dirty. Differents types available : clip, tan, lofi (bit crushing), overdrive, or waveshape. + By distorting the waveform the frequency content change, which will often make the sound "crunchy" or "abrasive". For games, it can simulate sound coming from some saturated device or speaker very efficiently. </description> <tutorials> </tutorials> @@ -82,26 +86,35 @@ </methods> <members> <member name="drive" type="float" setter="set_drive" getter="get_drive"> + Distortion power. Value can range from 0 to 1. Default value: [code]0[/code]. </member> <member name="keep_hf_hz" type="float" setter="set_keep_hf_hz" getter="get_keep_hf_hz"> + High-pass filter. Frequencies higher than this value will not be affected by the distortion. Value can range from 1 to 20000. Default value: [code]16000[/code]. </member> <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="AudioEffectDistortion.Mode"> + Distortion type. Default value: [code]MODE_CLIP[/code]. </member> <member name="post_gain" type="float" setter="set_post_gain" getter="get_post_gain"> + Increases or decreases the volume after the effect. Value can range from -80 to 24. Default value: [code]0[/code]. </member> <member name="pre_gain" type="float" setter="set_pre_gain" getter="get_pre_gain"> + Increases or decreases the volume before the effect. Value can range from -60 to 60. Default value: [code]0[/code]. </member> </members> <constants> <constant name="MODE_CLIP" value="0"> + Digital distortion effect which cuts off peaks at the top and bottom of the waveform. </constant> <constant name="MODE_ATAN" value="1"> </constant> <constant name="MODE_LOFI" value="2"> + Low-resolution digital distortion effect. You can use it to emulate the sound of early digital audio devices. </constant> <constant name="MODE_OVERDRIVE" value="3"> + Emulates the warm distortion produced by a field effect transistor, which is commonly used in solid-state musical instrument amplifiers. </constant> <constant name="MODE_WAVESHAPE" value="4"> + Waveshaper distortions are used mainly by electronic musicians to achieve an extra-abrasive sound. </constant> </constants> </class> diff --git a/doc/classes/AudioEffectEQ.xml b/doc/classes/AudioEffectEQ.xml index 94d5c696c3..246f6b882e 100644 --- a/doc/classes/AudioEffectEQ.xml +++ b/doc/classes/AudioEffectEQ.xml @@ -1,8 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AudioEffectEQ" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> <brief_description> + Base class for audio equalizers. Gives you control over frequencies. + Use it to create a custom equalizer if [AudioEffectEQ6], [AudioEffectEQ10] or [AudioEffectEQ21] don't fit your needs. </brief_description> <description> + AudioEffectEQ gives you control over frequencies. Use it to compensate for existing deficiencies in audio. AudioEffectEQ are very useful on the Master Bus to completely master a mix and give it character. They are also very useful when a game is run on a mobile device, to adjust the mix to that kind of speakers (it can be added but disabled when headphones are plugged). </description> <tutorials> </tutorials> @@ -13,6 +16,7 @@ <return type="int"> </return> <description> + Returns the number of bands of the equalizer. </description> </method> <method name="get_band_gain_db" qualifiers="const"> @@ -21,6 +25,7 @@ <argument index="0" name="band_idx" type="int"> </argument> <description> + Returns the band's gain at the specified index, in dB. </description> </method> <method name="set_band_gain_db"> @@ -31,6 +36,7 @@ <argument index="1" name="volume_db" type="float"> </argument> <description> + Sets band's gain at the specified index, in dB. </description> </method> </methods> diff --git a/doc/classes/AudioEffectEQ10.xml b/doc/classes/AudioEffectEQ10.xml index 004236dfde..7a29f4cc0b 100644 --- a/doc/classes/AudioEffectEQ10.xml +++ b/doc/classes/AudioEffectEQ10.xml @@ -1,8 +1,23 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AudioEffectEQ10" inherits="AudioEffectEQ" category="Core" version="3.0.alpha.custom_build"> <brief_description> + Adds a 10-band equalizer audio effect to an Audio bus. Gives you control over frequencies from 31 Hz to 16000 Hz. + Each frequency can be modulated between -60/+24 dB. </brief_description> <description> + Frequency bands : + Band 1 : 31 Hz + Band 2 : 62 Hz + Band 3 : 125 Hz + Band 4 : 250 Hz + Band 5 : 500 Hz + Band 6 : 1000 Hz + Band 7 : 2000 Hz + Band 8 : 4000 Hz + Band 9 : 8000 Hz + Band 10 : 16000 Hz + + See also [AudioEffectEQ], [AudioEffectEQ6], [AudioEffectEQ21]. </description> <tutorials> </tutorials> diff --git a/doc/classes/AudioEffectEQ21.xml b/doc/classes/AudioEffectEQ21.xml index e4faa9bb0c..327f5a291a 100644 --- a/doc/classes/AudioEffectEQ21.xml +++ b/doc/classes/AudioEffectEQ21.xml @@ -1,8 +1,34 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AudioEffectEQ21" inherits="AudioEffectEQ" category="Core" version="3.0.alpha.custom_build"> <brief_description> + Adds a 21-band equalizer audio effect to an Audio bus. Gives you control over frequencies from 22 Hz to 22000 Hz. + Each frequency can be modulated between -60/+24 dB. </brief_description> <description> + Frequency bands : + Band 1 : 22 Hz + Band 2 : 32 Hz + Band 3 : 44 Hz + Band 4 : 63 Hz + Band 5 : 90 Hz + Band 6 : 125 Hz + Band 7 : 175 Hz + Band 8 : 250 Hz + Band 9 : 350 Hz + Band 10 : 500 Hz + Band 11 : 700 Hz + Band 12 : 1000 Hz + Band 13 : 1400 Hz + Band 14 : 2000 Hz + Band 15 : 2800 Hz + Band 16 : 4000 Hz + Band 17 : 5600 Hz + Band 18 : 8000 Hz + Band 19 : 11000 Hz + Band 20 : 16000 Hz + Band 21 : 22000 Hz + + See also [AudioEffectEQ], [AudioEffectEQ6], [AudioEffectEQ10]. </description> <tutorials> </tutorials> diff --git a/doc/classes/AudioEffectEQ6.xml b/doc/classes/AudioEffectEQ6.xml index b74cc5d285..bc05535041 100644 --- a/doc/classes/AudioEffectEQ6.xml +++ b/doc/classes/AudioEffectEQ6.xml @@ -1,8 +1,19 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AudioEffectEQ6" inherits="AudioEffectEQ" category="Core" version="3.0.alpha.custom_build"> <brief_description> + Adds a 6-band equalizer audio effect to an Audio bus. Gives you control over frequencies from 32 Hz to 10000 Hz. + Each frequency can be modulated between -60/+24 dB. </brief_description> <description> + Frequency bands : + Band 1 : 32 Hz + Band 2 : 100 Hz + Band 3 : 320 Hz + Band 4 : 1000 Hz + Band 5 : 3200 Hz + Band 6 : 10000 Hz + + See also [AudioEffectEQ], [AudioEffectEQ10], [AudioEffectEQ21]. </description> <tutorials> </tutorials> diff --git a/doc/classes/AudioEffectLimiter.xml b/doc/classes/AudioEffectLimiter.xml index e52fb57c70..5209f290b1 100644 --- a/doc/classes/AudioEffectLimiter.xml +++ b/doc/classes/AudioEffectLimiter.xml @@ -1,8 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AudioEffectLimiter" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> <brief_description> + Adds a soft clip Limiter audio effect to an Audio bus. </brief_description> <description> + A limiter is similar to a compressor, but it’s less flexible and designed to disallow sound going over a given dB threshold. Adding one in the Master Bus is always recommended to reduce the effects of clipping. + Soft clipping starts to reduce the peaks a little below the threshold level and progressively increases its effect as the input level increases such that the threshold is never exceeded. </description> <tutorials> </tutorials> @@ -68,12 +71,15 @@ </methods> <members> <member name="ceiling_db" type="float" setter="set_ceiling_db" getter="get_ceiling_db"> + The waveform's maximum allowed value. Value can range from -20 to -0.1. Default value: [code]-0.1dB[/code]. </member> <member name="soft_clip_db" type="float" setter="set_soft_clip_db" getter="get_soft_clip_db"> + Applies a gain to the limited waves. Value can range from 0 to 6. Default value: [code]2dB[/code]. </member> <member name="soft_clip_ratio" type="float" setter="set_soft_clip_ratio" getter="get_soft_clip_ratio"> </member> <member name="threshold_db" type="float" setter="set_threshold_db" getter="get_threshold_db"> + Threshold from which the limiter begins to be active. Value can range from -30 to 0. Default value: [code]0dB[/code]. </member> </members> <constants> diff --git a/doc/classes/AudioEffectPanner.xml b/doc/classes/AudioEffectPanner.xml index b55d7f91c1..56b39a36c6 100644 --- a/doc/classes/AudioEffectPanner.xml +++ b/doc/classes/AudioEffectPanner.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AudioEffectPanner" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> <brief_description> + Adds a Panner audio effect to an Audio bus. Pans sound left or right. </brief_description> <description> + Determines how much of an audio signal is sent to the left and right buses. </description> <tutorials> </tutorials> @@ -26,6 +28,7 @@ </methods> <members> <member name="pan" type="float" setter="set_pan" getter="get_pan"> + Pan position. Value can range from -1 (fully left) to 1 (fully right). </member> </members> <constants> diff --git a/doc/classes/AudioEffectPhaser.xml b/doc/classes/AudioEffectPhaser.xml index 7e9cd27a47..bd9067471b 100644 --- a/doc/classes/AudioEffectPhaser.xml +++ b/doc/classes/AudioEffectPhaser.xml @@ -1,8 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AudioEffectPhaser" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> <brief_description> + Adds a Phaser audio effect to an Audio bus. + Combines the original signal with a copy that is slightly out of phase with the original. </brief_description> <description> + Combines phase-shifted signals with the original signal. The movement of the phase-shifted signals is controlled using a Low Frequency Oscillator. </description> <tutorials> </tutorials> @@ -82,14 +85,19 @@ </methods> <members> <member name="depth" type="float" setter="set_depth" getter="get_depth"> + Governs how high the filter frequencies sweep. Low value will primarily affect bass frequencies. High value can sweep high into the treble. Value can range from 0.1 to 4. Default value: [code]1[/code]. </member> <member name="feedback" type="float" setter="set_feedback" getter="get_feedback"> + Output percent of modified sound. Value can range from 0.1 to 0.9. Default value: [code]0.7[/code]. </member> <member name="range_max_hz" type="float" setter="set_range_max_hz" getter="get_range_max_hz"> + Determines the maximum frequency affected by the LFO modulations. Value can range from 10 to 10000. Default value: [code]1600hz[/code]. </member> <member name="range_min_hz" type="float" setter="set_range_min_hz" getter="get_range_min_hz"> + Determines the minimum frequency affected by the LFO modulations. Value can range from 10 to 10000. Default value: [code]440hz[/code]. </member> <member name="rate_hz" type="float" setter="set_rate_hz" getter="get_rate_hz"> + Adjusts the rate at which the effect sweeps up and down across the frequency range. </member> </members> <constants> diff --git a/doc/classes/AudioEffectPitchShift.xml b/doc/classes/AudioEffectPitchShift.xml index 6fc3acdc20..edcb54e09e 100644 --- a/doc/classes/AudioEffectPitchShift.xml +++ b/doc/classes/AudioEffectPitchShift.xml @@ -1,8 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AudioEffectPitchShift" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> <brief_description> + Adds a Pitch shift audio effect to an Audio bus. + Raises or lowers the pitch of original sound. </brief_description> <description> + Allows modulation of pitch independently of tempo. All frequencies can be increased/decreased with minimal effect on transients. </description> <tutorials> </tutorials> @@ -26,6 +29,7 @@ </methods> <members> <member name="pitch_scale" type="float" setter="set_pitch_scale" getter="get_pitch_scale"> + Pitch value. Can range from 0 (-1 octave) to 16 (+16 octaves). </member> </members> <constants> diff --git a/doc/classes/AudioEffectReverb.xml b/doc/classes/AudioEffectReverb.xml index b390fa239c..4cda24530b 100644 --- a/doc/classes/AudioEffectReverb.xml +++ b/doc/classes/AudioEffectReverb.xml @@ -1,8 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AudioEffectReverb" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> <brief_description> + Adds a Reverb audio effect to an Audio bus. + Simulates the sound of acoustic environments such as rooms, concert halls, caverns, or an open spaces. </brief_description> <description> + Simulates rooms of different sizes. Its parameters can be adjusted to simulate the sound of a specific room. </description> <tutorials> </tutorials> @@ -124,20 +127,28 @@ </methods> <members> <member name="damping" type="float" setter="set_damping" getter="get_damping"> + Widens or narrows the stereo image of the reverb tail. 1 means fully widens. Value can range from 0 to 1. Default value: [code]1[/code]. </member> <member name="dry" type="float" setter="set_dry" getter="get_dry"> + Output percent of original sound. At 0, only modified sound is outputted. Value can range from 0 to 1. Default value: [code]1[/code]. </member> <member name="hipass" type="float" setter="set_hpf" getter="get_hpf"> + High-pass filter passes signals with a frequency higher than a certain cutoff frequency and attenuates signals with frequencies lower than the cutoff frequency. Value can range from 0 to 1. Default value: [code]0[/code]. </member> <member name="predelay_feedback" type="float" setter="set_predelay_msec" getter="get_predelay_msec"> + Output percent of predelay. Value can range from 0 to 1. Default value: [code]1[/code]. </member> <member name="predelay_msec" type="float" setter="set_predelay_msec" getter="get_predelay_msec"> + Time between the original signal and the early reflections of the reverb signal. Default value: [code]150ms[/code]. </member> <member name="room_size" type="float" setter="set_room_size" getter="get_room_size"> + Dimensions of simulated room. Bigger means more echoes. Value can range from 0 to 1. Default value: [code]0.8[/code]. </member> <member name="spread" type="float" setter="set_spread" getter="get_spread"> + Defines how reflective the imaginary room's walls are. Value can range from 0 to 1. Default value: [code]1[/code]. </member> <member name="wet" type="float" setter="set_wet" getter="get_wet"> + Output percent of modified sound. At 0, only original sound is outputted. Value can range from 0 to 1. Default value: [code]0.5[/code]. </member> </members> <constants> diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index 59c3bd30c7..b3bdd1d6c2 100644 --- a/doc/classes/Control.xml +++ b/doc/classes/Control.xml @@ -1,16 +1,16 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="Control" inherits="CanvasItem" category="Core" version="3.0.alpha.custom_build"> <brief_description> - Base node for all User Interface components. + All User Interface nodes inherit from Control. Features anchors and margins to adapt its position and size to its parent. </brief_description> <description> - The base class Node for all User Interface components. Every UI node inherits from it. Any scene or portion of a scene tree composed of Control nodes is a User Interface. - Controls use anchors and margins to place themselves relative to their parent. They adapt automatically when their parent or the screen size changes. To build flexible UIs, use built-in [Container] nodes or create your own. - Anchors work by defining which margin do they follow, and a value relative to it. Allowed anchoring modes are ANCHOR_BEGIN, where the margin is relative to the top or left margins of the parent (in pixels), ANCHOR_END for the right and bottom margins of the parent and ANCHOR_RATIO, which is a ratio from 0 to 1 in the parent range. - Godot sends Input events to the root node first, via [method Node._input]. The method distributes it through the node tree and delivers the input events to the node under the mouse cursor or on focus with the keyboard. To do so, it calls [method MainLoop._input_event]. No need to enable [method Node.set_process_input] on Controls to receive input events. Call [method accept_event] to ensure no other node receives the event, not even [method Node._unhandled_input]. - Only the one Control node in focus receives keyboard events. To do so, the Control must get the focus mode with [method set_focus_mode]. It loses focus when another Control gets it, or if the current Control in focus is hidden. - You'll sometimes want Controls to ignore mouse or touch events. For example, if you place an icon on top of a button. Call [method set_ignore_mouse] for that. - [Theme] resources change the Control's appearance. If you change the [Theme] on a parent Control node, it will propagate to all of its children. You can override parts of the theme on each Control with the add_*_override methods, like [method add_font_override]. You can also override the theme from the editor. + Base class for all User Interface or [i]UI[/i] related nodes. [code]Control[/code] features a bounding rectangle that defines its extents, an anchor position relative to its parent and margins that represent an offset to the anchor. The margins update automatically when the node, any of its parents, or the screen size change. + For more information on Godot's UI system, anchors, margins, and containers, see the related tutorials in the manual. To build flexible UIs, you'll need a mix of UI elements that inherit from [code]Control[/code] and [Container] nodes. + [b]User Interface nodes and input[/b] + Godot sends input events to the scene's root node first, by calling [method Node._input]. [method Node._input] forwards the event down the node tree to the nodes under the mouse cursor, or on keyboard focus. To do so, it calls [method MainLoop._input_event]. Call [method accept_event] so no other node receives the event. Once you accepted an input, it becomes handled so [method Node._unhandled_input] will not process it. + Only one [code]Control[/code] node can be in keyboard focus. Only the node in focus will receive keyboard events. To get the foucs, call [method set_focus_mode]. [code]Control[/code] nodes lose focus when another node grabs it, or if you hide the node in focus. + Call [method set_ignore_mouse] to tell a [code]Control[/code] node to ignore mouse or touch events. You'll need it if you place an icon on top of a button. + [Theme] resources change the Control's appearance. If you change the [Theme] on a [code]Control[/code] node, it affects all of its children. To override some of the theme's parameters, call one of the [code]add_*_override[/code] methods, like [method add_font_override]. You can override the theme with the inspector. </description> <tutorials> </tutorials> @@ -21,7 +21,7 @@ <return type="Vector2"> </return> <description> - Returns the minimum size this Control can shrink to. A control will never be displayed or resized smaller than its minimum size. + Returns the minimum size this Control can shrink to. The node can never be smaller than this minimum size. </description> </method> <method name="_gui_input" qualifiers="virtual"> @@ -30,13 +30,15 @@ <argument index="0" name="event" type="InputEvent"> </argument> <description> + The node's parent forwards input events to this method. Use it to process and accept inputs on UI elements. See [method accept_event]. + Replaces Godot 2's [code]_input_event[/code]. </description> </method> <method name="accept_event"> <return type="void"> </return> <description> - Marks the input event as handled. No other Control will receive it, and the input event will not propagate. Not even to nodes listening to [method Node._unhandled_input] or [method Node._unhandled_key_input]. + Marks an input event as handled. Once you accept an input event, it stops propagating, even to nodes listening to [method Node._unhandled_input] or [method Node._unhandled_key_input]. </description> </method> <method name="add_color_override"> @@ -47,6 +49,7 @@ <argument index="1" name="color" type="Color"> </argument> <description> + Overrides the color in the [theme] resource the node uses. </description> </method> <method name="add_constant_override"> @@ -57,7 +60,7 @@ <argument index="1" name="constant" type="int"> </argument> <description> - Override a single constant (integer) in the theme of this Control. If constant equals Theme.INVALID_CONSTANT, override is cleared. + Overrides an integer constant in the [theme] resource the node uses. If the [code]constant[code] is invalid, Godot clears the override. See [member Theme.INVALID_CONSTANT] for more information. </description> </method> <method name="add_font_override"> @@ -68,7 +71,7 @@ <argument index="1" name="font" type="Font"> </argument> <description> - Override a single font (font) in the theme of this Control. If font is empty, override is cleared. + Overrides the [code]name[/code] font in the [theme] resource the node uses. If [code]font[/code] is empty, Godot clears the override. </description> </method> <method name="add_icon_override"> @@ -79,7 +82,7 @@ <argument index="1" name="texture" type="Texture"> </argument> <description> - Override a single icon ([Texture]) in the theme of this Control. If texture is empty, override is cleared. + Overrides the [code]name[/code] icon in the [theme] resource the node uses. If [code]icon[/code] is empty, Godot clears the override. </description> </method> <method name="add_shader_override"> @@ -90,6 +93,7 @@ <argument index="1" name="shader" type="Shader"> </argument> <description> + Overrides the [code]name[/code] shader in the [theme] resource the node uses. If [code]shader[/code] is empty, Godot clears the override. </description> </method> <method name="add_style_override"> @@ -100,7 +104,7 @@ <argument index="1" name="stylebox" type="StyleBox"> </argument> <description> - Override a single stylebox ([Stylebox]) in the theme of this Control. If stylebox is empty, override is cleared. + Overrides the [code]name[/code] [Stylebox] in the [theme] resource the node uses. If [code]stylebox[/code] is empty, Godot clears the override. </description> </method> <method name="can_drop_data" qualifiers="virtual"> @@ -180,7 +184,7 @@ <argument index="0" name="position" type="Vector2" default="Vector2( 0, 0 )"> </argument> <description> - Return the cursor shape at a certain position in the control. + Returns the mouse cursor shape the control displays on mouse hover, one of the [code]CURSOR_*[/code] constants. </description> </method> <method name="get_custom_minimum_size" qualifiers="const"> @@ -193,7 +197,7 @@ <return type="int" enum="Control.CursorShape"> </return> <description> - Return the default cursor shape for this control. See enum CURSOR_* for the list of shapes. + Returns the default cursor shape for this control. See enum [code]CURSOR_*[/code] for the list of shapes. </description> </method> <method name="get_drag_data" qualifiers="virtual"> @@ -624,7 +628,7 @@ <argument index="0" name="shape" type="int" enum="Control.CursorShape"> </argument> <description> - Set the default cursor shape for this control. See enum CURSOR_* for the list of shapes. + Sets the default cursor shape for this control. See [code]CURSOR_*[/code] for the list of available cursor shapes. Useful for Godot plugins and applications or games that use the system's mouse cursors. </description> </method> <method name="set_drag_forwarding"> @@ -785,7 +789,7 @@ <argument index="0" name="theme" type="Theme"> </argument> <description> - Override whole the [Theme] for this Control and all its children controls. + Overrides the whole [Theme] for this node and all its [code]Control[/code] children. </description> </method> <method name="set_tooltip"> @@ -794,7 +798,7 @@ <argument index="0" name="tooltip" type="String"> </argument> <description> - Set a tooltip, which will appear when the cursor is resting over this control. + Changes the tooltip text. The tooltip appears when the user's mouse cursor stays idle over this control for a few moments. </description> </method> <method name="set_v_grow_direction"> @@ -834,58 +838,83 @@ </methods> <members> <member name="anchor_bottom" type="float" setter="_set_anchor" getter="get_anchor"> + Anchors the bottom edge of the node to the origin, the center, or the end of its parent container. It changes how the bottom margin updates when the node moves or changes size. Use one of the [code]ANCHOR_*[/code] constants. Default value: [code]ANCHOR_BEGIN[/code]. </member> <member name="anchor_left" type="float" setter="_set_anchor" getter="get_anchor"> + Anchors the left edge of the node to the origin, the center or the end of its parent container. It changes how the left margin updates when the node moves or changes size. Use one of the [code]ANCHOR_*[/code] constants. Default value: [code]ANCHOR_BEGIN[/code]. </member> <member name="anchor_right" type="float" setter="_set_anchor" getter="get_anchor"> + Anchors the right edge of the node to the origin, the center or the end of its parent container. It changes how the right margin updates when the node moves or changes size. Use one of the [code]ANCHOR_*[/code] constants. Default value: [code]ANCHOR_BEGIN[/code]. </member> <member name="anchor_top" type="float" setter="_set_anchor" getter="get_anchor"> + Anchors the top edge of the node to the origin, the center or the end of its parent container. It changes how the top margin updates when the node moves or changes size. Use one of the [code]ANCHOR_*[/code] constants. Default value: [code]ANCHOR_BEGIN[/code]. </member> <member name="focus_neighbour_bottom" type="NodePath" setter="set_focus_neighbour" getter="get_focus_neighbour"> + Tells Godot which node it should give keyboard focus to if the user presses Tab, the down arrow on the keyboard, or down on a gamepad. The node must be a [code]Control[/code]. If this property is not set, Godot will give focus to the closest [code]Control[/code] to the bottom of this one. + If the user presses Tab, Godot will give focus to the closest node to the right first, then to the bottom. If the user presses Shift+Tab, Godot will look to the left of the node, then above it. </member> <member name="focus_neighbour_left" type="NodePath" setter="set_focus_neighbour" getter="get_focus_neighbour"> + Tells Godot which node it should give keyboard focus to if the user presses Shift+Tab, the left arrow on the keyboard or left on a gamepad. The node must be a [code]Control[/code]. If this property is not set, Godot will give focus to the closest [code]Control[/code] to the left of this one. </member> <member name="focus_neighbour_right" type="NodePath" setter="set_focus_neighbour" getter="get_focus_neighbour"> + Tells Godot which node it should give keyboard focus to if the user presses Tab, the right arrow on the keyboard or right on a gamepad. The node must be a [code]Control[/code]. If this property is not set, Godot will give focus to the closest [code]Control[/code] to the bottom of this one. </member> <member name="focus_neighbour_top" type="NodePath" setter="set_focus_neighbour" getter="get_focus_neighbour"> + Tells Godot which node it should give keyboard focus to if the user presses Shift+Tab, the top arrow on the keyboard or top on a gamepad. The node must be a [code]Control[/code]. If this property is not set, Godot will give focus to the closest [code]Control[/code] to the bottom of this one. </member> <member name="grow_horizontal" type="int" setter="set_h_grow_direction" getter="get_h_grow_direction" enum="Control.GrowDirection"> </member> <member name="grow_vertical" type="int" setter="set_v_grow_direction" getter="get_v_grow_direction" enum="Control.GrowDirection"> </member> <member name="hint_tooltip" type="String" setter="set_tooltip" getter="_get_tooltip"> + Changes the tooltip text. The tooltip appears when the user's mouse cursor stays idle over this control for a few moments. </member> <member name="margin_bottom" type="float" setter="set_margin" getter="get_margin"> + Distance between the node's bottom edge and its parent container, based on [member anchor_bottom]. + Margins are often controlled by one or multiple parent [Container] nodes. Margins update automatically when you move or resize the node. </member> <member name="margin_left" type="float" setter="set_margin" getter="get_margin"> + Distance between the node's left edge and its parent container, based on [member anchor_left]. </member> <member name="margin_right" type="float" setter="set_margin" getter="get_margin"> + Distance between the node's right edge and its parent container, based on [member anchor_right]. </member> <member name="margin_top" type="float" setter="set_margin" getter="get_margin"> + Distance between the node's top edge and its parent container, based on [member anchor_top]. </member> <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" enum="Control.MouseFilter"> </member> <member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents"> </member> <member name="rect_min_size" type="Vector2" setter="set_custom_minimum_size" getter="get_custom_minimum_size"> + The minimum size of the node's bounding rectangle. If you set it to a value greater than (0, 0), the node's bounding rectangle will always have at least this size, even if its content is smaller. If it's set to (0, 0), the node sizes automatically to fit its content, be it a texture or child nodes. </member> <member name="rect_pivot_offset" type="Vector2" setter="set_pivot_offset" getter="get_pivot_offset"> + By default, the node's pivot is its top-left corner. When you change its [member rect_scale], it will scale around this pivot. Set this property to [member rect_size] / 2 to center the pivot in the node's rectangle. </member> <member name="rect_position" type="Vector2" setter="set_position" getter="get_position"> + The node's position, relative to its parent. It corresponds to the rectangle's top-left corner. The property is not affected by [member rect_pivot_offset]. </member> <member name="rect_rotation" type="float" setter="set_rotation_deg" getter="get_rotation_deg"> + The node's rotation around its pivot, in degrees. See [member rect_pivot_offset] to change the pivot's position. </member> <member name="rect_scale" type="Vector2" setter="set_scale" getter="get_scale"> + The node's scale, relative to its [member rect_size]. Change this property to scale the node around its [member rect_pivot_offset]. </member> <member name="rect_size" type="Vector2" setter="set_size" getter="get_size"> + The size of the node's bounding rectangle, in pixels. [Container] nodes update this property automatically. </member> <member name="size_flags_horizontal" type="int" setter="set_h_size_flags" getter="get_h_size_flags"> + Tells the parent [Container] nodes how they should resize and place the node on the X axis. Use one of the [code]SIZE_*[/code] constants to change the flags. See the constants to learn what each does. </member> <member name="size_flags_stretch_ratio" type="float" setter="set_stretch_ratio" getter="get_stretch_ratio"> + If the node and at least one of its neighbours uses the [code]SIZE_EXPAND[/code] size flag, the parent [Container] will let it take more or less space depending on this property. If this node has a stretch ratio of 2 and its neighbour a ratio of 1, this node will take two thirds of the available space. </member> <member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags"> + Tells the parent [Container] nodes how they should resize and place the node on the Y axis. Use one of the [code]SIZE_*[/code] constants to change the flags. See the constants to learn what each does. </member> <member name="theme" type="Theme" setter="set_theme" getter="get_theme"> + Changing this property replaces the current [Theme] resource this node and all its [code]Control[/code] children use. </member> </members> <signals> @@ -903,6 +932,7 @@ <argument index="0" name="ev" type="Object"> </argument> <description> + Emitted when the node receives an [InputEvent]. </description> </signal> <signal name="minimum_size_changed"> @@ -912,16 +942,17 @@ </signal> <signal name="modal_closed"> <description> + Emitted when a modal [code]Control[/code] is closed. See [method show_modal]. </description> </signal> <signal name="mouse_entered"> <description> - Emitted when the mouse enters the control's area. + Emitted when the mouse enters the control's [code]Rect[/code] area. </description> </signal> <signal name="mouse_exited"> <description> - Emitted when the mouse leaves the control's area. + Emitted when the mouse leaves the control's [code]Rect[/code] area. </description> </signal> <signal name="resized"> @@ -931,116 +962,154 @@ </signal> <signal name="size_flags_changed"> <description> - Emitted when the size flags change. + Emitted when one of the size flags changes. See [member size_flags_horizontal] and [member size_flags_vertical]. </description> </signal> </signals> <constants> <constant name="FOCUS_NONE" value="0"> - Control can't acquire focus. + The node cannot grab focus. Use with [member set_focus_mode]. </constant> <constant name="FOCUS_CLICK" value="1"> - Control can acquire focus only if clicked. + The node can only grab focus on mouse clicks. Use with [member set_focus_mode]. </constant> <constant name="FOCUS_ALL" value="2"> - Control can acquire focus if clicked, or by pressing TAB/Directionals in the keyboard from another Control. + The node can grab focus on mouse click or using the arrows and the Tab keys on the keyboard. Use with [member set_focus_mode]. </constant> <constant name="NOTIFICATION_RESIZED" value="40" enum=""> - Control changed size (get_size() reports the new size). + Sent when the node changes size. Use [member rect_size] to get the new size. </constant> <constant name="NOTIFICATION_MOUSE_ENTER" value="41" enum=""> - Mouse pointer entered the area of the Control. + Sent when the mouse pointer enters the node's [code]Rect[/code] area. </constant> <constant name="NOTIFICATION_MOUSE_EXIT" value="42" enum=""> - Mouse pointer exited the area of the Control. + Sent when the mouse pointer exits the node's [code]Rect[/code] area. </constant> <constant name="NOTIFICATION_FOCUS_ENTER" value="43" enum=""> - Control gained focus. + Sent when the node grabs focus. </constant> <constant name="NOTIFICATION_FOCUS_EXIT" value="44" enum=""> - Control lost focus. + Sent when the node loses focus. </constant> <constant name="NOTIFICATION_THEME_CHANGED" value="45" enum=""> - Theme changed. Redrawing is desired. + Sent when the node's [member theme] changes, right before Godot redraws the [code]Control[/code]. Happens when you call one of the [code]add_*_override[/code] </constant> <constant name="NOTIFICATION_MODAL_CLOSE" value="46" enum=""> - Modal control was closed. + Sent when an open modal dialog closes. See [member show_modal]. </constant> <constant name="CURSOR_ARROW" value="0"> + Show the system's arrow mouse cursor when the user hovers the node. Use with [method set_default_cursor_shape]. </constant> <constant name="CURSOR_IBEAM" value="1"> + Show the system's I-beam mouse cursor when the user hovers the node. The I-beam pointer has a shape similar to "I". It tells the user they can highlight or insert text. </constant> <constant name="CURSOR_POINTING_HAND" value="2"> + Show the system's pointing hand mouse cursor when the user hovers the node. </constant> <constant name="CURSOR_CROSS" value="3"> + Show the system's cross mouse cursor when the user hovers the node. </constant> <constant name="CURSOR_WAIT" value="4"> + Show the system's wait mouse cursor, often an hourglass, when the user hovers the node. </constant> <constant name="CURSOR_BUSY" value="5"> + Show the system's busy mouse cursor when the user hovers the node. Often an hourglass. </constant> <constant name="CURSOR_DRAG" value="6"> + Show the system's drag mouse cursor, often a closed fist or a cross symbol, when the user hovers the node. It tells the user they're currently dragging an item, like a node in the Scene dock. </constant> <constant name="CURSOR_CAN_DROP" value="7"> + Show the system's drop mouse cursor when the user hovers the node. It can be an open hand. It tells the user they can drop an item they're currently grabbing, like a node in the Scene dock. </constant> <constant name="CURSOR_FORBIDDEN" value="8"> + Show the system's forbidden mouse cursor when the user hovers the node. Often a crossed circle. </constant> <constant name="CURSOR_VSIZE" value="9"> + Show the system's vertical resize mouse cursor when the user hovers the node. A double headed vertical arrow. It tells the user they can resize the window or the panel vertically. </constant> <constant name="CURSOR_HSIZE" value="10"> + Show the system's horizontal resize mouse cursor when the user hovers the node. A double headed horizontal arrow. It tells the user they can resize the window or the panel horizontally. </constant> <constant name="CURSOR_BDIAGSIZE" value="11"> + Show the system's window resize mouse cursor when the user hovers the node. The cursor is a double headed arrow that goes from the bottom left to the top right. It tells the user they can resize the window or the panel both horizontally and vertically. </constant> <constant name="CURSOR_FDIAGSIZE" value="12"> + Show the system's window resize mouse cursor when the user hovers the node. The cursor is a double headed arrow that goes from the top left to the bottom right, the opposite of [code]CURSOR_BDIAGSIZE[/code]. It tells the user they can resize the window or the panel both horizontally and vertically. </constant> <constant name="CURSOR_MOVE" value="13"> + Show the system's move mouse cursor when the user hovers the node. It shows 2 double-headed arrows at a 90 degree angle. It tells the user they can move a UI element freely. </constant> <constant name="CURSOR_VSPLIT" value="14"> + Show the system's vertical split mouse cursor when the user hovers the node. On Windows, it's the same as [code]CURSOR_VSIZE[/code]. </constant> <constant name="CURSOR_HSPLIT" value="15"> + Show the system's horizontal split mouse cursor when the user hovers the node. On Windows, it's the same as [code]CURSOR_HSIZE[/code]. </constant> <constant name="CURSOR_HELP" value="16"> + Show the system's help mouse cursor when the user hovers the node, a question mark. </constant> <constant name="PRESET_TOP_LEFT" value="0"> + Snap all 4 anchors to the top-left of the parent container's bounds. Use with [method set_anchors_preset]. </constant> <constant name="PRESET_TOP_RIGHT" value="1"> + Snap all 4 anchors to the top-right of the parent container's bounds. Use with [method set_anchors_preset]. </constant> <constant name="PRESET_BOTTOM_LEFT" value="2"> + Snap all 4 anchors to the bottom-left of the parent container's bounds. Use with [method set_anchors_preset]. </constant> <constant name="PRESET_BOTTOM_RIGHT" value="3"> + Snap all 4 anchors to the bottom-right of the parent container's bounds. Use with [method set_anchors_preset]. </constant> <constant name="PRESET_CENTER_LEFT" value="4"> + Snap all 4 anchors to the center of the left edge of the parent container's bounds. Use with [method set_anchors_preset]. </constant> <constant name="PRESET_CENTER_TOP" value="5"> + Snap all 4 anchors to the center of the top edge of the parent container's bounds. Use with [method set_anchors_preset]. </constant> <constant name="PRESET_CENTER_RIGHT" value="6"> + Snap all 4 anchors to the center of the right edge of the parent container's bounds. Use with [method set_anchors_preset]. </constant> <constant name="PRESET_CENTER_BOTTOM" value="7"> + Snap all 4 anchors to the center of the bottom edge of the parent container's bounds. Use with [method set_anchors_preset]. </constant> <constant name="PRESET_CENTER" value="8"> + Snap all 4 anchors to the center of the parent container's bounds. Use with [method set_anchors_preset]. </constant> <constant name="PRESET_LEFT_WIDE" value="9"> + Snap all 4 anchors to the left edge of the parent container. The left margin becomes relative to the left edge and the top margin relative to the top left corner of the node's parent. Use with [method set_anchors_preset]. </constant> <constant name="PRESET_TOP_WIDE" value="10"> + Snap all 4 anchors to the top edge of the parent container. The left margin becomes relative to the top left corner, the top margin relative to the top edge, and the right margin relative to the top right corner of the node's parent. Use with [method set_anchors_preset]. </constant> <constant name="PRESET_RIGHT_WIDE" value="11"> + Snap all 4 anchors to the right edge of the parent container. The right margin becomes relative to the right edge and the top margin relative to the top right corner of the node's parent. Use with [method set_anchors_preset]. </constant> <constant name="PRESET_BOTTOM_WIDE" value="12"> + Snap all 4 anchors to the bottom edge of the parent container. The left margin becomes relative to the bottom left corner, the bottom margin relative to the bottom edge, and the right margin relative to the bottom right corner of the node's parent. Use with [method set_anchors_preset]. </constant> <constant name="PRESET_VCENTER_WIDE" value="13"> + Snap all 4 anchors to a vertical line that cuts the parent container in half. Use with [method set_anchors_preset]. </constant> <constant name="PRESET_HCENTER_WIDE" value="14"> + Snap all 4 anchors to a horizontal line that cuts the parent container in half. Use with [method set_anchors_preset]. </constant> <constant name="PRESET_WIDE" value="15"> + Snap all 4 anchors to the respective corners of the parent container. Set all 4 margins to 0 after you applied this preset and the [code]Control[/code] will fit its parent container. Use with [method set_anchors_preset]. </constant> <constant name="SIZE_EXPAND" value="2"> + Tells the parent [Container] to let this node take all the available space on the axis you flag. If multiple neighboring nodes are set to expand, they'll share the space based on their stretch ratio. See [member size_flags_stretch_ratio]. Use with [member size_flags_horizontal] and [member size_flags_vertical]. </constant> <constant name="SIZE_FILL" value="1"> + Tells the parent [Container] to expand the bounds of this node to fill all the available space without pushing any other node. Use with [member size_flags_horizontal] and [member size_flags_vertical]. </constant> <constant name="SIZE_EXPAND_FILL" value="3"> + Sets the node's size flags to both fill and expand. See the 2 constants above for more information. </constant> <constant name="SIZE_SHRINK_CENTER" value="4"> + Tells the parent [Container] to center the node in itself. It centers the [code]Control[/code] based on its bounding box, so it doesn't work with the fill or expand size flags. Use with [member size_flags_horizontal] and [member size_flags_vertical]. </constant> <constant name="SIZE_SHRINK_END" value="8"> + Tells the parent [Container] to align the node with its end, either the bottom or the right edge. It doesn't work with the fill or expand size flags. Use with [member size_flags_horizontal] and [member size_flags_vertical]. </constant> <constant name="MOUSE_FILTER_STOP" value="0"> </constant> @@ -1053,10 +1122,10 @@ <constant name="GROW_DIRECTION_END" value="1"> </constant> <constant name="ANCHOR_BEGIN" value="0"> - X is relative to MARGIN_LEFT, Y is relative to MARGIN_TOP. + Snaps one of the 4 anchor's sides to the origin of the node's [code]Rect[/code], in the top left. Use it with one of the [code]anchor_*[/code] member variables, like [member anchor_left]. To change all 4 anchors at once, use [method set_anchors_preset]. </constant> <constant name="ANCHOR_END" value="1"> - X is relative to -MARGIN_RIGHT, Y is relative to -MARGIN_BOTTOM. + Snaps one of the 4 anchor's sides to the end of the node's [code]Rect[/code], in the bottom right. Use it with one of the [code]anchor_*[/code] member variables, like [member anchor_left]. To change all 4 anchors at once, use [method set_anchors_preset]. </constant> </constants> </class> diff --git a/doc/classes/EditorResourcePreview.xml b/doc/classes/EditorResourcePreview.xml index e530557a23..acf36b6a08 100644 --- a/doc/classes/EditorResourcePreview.xml +++ b/doc/classes/EditorResourcePreview.xml @@ -41,7 +41,7 @@ <argument index="3" name="userdata" type="Variant"> </argument> <description> - Queue a resource being edited for preview (using an instance). Once the preview is ready, your receiver.receiver_func will be called either containing the preview texture or an empty texure (if no preview was possible). Callback must have the format: (path,texture,userdata). Userdata can be anything. + Queue a resource being edited for preview (using an instance). Once the preview is ready, your receiver.receiver_func will be called either containing the preview texture or an empty texture (if no preview was possible). Callback must have the format: (path,texture,userdata). Userdata can be anything. </description> </method> <method name="queue_resource_preview"> @@ -56,7 +56,7 @@ <argument index="3" name="userdata" type="Variant"> </argument> <description> - Queue a resource file for preview (using a path). Once the preview is ready, your receiver.receiver_func will be called either containing the preview texture or an empty texure (if no preview was possible). Callback must have the format: (path,texture,userdata). Userdata can be anything. + Queue a resource file for preview (using a path). Once the preview is ready, your receiver.receiver_func will be called either containing the preview texture or an empty texture (if no preview was possible). Callback must have the format: (path,texture,userdata). Userdata can be anything. </description> </method> <method name="remove_preview_generator"> diff --git a/doc/classes/ImageTexture.xml b/doc/classes/ImageTexture.xml index 2b74a15fd5..4fcdf684c0 100644 --- a/doc/classes/ImageTexture.xml +++ b/doc/classes/ImageTexture.xml @@ -66,7 +66,7 @@ <argument index="0" name="path" type="String"> </argument> <description> - Load an [ImageTexure]. + Load an [ImageTexture]. </description> </method> <method name="set_data"> diff --git a/doc/classes/JSON.xml b/doc/classes/JSON.xml index a38b2f61cf..8bff140bb4 100644 --- a/doc/classes/JSON.xml +++ b/doc/classes/JSON.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="JSON" inherits="Object" category="Core" version="3.0.alpha.custom_build"> <brief_description> + Helper class for parsing JSON data. </brief_description> <description> + Helper class for parsing JSON data. </description> <tutorials> </tutorials> @@ -15,6 +17,7 @@ <argument index="0" name="json" type="String"> </argument> <description> + Parses a JSON encoded string and returns a [JSONParseResult] containing the result. </description> </method> <method name="print"> @@ -23,6 +26,7 @@ <argument index="0" name="value" type="Variant"> </argument> <description> + Converts a Variant var to JSON text and returns the result. Useful for serializing data to store or send over the network. </description> </method> </methods> diff --git a/doc/classes/JSONParseResult.xml b/doc/classes/JSONParseResult.xml index 6aeb614508..86edaaf1e6 100644 --- a/doc/classes/JSONParseResult.xml +++ b/doc/classes/JSONParseResult.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="JSONParseResult" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> <brief_description> + Data class wrapper for decoded JSON. </brief_description> <description> + Returned by [method JSON.parse], [JSONParseResult] contains decoded JSON or error information if JSON source not successfully parsed. You can check if JSON source was successfully parsed with [code]if json_result.error == 0[/code]. </description> <tutorials> </tutorials> @@ -68,12 +70,24 @@ </methods> <members> <member name="error" type="int" setter="set_error" getter="get_error" enum="Error"> + The error type if JSON source was not successfully parsed. See [@Global Scope]ERR_* constants. </member> <member name="error_line" type="int" setter="set_error_line" getter="get_error_line"> + The line number where the error occurred if JSON source was not successfully parsed. </member> <member name="error_string" type="String" setter="set_error_string" getter="get_error_string"> + The error message if JSON source was not successfully parsed. See [@Global Scope]ERR_* constants. </member> <member name="result" type="Variant" setter="set_result" getter="get_result"> + A [Variant] containing the parsed JSON. Use typeof() to check if it is what you expect. For exemple, if JSON source starts with braces [code]{}[/code] a [Dictionary] will be returned, if JSON source starts with array braces [code][][/code] an [Array] will be returned. + [i]Be aware that the JSON specification does not define integer or float types, but only a number type. Therefore, parsing a JSON text will convert all numerical values to float types.[/i] + [codeblock] + p = JSON.parse('["hello", "world", "!"]') + if typeof(p) == TYPE_ARRAY: + print(p[0]) # prints 'hello' + else: + print("unexpected results") + [/codeblock] </member> </members> <constants> diff --git a/doc/tools/doc_status.py b/doc/tools/doc_status.py index 6b6b794f11..314f890bd7 100644 --- a/doc/tools/doc_status.py +++ b/doc/tools/doc_status.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +import fnmatch import os import sys import re @@ -356,8 +357,13 @@ for file in input_file_list: class_names.sort() if len(input_class_list) < 1: - input_class_list = class_names + input_class_list = ['*'] +filtered_classes = set() +for pattern in input_class_list: + filtered_classes |= set(fnmatch.filter(class_names, pattern)) +filtered_classes = list(filtered_classes) +filtered_classes.sort() ################################################################################ # Make output table # @@ -369,10 +375,7 @@ table_column_chars = '|' total_status = ClassStatus('Total') -for cn in input_class_list: - if not cn in classes: - print('Cannot find class ' + cn + '!') - sys.exit(255) +for cn in filtered_classes: c = classes[cn] validate_tag(c, 'class') diff --git a/drivers/SCsub b/drivers/SCsub index 195f7ec438..34d6254578 100644 --- a/drivers/SCsub +++ b/drivers/SCsub @@ -13,6 +13,7 @@ SConscript('windows/SCsub') # Sounds drivers SConscript('alsa/SCsub') +SConscript('coreaudio/SCsub') SConscript('pulseaudio/SCsub') if (env["platform"] == "windows"): SConscript("rtaudio/SCsub") diff --git a/drivers/coreaudio/SCsub b/drivers/coreaudio/SCsub new file mode 100644 index 0000000000..233593b0f9 --- /dev/null +++ b/drivers/coreaudio/SCsub @@ -0,0 +1,8 @@ +#!/usr/bin/env python + +Import('env') + +# Driver source files +env.add_source_files(env.drivers_sources, "*.cpp") + +Export('env') diff --git a/platform/osx/audio_driver_osx.cpp b/drivers/coreaudio/audio_driver_coreaudio.cpp index 3b3ba60507..c531d6af9d 100644 --- a/platform/osx/audio_driver_osx.cpp +++ b/drivers/coreaudio/audio_driver_coreaudio.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* audio_driver_osx.cpp */ +/* audio_driver_coreaudio.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,27 +27,33 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifdef OSX_ENABLED +#ifdef COREAUDIO_ENABLED -#include "audio_driver_osx.h" +#include "audio_driver_coreaudio.h" #include "core/project_settings.h" #include "os/os.h" #define kOutputBus 0 +#ifdef OSX_ENABLED static OSStatus outputDeviceAddressCB(AudioObjectID inObjectID, UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses, void *__nullable inClientData) { - AudioDriverOSX *driver = (AudioDriverOSX *)inClientData; + AudioDriverCoreAudio *driver = (AudioDriverCoreAudio *)inClientData; driver->reopen(); return noErr; } +#endif -Error AudioDriverOSX::initDevice() { +Error AudioDriverCoreAudio::initDevice() { AudioComponentDescription desc; zeromem(&desc, sizeof(desc)); desc.componentType = kAudioUnitType_Output; +#ifdef OSX_ENABLED desc.componentSubType = kAudioUnitSubType_HALOutput; +#else + desc.componentSubType = kAudioUnitSubType_RemoteIO; +#endif desc.componentManufacturer = kAudioUnitManufacturer_Apple; AudioComponent comp = AudioComponentFindNext(NULL, &desc); @@ -96,8 +102,10 @@ Error AudioDriverOSX::initDevice() { // Sample rate is independent of channels (ref: https://stackoverflow.com/questions/11048825/audio-sample-frequency-rely-on-channels) buffer_frames = closest_power_of_2(latency * mix_rate / 1000); +#ifdef OSX_ENABLED result = AudioUnitSetProperty(audio_unit, kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Global, kOutputBus, &buffer_frames, sizeof(UInt32)); ERR_FAIL_COND_V(result != noErr, FAILED); +#endif buffer_size = buffer_frames * channels; samples_in.resize(buffer_size); @@ -109,7 +117,7 @@ Error AudioDriverOSX::initDevice() { AURenderCallbackStruct callback; zeromem(&callback, sizeof(AURenderCallbackStruct)); - callback.inputProc = &AudioDriverOSX::output_callback; + callback.inputProc = &AudioDriverCoreAudio::output_callback; callback.inputProcRefCon = this; result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, kOutputBus, &callback, sizeof(callback)); ERR_FAIL_COND_V(result != noErr, FAILED); @@ -120,7 +128,7 @@ Error AudioDriverOSX::initDevice() { return OK; } -Error AudioDriverOSX::finishDevice() { +Error AudioDriverCoreAudio::finishDevice() { OSStatus result; if (active) { @@ -136,24 +144,26 @@ Error AudioDriverOSX::finishDevice() { return OK; } -Error AudioDriverOSX::init() { +Error AudioDriverCoreAudio::init() { OSStatus result; mutex = Mutex::create(); active = false; channels = 2; +#ifdef OSX_ENABLED outputDeviceAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice; outputDeviceAddress.mScope = kAudioObjectPropertyScopeGlobal; outputDeviceAddress.mElement = kAudioObjectPropertyElementMaster; result = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &outputDeviceAddress, &outputDeviceAddressCB, this); ERR_FAIL_COND_V(result != noErr, FAILED); +#endif return initDevice(); }; -Error AudioDriverOSX::reopen() { +Error AudioDriverCoreAudio::reopen() { bool restart = false; lock(); @@ -185,13 +195,13 @@ Error AudioDriverOSX::reopen() { return OK; } -OSStatus AudioDriverOSX::output_callback(void *inRefCon, +OSStatus AudioDriverCoreAudio::output_callback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData) { - AudioDriverOSX *ad = (AudioDriverOSX *)inRefCon; + AudioDriverCoreAudio *ad = (AudioDriverCoreAudio *)inRefCon; if (!ad->active || !ad->try_lock()) { for (unsigned int i = 0; i < ioData->mNumberBuffers; i++) { @@ -227,7 +237,7 @@ OSStatus AudioDriverOSX::output_callback(void *inRefCon, return 0; }; -void AudioDriverOSX::start() { +void AudioDriverCoreAudio::start() { if (!active) { OSStatus result = AudioOutputUnitStart(audio_unit); if (result != noErr) { @@ -238,37 +248,41 @@ void AudioDriverOSX::start() { } }; -int AudioDriverOSX::get_mix_rate() const { +int AudioDriverCoreAudio::get_mix_rate() const { return mix_rate; }; -AudioDriver::SpeakerMode AudioDriverOSX::get_speaker_mode() const { +AudioDriver::SpeakerMode AudioDriverCoreAudio::get_speaker_mode() const { return get_speaker_mode_by_total_channels(channels); }; -void AudioDriverOSX::lock() { +void AudioDriverCoreAudio::lock() { if (mutex) mutex->lock(); }; -void AudioDriverOSX::unlock() { +void AudioDriverCoreAudio::unlock() { if (mutex) mutex->unlock(); }; -bool AudioDriverOSX::try_lock() { +bool AudioDriverCoreAudio::try_lock() { if (mutex) return mutex->try_lock() == OK; return true; } -void AudioDriverOSX::finish() { +void AudioDriverCoreAudio::finish() { + OSStatus result; + finishDevice(); - OSStatus result = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &outputDeviceAddress, &outputDeviceAddressCB, this); +#ifdef OSX_ENABLED + result = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &outputDeviceAddress, &outputDeviceAddressCB, this); if (result != noErr) { ERR_PRINT("AudioObjectRemovePropertyListener failed"); } +#endif AURenderCallbackStruct callback; zeromem(&callback, sizeof(AURenderCallbackStruct)); @@ -283,7 +297,7 @@ void AudioDriverOSX::finish() { } }; -AudioDriverOSX::AudioDriverOSX() { +AudioDriverCoreAudio::AudioDriverCoreAudio() { active = false; mutex = NULL; @@ -296,6 +310,6 @@ AudioDriverOSX::AudioDriverOSX() { samples_in.clear(); }; -AudioDriverOSX::~AudioDriverOSX(){}; +AudioDriverCoreAudio::~AudioDriverCoreAudio(){}; #endif diff --git a/platform/osx/audio_driver_osx.h b/drivers/coreaudio/audio_driver_coreaudio.h index a7e68c8141..33b3ba93ec 100644 --- a/platform/osx/audio_driver_osx.h +++ b/drivers/coreaudio/audio_driver_coreaudio.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* audio_driver_osx.h */ +/* audio_driver_coreaudio.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,20 +27,24 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifdef OSX_ENABLED +#ifdef COREAUDIO_ENABLED -#ifndef AUDIO_DRIVER_OSX_H -#define AUDIO_DRIVER_OSX_H +#ifndef AUDIO_DRIVER_COREAUDIO_H +#define AUDIO_DRIVER_COREAUDIO_H #include "servers/audio_server.h" #include <AudioUnit/AudioUnit.h> +#ifdef OSX_ENABLED #include <CoreAudio/AudioHardware.h> +#endif -class AudioDriverOSX : public AudioDriver { +class AudioDriverCoreAudio : public AudioDriver { AudioComponentInstance audio_unit; +#ifdef OSX_ENABLED AudioObjectPropertyAddress outputDeviceAddress; +#endif bool active; Mutex *mutex; @@ -62,7 +66,7 @@ class AudioDriverOSX : public AudioDriver { public: const char *get_name() const { - return "AudioUnit"; + return "CoreAudio"; }; virtual Error init(); @@ -76,8 +80,8 @@ public: bool try_lock(); Error reopen(); - AudioDriverOSX(); - ~AudioDriverOSX(); + AudioDriverCoreAudio(); + ~AudioDriverCoreAudio(); }; #endif diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 98a9211d0c..eaf0b06664 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "rasterizer_scene_gles3.h" - +#include "math_funcs.h" #include "os/os.h" #include "project_settings.h" #include "rasterizer_canvas_gles3.h" @@ -799,12 +799,12 @@ void RasterizerSceneGLES3::environment_set_sky(RID p_env, RID p_sky) { env->sky = p_sky; } -void RasterizerSceneGLES3::environment_set_sky_scale(RID p_env, float p_scale) { +void RasterizerSceneGLES3::environment_set_sky_custom_fov(RID p_env, float p_scale) { Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); - env->sky_scale = p_scale; + env->sky_custom_fov = p_scale; } void RasterizerSceneGLES3::environment_set_bg_color(RID p_env, const Color &p_color) { @@ -2319,7 +2319,7 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G } } -void RasterizerSceneGLES3::_draw_sky(RasterizerStorageGLES3::Sky *p_sky, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_scale, float p_energy) { +void RasterizerSceneGLES3::_draw_sky(RasterizerStorageGLES3::Sky *p_sky, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_custom_fov, float p_energy) { if (!p_sky) return; @@ -2365,16 +2365,28 @@ void RasterizerSceneGLES3::_draw_sky(RasterizerStorageGLES3::Sky *p_sky, const C //sky uv vectors float vw, vh, zn; - p_projection.get_viewport_size(vw, vh); - zn = p_projection.get_z_near(); + CameraMatrix camera; + + if (p_custom_fov) { + + float near_plane = p_projection.get_z_near(); + float far_plane = p_projection.get_z_far(); + float aspect = p_projection.get_aspect(); + + camera.set_perspective(p_custom_fov, aspect, near_plane, far_plane); - float scale = p_scale; + } else { + camera = p_projection; + } + + camera.get_viewport_size(vw, vh); + zn = p_projection.get_z_near(); for (int i = 0; i < 4; i++) { Vector3 uv = vertices[i * 2 + 1]; - uv.x = (uv.x * 2.0 - 1.0) * vw * scale; - uv.y = -(uv.y * 2.0 - 1.0) * vh * scale; + uv.x = (uv.x * 2.0 - 1.0) * vw; + uv.y = -(uv.y * 2.0 - 1.0) * vh; uv.z = -zn; vertices[i * 2 + 1] = p_transform.basis.xform(uv).normalized(); vertices[i * 2 + 1].z = -vertices[i * 2 + 1].z; @@ -2522,9 +2534,10 @@ void RasterizerSceneGLES3::_setup_directional_light(int p_index, const Transform float sign = li->light_ptr->negative ? -1 : 1; Color linear_col = li->light_ptr->color.to_linear(); - ubo_data.light_color_energy[0] = linear_col.r * sign * li->light_ptr->param[VS::LIGHT_PARAM_ENERGY]; - ubo_data.light_color_energy[1] = linear_col.g * sign * li->light_ptr->param[VS::LIGHT_PARAM_ENERGY]; - ubo_data.light_color_energy[2] = linear_col.b * sign * li->light_ptr->param[VS::LIGHT_PARAM_ENERGY]; + //compensate normalized diffuse range by multiplying by PI + ubo_data.light_color_energy[0] = linear_col.r * sign * li->light_ptr->param[VS::LIGHT_PARAM_ENERGY] * Math_PI; + ubo_data.light_color_energy[1] = linear_col.g * sign * li->light_ptr->param[VS::LIGHT_PARAM_ENERGY] * Math_PI; + ubo_data.light_color_energy[2] = linear_col.b * sign * li->light_ptr->param[VS::LIGHT_PARAM_ENERGY] * Math_PI; ubo_data.light_color_energy[3] = 0; //omni, keep at 0 @@ -2662,9 +2675,9 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result, int p_light_c float sign = li->light_ptr->negative ? -1 : 1; Color linear_col = li->light_ptr->color.to_linear(); - ubo_data.light_color_energy[0] = linear_col.r * sign * li->light_ptr->param[VS::LIGHT_PARAM_ENERGY]; - ubo_data.light_color_energy[1] = linear_col.g * sign * li->light_ptr->param[VS::LIGHT_PARAM_ENERGY]; - ubo_data.light_color_energy[2] = linear_col.b * sign * li->light_ptr->param[VS::LIGHT_PARAM_ENERGY]; + ubo_data.light_color_energy[0] = linear_col.r * sign * li->light_ptr->param[VS::LIGHT_PARAM_ENERGY] * Math_PI; + ubo_data.light_color_energy[1] = linear_col.g * sign * li->light_ptr->param[VS::LIGHT_PARAM_ENERGY] * Math_PI; + ubo_data.light_color_energy[2] = linear_col.b * sign * li->light_ptr->param[VS::LIGHT_PARAM_ENERGY] * Math_PI; ubo_data.light_color_energy[3] = 0; Vector3 pos = p_camera_inverse_transform.xform(li->transform.origin); @@ -2748,9 +2761,9 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result, int p_light_c float sign = li->light_ptr->negative ? -1 : 1; Color linear_col = li->light_ptr->color.to_linear(); - ubo_data.light_color_energy[0] = linear_col.r * sign * li->light_ptr->param[VS::LIGHT_PARAM_ENERGY]; - ubo_data.light_color_energy[1] = linear_col.g * sign * li->light_ptr->param[VS::LIGHT_PARAM_ENERGY]; - ubo_data.light_color_energy[2] = linear_col.b * sign * li->light_ptr->param[VS::LIGHT_PARAM_ENERGY]; + ubo_data.light_color_energy[0] = linear_col.r * sign * li->light_ptr->param[VS::LIGHT_PARAM_ENERGY] * Math_PI; + ubo_data.light_color_energy[1] = linear_col.g * sign * li->light_ptr->param[VS::LIGHT_PARAM_ENERGY] * Math_PI; + ubo_data.light_color_energy[2] = linear_col.b * sign * li->light_ptr->param[VS::LIGHT_PARAM_ENERGY] * Math_PI; ubo_data.light_color_energy[3] = 0; Vector3 pos = p_camera_inverse_transform.xform(li->transform.origin); @@ -4258,7 +4271,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const glBindFramebuffer(GL_FRAMEBUFFER,storage->frame.current_rt->buffers.fbo); //switch to alpha fbo for sky, only diffuse/ambient matters */ - _draw_sky(sky, p_cam_projection, p_cam_transform, false, env->sky_scale, env->bg_energy); + _draw_sky(sky, p_cam_projection, p_cam_transform, false, env->sky_custom_fov, env->bg_energy); } //_render_list_forward(&alpha_render_list,camera_transform,camera_transform_inverse,camera_projection,false,fragment_lighting,true); diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h index 04cb3597da..28a5cef0ee 100644 --- a/drivers/gles3/rasterizer_scene_gles3.h +++ b/drivers/gles3/rasterizer_scene_gles3.h @@ -352,7 +352,7 @@ public: VS::EnvironmentBG bg_mode; RID sky; - float sky_scale; + float sky_custom_fov; Color bg_color; float bg_energy; @@ -435,7 +435,7 @@ public: Environment() { bg_mode = VS::ENV_BG_CLEAR_COLOR; - sky_scale = 1.0; + sky_custom_fov = 0.0; bg_energy = 1.0; sky_ambient = 0; ambient_energy = 1.0; @@ -520,7 +520,7 @@ public: virtual void environment_set_background(RID p_env, VS::EnvironmentBG p_bg); virtual void environment_set_sky(RID p_env, RID p_sky); - virtual void environment_set_sky_scale(RID p_env, float p_scale); + virtual void environment_set_sky_custom_fov(RID p_env, float p_scale); virtual void environment_set_bg_color(RID p_env, const Color &p_color); virtual void environment_set_bg_energy(RID p_env, float p_energy); virtual void environment_set_canvas_max_layer(RID p_env, int p_max_layer); @@ -811,7 +811,7 @@ public: _FORCE_INLINE_ void _add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *p_material, bool p_depth_pass); - void _draw_sky(RasterizerStorageGLES3::Sky *p_sky, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_scale, float p_energy); + void _draw_sky(RasterizerStorageGLES3::Sky *p_sky, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_custom_fov, float p_energy); void _setup_environment(Environment *env, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform); void _setup_directional_light(int p_index, const Transform &p_camera_inverse_transform, bool p_use_shadows); diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index b173958664..91159e3381 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -700,9 +700,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { /** CANVAS ITEM SHADER **/ - actions[VS::SHADER_CANVAS_ITEM].renames["SRC_VERTEX"] = "vertex"; actions[VS::SHADER_CANVAS_ITEM].renames["VERTEX"] = "outvec.xy"; - actions[VS::SHADER_CANVAS_ITEM].renames["VERTEX_COLOR"] = "vertex_color"; actions[VS::SHADER_CANVAS_ITEM].renames["UV"] = "uv_interp"; actions[VS::SHADER_CANVAS_ITEM].renames["POINT_SIZE"] = "gl_PointSize"; @@ -711,6 +709,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_CANVAS_ITEM].renames["EXTRA_MATRIX"] == "extra_matrix"; actions[VS::SHADER_CANVAS_ITEM].renames["TIME"] = "time"; actions[VS::SHADER_CANVAS_ITEM].renames["AT_LIGHT_PASS"] = "at_light_pass"; + actions[VS::SHADER_CANVAS_ITEM].renames["INSTANCE_CUSTOM"] = "instance_custom"; actions[VS::SHADER_CANVAS_ITEM].renames["COLOR"] = "color"; actions[VS::SHADER_CANVAS_ITEM].renames["NORMAL"] = "normal"; @@ -720,6 +719,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_CANVAS_ITEM].renames["COLOR"] = "color"; actions[VS::SHADER_CANVAS_ITEM].renames["TEXTURE"] = "color_texture"; actions[VS::SHADER_CANVAS_ITEM].renames["TEXTURE_PIXEL_SIZE"] = "color_texpixel_size"; + actions[VS::SHADER_CANVAS_ITEM].renames["NORMAL_TEXTURE"] = "normal_texture"; actions[VS::SHADER_CANVAS_ITEM].renames["SCREEN_UV"] = "screen_uv"; actions[VS::SHADER_CANVAS_ITEM].renames["SCREEN_TEXTURE"] = "screen_texture"; actions[VS::SHADER_CANVAS_ITEM].renames["SCREEN_PIXEL_SIZE"] = "screen_pixel_size"; diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl index bf8eaf601d..731d6968ce 100644 --- a/drivers/gles3/shaders/canvas.glsl +++ b/drivers/gles3/shaders/canvas.glsl @@ -105,13 +105,16 @@ VERTEX_SHADER_GLOBALS void main() { - vec4 vertex_color = color_attrib; + vec4 color = color_attrib; #ifdef USE_INSTANCING mat4 extra_matrix2 = extra_matrix * transpose(mat4(instance_xform0,instance_xform1,instance_xform2,vec4(0.0,0.0,0.0,1.0))); - vertex_color*=instance_color; + color*=instance_color; + vec4 instance_custom = instance_custom_data; + #else mat4 extra_matrix2 = extra_matrix; + vec4 instance_custom = vec4(0.0); #endif #ifdef USE_TEXTURE_RECT @@ -135,7 +138,7 @@ void main() { //compute h and v frames and adjust UV interp for animation int total_frames = h_frames * v_frames; - int frame = min(int(float(total_frames) *instance_custom_data.z),total_frames-1); + int frame = min(int(float(total_frames) *instance_custom.z),total_frames-1); float frame_w = 1.0/float(h_frames); float frame_h = 1.0/float(v_frames); uv_interp.x = uv_interp.x * frame_w + frame_w * float(frame % h_frames); @@ -146,7 +149,6 @@ void main() { #define extra_matrix extra_matrix2 { - vec2 src_vtx=outvec.xy; VERTEX_SHADER_CODE @@ -165,7 +167,7 @@ VERTEX_SHADER_CODE #undef extra_matrix - color_interp = vertex_color; + color_interp = color; #ifdef USE_PIXEL_SNAP diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index b6fb69a2aa..41d5ef5bc9 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -1,5 +1,6 @@ [vertex] +#define M_PI 3.14159265359 /* from VisualServer: @@ -166,7 +167,7 @@ out vec4 specular_light_interp; void light_compute(vec3 N, vec3 L,vec3 V, vec3 light_color,float roughness,inout vec3 diffuse, inout vec3 specular) { float dotNL = max(dot(N,L), 0.0 ); - diffuse += dotNL * light_color; + diffuse += dotNL * light_color / M_PI; if (roughness > 0.0) { @@ -589,7 +590,7 @@ vec3 textureDualParaboloid(sampler2DArray p_tex, vec3 p_vec,float p_roughness) { norm.xy=norm.xy * vec2(0.5,0.25) + vec2(0.5,0.25); // we need to lie the derivatives (normg) and assume that DP side is always the same - // to get proper texure filtering + // to get proper texture filtering vec2 normg=norm.xy; if (norm.z>0.0) { norm.y=0.5-norm.y+0.5; @@ -920,6 +921,7 @@ LIGHT_SHADER_CODE #elif defined(DIFFUSE_OREN_NAYAR) { + // see http://mimosa-pudica.net/improved-oren-nayar.html float LdotV = dot(L, V); float NdotL = dot(L, N); float NdotV = dot(N, V); @@ -928,10 +930,10 @@ LIGHT_SHADER_CODE float t = mix(1.0, max(NdotL, NdotV), step(0.0, s)); float sigma2 = roughness * roughness; - vec3 A = 1.0 + sigma2 * (diffuse_color / (sigma2 + 0.13) + 0.5 / (sigma2 + 0.33)); + vec3 A = 1.0 + sigma2 * (- 0.5 / (sigma2 + 0.33) + 0.17*diffuse_color / (sigma2 + 0.13) ); float B = 0.45 * sigma2 / (sigma2 + 0.09); - light_amount = max(0.0, NdotL) * (A + vec3(B) * s / t) / M_PI; + light_amount = dotNL * (A + vec3(B) * s / t) / M_PI; } #elif defined(DIFFUSE_TOON) @@ -951,7 +953,7 @@ LIGHT_SHADER_CODE float FD90 = 0.5 + 2.0 * LoH * LoH * roughness; float FdV = 1.0 + (FD90 - 1.0) * SchlickFresnel(NoV); float FdL = 1.0 + (FD90 - 1.0) * SchlickFresnel(NoL); - light_amount = ( (1.0 / M_PI) * FdV * FdL ); + light_amount = ( (1.0 / M_PI) * FdV * FdL ) * NoL; /* float energyBias = mix(roughness, 0.0, 0.5); float energyFactor = mix(roughness, 1.0, 1.0 / 1.51); @@ -964,11 +966,11 @@ LIGHT_SHADER_CODE } #else //lambert - light_amount = dotNL; + light_amount = dotNL / M_PI; #endif #if defined(TRANSMISSION_USED) - diffuse += light_color * diffuse_color * mix(vec3(light_amount),vec3(1.0),transmission) * attenuation; + diffuse += light_color * diffuse_color * mix(vec3(light_amount),vec3(M_PI),transmission) * attenuation; #else diffuse += light_color * diffuse_color * light_amount * attenuation; #endif @@ -1943,18 +1945,19 @@ FRAGMENT_SHADER_CODE //simplify for toon, as specular_light *= specular * metallic * albedo * 2.0; #else - //brdf approximation (Lazarov 2013) - float ndotv = clamp(dot(normal,eye_vec),0.0,1.0); - vec3 dielectric = vec3(0.034) * specular * 2.0; //energy conservation - vec3 f0 = mix(dielectric, albedo, metallic); + vec3 dielectric = vec3(0.034) * specular * 2.0; + vec3 specular_color = mix(dielectric, albedo, metallic); + // Environment brdf approximation (Lazarov 2013) + // see https://www.unrealengine.com/en-US/blog/physically-based-shading-on-mobile const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022); const vec4 c1 = vec4( 1.0, 0.0425, 1.04, -0.04); vec4 r = roughness * c0 + c1; + float ndotv = clamp(dot(normal,eye_vec),0.0,1.0); float a004 = min( r.x * r.x, exp2( -9.28 * ndotv ) ) * r.x + r.y; - vec2 brdf = vec2( -1.04, 1.04 ) * a004 + r.zw; + vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw; - specular_light *= min(1.0,50.0 * f0.g) * brdf.y + brdf.x * f0; + specular_light *= AB.x * specular_color + AB.y; #endif } diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index a7516c091f..985b336d20 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1010,7 +1010,7 @@ void CodeTextEditor::_reset_zoom() { Ref<DynamicFont> font = text_editor->get_font("font"); // reset source font size to default if (font.is_valid()) { - EditorSettings::get_singleton()->set("interface/source_font_size", 14); + EditorSettings::get_singleton()->set("interface/editor/source_font_size", 14); font->set_size(14); } } @@ -1066,7 +1066,7 @@ void CodeTextEditor::_font_resize_timeout() { if (font.is_valid()) { int new_size = CLAMP(font->get_size() + font_resize_val, 8 * EDSCALE, 96 * EDSCALE); if (new_size != font->get_size()) { - EditorSettings::get_singleton()->set("interface/source_font_size", new_size / EDSCALE); + EditorSettings::get_singleton()->set("interface/editor/source_font_size", new_size / EDSCALE); font->set_size(new_size); } diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 110b2a6a8c..cf6259bede 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -122,7 +122,7 @@ void editor_register_fonts(Ref<Theme> p_theme) { dfmono->set_font_ptr(_font_Hack_Regular, _font_Hack_Regular_size); //dfd->set_force_autohinter(true); //just looks better..i think? - MAKE_DEFAULT_FONT(df, int(EditorSettings::get_singleton()->get("interface/font_size")) * EDSCALE); + MAKE_DEFAULT_FONT(df, int(EditorSettings::get_singleton()->get("interface/editor/font_size")) * EDSCALE); p_theme->set_default_theme_font(df); @@ -142,7 +142,7 @@ void editor_register_fonts(Ref<Theme> p_theme) { Ref<DynamicFont> df_code; df_code.instance(); - df_code->set_size(int(EditorSettings::get_singleton()->get("interface/source_font_size")) * EDSCALE); + df_code->set_size(int(EditorSettings::get_singleton()->get("interface/editor/source_font_size")) * EDSCALE); df_code->set_font_data(dfmono); MAKE_FALLBACKS(df_code); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index f2452df9f0..cb94ea72d1 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -650,8 +650,8 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { // Colors const Color title_color = get_color("accent_color", "Editor"); - const Color text_color = get_color("font_color", "RichTextLabel"); - const Color highlight_color = get_color("highlight_color", "RichTextLabel"); + const Color text_color = get_color("default_color", "RichTextLabel"); + const Color headline_color = get_color("headline_color", "EditorHelp"); const Color base_type_color = title_color.linear_interpolate(text_color, 0.5); const Color comment_color = Color(text_color.r, text_color.g, text_color.b, 0.6); const Color symbol_color = comment_color; @@ -669,7 +669,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->push_font(doc_title_font); class_desc->push_color(title_color); class_desc->add_text(TTR("Class:") + " "); - class_desc->push_color(highlight_color); + class_desc->push_color(headline_color); _add_text(p_class); class_desc->pop(); class_desc->pop(); @@ -812,7 +812,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { } class_desc->push_font(doc_code_font); - class_desc->push_color(highlight_color); + class_desc->push_color(headline_color); _add_text(cd.properties[i].name); if (describe) { @@ -883,7 +883,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { method_descr = true; class_desc->push_meta("@" + methods[i].name); } - class_desc->push_color(highlight_color); + class_desc->push_color(headline_color); _add_text(methods[i].name); class_desc->pop(); if (methods[i].description != "") @@ -969,7 +969,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->push_cell(); class_desc->push_font(doc_code_font); - class_desc->push_color(highlight_color); + class_desc->push_color(headline_color); _add_text(cd.theme_properties[i].name); class_desc->pop(); class_desc->pop(); @@ -1015,7 +1015,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->push_font(doc_code_font); // monofont //_add_type("void"); //class_desc->add_text(" "); - class_desc->push_color(highlight_color); + class_desc->push_color(headline_color); _add_text(cd.signals[i].name); class_desc->pop(); class_desc->push_color(symbol_color); @@ -1102,7 +1102,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { e = e.get_slice(".", 1); } - class_desc->push_color(highlight_color); + class_desc->push_color(headline_color); class_desc->add_text(e); class_desc->pop(); class_desc->pop(); @@ -1117,7 +1117,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { for (int i = 0; i < enum_list.size(); i++) { class_desc->push_font(doc_code_font); - class_desc->push_color(highlight_color); + class_desc->push_color(headline_color); _add_text(enum_list[i].name); class_desc->pop(); class_desc->push_color(symbol_color); @@ -1165,7 +1165,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { constant_line[constants[i].name] = class_desc->get_line_count() - 2; class_desc->push_font(doc_code_font); - class_desc->push_color(highlight_color); + class_desc->push_color(headline_color); _add_text(constants[i].name); class_desc->pop(); class_desc->push_color(symbol_color); @@ -1235,7 +1235,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { _add_type(cd.properties[i].type, cd.properties[i].enumeration); class_desc->add_text(" "); - class_desc->push_color(highlight_color); + class_desc->push_color(headline_color); _add_text(cd.properties[i].name); class_desc->pop(); //color @@ -1324,7 +1324,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { _add_type(methods[i].return_type, methods[i].return_enum); class_desc->add_text(" "); - class_desc->push_color(highlight_color); + class_desc->push_color(headline_color); _add_text(methods[i].name); class_desc->pop(); class_desc->push_color(symbol_color); @@ -1456,7 +1456,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { Ref<Font> doc_font = p_rt->get_font("doc", "EditorFonts"); Ref<Font> doc_code_font = p_rt->get_font("doc_source", "EditorFonts"); - Color font_color_hl = p_rt->get_color("highlight_color", "RichTextLabel"); + Color font_color_hl = p_rt->get_color("headline_color", "EditorHelp"); Color link_color = p_rt->get_color("accent_color", "Editor").linear_interpolate(font_color_hl, 0.8); String bbcode = p_bbcode.replace("\t", " ").replace("\r", " ").strip_edges(); @@ -1695,9 +1695,6 @@ void EditorHelp::_notification(int p_what) { //back->set_icon(get_icon("Back","EditorIcons")); _update_doc(); - class_desc->add_style_override("normal", class_desc->get_stylebox("code_normal", "RichTextLabel")); - class_desc->add_style_override("focus", class_desc->get_stylebox("code_focus", "RichTextLabel")); - } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 21520875cd..a04ded7b5b 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -114,7 +114,7 @@ EditorNode *EditorNode::singleton = NULL; void EditorNode::_update_scene_tabs() { - bool show_rb = EditorSettings::get_singleton()->get("interface/show_script_in_scene_tabs"); + bool show_rb = EditorSettings::get_singleton()->get("interface/editor/show_script_in_scene_tabs"); scene_tabs->clear_tabs(); Ref<Texture> script_icon = gui_base->get_icon("Script", "EditorIcons"); @@ -282,8 +282,8 @@ void EditorNode::_notification(int p_what) { } if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - scene_tabs->set_tab_close_display_policy((bool(EDITOR_DEF("interface/always_show_close_button_in_scene_tabs", false)) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY)); - property_editor->set_enable_capitalize_paths(bool(EDITOR_DEF("interface/capitalize_properties", true))); + scene_tabs->set_tab_close_display_policy((bool(EDITOR_DEF("interface/editor/always_show_close_button_in_scene_tabs", false)) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY)); + property_editor->set_enable_capitalize_paths(bool(EDITOR_DEF("interface/editor/capitalize_properties", true))); Ref<Theme> theme = create_editor_theme(theme_base->get_theme()); theme_base->set_theme(theme); @@ -308,6 +308,10 @@ void EditorNode::_notification(int p_what) { } _update_scene_tabs(); + // debugger area + if (ScriptEditor::get_singleton()->get_debugger()->is_visible()) + bottom_panel->add_style_override("panel", gui_base->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")); + //_update_icons for (int i = 0; i < singleton->main_editor_buttons.size(); i++) { main_editor_buttons[i]->set_icon(gui_base->get_icon(singleton->main_editor_buttons[i]->get_name(), "EditorIcons")); @@ -2240,10 +2244,10 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { case RUN_PROJECT_MANAGER: { if (!p_confirmed) { - bool save_each = EDITOR_DEF("interface/save_each_scene_on_quit", true); + bool save_each = EDITOR_DEF("interface/editor/save_each_scene_on_quit", true); if (_next_unsaved_scene(!save_each) == -1) { - bool confirm = EDITOR_DEF("interface/quit_confirmation", true); + bool confirm = EDITOR_DEF("interface/editor/quit_confirmation", true); if (confirm) { confirmation->get_ok()->set_text(p_option == FILE_QUIT ? TTR("Quit") : TTR("Yes")); @@ -2568,7 +2572,7 @@ void EditorNode::_editor_select(int p_which) { editor_data.get_editor_plugin(i)->notify_main_screen_changed(editor_plugin_screen->get_name()); } - if (EditorSettings::get_singleton()->get("interface/separate_distraction_mode")) { + if (EditorSettings::get_singleton()->get("interface/editor/separate_distraction_mode")) { if (p_which == EDITOR_SCRIPT) { set_distraction_free_mode(script_distraction); } else { @@ -4062,29 +4066,25 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) { ERR_FAIL_INDEX(p_idx, bottom_panel_items.size()); if (p_enable) { - // this is the debug panel wich uses tabs, so the top section should be smaller - if (ScriptEditor::get_singleton()->get_debugger() == bottom_panel_items[p_idx].control) { - Ref<StyleBoxFlat> style_panel_invisible_top = gui_base->get_stylebox("debugger_panel", "EditorStyles"); - bottom_panel->add_style_override("panel", style_panel_invisible_top); - } else { - bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer")); - } for (int i = 0; i < bottom_panel_items.size(); i++) { bottom_panel_items[i].button->set_pressed(i == p_idx); bottom_panel_items[i].control->set_visible(i == p_idx); } + if (ScriptEditor::get_singleton()->get_debugger() == bottom_panel_items[p_idx].control) { // this is the debug panel wich uses tabs, so the top section should be smaller + bottom_panel->add_style_override("panel", gui_base->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")); + } else { + bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer")); + } center_split->set_dragger_visibility(SplitContainer::DRAGGER_VISIBLE); center_split->set_collapsed(false); } else { bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer")); - for (int i = 0; i < bottom_panel_items.size(); i++) { bottom_panel_items[i].button->set_pressed(false); bottom_panel_items[i].control->set_visible(false); } - center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN); center_split->set_collapsed(true); } @@ -4101,7 +4101,7 @@ bool EditorNode::get_docks_visible() const { void EditorNode::_toggle_distraction_free_mode() { - if (EditorSettings::get_singleton()->get("interface/separate_distraction_mode")) { + if (EditorSettings::get_singleton()->get("interface/editor/separate_distraction_mode")) { int screen = -1; for (int i = 0; i < editor_table.size(); i++) { if (editor_plugin_screen == editor_table[i]) { @@ -4385,7 +4385,7 @@ void EditorNode::_open_imported() { void EditorNode::dim_editor(bool p_dimming) { static int dim_count = 0; - bool dim_ui = EditorSettings::get_singleton()->get("interface/dim_editor_on_dialog_popup"); + bool dim_ui = EditorSettings::get_singleton()->get("interface/editor/dim_editor_on_dialog_popup"); if (p_dimming) { if (dim_ui) { if (dim_count == 0) { @@ -4412,9 +4412,9 @@ void EditorNode::_start_dimming(bool p_dimming) { void EditorNode::_dim_timeout() { _dim_time += _dim_timer->get_wait_time(); - float wait_time = EditorSettings::get_singleton()->get("interface/dim_transition_time"); + float wait_time = EditorSettings::get_singleton()->get("interface/editor/dim_transition_time"); - float c = 1.0f - (float)EditorSettings::get_singleton()->get("interface/dim_amount"); + float c = 1.0f - (float)EditorSettings::get_singleton()->get("interface/editor/dim_amount"); Color base = _dimming ? Color(1, 1, 1) : Color(c, c, c); Color final = _dimming ? Color(c, c, c) : Color(1, 1, 1); @@ -4586,7 +4586,7 @@ EditorNode::EditorNode() { EditorSettings::create(); { - int dpi_mode = EditorSettings::get_singleton()->get("interface/hidpi_mode"); + int dpi_mode = EditorSettings::get_singleton()->get("interface/editor/hidpi_mode"); if (dpi_mode == 0) { editor_set_scale(OS::get_singleton()->get_screen_dpi(0) >= 192 && OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x > 2000 ? 2.0 : 1.0); } else if (dpi_mode == 1) { @@ -4623,6 +4623,10 @@ EditorNode::EditorNode() { import_wav.instance(); ResourceFormatImporter::get_singleton()->add_importer(import_wav); + Ref<ResourceImporterOBJ> import_obj; + import_obj.instance(); + ResourceFormatImporter::get_singleton()->add_importer(import_obj); + Ref<ResourceImporterScene> import_scene; import_scene.instance(); ResourceFormatImporter::get_singleton()->add_importer(import_scene); @@ -4837,7 +4841,7 @@ EditorNode::EditorNode() { scene_tabs->add_style_override("tab_bg", gui_base->get_stylebox("SceneTabBG", "EditorStyles")); scene_tabs->add_tab("unsaved"); scene_tabs->set_tab_align(Tabs::ALIGN_LEFT); - scene_tabs->set_tab_close_display_policy((bool(EDITOR_DEF("interface/always_show_close_button_in_scene_tabs", false)) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY)); + scene_tabs->set_tab_close_display_policy((bool(EDITOR_DEF("interface/editor/always_show_close_button_in_scene_tabs", false)) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY)); scene_tabs->set_min_width(int(EDITOR_DEF("interface/scene_tabs/minimum_width", 50)) * EDSCALE); scene_tabs->connect("tab_changed", this, "_scene_tab_changed"); scene_tabs->connect("right_button_pressed", this, "_scene_tab_script_edited"); @@ -5291,7 +5295,7 @@ EditorNode::EditorNode() { property_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); property_editor->set_use_doc_hints(true); property_editor->set_hide_script(false); - property_editor->set_enable_capitalize_paths(bool(EDITOR_DEF("interface/capitalize_properties", true))); + property_editor->set_enable_capitalize_paths(bool(EDITOR_DEF("interface/editor/capitalize_properties", true))); property_editor->hide_top_label(); property_editor->register_text_enter(search_box); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 325f30a453..d8c2d7cca4 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -453,7 +453,7 @@ String EditorSettings::get_settings_path() const { void EditorSettings::setup_language() { - String lang = get("interface/editor_language"); + String lang = get("interface/editor/editor_language"); if (lang == "en") return; //none to do @@ -555,29 +555,29 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { best = "en"; } - _initial_set("interface/editor_language", best); - hints["interface/editor_language"] = PropertyInfo(Variant::STRING, "interface/editor_language", PROPERTY_HINT_ENUM, lang_hint, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + _initial_set("interface/editor/editor_language", best); + hints["interface/editor/editor_language"] = PropertyInfo(Variant::STRING, "interface/editor/editor_language", PROPERTY_HINT_ENUM, lang_hint, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); } - _initial_set("interface/hidpi_mode", 0); - hints["interface/hidpi_mode"] = PropertyInfo(Variant::INT, "interface/hidpi_mode", PROPERTY_HINT_ENUM, "Auto,VeryLoDPI,LoDPI,MidDPI,HiDPI", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); - _initial_set("interface/show_script_in_scene_tabs", false); - _initial_set("interface/font_size", 14); - hints["interface/font_size"] = PropertyInfo(Variant::INT, "interface/font_size", PROPERTY_HINT_RANGE, "10,40,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); - _initial_set("interface/source_font_size", 14); - hints["interface/source_font_size"] = PropertyInfo(Variant::INT, "interface/source_font_size", PROPERTY_HINT_RANGE, "8,96,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); - _initial_set("interface/custom_font", ""); - hints["interface/custom_font"] = PropertyInfo(Variant::STRING, "interface/custom_font", PROPERTY_HINT_GLOBAL_FILE, "*.font,*.tres,*.res", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); - _initial_set("interface/dim_editor_on_dialog_popup", true); - _initial_set("interface/dim_amount", 0.6f); - hints["interface/dim_amount"] = PropertyInfo(Variant::REAL, "interface/dim_amount", PROPERTY_HINT_RANGE, "0,1,0.01", PROPERTY_USAGE_DEFAULT); - _initial_set("interface/dim_transition_time", 0.08f); - hints["interface/dim_transition_time"] = PropertyInfo(Variant::REAL, "interface/dim_transition_time", PROPERTY_HINT_RANGE, "0,1,0.001", PROPERTY_USAGE_DEFAULT); - - _initial_set("interface/separate_distraction_mode", false); - - _initial_set("interface/save_each_scene_on_quit", true); // Regression - _initial_set("interface/quit_confirmation", true); + _initial_set("interface/editor/hidpi_mode", 0); + hints["interface/editor/hidpi_mode"] = PropertyInfo(Variant::INT, "interface/editor/hidpi_mode", PROPERTY_HINT_ENUM, "Auto,VeryLoDPI,LoDPI,MidDPI,HiDPI", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + _initial_set("interface/editor/show_script_in_scene_tabs", false); + _initial_set("interface/editor/font_size", 14); + hints["interface/editor/font_size"] = PropertyInfo(Variant::INT, "interface/editor/font_size", PROPERTY_HINT_RANGE, "10,40,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + _initial_set("interface/editor/source_font_size", 14); + hints["interface/editor/source_font_size"] = PropertyInfo(Variant::INT, "interface/editor/source_font_size", PROPERTY_HINT_RANGE, "8,96,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + _initial_set("interface/editor/custom_font", ""); + hints["interface/editor/custom_font"] = PropertyInfo(Variant::STRING, "interface/editor/custom_font", PROPERTY_HINT_GLOBAL_FILE, "*.font,*.tres,*.res", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + _initial_set("interface/editor/dim_editor_on_dialog_popup", true); + _initial_set("interface/editor/dim_amount", 0.6f); + hints["interface/editor/dim_amount"] = PropertyInfo(Variant::REAL, "interface/editor/dim_amount", PROPERTY_HINT_RANGE, "0,1,0.01", PROPERTY_USAGE_DEFAULT); + _initial_set("interface/editor/dim_transition_time", 0.08f); + hints["interface/editor/dim_transition_time"] = PropertyInfo(Variant::REAL, "interface/editor/dim_transition_time", PROPERTY_HINT_RANGE, "0,1,0.001", PROPERTY_USAGE_DEFAULT); + + _initial_set("interface/editor/separate_distraction_mode", false); + + _initial_set("interface/editor/save_each_scene_on_quit", true); // Regression + _initial_set("interface/editor/quit_confirmation", true); _initial_set("interface/theme/preset", 0); hints["interface/theme/preset"] = PropertyInfo(Variant::INT, "interface/theme/preset", PROPERTY_HINT_ENUM, "Default,Grey,Godot 2,Arc,Light,Custom", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); @@ -610,7 +610,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { hints["filesystem/directories/default_project_path"] = PropertyInfo(Variant::STRING, "filesystem/directories/default_project_path", PROPERTY_HINT_GLOBAL_DIR); _initial_set("filesystem/directories/default_project_export_path", ""); hints["global/default_project_export_path"] = PropertyInfo(Variant::STRING, "global/default_project_export_path", PROPERTY_HINT_GLOBAL_DIR); - _initial_set("interface/show_script_in_scene_tabs", false); + _initial_set("interface/editor/show_script_in_scene_tabs", false); _initial_set("text_editor/theme/color_theme", "Adaptive"); hints["text_editor/theme/color_theme"] = PropertyInfo(Variant::STRING, "text_editor/theme/color_theme", PROPERTY_HINT_ENUM, "Adaptive,Default"); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index b33c36867a..08bb976bcc 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -426,19 +426,19 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { Ref<StyleBoxEmpty> style_empty = make_empty_stylebox(default_margin_size, default_margin_size, default_margin_size, default_margin_size); // Tabs - const int tab_default_margin_side = 10 * EDSCALE; Ref<StyleBoxFlat> style_tab_selected = style_widget->duplicate(); + style_tab_selected->set_border_width_all(border_width); style_tab_selected->set_border_width(MARGIN_BOTTOM, 0); style_tab_selected->set_border_color_all(dark_color_3); style_tab_selected->set_expand_margin_size(MARGIN_BOTTOM, border_width); - style_tab_selected->set_default_margin(MARGIN_LEFT, tab_default_margin_side); - style_tab_selected->set_default_margin(MARGIN_RIGHT, tab_default_margin_side); + style_tab_selected->set_default_margin(MARGIN_LEFT, 10 * EDSCALE); + style_tab_selected->set_default_margin(MARGIN_RIGHT, 10 * EDSCALE); style_tab_selected->set_bg_color(tab_color); Ref<StyleBoxFlat> style_tab_unselected = style_tab_selected->duplicate(); - style_tab_unselected->set_bg_color(Color(0.0, 0.0, 0.0, 0.0)); - style_tab_unselected->set_border_color_all(Color(0.0, 0.0, 0.0, 0.0)); + style_tab_unselected->set_draw_center(false); + style_tab_unselected->set_border_width_all(0); // Editor background theme->set_stylebox("Background", "EditorStyles", make_flat_stylebox(background_color, default_margin_size, default_margin_size, default_margin_size, default_margin_size)); @@ -688,29 +688,18 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("separator", "HSeparator", make_line_stylebox(separator_color, border_width)); theme->set_stylebox("separator", "VSeparator", make_line_stylebox(separator_color, border_width, 0, true)); - // HACK Debuger panel + // Debugger + Ref<StyleBoxFlat> style_panel_debugger = style_content_panel->duplicate(); - const int v_offset = theme->get_font("font", "Tabs")->get_height() + style_tab_selected->get_minimum_size().height + default_margin_size * EDSCALE; - style_panel_debugger->set_expand_margin_size(MARGIN_TOP, -v_offset); - theme->set_stylebox("debugger_panel", "EditorStyles", style_panel_debugger); + style_panel_debugger->set_border_width(MARGIN_BOTTOM, 0); + theme->set_stylebox("DebuggerPanel", "EditorStyles", style_panel_debugger); + theme->set_stylebox("DebuggerTabFG", "EditorStyles", style_tab_selected); + theme->set_stylebox("DebuggerTabBG", "EditorStyles", style_tab_unselected); - // Debugger - Ref<StyleBoxFlat> style_debugger_contents = style_content_panel->duplicate(); - style_debugger_contents->set_default_margin(MARGIN_LEFT, 0); - style_debugger_contents->set_default_margin(MARGIN_BOTTOM, 0); - style_debugger_contents->set_default_margin(MARGIN_RIGHT, 0); - style_debugger_contents->set_border_width_all(0); - style_debugger_contents->set_expand_margin_size(MARGIN_TOP, -v_offset); - theme->set_constant("extra_margin", "DebuggerPanel", default_margin_size * EDSCALE + border_width); - theme->set_stylebox("DebuggerPanel", "EditorStyles", style_debugger_contents); - Ref<StyleBoxFlat> style_tab_fg_debugger = style_tab_selected->duplicate(); - style_tab_fg_debugger->set_expand_margin_size(MARGIN_LEFT, default_margin_size * EDSCALE + border_width); - style_tab_fg_debugger->set_default_margin(MARGIN_LEFT, tab_default_margin_side - default_margin_size * EDSCALE); - theme->set_stylebox("DebuggerTabFG", "EditorStyles", style_tab_fg_debugger); - Ref<StyleBoxFlat> style_tab_bg_debugger = style_tab_unselected->duplicate(); - style_tab_bg_debugger->set_expand_margin_size(MARGIN_LEFT, default_margin_size * EDSCALE + border_width); - style_tab_bg_debugger->set_default_margin(MARGIN_LEFT, tab_default_margin_side - default_margin_size * EDSCALE); - theme->set_stylebox("DebuggerTabBG", "EditorStyles", style_tab_bg_debugger); + Ref<StyleBoxFlat> style_panel_invisible_top = style_content_panel->duplicate(); + int stylebox_offset = theme->get_font("tab_fg", "TabContainer")->get_height() + theme->get_stylebox("tab_fg", "TabContainer")->get_minimum_size().height + theme->get_stylebox("panel", "TabContainer")->get_default_margin(MARGIN_TOP); + style_panel_invisible_top->set_expand_margin_size(MARGIN_TOP, -stylebox_offset); + theme->set_stylebox("BottomPanelDebuggerOverride", "EditorStyles", style_panel_invisible_top); // LineEdit theme->set_stylebox("normal", "LineEdit", style_widget); @@ -809,21 +798,11 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("grabber_area", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0)); //RichTextLabel - Color rtl_combined_bg_color = dark_color_1.linear_interpolate(script_bg_color, script_bg_color.a); - Color rtl_mono_color = (rtl_combined_bg_color.r + rtl_combined_bg_color.g + rtl_combined_bg_color.b > 1.5) ? Color(0, 0, 0) : Color(1, 1, 1); - Color rtl_font_color = rtl_mono_color.linear_interpolate(rtl_combined_bg_color, 0.25); - theme->set_color("default_color", "RichTextLabel", rtl_font_color); + theme->set_color("default_color", "RichTextLabel", font_color); theme->set_stylebox("focus", "RichTextLabel", make_empty_stylebox()); theme->set_stylebox("normal", "RichTextLabel", style_tree_bg); - Ref<StyleBoxFlat> style_code = style_tree_bg->duplicate(); - style_code->set_bg_color(rtl_combined_bg_color); - theme->set_stylebox("code_normal", "RichTextLabel", style_code); - Ref<StyleBoxFlat> style_code_focus = style_tree_focus->duplicate(); - style_code_focus->set_bg_color(rtl_combined_bg_color); - theme->set_stylebox("code_focus", "RichTextLabel", style_code_focus); - theme->set_color("font_color", "RichTextLabel", rtl_font_color); - theme->set_color("highlight_color", "RichTextLabel", rtl_mono_color); + theme->set_color("headline_color", "EditorHelp", mono_color); // Panel theme->set_stylebox("panel", "Panel", make_flat_stylebox(dark_color_1, 6, 4, 6, 4)); @@ -990,7 +969,7 @@ Ref<Theme> create_custom_theme() { theme = ResourceLoader::load(custom_theme); } - String global_font = EditorSettings::get_singleton()->get("interface/custom_font"); + String global_font = EditorSettings::get_singleton()->get("interface/editor/custom_font"); if (global_font != "") { Ref<Font> fnt = ResourceLoader::load(global_font); if (fnt.is_valid()) { diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index 6a936649c3..4541c77085 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -40,12 +40,8 @@ uint32_t EditorOBJImporter::get_import_flags() const { return IMPORT_SCENE; } -void EditorOBJImporter::get_extensions(List<String> *r_extensions) const { - r_extensions->push_back("obj"); -} - -Error EditorOBJImporter::_parse_material_library(const String &p_path, Map<String, Ref<SpatialMaterial> > &material_map, List<String> *r_missing_deps) { +static Error _parse_material_library(const String &p_path, Map<String, Ref<SpatialMaterial> > &material_map, List<String> *r_missing_deps) { FileAccessRef f = FileAccess::open(p_path, FileAccess::READ); ERR_FAIL_COND_V(!f, ERR_CANT_OPEN); @@ -134,7 +130,7 @@ Error EditorOBJImporter::_parse_material_library(const String &p_path, Map<Strin if (texture.is_valid()) { current->set_texture(SpatialMaterial::TEXTURE_ALBEDO, texture); - } else { + } else if (r_missing_deps) { r_missing_deps->push_back(path); } @@ -149,7 +145,7 @@ Error EditorOBJImporter::_parse_material_library(const String &p_path, Map<Strin if (texture.is_valid()) { current->set_texture(SpatialMaterial::TEXTURE_METALLIC, texture); - } else { + } else if (r_missing_deps) { r_missing_deps->push_back(path); } @@ -164,7 +160,7 @@ Error EditorOBJImporter::_parse_material_library(const String &p_path, Map<Strin if (texture.is_valid()) { current->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, texture); - } else { + } else if (r_missing_deps) { r_missing_deps->push_back(path); } } else if (l.begins_with("map_bump ")) { @@ -179,7 +175,7 @@ Error EditorOBJImporter::_parse_material_library(const String &p_path, Map<Strin if (texture.is_valid()) { current->set_feature(SpatialMaterial::FEATURE_NORMAL_MAPPING, true); current->set_texture(SpatialMaterial::TEXTURE_NORMAL, texture); - } else { + } else if (r_missing_deps) { r_missing_deps->push_back(path); } } else if (f->eof_reached()) { @@ -190,28 +186,16 @@ Error EditorOBJImporter::_parse_material_library(const String &p_path, Map<Strin return OK; } -Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { +static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p_single_mesh, bool p_generate_tangents, List<String> *r_missing_deps) { FileAccessRef f = FileAccess::open(p_path, FileAccess::READ); - if (r_err) { - *r_err = ERR_CANT_OPEN; - } - - ERR_FAIL_COND_V(!f, NULL); - - if (r_err) { - *r_err = OK; - } - - Spatial *scene = memnew(Spatial); + ERR_FAIL_COND_V(!f, ERR_CANT_OPEN); Ref<ArrayMesh> mesh; mesh.instance(); - Map<String, Ref<Material> > name_map; - - bool generate_tangents = p_flags & IMPORT_GENERATE_TANGENT_ARRAYS; + bool generate_tangents = p_generate_tangents; bool flip_faces = false; //bool flip_faces = p_options["force/flip_faces"]; //bool force_smooth = p_options["force/smooth_shading"]; @@ -239,7 +223,7 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in if (l.begins_with("v ")) { //vertex Vector<String> v = l.split(" ", false); - ERR_FAIL_COND_V(v.size() < 4, NULL); + ERR_FAIL_COND_V(v.size() < 4, ERR_FILE_CORRUPT); Vector3 vtx; vtx.x = v[1].to_float(); vtx.y = v[2].to_float(); @@ -248,7 +232,7 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in } else if (l.begins_with("vt ")) { //uv Vector<String> v = l.split(" ", false); - ERR_FAIL_COND_V(v.size() < 3, NULL); + ERR_FAIL_COND_V(v.size() < 3, ERR_FILE_CORRUPT); Vector2 uv; uv.x = v[1].to_float(); uv.y = 1.0 - v[2].to_float(); @@ -257,7 +241,7 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in } else if (l.begins_with("vn ")) { //normal Vector<String> v = l.split(" ", false); - ERR_FAIL_COND_V(v.size() < 4, NULL); + ERR_FAIL_COND_V(v.size() < 4, ERR_FILE_CORRUPT); Vector3 nrm; nrm.x = v[1].to_float(); nrm.y = v[2].to_float(); @@ -267,19 +251,19 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in //vertex Vector<String> v = l.split(" ", false); - ERR_FAIL_COND_V(v.size() < 4, NULL); + ERR_FAIL_COND_V(v.size() < 4, ERR_FILE_CORRUPT); //not very fast, could be sped up Vector<String> face[3]; face[0] = v[1].split("/"); face[1] = v[2].split("/"); - ERR_FAIL_COND_V(face[0].size() == 0, NULL); - ERR_FAIL_COND_V(face[0].size() != face[1].size(), NULL); + ERR_FAIL_COND_V(face[0].size() == 0, ERR_FILE_CORRUPT); + ERR_FAIL_COND_V(face[0].size() != face[1].size(), ERR_FILE_CORRUPT); for (int i = 2; i < v.size() - 1; i++) { face[2] = v[i + 1].split("/"); - ERR_FAIL_COND_V(face[0].size() != face[2].size(), NULL); + ERR_FAIL_COND_V(face[0].size() != face[2].size(), ERR_FILE_CORRUPT); for (int j = 0; j < 3; j++) { int idx = j; @@ -292,7 +276,7 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in int norm = face[idx][2].to_int() - 1; if (norm < 0) norm += normals.size() + 1; - ERR_FAIL_INDEX_V(norm, normals.size(), NULL); + ERR_FAIL_INDEX_V(norm, normals.size(), ERR_FILE_CORRUPT); surf_tool->add_normal(normals[norm]); } @@ -300,14 +284,14 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in int uv = face[idx][1].to_int() - 1; if (uv < 0) uv += uvs.size() + 1; - ERR_FAIL_INDEX_V(uv, uvs.size(), NULL); + ERR_FAIL_INDEX_V(uv, uvs.size(), ERR_FILE_CORRUPT); surf_tool->add_uv(uvs[uv]); } int vtx = face[idx][0].to_int() - 1; if (vtx < 0) vtx += vertices.size() + 1; - ERR_FAIL_INDEX_V(vtx, vertices.size(), NULL); + ERR_FAIL_INDEX_V(vtx, vertices.size(), ERR_FILE_CORRUPT); Vector3 vertex = vertices[vtx]; //if (weld_vertices) @@ -359,16 +343,13 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in if (l.begins_with("o ") || f->eof_reached()) { - MeshInstance *mi = memnew(MeshInstance); - mi->set_name(name); - mi->set_mesh(mesh); - - scene->add_child(mi); - mi->set_owner(scene); - - mesh.instance(); - current_group = ""; - current_material = ""; + if (!p_single_mesh) { + mesh->set_name(name); + r_meshes.push_back(mesh); + mesh.instance(); + current_group = ""; + current_material = ""; + } } if (f->eof_reached()) { @@ -406,16 +387,40 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in } } - /* - TODO, check existing materials and merge? - //re-apply materials if exist - for(int i=0;i<mesh->get_surface_count();i++) { + if (p_single_mesh) { + + r_meshes.push_back(mesh); + } + + return OK; +} + +Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { + + List<Ref<Mesh> > meshes; + + Error err = _parse_obj(p_path, meshes, false, p_flags & IMPORT_GENERATE_TANGENT_ARRAYS, r_missing_deps); + + if (err != OK) { + if (r_err) { + *r_err = err; + } + return NULL; + } + + Spatial *scene = memnew(Spatial); + + for (List<Ref<Mesh> >::Element *E = meshes.front(); E; E = E->next()) { + + MeshInstance *mi = memnew(MeshInstance); + mi->set_name(E->get()->get_name()); + scene->add_child(mi); + mi->set_owner(scene); + } - String n = mesh->surface_get_name(i); - if (name_map.has(n)) - mesh->surface_set_material(i,name_map[n]); + if (r_err) { + *r_err = OK; } -*/ return scene; } @@ -423,5 +428,68 @@ Ref<Animation> EditorOBJImporter::import_animation(const String &p_path, uint32_ return Ref<Animation>(); } + +void EditorOBJImporter::get_extensions(List<String> *r_extensions) const { + + r_extensions->push_back("obj"); +} + EditorOBJImporter::EditorOBJImporter() { } +//////////////////////////////////////////////////// + +String ResourceImporterOBJ::get_importer_name() const { + return "wavefront_obj"; +} +String ResourceImporterOBJ::get_visible_name() const { + return "OBJ As Mesh"; +} +void ResourceImporterOBJ::get_recognized_extensions(List<String> *p_extensions) const { + + p_extensions->push_back("obj"); +} +String ResourceImporterOBJ::get_save_extension() const { + return "mesh"; +} +String ResourceImporterOBJ::get_resource_type() const { + return "Mesh"; +} + +int ResourceImporterOBJ::get_preset_count() const { + return 0; +} +String ResourceImporterOBJ::get_preset_name(int p_idx) const { + return ""; +} + +void ResourceImporterOBJ::get_import_options(List<ImportOption> *r_options, int p_preset) const { + + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "generate_tangents"), true)); +} +bool ResourceImporterOBJ::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { + + return true; +} + +Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) { + + List<Ref<Mesh> > meshes; + + Error err = _parse_obj(p_source_file, meshes, true, p_options["generate_tangents"], NULL); + + ERR_FAIL_COND_V(err != OK, err); + ERR_FAIL_COND_V(meshes.size() != 1, ERR_BUG); + + String save_path = p_save_path + ".mesh"; + + err = ResourceSaver::save(save_path, meshes.front()->get()); + + ERR_FAIL_COND_V(err != OK, err); + + r_gen_files->push_back(save_path); + + return OK; +} + +ResourceImporterOBJ::ResourceImporterOBJ() { +} diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h index 247d58e148..7eeceeabbe 100644 --- a/editor/import/resource_importer_obj.h +++ b/editor/import/resource_importer_obj.h @@ -36,8 +36,6 @@ class EditorOBJImporter : public EditorSceneImporter { GDCLASS(EditorOBJImporter, EditorSceneImporter); - Error _parse_material_library(const String &p_path, Map<String, Ref<SpatialMaterial> > &material_map, List<String> *r_missing_deps); - public: virtual uint32_t get_import_flags() const; virtual void get_extensions(List<String> *r_extensions) const; @@ -47,4 +45,24 @@ public: EditorOBJImporter(); }; +class ResourceImporterOBJ : public ResourceImporter { + GDCLASS(ResourceImporterOBJ, ResourceImporter) +public: + virtual String get_importer_name() const; + virtual String get_visible_name() const; + virtual void get_recognized_extensions(List<String> *p_extensions) const; + virtual String get_save_extension() const; + virtual String get_resource_type() const; + + virtual int get_preset_count() const; + virtual String get_preset_name(int p_idx) const; + + virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; + virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; + + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL); + + ResourceImporterOBJ(); +}; + #endif // RESOURCEIMPORTEROBJ_H diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index b6b112b905..3310f1f496 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1219,50 +1219,26 @@ void CanvasItemEditor::_viewport_base_gui_input(const Ref<InputEvent> &p_event) if (b->get_button_index() == BUTTON_WHEEL_DOWN) { // Scroll or pan down if (bool(EditorSettings::get_singleton()->get("editors/2d/scroll_to_pan"))) { - v_scroll->set_value(v_scroll->get_value() + int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor()); - + _update_scroll(0); + viewport->update(); } else { - - if (zoom < MIN_ZOOM) - return; - - float prev_zoom = zoom; - zoom = zoom * (1 - (0.05 * b->get_factor())); - { - Point2 ofs = viewport_scrollable->get_transform().affine_inverse().xform(b->get_position()); - ofs = ofs / prev_zoom - ofs / zoom; - h_scroll->set_value(h_scroll->get_value() + ofs.x); - v_scroll->set_value(v_scroll->get_value() + ofs.y); - } + _zoom_on_position(zoom * (1 - (0.05 * b->get_factor())), viewport_scrollable->get_transform().affine_inverse().xform(b->get_position())); } - _update_scroll(0); - viewport->update(); return; } if (b->get_button_index() == BUTTON_WHEEL_UP) { // Scroll or pan up if (bool(EditorSettings::get_singleton()->get("editors/2d/scroll_to_pan"))) { - v_scroll->set_value(v_scroll->get_value() - int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor()); - + _update_scroll(0); + viewport->update(); } else { - if (zoom > MAX_ZOOM) return; - - float prev_zoom = zoom; - zoom = zoom * ((0.95 + (0.05 * b->get_factor())) / 0.95); - { - Point2 ofs = viewport_scrollable->get_transform().affine_inverse().xform(b->get_position()); - ofs = ofs / prev_zoom - ofs / zoom; - h_scroll->set_value(h_scroll->get_value() + ofs.x); - v_scroll->set_value(v_scroll->get_value() + ofs.y); - } + _zoom_on_position(zoom * ((0.95 + (0.05 * b->get_factor())) / 0.95), viewport_scrollable->get_transform().affine_inverse().xform(b->get_position())); } - _update_scroll(0); - viewport->update(); return; } @@ -2668,13 +2644,13 @@ void CanvasItemEditor::_draw_viewport() { all_group = false; } else { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (Object::cast_to<Control>(E->get()) && !Object::cast_to<Control>(E->get())->has_meta("_edit_lock_")) { + if (Object::cast_to<CanvasItem>(E->get()) && !Object::cast_to<CanvasItem>(E->get())->has_meta("_edit_lock_")) { all_locked = false; break; } } for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (Object::cast_to<Control>(E->get()) && !Object::cast_to<Control>(E->get())->has_meta("_edit_group_")) { + if (Object::cast_to<CanvasItem>(E->get()) && !Object::cast_to<CanvasItem>(E->get())->has_meta("_edit_group_")) { all_group = false; break; } @@ -2704,6 +2680,7 @@ void CanvasItemEditor::_draw_viewport() { over_plugin_list->forward_draw_over_canvas(transform, viewport); } _draw_focus(); + _draw_bones(); } void CanvasItemEditor::_notification(int p_what) { @@ -3068,31 +3045,32 @@ void CanvasItemEditor::_set_full_rect() { undo_redo->commit_action(); } -void CanvasItemEditor::_zoom_minus() { - if (zoom < MIN_ZOOM) +void CanvasItemEditor::_zoom_on_position(float p_zoom, Point2 p_position) { + if (p_zoom < MIN_ZOOM || p_zoom > MAX_ZOOM) return; - zoom /= 2.0; + + float prev_zoom = zoom; + zoom = p_zoom; + Point2 ofs = p_position; + ofs = ofs / prev_zoom - ofs / zoom; + h_scroll->set_value(h_scroll->get_value() + ofs.x); + v_scroll->set_value(v_scroll->get_value() + ofs.y); _update_scroll(0); viewport->update(); viewport_base->update(); } +void CanvasItemEditor::_zoom_minus() { + _zoom_on_position(zoom / 2.0, viewport_scrollable->get_size() / 2.0); +} + void CanvasItemEditor::_zoom_reset() { - zoom = 1; - _update_scroll(0); - viewport->update(); - viewport_base->update(); + _zoom_on_position(1.0, viewport_scrollable->get_size() / 2.0); } void CanvasItemEditor::_zoom_plus() { - if (zoom > MAX_ZOOM) - return; - - zoom *= 2.0; - _update_scroll(0); - viewport->update(); - viewport_base->update(); + _zoom_on_position(zoom * 2.0, viewport_scrollable->get_size() / 2.0); } void CanvasItemEditor::_toggle_snap(bool p_status) { @@ -4181,7 +4159,7 @@ void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String & editor_data->get_undo_redo().add_do_property(child, property, texture); // make visible for certain node type - if (default_type == "Patch9Rect") { + if (default_type == "NinePatchRect") { editor_data->get_undo_redo().add_do_property(child, "rect/size", texture_size); } else if (default_type == "Polygon2D") { PoolVector<Vector2> list; @@ -4199,7 +4177,7 @@ void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String & } Transform2D trans = canvas->get_canvas_transform(); Point2 target_position = (p_point - trans.get_origin()) / trans.get_scale().x - pos; - if (default_type == "Polygon2D" || default_type == "TouchScreenButton" || default_type == "TextureRect" || default_type == "Patch9Rect") { + if (default_type == "Polygon2D" || default_type == "TouchScreenButton" || default_type == "TextureRect" || default_type == "NinePatchRect") { target_position -= texture_size / 2; } // there's nothing to be used as source position so snapping will work as absolute if enabled @@ -4275,7 +4253,7 @@ void CanvasItemEditorViewport::_perform_drop_data() { child = memnew(TouchScreenButton); else if (default_type == "TextureRect") child = memnew(TextureRect); - else if (default_type == "Patch9Rect") + else if (default_type == "NinePatchRect") child = memnew(NinePatchRect); else child = memnew(Sprite); // default @@ -4437,7 +4415,7 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte types.push_back("TouchScreenButton"); // Control types.push_back("TextureRect"); - types.push_back("Patch9Rect"); + types.push_back("NinePatchRect"); target_node = NULL; editor = p_node; diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index af834507e0..bb4e584f2a 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -387,6 +387,7 @@ class CanvasItemEditor : public VBoxContainer { void _set_anchors_preset(Control::LayoutPreset p_preset); void _set_full_rect(); + void _zoom_on_position(float p_zoom, Point2 p_position = Point2()); void _zoom_minus(); void _zoom_reset(); void _zoom_plus(); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 47443b81ce..b66e9598f9 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1557,11 +1557,7 @@ ScriptTextEditor::ScriptTextEditor() { static ScriptEditorBase *create_editor(const Ref<Script> &p_script) { - if (p_script->has_source_code()) { - return memnew(ScriptTextEditor); - } - - return NULL; + return memnew(ScriptTextEditor); } void ScriptTextEditor::register_editor() { diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 3370ce51fd..0a7f3ff8f9 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -907,7 +907,7 @@ void TextureRegionEditorPlugin::edit(Object *p_object) { } bool TextureRegionEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("Sprite") || p_object->is_class("Patch9Rect") || p_object->is_class("StyleBoxTexture") || p_object->is_class("AtlasTexture"); + return p_object->is_class("Sprite") || p_object->is_class("NinePatchRect") || p_object->is_class("StyleBoxTexture") || p_object->is_class("AtlasTexture"); } void TextureRegionEditorPlugin::make_visible(bool p_visible) { diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index c679b44342..1a767dad05 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -1418,7 +1418,7 @@ ProjectManager::ProjectManager() { EditorSettings::get_singleton()->set_optimize_save(false); //just write settings as they came { - int dpi_mode = EditorSettings::get_singleton()->get("interface/hidpi_mode"); + int dpi_mode = EditorSettings::get_singleton()->get("interface/editor/hidpi_mode"); if (dpi_mode == 0) { editor_set_scale(OS::get_singleton()->get_screen_dpi(0) >= 192 && OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x > 2000 ? 2.0 : 1.0); } else if (dpi_mode == 1) { diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index fcae4c04fb..9665f48e42 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -4257,7 +4257,7 @@ PropertyEditor::PropertyEditor() { use_filter = false; subsection_selectable = false; property_selectable = false; - show_type_icons = EDITOR_DEF("interface/show_type_icons", false); + show_type_icons = EDITOR_DEF("interface/editor/show_type_icons", false); } PropertyEditor::~PropertyEditor() { diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index 8d3eb5974e..c968f4edd4 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -1045,6 +1045,8 @@ void ScriptEditorDebugger::_notification(int p_what) { tabs->add_style_override("panel", editor->get_gui_base()->get_stylebox("DebuggerPanel", "EditorStyles")); tabs->add_style_override("tab_fg", editor->get_gui_base()->get_stylebox("DebuggerTabFG", "EditorStyles")); tabs->add_style_override("tab_bg", editor->get_gui_base()->get_stylebox("DebuggerTabBG", "EditorStyles")); + tabs->set_margin(MARGIN_LEFT, -EditorNode::get_singleton()->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT)); + tabs->set_margin(MARGIN_RIGHT, EditorNode::get_singleton()->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_RIGHT)); } break; } } @@ -1622,7 +1624,10 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { tabs->add_style_override("panel", editor->get_gui_base()->get_stylebox("DebuggerPanel", "EditorStyles")); tabs->add_style_override("tab_fg", editor->get_gui_base()->get_stylebox("DebuggerTabFG", "EditorStyles")); tabs->add_style_override("tab_bg", editor->get_gui_base()->get_stylebox("DebuggerTabBG", "EditorStyles")); + tabs->set_anchors_and_margins_preset(Control::PRESET_WIDE); + tabs->set_margin(MARGIN_LEFT, -editor->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT)); + tabs->set_margin(MARGIN_RIGHT, editor->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_RIGHT)); add_child(tabs); { //debugger diff --git a/main/performance.cpp b/main/performance.cpp index e85d2bf736..4dac6c119e 100644 --- a/main/performance.cpp +++ b/main/performance.cpp @@ -94,7 +94,7 @@ String Performance::get_monitor_name(Monitor p_monitor) const { "raster/surface_changes", "raster/draw_calls", "video/video_mem", - "video/texure_mem", + "video/texture_mem", "video/vertex_mem", "video/video_mem_max", "physics_2d/active_objects", diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp index 11856e4ffb..f0c09a3370 100644 --- a/modules/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative.cpp @@ -110,6 +110,7 @@ GDNativeLibrary::~GDNativeLibrary() { void GDNativeLibrary::_bind_methods() { ClassDB::bind_method(D_METHOD("set_library_path", "platform", "path"), &GDNativeLibrary::set_library_path); ClassDB::bind_method(D_METHOD("get_library_path", "platform"), &GDNativeLibrary::get_library_path); + ClassDB::bind_method(D_METHOD("get_active_library_path"), &GDNativeLibrary::get_active_library_path); ClassDB::bind_method(D_METHOD("is_singleton_gdnative"), &GDNativeLibrary::is_singleton_gdnative); ClassDB::bind_method(D_METHOD("set_singleton_gdnative", "singleton"), &GDNativeLibrary::set_singleton_gdnative); @@ -268,6 +269,7 @@ bool GDNative::initialize() { options.editor_api_hash = ClassDB::get_api_hash(ClassDB::API_EDITOR); options.no_api_hash = ClassDB::get_api_hash(ClassDB::API_NONE); options.gd_native_library = (godot_object *)(get_library().ptr()); + options.active_library_path = (godot_string *)&path; library_init_fpointer(&options); diff --git a/modules/gdnative/include/gdnative/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h index 19dd030637..9134f1c581 100644 --- a/modules/gdnative/include/gdnative/gdnative.h +++ b/modules/gdnative/include/gdnative/gdnative.h @@ -243,6 +243,7 @@ typedef struct { uint64_t no_api_hash; godot_object *gd_native_library; // pointer to GDNativeLibrary that is being initialized const struct godot_gdnative_api_struct *api_struct; + const godot_string *active_library_path; } godot_gdnative_init_options; typedef struct { diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index aa39ad92c4..b0408917a4 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -1952,7 +1952,6 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N //make sure identifier exists... const GDParser::IdentifierNode *id = static_cast<const GDParser::IdentifierNode *>(op->arguments[1]); - if (op->arguments[0]->type == GDParser::Node::TYPE_SELF) { //self, look up @@ -2021,7 +2020,7 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N base = script->get_native(); } else if (nc.is_valid()) { - if (context.function && !context.function->_static) { + if (!(context.function && context.function->_static)) { GDCompletionIdentifier ci; ci.type = Variant::OBJECT; diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp index 767ea29f3c..9df2823c35 100644 --- a/modules/gdscript/gd_function.cpp +++ b/modules/gdscript/gd_function.cpp @@ -469,7 +469,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a if (cmp == scr_B) { //inherits from script, all ok extends_ok = true; - OPCODE_BREAK; + break; } cmp = cmp->_base; diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp index e27452354b..9c198ea98e 100644 --- a/modules/svg/image_loader_svg.cpp +++ b/modules/svg/image_loader_svg.cpp @@ -51,7 +51,7 @@ inline void change_nsvg_paint_color(NSVGpaint *p_paint, const uint32_t p_old, co if (p_paint->type == NSVG_PAINT_COLOR) { if (p_paint->color << 8 == p_old << 8) { - p_paint->color = p_new; + p_paint->color = (p_paint->color & 0xFF000000) | (p_new & 0x00FFFFFF); } } diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp index c17265d275..8d73de9889 100644 --- a/modules/visual_script/visual_script_func_nodes.cpp +++ b/modules/visual_script/visual_script_func_nodes.cpp @@ -763,7 +763,7 @@ public: NodePath node_path; int input_args; bool validate; - bool returns; + int returns; VisualScriptFunctionCall::RPCCallMode rpc_mode; StringName function; StringName singleton; @@ -856,7 +856,13 @@ public: } } else if (returns) { if (call_mode == VisualScriptFunctionCall::CALL_MODE_INSTANCE) { - *p_outputs[1] = v.call(function, p_inputs + 1, input_args, r_error); + if (returns >= 2) { + *p_outputs[1] = v.call(function, p_inputs + 1, input_args, r_error); + } else { + r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; + r_error_str = "Invalid returns count for call_mode == CALL_MODE_INSTANCE"; + return 0; + } } else { *p_outputs[0] = v.call(function, p_inputs + 1, input_args, r_error); } diff --git a/platform/iphone/SCsub b/platform/iphone/SCsub index 998d0a3f0d..61798c5f87 100644 --- a/platform/iphone/SCsub +++ b/platform/iphone/SCsub @@ -5,7 +5,6 @@ Import('env') iphone_lib = [ 'os_iphone.cpp', - 'audio_driver_iphone.cpp', 'sem_iphone.cpp', 'gl_view.mm', 'main.m', diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index c7b65b476b..da6ceacdac 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -29,8 +29,8 @@ /*************************************************************************/ #import "app_delegate.h" -#include "audio_driver_iphone.h" #include "core/project_settings.h" +#include "drivers/coreaudio/audio_driver_coreaudio.h" #import "gl_view.h" #include "main/main.h" #include "os_iphone.h" @@ -736,8 +736,8 @@ static int frame_count = 0; }; // Fixed audio can not resume if it is interrupted cause by an incoming phone call - if (AudioDriverIphone::get_singleton() != NULL) - AudioDriverIphone::get_singleton()->start(); + if (AudioDriverCoreAudio::get_singleton() != NULL) + AudioDriverCoreAudio::get_singleton()->start(); } - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { diff --git a/platform/iphone/audio_driver_iphone.cpp b/platform/iphone/audio_driver_iphone.cpp deleted file mode 100644 index dbc5bdb654..0000000000 --- a/platform/iphone/audio_driver_iphone.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/*************************************************************************/ -/* audio_driver_iphone.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "audio_driver_iphone.h" - -Error AudioDriverIphone::init() { - - active = false; - channels = 2; - - AudioStreamBasicDescription strdesc; - strdesc.mFormatID = kAudioFormatLinearPCM; - strdesc.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked; - strdesc.mChannelsPerFrame = channels; - strdesc.mSampleRate = 44100; - strdesc.mFramesPerPacket = 1; - strdesc.mBitsPerChannel = 16; - strdesc.mBytesPerFrame = - strdesc.mBitsPerChannel * strdesc.mChannelsPerFrame / 8; - strdesc.mBytesPerPacket = - strdesc.mBytesPerFrame * strdesc.mFramesPerPacket; - - AURenderCallbackStruct callback; - AudioComponentDescription desc; - const AudioUnitElement output_bus = 0; - const AudioUnitElement bus = output_bus; - const AudioUnitScope scope = kAudioUnitScope_Input; - - zeromem(&desc, sizeof(desc)); - desc.componentType = kAudioUnitType_Output; - desc.componentSubType = kAudioUnitSubType_RemoteIO; /* !!! FIXME: ? */ - AudioComponent comp = AudioComponentFindNext(NULL, &desc); - desc.componentManufacturer = kAudioUnitManufacturer_Apple; - - OSStatus result = AudioComponentInstanceNew(comp, &audio_unit); - ERR_FAIL_COND_V(result != noErr, FAILED); - ERR_FAIL_COND_V(comp == NULL, FAILED); - - result = AudioUnitSetProperty(audio_unit, - kAudioUnitProperty_StreamFormat, - scope, bus, &strdesc, sizeof(strdesc)); - ERR_FAIL_COND_V(result != noErr, FAILED); - - zeromem(&callback, sizeof(AURenderCallbackStruct)); - callback.inputProc = &AudioDriverIphone::output_callback; - callback.inputProcRefCon = this; - result = AudioUnitSetProperty(audio_unit, - kAudioUnitProperty_SetRenderCallback, - scope, bus, &callback, sizeof(callback)); - ERR_FAIL_COND_V(result != noErr, FAILED); - - result = AudioUnitInitialize(audio_unit); - ERR_FAIL_COND_V(result != noErr, FAILED); - - result = AudioOutputUnitStart(audio_unit); - ERR_FAIL_COND_V(result != noErr, FAILED); - - const int samples = 1024; - samples_in = memnew_arr(int32_t, samples); // whatever - buffer_frames = samples / channels; - - return FAILED; -}; - -OSStatus AudioDriverIphone::output_callback(void *inRefCon, - AudioUnitRenderActionFlags *ioActionFlags, - const AudioTimeStamp *inTimeStamp, - UInt32 inBusNumber, UInt32 inNumberFrames, - AudioBufferList *ioData) { - - AudioBuffer *abuf; - AudioDriverIphone *ad = (AudioDriverIphone *)inRefCon; - - bool mix = true; - - if (!ad->active) - mix = false; - else if (ad->mutex) { - mix = ad->mutex->try_lock() == OK; - }; - - if (!mix) { - for (unsigned int i = 0; i < ioData->mNumberBuffers; i++) { - abuf = &ioData->mBuffers[i]; - zeromem(abuf->mData, abuf->mDataByteSize); - }; - return 0; - }; - - int frames_left; - - for (unsigned int i = 0; i < ioData->mNumberBuffers; i++) { - - abuf = &ioData->mBuffers[i]; - frames_left = inNumberFrames; - int16_t *out = (int16_t *)abuf->mData; - - while (frames_left) { - - int frames = MIN(frames_left, ad->buffer_frames); - //ad->lock(); - ad->audio_server_process(frames, ad->samples_in); - //ad->unlock(); - - for (int i = 0; i < frames * ad->channels; i++) { - - out[i] = ad->samples_in[i] >> 16; - } - - frames_left -= frames; - out += frames * ad->channels; - }; - }; - - if (ad->mutex) - ad->mutex->unlock(); - - return 0; -}; - -void AudioDriverIphone::start() { - active = true; - // Resume audio - // iOS audio-thread stoped if it is interrupted cause by an incoming phone call - // Use AudioOutputUnitStart to re-create audio-thread - OSStatus result = AudioOutputUnitStart(audio_unit); - ERR_FAIL_COND(result != noErr); -}; - -int AudioDriverIphone::get_mix_rate() const { - return 44100; -}; - -AudioDriver::SpeakerMode AudioDriverIphone::get_speaker_mode() const { - return SPEAKER_MODE_STEREO; -}; - -void AudioDriverIphone::lock() { - - if (active && mutex) - mutex->lock(); -}; - -void AudioDriverIphone::unlock() { - if (active && mutex) - mutex->unlock(); -}; - -void AudioDriverIphone::finish() { - - memdelete_arr(samples_in); -}; - -AudioDriverIphone::AudioDriverIphone() { - - mutex = Mutex::create(); //NULL; -}; - -AudioDriverIphone::~AudioDriverIphone(){ - -}; diff --git a/platform/iphone/audio_driver_iphone.h b/platform/iphone/audio_driver_iphone.h deleted file mode 100644 index 930ed168f7..0000000000 --- a/platform/iphone/audio_driver_iphone.h +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************/ -/* audio_driver_iphone.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ - -#include "servers/audio_server.h" - -#include <AudioUnit/AudioUnit.h> - -class AudioDriverIphone : public AudioDriver { - - AudioComponentInstance audio_unit; - bool active; - Mutex *mutex; - - int channels; - int32_t *samples_in; - int buffer_frames; - - static OSStatus output_callback(void *inRefCon, - AudioUnitRenderActionFlags *ioActionFlags, - const AudioTimeStamp *inTimeStamp, - UInt32 inBusNumber, UInt32 inNumberFrames, - AudioBufferList *ioData); - -public: - const char *get_name() const { - return "IPhone"; - }; - - virtual Error init(); - virtual void start(); - virtual int get_mix_rate() const; - virtual SpeakerMode get_speaker_mode() const; - virtual void lock(); - virtual void unlock(); - virtual void finish(); - - AudioDriverIphone(); - ~AudioDriverIphone(); -}; diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py index dd4db0b1cd..00d8a59f74 100644 --- a/platform/iphone/detect.py +++ b/platform/iphone/detect.py @@ -148,7 +148,7 @@ def configure(env): env['ENV']['CODESIGN_ALLOCATE'] = '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate' env.Append(CPPPATH=['#platform/iphone']) - env.Append(CPPFLAGS=['-DIPHONE_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DMPC_FIXED_POINT']) + env.Append(CPPFLAGS=['-DIPHONE_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DMPC_FIXED_POINT', '-DCOREAUDIO_ENABLED']) # TODO: Move that to opus module's config if 'module_opus_enabled' in env and env['module_opus_enabled']: diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp index 0e3eeed114..086cbe5010 100644 --- a/platform/iphone/os_iphone.cpp +++ b/platform/iphone/os_iphone.cpp @@ -35,7 +35,6 @@ #include "servers/visual/visual_server_raster.h" //#include "servers/visual/visual_server_wrap_mt.h" -#include "audio_driver_iphone.h" #include "main/main.h" #include "core/io/file_access_pack.h" @@ -124,9 +123,8 @@ void OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p_ // reset this to what it should be, it will have been set to 0 after visual_server->init() is called RasterizerStorageGLES3::system_fbo = gl_view_base_fb; - audio_driver = memnew(AudioDriverIphone); - audio_driver->set_singleton(); - audio_driver->init(); + AudioDriverManager::add_driver(&audio_driver); + AudioDriverManager::initialize(p_audio_driver); // init physics servers physics_server = memnew(PhysicsServerSW); diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h index 475dceebf2..3ebd5a74db 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -32,6 +32,7 @@ #ifndef OS_IPHONE_H #define OS_IPHONE_H +#include "drivers/coreaudio/audio_driver_coreaudio.h" #include "drivers/unix/os_unix.h" #include "os/input.h" @@ -46,8 +47,6 @@ #include "servers/visual/rasterizer.h" #include "servers/visual_server.h" -class AudioDriverIphone; - class OSIPhone : public OS_Unix { public: @@ -70,7 +69,7 @@ private: PhysicsServer *physics_server; Physics2DServer *physics_2d_server; - AudioDriverIphone *audio_driver; + AudioDriverCoreAudio audio_driver; #ifdef GAME_CENTER_ENABLED GameCenter *game_center; diff --git a/platform/javascript/engine.js b/platform/javascript/engine.js index 552f5a7e02..99d1c20bbd 100644 --- a/platform/javascript/engine.js +++ b/platform/javascript/engine.js @@ -84,10 +84,10 @@ rtenvOpts.print = stdout; if (typeof stderr === 'function') rtenvOpts.printErr = stderr; - if (typeof WebAssembly === 'object' && initializer instanceof WebAssembly.Module) { + if (typeof WebAssembly === 'object' && initializer instanceof ArrayBuffer) { rtenvOpts.instantiateWasm = function(imports, onSuccess) { WebAssembly.instantiate(initializer, imports).then(function(result) { - onSuccess(result); + onSuccess(result.instance); }); return {}; }; @@ -241,7 +241,7 @@ return Promise.reject(new Error("Browser doesn't support WebAssembly")); // TODO cache/retrieve module to/from idb engineLoadPromise = loadPromise(basePath + '.wasm').then(function(xhr) { - return WebAssembly.compile(xhr.response); + return xhr.response; }); } else { var asmjsPromise = loadPromise(basePath + '.asm.js').then(function(xhr) { diff --git a/platform/osx/SCsub b/platform/osx/SCsub index 27bffbe80e..be3950bc6d 100644 --- a/platform/osx/SCsub +++ b/platform/osx/SCsub @@ -10,7 +10,6 @@ files = [ 'crash_handler_osx.mm', 'os_osx.mm', 'godot_main_osx.mm', - 'audio_driver_osx.cpp', 'sem_osx.cpp', 'dir_access_osx.mm', 'joypad_osx.cpp', diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 51da000712..f66c3f00da 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -103,7 +103,7 @@ def configure(env): ## Flags env.Append(CPPPATH=['#platform/osx']) - env.Append(CPPFLAGS=['-DOSX_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DAPPLE_STYLE_KEYS']) + env.Append(CPPFLAGS=['-DOSX_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DAPPLE_STYLE_KEYS', '-DCOREAUDIO_ENABLED']) env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit', '-framework', 'CoreAudio', '-lz', '-framework', 'IOKit', '-framework', 'ForceFeedback']) env.Append(LIBS=['pthread']) diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 6c81da04f5..1f76b7f990 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -31,13 +31,11 @@ #define OS_OSX_H #include "crash_handler_osx.h" -#include "drivers/alsa/audio_driver_alsa.h" -#include "drivers/rtaudio/audio_driver_rtaudio.h" +#include "drivers/coreaudio/audio_driver_coreaudio.h" #include "drivers/unix/os_unix.h" #include "joypad_osx.h" #include "main/input_default.h" #include "os/input.h" -#include "platform/osx/audio_driver_osx.h" #include "power_osx.h" #include "servers/audio_server.h" #include "servers/physics_2d/physics_2d_server_sw.h" @@ -69,7 +67,7 @@ public: IP_Unix *ip_unix; - AudioDriverOSX audio_driver_osx; + AudioDriverCoreAudio audio_driver; InputDefault *input; JoypadOSX *joypad_osx; diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 9a26adc155..16bef349dc 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1071,7 +1071,7 @@ void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_au bool use_gl2 = p_video_driver != 1; - AudioDriverManager::add_driver(&audio_driver_osx); + AudioDriverManager::add_driver(&audio_driver); // only opengl support here... RasterizerGLES3::register_config(); diff --git a/scene/3d/immediate_geometry.h b/scene/3d/immediate_geometry.h index 6db825bf54..93ef726c6d 100644 --- a/scene/3d/immediate_geometry.h +++ b/scene/3d/immediate_geometry.h @@ -38,7 +38,7 @@ class ImmediateGeometry : public GeometryInstance { GDCLASS(ImmediateGeometry, GeometryInstance); RID im; - //a list of texures drawn need to be kept, to avoid references + //a list of textures drawn need to be kept, to avoid references // in VisualServer from becoming invalid if the texture is no longer used List<Ref<Texture> > cached_textures; bool empty; diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp index 3518113130..a072572142 100644 --- a/scene/3d/vehicle_body.cpp +++ b/scene/3d/vehicle_body.cpp @@ -267,6 +267,8 @@ void VehicleWheel::_bind_methods() { ClassDB::bind_method(D_METHOD("set_roll_influence", "roll_influence"), &VehicleWheel::set_roll_influence); ClassDB::bind_method(D_METHOD("get_roll_influence"), &VehicleWheel::get_roll_influence); + ClassDB::bind_method(D_METHOD("get_skidinfo"), &VehicleWheel::get_skidinfo); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_as_traction"), "set_use_as_traction", "is_used_as_traction"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_as_steering"), "set_use_as_steering", "is_used_as_steering"); ADD_GROUP("Wheel", "wheel_"); @@ -303,6 +305,11 @@ bool VehicleWheel::is_used_as_steering() const { return steers; } +float VehicleWheel::get_skidinfo() const { + + return m_skidInfo; +} + VehicleWheel::VehicleWheel() { steers = false; diff --git a/scene/3d/vehicle_body.h b/scene/3d/vehicle_body.h index eb661adb90..c642eb61b8 100644 --- a/scene/3d/vehicle_body.h +++ b/scene/3d/vehicle_body.h @@ -131,6 +131,8 @@ public: void set_roll_influence(float p_value); float get_roll_influence() const; + float get_skidinfo() const; + String get_configuration_warning() const; VehicleWheel(); diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index b0eb12fb6b..0d3cccc2b5 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -941,17 +941,17 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { //too difficult to get right //set_zoom(zoom/ZOOM_SCALE); } - if (b->get_button_index() == BUTTON_WHEEL_UP) { - h_scroll->set_value(h_scroll->get_value() - h_scroll->get_page() * b->get_factor() / 8); - } - if (b->get_button_index() == BUTTON_WHEEL_DOWN) { - h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * b->get_factor() / 8); + if (b->get_button_index() == BUTTON_WHEEL_UP && !Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { + v_scroll->set_value(v_scroll->get_value() - v_scroll->get_page() * b->get_factor() / 8); } - if (b->get_button_index() == BUTTON_WHEEL_RIGHT) { + if (b->get_button_index() == BUTTON_WHEEL_DOWN && !Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * b->get_factor() / 8); } - if (b->get_button_index() == BUTTON_WHEEL_LEFT) { - v_scroll->set_value(v_scroll->get_value() - v_scroll->get_page() * b->get_factor() / 8); + if (b->get_button_index() == BUTTON_WHEEL_RIGHT || (b->get_button_index() == BUTTON_WHEEL_DOWN && Input::get_singleton()->is_key_pressed(KEY_SHIFT))) { + h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * b->get_factor() / 8); + } + if (b->get_button_index() == BUTTON_WHEEL_LEFT || (b->get_button_index() == BUTTON_WHEEL_UP && Input::get_singleton()->is_key_pressed(KEY_SHIFT))) { + h_scroll->set_value(h_scroll->get_value() - h_scroll->get_page() * b->get_factor() / 8); } } diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 80e12e9580..6e50614e8f 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -264,9 +264,9 @@ void TabContainer::_notification(int p_what) { if (popup) { x -= menu->get_width(); if (mouse_x_cache > x) - menu_hl->draw(get_canvas_item(), Size2(x, 0)); + menu_hl->draw(get_canvas_item(), Size2(x, (header_height - menu_hl->get_height()) / 2)); else - menu->draw(get_canvas_item(), Size2(x, 0)); + menu->draw(get_canvas_item(), Size2(x, (header_height - menu->get_height()) / 2)); } // Draw the navigation buttons. diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index d79ce25344..11bdbfc3e8 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -501,8 +501,7 @@ void TextEdit::_notification(int p_what) { if (cache.background_color.a > 0.01) { - Point2i ofs = Point2i(cache.style_normal->get_offset()) / 2.0; - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(ofs, get_size() - cache.style_normal->get_minimum_size() + ofs), cache.background_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(), get_size()), cache.background_color); } //compute actual region to start (may be inside say, a comment). //slow in very large documments :( but ok for source! diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index da3bc6a95b..4c6fa7c8a1 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -55,12 +55,11 @@ void Environment::set_sky(const Ref<Sky> &p_sky) { VS::get_singleton()->environment_set_sky(environment, sb_rid); } -void Environment::set_sky_scale(float p_scale) { +void Environment::set_sky_custom_fov(float p_scale) { - bg_sky_scale = p_scale; - VS::get_singleton()->environment_set_sky_scale(environment, p_scale); + bg_sky_custom_fov = p_scale; + VS::get_singleton()->environment_set_sky_custom_fov(environment, p_scale); } - void Environment::set_bg_color(const Color &p_color) { bg_color = p_color; @@ -101,9 +100,9 @@ Ref<Sky> Environment::get_sky() const { return bg_sky; } -float Environment::get_sky_scale() const { +float Environment::get_sky_custom_fov() const { - return bg_sky_scale; + return bg_sky_custom_fov; } Color Environment::get_bg_color() const { @@ -268,7 +267,7 @@ Ref<Texture> Environment::get_adjustment_color_correction() const { void Environment::_validate_property(PropertyInfo &property) const { - if (property.name == "background_sky" || property.name == "background_sky_scale" || property.name == "ambient_light/sky_contribution") { + if (property.name == "background_sky" || property.name == "background_sky_custom_fov" || property.name == "ambient_light/sky_contribution") { if (bg_mode != BG_SKY && bg_mode != BG_COLOR_SKY) { property.usage = PROPERTY_USAGE_NOEDITOR; } @@ -820,7 +819,7 @@ void Environment::_bind_methods() { ClassDB::bind_method(D_METHOD("set_background", "mode"), &Environment::set_background); ClassDB::bind_method(D_METHOD("set_sky", "sky"), &Environment::set_sky); - ClassDB::bind_method(D_METHOD("set_sky_scale", "scale"), &Environment::set_sky_scale); + ClassDB::bind_method(D_METHOD("set_sky_custom_fov", "scale"), &Environment::set_sky_custom_fov); ClassDB::bind_method(D_METHOD("set_bg_color", "color"), &Environment::set_bg_color); ClassDB::bind_method(D_METHOD("set_bg_energy", "energy"), &Environment::set_bg_energy); ClassDB::bind_method(D_METHOD("set_canvas_max_layer", "layer"), &Environment::set_canvas_max_layer); @@ -830,7 +829,7 @@ void Environment::_bind_methods() { ClassDB::bind_method(D_METHOD("get_background"), &Environment::get_background); ClassDB::bind_method(D_METHOD("get_sky"), &Environment::get_sky); - ClassDB::bind_method(D_METHOD("get_sky_scale"), &Environment::get_sky_scale); + ClassDB::bind_method(D_METHOD("get_sky_custom_fov"), &Environment::get_sky_custom_fov); ClassDB::bind_method(D_METHOD("get_bg_color"), &Environment::get_bg_color); ClassDB::bind_method(D_METHOD("get_bg_energy"), &Environment::get_bg_energy); ClassDB::bind_method(D_METHOD("get_canvas_max_layer"), &Environment::get_canvas_max_layer); @@ -841,7 +840,7 @@ void Environment::_bind_methods() { ADD_GROUP("Background", "background_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "background_mode", PROPERTY_HINT_ENUM, "Clear Color,Custom Color,Sky,Color+Sky,Canvas,Keep"), "set_background", "get_background"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "background_sky", PROPERTY_HINT_RESOURCE_TYPE, "Sky"), "set_sky", "get_sky"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "background_sky_scale", PROPERTY_HINT_RANGE, "0,32,0.01"), "set_sky_scale", "get_sky_scale"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "background_sky_custom_fov", PROPERTY_HINT_RANGE, "0,180,0.1"), "set_sky_custom_fov", "get_sky_custom_fov"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "background_color"), "set_bg_color", "get_bg_color"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "background_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_bg_energy", "get_bg_energy"); ADD_PROPERTY(PropertyInfo(Variant::INT, "background_canvas_max_layer", PROPERTY_HINT_RANGE, "-1000,1000,1"), "set_canvas_max_layer", "get_canvas_max_layer"); @@ -1142,7 +1141,7 @@ Environment::Environment() { environment = VS::get_singleton()->environment_create(); bg_mode = BG_CLEAR_COLOR; - bg_sky_scale = 1.0; + bg_sky_custom_fov = 0; bg_energy = 1.0; bg_canvas_max_layer = 0; ambient_energy = 1.0; diff --git a/scene/resources/environment.h b/scene/resources/environment.h index 9046ec1e49..5909846074 100644 --- a/scene/resources/environment.h +++ b/scene/resources/environment.h @@ -76,7 +76,7 @@ private: BGMode bg_mode; Ref<Sky> bg_sky; - float bg_sky_scale; + float bg_sky_custom_fov; Color bg_color; float bg_energy; int bg_canvas_max_layer; @@ -162,7 +162,7 @@ protected: public: void set_background(BGMode p_bg); void set_sky(const Ref<Sky> &p_sky); - void set_sky_scale(float p_scale); + void set_sky_custom_fov(float p_scale); void set_bg_color(const Color &p_color); void set_bg_energy(float p_energy); void set_canvas_max_layer(int p_max_layer); @@ -172,7 +172,7 @@ public: BGMode get_background() const; Ref<Sky> get_sky() const; - float get_sky_scale() const; + float get_sky_custom_fov() const; Color get_bg_color() const; float get_bg_energy() const; int get_canvas_max_layer() const; diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index da0f522ff3..2936df7a51 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -370,10 +370,10 @@ void SpatialMaterial::_update_shader() { case CULL_DISABLED: code += ",cull_disabled"; break; } switch (diffuse_mode) { + case DIFFUSE_BURLEY: code += ",diffuse_burley"; break; case DIFFUSE_LAMBERT: code += ",diffuse_lambert"; break; case DIFFUSE_LAMBERT_WRAP: code += ",diffuse_lambert_wrap"; break; case DIFFUSE_OREN_NAYAR: code += ",diffuse_oren_nayar"; break; - case DIFFUSE_BURLEY: code += ",diffuse_burley"; break; case DIFFUSE_TOON: code += ",diffuse_toon"; break; } switch (specular_mode) { @@ -1809,7 +1809,7 @@ void SpatialMaterial::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "vertex_color_is_srgb"), "set_flag", "get_flag", FLAG_SRGB_VERTEX_COLOR); ADD_GROUP("Parameters", "params_"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "params_diffuse_mode", PROPERTY_HINT_ENUM, "Lambert,Lambert Wrap,Oren Nayar,Burley,Toon"), "set_diffuse_mode", "get_diffuse_mode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "params_diffuse_mode", PROPERTY_HINT_ENUM, "Burley,Lambert,Lambert Wrap,Oren Nayar,Toon"), "set_diffuse_mode", "get_diffuse_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "params_specular_mode", PROPERTY_HINT_ENUM, "SchlickGGX,Blinn,Phong,Toon,Disabled"), "set_specular_mode", "get_specular_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "params_blend_mode", PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul"), "set_blend_mode", "get_blend_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "params_cull_mode", PROPERTY_HINT_ENUM, "Back,Front,Disabled"), "set_cull_mode", "get_cull_mode"); @@ -1991,10 +1991,10 @@ void SpatialMaterial::_bind_methods() { BIND_ENUM_CONSTANT(FLAG_TRIPLANAR_USE_WORLD); BIND_ENUM_CONSTANT(FLAG_MAX); + BIND_ENUM_CONSTANT(DIFFUSE_BURLEY); BIND_ENUM_CONSTANT(DIFFUSE_LAMBERT); BIND_ENUM_CONSTANT(DIFFUSE_LAMBERT_WRAP); BIND_ENUM_CONSTANT(DIFFUSE_OREN_NAYAR); - BIND_ENUM_CONSTANT(DIFFUSE_BURLEY); BIND_ENUM_CONSTANT(DIFFUSE_TOON); BIND_ENUM_CONSTANT(SPECULAR_SCHLICK_GGX); diff --git a/scene/resources/material.h b/scene/resources/material.h index cf190f0921..c0e007ac5f 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -185,10 +185,10 @@ public: }; enum DiffuseMode { + DIFFUSE_BURLEY, DIFFUSE_LAMBERT, DIFFUSE_LAMBERT_WRAP, DIFFUSE_OREN_NAYAR, - DIFFUSE_BURLEY, DIFFUSE_TOON, }; diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 344c10089a..b3f6b243de 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -53,7 +53,7 @@ public: virtual void environment_set_background(RID p_env, VS::EnvironmentBG p_bg) = 0; virtual void environment_set_sky(RID p_env, RID p_sky) = 0; - virtual void environment_set_sky_scale(RID p_env, float p_scale) = 0; + virtual void environment_set_sky_custom_fov(RID p_env, float p_scale) = 0; virtual void environment_set_bg_color(RID p_env, const Color &p_color) = 0; virtual void environment_set_bg_energy(RID p_env, float p_energy) = 0; virtual void environment_set_canvas_max_layer(RID p_env, int p_max_layer) = 0; diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp index 01e3d7592d..7489ca7e3e 100644 --- a/servers/visual/shader_types.cpp +++ b/servers/visual/shader_types.cpp @@ -50,12 +50,6 @@ ShaderTypes::ShaderTypes() { /*************** SPATIAL ***********************/ - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["SRC_VERTEX"] = ShaderLanguage::TYPE_VEC3; - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["SRC_NORMAL"] = ShaderLanguage::TYPE_VEC3; - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["SRC_BONES"] = ShaderLanguage::TYPE_IVEC4; - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["SRC_WEIGHTS"] = ShaderLanguage::TYPE_VEC4; - - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["POSITION"] = ShaderLanguage::TYPE_VEC4; shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["VERTEX"] = ShaderLanguage::TYPE_VEC3; shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["NORMAL"] = ShaderLanguage::TYPE_VEC3; shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["TANGENT"] = ShaderLanguage::TYPE_VEC3; @@ -90,7 +84,6 @@ ShaderTypes::ShaderTypes() { shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["UV"] = ShaderLanguage::TYPE_VEC2; shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["UV2"] = ShaderLanguage::TYPE_VEC2; shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["NORMAL"] = ShaderLanguage::TYPE_VEC3; shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["ALBEDO"] = ShaderLanguage::TYPE_VEC3; shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["ALPHA"] = ShaderLanguage::TYPE_FLOAT; shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["METALLIC"] = ShaderLanguage::TYPE_FLOAT; @@ -179,21 +172,19 @@ ShaderTypes::ShaderTypes() { /************ CANVAS ITEM **************************/ - shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["SRC_VERTEX"] = ShaderLanguage::TYPE_VEC2; shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["VERTEX"] = ShaderLanguage::TYPE_VEC2; shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["UV"] = ShaderLanguage::TYPE_VEC2; - shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["VERTEX_COLOR"] = ShaderLanguage::TYPE_VEC4; + shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4; shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["POINT_SIZE"] = ShaderLanguage::TYPE_FLOAT; shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["WORLD_MATRIX"] = ShaderLanguage::TYPE_MAT4; shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["PROJECTION_MATRIX"] = ShaderLanguage::TYPE_MAT4; shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["EXTRA_MATRIX"] = ShaderLanguage::TYPE_MAT4; shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["TIME"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["PARTICLE_CUSTOM"] = ShaderLanguage::TYPE_VEC4; + shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["INSTANCE_CUSTOM"] = ShaderLanguage::TYPE_VEC4; shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["AT_LIGHT_PASS"] = ShaderLanguage::TYPE_BOOL; shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].can_discard = false; - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SRC_COLOR"] = ShaderLanguage::TYPE_VEC4; shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["FRAGCOORD"] = ShaderLanguage::TYPE_VEC4; shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMAL"] = ShaderLanguage::TYPE_VEC3; shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMALMAP"] = ShaderLanguage::TYPE_VEC3; @@ -202,13 +193,13 @@ ShaderTypes::ShaderTypes() { shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4; shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D; shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["TEXTURE_PIXEL_SIZE"] = ShaderLanguage::TYPE_VEC2; + shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMAL_TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D; shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SCREEN_UV"] = ShaderLanguage::TYPE_VEC2; shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SCREEN_PIXEL_SIZE"] = ShaderLanguage::TYPE_VEC2; shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["POINT_COORD"] = ShaderLanguage::TYPE_VEC2; shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["TIME"] = ShaderLanguage::TYPE_FLOAT; shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["AT_LIGHT_PASS"] = ShaderLanguage::TYPE_BOOL; shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SCREEN_TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D; - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SCREEN_UV"] = ShaderLanguage::TYPE_VEC2; shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].can_discard = true; shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["POSITION"] = ShaderLanguage::TYPE_VEC2; diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index b5cae978f5..888fb29f93 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -968,7 +968,7 @@ public: BIND2(environment_set_background, RID, EnvironmentBG) BIND2(environment_set_sky, RID, RID) - BIND2(environment_set_sky_scale, RID, float) + BIND2(environment_set_sky_custom_fov, RID, float) BIND2(environment_set_bg_color, RID, const Color &) BIND2(environment_set_bg_energy, RID, float) BIND2(environment_set_canvas_max_layer, RID, int) diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 5cf941b93d..caec890217 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -381,7 +381,7 @@ public: FUNC2(environment_set_background, RID, EnvironmentBG) FUNC2(environment_set_sky, RID, RID) - FUNC2(environment_set_sky_scale, RID, float) + FUNC2(environment_set_sky_custom_fov, RID, float) FUNC2(environment_set_bg_color, RID, const Color &) FUNC2(environment_set_bg_energy, RID, float) FUNC2(environment_set_canvas_max_layer, RID, int) diff --git a/servers/visual_server.h b/servers/visual_server.h index 72f36f6b65..1cc097f50e 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -85,7 +85,7 @@ public: enum TextureFlags { TEXTURE_FLAG_MIPMAPS = 1, /// Enable automatic mipmap generation - when available TEXTURE_FLAG_REPEAT = 2, /// Repeat texture (Tiling), otherwise Clamping - TEXTURE_FLAG_FILTER = 4, /// Create texure with linear (or available) filter + TEXTURE_FLAG_FILTER = 4, /// Create texture with linear (or available) filter TEXTURE_FLAG_ANISOTROPIC_FILTER = 8, TEXTURE_FLAG_CONVERT_TO_LINEAR = 16, TEXTURE_FLAG_MIRRORED_REPEAT = 32, /// Repeat texture, with alternate sections mirrored @@ -637,7 +637,7 @@ public: virtual void environment_set_background(RID p_env, EnvironmentBG p_bg) = 0; virtual void environment_set_sky(RID p_env, RID p_sky) = 0; - virtual void environment_set_sky_scale(RID p_env, float p_scale) = 0; + virtual void environment_set_sky_custom_fov(RID p_env, float p_scale) = 0; virtual void environment_set_bg_color(RID p_env, const Color &p_color) = 0; virtual void environment_set_bg_energy(RID p_env, float p_energy) = 0; virtual void environment_set_canvas_max_layer(RID p_env, int p_max_layer) = 0; |