feat: modules moved and engine moved to submodule

This commit is contained in:
Jan van der Weide 2025-04-12 18:40:44 +02:00
parent dfb5e645cd
commit c33d2130cc
5136 changed files with 225275 additions and 64485 deletions

View file

@ -10,8 +10,6 @@ env.add_source_files(env.servers_sources, "camera_server.cpp")
env.add_source_files(env.servers_sources, "display_server.cpp")
env.add_source_files(env.servers_sources, "navigation_server_2d.cpp")
env.add_source_files(env.servers_sources, "navigation_server_3d.cpp")
env.add_source_files(env.servers_sources, "physics_server_2d.cpp")
env.add_source_files(env.servers_sources, "physics_server_2d_wrap_mt.cpp")
env.add_source_files(env.servers_sources, "register_server_types.cpp")
env.add_source_files(env.servers_sources, "rendering_server.cpp")
env.add_source_files(env.servers_sources, "text_server.cpp")
@ -26,11 +24,17 @@ SConscript("navigation/SCsub")
SConscript("rendering/SCsub")
SConscript("text/SCsub")
if not env["disable_3d"]:
if not env["disable_physics_2d"]:
env.add_source_files(env.servers_sources, "physics_server_2d.cpp")
env.add_source_files(env.servers_sources, "physics_server_2d_wrap_mt.cpp")
if not env["disable_physics_3d"]:
env.add_source_files(env.servers_sources, "physics_server_3d.cpp")
env.add_source_files(env.servers_sources, "physics_server_3d_wrap_mt.cpp")
SConscript("xr/SCsub")
if not env["disable_xr"]:
env.add_source_files(env.servers_sources, "xr_server.cpp")
SConscript("xr/SCsub")
lib = env.add_library("servers", env.servers_sources)

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_DRIVER_DUMMY_H
#define AUDIO_DRIVER_DUMMY_H
#pragma once
#include "servers/audio_server.h"
@ -85,5 +84,3 @@ public:
AudioDriverDummy();
~AudioDriverDummy() {}
};
#endif // AUDIO_DRIVER_DUMMY_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_EFFECT_H
#define AUDIO_EFFECT_H
#pragma once
#include "core/io/resource.h"
#include "core/math/audio_frame.h"
@ -60,5 +59,3 @@ public:
virtual Ref<AudioEffectInstance> instantiate();
AudioEffect();
};
#endif // AUDIO_EFFECT_H

View file

@ -60,7 +60,7 @@ void AudioFilterSW::prepare_coefficients(Coeffs *p_coeffs) {
final_cutoff = 1; //don't allow less than this
}
double omega = Math_TAU * final_cutoff / sampling_rate;
double omega = Math::TAU * final_cutoff / sampling_rate;
double sin_v = Math::sin(omega);
double cos_v = Math::cos(omega);
@ -134,7 +134,7 @@ void AudioFilterSW::prepare_coefficients(Coeffs *p_coeffs) {
double hicutoff = resonance;
double centercutoff = (cutoff + resonance) / 2.0;
double bandwidth = (Math::log(centercutoff) - Math::log(hicutoff)) / Math::log((double)2);
omega = Math_TAU * centercutoff / sampling_rate;
omega = Math::TAU * centercutoff / sampling_rate;
alpha = Math::sin(omega) * Math::sinh(Math::log((double)2) / 2 * bandwidth * omega / Math::sin(omega));
a0 = 1 + alpha;
@ -191,7 +191,7 @@ void AudioFilterSW::set_stages(int p_stages) {
/* Fourier transform kernel to obtain response */
float AudioFilterSW::get_response(float p_freq, Coeffs *p_coeffs) {
float freq = p_freq / sampling_rate * Math_TAU;
float freq = p_freq / sampling_rate * Math::TAU;
float cx = p_coeffs->b0, cy = 0.0;

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_FILTER_SW_H
#define AUDIO_FILTER_SW_H
#pragma once
#include "core/typedefs.h"
@ -122,5 +121,3 @@ void AudioFilterSW::Processor::process_one_interp(float &p_sample) {
coeffs.a1 += incr_coeffs.a1;
coeffs.a2 += incr_coeffs.a2;
}
#endif // AUDIO_FILTER_SW_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_RB_RESAMPLER_H
#define AUDIO_RB_RESAMPLER_H
#pragma once
#include "core/math/audio_frame.h"
#include "core/templates/safe_refcount.h"
@ -168,5 +167,3 @@ public:
AudioRBResampler();
~AudioRBResampler();
};
#endif // AUDIO_RB_RESAMPLER_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_STREAM_H
#define AUDIO_STREAM_H
#pragma once
#include "core/io/resource.h"
#include "scene/property_list_helper.h"
@ -373,5 +372,3 @@ public:
};
VARIANT_ENUM_CAST(AudioStreamRandomizer::PlaybackMode);
#endif // AUDIO_STREAM_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_EFFECT_AMPLIFY_H
#define AUDIO_EFFECT_AMPLIFY_H
#pragma once
#include "servers/audio/audio_effect.h"
@ -65,5 +64,3 @@ public:
AudioEffectAmplify();
};
#endif // AUDIO_EFFECT_AMPLIFY_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_EFFECT_CAPTURE_H
#define AUDIO_EFFECT_CAPTURE_H
#pragma once
#include "core/math/audio_frame.h"
#include "core/object/ref_counted.h"
@ -76,5 +75,3 @@ public:
int get_buffer_length_frames() const;
int64_t get_pushed_frames() const;
};
#endif // AUDIO_EFFECT_CAPTURE_H

View file

@ -84,7 +84,7 @@ void AudioEffectChorusInstance::_process_chunk(const AudioFrame *p_src_frames, A
if (v.cutoff == 0) {
continue;
}
float auxlp = expf(-Math_TAU * v.cutoff / mix_rate);
float auxlp = expf(-Math::TAU * v.cutoff / mix_rate);
float c1 = 1.0 - auxlp;
float c2 = auxlp;
AudioFrame h = filter_h[vc];
@ -104,7 +104,7 @@ void AudioEffectChorusInstance::_process_chunk(const AudioFrame *p_src_frames, A
float phase = (float)(local_cycles & AudioEffectChorus::CYCLES_MASK) / (float)(1 << AudioEffectChorus::CYCLES_FRAC);
float wave_delay = sinf(phase * Math_TAU) * max_depth_frames;
float wave_delay = sinf(phase * Math::TAU) * max_depth_frames;
int wave_delay_frames = lrint(floor(wave_delay));
float wave_delay_frac = wave_delay - (float)wave_delay_frames;
@ -274,7 +274,7 @@ float AudioEffectChorus::get_dry() const {
void AudioEffectChorus::_validate_property(PropertyInfo &p_property) const {
if (p_property.name.begins_with("voice/")) {
int voice_idx = p_property.name.get_slice("/", 1).to_int();
int voice_idx = p_property.name.get_slicec('/', 1).to_int();
if (voice_idx > voice_count) {
p_property.usage = PROPERTY_USAGE_NONE;
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_EFFECT_CHORUS_H
#define AUDIO_EFFECT_CHORUS_H
#pragma once
#include "servers/audio/audio_effect.h"
@ -132,5 +131,3 @@ public:
AudioEffectChorus();
};
#endif // AUDIO_EFFECT_CHORUS_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_EFFECT_COMPRESSOR_H
#define AUDIO_EFFECT_COMPRESSOR_H
#pragma once
#include "servers/audio/audio_effect.h"
@ -90,5 +89,3 @@ public:
AudioEffectCompressor();
};
#endif // AUDIO_EFFECT_COMPRESSOR_H

View file

@ -73,7 +73,7 @@ void AudioEffectDelayInstance::_process_chunk(const AudioFrame *p_src_frames, Au
tap2_vol.right *= CLAMP(1.0 + base->tap_2_pan, 0, 1);
// feedback lowpass here
float lpf_c = expf(-Math_TAU * base->feedback_lowpass / mix_rate); // 0 .. 10khz
float lpf_c = expf(-Math::TAU * base->feedback_lowpass / mix_rate); // 0 .. 10khz
float lpf_ic = 1.0 - lpf_c;
const AudioFrame *src = p_src_frames;

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_EFFECT_DELAY_H
#define AUDIO_EFFECT_DELAY_H
#pragma once
#include "servers/audio/audio_effect.h"
@ -131,5 +130,3 @@ public:
AudioEffectDelay() {}
};
#endif // AUDIO_EFFECT_DELAY_H

View file

@ -36,8 +36,8 @@ void AudioEffectDistortionInstance::process(const AudioFrame *p_src_frames, Audi
const float *src = (const float *)p_src_frames;
float *dst = (float *)p_dst_frames;
//float lpf_c=expf(-Math_TAU*keep_hf_hz.get()/(mix_rate*(float)OVERSAMPLE));
float lpf_c = expf(-Math_TAU * base->keep_hf_hz / (AudioServer::get_singleton()->get_mix_rate()));
//float lpf_c=expf(-Math::TAU*keep_hf_hz.get()/(mix_rate*(float)OVERSAMPLE));
float lpf_c = expf(-Math::TAU * base->keep_hf_hz / (AudioServer::get_singleton()->get_mix_rate()));
float lpf_ic = 1.0 - lpf_c;
float drive_f = base->drive;

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_EFFECT_DISTORTION_H
#define AUDIO_EFFECT_DISTORTION_H
#pragma once
#include "servers/audio/audio_effect.h"
@ -89,5 +88,3 @@ public:
};
VARIANT_ENUM_CAST(AudioEffectDistortion::Mode)
#endif // AUDIO_EFFECT_DISTORTION_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_EFFECT_EQ_H
#define AUDIO_EFFECT_EQ_H
#pragma once
#include "servers/audio/audio_effect.h"
#include "servers/audio/effects/eq_filter.h"
@ -97,5 +96,3 @@ public:
AudioEffectEQ21() :
AudioEffectEQ(EQ::PRESET_21_BANDS) {}
};
#endif // AUDIO_EFFECT_EQ_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_EFFECT_FILTER_H
#define AUDIO_EFFECT_FILTER_H
#pragma once
#include "servers/audio/audio_effect.h"
#include "servers/audio/audio_filter_sw.h"
@ -166,5 +165,3 @@ public:
AudioEffectHighShelfFilter() :
AudioEffectFilter(AudioFilterSW::HIGHSHELF) {}
};
#endif // AUDIO_EFFECT_FILTER_H

View file

@ -47,7 +47,7 @@ void AudioEffectHardLimiterInstance::process(const AudioFrame *p_src_frames, Aud
sample_left *= pre_gain;
sample_right *= pre_gain;
float largest_sample = MAX(ABS(sample_left), ABS(sample_right));
float largest_sample = MAX(Math::abs(sample_left), Math::abs(sample_right));
release_factor = MAX(0.0, release_factor - 1.0 / sample_rate);
release_factor = MIN(release_factor, release);

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_EFFECT_HARD_LIMITER_H
#define AUDIO_EFFECT_HARD_LIMITER_H
#pragma once
#include "servers/audio/audio_effect.h"
@ -85,5 +84,3 @@ public:
Ref<AudioEffectInstance> instantiate() override;
};
#endif // AUDIO_EFFECT_HARD_LIMITER_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_EFFECT_LIMITER_H
#define AUDIO_EFFECT_LIMITER_H
#pragma once
#include "servers/audio/audio_effect.h"
@ -75,5 +74,3 @@ public:
AudioEffectLimiter();
};
#endif // AUDIO_EFFECT_LIMITER_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_EFFECT_PANNER_H
#define AUDIO_EFFECT_PANNER_H
#pragma once
#include "servers/audio/audio_effect.h"
@ -60,5 +59,3 @@ public:
AudioEffectPanner();
};
#endif // AUDIO_EFFECT_PANNER_H

View file

@ -37,13 +37,13 @@ void AudioEffectPhaserInstance::process(const AudioFrame *p_src_frames, AudioFra
float dmin = base->range_min / (sampling_rate / 2.0);
float dmax = base->range_max / (sampling_rate / 2.0);
float increment = Math_TAU * (base->rate / sampling_rate);
float increment = Math::TAU * (base->rate / sampling_rate);
for (int i = 0; i < p_frame_count; i++) {
phase += increment;
while (phase >= Math_TAU) {
phase -= Math_TAU;
while (phase >= Math::TAU) {
phase -= Math::TAU;
}
float d = dmin + (dmax - dmin) * ((sin(phase) + 1.f) / 2.f);

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_EFFECT_PHASER_H
#define AUDIO_EFFECT_PHASER_H
#pragma once
#include "servers/audio/audio_effect.h"
@ -102,5 +101,3 @@ public:
AudioEffectPhaser();
};
#endif // AUDIO_EFFECT_PHASER_H

View file

@ -92,7 +92,7 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff
fftFrameSize2 = fftFrameSize/2;
stepSize = fftFrameSize/osamp;
freqPerBin = sampleRate/(double)fftFrameSize;
expct = 2.*Math_PI*(double)stepSize/(double)fftFrameSize;
expct = 2.*Math::PI*(double)stepSize/(double)fftFrameSize;
inFifoLatency = fftFrameSize-stepSize;
if (gRover == 0) { gRover = inFifoLatency;
}
@ -112,7 +112,7 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff
/* do windowing and re,im interleave */
for (k = 0; k < fftFrameSize;k++) {
window = -.5*cos(2.*Math_PI*(double)k/(double)fftFrameSize)+.5;
window = -.5*cos(2.*Math::PI*(double)k/(double)fftFrameSize)+.5;
gFFTworksp[2*k] = gInFIFO[k] * window;
gFFTworksp[2*k+1] = 0.;
}
@ -140,14 +140,14 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff
tmp -= (double)k*expct;
/* map delta phase into +/- Pi interval */
qpd = tmp/Math_PI;
qpd = tmp/Math::PI;
if (qpd >= 0) { qpd += qpd&1;
} else { qpd -= qpd&1;
}
tmp -= Math_PI*(double)qpd;
tmp -= Math::PI*(double)qpd;
/* get deviation from bin frequency from the +/- Pi interval */
tmp = osamp*tmp/(2.*Math_PI);
tmp = osamp*tmp/(2.*Math::PI);
/* compute the k-th partials' true frequency */
tmp = (double)k*freqPerBin + tmp*freqPerBin;
@ -184,7 +184,7 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff
tmp /= freqPerBin;
/* take osamp into account */
tmp = 2.*Math_PI*tmp/osamp;
tmp = 2.*Math::PI*tmp/osamp;
/* add the overlap phase advance back in */
tmp += (double)k*expct;
@ -207,7 +207,7 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff
/* do windowing and add to output accumulator */
for(k=0; k < fftFrameSize; k++) {
window = -.5*cos(2.*Math_PI*(double)k/(double)fftFrameSize)+.5;
window = -.5*cos(2.*Math::PI*(double)k/(double)fftFrameSize)+.5;
gOutputAccum[k] += 2.*window*gFFTworksp[2*k]/(fftFrameSize2*osamp);
}
for (k = 0; k < stepSize; k++) { gOutFIFO[k] = gOutputAccum[k];
@ -260,7 +260,7 @@ void SMBPitchShift::smbFft(float *fftBuffer, long fftFrameSize, long sign)
le2 = le>>1;
ur = 1.0;
ui = 0.0;
arg = Math_PI / (le2>>1);
arg = Math::PI / (le2>>1);
wr = cos(arg);
wi = sign*sin(arg);
for (j = 0; j < le2; j += 2) {
@ -288,6 +288,9 @@ void SMBPitchShift::smbFft(float *fftBuffer, long fftFrameSize, long sign)
void AudioEffectPitchShiftInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
// Avoid distortion by skipping processing if pitch_scale is 1.0.
if (Math::is_equal_approx(base->pitch_scale, 1.0f)) {
for (int i = 0; i < p_frame_count; i++) {
p_dst_frames[i] = p_src_frames[i];
}
return;
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_EFFECT_PITCH_SHIFT_H
#define AUDIO_EFFECT_PITCH_SHIFT_H
#pragma once
#include "servers/audio/audio_effect.h"
@ -110,5 +109,3 @@ public:
};
VARIANT_ENUM_CAST(AudioEffectPitchShift::FFTSize);
#endif // AUDIO_EFFECT_PITCH_SHIFT_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_EFFECT_RECORD_H
#define AUDIO_EFFECT_RECORD_H
#pragma once
#include "core/os/thread.h"
#include "scene/resources/audio_stream_wav.h"
@ -94,5 +93,3 @@ public:
AudioEffectRecord();
~AudioEffectRecord();
};
#endif // AUDIO_EFFECT_RECORD_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_EFFECT_REVERB_H
#define AUDIO_EFFECT_REVERB_H
#pragma once
#include "servers/audio/audio_effect.h"
#include "servers/audio/effects/reverb_filter.h"
@ -93,5 +92,3 @@ public:
AudioEffectReverb();
};
#endif // AUDIO_EFFECT_REVERB_H

View file

@ -71,7 +71,7 @@ static void smbFft(float *fftBuffer, long fftFrameSize, long sign)
le2 = le >> 1;
ur = 1.0;
ui = 0.0;
arg = Math_PI / (le2 >> 1);
arg = Math::PI / (le2 >> 1);
wr = cos(arg);
wi = sign * sin(arg);
for (j = 0; j < le2; j += 2) {
@ -110,7 +110,7 @@ void AudioEffectSpectrumAnalyzerInstance::process(const AudioFrame *p_src_frames
while (p_frame_count) {
int to_fill = fft_size * 2 - temporal_fft_pos;
to_fill = MIN(to_fill, p_frame_count);
const double to_fill_step = Math_TAU / (double)fft_size;
const double to_fill_step = Math::TAU / (double)fft_size;
float *fftw = temporal_fft.ptrw();
for (int i = 0; i < to_fill; i++) { //left and right buffers

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_EFFECT_SPECTRUM_ANALYZER_H
#define AUDIO_EFFECT_SPECTRUM_ANALYZER_H
#pragma once
#include "servers/audio/audio_effect.h"
@ -103,5 +102,3 @@ public:
};
VARIANT_ENUM_CAST(AudioEffectSpectrumAnalyzer::FFTSize);
#endif // AUDIO_EFFECT_SPECTRUM_ANALYZER_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_EFFECT_STEREO_ENHANCE_H
#define AUDIO_EFFECT_STEREO_ENHANCE_H
#pragma once
#include "servers/audio/audio_effect.h"
@ -81,5 +80,3 @@ public:
AudioEffectStereoEnhance();
};
#endif // AUDIO_EFFECT_STEREO_ENHANCE_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_STREAM_GENERATOR_H
#define AUDIO_STREAM_GENERATOR_H
#pragma once
#include "core/templates/ring_buffer.h"
#include "servers/audio/audio_stream.h"
@ -112,5 +111,3 @@ public:
};
VARIANT_ENUM_CAST(AudioStreamGenerator::AudioStreamGeneratorMixRate);
#endif // AUDIO_STREAM_GENERATOR_H

View file

@ -88,9 +88,9 @@ void EQ::recalculate_band_coefficients() {
double frq_l = round(frq / pow(2.0, octave_size / 2.0));
double side_gain2 = POW2(Math_SQRT12);
double th = Math_TAU * frq / mix_rate;
double th_l = Math_TAU * frq_l / mix_rate;
double side_gain2 = POW2(Math::SQRT12);
double th = Math::TAU * frq / mix_rate;
double th_l = Math::TAU * frq_l / mix_rate;
double c2a = side_gain2 * POW2(cos(th)) - 2.0 * side_gain2 * cos(th_l) * cos(th) + side_gain2 - POW2(sin(th_l));

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef EQ_FILTER_H
#define EQ_FILTER_H
#pragma once
#include "core/templates/vector.h"
@ -97,5 +96,3 @@ inline void EQ::BandProcess::process_one(float &p_data) {
history.b3 = history.b2;
history.b2 = history.b1;
}
#endif // EQ_FILTER_H

View file

@ -90,7 +90,7 @@ void Reverb::process(float *p_src, float *p_dst, int p_frames) {
}
if (params.hpf > 0) {
float hpaux = expf(-Math_TAU * params.hpf * 6000 / params.mix_rate);
float hpaux = expf(-Math::TAU * params.hpf * 6000 / params.mix_rate);
float hp_a1 = (1.0 + hpaux) / 2.0;
float hp_a2 = -(1.0 + hpaux) / 2.0;
float hp_b1 = hpaux;
@ -292,7 +292,7 @@ void Reverb::update_parameters() {
float auxdmp = params.damp / 2.0 + 0.5; //only half the range (0.5 .. 1.0 is enough)
auxdmp *= auxdmp;
c.damp = expf(-Math_TAU * auxdmp * 10000 / params.mix_rate); // 0 .. 10khz
c.damp = expf(-Math::TAU * auxdmp * 10000 / params.mix_rate); // 0 .. 10khz
}
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef REVERB_FILTER_H
#define REVERB_FILTER_H
#pragma once
class Reverb {
public:
@ -114,5 +113,3 @@ public:
~Reverb();
};
#endif // REVERB_FILTER_H

View file

@ -294,19 +294,23 @@ void AudioServer::_driver_process(int p_frames, int32_t *p_buffer) {
// The destination start for data will be the same in all cases.
int32_t *dest = &p_buffer[from_buf * (cs * 2) + (k * 2)];
#ifdef DEBUG_ENABLED
if (!debug_mute && master->channels[k].active) {
#else
if (master->channels[k].active) {
#endif // DEBUG_ENABLED
const AudioFrame *buf = master->channels[k].buffer.ptr();
for (int j = 0; j < to_copy; j++) {
float l = CLAMP(buf[from + j].left, -1.0, 1.0);
int32_t vl = l * ((1 << 20) - 1);
int32_t vl2 = (vl < 0 ? -1 : 1) * (ABS(vl) << 11);
int32_t vl2 = (vl < 0 ? -1 : 1) * (Math::abs(vl) << 11);
*dest = vl2;
dest++;
float r = CLAMP(buf[from + j].right, -1.0, 1.0);
int32_t vr = r * ((1 << 20) - 1);
int32_t vr2 = (vr < 0 ? -1 : 1) * (ABS(vr) << 11);
int32_t vr2 = (vr < 0 ? -1 : 1) * (Math::abs(vr) << 11);
*dest = vr2;
dest += stride_minus_one;
}
@ -621,11 +625,11 @@ void AudioServer::_mix_step() {
for (uint32_t j = 0; j < buffer_size; j++) {
buf[j] *= volume;
float l = ABS(buf[j].left);
float l = Math::abs(buf[j].left);
if (l > peak.left) {
peak.left = l;
}
float r = ABS(buf[j].right);
float r = Math::abs(buf[j].right);
if (r > peak.right) {
peak.right = r;
}
@ -765,6 +769,16 @@ int AudioServer::thread_find_bus_index(const StringName &p_name) {
}
}
#ifdef DEBUG_ENABLED
void AudioServer::set_debug_mute(bool p_mute) {
debug_mute = p_mute;
}
bool AudioServer::get_debug_mute() const {
return debug_mute;
}
#endif // DEBUG_ENABLED
void AudioServer::set_bus_count(int p_count) {
ERR_FAIL_COND(p_count < 1);
ERR_FAIL_INDEX(p_count, 256);
@ -1230,6 +1244,7 @@ void AudioServer::start_playback_stream(Ref<AudioStreamPlayback> p_playback, con
int idx = 0;
for (KeyValue<StringName, Vector<AudioFrame>> pair : p_bus_volumes) {
if (pair.value.size() < channel_count || pair.value.size() != MAX_CHANNELS_PER_BUS) {
delete playback_node;
delete new_bus_details;
ERR_FAIL();
}
@ -1322,8 +1337,10 @@ void AudioServer::set_playback_bus_volumes_linear(Ref<AudioStreamPlayback> p_pla
if (idx >= MAX_BUSES_PER_PLAYBACK) {
break;
}
ERR_FAIL_COND(pair.value.size() < channel_count);
ERR_FAIL_COND(pair.value.size() != MAX_CHANNELS_PER_BUS);
if (pair.value.size() < channel_count || pair.value.size() != MAX_CHANNELS_PER_BUS) {
delete new_bus_details;
ERR_FAIL();
}
new_bus_details->bus_active[idx] = true;
new_bus_details->bus[idx] = pair.key;
@ -2044,14 +2061,14 @@ AudioServer::~AudioServer() {
bool AudioBusLayout::_set(const StringName &p_name, const Variant &p_value) {
String s = p_name;
if (s.begins_with("bus/")) {
int index = s.get_slice("/", 1).to_int();
int index = s.get_slicec('/', 1).to_int();
if (buses.size() <= index) {
buses.resize(index + 1);
}
Bus &bus = buses.write[index];
String what = s.get_slice("/", 2);
String what = s.get_slicec('/', 2);
if (what == "name") {
bus.name = p_value;
@ -2066,14 +2083,14 @@ bool AudioBusLayout::_set(const StringName &p_name, const Variant &p_value) {
} else if (what == "send") {
bus.send = p_value;
} else if (what == "effect") {
int which = s.get_slice("/", 3).to_int();
int which = s.get_slicec('/', 3).to_int();
if (bus.effects.size() <= which) {
bus.effects.resize(which + 1);
}
Bus::Effect &fx = bus.effects.write[which];
String fxwhat = s.get_slice("/", 4);
String fxwhat = s.get_slicec('/', 4);
if (fxwhat == "effect") {
fx.effect = p_value;
} else if (fxwhat == "enabled") {
@ -2096,14 +2113,14 @@ bool AudioBusLayout::_set(const StringName &p_name, const Variant &p_value) {
bool AudioBusLayout::_get(const StringName &p_name, Variant &r_ret) const {
String s = p_name;
if (s.begins_with("bus/")) {
int index = s.get_slice("/", 1).to_int();
int index = s.get_slicec('/', 1).to_int();
if (index < 0 || index >= buses.size()) {
return false;
}
const Bus &bus = buses[index];
String what = s.get_slice("/", 2);
String what = s.get_slicec('/', 2);
if (what == "name") {
r_ret = bus.name;
@ -2118,14 +2135,14 @@ bool AudioBusLayout::_get(const StringName &p_name, Variant &r_ret) const {
} else if (what == "send") {
r_ret = bus.send;
} else if (what == "effect") {
int which = s.get_slice("/", 3).to_int();
int which = s.get_slicec('/', 3).to_int();
if (which < 0 || which >= bus.effects.size()) {
return false;
}
const Bus::Effect &fx = bus.effects[which];
String fxwhat = s.get_slice("/", 4);
String fxwhat = s.get_slicec('/', 4);
if (fxwhat == "effect") {
r_ret = fx.effect;
} else if (fxwhat == "enabled") {

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_SERVER_H
#define AUDIO_SERVER_H
#pragma once
#include "core/math/audio_frame.h"
#include "core/object/class_db.h"
@ -229,6 +228,10 @@ private:
bool tag_used_audio_streams = false;
#ifdef DEBUG_ENABLED
bool debug_mute = false;
#endif // DEBUG_ENABLED
struct Bus {
StringName name;
bool solo = false;
@ -367,6 +370,11 @@ public:
int thread_get_mix_buffer_size() const;
int thread_find_bus_index(const StringName &p_name);
#ifdef DEBUG_ENABLED
void set_debug_mute(bool p_mute);
bool get_debug_mute() const;
#endif // DEBUG_ENABLED
void set_bus_count(int p_count);
int get_bus_count() const;
@ -548,5 +556,3 @@ public:
};
typedef AudioServer AS;
#endif // AUDIO_SERVER_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef CAMERA_FEED_H
#define CAMERA_FEED_H
#pragma once
#include "core/io/image.h"
#include "core/math/transform_2d.h"
@ -129,5 +128,3 @@ public:
VARIANT_ENUM_CAST(CameraFeed::FeedDataType);
VARIANT_ENUM_CAST(CameraFeed::FeedPosition);
#endif // CAMERA_FEED_H

View file

@ -39,6 +39,10 @@
CameraServer::CreateFunc CameraServer::create_func = nullptr;
void CameraServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_monitoring_feeds", "is_monitoring_feeds"), &CameraServer::set_monitoring_feeds);
ClassDB::bind_method(D_METHOD("is_monitoring_feeds"), &CameraServer::is_monitoring_feeds);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "monitoring_feeds"), "set_monitoring_feeds", "is_monitoring_feeds");
ClassDB::bind_method(D_METHOD("get_feed", "index"), &CameraServer::get_feed);
ClassDB::bind_method(D_METHOD("get_feed_count"), &CameraServer::get_feed_count);
ClassDB::bind_method(D_METHOD("feeds"), &CameraServer::get_feeds);
@ -61,6 +65,10 @@ CameraServer *CameraServer::get_singleton() {
return singleton;
}
void CameraServer::set_monitoring_feeds(bool p_monitoring_feeds) {
monitoring_feeds = p_monitoring_feeds;
}
int CameraServer::get_free_id() {
bool id_exists = true;
int newid = 0;
@ -80,6 +88,8 @@ int CameraServer::get_free_id() {
}
int CameraServer::get_feed_index(int p_id) {
ERR_FAIL_COND_V_MSG(!monitoring_feeds, -1, "CameraServer is not actively monitoring feeds; call set_monitoring_feeds(true) first.");
for (int i = 0; i < feeds.size(); i++) {
if (feeds[i]->get_id() == p_id) {
return i;
@ -90,6 +100,8 @@ int CameraServer::get_feed_index(int p_id) {
}
Ref<CameraFeed> CameraServer::get_feed_by_id(int p_id) {
ERR_FAIL_COND_V_MSG(!monitoring_feeds, nullptr, "CameraServer is not actively monitoring feeds; call set_monitoring_feeds(true) first.");
int index = get_feed_index(p_id);
if (index == -1) {
@ -129,16 +141,19 @@ void CameraServer::remove_feed(const Ref<CameraFeed> &p_feed) {
}
Ref<CameraFeed> CameraServer::get_feed(int p_index) {
ERR_FAIL_COND_V_MSG(!monitoring_feeds, nullptr, "CameraServer is not actively monitoring feeds; call set_monitoring_feeds(true) first.");
ERR_FAIL_INDEX_V(p_index, feeds.size(), nullptr);
return feeds[p_index];
}
int CameraServer::get_feed_count() {
ERR_FAIL_COND_V_MSG(!monitoring_feeds, 0, "CameraServer is not actively monitoring feeds; call set_monitoring_feeds(true) first.");
return feeds.size();
}
TypedArray<CameraFeed> CameraServer::get_feeds() {
ERR_FAIL_COND_V_MSG(!monitoring_feeds, {}, "CameraServer is not actively monitoring feeds; call set_monitoring_feeds(true) first.");
TypedArray<CameraFeed> return_feeds;
int cc = get_feed_count();
return_feeds.resize(cc);
@ -151,6 +166,7 @@ TypedArray<CameraFeed> CameraServer::get_feeds() {
}
RID CameraServer::feed_texture(int p_id, CameraServer::FeedImage p_texture) {
ERR_FAIL_COND_V_MSG(!monitoring_feeds, RID(), "CameraServer is not actively monitoring feeds; call set_monitoring_feeds(true) first.");
int index = get_feed_index(p_id);
ERR_FAIL_COND_V(index == -1, RID());

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef CAMERA_SERVER_H
#define CAMERA_SERVER_H
#pragma once
#include "core/object/class_db.h"
#include "core/object/ref_counted.h"
@ -65,6 +64,7 @@ private:
protected:
static CreateFunc create_func;
bool monitoring_feeds = false;
Vector<Ref<CameraFeed>> feeds;
static CameraServer *singleton;
@ -89,6 +89,9 @@ public:
return server;
}
virtual void set_monitoring_feeds(bool p_monitoring_feeds);
_FORCE_INLINE_ bool is_monitoring_feeds() const { return monitoring_feeds; }
// Right now we identify our feed by it's ID when it's used in the background.
// May see if we can change this to purely relying on CameraFeed objects or by name.
int get_free_id();
@ -112,5 +115,3 @@ public:
};
VARIANT_ENUM_CAST(CameraServer::FeedImage);
#endif // CAMERA_SERVER_H

View file

@ -42,8 +42,7 @@
Array ServersDebugger::ResourceUsage::serialize() {
infos.sort();
Array arr;
arr.push_back(infos.size() * 4);
Array arr = { infos.size() * 4 };
for (const ResourceInfo &E : infos) {
arr.push_back(E.path);
arr.push_back(E.format);
@ -73,9 +72,7 @@ bool ServersDebugger::ResourceUsage::deserialize(const Array &p_arr) {
}
Array ServersDebugger::ScriptFunctionSignature::serialize() {
Array arr;
arr.push_back(name);
arr.push_back(id);
Array arr = { name, id };
return arr;
}
@ -88,13 +85,7 @@ bool ServersDebugger::ScriptFunctionSignature::deserialize(const Array &p_arr) {
}
Array ServersDebugger::ServersProfilerFrame::serialize() {
Array arr;
arr.push_back(frame_number);
arr.push_back(frame_time);
arr.push_back(process_time);
arr.push_back(physics_time);
arr.push_back(physics_frame_time);
arr.push_back(script_time);
Array arr = { frame_number, frame_time, process_time, physics_time, physics_frame_time, script_time };
arr.push_back(servers.size());
for (const ServerInfo &s : servers) {
@ -163,9 +154,7 @@ bool ServersDebugger::ServersProfilerFrame::deserialize(const Array &p_arr) {
}
Array ServersDebugger::VisualProfilerFrame::serialize() {
Array arr;
arr.push_back(frame_number);
arr.push_back(areas.size() * 3);
Array arr = { frame_number, areas.size() * 3 };
for (int i = 0; i < areas.size(); i++) {
arr.push_back(areas[i].name);
arr.push_back(areas[i].cpu_msec);
@ -372,9 +361,10 @@ public:
RS::get_singleton()->set_frame_profiling_enabled(p_enable);
// Send hardware information from the remote device so that it's accurate for remote debugging.
Array hardware_info;
hardware_info.push_back(OS::get_singleton()->get_processor_name());
hardware_info.push_back(RenderingServer::get_singleton()->get_video_adapter_name());
Array hardware_info = {
OS::get_singleton()->get_processor_name(),
RenderingServer::get_singleton()->get_video_adapter_name()
};
EngineDebugger::get_singleton()->send_message("visual:hardware_info", hardware_info);
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SERVERS_DEBUGGER_H
#define SERVERS_DEBUGGER_H
#pragma once
#include "servers/rendering_server.h"
@ -127,5 +126,3 @@ public:
~ServersDebugger();
};
#endif // SERVERS_DEBUGGER_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef NATIVE_MENU_H
#define NATIVE_MENU_H
#pragma once
#include "core/input/input.h"
#include "core/variant/callable.h"
@ -156,5 +155,3 @@ public:
VARIANT_ENUM_CAST(NativeMenu::Feature);
VARIANT_ENUM_CAST(NativeMenu::SystemMenus);
#endif // NATIVE_MENU_H

View file

@ -0,0 +1,46 @@
/**************************************************************************/
/* display_server.compat.inc */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* 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. */
/**************************************************************************/
#ifndef DISABLE_DEPRECATED
Error DisplayServer::_file_dialog_show_bind_compat_98194(const String &p_title, const String &p_current_directory, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const Callable &p_callback) {
return file_dialog_show(p_title, p_current_directory, p_filename, p_show_hidden, p_mode, p_filters, p_callback, MAIN_WINDOW_ID);
}
Error DisplayServer::_file_dialog_with_options_show_bind_compat_98194(const String &p_title, const String &p_current_directory, const String &p_root, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const TypedArray<Dictionary> &p_options, const Callable &p_callback) {
return file_dialog_with_options_show(p_title, p_current_directory, p_root, p_filename, p_show_hidden, p_mode, p_filters, p_options, p_callback, MAIN_WINDOW_ID);
}
void DisplayServer::_bind_compatibility_methods() {
ClassDB::bind_compatibility_method(D_METHOD("file_dialog_show", "title", "current_directory", "filename", "show_hidden", "mode", "filters", "callback"), &DisplayServer::_file_dialog_show_bind_compat_98194);
ClassDB::bind_compatibility_method(D_METHOD("file_dialog_with_options_show", "title", "current_directory", "root", "filename", "show_hidden", "mode", "filters", "options", "callback"), &DisplayServer::_file_dialog_with_options_show_bind_compat_98194);
}
#endif

View file

@ -29,6 +29,7 @@
/**************************************************************************/
#include "display_server.h"
#include "display_server.compat.inc"
#include "core/input/input.h"
#include "scene/resources/texture.h"
@ -47,6 +48,8 @@
DisplayServer *DisplayServer::singleton = nullptr;
DisplayServer::AccessibilityMode DisplayServer::accessibility_mode = DisplayServer::AccessibilityMode::ACCESSIBILITY_AUTO;
bool DisplayServer::hidpi_allowed = false;
bool DisplayServer::window_early_clear_override_enabled = false;
@ -525,7 +528,7 @@ Point2i DisplayServer::mouse_get_position() const {
}
BitField<MouseButtonMask> DisplayServer::mouse_get_button_state() const {
ERR_FAIL_V_MSG(0, "Mouse is not supported by this display server.");
ERR_FAIL_V_MSG(MouseButtonMask::NONE, "Mouse is not supported by this display server.");
}
void DisplayServer::clipboard_set(const String &p_text) {
@ -629,6 +632,456 @@ void DisplayServer::window_set_ime_position(const Point2i &p_pos, WindowID p_win
WARN_PRINT("IME not supported by this display server.");
}
RID DisplayServer::accessibility_create_element(WindowID p_window, DisplayServer::AccessibilityRole p_role) {
if (accessibility_driver) {
return accessibility_driver->accessibility_create_element(p_window, p_role);
} else {
return RID();
}
}
RID DisplayServer::accessibility_create_sub_element(const RID &p_parent_rid, DisplayServer::AccessibilityRole p_role, int p_insert_pos) {
if (accessibility_driver) {
return accessibility_driver->accessibility_create_sub_element(p_parent_rid, p_role, p_insert_pos);
} else {
return RID();
}
}
RID DisplayServer::accessibility_create_sub_text_edit_elements(const RID &p_parent_rid, const RID &p_shaped_text, float p_min_height, int p_insert_pos) {
if (accessibility_driver) {
return accessibility_driver->accessibility_create_sub_text_edit_elements(p_parent_rid, p_shaped_text, p_min_height, p_insert_pos);
} else {
return RID();
}
}
bool DisplayServer::accessibility_has_element(const RID &p_id) const {
if (accessibility_driver) {
return accessibility_driver->accessibility_has_element(p_id);
} else {
return false;
}
}
void DisplayServer::accessibility_free_element(const RID &p_id) {
if (accessibility_driver) {
accessibility_driver->accessibility_free_element(p_id);
}
}
void DisplayServer::accessibility_element_set_meta(const RID &p_id, const Variant &p_meta) {
if (accessibility_driver) {
accessibility_driver->accessibility_element_set_meta(p_id, p_meta);
}
}
Variant DisplayServer::accessibility_element_get_meta(const RID &p_id) const {
if (accessibility_driver) {
return accessibility_driver->accessibility_element_get_meta(p_id);
} else {
return Variant();
}
}
void DisplayServer::accessibility_update_if_active(const Callable &p_callable) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_if_active(p_callable);
}
}
void DisplayServer::accessibility_update_set_focus(const RID &p_id) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_focus(p_id);
}
}
RID DisplayServer::accessibility_get_window_root(DisplayServer::WindowID p_window_id) const {
if (accessibility_driver) {
return accessibility_driver->accessibility_get_window_root(p_window_id);
} else {
return RID();
}
}
void DisplayServer::accessibility_set_window_rect(DisplayServer::WindowID p_window_id, const Rect2 &p_rect_out, const Rect2 &p_rect_in) {
if (accessibility_driver) {
accessibility_driver->accessibility_set_window_rect(p_window_id, p_rect_out, p_rect_in);
}
}
void DisplayServer::accessibility_set_window_focused(DisplayServer::WindowID p_window_id, bool p_focused) {
if (accessibility_driver) {
accessibility_driver->accessibility_set_window_focused(p_window_id, p_focused);
}
}
void DisplayServer::accessibility_update_set_role(const RID &p_id, DisplayServer::AccessibilityRole p_role) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_role(p_id, p_role);
}
}
void DisplayServer::accessibility_update_set_name(const RID &p_id, const String &p_name) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_name(p_id, p_name);
}
}
void DisplayServer::accessibility_update_set_description(const RID &p_id, const String &p_description) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_description(p_id, p_description);
}
}
void DisplayServer::accessibility_update_set_extra_info(const RID &p_id, const String &p_name_extra_info) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_extra_info(p_id, p_name_extra_info);
}
}
void DisplayServer::accessibility_update_set_value(const RID &p_id, const String &p_value) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_value(p_id, p_value);
}
}
void DisplayServer::accessibility_update_set_tooltip(const RID &p_id, const String &p_tooltip) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_tooltip(p_id, p_tooltip);
}
}
void DisplayServer::accessibility_update_set_bounds(const RID &p_id, const Rect2 &p_rect) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_bounds(p_id, p_rect);
}
}
void DisplayServer::accessibility_update_set_transform(const RID &p_id, const Transform2D &p_transform) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_transform(p_id, p_transform);
}
}
void DisplayServer::accessibility_update_add_child(const RID &p_id, const RID &p_child_id) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_add_child(p_id, p_child_id);
}
}
void DisplayServer::accessibility_update_add_related_controls(const RID &p_id, const RID &p_related_id) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_add_related_controls(p_id, p_related_id);
}
}
void DisplayServer::accessibility_update_add_related_details(const RID &p_id, const RID &p_related_id) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_add_related_details(p_id, p_related_id);
}
}
void DisplayServer::accessibility_update_add_related_described_by(const RID &p_id, const RID &p_related_id) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_add_related_described_by(p_id, p_related_id);
}
}
void DisplayServer::accessibility_update_add_related_flow_to(const RID &p_id, const RID &p_related_id) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_add_related_flow_to(p_id, p_related_id);
}
}
void DisplayServer::accessibility_update_add_related_labeled_by(const RID &p_id, const RID &p_related_id) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_add_related_labeled_by(p_id, p_related_id);
}
}
void DisplayServer::accessibility_update_add_related_radio_group(const RID &p_id, const RID &p_related_id) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_add_related_radio_group(p_id, p_related_id);
}
}
void DisplayServer::accessibility_update_set_active_descendant(const RID &p_id, const RID &p_other_id) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_active_descendant(p_id, p_other_id);
}
}
void DisplayServer::accessibility_update_set_next_on_line(const RID &p_id, const RID &p_other_id) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_next_on_line(p_id, p_other_id);
}
}
void DisplayServer::accessibility_update_set_previous_on_line(const RID &p_id, const RID &p_other_id) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_previous_on_line(p_id, p_other_id);
}
}
void DisplayServer::accessibility_update_set_member_of(const RID &p_id, const RID &p_group_id) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_member_of(p_id, p_group_id);
}
}
void DisplayServer::accessibility_update_set_in_page_link_target(const RID &p_id, const RID &p_other_id) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_in_page_link_target(p_id, p_other_id);
}
}
void DisplayServer::accessibility_update_set_error_message(const RID &p_id, const RID &p_other_id) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_error_message(p_id, p_other_id);
}
}
void DisplayServer::accessibility_update_set_live(const RID &p_id, DisplayServer::AccessibilityLiveMode p_live) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_live(p_id, p_live);
}
}
void DisplayServer::accessibility_update_add_action(const RID &p_id, DisplayServer::AccessibilityAction p_action, const Callable &p_callable) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_add_action(p_id, p_action, p_callable);
}
}
void DisplayServer::accessibility_update_add_custom_action(const RID &p_id, int p_action_id, const String &p_action_description) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_add_custom_action(p_id, p_action_id, p_action_description);
}
}
void DisplayServer::accessibility_update_set_table_row_count(const RID &p_id, int p_count) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_table_row_count(p_id, p_count);
}
}
void DisplayServer::accessibility_update_set_table_column_count(const RID &p_id, int p_count) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_table_column_count(p_id, p_count);
}
}
void DisplayServer::accessibility_update_set_table_row_index(const RID &p_id, int p_index) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_table_row_index(p_id, p_index);
}
}
void DisplayServer::accessibility_update_set_table_column_index(const RID &p_id, int p_index) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_table_column_index(p_id, p_index);
}
}
void DisplayServer::accessibility_update_set_table_cell_position(const RID &p_id, int p_row_index, int p_column_index) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_table_cell_position(p_id, p_row_index, p_column_index);
}
}
void DisplayServer::accessibility_update_set_table_cell_span(const RID &p_id, int p_row_span, int p_column_span) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_table_cell_span(p_id, p_row_span, p_column_span);
}
}
void DisplayServer::accessibility_update_set_list_item_count(const RID &p_id, int p_size) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_list_item_count(p_id, p_size);
}
}
void DisplayServer::accessibility_update_set_list_item_index(const RID &p_id, int p_index) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_list_item_index(p_id, p_index);
}
}
void DisplayServer::accessibility_update_set_list_item_level(const RID &p_id, int p_level) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_list_item_level(p_id, p_level);
}
}
void DisplayServer::accessibility_update_set_list_item_selected(const RID &p_id, bool p_selected) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_list_item_selected(p_id, p_selected);
}
}
void DisplayServer::accessibility_update_set_list_item_expanded(const RID &p_id, bool p_expanded) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_list_item_expanded(p_id, p_expanded);
}
}
void DisplayServer::accessibility_update_set_popup_type(const RID &p_id, DisplayServer::AccessibilityPopupType p_popup) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_popup_type(p_id, p_popup);
}
}
void DisplayServer::accessibility_update_set_checked(const RID &p_id, bool p_checekd) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_checked(p_id, p_checekd);
}
}
void DisplayServer::accessibility_update_set_num_value(const RID &p_id, double p_position) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_num_value(p_id, p_position);
}
}
void DisplayServer::accessibility_update_set_num_range(const RID &p_id, double p_min, double p_max) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_num_range(p_id, p_min, p_max);
}
}
void DisplayServer::accessibility_update_set_num_step(const RID &p_id, double p_step) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_num_step(p_id, p_step);
}
}
void DisplayServer::accessibility_update_set_num_jump(const RID &p_id, double p_jump) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_num_jump(p_id, p_jump);
}
}
void DisplayServer::accessibility_update_set_scroll_x(const RID &p_id, double p_position) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_scroll_x(p_id, p_position);
}
}
void DisplayServer::accessibility_update_set_scroll_x_range(const RID &p_id, double p_min, double p_max) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_scroll_x_range(p_id, p_min, p_max);
}
}
void DisplayServer::accessibility_update_set_scroll_y(const RID &p_id, double p_position) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_scroll_y(p_id, p_position);
}
}
void DisplayServer::accessibility_update_set_scroll_y_range(const RID &p_id, double p_min, double p_max) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_scroll_y_range(p_id, p_min, p_max);
}
}
void DisplayServer::accessibility_update_set_text_decorations(const RID &p_id, bool p_underline, bool p_strikethrough, bool p_overline) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_text_decorations(p_id, p_underline, p_strikethrough, p_overline);
}
}
void DisplayServer::accessibility_update_set_text_align(const RID &p_id, HorizontalAlignment p_align) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_text_align(p_id, p_align);
}
}
void DisplayServer::accessibility_update_set_text_selection(const RID &p_id, const RID &p_text_start_id, int p_start_char, const RID &p_text_end_id, int p_end_char) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_text_selection(p_id, p_text_start_id, p_start_char, p_text_end_id, p_end_char);
}
}
void DisplayServer::accessibility_update_set_flag(const RID &p_id, DisplayServer::AccessibilityFlags p_flag, bool p_value) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_flag(p_id, p_flag, p_value);
}
}
void DisplayServer::accessibility_update_set_classname(const RID &p_id, const String &p_classname) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_classname(p_id, p_classname);
}
}
void DisplayServer::accessibility_update_set_placeholder(const RID &p_id, const String &p_placeholder) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_placeholder(p_id, p_placeholder);
}
}
void DisplayServer::accessibility_update_set_language(const RID &p_id, const String &p_language) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_language(p_id, p_language);
}
}
void DisplayServer::accessibility_update_set_text_orientation(const RID &p_id, bool p_vertical) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_text_orientation(p_id, p_vertical);
}
}
void DisplayServer::accessibility_update_set_list_orientation(const RID &p_id, bool p_vertical) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_list_orientation(p_id, p_vertical);
}
}
void DisplayServer::accessibility_update_set_shortcut(const RID &p_id, const String &p_shortcut) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_shortcut(p_id, p_shortcut);
}
}
void DisplayServer::accessibility_update_set_url(const RID &p_id, const String &p_url) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_url(p_id, p_url);
}
}
void DisplayServer::accessibility_update_set_role_description(const RID &p_id, const String &p_description) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_role_description(p_id, p_description);
}
}
void DisplayServer::accessibility_update_set_state_description(const RID &p_id, const String &p_description) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_state_description(p_id, p_description);
}
}
void DisplayServer::accessibility_update_set_color_value(const RID &p_id, const Color &p_color) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_color_value(p_id, p_color);
}
}
void DisplayServer::accessibility_update_set_background_color(const RID &p_id, const Color &p_color) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_background_color(p_id, p_color);
}
}
void DisplayServer::accessibility_update_set_foreground_color(const RID &p_id, const Color &p_color) {
if (accessibility_driver) {
accessibility_driver->accessibility_update_set_foreground_color(p_id, p_color);
}
}
Point2i DisplayServer::ime_get_selection() const {
ERR_FAIL_V_MSG(Point2i(), "IME or NOTIFICATION_WM_IME_UPDATE not supported by this display server.");
}
@ -704,12 +1157,12 @@ Error DisplayServer::dialog_input_text(String p_title, String p_description, Str
return ERR_UNAVAILABLE;
}
Error DisplayServer::file_dialog_show(const String &p_title, const String &p_current_directory, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const Callable &p_callback) {
Error DisplayServer::file_dialog_show(const String &p_title, const String &p_current_directory, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const Callable &p_callback, WindowID p_window_id) {
WARN_PRINT("Native dialogs not supported by this display server.");
return ERR_UNAVAILABLE;
}
Error DisplayServer::file_dialog_with_options_show(const String &p_title, const String &p_current_directory, const String &p_root, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const TypedArray<Dictionary> &p_options, const Callable &p_callback) {
Error DisplayServer::file_dialog_with_options_show(const String &p_title, const String &p_current_directory, const String &p_root, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const TypedArray<Dictionary> &p_options, const Callable &p_callback, WindowID p_window_id) {
WARN_PRINT("Native dialogs not supported by this display server.");
return ERR_UNAVAILABLE;
}
@ -747,6 +1200,10 @@ Key DisplayServer::keyboard_get_label_from_physical(Key p_keycode) const {
void DisplayServer::show_emoji_and_symbol_picker() const {
}
bool DisplayServer::color_picker(const Callable &p_callback) {
return false;
}
void DisplayServer::force_process_and_drop_events() {
}
@ -1019,6 +1476,88 @@ void DisplayServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("window_start_drag", "window_id"), &DisplayServer::window_start_drag, DEFVAL(MAIN_WINDOW_ID));
ClassDB::bind_method(D_METHOD("window_start_resize", "edge", "window_id"), &DisplayServer::window_start_resize, DEFVAL(MAIN_WINDOW_ID));
ClassDB::bind_method(D_METHOD("accessibility_should_increase_contrast"), &DisplayServer::accessibility_should_increase_contrast);
ClassDB::bind_method(D_METHOD("accessibility_should_reduce_animation"), &DisplayServer::accessibility_should_reduce_animation);
ClassDB::bind_method(D_METHOD("accessibility_should_reduce_transparency"), &DisplayServer::accessibility_should_reduce_transparency);
ClassDB::bind_method(D_METHOD("accessibility_screen_reader_active"), &DisplayServer::accessibility_screen_reader_active);
ClassDB::bind_method(D_METHOD("accessibility_create_element", "window_id", "role"), &DisplayServer::accessibility_create_element);
ClassDB::bind_method(D_METHOD("accessibility_create_sub_element", "parent_rid", "role", "insert_pos"), &DisplayServer::accessibility_create_sub_element, DEFVAL(-1));
ClassDB::bind_method(D_METHOD("accessibility_create_sub_text_edit_elements", "parent_rid", "shaped_text", "min_height", "insert_pos"), &DisplayServer::accessibility_create_sub_text_edit_elements, DEFVAL(-1));
ClassDB::bind_method(D_METHOD("accessibility_has_element", "id"), &DisplayServer::accessibility_has_element);
ClassDB::bind_method(D_METHOD("accessibility_free_element", "id"), &DisplayServer::accessibility_free_element);
ClassDB::bind_method(D_METHOD("accessibility_element_set_meta", "id", "meta"), &DisplayServer::accessibility_element_set_meta);
ClassDB::bind_method(D_METHOD("accessibility_element_get_meta", "id"), &DisplayServer::accessibility_element_get_meta);
ClassDB::bind_method(D_METHOD("_accessibility_update_if_active", "callback"), &DisplayServer::accessibility_update_if_active);
ClassDB::bind_method(D_METHOD("accessibility_set_window_rect", "window_id", "rect_out", "rect_in"), &DisplayServer::accessibility_set_window_rect);
ClassDB::bind_method(D_METHOD("accessibility_set_window_focused", "window_id", "focused"), &DisplayServer::accessibility_set_window_focused);
ClassDB::bind_method(D_METHOD("accessibility_update_set_focus", "id"), &DisplayServer::accessibility_update_set_focus);
ClassDB::bind_method(D_METHOD("accessibility_get_window_root", "window_id"), &DisplayServer::accessibility_get_window_root);
ClassDB::bind_method(D_METHOD("accessibility_update_set_role", "id", "role"), &DisplayServer::accessibility_update_set_role);
ClassDB::bind_method(D_METHOD("accessibility_update_set_name", "id", "name"), &DisplayServer::accessibility_update_set_name);
ClassDB::bind_method(D_METHOD("accessibility_update_set_extra_info", "id", "name"), &DisplayServer::accessibility_update_set_extra_info);
ClassDB::bind_method(D_METHOD("accessibility_update_set_description", "id", "description"), &DisplayServer::accessibility_update_set_description);
ClassDB::bind_method(D_METHOD("accessibility_update_set_value", "id", "value"), &DisplayServer::accessibility_update_set_value);
ClassDB::bind_method(D_METHOD("accessibility_update_set_tooltip", "id", "tooltip"), &DisplayServer::accessibility_update_set_tooltip);
ClassDB::bind_method(D_METHOD("accessibility_update_set_bounds", "id", "p_rect"), &DisplayServer::accessibility_update_set_bounds);
ClassDB::bind_method(D_METHOD("accessibility_update_set_transform", "id", "transform"), &DisplayServer::accessibility_update_set_transform);
ClassDB::bind_method(D_METHOD("accessibility_update_add_child", "id", "child_id"), &DisplayServer::accessibility_update_add_child);
ClassDB::bind_method(D_METHOD("accessibility_update_add_related_controls", "id", "related_id"), &DisplayServer::accessibility_update_add_related_controls);
ClassDB::bind_method(D_METHOD("accessibility_update_add_related_details", "id", "related_id"), &DisplayServer::accessibility_update_add_related_details);
ClassDB::bind_method(D_METHOD("accessibility_update_add_related_described_by", "id", "related_id"), &DisplayServer::accessibility_update_add_related_described_by);
ClassDB::bind_method(D_METHOD("accessibility_update_add_related_flow_to", "id", "related_id"), &DisplayServer::accessibility_update_add_related_flow_to);
ClassDB::bind_method(D_METHOD("accessibility_update_add_related_labeled_by", "id", "related_id"), &DisplayServer::accessibility_update_add_related_labeled_by);
ClassDB::bind_method(D_METHOD("accessibility_update_add_related_radio_group", "id", "related_id"), &DisplayServer::accessibility_update_add_related_radio_group);
ClassDB::bind_method(D_METHOD("accessibility_update_set_active_descendant", "id", "other_id"), &DisplayServer::accessibility_update_set_active_descendant);
ClassDB::bind_method(D_METHOD("accessibility_update_set_next_on_line", "id", "other_id"), &DisplayServer::accessibility_update_set_next_on_line);
ClassDB::bind_method(D_METHOD("accessibility_update_set_previous_on_line", "id", "other_id"), &DisplayServer::accessibility_update_set_previous_on_line);
ClassDB::bind_method(D_METHOD("accessibility_update_set_member_of", "id", "group_id"), &DisplayServer::accessibility_update_set_member_of);
ClassDB::bind_method(D_METHOD("accessibility_update_set_in_page_link_target", "id", "other_id"), &DisplayServer::accessibility_update_set_in_page_link_target);
ClassDB::bind_method(D_METHOD("accessibility_update_set_error_message", "id", "other_id"), &DisplayServer::accessibility_update_set_error_message);
ClassDB::bind_method(D_METHOD("accessibility_update_set_live", "id", "live"), &DisplayServer::accessibility_update_set_live);
ClassDB::bind_method(D_METHOD("accessibility_update_add_action", "id", "action", "callable"), &DisplayServer::accessibility_update_add_action);
ClassDB::bind_method(D_METHOD("accessibility_update_add_custom_action", "id", "action_id", "action_description"), &DisplayServer::accessibility_update_add_custom_action);
ClassDB::bind_method(D_METHOD("accessibility_update_set_table_row_count", "id", "count"), &DisplayServer::accessibility_update_set_table_row_count);
ClassDB::bind_method(D_METHOD("accessibility_update_set_table_column_count", "id", "count"), &DisplayServer::accessibility_update_set_table_column_count);
ClassDB::bind_method(D_METHOD("accessibility_update_set_table_row_index", "id", "index"), &DisplayServer::accessibility_update_set_table_row_index);
ClassDB::bind_method(D_METHOD("accessibility_update_set_table_column_index", "id", "index"), &DisplayServer::accessibility_update_set_table_column_index);
ClassDB::bind_method(D_METHOD("accessibility_update_set_table_cell_position", "id", "row_index", "column_index"), &DisplayServer::accessibility_update_set_table_cell_position);
ClassDB::bind_method(D_METHOD("accessibility_update_set_table_cell_span", "id", "row_span", "column_span"), &DisplayServer::accessibility_update_set_table_cell_span);
ClassDB::bind_method(D_METHOD("accessibility_update_set_list_item_count", "id", "size"), &DisplayServer::accessibility_update_set_list_item_count);
ClassDB::bind_method(D_METHOD("accessibility_update_set_list_item_index", "id", "index"), &DisplayServer::accessibility_update_set_list_item_index);
ClassDB::bind_method(D_METHOD("accessibility_update_set_list_item_level", "id", "level"), &DisplayServer::accessibility_update_set_list_item_level);
ClassDB::bind_method(D_METHOD("accessibility_update_set_list_item_selected", "id", "selected"), &DisplayServer::accessibility_update_set_list_item_selected);
ClassDB::bind_method(D_METHOD("accessibility_update_set_list_item_expanded", "id", "expanded"), &DisplayServer::accessibility_update_set_list_item_expanded);
ClassDB::bind_method(D_METHOD("accessibility_update_set_popup_type", "id", "popup"), &DisplayServer::accessibility_update_set_popup_type);
ClassDB::bind_method(D_METHOD("accessibility_update_set_checked", "id", "checekd"), &DisplayServer::accessibility_update_set_checked);
ClassDB::bind_method(D_METHOD("accessibility_update_set_num_value", "id", "position"), &DisplayServer::accessibility_update_set_num_value);
ClassDB::bind_method(D_METHOD("accessibility_update_set_num_range", "id", "min", "max"), &DisplayServer::accessibility_update_set_num_range);
ClassDB::bind_method(D_METHOD("accessibility_update_set_num_step", "id", "step"), &DisplayServer::accessibility_update_set_num_step);
ClassDB::bind_method(D_METHOD("accessibility_update_set_num_jump", "id", "jump"), &DisplayServer::accessibility_update_set_num_jump);
ClassDB::bind_method(D_METHOD("accessibility_update_set_scroll_x", "id", "position"), &DisplayServer::accessibility_update_set_scroll_x);
ClassDB::bind_method(D_METHOD("accessibility_update_set_scroll_x_range", "id", "min", "max"), &DisplayServer::accessibility_update_set_scroll_x_range);
ClassDB::bind_method(D_METHOD("accessibility_update_set_scroll_y", "id", "position"), &DisplayServer::accessibility_update_set_scroll_y);
ClassDB::bind_method(D_METHOD("accessibility_update_set_scroll_y_range", "id", "min", "max"), &DisplayServer::accessibility_update_set_scroll_y_range);
ClassDB::bind_method(D_METHOD("accessibility_update_set_text_decorations", "id", "underline", "strikethrough", "overline"), &DisplayServer::accessibility_update_set_text_decorations);
ClassDB::bind_method(D_METHOD("accessibility_update_set_text_align", "id", "align"), &DisplayServer::accessibility_update_set_text_align);
ClassDB::bind_method(D_METHOD("accessibility_update_set_text_selection", "id", "text_start_id", "start_char", "text_end_id", "end_char"), &DisplayServer::accessibility_update_set_text_selection);
ClassDB::bind_method(D_METHOD("accessibility_update_set_flag", "id", "flag", "value"), &DisplayServer::accessibility_update_set_flag);
ClassDB::bind_method(D_METHOD("accessibility_update_set_classname", "id", "classname"), &DisplayServer::accessibility_update_set_classname);
ClassDB::bind_method(D_METHOD("accessibility_update_set_placeholder", "id", "placeholder"), &DisplayServer::accessibility_update_set_placeholder);
ClassDB::bind_method(D_METHOD("accessibility_update_set_language", "id", "language"), &DisplayServer::accessibility_update_set_language);
ClassDB::bind_method(D_METHOD("accessibility_update_set_text_orientation", "id", "vertical"), &DisplayServer::accessibility_update_set_text_orientation);
ClassDB::bind_method(D_METHOD("accessibility_update_set_list_orientation", "id", "vertical"), &DisplayServer::accessibility_update_set_list_orientation);
ClassDB::bind_method(D_METHOD("accessibility_update_set_shortcut", "id", "shortcut"), &DisplayServer::accessibility_update_set_shortcut);
ClassDB::bind_method(D_METHOD("accessibility_update_set_url", "id", "url"), &DisplayServer::accessibility_update_set_url);
ClassDB::bind_method(D_METHOD("accessibility_update_set_role_description", "id", "description"), &DisplayServer::accessibility_update_set_role_description);
ClassDB::bind_method(D_METHOD("accessibility_update_set_state_description", "id", "description"), &DisplayServer::accessibility_update_set_state_description);
ClassDB::bind_method(D_METHOD("accessibility_update_set_color_value", "id", "color"), &DisplayServer::accessibility_update_set_color_value);
ClassDB::bind_method(D_METHOD("accessibility_update_set_background_color", "id", "color"), &DisplayServer::accessibility_update_set_background_color);
ClassDB::bind_method(D_METHOD("accessibility_update_set_foreground_color", "id", "color"), &DisplayServer::accessibility_update_set_foreground_color);
ClassDB::bind_method(D_METHOD("ime_get_selection"), &DisplayServer::ime_get_selection);
ClassDB::bind_method(D_METHOD("ime_get_text"), &DisplayServer::ime_get_text);
@ -1028,6 +1567,7 @@ void DisplayServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("virtual_keyboard_get_height"), &DisplayServer::virtual_keyboard_get_height);
ClassDB::bind_method(D_METHOD("has_hardware_keyboard"), &DisplayServer::has_hardware_keyboard);
ClassDB::bind_method(D_METHOD("set_hardware_keyboard_connection_change_callback", "callable"), &DisplayServer::set_hardware_keyboard_connection_change_callback);
ClassDB::bind_method(D_METHOD("cursor_set_shape", "shape"), &DisplayServer::cursor_set_shape);
ClassDB::bind_method(D_METHOD("cursor_get_shape"), &DisplayServer::cursor_get_shape);
@ -1040,8 +1580,8 @@ void DisplayServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("dialog_show", "title", "description", "buttons", "callback"), &DisplayServer::dialog_show);
ClassDB::bind_method(D_METHOD("dialog_input_text", "title", "description", "existing_text", "callback"), &DisplayServer::dialog_input_text);
ClassDB::bind_method(D_METHOD("file_dialog_show", "title", "current_directory", "filename", "show_hidden", "mode", "filters", "callback"), &DisplayServer::file_dialog_show);
ClassDB::bind_method(D_METHOD("file_dialog_with_options_show", "title", "current_directory", "root", "filename", "show_hidden", "mode", "filters", "options", "callback"), &DisplayServer::file_dialog_with_options_show);
ClassDB::bind_method(D_METHOD("file_dialog_show", "title", "current_directory", "filename", "show_hidden", "mode", "filters", "callback", "parent_window_id"), &DisplayServer::file_dialog_show, DEFVAL(MAIN_WINDOW_ID));
ClassDB::bind_method(D_METHOD("file_dialog_with_options_show", "title", "current_directory", "root", "filename", "show_hidden", "mode", "filters", "options", "callback", "parent_window_id"), &DisplayServer::file_dialog_with_options_show, DEFVAL(MAIN_WINDOW_ID));
ClassDB::bind_method(D_METHOD("beep"), &DisplayServer::beep);
@ -1054,6 +1594,7 @@ void DisplayServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("keyboard_get_label_from_physical", "keycode"), &DisplayServer::keyboard_get_label_from_physical);
ClassDB::bind_method(D_METHOD("show_emoji_and_symbol_picker"), &DisplayServer::show_emoji_and_symbol_picker);
ClassDB::bind_method(D_METHOD("color_picker", "callback"), &DisplayServer::color_picker);
ClassDB::bind_method(D_METHOD("process_events"), &DisplayServer::process_events);
ClassDB::bind_method(D_METHOD("force_process_and_drop_events"), &DisplayServer::force_process_and_drop_events);
@ -1113,6 +1654,102 @@ void DisplayServer::_bind_methods() {
BIND_ENUM_CONSTANT(FEATURE_WINDOW_EMBEDDING);
BIND_ENUM_CONSTANT(FEATURE_NATIVE_DIALOG_FILE_MIME);
BIND_ENUM_CONSTANT(FEATURE_EMOJI_AND_SYMBOL_PICKER);
BIND_ENUM_CONSTANT(FEATURE_NATIVE_COLOR_PICKER);
BIND_ENUM_CONSTANT(FEATURE_SELF_FITTING_WINDOWS);
BIND_ENUM_CONSTANT(FEATURE_ACCESSIBILITY_SCREEN_READER);
BIND_ENUM_CONSTANT(ROLE_UNKNOWN);
BIND_ENUM_CONSTANT(ROLE_DEFAULT_BUTTON);
BIND_ENUM_CONSTANT(ROLE_AUDIO);
BIND_ENUM_CONSTANT(ROLE_VIDEO);
BIND_ENUM_CONSTANT(ROLE_STATIC_TEXT);
BIND_ENUM_CONSTANT(ROLE_CONTAINER);
BIND_ENUM_CONSTANT(ROLE_PANEL);
BIND_ENUM_CONSTANT(ROLE_BUTTON);
BIND_ENUM_CONSTANT(ROLE_LINK);
BIND_ENUM_CONSTANT(ROLE_CHECK_BOX);
BIND_ENUM_CONSTANT(ROLE_RADIO_BUTTON);
BIND_ENUM_CONSTANT(ROLE_CHECK_BUTTON);
BIND_ENUM_CONSTANT(ROLE_SCROLL_BAR);
BIND_ENUM_CONSTANT(ROLE_SCROLL_VIEW);
BIND_ENUM_CONSTANT(ROLE_SPLITTER);
BIND_ENUM_CONSTANT(ROLE_SLIDER);
BIND_ENUM_CONSTANT(ROLE_SPIN_BUTTON);
BIND_ENUM_CONSTANT(ROLE_PROGRESS_INDICATOR);
BIND_ENUM_CONSTANT(ROLE_TEXT_FIELD);
BIND_ENUM_CONSTANT(ROLE_MULTILINE_TEXT_FIELD);
BIND_ENUM_CONSTANT(ROLE_COLOR_PICKER);
BIND_ENUM_CONSTANT(ROLE_TABLE);
BIND_ENUM_CONSTANT(ROLE_CELL);
BIND_ENUM_CONSTANT(ROLE_ROW);
BIND_ENUM_CONSTANT(ROLE_ROW_GROUP);
BIND_ENUM_CONSTANT(ROLE_ROW_HEADER);
BIND_ENUM_CONSTANT(ROLE_COLUMN_HEADER);
BIND_ENUM_CONSTANT(ROLE_TREE);
BIND_ENUM_CONSTANT(ROLE_TREE_ITEM);
BIND_ENUM_CONSTANT(ROLE_LIST);
BIND_ENUM_CONSTANT(ROLE_LIST_ITEM);
BIND_ENUM_CONSTANT(ROLE_LIST_BOX);
BIND_ENUM_CONSTANT(ROLE_LIST_BOX_OPTION);
BIND_ENUM_CONSTANT(ROLE_TAB_BAR);
BIND_ENUM_CONSTANT(ROLE_TAB);
BIND_ENUM_CONSTANT(ROLE_TAB_PANEL);
BIND_ENUM_CONSTANT(ROLE_MENU_BAR);
BIND_ENUM_CONSTANT(ROLE_MENU);
BIND_ENUM_CONSTANT(ROLE_MENU_ITEM);
BIND_ENUM_CONSTANT(ROLE_MENU_ITEM_CHECK_BOX);
BIND_ENUM_CONSTANT(ROLE_MENU_ITEM_RADIO);
BIND_ENUM_CONSTANT(ROLE_IMAGE);
BIND_ENUM_CONSTANT(ROLE_WINDOW);
BIND_ENUM_CONSTANT(ROLE_TITLE_BAR);
BIND_ENUM_CONSTANT(ROLE_DIALOG);
BIND_ENUM_CONSTANT(ROLE_TOOLTIP);
BIND_ENUM_CONSTANT(POPUP_UNKNOWN);
BIND_ENUM_CONSTANT(POPUP_MENU);
BIND_ENUM_CONSTANT(POPUP_LIST);
BIND_ENUM_CONSTANT(POPUP_TREE);
BIND_ENUM_CONSTANT(POPUP_DIALOG);
BIND_ENUM_CONSTANT(FLAG_HIDDEN);
BIND_ENUM_CONSTANT(FLAG_LINKED);
BIND_ENUM_CONSTANT(FLAG_MULTISELECTABLE);
BIND_ENUM_CONSTANT(FLAG_REQUIRED);
BIND_ENUM_CONSTANT(FLAG_VISITED);
BIND_ENUM_CONSTANT(FLAG_BUSY);
BIND_ENUM_CONSTANT(FLAG_MODAL);
BIND_ENUM_CONSTANT(FLAG_TOUCH_PASSTHROUGH);
BIND_ENUM_CONSTANT(FLAG_READONLY);
BIND_ENUM_CONSTANT(FLAG_DISABLED);
BIND_ENUM_CONSTANT(FLAG_CLIPS_CHILDREN);
BIND_ENUM_CONSTANT(ACTION_CLICK);
BIND_ENUM_CONSTANT(ACTION_FOCUS);
BIND_ENUM_CONSTANT(ACTION_BLUR);
BIND_ENUM_CONSTANT(ACTION_COLLAPSE);
BIND_ENUM_CONSTANT(ACTION_EXPAND);
BIND_ENUM_CONSTANT(ACTION_DECREMENT);
BIND_ENUM_CONSTANT(ACTION_INCREMENT);
BIND_ENUM_CONSTANT(ACTION_HIDE_TOOLTIP);
BIND_ENUM_CONSTANT(ACTION_SHOW_TOOLTIP);
BIND_ENUM_CONSTANT(ACTION_SET_TEXT_SELECTION);
BIND_ENUM_CONSTANT(ACTION_REPLACE_SELECTED_TEXT);
BIND_ENUM_CONSTANT(ACTION_SCROLL_BACKWARD);
BIND_ENUM_CONSTANT(ACTION_SCROLL_DOWN);
BIND_ENUM_CONSTANT(ACTION_SCROLL_FORWARD);
BIND_ENUM_CONSTANT(ACTION_SCROLL_LEFT);
BIND_ENUM_CONSTANT(ACTION_SCROLL_RIGHT);
BIND_ENUM_CONSTANT(ACTION_SCROLL_UP);
BIND_ENUM_CONSTANT(ACTION_SCROLL_INTO_VIEW);
BIND_ENUM_CONSTANT(ACTION_SCROLL_TO_POINT);
BIND_ENUM_CONSTANT(ACTION_SET_SCROLL_OFFSET);
BIND_ENUM_CONSTANT(ACTION_SET_VALUE);
BIND_ENUM_CONSTANT(ACTION_SHOW_CONTEXT_MENU);
BIND_ENUM_CONSTANT(ACTION_CUSTOM);
BIND_ENUM_CONSTANT(LIVE_OFF);
BIND_ENUM_CONSTANT(LIVE_POLITE);
BIND_ENUM_CONSTANT(LIVE_ASSERTIVE);
BIND_ENUM_CONSTANT(MOUSE_MODE_VISIBLE);
BIND_ENUM_CONSTANT(MOUSE_MODE_HIDDEN);
@ -1188,6 +1825,9 @@ void DisplayServer::_bind_methods() {
BIND_ENUM_CONSTANT(WINDOW_FLAG_MOUSE_PASSTHROUGH);
BIND_ENUM_CONSTANT(WINDOW_FLAG_SHARP_CORNERS);
BIND_ENUM_CONSTANT(WINDOW_FLAG_EXCLUDE_FROM_CAPTURE);
BIND_ENUM_CONSTANT(WINDOW_FLAG_POPUP_WM_HINT);
BIND_ENUM_CONSTANT(WINDOW_FLAG_MINIMIZE_DISABLED);
BIND_ENUM_CONSTANT(WINDOW_FLAG_MAXIMIZE_DISABLED);
BIND_ENUM_CONSTANT(WINDOW_FLAG_MAX);
BIND_ENUM_CONSTANT(WINDOW_EVENT_MOUSE_ENTER);
@ -1198,6 +1838,7 @@ void DisplayServer::_bind_methods() {
BIND_ENUM_CONSTANT(WINDOW_EVENT_GO_BACK_REQUEST);
BIND_ENUM_CONSTANT(WINDOW_EVENT_DPI_CHANGE);
BIND_ENUM_CONSTANT(WINDOW_EVENT_TITLEBAR_CHANGE);
BIND_ENUM_CONSTANT(WINDOW_EVENT_FORCE_CLOSE);
BIND_ENUM_CONSTANT(WINDOW_EDGE_TOP_LEFT);
BIND_ENUM_CONSTANT(WINDOW_EDGE_TOP);
@ -1331,10 +1972,14 @@ bool DisplayServer::is_rendering_device_supported() {
Error err;
#ifdef WINDOWS_ENABLED
// On some NVIDIA drivers combining OpenGL and RenderingDevice can result in crash, offload the check to the subprocess.
#if defined(WINDOWS_ENABLED) || defined(LINUXBSD_ENABLED)
// On some drivers combining OpenGL and RenderingDevice can result in crash, offload the check to the subprocess.
List<String> arguments;
arguments.push_back("--test-rd-support");
if (get_singleton()) {
arguments.push_back("--display-driver");
arguments.push_back(get_singleton()->get_name().to_lower());
}
String pipe;
int exitcode = 0;
@ -1359,11 +2004,10 @@ bool DisplayServer::is_rendering_device_supported() {
#endif
#ifdef METAL_ENABLED
if (rcd == nullptr) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability"
GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wunguarded-availability")
// Eliminate "RenderingContextDriverMetal is only available on iOS 14.0 or newer".
rcd = memnew(RenderingContextDriverMetal);
#pragma clang diagnostic pop
GODOT_CLANG_WARNING_POP
}
#endif
@ -1442,11 +2086,10 @@ bool DisplayServer::can_create_rendering_device() {
#endif
#ifdef METAL_ENABLED
if (rcd == nullptr) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability"
GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wunguarded-availability")
// Eliminate "RenderingContextDriverMetal is only available on iOS 14.0 or newer".
rcd = memnew(RenderingContextDriverMetal);
#pragma clang diagnostic pop
GODOT_CLANG_WARNING_POP
}
#endif

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef DISPLAY_SERVER_H
#define DISPLAY_SERVER_H
#pragma once
#include "core/input/input.h"
#include "core/io/image.h"
@ -40,6 +39,7 @@
#include "display/native_menu.h"
class Texture2D;
class AccessibilityDriver;
class DisplayServer : public Object {
GDCLASS(DisplayServer, Object)
@ -109,6 +109,10 @@ private:
protected:
static void _bind_methods();
#ifndef DISABLE_DEPRECATED
static void _bind_compatibility_methods();
#endif
static Ref<Image> _get_cursor_image_from_resource(const Ref<Resource> &p_cursor, const Vector2 &p_hotspot);
enum {
@ -162,6 +166,9 @@ public:
FEATURE_WINDOW_EMBEDDING,
FEATURE_NATIVE_DIALOG_FILE_MIME,
FEATURE_EMOJI_AND_SYMBOL_PICKER,
FEATURE_NATIVE_COLOR_PICKER,
FEATURE_SELF_FITTING_WINDOWS,
FEATURE_ACCESSIBILITY_SCREEN_READER,
};
virtual bool has_feature(Feature p_feature) const = 0;
@ -267,6 +274,7 @@ public:
virtual Color get_accent_color() const { return Color(0, 0, 0, 0); }
virtual Color get_base_color() const { return Color(0, 0, 0, 0); }
virtual void set_system_theme_change_callback(const Callable &p_callable) {}
virtual void set_hardware_keyboard_connection_change_callback(const Callable &p_callable) {}
private:
static bool window_early_clear_override_enabled;
@ -402,6 +410,9 @@ public:
WINDOW_FLAG_MOUSE_PASSTHROUGH,
WINDOW_FLAG_SHARP_CORNERS,
WINDOW_FLAG_EXCLUDE_FROM_CAPTURE,
WINDOW_FLAG_POPUP_WM_HINT,
WINDOW_FLAG_MINIMIZE_DISABLED,
WINDOW_FLAG_MAXIMIZE_DISABLED,
WINDOW_FLAG_MAX,
};
@ -417,6 +428,9 @@ public:
WINDOW_FLAG_MOUSE_PASSTHROUGH_BIT = (1 << WINDOW_FLAG_MOUSE_PASSTHROUGH),
WINDOW_FLAG_SHARP_CORNERS_BIT = (1 << WINDOW_FLAG_SHARP_CORNERS),
WINDOW_FLAG_EXCLUDE_FROM_CAPTURE_BIT = (1 << WINDOW_FLAG_EXCLUDE_FROM_CAPTURE),
WINDOW_FLAG_POPUP_WM_HINT_BIT = (1 << WINDOW_FLAG_POPUP_WM_HINT),
WINDOW_FLAG_MINIMIZE_DISABLED_BIT = (1 << WINDOW_FLAG_MINIMIZE_DISABLED),
WINDOW_FLAG_MAXIMIZE_DISABLED_BIT = (1 << WINDOW_FLAG_MAXIMIZE_DISABLED),
};
virtual WindowID create_sub_window(WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Rect2i &p_rect = Rect2i(), bool p_exclusive = false, WindowID p_transient_parent = INVALID_WINDOW_ID);
@ -445,6 +459,7 @@ public:
WINDOW_EVENT_GO_BACK_REQUEST,
WINDOW_EVENT_DPI_CHANGE,
WINDOW_EVENT_TITLEBAR_CHANGE,
WINDOW_EVENT_FORCE_CLOSE,
};
virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) = 0;
virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) = 0;
@ -523,6 +538,209 @@ public:
virtual void window_start_resize(WindowResizeEdge p_edge, WindowID p_window = MAIN_WINDOW_ID) {}
// Accessibility.
enum AccessibilityMode {
ACCESSIBILITY_AUTO,
ACCESSIBILITY_ALWAYS,
ACCESSIBILITY_DISABLED,
};
protected:
AccessibilityDriver *accessibility_driver = nullptr;
static AccessibilityMode accessibility_mode;
public:
enum AccessibilityRole {
ROLE_UNKNOWN,
ROLE_DEFAULT_BUTTON,
ROLE_AUDIO,
ROLE_VIDEO,
ROLE_STATIC_TEXT,
ROLE_CONTAINER,
ROLE_PANEL,
ROLE_BUTTON,
ROLE_LINK,
ROLE_CHECK_BOX,
ROLE_RADIO_BUTTON,
ROLE_CHECK_BUTTON,
ROLE_SCROLL_BAR,
ROLE_SCROLL_VIEW,
ROLE_SPLITTER,
ROLE_SLIDER,
ROLE_SPIN_BUTTON,
ROLE_PROGRESS_INDICATOR,
ROLE_TEXT_FIELD,
ROLE_MULTILINE_TEXT_FIELD,
ROLE_COLOR_PICKER,
ROLE_TABLE,
ROLE_CELL,
ROLE_ROW,
ROLE_ROW_GROUP,
ROLE_ROW_HEADER,
ROLE_COLUMN_HEADER,
ROLE_TREE,
ROLE_TREE_ITEM,
ROLE_LIST,
ROLE_LIST_ITEM,
ROLE_LIST_BOX,
ROLE_LIST_BOX_OPTION,
ROLE_TAB_BAR,
ROLE_TAB,
ROLE_TAB_PANEL,
ROLE_MENU_BAR,
ROLE_MENU,
ROLE_MENU_ITEM,
ROLE_MENU_ITEM_CHECK_BOX,
ROLE_MENU_ITEM_RADIO,
ROLE_IMAGE,
ROLE_WINDOW,
ROLE_TITLE_BAR,
ROLE_DIALOG,
ROLE_TOOLTIP,
};
enum AccessibilityPopupType {
POPUP_UNKNOWN,
POPUP_MENU,
POPUP_LIST,
POPUP_TREE,
POPUP_DIALOG,
};
enum AccessibilityFlags {
FLAG_HIDDEN,
FLAG_LINKED,
FLAG_MULTISELECTABLE,
FLAG_REQUIRED,
FLAG_VISITED,
FLAG_BUSY,
FLAG_MODAL,
FLAG_TOUCH_PASSTHROUGH,
FLAG_READONLY,
FLAG_DISABLED,
FLAG_CLIPS_CHILDREN,
};
enum AccessibilityAction {
ACTION_CLICK,
ACTION_FOCUS,
ACTION_BLUR,
ACTION_COLLAPSE,
ACTION_EXPAND,
ACTION_DECREMENT,
ACTION_INCREMENT,
ACTION_HIDE_TOOLTIP,
ACTION_SHOW_TOOLTIP,
ACTION_SET_TEXT_SELECTION,
ACTION_REPLACE_SELECTED_TEXT,
ACTION_SCROLL_BACKWARD,
ACTION_SCROLL_DOWN,
ACTION_SCROLL_FORWARD,
ACTION_SCROLL_LEFT,
ACTION_SCROLL_RIGHT,
ACTION_SCROLL_UP,
ACTION_SCROLL_INTO_VIEW,
ACTION_SCROLL_TO_POINT,
ACTION_SET_SCROLL_OFFSET,
ACTION_SET_VALUE,
ACTION_SHOW_CONTEXT_MENU,
ACTION_CUSTOM,
};
enum AccessibilityLiveMode {
LIVE_OFF,
LIVE_POLITE,
LIVE_ASSERTIVE,
};
static AccessibilityMode accessibility_get_mode() { return accessibility_mode; }
static void accessibility_set_mode(AccessibilityMode p_mode) { accessibility_mode = p_mode; }
virtual int accessibility_should_increase_contrast() const { return -1; }
virtual int accessibility_should_reduce_animation() const { return -1; }
virtual int accessibility_should_reduce_transparency() const { return -1; }
virtual int accessibility_screen_reader_active() const { return -1; }
virtual RID accessibility_create_element(WindowID p_window_id, DisplayServer::AccessibilityRole p_role);
virtual RID accessibility_create_sub_element(const RID &p_parent_rid, DisplayServer::AccessibilityRole p_role, int p_insert_pos = -1);
virtual RID accessibility_create_sub_text_edit_elements(const RID &p_parent_rid, const RID &p_shaped_text, float p_min_height, int p_insert_pos = -1);
virtual bool accessibility_has_element(const RID &p_id) const;
virtual void accessibility_free_element(const RID &p_id);
virtual void accessibility_element_set_meta(const RID &p_id, const Variant &p_meta);
virtual Variant accessibility_element_get_meta(const RID &p_id) const;
virtual void accessibility_update_if_active(const Callable &p_callable);
virtual void accessibility_update_set_focus(const RID &p_id);
virtual RID accessibility_get_window_root(DisplayServer::WindowID p_window_id) const;
virtual void accessibility_set_window_rect(DisplayServer::WindowID p_window_id, const Rect2 &p_rect_out, const Rect2 &p_rect_in);
virtual void accessibility_set_window_focused(DisplayServer::WindowID p_window_id, bool p_focused);
virtual void accessibility_update_set_role(const RID &p_id, DisplayServer::AccessibilityRole p_role);
virtual void accessibility_update_set_name(const RID &p_id, const String &p_name);
virtual void accessibility_update_set_extra_info(const RID &p_id, const String &p_name_extra_info);
virtual void accessibility_update_set_description(const RID &p_id, const String &p_description);
virtual void accessibility_update_set_value(const RID &p_id, const String &p_value);
virtual void accessibility_update_set_tooltip(const RID &p_id, const String &p_tooltip);
virtual void accessibility_update_set_bounds(const RID &p_id, const Rect2 &p_rect);
virtual void accessibility_update_set_transform(const RID &p_id, const Transform2D &p_transform);
virtual void accessibility_update_add_child(const RID &p_id, const RID &p_child_id);
virtual void accessibility_update_add_related_controls(const RID &p_id, const RID &p_related_id);
virtual void accessibility_update_add_related_details(const RID &p_id, const RID &p_related_id);
virtual void accessibility_update_add_related_described_by(const RID &p_id, const RID &p_related_id);
virtual void accessibility_update_add_related_flow_to(const RID &p_id, const RID &p_related_id);
virtual void accessibility_update_add_related_labeled_by(const RID &p_id, const RID &p_related_id);
virtual void accessibility_update_add_related_radio_group(const RID &p_id, const RID &p_related_id);
virtual void accessibility_update_set_active_descendant(const RID &p_id, const RID &p_other_id);
virtual void accessibility_update_set_next_on_line(const RID &p_id, const RID &p_other_id);
virtual void accessibility_update_set_previous_on_line(const RID &p_id, const RID &p_other_id);
virtual void accessibility_update_set_member_of(const RID &p_id, const RID &p_group_id);
virtual void accessibility_update_set_in_page_link_target(const RID &p_id, const RID &p_other_id);
virtual void accessibility_update_set_error_message(const RID &p_id, const RID &p_other_id);
virtual void accessibility_update_set_live(const RID &p_id, DisplayServer::AccessibilityLiveMode p_live);
virtual void accessibility_update_add_action(const RID &p_id, DisplayServer::AccessibilityAction p_action, const Callable &p_callable);
virtual void accessibility_update_add_custom_action(const RID &p_id, int p_action_id, const String &p_action_description);
virtual void accessibility_update_set_table_row_count(const RID &p_id, int p_count);
virtual void accessibility_update_set_table_column_count(const RID &p_id, int p_count);
virtual void accessibility_update_set_table_row_index(const RID &p_id, int p_index);
virtual void accessibility_update_set_table_column_index(const RID &p_id, int p_index);
virtual void accessibility_update_set_table_cell_position(const RID &p_id, int p_row_index, int p_column_index);
virtual void accessibility_update_set_table_cell_span(const RID &p_id, int p_row_span, int p_column_span);
virtual void accessibility_update_set_list_item_count(const RID &p_id, int p_size);
virtual void accessibility_update_set_list_item_index(const RID &p_id, int p_index);
virtual void accessibility_update_set_list_item_level(const RID &p_id, int p_level);
virtual void accessibility_update_set_list_item_selected(const RID &p_id, bool p_selected);
virtual void accessibility_update_set_list_item_expanded(const RID &p_id, bool p_expanded);
virtual void accessibility_update_set_popup_type(const RID &p_id, DisplayServer::AccessibilityPopupType p_popup);
virtual void accessibility_update_set_checked(const RID &p_id, bool p_checekd);
virtual void accessibility_update_set_num_value(const RID &p_id, double p_position);
virtual void accessibility_update_set_num_range(const RID &p_id, double p_min, double p_max);
virtual void accessibility_update_set_num_step(const RID &p_id, double p_step);
virtual void accessibility_update_set_num_jump(const RID &p_id, double p_jump);
virtual void accessibility_update_set_scroll_x(const RID &p_id, double p_position);
virtual void accessibility_update_set_scroll_x_range(const RID &p_id, double p_min, double p_max);
virtual void accessibility_update_set_scroll_y(const RID &p_id, double p_position);
virtual void accessibility_update_set_scroll_y_range(const RID &p_id, double p_min, double p_max);
virtual void accessibility_update_set_text_decorations(const RID &p_id, bool p_underline, bool p_strikethrough, bool p_overline);
virtual void accessibility_update_set_text_align(const RID &p_id, HorizontalAlignment p_align);
virtual void accessibility_update_set_text_selection(const RID &p_id, const RID &p_text_start_id, int p_start_char, const RID &p_text_end_id, int p_end_char);
virtual void accessibility_update_set_flag(const RID &p_id, DisplayServer::AccessibilityFlags p_flag, bool p_value);
virtual void accessibility_update_set_classname(const RID &p_id, const String &p_classname);
virtual void accessibility_update_set_placeholder(const RID &p_id, const String &p_placeholder);
virtual void accessibility_update_set_language(const RID &p_id, const String &p_language);
virtual void accessibility_update_set_text_orientation(const RID &p_id, bool p_vertical);
virtual void accessibility_update_set_list_orientation(const RID &p_id, bool p_vertical);
virtual void accessibility_update_set_shortcut(const RID &p_id, const String &p_shortcut);
virtual void accessibility_update_set_url(const RID &p_id, const String &p_url);
virtual void accessibility_update_set_role_description(const RID &p_id, const String &p_description);
virtual void accessibility_update_set_state_description(const RID &p_id, const String &p_description);
virtual void accessibility_update_set_color_value(const RID &p_id, const Color &p_color);
virtual void accessibility_update_set_background_color(const RID &p_id, const Color &p_color);
virtual void accessibility_update_set_foreground_color(const RID &p_id, const Color &p_color);
// necessary for GL focus, may be able to use one of the existing functions for this, not sure yet
virtual void gl_window_make_current(DisplayServer::WindowID p_window_id);
@ -592,8 +810,13 @@ public:
FILE_DIALOG_MODE_SAVE_FILE,
FILE_DIALOG_MODE_SAVE_MAX
};
virtual Error file_dialog_show(const String &p_title, const String &p_current_directory, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const Callable &p_callback);
virtual Error file_dialog_with_options_show(const String &p_title, const String &p_current_directory, const String &p_root, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const TypedArray<Dictionary> &p_options, const Callable &p_callback);
virtual Error file_dialog_show(const String &p_title, const String &p_current_directory, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const Callable &p_callback, WindowID p_window_id = MAIN_WINDOW_ID);
virtual Error file_dialog_with_options_show(const String &p_title, const String &p_current_directory, const String &p_root, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const TypedArray<Dictionary> &p_options, const Callable &p_callback, WindowID p_window_id = MAIN_WINDOW_ID);
#ifndef DISABLE_DEPRECATED
Error _file_dialog_show_bind_compat_98194(const String &p_title, const String &p_current_directory, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const Callable &p_callback);
Error _file_dialog_with_options_show_bind_compat_98194(const String &p_title, const String &p_current_directory, const String &p_root, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const TypedArray<Dictionary> &p_options, const Callable &p_callback);
#endif
virtual void beep() const;
@ -605,6 +828,7 @@ public:
virtual Key keyboard_get_keycode_from_physical(Key p_keycode) const;
virtual Key keyboard_get_label_from_physical(Key p_keycode) const;
virtual void show_emoji_and_symbol_picker() const;
virtual bool color_picker(const Callable &p_callback);
virtual int tablet_get_driver_count() const { return 1; }
virtual String tablet_get_driver_name(int p_driver) const { return "default"; }
@ -661,6 +885,104 @@ public:
~DisplayServer();
};
/**************************************************************************/
class AccessibilityDriver {
public:
virtual Error init() = 0;
virtual bool window_create(DisplayServer::WindowID p_window_id, void *p_handle) = 0;
virtual void window_destroy(DisplayServer::WindowID p_window_id) = 0;
virtual RID accessibility_create_element(DisplayServer::WindowID p_window_id, DisplayServer::AccessibilityRole p_role) = 0;
virtual RID accessibility_create_sub_element(const RID &p_parent_rid, DisplayServer::AccessibilityRole p_role, int p_insert_pos = -1) = 0;
virtual RID accessibility_create_sub_text_edit_elements(const RID &p_parent_rid, const RID &p_shaped_text, float p_min_height, int p_insert_pos = -1) = 0;
virtual bool accessibility_has_element(const RID &p_id) const = 0;
virtual void accessibility_free_element(const RID &p_id) = 0;
virtual void accessibility_element_set_meta(const RID &p_id, const Variant &p_meta) = 0;
virtual Variant accessibility_element_get_meta(const RID &p_id) const = 0;
virtual void accessibility_update_if_active(const Callable &p_callable) = 0;
virtual RID accessibility_get_window_root(DisplayServer::WindowID p_window_id) const = 0;
virtual void accessibility_update_set_focus(const RID &p_id) = 0;
virtual void accessibility_set_window_rect(DisplayServer::WindowID p_window_id, const Rect2 &p_rect_out, const Rect2 &p_rect_in) = 0;
virtual void accessibility_set_window_focused(DisplayServer::WindowID p_window_id, bool p_focused) = 0;
virtual void accessibility_update_set_role(const RID &p_id, DisplayServer::AccessibilityRole p_role) = 0;
virtual void accessibility_update_set_name(const RID &p_id, const String &p_name) = 0;
virtual void accessibility_update_set_extra_info(const RID &p_id, const String &p_name_extra_info) = 0;
virtual void accessibility_update_set_description(const RID &p_id, const String &p_description) = 0;
virtual void accessibility_update_set_value(const RID &p_id, const String &p_value) = 0;
virtual void accessibility_update_set_tooltip(const RID &p_id, const String &p_tooltip) = 0;
virtual void accessibility_update_set_bounds(const RID &p_id, const Rect2 &p_rect) = 0;
virtual void accessibility_update_set_transform(const RID &p_id, const Transform2D &p_transform) = 0;
virtual void accessibility_update_add_child(const RID &p_id, const RID &p_child_id) = 0;
virtual void accessibility_update_add_related_controls(const RID &p_id, const RID &p_related_id) = 0;
virtual void accessibility_update_add_related_details(const RID &p_id, const RID &p_related_id) = 0;
virtual void accessibility_update_add_related_described_by(const RID &p_id, const RID &p_related_id) = 0;
virtual void accessibility_update_add_related_flow_to(const RID &p_id, const RID &p_related_id) = 0;
virtual void accessibility_update_add_related_labeled_by(const RID &p_id, const RID &p_related_id) = 0;
virtual void accessibility_update_add_related_radio_group(const RID &p_id, const RID &p_related_id) = 0;
virtual void accessibility_update_set_active_descendant(const RID &p_id, const RID &p_other_id) = 0;
virtual void accessibility_update_set_next_on_line(const RID &p_id, const RID &p_other_id) = 0;
virtual void accessibility_update_set_previous_on_line(const RID &p_id, const RID &p_other_id) = 0;
virtual void accessibility_update_set_member_of(const RID &p_id, const RID &p_group_id) = 0;
virtual void accessibility_update_set_in_page_link_target(const RID &p_id, const RID &p_other_id) = 0;
virtual void accessibility_update_set_error_message(const RID &p_id, const RID &p_other_id) = 0;
virtual void accessibility_update_set_live(const RID &p_id, DisplayServer::AccessibilityLiveMode p_live) = 0;
virtual void accessibility_update_add_action(const RID &p_id, DisplayServer::AccessibilityAction p_action, const Callable &p_callable) = 0;
virtual void accessibility_update_add_custom_action(const RID &p_id, int p_action_id, const String &p_action_description) = 0;
virtual void accessibility_update_set_table_row_count(const RID &p_id, int p_count) = 0;
virtual void accessibility_update_set_table_column_count(const RID &p_id, int p_count) = 0;
virtual void accessibility_update_set_table_row_index(const RID &p_id, int p_index) = 0;
virtual void accessibility_update_set_table_column_index(const RID &p_id, int p_index) = 0;
virtual void accessibility_update_set_table_cell_position(const RID &p_id, int p_row_index, int p_column_index) = 0;
virtual void accessibility_update_set_table_cell_span(const RID &p_id, int p_row_span, int p_column_span) = 0;
virtual void accessibility_update_set_list_item_count(const RID &p_id, int p_size) = 0;
virtual void accessibility_update_set_list_item_index(const RID &p_id, int p_index) = 0;
virtual void accessibility_update_set_list_item_level(const RID &p_id, int p_level) = 0;
virtual void accessibility_update_set_list_item_selected(const RID &p_id, bool p_selected) = 0;
virtual void accessibility_update_set_list_item_expanded(const RID &p_id, bool p_expanded) = 0;
virtual void accessibility_update_set_popup_type(const RID &p_id, DisplayServer::AccessibilityPopupType p_popup) = 0;
virtual void accessibility_update_set_checked(const RID &p_id, bool p_checekd) = 0;
virtual void accessibility_update_set_num_value(const RID &p_id, double p_position) = 0;
virtual void accessibility_update_set_num_range(const RID &p_id, double p_min, double p_max) = 0;
virtual void accessibility_update_set_num_step(const RID &p_id, double p_step) = 0;
virtual void accessibility_update_set_num_jump(const RID &p_id, double p_jump) = 0;
virtual void accessibility_update_set_scroll_x(const RID &p_id, double p_position) = 0;
virtual void accessibility_update_set_scroll_x_range(const RID &p_id, double p_min, double p_max) = 0;
virtual void accessibility_update_set_scroll_y(const RID &p_id, double p_position) = 0;
virtual void accessibility_update_set_scroll_y_range(const RID &p_id, double p_min, double p_max) = 0;
virtual void accessibility_update_set_text_decorations(const RID &p_id, bool p_underline, bool p_strikethrough, bool p_overline) = 0;
virtual void accessibility_update_set_text_align(const RID &p_id, HorizontalAlignment p_align) = 0;
virtual void accessibility_update_set_text_selection(const RID &p_id, const RID &p_text_start_id, int p_start_char, const RID &p_text_end_id, int p_end_char) = 0;
virtual void accessibility_update_set_flag(const RID &p_id, DisplayServer::AccessibilityFlags p_flag, bool p_value) = 0;
virtual void accessibility_update_set_classname(const RID &p_id, const String &p_classname) = 0;
virtual void accessibility_update_set_placeholder(const RID &p_id, const String &p_placeholder) = 0;
virtual void accessibility_update_set_language(const RID &p_id, const String &p_language) = 0;
virtual void accessibility_update_set_text_orientation(const RID &p_id, bool p_vertical) = 0;
virtual void accessibility_update_set_list_orientation(const RID &p_id, bool p_vertical) = 0;
virtual void accessibility_update_set_shortcut(const RID &p_id, const String &p_shortcut) = 0;
virtual void accessibility_update_set_url(const RID &p_id, const String &p_url) = 0;
virtual void accessibility_update_set_role_description(const RID &p_id, const String &p_description) = 0;
virtual void accessibility_update_set_state_description(const RID &p_id, const String &p_description) = 0;
virtual void accessibility_update_set_color_value(const RID &p_id, const Color &p_color) = 0;
virtual void accessibility_update_set_background_color(const RID &p_id, const Color &p_color) = 0;
virtual void accessibility_update_set_foreground_color(const RID &p_id, const Color &p_color) = 0;
AccessibilityDriver() {}
virtual ~AccessibilityDriver() {}
};
VARIANT_ENUM_CAST(DisplayServer::AccessibilityAction)
VARIANT_ENUM_CAST(DisplayServer::AccessibilityFlags)
VARIANT_ENUM_CAST(DisplayServer::AccessibilityLiveMode)
VARIANT_ENUM_CAST(DisplayServer::AccessibilityPopupType)
VARIANT_ENUM_CAST(DisplayServer::AccessibilityRole)
VARIANT_ENUM_CAST(DisplayServer::WindowEvent)
VARIANT_ENUM_CAST(DisplayServer::Feature)
VARIANT_ENUM_CAST(DisplayServer::MouseMode)
@ -674,5 +996,3 @@ VARIANT_ENUM_CAST(DisplayServer::CursorShape)
VARIANT_ENUM_CAST(DisplayServer::VSyncMode)
VARIANT_ENUM_CAST(DisplayServer::TTSUtteranceEvent)
VARIANT_ENUM_CAST(DisplayServer::FileDialogMode)
#endif // DISPLAY_SERVER_H

View file

@ -28,14 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef DISPLAY_SERVER_HEADLESS_H
#define DISPLAY_SERVER_HEADLESS_H
#pragma once
#include "servers/display_server.h"
#include "servers/rendering/dummy/rasterizer_dummy.h"
class DisplayServerHeadless : public DisplayServer {
GDSOFTCLASS(DisplayServerHeadless, DisplayServer);
private:
friend class DisplayServer;
@ -184,8 +185,8 @@ public:
Error dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback) override { return ERR_UNAVAILABLE; }
Error dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback) override { return ERR_UNAVAILABLE; }
Error file_dialog_show(const String &p_title, const String &p_current_directory, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const Callable &p_callback) override { return ERR_UNAVAILABLE; }
Error file_dialog_with_options_show(const String &p_title, const String &p_current_directory, const String &p_root, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const TypedArray<Dictionary> &p_options, const Callable &p_callback) override { return ERR_UNAVAILABLE; }
Error file_dialog_show(const String &p_title, const String &p_current_directory, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const Callable &p_callback, WindowID p_window_id) override { return ERR_UNAVAILABLE; }
Error file_dialog_with_options_show(const String &p_title, const String &p_current_directory, const String &p_root, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const TypedArray<Dictionary> &p_options, const Callable &p_callback, WindowID p_window_id) override { return ERR_UNAVAILABLE; }
void release_rendering_thread() override {}
void swap_buffers() override {}
@ -208,5 +209,3 @@ public:
}
}
};
#endif // DISPLAY_SERVER_HEADLESS_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef PHYSICS_SERVER_2D_EXTENSION_H
#define PHYSICS_SERVER_2D_EXTENSION_H
#pragma once
#include "core/extension/ext_wrappers.gen.inc"
#include "core/object/gdvirtual.gen.inc"
@ -451,5 +450,3 @@ public:
PhysicsServer2DExtension();
~PhysicsServer2DExtension();
};
#endif // PHYSICS_SERVER_2D_EXTENSION_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef PHYSICS_SERVER_3D_EXTENSION_H
#define PHYSICS_SERVER_3D_EXTENSION_H
#pragma once
#include "core/extension/ext_wrappers.gen.inc"
#include "core/object/script_language.h"
@ -539,5 +538,3 @@ public:
PhysicsServer3DExtension();
~PhysicsServer3DExtension();
};
#endif // PHYSICS_SERVER_3D_EXTENSION_H

View file

@ -99,6 +99,18 @@ void MovieWriter::begin(const Size2i &p_movie_size, uint32_t p_fps, const String
print_line(vformat("Movie Maker mode enabled, recording movie at %d FPS...", p_fps));
// When using Display/Window/Stretch/Mode = Viewport, use the project's
// configured viewport size instead of the size of the window in the OS
Size2i actual_movie_size = p_movie_size;
String stretch_mode = GLOBAL_GET("display/window/stretch/mode");
if (stretch_mode == "viewport") {
actual_movie_size.width = GLOBAL_GET("display/window/size/viewport_width");
actual_movie_size.height = GLOBAL_GET("display/window/size/viewport_height");
print_line(vformat("Movie Maker mode using project viewport size: %dx%d",
actual_movie_size.width, actual_movie_size.height));
}
// Check for available disk space and warn the user if needed.
Ref<DirAccess> dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
String path = p_base_path.get_basename();
@ -125,7 +137,7 @@ void MovieWriter::begin(const Size2i &p_movie_size, uint32_t p_fps, const String
audio_channels = AudioDriverDummy::get_dummy_singleton()->get_channels();
audio_mix_buffer.resize(mix_rate * audio_channels / fps);
write_begin(p_movie_size, p_fps, p_base_path);
write_begin(actual_movie_size, p_fps, p_base_path);
}
void MovieWriter::_bind_methods() {
@ -172,10 +184,12 @@ void MovieWriter::set_extensions_hint() {
void MovieWriter::add_frame() {
const int movie_time_seconds = Engine::get_singleton()->get_frames_drawn() / fps;
const String movie_time = vformat("%s:%s:%s",
String::num(movie_time_seconds / 3600).pad_zeros(2),
String::num((movie_time_seconds % 3600) / 60).pad_zeros(2),
String::num(movie_time_seconds % 60).pad_zeros(2));
const int frame_remainder = Engine::get_singleton()->get_frames_drawn() % fps;
const String movie_time = vformat("%s:%s:%s:%s",
String::num(movie_time_seconds / 3600, 0).pad_zeros(2),
String::num((movie_time_seconds % 3600) / 60, 0).pad_zeros(2),
String::num(movie_time_seconds % 60, 0).pad_zeros(2),
String::num(frame_remainder, 0).pad_zeros(2));
#ifdef DEBUG_ENABLED
DisplayServer::get_singleton()->window_set_title(vformat("MovieWriter: Frame %d (time: %s) - %s (DEBUG)", Engine::get_singleton()->get_frames_drawn(), movie_time, project_name));
@ -204,7 +218,7 @@ void MovieWriter::end() {
write_end();
// Print a report with various statistics.
print_line("----------------");
print_line("--------------------------------------------------------------------------------");
String movie_path = Engine::get_singleton()->get_write_movie_path();
if (movie_path.is_relative_path()) {
// Print absolute path to make finding the file easier,
@ -214,19 +228,21 @@ void MovieWriter::end() {
print_line(vformat("Done recording movie at path: %s", movie_path));
const int movie_time_seconds = Engine::get_singleton()->get_frames_drawn() / fps;
const String movie_time = vformat("%s:%s:%s",
String::num(movie_time_seconds / 3600).pad_zeros(2),
String::num((movie_time_seconds % 3600) / 60).pad_zeros(2),
String::num(movie_time_seconds % 60).pad_zeros(2));
const int frame_remainder = Engine::get_singleton()->get_frames_drawn() % fps;
const String movie_time = vformat("%s:%s:%s:%s",
String::num(movie_time_seconds / 3600, 0).pad_zeros(2),
String::num((movie_time_seconds % 3600) / 60, 0).pad_zeros(2),
String::num(movie_time_seconds % 60, 0).pad_zeros(2),
String::num(frame_remainder, 0).pad_zeros(2));
const int real_time_seconds = Time::get_singleton()->get_ticks_msec() / 1000;
const String real_time = vformat("%s:%s:%s",
String::num(real_time_seconds / 3600).pad_zeros(2),
String::num((real_time_seconds % 3600) / 60).pad_zeros(2),
String::num(real_time_seconds % 60).pad_zeros(2));
String::num(real_time_seconds / 3600, 0).pad_zeros(2),
String::num((real_time_seconds % 3600) / 60, 0).pad_zeros(2),
String::num(real_time_seconds % 60, 0).pad_zeros(2));
print_line(vformat("%d frames at %d FPS (movie length: %s), recorded in %s (%d%% of real-time speed).", Engine::get_singleton()->get_frames_drawn(), fps, movie_time, real_time, (float(movie_time_seconds) / real_time_seconds) * 100));
print_line(vformat("%d frames at %d FPS (movie length: %s), recorded in %s (%d%% of real-time speed).", Engine::get_singleton()->get_frames_drawn(), fps, movie_time, real_time, (float(MAX(1, movie_time_seconds)) / MAX(1, real_time_seconds)) * 100));
print_line(vformat("CPU time: %.2f seconds (average: %.2f ms/frame)", cpu_time / 1000, cpu_time / Engine::get_singleton()->get_frames_drawn()));
print_line(vformat("GPU time: %.2f seconds (average: %.2f ms/frame)", gpu_time / 1000, gpu_time / Engine::get_singleton()->get_frames_drawn()));
print_line("----------------");
print_line("--------------------------------------------------------------------------------");
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef MOVIE_WRITER_H
#define MOVIE_WRITER_H
#pragma once
#include "core/io/image.h"
#include "core/templates/local_vector.h"
@ -89,5 +88,3 @@ public:
void end();
};
#endif // MOVIE_WRITER_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef MOVIE_WRITER_MJPEG_H
#define MOVIE_WRITER_MJPEG_H
#pragma once
#include "servers/movie_writer/movie_writer.h"
@ -69,5 +68,3 @@ protected:
public:
MovieWriterMJPEG();
};
#endif // MOVIE_WRITER_MJPEG_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef MOVIE_WRITER_PNGWAV_H
#define MOVIE_WRITER_PNGWAV_H
#pragma once
#include "servers/movie_writer/movie_writer.h"
@ -67,5 +66,3 @@ protected:
public:
MovieWriterPNGWAV();
};
#endif // MOVIE_WRITER_PNGWAV_H

View file

@ -3,4 +3,10 @@ from misc.utility.scons_hints import *
Import("env")
env.add_source_files(env.servers_sources, "*.cpp")
if not env["disable_navigation_2d"]:
env.add_source_files(env.servers_sources, "navigation_path_query_parameters_2d.cpp")
env.add_source_files(env.servers_sources, "navigation_path_query_result_2d.cpp")
if not env["disable_navigation_3d"]:
env.add_source_files(env.servers_sources, "navigation_path_query_parameters_3d.cpp")
env.add_source_files(env.servers_sources, "navigation_path_query_result_3d.cpp")

View file

@ -0,0 +1,158 @@
/**************************************************************************/
/* nav_heap.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* 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. */
/**************************************************************************/
#pragma once
#include "core/templates/local_vector.h"
template <typename T>
struct NoopIndexer {
void operator()(const T &p_value, uint32_t p_index) {}
};
/**
* A max-heap implementation that notifies of element index changes.
*/
template <typename T, typename LessThan = Comparator<T>, typename Indexer = NoopIndexer<T>>
class Heap {
LocalVector<T> _buffer;
LessThan _less_than;
Indexer _indexer;
public:
static constexpr uint32_t INVALID_INDEX = UINT32_MAX;
void reserve(uint32_t p_size) {
_buffer.reserve(p_size);
}
uint32_t size() const {
return _buffer.size();
}
bool is_empty() const {
return _buffer.is_empty();
}
void push(const T &p_element) {
_buffer.push_back(p_element);
_indexer(p_element, _buffer.size() - 1);
_shift_up(_buffer.size() - 1);
}
T pop() {
ERR_FAIL_COND_V_MSG(_buffer.is_empty(), T(), "Can't pop an empty heap.");
T value = _buffer[0];
_indexer(value, INVALID_INDEX);
if (_buffer.size() > 1) {
_buffer[0] = _buffer[_buffer.size() - 1];
_indexer(_buffer[0], 0);
_buffer.remove_at(_buffer.size() - 1);
_shift_down(0);
} else {
_buffer.remove_at(_buffer.size() - 1);
}
return value;
}
/**
* Update the position of the element in the heap if necessary.
*/
void shift(uint32_t p_index) {
ERR_FAIL_UNSIGNED_INDEX_MSG(p_index, _buffer.size(), "Heap element index is out of range.");
if (!_shift_up(p_index)) {
_shift_down(p_index);
}
}
void clear() {
for (const T &value : _buffer) {
_indexer(value, INVALID_INDEX);
}
_buffer.clear();
}
Heap() {}
Heap(const LessThan &p_less_than) :
_less_than(p_less_than) {}
Heap(const Indexer &p_indexer) :
_indexer(p_indexer) {}
Heap(const LessThan &p_less_than, const Indexer &p_indexer) :
_less_than(p_less_than), _indexer(p_indexer) {}
private:
bool _shift_up(uint32_t p_index) {
T value = _buffer[p_index];
uint32_t current_index = p_index;
uint32_t parent_index = (current_index - 1) / 2;
while (current_index > 0 && _less_than(_buffer[parent_index], value)) {
_buffer[current_index] = _buffer[parent_index];
_indexer(_buffer[current_index], current_index);
current_index = parent_index;
parent_index = (current_index - 1) / 2;
}
if (current_index != p_index) {
_buffer[current_index] = value;
_indexer(value, current_index);
return true;
} else {
return false;
}
}
bool _shift_down(uint32_t p_index) {
T value = _buffer[p_index];
uint32_t current_index = p_index;
uint32_t child_index = 2 * current_index + 1;
while (child_index < _buffer.size()) {
if (child_index + 1 < _buffer.size() &&
_less_than(_buffer[child_index], _buffer[child_index + 1])) {
child_index++;
}
if (_less_than(_buffer[child_index], value)) {
break;
}
_buffer[current_index] = _buffer[child_index];
_indexer(_buffer[current_index], current_index);
current_index = child_index;
child_index = 2 * current_index + 1;
}
if (current_index != p_index) {
_buffer[current_index] = value;
_indexer(value, current_index);
return true;
} else {
return false;
}
}
};

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef NAVIGATION_GLOBALS_H
#define NAVIGATION_GLOBALS_H
#pragma once
namespace NavigationDefaults3D {
@ -55,6 +54,7 @@ namespace NavigationDefaults2D {
// Same as in 3D but larger since 1px is treated as 1m.
constexpr float navmesh_cell_size{ 1.0f }; // Must match ProjectSettings default 2D cell_size.
constexpr float navmesh_cell_size_min{ 0.01f };
constexpr auto navmesh_cell_size_hint{ "0.001,100,0.001,or_greater" };
// Map.
@ -63,5 +63,3 @@ constexpr float edge_connection_margin{ 1.0f };
constexpr float link_connection_radius{ 4.0f };
} //namespace NavigationDefaults2D
#endif // NAVIGATION_GLOBALS_H

View file

@ -102,6 +102,38 @@ real_t NavigationPathQueryParameters2D::get_simplify_epsilon() const {
return simplify_epsilon;
}
void NavigationPathQueryParameters2D::set_included_regions(const TypedArray<RID> &p_regions) {
_included_regions.resize(p_regions.size());
for (uint32_t i = 0; i < _included_regions.size(); i++) {
_included_regions[i] = p_regions[i];
}
}
TypedArray<RID> NavigationPathQueryParameters2D::get_included_regions() const {
TypedArray<RID> r_regions;
r_regions.resize(_included_regions.size());
for (uint32_t i = 0; i < _included_regions.size(); i++) {
r_regions[i] = _included_regions[i];
}
return r_regions;
}
void NavigationPathQueryParameters2D::set_excluded_regions(const TypedArray<RID> &p_regions) {
_excluded_regions.resize(p_regions.size());
for (uint32_t i = 0; i < _excluded_regions.size(); i++) {
_excluded_regions[i] = p_regions[i];
}
}
TypedArray<RID> NavigationPathQueryParameters2D::get_excluded_regions() const {
TypedArray<RID> r_regions;
r_regions.resize(_excluded_regions.size());
for (uint32_t i = 0; i < _excluded_regions.size(); i++) {
r_regions[i] = _excluded_regions[i];
}
return r_regions;
}
void NavigationPathQueryParameters2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_pathfinding_algorithm", "pathfinding_algorithm"), &NavigationPathQueryParameters2D::set_pathfinding_algorithm);
ClassDB::bind_method(D_METHOD("get_pathfinding_algorithm"), &NavigationPathQueryParameters2D::get_pathfinding_algorithm);
@ -130,6 +162,12 @@ void NavigationPathQueryParameters2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_simplify_epsilon", "epsilon"), &NavigationPathQueryParameters2D::set_simplify_epsilon);
ClassDB::bind_method(D_METHOD("get_simplify_epsilon"), &NavigationPathQueryParameters2D::get_simplify_epsilon);
ClassDB::bind_method(D_METHOD("set_included_regions", "regions"), &NavigationPathQueryParameters2D::set_included_regions);
ClassDB::bind_method(D_METHOD("get_included_regions"), &NavigationPathQueryParameters2D::get_included_regions);
ClassDB::bind_method(D_METHOD("set_excluded_regions", "regions"), &NavigationPathQueryParameters2D::set_excluded_regions);
ClassDB::bind_method(D_METHOD("get_excluded_regions"), &NavigationPathQueryParameters2D::get_excluded_regions);
ADD_PROPERTY(PropertyInfo(Variant::RID, "map"), "set_map", "get_map");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "start_position"), "set_start_position", "get_start_position");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "target_position"), "set_target_position", "get_target_position");
@ -139,6 +177,8 @@ void NavigationPathQueryParameters2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "metadata_flags", PROPERTY_HINT_FLAGS, "Include Types,Include RIDs,Include Owners"), "set_metadata_flags", "get_metadata_flags");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "simplify_path"), "set_simplify_path", "get_simplify_path");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "simplify_epsilon"), "set_simplify_epsilon", "get_simplify_epsilon");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "excluded_regions", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_excluded_regions", "get_excluded_regions");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "included_regions", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_included_regions", "get_included_regions");
BIND_ENUM_CONSTANT(PATHFINDING_ALGORITHM_ASTAR);

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef NAVIGATION_PATH_QUERY_PARAMETERS_2D_H
#define NAVIGATION_PATH_QUERY_PARAMETERS_2D_H
#pragma once
#include "core/object/ref_counted.h"
#include "servers/navigation/navigation_utilities.h"
@ -69,6 +68,8 @@ private:
BitField<PathMetadataFlags> metadata_flags = PATH_METADATA_INCLUDE_ALL;
bool simplify_path = false;
real_t simplify_epsilon = 0.0;
LocalVector<RID> _excluded_regions;
LocalVector<RID> _included_regions;
public:
void set_pathfinding_algorithm(const PathfindingAlgorithm p_pathfinding_algorithm);
@ -97,10 +98,14 @@ public:
void set_simplify_epsilon(real_t p_epsilon);
real_t get_simplify_epsilon() const;
void set_excluded_regions(const TypedArray<RID> &p_regions);
TypedArray<RID> get_excluded_regions() const;
void set_included_regions(const TypedArray<RID> &p_regions);
TypedArray<RID> get_included_regions() const;
};
VARIANT_ENUM_CAST(NavigationPathQueryParameters2D::PathfindingAlgorithm);
VARIANT_ENUM_CAST(NavigationPathQueryParameters2D::PathPostProcessing);
VARIANT_BITFIELD_CAST(NavigationPathQueryParameters2D::PathMetadataFlags);
#endif // NAVIGATION_PATH_QUERY_PARAMETERS_2D_H

View file

@ -102,6 +102,38 @@ real_t NavigationPathQueryParameters3D::get_simplify_epsilon() const {
return simplify_epsilon;
}
void NavigationPathQueryParameters3D::set_included_regions(const TypedArray<RID> &p_regions) {
_included_regions.resize(p_regions.size());
for (uint32_t i = 0; i < _included_regions.size(); i++) {
_included_regions[i] = p_regions[i];
}
}
TypedArray<RID> NavigationPathQueryParameters3D::get_included_regions() const {
TypedArray<RID> r_regions;
r_regions.resize(_included_regions.size());
for (uint32_t i = 0; i < _included_regions.size(); i++) {
r_regions[i] = _included_regions[i];
}
return r_regions;
}
void NavigationPathQueryParameters3D::set_excluded_regions(const TypedArray<RID> &p_regions) {
_excluded_regions.resize(p_regions.size());
for (uint32_t i = 0; i < _excluded_regions.size(); i++) {
_excluded_regions[i] = p_regions[i];
}
}
TypedArray<RID> NavigationPathQueryParameters3D::get_excluded_regions() const {
TypedArray<RID> r_regions;
r_regions.resize(_excluded_regions.size());
for (uint32_t i = 0; i < _excluded_regions.size(); i++) {
r_regions[i] = _excluded_regions[i];
}
return r_regions;
}
void NavigationPathQueryParameters3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_pathfinding_algorithm", "pathfinding_algorithm"), &NavigationPathQueryParameters3D::set_pathfinding_algorithm);
ClassDB::bind_method(D_METHOD("get_pathfinding_algorithm"), &NavigationPathQueryParameters3D::get_pathfinding_algorithm);
@ -130,6 +162,12 @@ void NavigationPathQueryParameters3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_simplify_epsilon", "epsilon"), &NavigationPathQueryParameters3D::set_simplify_epsilon);
ClassDB::bind_method(D_METHOD("get_simplify_epsilon"), &NavigationPathQueryParameters3D::get_simplify_epsilon);
ClassDB::bind_method(D_METHOD("set_included_regions", "regions"), &NavigationPathQueryParameters3D::set_included_regions);
ClassDB::bind_method(D_METHOD("get_included_regions"), &NavigationPathQueryParameters3D::get_included_regions);
ClassDB::bind_method(D_METHOD("set_excluded_regions", "regions"), &NavigationPathQueryParameters3D::set_excluded_regions);
ClassDB::bind_method(D_METHOD("get_excluded_regions"), &NavigationPathQueryParameters3D::get_excluded_regions);
ADD_PROPERTY(PropertyInfo(Variant::RID, "map"), "set_map", "get_map");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "start_position"), "set_start_position", "get_start_position");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "target_position"), "set_target_position", "get_target_position");
@ -139,6 +177,8 @@ void NavigationPathQueryParameters3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "metadata_flags", PROPERTY_HINT_FLAGS, "Include Types,Include RIDs,Include Owners"), "set_metadata_flags", "get_metadata_flags");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "simplify_path"), "set_simplify_path", "get_simplify_path");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "simplify_epsilon"), "set_simplify_epsilon", "get_simplify_epsilon");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "excluded_regions", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_excluded_regions", "get_excluded_regions");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "included_regions", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_included_regions", "get_included_regions");
BIND_ENUM_CONSTANT(PATHFINDING_ALGORITHM_ASTAR);

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef NAVIGATION_PATH_QUERY_PARAMETERS_3D_H
#define NAVIGATION_PATH_QUERY_PARAMETERS_3D_H
#pragma once
#include "core/object/ref_counted.h"
#include "servers/navigation/navigation_utilities.h"
@ -69,6 +68,8 @@ private:
BitField<PathMetadataFlags> metadata_flags = PATH_METADATA_INCLUDE_ALL;
bool simplify_path = false;
real_t simplify_epsilon = 0.0;
LocalVector<RID> _excluded_regions;
LocalVector<RID> _included_regions;
public:
void set_pathfinding_algorithm(const PathfindingAlgorithm p_pathfinding_algorithm);
@ -97,10 +98,14 @@ public:
void set_simplify_epsilon(real_t p_epsilon);
real_t get_simplify_epsilon() const;
void set_excluded_regions(const TypedArray<RID> &p_regions);
TypedArray<RID> get_excluded_regions() const;
void set_included_regions(const TypedArray<RID> &p_regions);
TypedArray<RID> get_included_regions() const;
};
VARIANT_ENUM_CAST(NavigationPathQueryParameters3D::PathfindingAlgorithm);
VARIANT_ENUM_CAST(NavigationPathQueryParameters3D::PathPostProcessing);
VARIANT_BITFIELD_CAST(NavigationPathQueryParameters3D::PathMetadataFlags);
#endif // NAVIGATION_PATH_QUERY_PARAMETERS_3D_H

View file

@ -69,6 +69,47 @@ void NavigationPathQueryResult2D::reset() {
path_owner_ids.clear();
}
void NavigationPathQueryResult2D::set_data(const LocalVector<Vector2> &p_path, const LocalVector<int32_t> &p_path_types, const LocalVector<RID> &p_path_rids, const LocalVector<int64_t> &p_path_owner_ids) {
path.clear();
path_types.clear();
path_rids.clear();
path_owner_ids.clear();
{
path.resize(p_path.size());
Vector2 *w = path.ptrw();
const Vector2 *r = p_path.ptr();
for (uint32_t i = 0; i < p_path.size(); i++) {
w[i] = r[i];
}
}
{
path_types.resize(p_path_types.size());
int32_t *w = path_types.ptrw();
const int32_t *r = p_path_types.ptr();
for (uint32_t i = 0; i < p_path_types.size(); i++) {
w[i] = r[i];
}
}
{
path_rids.resize(p_path_rids.size());
for (uint32_t i = 0; i < p_path_rids.size(); i++) {
path_rids[i] = p_path_rids[i];
}
}
{
path_owner_ids.resize(p_path_owner_ids.size());
int64_t *w = path_owner_ids.ptrw();
const int64_t *r = p_path_owner_ids.ptr();
for (uint32_t i = 0; i < p_path_owner_ids.size(); i++) {
w[i] = r[i];
}
}
}
void NavigationPathQueryResult2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_path", "path"), &NavigationPathQueryResult2D::set_path);
ClassDB::bind_method(D_METHOD("get_path"), &NavigationPathQueryResult2D::get_path);

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef NAVIGATION_PATH_QUERY_RESULT_2D_H
#define NAVIGATION_PATH_QUERY_RESULT_2D_H
#pragma once
#include "core/object/ref_counted.h"
#include "servers/navigation/navigation_utilities.h"
@ -64,8 +63,8 @@ public:
const Vector<int64_t> &get_path_owner_ids() const;
void reset();
void set_data(const LocalVector<Vector2> &p_path, const LocalVector<int32_t> &p_path_types, const LocalVector<RID> &p_path_rids, const LocalVector<int64_t> &p_path_owner_ids);
};
VARIANT_ENUM_CAST(NavigationPathQueryResult2D::PathSegmentType);
#endif // NAVIGATION_PATH_QUERY_RESULT_2D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef NAVIGATION_PATH_QUERY_RESULT_3D_H
#define NAVIGATION_PATH_QUERY_RESULT_3D_H
#pragma once
#include "core/object/ref_counted.h"
#include "core/variant/typed_array.h"
@ -70,5 +69,3 @@ public:
};
VARIANT_ENUM_CAST(NavigationPathQueryResult3D::PathSegmentType);
#endif // NAVIGATION_PATH_QUERY_RESULT_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef NAVIGATION_UTILITIES_H
#define NAVIGATION_UTILITIES_H
#pragma once
#include "core/math/vector3.h"
#include "core/variant/typed_array.h"
@ -60,5 +59,3 @@ enum PathMetadataFlags {
};
} //namespace NavigationUtilities
#endif // NAVIGATION_UTILITIES_H

View file

@ -31,8 +31,10 @@
#include "navigation_server_2d.h"
#include "navigation_server_2d.compat.inc"
#include "core/config/project_settings.h"
#include "scene/main/node.h"
#include "servers/navigation/navigation_globals.h"
#include "servers/navigation_server_2d_dummy.h"
#include "servers/navigation_server_3d.h"
NavigationServer2D *NavigationServer2D::singleton = nullptr;
@ -182,12 +184,28 @@ void NavigationServer2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("free_rid", "rid"), &NavigationServer2D::free);
ClassDB::bind_method(D_METHOD("set_active", "active"), &NavigationServer2D::set_active);
ClassDB::bind_method(D_METHOD("set_debug_enabled", "enabled"), &NavigationServer2D::set_debug_enabled);
ClassDB::bind_method(D_METHOD("get_debug_enabled"), &NavigationServer2D::get_debug_enabled);
ADD_SIGNAL(MethodInfo("map_changed", PropertyInfo(Variant::RID, "map")));
ADD_SIGNAL(MethodInfo("navigation_debug_changed"));
ADD_SIGNAL(MethodInfo("avoidance_debug_changed"));
ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &NavigationServer2D::get_process_info);
BIND_ENUM_CONSTANT(INFO_ACTIVE_MAPS);
BIND_ENUM_CONSTANT(INFO_REGION_COUNT);
BIND_ENUM_CONSTANT(INFO_AGENT_COUNT);
BIND_ENUM_CONSTANT(INFO_LINK_COUNT);
BIND_ENUM_CONSTANT(INFO_POLYGON_COUNT);
BIND_ENUM_CONSTANT(INFO_EDGE_COUNT);
BIND_ENUM_CONSTANT(INFO_EDGE_MERGE_COUNT);
BIND_ENUM_CONSTANT(INFO_EDGE_CONNECTION_COUNT);
BIND_ENUM_CONSTANT(INFO_EDGE_FREE_COUNT);
BIND_ENUM_CONSTANT(INFO_OBSTACLE_COUNT);
}
NavigationServer2D *NavigationServer2D::get_singleton() {
@ -197,19 +215,49 @@ NavigationServer2D *NavigationServer2D::get_singleton() {
NavigationServer2D::NavigationServer2D() {
ERR_FAIL_COND(singleton != nullptr);
singleton = this;
ERR_FAIL_NULL_MSG(NavigationServer3D::get_singleton(), "The Navigation3D singleton should be initialized before the 2D one.");
NavigationServer3D::get_singleton()->connect("map_changed", callable_mp(this, &NavigationServer2D::_emit_map_changed));
GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "navigation/2d/default_cell_size", PROPERTY_HINT_RANGE, NavigationDefaults2D::navmesh_cell_size_hint), NavigationDefaults2D::navmesh_cell_size);
GLOBAL_DEF("navigation/2d/use_edge_connections", true);
GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "navigation/2d/default_edge_connection_margin", PROPERTY_HINT_RANGE, "0.01,10,0.001,or_greater"), NavigationDefaults2D::edge_connection_margin);
GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "navigation/2d/default_link_connection_radius", PROPERTY_HINT_RANGE, "0.01,10,0.001,or_greater"), NavigationDefaults2D::link_connection_radius);
#ifdef DEBUG_ENABLED
NavigationServer3D::get_singleton()->connect(SNAME("navigation_debug_changed"), callable_mp(this, &NavigationServer2D::_emit_navigation_debug_changed_signal));
#endif // DEBUG_ENABLED
}
debug_navigation_edge_connection_color = GLOBAL_DEF("debug/shapes/navigation/2d/edge_connection_color", Color(1.0, 0.0, 1.0, 1.0));
debug_navigation_geometry_edge_color = GLOBAL_DEF("debug/shapes/navigation/2d/geometry_edge_color", Color(0.5, 1.0, 1.0, 1.0));
debug_navigation_geometry_face_color = GLOBAL_DEF("debug/shapes/navigation/2d/geometry_face_color", Color(0.5, 1.0, 1.0, 0.4));
debug_navigation_geometry_edge_disabled_color = GLOBAL_DEF("debug/shapes/navigation/2d/geometry_edge_disabled_color", Color(0.5, 0.5, 0.5, 1.0));
debug_navigation_geometry_face_disabled_color = GLOBAL_DEF("debug/shapes/navigation/2d/geometry_face_disabled_color", Color(0.5, 0.5, 0.5, 0.4));
debug_navigation_link_connection_color = GLOBAL_DEF("debug/shapes/navigation/2d/link_connection_color", Color(1.0, 0.5, 1.0, 1.0));
debug_navigation_link_connection_disabled_color = GLOBAL_DEF("debug/shapes/navigation/2d/link_connection_disabled_color", Color(0.5, 0.5, 0.5, 1.0));
debug_navigation_agent_path_color = GLOBAL_DEF("debug/shapes/navigation/2d/agent_path_color", Color(1.0, 0.0, 0.0, 1.0));
#ifdef DEBUG_ENABLED
void NavigationServer2D::_emit_navigation_debug_changed_signal() {
emit_signal(SNAME("navigation_debug_changed"));
}
debug_navigation_enable_edge_connections = GLOBAL_DEF("debug/shapes/navigation/2d/enable_edge_connections", true);
debug_navigation_enable_edge_lines = GLOBAL_DEF("debug/shapes/navigation/2d/enable_edge_lines", true);
debug_navigation_enable_geometry_face_random_color = GLOBAL_DEF("debug/shapes/navigation/2d/enable_geometry_face_random_color", true);
debug_navigation_enable_link_connections = GLOBAL_DEF("debug/shapes/navigation/2d/enable_link_connections", true);
debug_navigation_enable_agent_paths = GLOBAL_DEF("debug/shapes/navigation/2d/enable_agent_paths", true);
debug_navigation_agent_path_point_size = GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "debug/shapes/navigation/2d/agent_path_point_size", PROPERTY_HINT_RANGE, "0.01,10,0.001,or_greater"), 4.0);
debug_navigation_avoidance_agents_radius_color = GLOBAL_DEF("debug/shapes/avoidance/2d/agents_radius_color", Color(1.0, 1.0, 0.0, 0.25));
debug_navigation_avoidance_obstacles_radius_color = GLOBAL_DEF("debug/shapes/avoidance/2d/obstacles_radius_color", Color(1.0, 0.5, 0.0, 0.25));
debug_navigation_avoidance_static_obstacle_pushin_face_color = GLOBAL_DEF("debug/shapes/avoidance/2d/obstacles_static_face_pushin_color", Color(1.0, 0.0, 0.0, 0.0));
debug_navigation_avoidance_static_obstacle_pushin_edge_color = GLOBAL_DEF("debug/shapes/avoidance/2d/obstacles_static_edge_pushin_color", Color(1.0, 0.0, 0.0, 1.0));
debug_navigation_avoidance_static_obstacle_pushout_face_color = GLOBAL_DEF("debug/shapes/avoidance/2d/obstacles_static_face_pushout_color", Color(1.0, 1.0, 0.0, 0.5));
debug_navigation_avoidance_static_obstacle_pushout_edge_color = GLOBAL_DEF("debug/shapes/avoidance/2d/obstacles_static_edge_pushout_color", Color(1.0, 1.0, 0.0, 1.0));
debug_navigation_avoidance_enable_agents_radius = GLOBAL_DEF("debug/shapes/avoidance/2d/enable_agents_radius", true);
debug_navigation_avoidance_enable_obstacles_radius = GLOBAL_DEF("debug/shapes/avoidance/2d/enable_obstacles_radius", true);
debug_navigation_avoidance_enable_obstacles_static = GLOBAL_DEF("debug/shapes/avoidance/2d/enable_obstacles_static", true);
if (Engine::get_singleton()->is_editor_hint()) {
// enable NavigationServer3D when in Editor or else navigation mesh edge connections are invisible
// on runtime tests SceneTree has "Visible Navigation" set and main iteration takes care of this.
set_debug_enabled(true);
set_debug_navigation_enabled(true);
set_debug_avoidance_enabled(true);
}
#endif // DEBUG_ENABLED
}
NavigationServer2D::~NavigationServer2D() {
singleton = nullptr;
@ -256,209 +304,239 @@ void NavigationServer2D::source_geometry_parser_set_callback(RID p_parser, const
parser->callback = p_callback;
}
void NavigationServer2D::_emit_map_changed(RID p_map) {
emit_signal(SNAME("map_changed"), p_map);
}
void NavigationServer2D::set_debug_enabled(bool p_enabled) {
NavigationServer3D::get_singleton()->set_debug_enabled(p_enabled);
#ifdef DEBUG_ENABLED
if (debug_enabled != p_enabled) {
debug_dirty = true;
}
debug_enabled = p_enabled;
if (debug_dirty) {
navigation_debug_dirty = true;
callable_mp(this, &NavigationServer2D::_emit_navigation_debug_changed_signal).call_deferred();
avoidance_debug_dirty = true;
callable_mp(this, &NavigationServer2D::_emit_avoidance_debug_changed_signal).call_deferred();
}
#endif // DEBUG_ENABLED
}
bool NavigationServer2D::get_debug_enabled() const {
return NavigationServer3D::get_singleton()->get_debug_enabled();
return debug_enabled;
}
#ifdef DEBUG_ENABLED
void NavigationServer2D::_emit_navigation_debug_changed_signal() {
if (navigation_debug_dirty) {
navigation_debug_dirty = false;
emit_signal(SNAME("navigation_debug_changed"));
}
}
void NavigationServer2D::_emit_avoidance_debug_changed_signal() {
if (avoidance_debug_dirty) {
avoidance_debug_dirty = false;
emit_signal(SNAME("avoidance_debug_changed"));
}
}
#endif // DEBUG_ENABLED
#ifdef DEBUG_ENABLED
void NavigationServer2D::set_debug_navigation_enabled(bool p_enabled) {
NavigationServer3D::get_singleton()->set_debug_navigation_enabled(p_enabled);
debug_navigation_enabled = p_enabled;
navigation_debug_dirty = true;
callable_mp(this, &NavigationServer2D::_emit_navigation_debug_changed_signal).call_deferred();
}
bool NavigationServer2D::get_debug_navigation_enabled() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_enabled();
return debug_navigation_enabled;
}
void NavigationServer2D::set_debug_avoidance_enabled(bool p_enabled) {
NavigationServer3D::get_singleton()->set_debug_avoidance_enabled(p_enabled);
debug_avoidance_enabled = p_enabled;
avoidance_debug_dirty = true;
callable_mp(this, &NavigationServer2D::_emit_avoidance_debug_changed_signal).call_deferred();
}
bool NavigationServer2D::get_debug_avoidance_enabled() const {
return NavigationServer3D::get_singleton()->get_debug_avoidance_enabled();
return debug_avoidance_enabled;
}
void NavigationServer2D::set_debug_navigation_edge_connection_color(const Color &p_color) {
NavigationServer3D::get_singleton()->set_debug_navigation_edge_connection_color(p_color);
debug_navigation_edge_connection_color = p_color;
}
Color NavigationServer2D::get_debug_navigation_edge_connection_color() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_edge_connection_color();
return debug_navigation_edge_connection_color;
}
void NavigationServer2D::set_debug_navigation_geometry_face_color(const Color &p_color) {
NavigationServer3D::get_singleton()->set_debug_navigation_geometry_face_color(p_color);
debug_navigation_geometry_face_color = p_color;
}
Color NavigationServer2D::get_debug_navigation_geometry_face_color() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_geometry_face_color();
return debug_navigation_geometry_face_color;
}
void NavigationServer2D::set_debug_navigation_geometry_face_disabled_color(const Color &p_color) {
NavigationServer3D::get_singleton()->set_debug_navigation_geometry_face_disabled_color(p_color);
debug_navigation_geometry_face_disabled_color = p_color;
}
Color NavigationServer2D::get_debug_navigation_geometry_face_disabled_color() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_geometry_face_disabled_color();
return debug_navigation_geometry_face_disabled_color;
}
void NavigationServer2D::set_debug_navigation_link_connection_color(const Color &p_color) {
NavigationServer3D::get_singleton()->set_debug_navigation_link_connection_color(p_color);
debug_navigation_link_connection_color = p_color;
}
Color NavigationServer2D::get_debug_navigation_link_connection_color() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_link_connection_color();
return debug_navigation_link_connection_color;
}
void NavigationServer2D::set_debug_navigation_link_connection_disabled_color(const Color &p_color) {
NavigationServer3D::get_singleton()->set_debug_navigation_link_connection_disabled_color(p_color);
debug_navigation_link_connection_disabled_color = p_color;
}
Color NavigationServer2D::get_debug_navigation_link_connection_disabled_color() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_link_connection_disabled_color();
return debug_navigation_link_connection_disabled_color;
}
void NavigationServer2D::set_debug_navigation_geometry_edge_color(const Color &p_color) {
NavigationServer3D::get_singleton()->set_debug_navigation_geometry_edge_color(p_color);
debug_navigation_geometry_edge_color = p_color;
}
Color NavigationServer2D::get_debug_navigation_geometry_edge_color() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_geometry_edge_color();
return debug_navigation_geometry_edge_color;
}
void NavigationServer2D::set_debug_navigation_geometry_edge_disabled_color(const Color &p_color) {
NavigationServer3D::get_singleton()->set_debug_navigation_geometry_edge_disabled_color(p_color);
debug_navigation_geometry_edge_disabled_color = p_color;
}
Color NavigationServer2D::get_debug_navigation_geometry_edge_disabled_color() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_geometry_edge_disabled_color();
return debug_navigation_geometry_edge_disabled_color;
}
void NavigationServer2D::set_debug_navigation_enable_edge_connections(const bool p_value) {
NavigationServer3D::get_singleton()->set_debug_navigation_enable_edge_connections(p_value);
debug_navigation_enable_edge_connections = p_value;
}
bool NavigationServer2D::get_debug_navigation_enable_edge_connections() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_enable_edge_connections();
return debug_navigation_enable_edge_connections;
}
void NavigationServer2D::set_debug_navigation_enable_geometry_face_random_color(const bool p_value) {
NavigationServer3D::get_singleton()->set_debug_navigation_enable_geometry_face_random_color(p_value);
debug_navigation_enable_geometry_face_random_color = p_value;
}
bool NavigationServer2D::get_debug_navigation_enable_geometry_face_random_color() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_enable_geometry_face_random_color();
return debug_navigation_enable_geometry_face_random_color;
}
void NavigationServer2D::set_debug_navigation_enable_edge_lines(const bool p_value) {
NavigationServer3D::get_singleton()->set_debug_navigation_enable_edge_lines(p_value);
debug_navigation_enable_edge_lines = p_value;
}
bool NavigationServer2D::get_debug_navigation_enable_edge_lines() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_enable_edge_lines();
return debug_navigation_enable_edge_lines;
}
void NavigationServer2D::set_debug_navigation_agent_path_color(const Color &p_color) {
NavigationServer3D::get_singleton()->set_debug_navigation_agent_path_color(p_color);
debug_navigation_agent_path_color = p_color;
}
Color NavigationServer2D::get_debug_navigation_agent_path_color() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_agent_path_color();
return debug_navigation_agent_path_color;
}
void NavigationServer2D::set_debug_navigation_enable_agent_paths(const bool p_value) {
NavigationServer3D::get_singleton()->set_debug_navigation_enable_agent_paths(p_value);
debug_navigation_enable_agent_paths = p_value;
}
bool NavigationServer2D::get_debug_navigation_enable_agent_paths() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_enable_agent_paths();
return debug_navigation_enable_agent_paths;
}
void NavigationServer2D::set_debug_navigation_agent_path_point_size(real_t p_point_size) {
NavigationServer3D::get_singleton()->set_debug_navigation_agent_path_point_size(p_point_size);
debug_navigation_agent_path_point_size = p_point_size;
}
real_t NavigationServer2D::get_debug_navigation_agent_path_point_size() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_agent_path_point_size();
return debug_navigation_agent_path_point_size;
}
void NavigationServer2D::set_debug_navigation_avoidance_enable_agents_radius(const bool p_value) {
NavigationServer3D::get_singleton()->set_debug_navigation_avoidance_enable_agents_radius(p_value);
debug_navigation_avoidance_enable_agents_radius = p_value;
}
bool NavigationServer2D::get_debug_navigation_avoidance_enable_agents_radius() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_avoidance_enable_agents_radius();
return debug_navigation_avoidance_enable_agents_radius;
}
void NavigationServer2D::set_debug_navigation_avoidance_enable_obstacles_radius(const bool p_value) {
NavigationServer3D::get_singleton()->set_debug_navigation_avoidance_enable_obstacles_radius(p_value);
debug_navigation_avoidance_enable_obstacles_radius = p_value;
}
bool NavigationServer2D::get_debug_navigation_avoidance_enable_obstacles_radius() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_avoidance_enable_obstacles_radius();
return debug_navigation_avoidance_enable_obstacles_radius;
}
void NavigationServer2D::set_debug_navigation_avoidance_agents_radius_color(const Color &p_color) {
NavigationServer3D::get_singleton()->set_debug_navigation_avoidance_agents_radius_color(p_color);
debug_navigation_avoidance_agents_radius_color = p_color;
}
Color NavigationServer2D::get_debug_navigation_avoidance_agents_radius_color() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_avoidance_agents_radius_color();
return debug_navigation_avoidance_agents_radius_color;
}
void NavigationServer2D::set_debug_navigation_avoidance_obstacles_radius_color(const Color &p_color) {
NavigationServer3D::get_singleton()->set_debug_navigation_avoidance_obstacles_radius_color(p_color);
debug_navigation_avoidance_obstacles_radius_color = p_color;
}
Color NavigationServer2D::get_debug_navigation_avoidance_obstacles_radius_color() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_avoidance_obstacles_radius_color();
return debug_navigation_avoidance_obstacles_radius_color;
}
void NavigationServer2D::set_debug_navigation_avoidance_static_obstacle_pushin_face_color(const Color &p_color) {
NavigationServer3D::get_singleton()->set_debug_navigation_avoidance_static_obstacle_pushin_face_color(p_color);
debug_navigation_avoidance_static_obstacle_pushin_face_color = p_color;
}
Color NavigationServer2D::get_debug_navigation_avoidance_static_obstacle_pushin_face_color() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_avoidance_static_obstacle_pushin_face_color();
return debug_navigation_avoidance_static_obstacle_pushin_face_color;
}
void NavigationServer2D::set_debug_navigation_avoidance_static_obstacle_pushout_face_color(const Color &p_color) {
NavigationServer3D::get_singleton()->set_debug_navigation_avoidance_static_obstacle_pushout_face_color(p_color);
debug_navigation_avoidance_static_obstacle_pushout_face_color = p_color;
}
Color NavigationServer2D::get_debug_navigation_avoidance_static_obstacle_pushout_face_color() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_avoidance_static_obstacle_pushout_face_color();
return debug_navigation_avoidance_static_obstacle_pushout_face_color;
}
void NavigationServer2D::set_debug_navigation_avoidance_static_obstacle_pushin_edge_color(const Color &p_color) {
NavigationServer3D::get_singleton()->set_debug_navigation_avoidance_static_obstacle_pushin_edge_color(p_color);
debug_navigation_avoidance_static_obstacle_pushin_edge_color = p_color;
}
Color NavigationServer2D::get_debug_navigation_avoidance_static_obstacle_pushin_edge_color() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_avoidance_static_obstacle_pushin_edge_color();
return debug_navigation_avoidance_static_obstacle_pushin_edge_color;
}
void NavigationServer2D::set_debug_navigation_avoidance_static_obstacle_pushout_edge_color(const Color &p_color) {
NavigationServer3D::get_singleton()->set_debug_navigation_avoidance_static_obstacle_pushout_edge_color(p_color);
debug_navigation_avoidance_static_obstacle_pushout_edge_color = p_color;
}
Color NavigationServer2D::get_debug_navigation_avoidance_static_obstacle_pushout_edge_color() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_avoidance_static_obstacle_pushout_edge_color();
return debug_navigation_avoidance_static_obstacle_pushout_edge_color;
}
void NavigationServer2D::set_debug_navigation_avoidance_enable_obstacles_static(const bool p_value) {
NavigationServer3D::get_singleton()->set_debug_navigation_avoidance_enable_obstacles_static(p_value);
debug_navigation_avoidance_enable_obstacles_static = p_value;
}
bool NavigationServer2D::get_debug_navigation_avoidance_enable_obstacles_static() const {
return NavigationServer3D::get_singleton()->get_debug_navigation_avoidance_enable_obstacles_static();
return debug_navigation_avoidance_enable_obstacles_static;
}
#endif // DEBUG_ENABLED
@ -481,8 +559,6 @@ NavigationServer2D *NavigationServer2DManager::new_default_server() {
}
void NavigationServer2DManager::initialize_server() {
// NavigationServer3D must be initialized before NavigationServer2D.
ERR_FAIL_NULL(NavigationServer3D::get_singleton());
ERR_FAIL_COND(navigation_server_2d != nullptr);
// Init 2D Navigation Server

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef NAVIGATION_SERVER_2D_H
#define NAVIGATION_SERVER_2D_H
#pragma once
#include "core/object/class_db.h"
#include "core/templates/rid.h"
@ -54,8 +53,6 @@ class NavigationServer2D : public Object {
static NavigationServer2D *singleton;
void _emit_map_changed(RID p_map);
protected:
static void _bind_methods();
@ -304,6 +301,15 @@ public:
/// Returns a customized navigation path using a query parameters object
virtual void query_path(const Ref<NavigationPathQueryParameters2D> &p_query_parameters, Ref<NavigationPathQueryResult2D> p_query_result, const Callable &p_callback = Callable()) = 0;
/// Control activation of this server.
virtual void set_active(bool p_active) = 0;
/// Process the collision avoidance agents.
/// The result of this process is needed by the physics server,
/// so this must be called in the main thread.
/// Note: This function is not thread safe.
virtual void process(double p_delta_time) = 0;
virtual void physics_process(double p_delta_time) = 0;
virtual void init() = 0;
virtual void sync() = 0;
virtual void finish() = 0;
@ -330,6 +336,21 @@ public:
NavigationServer2D();
~NavigationServer2D() override;
enum ProcessInfo {
INFO_ACTIVE_MAPS,
INFO_REGION_COUNT,
INFO_AGENT_COUNT,
INFO_LINK_COUNT,
INFO_POLYGON_COUNT,
INFO_EDGE_COUNT,
INFO_EDGE_MERGE_COUNT,
INFO_EDGE_CONNECTION_COUNT,
INFO_EDGE_FREE_COUNT,
INFO_OBSTACLE_COUNT,
};
virtual int get_process_info(ProcessInfo p_info) const = 0;
void set_debug_enabled(bool p_enabled);
bool get_debug_enabled() const;
@ -340,8 +361,50 @@ protected:
static void _bind_compatibility_methods();
#endif
public:
private:
bool debug_enabled = false;
#ifdef DEBUG_ENABLED
bool debug_dirty = true;
bool debug_navigation_enabled = false;
bool navigation_debug_dirty = true;
void _emit_navigation_debug_changed_signal();
bool debug_avoidance_enabled = false;
bool avoidance_debug_dirty = true;
void _emit_avoidance_debug_changed_signal();
Color debug_navigation_edge_connection_color = Color(1.0, 0.0, 1.0, 1.0);
Color debug_navigation_geometry_edge_color = Color(0.5, 1.0, 1.0, 1.0);
Color debug_navigation_geometry_face_color = Color(0.5, 1.0, 1.0, 0.4);
Color debug_navigation_geometry_edge_disabled_color = Color(0.5, 0.5, 0.5, 1.0);
Color debug_navigation_geometry_face_disabled_color = Color(0.5, 0.5, 0.5, 0.4);
Color debug_navigation_link_connection_color = Color(1.0, 0.5, 1.0, 1.0);
Color debug_navigation_link_connection_disabled_color = Color(0.5, 0.5, 0.5, 1.0);
Color debug_navigation_agent_path_color = Color(1.0, 0.0, 0.0, 1.0);
real_t debug_navigation_agent_path_point_size = 4.0;
Color debug_navigation_avoidance_agents_radius_color = Color(1.0, 1.0, 0.0, 0.25);
Color debug_navigation_avoidance_obstacles_radius_color = Color(1.0, 0.5, 0.0, 0.25);
Color debug_navigation_avoidance_static_obstacle_pushin_face_color = Color(1.0, 0.0, 0.0, 0.0);
Color debug_navigation_avoidance_static_obstacle_pushout_face_color = Color(1.0, 1.0, 0.0, 0.5);
Color debug_navigation_avoidance_static_obstacle_pushin_edge_color = Color(1.0, 0.0, 0.0, 1.0);
Color debug_navigation_avoidance_static_obstacle_pushout_edge_color = Color(1.0, 1.0, 0.0, 1.0);
bool debug_navigation_enable_edge_connections = true;
bool debug_navigation_enable_edge_lines = true;
bool debug_navigation_enable_geometry_face_random_color = true;
bool debug_navigation_enable_link_connections = true;
bool debug_navigation_enable_agent_paths = true;
bool debug_navigation_avoidance_enable_agents_radius = true;
bool debug_navigation_avoidance_enable_obstacles_radius = true;
bool debug_navigation_avoidance_enable_obstacles_static = true;
public:
void set_debug_navigation_enabled(bool p_enabled);
bool get_debug_navigation_enabled() const;
@ -414,11 +477,6 @@ public:
void set_debug_navigation_avoidance_enable_obstacles_static(const bool p_value);
bool get_debug_navigation_avoidance_enable_obstacles_static() const;
#endif // DEBUG_ENABLED
#ifdef DEBUG_ENABLED
private:
void _emit_navigation_debug_changed_signal();
#endif // DEBUG_ENABLED
};
typedef NavigationServer2D *(*NavigationServer2DCallback)();
@ -435,4 +493,4 @@ public:
static void finalize_server();
};
#endif // NAVIGATION_SERVER_2D_H
VARIANT_ENUM_CAST(NavigationServer2D::ProcessInfo);

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef NAVIGATION_SERVER_2D_DUMMY_H
#define NAVIGATION_SERVER_2D_DUMMY_H
#pragma once
#include "servers/navigation_server_2d.h"
@ -163,10 +162,15 @@ public:
void query_path(const Ref<NavigationPathQueryParameters2D> &p_query_parameters, Ref<NavigationPathQueryResult2D> p_query_result, const Callable &p_callback = Callable()) override {}
void set_active(bool p_active) override {}
void process(double p_delta_time) override {}
void physics_process(double p_delta_time) override {}
void init() override {}
void sync() override {}
void finish() override {}
int get_process_info(ProcessInfo p_info) const override { return 0; }
void free(RID p_object) override {}
void parse_source_geometry_data(const Ref<NavigationPolygon> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData2D> &p_source_geometry_data, Node *p_root_node, const Callable &p_callback = Callable()) override {}
@ -182,5 +186,3 @@ public:
void set_debug_enabled(bool p_enabled) {}
bool get_debug_enabled() const { return false; }
};
#endif // NAVIGATION_SERVER_2D_DUMMY_H

View file

@ -240,11 +240,6 @@ NavigationServer3D::NavigationServer3D() {
ERR_FAIL_COND(singleton != nullptr);
singleton = this;
GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "navigation/2d/default_cell_size", PROPERTY_HINT_RANGE, NavigationDefaults2D::navmesh_cell_size_hint), NavigationDefaults2D::navmesh_cell_size);
GLOBAL_DEF("navigation/2d/use_edge_connections", true);
GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "navigation/2d/default_edge_connection_margin", PROPERTY_HINT_RANGE, "0.01,10,0.001,or_greater"), NavigationDefaults2D::edge_connection_margin);
GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "navigation/2d/default_link_connection_radius", PROPERTY_HINT_RANGE, "0.01,10,0.001,or_greater"), NavigationDefaults2D::link_connection_radius);
GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "navigation/3d/default_cell_size", PROPERTY_HINT_RANGE, NavigationDefaults3D::navmesh_cell_size_hint), NavigationDefaults3D::navmesh_cell_size);
GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "navigation/3d/default_cell_height", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), NavigationDefaults3D::navmesh_cell_height);
GLOBAL_DEF("navigation/3d/default_up", Vector3(0, 1, 0));
@ -253,48 +248,90 @@ NavigationServer3D::NavigationServer3D() {
GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "navigation/3d/default_edge_connection_margin", PROPERTY_HINT_RANGE, "0.01,10,0.001,or_greater"), NavigationDefaults3D::edge_connection_margin);
GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "navigation/3d/default_link_connection_radius", PROPERTY_HINT_RANGE, "0.01,10,0.001,or_greater"), NavigationDefaults3D::link_connection_radius);
GLOBAL_DEF("navigation/world/map_use_async_iterations", true);
GLOBAL_DEF("navigation/avoidance/thread_model/avoidance_use_multiple_threads", true);
GLOBAL_DEF("navigation/avoidance/thread_model/avoidance_use_high_priority_threads", true);
GLOBAL_DEF("navigation/pathfinding/max_threads", 4);
GLOBAL_DEF("navigation/baking/use_crash_prevention_checks", true);
GLOBAL_DEF("navigation/baking/thread_model/baking_use_multiple_threads", true);
GLOBAL_DEF("navigation/baking/thread_model/baking_use_high_priority_threads", true);
#ifdef DEBUG_ENABLED
debug_navigation_edge_connection_color = GLOBAL_DEF("debug/shapes/navigation/edge_connection_color", Color(1.0, 0.0, 1.0, 1.0));
debug_navigation_geometry_edge_color = GLOBAL_DEF("debug/shapes/navigation/geometry_edge_color", Color(0.5, 1.0, 1.0, 1.0));
debug_navigation_geometry_face_color = GLOBAL_DEF("debug/shapes/navigation/geometry_face_color", Color(0.5, 1.0, 1.0, 0.4));
debug_navigation_geometry_edge_disabled_color = GLOBAL_DEF("debug/shapes/navigation/geometry_edge_disabled_color", Color(0.5, 0.5, 0.5, 1.0));
debug_navigation_geometry_face_disabled_color = GLOBAL_DEF("debug/shapes/navigation/geometry_face_disabled_color", Color(0.5, 0.5, 0.5, 0.4));
debug_navigation_link_connection_color = GLOBAL_DEF("debug/shapes/navigation/link_connection_color", Color(1.0, 0.5, 1.0, 1.0));
debug_navigation_link_connection_disabled_color = GLOBAL_DEF("debug/shapes/navigation/link_connection_disabled_color", Color(0.5, 0.5, 0.5, 1.0));
debug_navigation_agent_path_color = GLOBAL_DEF("debug/shapes/navigation/agent_path_color", Color(1.0, 0.0, 0.0, 1.0));
#ifndef DISABLE_DEPRECATED
#define MOVE_PROJECT_SETTING_1(m_old_setting, m_new_setting) \
if (!ProjectSettings::get_singleton()->has_setting(m_new_setting) && ProjectSettings::get_singleton()->has_setting(m_old_setting)) { \
Variant value = GLOBAL_GET(m_old_setting); \
ProjectSettings::get_singleton()->set_setting(m_new_setting, value); \
ProjectSettings::get_singleton()->clear(m_old_setting); \
}
#define MOVE_PROJECT_SETTING_2(m_old_setting, m_new_setting_1, m_new_setting_2) \
if ((!ProjectSettings::get_singleton()->has_setting(m_new_setting_1) || !ProjectSettings::get_singleton()->has_setting(m_new_setting_2)) && \
ProjectSettings::get_singleton()->has_setting(m_old_setting)) { \
Variant value = GLOBAL_GET(m_old_setting); \
if (!ProjectSettings::get_singleton()->has_setting(m_new_setting_1)) { \
ProjectSettings::get_singleton()->set_setting(m_new_setting_1, value); \
} \
if (!ProjectSettings::get_singleton()->has_setting(m_new_setting_2)) { \
ProjectSettings::get_singleton()->set_setting(m_new_setting_2, value); \
} \
ProjectSettings::get_singleton()->clear(m_old_setting); \
}
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/edge_connection_color", "debug/shapes/navigation/2d/edge_connection_color", "debug/shapes/navigation/3d/edge_connection_color");
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/geometry_edge_color", "debug/shapes/navigation/2d/geometry_edge_color", "debug/shapes/navigation/3d/geometry_edge_color");
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/geometry_face_color", "debug/shapes/navigation/2d/geometry_face_color", "debug/shapes/navigation/3d/geometry_face_color");
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/geometry_edge_disabled_color", "debug/shapes/navigation/2d/geometry_edge_disabled_color", "debug/shapes/navigation/3d/geometry_edge_disabled_color");
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/geometry_face_disabled_color", "debug/shapes/navigation/2d/geometry_face_disabled_color", "debug/shapes/navigation/3d/geometry_face_disabled_color");
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/link_connection_color", "debug/shapes/navigation/2d/link_connection_color", "debug/shapes/navigation/3d/link_connection_color");
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/link_connection_disabled_color", "debug/shapes/navigation/2d/link_connection_disabled_color", "debug/shapes/navigation/3d/link_connection_disabled_color");
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/agent_path_color", "debug/shapes/navigation/2d/agent_path_color", "debug/shapes/navigation/3d/agent_path_color");
debug_navigation_enable_edge_connections = GLOBAL_DEF("debug/shapes/navigation/enable_edge_connections", true);
debug_navigation_enable_edge_connections_xray = GLOBAL_DEF("debug/shapes/navigation/enable_edge_connections_xray", true);
debug_navigation_enable_edge_lines = GLOBAL_DEF("debug/shapes/navigation/enable_edge_lines", true);
debug_navigation_enable_edge_lines_xray = GLOBAL_DEF("debug/shapes/navigation/enable_edge_lines_xray", true);
debug_navigation_enable_geometry_face_random_color = GLOBAL_DEF("debug/shapes/navigation/enable_geometry_face_random_color", true);
debug_navigation_enable_link_connections = GLOBAL_DEF("debug/shapes/navigation/enable_link_connections", true);
debug_navigation_enable_link_connections_xray = GLOBAL_DEF("debug/shapes/navigation/enable_link_connections_xray", true);
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/enable_edge_connections", "debug/shapes/navigation/2d/enable_edge_connections", "debug/shapes/navigation/3d/enable_edge_connections");
MOVE_PROJECT_SETTING_1("debug/shapes/navigation/enable_edge_connections_xray", "debug/shapes/navigation/3d/enable_edge_connections_xray");
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/enable_edge_lines", "debug/shapes/navigation/2d/enable_edge_lines", "debug/shapes/navigation/3d/enable_edge_lines");
MOVE_PROJECT_SETTING_1("debug/shapes/navigation/enable_edge_lines_xray", "debug/shapes/navigation/3d/enable_edge_lines_xray");
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/enable_geometry_face_random_color", "debug/shapes/navigation/2d/enable_geometry_face_random_color", "debug/shapes/navigation/3d/enable_geometry_face_random_color");
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/enable_link_connections", "debug/shapes/navigation/2d/enable_link_connections", "debug/shapes/navigation/3d/enable_link_connections");
MOVE_PROJECT_SETTING_1("debug/shapes/navigation/enable_link_connections_xray", "debug/shapes/navigation/3d/enable_link_connections_xray");
debug_navigation_enable_agent_paths = GLOBAL_DEF("debug/shapes/navigation/enable_agent_paths", true);
debug_navigation_enable_agent_paths_xray = GLOBAL_DEF("debug/shapes/navigation/enable_agent_paths_xray", true);
debug_navigation_agent_path_point_size = GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "debug/shapes/navigation/agent_path_point_size", PROPERTY_HINT_RANGE, "0.01,10,0.001,or_greater"), 4.0);
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/enable_agent_paths", "debug/shapes/navigation/2d/enable_agent_paths", "debug/shapes/navigation/3d/enable_agent_paths");
MOVE_PROJECT_SETTING_1("debug/shapes/navigation/enable_agent_paths_xray", "debug/shapes/navigation/3d/enable_agent_paths_xray");
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/agent_path_point_size", "debug/shapes/navigation/2d/agent_path_point_size", "debug/shapes/navigation/3d/agent_path_point_size");
debug_navigation_avoidance_agents_radius_color = GLOBAL_DEF("debug/shapes/avoidance/agents_radius_color", Color(1.0, 1.0, 0.0, 0.25));
debug_navigation_avoidance_obstacles_radius_color = GLOBAL_DEF("debug/shapes/avoidance/obstacles_radius_color", Color(1.0, 0.5, 0.0, 0.25));
debug_navigation_avoidance_static_obstacle_pushin_face_color = GLOBAL_DEF("debug/shapes/avoidance/obstacles_static_face_pushin_color", Color(1.0, 0.0, 0.0, 0.0));
debug_navigation_avoidance_static_obstacle_pushin_edge_color = GLOBAL_DEF("debug/shapes/avoidance/obstacles_static_edge_pushin_color", Color(1.0, 0.0, 0.0, 1.0));
debug_navigation_avoidance_static_obstacle_pushout_face_color = GLOBAL_DEF("debug/shapes/avoidance/obstacles_static_face_pushout_color", Color(1.0, 1.0, 0.0, 0.5));
debug_navigation_avoidance_static_obstacle_pushout_edge_color = GLOBAL_DEF("debug/shapes/avoidance/obstacles_static_edge_pushout_color", Color(1.0, 1.0, 0.0, 1.0));
debug_navigation_avoidance_enable_agents_radius = GLOBAL_DEF("debug/shapes/avoidance/enable_agents_radius", true);
debug_navigation_avoidance_enable_obstacles_radius = GLOBAL_DEF("debug/shapes/avoidance/enable_obstacles_radius", true);
debug_navigation_avoidance_enable_obstacles_static = GLOBAL_DEF("debug/shapes/avoidance/enable_obstacles_static", true);
MOVE_PROJECT_SETTING_2("debug/shapes/avoidance/agents_radius_color", "debug/shapes/avoidance/2d/agents_radius_color", "debug/shapes/avoidance/3d/agents_radius_color");
MOVE_PROJECT_SETTING_2("debug/shapes/avoidance/obstacles_radius_color", "debug/shapes/avoidance/2d/obstacles_radius_color", "debug/shapes/avoidance/3d/obstacles_radius_color");
MOVE_PROJECT_SETTING_2("debug/shapes/avoidance/obstacles_static_face_pushin_color", "debug/shapes/avoidance/2d/obstacles_static_face_pushin_color", "debug/shapes/avoidance/3d/obstacles_static_face_pushin_color");
MOVE_PROJECT_SETTING_2("debug/shapes/avoidance/obstacles_static_edge_pushin_color", "debug/shapes/avoidance/2d/obstacles_static_edge_pushin_color", "debug/shapes/avoidance/3d/obstacles_static_edge_pushin_color");
MOVE_PROJECT_SETTING_2("debug/shapes/avoidance/obstacles_static_face_pushout_color", "debug/shapes/avoidance/2d/obstacles_static_face_pushout_color", "debug/shapes/avoidance/3d/obstacles_static_face_pushout_color");
MOVE_PROJECT_SETTING_2("debug/shapes/avoidance/obstacles_static_edge_pushout_color", "debug/shapes/avoidance/2d/obstacles_static_edge_pushout_color", "debug/shapes/avoidance/3d/obstacles_static_edge_pushout_color");
MOVE_PROJECT_SETTING_2("debug/shapes/avoidance/enable_agents_radius", "debug/shapes/avoidance/2d/enable_agents_radius", "debug/shapes/avoidance/3d/enable_agents_radius");
MOVE_PROJECT_SETTING_2("debug/shapes/avoidance/enable_obstacles_radius", "debug/shapes/avoidance/2d/enable_obstacles_radius", "debug/shapes/avoidance/2d/enable_obstacles_static");
MOVE_PROJECT_SETTING_2("debug/shapes/avoidance/enable_obstacles_radius", "debug/shapes/avoidance/3d/enable_obstacles_radius", "debug/shapes/avoidance/3d/enable_obstacles_static");
#undef MOVE_PROJECT_SETTING_1
#undef MOVE_PROJECT_SETTING_2
#endif // DISABLE_DEPRECATED
debug_navigation_edge_connection_color = GLOBAL_DEF("debug/shapes/navigation/3d/edge_connection_color", Color(1.0, 0.0, 1.0, 1.0));
debug_navigation_geometry_edge_color = GLOBAL_DEF("debug/shapes/navigation/3d/geometry_edge_color", Color(0.5, 1.0, 1.0, 1.0));
debug_navigation_geometry_face_color = GLOBAL_DEF("debug/shapes/navigation/3d/geometry_face_color", Color(0.5, 1.0, 1.0, 0.4));
debug_navigation_geometry_edge_disabled_color = GLOBAL_DEF("debug/shapes/navigation/3d/geometry_edge_disabled_color", Color(0.5, 0.5, 0.5, 1.0));
debug_navigation_geometry_face_disabled_color = GLOBAL_DEF("debug/shapes/navigation/3d/geometry_face_disabled_color", Color(0.5, 0.5, 0.5, 0.4));
debug_navigation_link_connection_color = GLOBAL_DEF("debug/shapes/navigation/3d/link_connection_color", Color(1.0, 0.5, 1.0, 1.0));
debug_navigation_link_connection_disabled_color = GLOBAL_DEF("debug/shapes/navigation/3d/link_connection_disabled_color", Color(0.5, 0.5, 0.5, 1.0));
debug_navigation_agent_path_color = GLOBAL_DEF("debug/shapes/navigation/3d/agent_path_color", Color(1.0, 0.0, 0.0, 1.0));
debug_navigation_enable_edge_connections = GLOBAL_DEF("debug/shapes/navigation/3d/enable_edge_connections", true);
debug_navigation_enable_edge_connections_xray = GLOBAL_DEF("debug/shapes/navigation/3d/enable_edge_connections_xray", true);
debug_navigation_enable_edge_lines = GLOBAL_DEF("debug/shapes/navigation/3d/enable_edge_lines", true);
debug_navigation_enable_edge_lines_xray = GLOBAL_DEF("debug/shapes/navigation/3d/enable_edge_lines_xray", true);
debug_navigation_enable_geometry_face_random_color = GLOBAL_DEF("debug/shapes/navigation/3d/enable_geometry_face_random_color", true);
debug_navigation_enable_link_connections = GLOBAL_DEF("debug/shapes/navigation/3d/enable_link_connections", true);
debug_navigation_enable_link_connections_xray = GLOBAL_DEF("debug/shapes/navigation/3d/enable_link_connections_xray", true);
debug_navigation_enable_agent_paths = GLOBAL_DEF("debug/shapes/navigation/3d/enable_agent_paths", true);
debug_navigation_enable_agent_paths_xray = GLOBAL_DEF("debug/shapes/navigation/3d/enable_agent_paths_xray", true);
debug_navigation_agent_path_point_size = GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "debug/shapes/navigation/3d/agent_path_point_size", PROPERTY_HINT_RANGE, "0.01,10,0.001,or_greater"), 4.0);
debug_navigation_avoidance_agents_radius_color = GLOBAL_DEF("debug/shapes/avoidance/3d/agents_radius_color", Color(1.0, 1.0, 0.0, 0.25));
debug_navigation_avoidance_obstacles_radius_color = GLOBAL_DEF("debug/shapes/avoidance/3d/obstacles_radius_color", Color(1.0, 0.5, 0.0, 0.25));
debug_navigation_avoidance_static_obstacle_pushin_face_color = GLOBAL_DEF("debug/shapes/avoidance/3d/obstacles_static_face_pushin_color", Color(1.0, 0.0, 0.0, 0.0));
debug_navigation_avoidance_static_obstacle_pushin_edge_color = GLOBAL_DEF("debug/shapes/avoidance/3d/obstacles_static_edge_pushin_color", Color(1.0, 0.0, 0.0, 1.0));
debug_navigation_avoidance_static_obstacle_pushout_face_color = GLOBAL_DEF("debug/shapes/avoidance/3d/obstacles_static_face_pushout_color", Color(1.0, 1.0, 0.0, 0.5));
debug_navigation_avoidance_static_obstacle_pushout_edge_color = GLOBAL_DEF("debug/shapes/avoidance/3d/obstacles_static_edge_pushout_color", Color(1.0, 1.0, 0.0, 1.0));
debug_navigation_avoidance_enable_agents_radius = GLOBAL_DEF("debug/shapes/avoidance/3d/enable_agents_radius", true);
debug_navigation_avoidance_enable_obstacles_radius = GLOBAL_DEF("debug/shapes/avoidance/3d/enable_obstacles_radius", true);
debug_navigation_avoidance_enable_obstacles_static = GLOBAL_DEF("debug/shapes/avoidance/3d/enable_obstacles_static", true);
if (Engine::get_singleton()->is_editor_hint()) {
// enable NavigationServer3D when in Editor or else navigation mesh edge connections are invisible

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef NAVIGATION_SERVER_3D_H
#define NAVIGATION_SERVER_3D_H
#pragma once
#include "core/object/class_db.h"
#include "core/templates/rid.h"
@ -347,7 +346,8 @@ public:
/// The result of this process is needed by the physics server,
/// so this must be called in the main thread.
/// Note: This function is not thread safe.
virtual void process(real_t delta_time) = 0;
virtual void process(double p_delta_time) = 0;
virtual void physics_process(double p_delta_time) = 0;
virtual void init() = 0;
virtual void sync() = 0;
virtual void finish() = 0;
@ -590,5 +590,3 @@ public:
};
VARIANT_ENUM_CAST(NavigationServer3D::ProcessInfo);
#endif // NAVIGATION_SERVER_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef NAVIGATION_SERVER_3D_DUMMY_H
#define NAVIGATION_SERVER_3D_DUMMY_H
#pragma once
#include "servers/navigation_server_3d.h"
@ -197,7 +196,8 @@ public:
void free(RID p_object) override {}
void set_active(bool p_active) override {}
void process(real_t delta_time) override {}
void process(double p_delta_time) override {}
void physics_process(double p_delta_time) override {}
void init() override {}
void sync() override {}
void finish() override {}
@ -207,5 +207,3 @@ public:
void set_debug_enabled(bool p_enabled) {}
bool get_debug_enabled() const { return false; }
};
#endif // NAVIGATION_SERVER_3D_DUMMY_H

View file

@ -28,13 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef PHYSICS_SERVER_2D_H
#define PHYSICS_SERVER_2D_H
#pragma once
#include "core/io/resource.h"
#include "core/object/class_db.h"
#include "core/object/ref_counted.h"
constexpr int MAX_CONTACTS_REPORTED_2D_MAX = 4096;
class PhysicsDirectSpaceState2D;
template <typename T>
class TypedArray;
@ -845,5 +846,3 @@ VARIANT_ENUM_CAST(PhysicsServer2D::PinJointFlag);
VARIANT_ENUM_CAST(PhysicsServer2D::DampedSpringParam);
VARIANT_ENUM_CAST(PhysicsServer2D::AreaBodyStatus);
VARIANT_ENUM_CAST(PhysicsServer2D::ProcessInfo);
#endif // PHYSICS_SERVER_2D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef PHYSICS_SERVER_2D_DUMMY_H
#define PHYSICS_SERVER_2D_DUMMY_H
#pragma once
#include "physics_server_2d.h"
@ -346,5 +345,3 @@ public:
virtual int get_process_info(ProcessInfo p_info) override { return 0; }
};
#endif // PHYSICS_SERVER_2D_DUMMY_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef PHYSICS_SERVER_2D_WRAP_MT_H
#define PHYSICS_SERVER_2D_WRAP_MT_H
#pragma once
#include "core/object/worker_thread_pool.h"
#include "core/os/thread.h"
@ -338,5 +337,3 @@ public:
#ifdef DEBUG_ENABLED
#undef MAIN_THREAD_SYNC_WARN
#endif
#endif // PHYSICS_SERVER_2D_WRAP_MT_H

View file

@ -28,14 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef PHYSICS_SERVER_3D_H
#define PHYSICS_SERVER_3D_H
#pragma once
#ifndef _3D_DISABLED
#include "core/io/resource.h"
#include "core/object/gdvirtual.gen.inc"
constexpr int MAX_CONTACTS_REPORTED_3D_MAX = 4096;
class PhysicsDirectSpaceState3D;
template <typename T>
class TypedArray;
@ -1056,5 +1057,3 @@ VARIANT_ENUM_CAST(PhysicsServer3D::AreaBodyStatus);
VARIANT_ENUM_CAST(PhysicsServer3D::ProcessInfo);
#endif // _3D_DISABLED
#endif // PHYSICS_SERVER_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef PHYSICS_SERVER_3D_DUMMY_H
#define PHYSICS_SERVER_3D_DUMMY_H
#pragma once
#include "servers/physics_server_3d.h"
@ -432,5 +431,3 @@ public:
virtual int get_process_info(ProcessInfo p_info) override { return 0; }
};
#endif // PHYSICS_SERVER_3D_DUMMY_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef PHYSICS_SERVER_3D_WRAP_MT_H
#define PHYSICS_SERVER_3D_WRAP_MT_H
#pragma once
#include "core/config/project_settings.h"
#include "core/object/worker_thread_pool.h"
@ -414,5 +413,3 @@ public:
#ifdef DEBUG_ENABLED
#undef MAIN_THREAD_SYNC_WARN
#endif
#endif // PHYSICS_SERVER_3D_WRAP_MT_H

View file

@ -80,17 +80,25 @@
#include "text_server.h"
// 2D physics and navigation.
#ifndef NAVIGATION_2D_DISABLED
#include "navigation_server_2d.h"
#endif // NAVIGATION_2D_DISABLED
#ifndef PHYSICS_2D_DISABLED
#include "physics_server_2d.h"
#include "physics_server_2d_dummy.h"
#include "servers/extensions/physics_server_2d_extension.h"
#endif // PHYSICS_2D_DISABLED
// 3D physics and navigation (3D navigation is needed for 2D).
// 3D physics and navigation.
#ifndef NAVIGATION_3D_DISABLED
#include "navigation_server_3d.h"
#ifndef _3D_DISABLED
#endif // NAVIGATION_3D_DISABLED
#ifndef PHYSICS_3D_DISABLED
#include "physics_server_3d.h"
#include "physics_server_3d_dummy.h"
#include "servers/extensions/physics_server_3d_extension.h"
#endif // PHYSICS_3D_DISABLED
#ifndef XR_DISABLED
#include "xr/xr_body_tracker.h"
#include "xr/xr_controller_tracker.h"
#include "xr/xr_face_tracker.h"
@ -99,19 +107,21 @@
#include "xr/xr_interface_extension.h"
#include "xr/xr_positional_tracker.h"
#include "xr_server.h"
#endif // _3D_DISABLED
#endif // XR_DISABLED
ShaderTypes *shader_types = nullptr;
#ifndef _3D_DISABLED
static PhysicsServer3D *_create_dummy_physics_server_3d() {
return memnew(PhysicsServer3DDummy);
}
#endif // _3D_DISABLED
#ifndef PHYSICS_2D_DISABLED
static PhysicsServer2D *_create_dummy_physics_server_2d() {
return memnew(PhysicsServer2DDummy);
}
#endif // PHYSICS_2D_DISABLED
#ifndef PHYSICS_3D_DISABLED
static PhysicsServer3D *_create_dummy_physics_server_3d() {
return memnew(PhysicsServer3DDummy);
}
#endif // PHYSICS_3D_DISABLED
static bool has_server_feature_callback(const String &p_feature) {
if (RenderingServer::get_singleton()) {
@ -248,6 +258,13 @@ void register_server_types() {
ServersDebugger::initialize();
#ifndef NAVIGATION_2D_DISABLED
GDREGISTER_ABSTRACT_CLASS(NavigationServer2D);
GDREGISTER_CLASS(NavigationPathQueryParameters2D);
GDREGISTER_CLASS(NavigationPathQueryResult2D);
#endif // NAVIGATION_2D_DISABLED
#ifndef PHYSICS_2D_DISABLED
// Physics 2D
GDREGISTER_CLASS(PhysicsServer2DManager);
Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer2DManager", PhysicsServer2DManager::get_singleton(), "PhysicsServer2DManager"));
@ -273,12 +290,15 @@ void register_server_types() {
GLOBAL_DEF(PropertyInfo(Variant::STRING, PhysicsServer2DManager::setting_property_name, PROPERTY_HINT_ENUM, "DEFAULT"), "DEFAULT");
PhysicsServer2DManager::get_singleton()->register_server("Dummy", callable_mp_static(_create_dummy_physics_server_2d));
#endif // PHYSICS_2D_DISABLED
GDREGISTER_ABSTRACT_CLASS(NavigationServer2D);
GDREGISTER_CLASS(NavigationPathQueryParameters2D);
GDREGISTER_CLASS(NavigationPathQueryResult2D);
#ifndef NAVIGATION_3D_DISABLED
GDREGISTER_ABSTRACT_CLASS(NavigationServer3D);
GDREGISTER_CLASS(NavigationPathQueryParameters3D);
GDREGISTER_CLASS(NavigationPathQueryResult3D);
#endif // NAVIGATION_3D_DISABLED
#ifndef _3D_DISABLED
#ifndef PHYSICS_3D_DISABLED
// Physics 3D
GDREGISTER_CLASS(PhysicsServer3DManager);
Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer3DManager", PhysicsServer3DManager::get_singleton(), "PhysicsServer3DManager"));
@ -306,7 +326,9 @@ void register_server_types() {
GLOBAL_DEF(PropertyInfo(Variant::STRING, PhysicsServer3DManager::setting_property_name, PROPERTY_HINT_ENUM, "DEFAULT"), "DEFAULT");
PhysicsServer3DManager::get_singleton()->register_server("Dummy", callable_mp_static(_create_dummy_physics_server_3d));
#endif // PHYSICS_3D_DISABLED
#ifndef XR_DISABLED
GDREGISTER_ABSTRACT_CLASS(XRInterface);
GDREGISTER_CLASS(XRVRS);
GDREGISTER_CLASS(XRBodyTracker);
@ -318,11 +340,7 @@ void register_server_types() {
GDREGISTER_CLASS(XRPositionalTracker);
GDREGISTER_CLASS(XRServer);
GDREGISTER_ABSTRACT_CLASS(XRTracker);
#endif // _3D_DISABLED
GDREGISTER_ABSTRACT_CLASS(NavigationServer3D);
GDREGISTER_CLASS(NavigationPathQueryParameters3D);
GDREGISTER_CLASS(NavigationPathQueryResult3D);
#endif // XR_DISABLED
writer_mjpeg = memnew(MovieWriterMJPEG);
MovieWriter::add_writer(writer_mjpeg);
@ -351,15 +369,22 @@ void register_server_singletons() {
Engine::get_singleton()->add_singleton(Engine::Singleton("CameraServer", CameraServer::get_singleton(), "CameraServer"));
Engine::get_singleton()->add_singleton(Engine::Singleton("DisplayServer", DisplayServer::get_singleton(), "DisplayServer"));
Engine::get_singleton()->add_singleton(Engine::Singleton("NativeMenu", NativeMenu::get_singleton(), "NativeMenu"));
Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer2D", NavigationServer2D::get_singleton(), "NavigationServer2D"));
Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer3D", NavigationServer3D::get_singleton(), "NavigationServer3D"));
Engine::get_singleton()->add_singleton(Engine::Singleton("RenderingServer", RenderingServer::get_singleton(), "RenderingServer"));
#ifndef NAVIGATION_2D_DISABLED
Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer2D", NavigationServer2D::get_singleton(), "NavigationServer2D"));
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer3D", NavigationServer3D::get_singleton(), "NavigationServer3D"));
#endif // NAVIGATION_3D_DISABLED
#ifndef PHYSICS_2D_DISABLED
Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer2D", PhysicsServer2D::get_singleton(), "PhysicsServer2D"));
#ifndef _3D_DISABLED
#endif // PHYSICS_2D_DISABLED
#ifndef PHYSICS_3D_DISABLED
Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer3D", PhysicsServer3D::get_singleton(), "PhysicsServer3D"));
#endif // PHYSICS_3D_DISABLED
#ifndef XR_DISABLED
Engine::get_singleton()->add_singleton(Engine::Singleton("XRServer", XRServer::get_singleton(), "XRServer"));
#endif // _3D_DISABLED
#endif // XR_DISABLED
OS::get_singleton()->benchmark_end_measure("Servers", "Register Singletons");
}

View file

@ -28,12 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef REGISTER_SERVER_TYPES_H
#define REGISTER_SERVER_TYPES_H
#pragma once
void register_server_types();
void unregister_server_types();
void register_server_singletons();
#endif // REGISTER_SERVER_TYPES_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef FOG_DUMMY_H
#define FOG_DUMMY_H
#pragma once
#include "servers/rendering/environment/renderer_fog.h"
@ -51,5 +50,3 @@ public:
};
} // namespace RendererDummy
#endif // FOG_DUMMY_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GI_DUMMY_H
#define GI_DUMMY_H
#pragma once
#include "servers/rendering/environment/renderer_gi.h"
@ -83,5 +82,3 @@ public:
};
} // namespace RendererDummy
#endif // GI_DUMMY_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RASTERIZER_CANVAS_DUMMY_H
#define RASTERIZER_CANVAS_DUMMY_H
#pragma once
#include "servers/rendering/renderer_canvas_render.h"
@ -61,5 +60,3 @@ public:
RasterizerCanvasDummy() {}
~RasterizerCanvasDummy() {}
};
#endif // RASTERIZER_CANVAS_DUMMY_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RASTERIZER_DUMMY_H
#define RASTERIZER_DUMMY_H
#pragma once
#include "core/templates/rid_owner.h"
#include "core/templates/self_list.h"
@ -88,6 +87,7 @@ public:
void blit_render_targets_to_screen(int p_screen, const BlitToScreen *p_render_targets, int p_amount) override {}
bool is_opengl() override { return false; }
void gl_end_frame(bool p_swap_buffers) override {}
void end_frame(bool p_present) override {
@ -115,5 +115,3 @@ public:
RasterizerDummy() {}
~RasterizerDummy() {}
};
#endif // RASTERIZER_DUMMY_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RASTERIZER_SCENE_DUMMY_H
#define RASTERIZER_SCENE_DUMMY_H
#pragma once
#include "core/templates/paged_allocator.h"
#include "servers/rendering/renderer_scene_render.h"
@ -197,5 +196,3 @@ public:
RasterizerSceneDummy() {}
~RasterizerSceneDummy() {}
};
#endif // RASTERIZER_SCENE_DUMMY_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef LIGHT_STORAGE_DUMMY_H
#define LIGHT_STORAGE_DUMMY_H
#pragma once
#include "servers/rendering/storage/light_storage.h"
@ -219,5 +218,3 @@ public:
};
} // namespace RendererDummy
#endif // LIGHT_STORAGE_DUMMY_H

View file

@ -85,7 +85,7 @@ void MaterialStorage::global_shader_parameters_load_settings(bool p_load_texture
for (const PropertyInfo &E : settings) {
if (E.name.begins_with("shader_globals/")) {
StringName name = E.name.get_slice("/", 1);
StringName name = E.name.get_slicec('/', 1);
Dictionary d = GLOBAL_GET(E.name);
ERR_CONTINUE(!d.has("type"));

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef MATERIAL_STORAGE_DUMMY_H
#define MATERIAL_STORAGE_DUMMY_H
#pragma once
#include "servers/rendering/shader_compiler.h"
#include "servers/rendering/shader_language.h"
@ -128,5 +127,3 @@ public:
};
} // namespace RendererDummy
#endif // MATERIAL_STORAGE_DUMMY_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef MESH_STORAGE_DUMMY_H
#define MESH_STORAGE_DUMMY_H
#pragma once
#include "core/templates/rid_owner.h"
#include "servers/rendering/storage/mesh_storage.h"
@ -203,5 +202,3 @@ public:
};
} // namespace RendererDummy
#endif // MESH_STORAGE_DUMMY_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef PARTICLES_STORAGE_DUMMY_H
#define PARTICLES_STORAGE_DUMMY_H
#pragma once
#include "servers/rendering/storage/particles_storage.h"
@ -126,5 +125,3 @@ public:
};
} // namespace RendererDummy
#endif // PARTICLES_STORAGE_DUMMY_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef TEXTURE_STORAGE_DUMMY_H
#define TEXTURE_STORAGE_DUMMY_H
#pragma once
#include "servers/rendering/storage/texture_storage.h"
@ -215,5 +214,3 @@ public:
};
} // namespace RendererDummy
#endif // TEXTURE_STORAGE_DUMMY_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef UTILITIES_DUMMY_H
#define UTILITIES_DUMMY_H
#pragma once
#include "servers/rendering/storage/utilities.h"
@ -99,5 +98,3 @@ public:
};
} // namespace RendererDummy
#endif // UTILITIES_DUMMY_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RENDERER_FOG_H
#define RENDERER_FOG_H
#pragma once
#include "servers/rendering_server.h"
@ -49,5 +48,3 @@ public:
virtual AABB fog_volume_get_aabb(RID p_fog_volume) const = 0;
virtual RS::FogVolumeShape fog_volume_get_shape(RID p_fog_volume) const = 0;
};
#endif // RENDERER_FOG_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RENDERER_GI_H
#define RENDERER_GI_H
#pragma once
#include "servers/rendering_server.h"
@ -82,5 +81,3 @@ public:
virtual void sdfgi_reset() = 0;
};
#endif // RENDERER_GI_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef INSTANCE_UNIFORMS_H
#define INSTANCE_UNIFORMS_H
#pragma once
#include "core/variant/variant.h"
#include "servers/rendering/storage/material_storage.h"
@ -69,5 +68,3 @@ private:
void _init_param(Item &r_item, const RendererMaterialStorage::InstanceShaderParam &p_param) const;
void _invalidate_items();
};
#endif // INSTANCE_UNIFORMS_H

View file

@ -1440,7 +1440,7 @@ void RendererCanvasCull::canvas_item_add_circle(RID p_item, const Point2 &p_pos,
// Store circle center in the last point.
points_ptr[circle_segments + 1] = p_pos;
const real_t circle_point_step = Math_TAU / circle_segments;
const real_t circle_point_step = Math::TAU / circle_segments;
for (int i = 0; i < circle_segments + 1; i++) {
float angle = i * circle_point_step;
@ -1484,7 +1484,7 @@ void RendererCanvasCull::canvas_item_add_circle(RID p_item, const Point2 &p_pos,
points.resize(2 * circle_segments + 2);
colors.resize(2 * circle_segments + 2);
const real_t circle_point_step = Math_TAU / circle_segments;
const real_t circle_point_step = Math::TAU / circle_segments;
Vector2 *points_ptr = points.ptrw();
Color *colors_ptr = colors.ptrw();
@ -1522,7 +1522,7 @@ void RendererCanvasCull::canvas_item_add_texture_rect(RID p_item, const Rect2 &p
if (p_tile) {
rect->flags |= RendererCanvasRender::CANVAS_RECT_TILE;
rect->flags |= RendererCanvasRender::CANVAS_RECT_REGION;
rect->source = Rect2(0, 0, ABS(p_rect.size.width), ABS(p_rect.size.height));
rect->source = Rect2(0, 0, Math::abs(p_rect.size.width), Math::abs(p_rect.size.height));
}
if (p_rect.size.x < 0) {

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RENDERER_CANVAS_CULL_H
#define RENDERER_CANVAS_CULL_H
#pragma once
#include "core/templates/paged_allocator.h"
#include "renderer_compositor.h"
@ -412,5 +411,3 @@ public:
RendererCanvasCull();
~RendererCanvasCull();
};
#endif // RENDERER_CANVAS_CULL_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RENDERER_CANVAS_RENDER_H
#define RENDERER_CANVAS_RENDER_H
#pragma once
#include "servers/rendering/rendering_method.h"
#include "servers/rendering_server.h"
@ -557,5 +556,3 @@ public:
singleton = nullptr;
}
};
#endif // RENDERER_CANVAS_RENDER_H

View file

@ -31,7 +31,10 @@
#include "renderer_compositor.h"
#include "core/config/project_settings.h"
#ifndef XR_DISABLED
#include "servers/xr_server.h"
#endif // XR_DISABLED
RendererCompositor *RendererCompositor::singleton = nullptr;
@ -50,13 +53,13 @@ RendererCompositor::RendererCompositor() {
ERR_FAIL_COND_MSG(singleton != nullptr, "A RendererCompositor singleton already exists.");
singleton = this;
#ifndef _3D_DISABLED
#ifndef XR_DISABLED
if (XRServer::get_xr_mode() == XRServer::XRMODE_DEFAULT) {
xr_enabled = GLOBAL_GET("xr/shaders/enabled");
} else {
xr_enabled = XRServer::get_xr_mode() == XRServer::XRMODE_ON;
}
#endif // _3D_DISABLED
#endif // XR_DISABLED
}
RendererCompositor::~RendererCompositor() {

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RENDERER_COMPOSITOR_H
#define RENDERER_COMPOSITOR_H
#pragma once
#include "servers/rendering/environment/renderer_fog.h"
#include "servers/rendering/environment/renderer_gi.h"
@ -95,6 +94,7 @@ public:
virtual void blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount) = 0;
virtual bool is_opengl() = 0;
virtual void gl_end_frame(bool p_swap_buffers) = 0;
virtual void end_frame(bool p_present) = 0;
virtual void finalize() = 0;
@ -110,5 +110,3 @@ public:
RendererCompositor();
virtual ~RendererCompositor();
};
#endif // RENDERER_COMPOSITOR_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RENDERER_GEOMETRY_INSTANCE_H
#define RENDERER_GEOMETRY_INSTANCE_H
#pragma once
#include "core/math/rect2.h"
#include "core/math/transform_3d.h"
@ -149,5 +148,3 @@ public:
virtual Transform3D get_transform() override;
virtual AABB get_aabb() override;
};
#endif // RENDERER_GEOMETRY_INSTANCE_H

Some files were not shown because too many files have changed in this diff Show more