summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
Diffstat (limited to 'servers')
-rw-r--r--servers/SCsub1
-rw-r--r--servers/arvr/arvr_interface.cpp7
-rw-r--r--servers/arvr/arvr_interface.h1
-rw-r--r--servers/audio/audio_effect.h5
-rw-r--r--servers/audio/audio_filter_sw.cpp2
-rw-r--r--servers/audio/audio_stream.cpp5
-rw-r--r--servers/audio/audio_stream.h14
-rw-r--r--servers/audio/effects/audio_effect_amplify.h4
-rw-r--r--servers/audio/effects/audio_effect_chorus.h4
-rw-r--r--servers/audio/effects/audio_effect_compressor.h4
-rw-r--r--servers/audio/effects/audio_effect_delay.h4
-rw-r--r--servers/audio/effects/audio_effect_distortion.h5
-rw-r--r--servers/audio/effects/audio_effect_eq.h13
-rw-r--r--servers/audio/effects/audio_effect_filter.h23
-rw-r--r--servers/audio/effects/audio_effect_limiter.h4
-rw-r--r--servers/audio/effects/audio_effect_panner.h4
-rw-r--r--servers/audio/effects/audio_effect_phaser.h4
-rw-r--r--servers/audio/effects/audio_effect_pitch_shift.cpp42
-rw-r--r--servers/audio/effects/audio_effect_pitch_shift.h26
-rw-r--r--servers/audio/effects/audio_effect_record.cpp3
-rw-r--r--servers/audio/effects/audio_effect_record.h4
-rw-r--r--servers/audio/effects/audio_effect_reverb.h4
-rw-r--r--servers/audio/effects/audio_effect_spectrum_analyzer.cpp39
-rw-r--r--servers/audio/effects/audio_effect_spectrum_analyzer.h35
-rw-r--r--servers/audio/effects/audio_effect_stereo_enhance.h4
-rw-r--r--servers/audio/effects/audio_stream_generator.cpp30
-rw-r--r--servers/audio/effects/audio_stream_generator.h40
-rw-r--r--servers/audio_server.cpp17
-rw-r--r--servers/audio_server.h10
-rw-r--r--servers/camera/SCsub7
-rw-r--r--servers/camera/camera_feed.cpp266
-rw-r--r--servers/camera/camera_feed.h115
-rw-r--r--servers/camera_server.cpp169
-rw-r--r--servers/camera_server.h96
-rw-r--r--servers/physics/area_sw.cpp2
-rw-r--r--servers/physics/body_sw.cpp3
-rw-r--r--servers/physics/broad_phase_octree.cpp2
-rw-r--r--servers/physics/collision_object_sw.cpp7
-rw-r--r--servers/physics/collision_object_sw.h7
-rw-r--r--servers/physics/collision_solver_sat.cpp12
-rw-r--r--servers/physics/gjk_epa.cpp5
-rw-r--r--servers/physics/joints/generic_6dof_joint_sw.cpp1
-rw-r--r--servers/physics/space_sw.cpp4
-rw-r--r--servers/physics_2d/collision_object_2d_sw.cpp45
-rw-r--r--servers/physics_2d/collision_object_2d_sw.h2
-rw-r--r--servers/physics_2d/joints_2d_sw.cpp2
-rw-r--r--servers/physics_2d/physics_2d_server_sw.cpp20
-rw-r--r--servers/physics_2d/physics_2d_server_sw.h3
-rw-r--r--servers/physics_2d/space_2d_sw.cpp2
-rw-r--r--servers/register_server_types.cpp6
-rw-r--r--servers/server_wrap_mt_common.h2
-rw-r--r--servers/visual/rasterizer.h4
-rw-r--r--servers/visual/shader_language.cpp101
-rw-r--r--servers/visual/shader_language.h10
-rw-r--r--servers/visual/shader_types.cpp2
-rw-r--r--servers/visual/visual_server_canvas.cpp2
-rw-r--r--servers/visual/visual_server_canvas.h4
-rw-r--r--servers/visual/visual_server_raster.cpp4
-rw-r--r--servers/visual/visual_server_raster.h4
-rw-r--r--servers/visual/visual_server_scene.cpp6
-rw-r--r--servers/visual/visual_server_viewport.cpp2
-rw-r--r--servers/visual/visual_server_viewport.h3
-rw-r--r--servers/visual/visual_server_wrap_mt.h4
-rw-r--r--servers/visual_server.cpp14
-rw-r--r--servers/visual_server.h5
65 files changed, 1166 insertions, 135 deletions
diff --git a/servers/SCsub b/servers/SCsub
index f4af347fe6..34ba70b8cb 100644
--- a/servers/SCsub
+++ b/servers/SCsub
@@ -6,6 +6,7 @@ env.servers_sources = []
env.add_source_files(env.servers_sources, "*.cpp")
SConscript('arvr/SCsub')
+SConscript('camera/SCsub')
SConscript('physics/SCsub')
SConscript('physics_2d/SCsub')
SConscript('visual/SCsub')
diff --git a/servers/arvr/arvr_interface.cpp b/servers/arvr/arvr_interface.cpp
index 686ad0ba9b..e1b7611354 100644
--- a/servers/arvr/arvr_interface.cpp
+++ b/servers/arvr/arvr_interface.cpp
@@ -56,6 +56,7 @@ void ARVRInterface::_bind_methods() {
// but we do have properties specific to AR....
ClassDB::bind_method(D_METHOD("get_anchor_detection_is_enabled"), &ARVRInterface::get_anchor_detection_is_enabled);
ClassDB::bind_method(D_METHOD("set_anchor_detection_is_enabled", "enable"), &ARVRInterface::set_anchor_detection_is_enabled);
+ ClassDB::bind_method(D_METHOD("get_camera_feed_id"), &ARVRInterface::get_camera_feed_id);
ADD_GROUP("AR", "ar_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ar_is_anchor_detection_enabled"), "set_anchor_detection_is_enabled", "get_anchor_detection_is_enabled");
@@ -136,3 +137,9 @@ bool ARVRInterface::get_anchor_detection_is_enabled() const {
void ARVRInterface::set_anchor_detection_is_enabled(bool p_enable){
// don't do anything here, this needs to be implemented on AR interface to enable/disable things like plane detection etc.
};
+
+int ARVRInterface::get_camera_feed_id() {
+ // don't do anything here, this needs to be implemented on AR interface to enable/disable things like plane detection etc.
+
+ return 0;
+};
diff --git a/servers/arvr/arvr_interface.h b/servers/arvr/arvr_interface.h
index 9ea59a3961..ffafa4fcf5 100644
--- a/servers/arvr/arvr_interface.h
+++ b/servers/arvr/arvr_interface.h
@@ -101,6 +101,7 @@ public:
/** specific to AR **/
virtual bool get_anchor_detection_is_enabled() const;
virtual void set_anchor_detection_is_enabled(bool p_enable);
+ virtual int get_camera_feed_id();
/** rendering and internal **/
diff --git a/servers/audio/audio_effect.h b/servers/audio/audio_effect.h
index 1274e06740..8ae716db20 100644
--- a/servers/audio/audio_effect.h
+++ b/servers/audio/audio_effect.h
@@ -35,7 +35,7 @@
#include "core/resource.h"
class AudioEffectInstance : public Reference {
- GDCLASS(AudioEffectInstance, Reference)
+ GDCLASS(AudioEffectInstance, Reference);
public:
virtual void process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) = 0;
@@ -43,7 +43,8 @@ public:
};
class AudioEffect : public Resource {
- GDCLASS(AudioEffect, Resource)
+ GDCLASS(AudioEffect, Resource);
+
public:
virtual Ref<AudioEffectInstance> instance() = 0;
AudioEffect();
diff --git a/servers/audio/audio_filter_sw.cpp b/servers/audio/audio_filter_sw.cpp
index 392938a2be..ca033f6079 100644
--- a/servers/audio/audio_filter_sw.cpp
+++ b/servers/audio/audio_filter_sw.cpp
@@ -154,7 +154,6 @@ void AudioFilterSW::prepare_coefficients(Coeffs *p_coeffs) {
double tmpq = Math::sqrt(Q);
if (tmpq <= 0)
tmpq = 0.001;
- alpha = sin_v / (2 * tmpq);
double beta = Math::sqrt(tmpgain) / tmpq;
a0 = (tmpgain + 1.0) + (tmpgain - 1.0) * cos_v + beta * sin_v;
@@ -169,7 +168,6 @@ void AudioFilterSW::prepare_coefficients(Coeffs *p_coeffs) {
double tmpq = Math::sqrt(Q);
if (tmpq <= 0)
tmpq = 0.001;
- alpha = sin_v / (2 * tmpq);
double beta = Math::sqrt(tmpgain) / tmpq;
a0 = (tmpgain + 1.0) - (tmpgain - 1.0) * cos_v + beta * sin_v;
diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp
index 1a6430c499..17f5e158a7 100644
--- a/servers/audio/audio_stream.cpp
+++ b/servers/audio/audio_stream.cpp
@@ -49,8 +49,9 @@ void AudioStreamPlaybackResampled::_begin_resample() {
void AudioStreamPlaybackResampled::mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) {
float target_rate = AudioServer::get_singleton()->get_mix_rate();
+ float global_rate_scale = AudioServer::get_singleton()->get_global_rate_scale();
- uint64_t mix_increment = uint64_t(((get_stream_sampling_rate() * p_rate_scale) / double(target_rate)) * double(FP_LEN));
+ uint64_t mix_increment = uint64_t(((get_stream_sampling_rate() * p_rate_scale) / double(target_rate * global_rate_scale)) * double(FP_LEN));
for (int i = 0; i < p_frames; i++) {
@@ -223,7 +224,7 @@ float AudioStreamPlaybackMicrophone::get_playback_position() const {
}
void AudioStreamPlaybackMicrophone::seek(float p_time) {
- return; // Can't seek a microphone input
+ // Can't seek a microphone input
}
AudioStreamPlaybackMicrophone::~AudioStreamPlaybackMicrophone() {
diff --git a/servers/audio/audio_stream.h b/servers/audio/audio_stream.h
index ab4ef5f91b..ef9f8ea92a 100644
--- a/servers/audio/audio_stream.h
+++ b/servers/audio/audio_stream.h
@@ -38,7 +38,7 @@
class AudioStreamPlayback : public Reference {
- GDCLASS(AudioStreamPlayback, Reference)
+ GDCLASS(AudioStreamPlayback, Reference);
public:
virtual void start(float p_from_pos = 0.0) = 0;
@@ -55,7 +55,7 @@ public:
class AudioStreamPlaybackResampled : public AudioStreamPlayback {
- GDCLASS(AudioStreamPlaybackResampled, AudioStreamPlayback)
+ GDCLASS(AudioStreamPlaybackResampled, AudioStreamPlayback);
enum {
FP_BITS = 16, //fixed point used for resampling
@@ -81,7 +81,7 @@ public:
class AudioStream : public Resource {
- GDCLASS(AudioStream, Resource)
+ GDCLASS(AudioStream, Resource);
OBJ_SAVE_TYPE(AudioStream) //children are all saved as AudioStream, so they can be exchanged
protected:
@@ -100,7 +100,7 @@ class AudioStreamPlaybackMicrophone;
class AudioStreamMicrophone : public AudioStream {
- GDCLASS(AudioStreamMicrophone, AudioStream)
+ GDCLASS(AudioStreamMicrophone, AudioStream);
friend class AudioStreamPlaybackMicrophone;
Set<AudioStreamPlaybackMicrophone *> playbacks;
@@ -119,7 +119,7 @@ public:
class AudioStreamPlaybackMicrophone : public AudioStreamPlaybackResampled {
- GDCLASS(AudioStreamPlaybackMicrophone, AudioStreamPlayback)
+ GDCLASS(AudioStreamPlaybackMicrophone, AudioStreamPlaybackResampled);
friend class AudioStreamMicrophone;
bool active;
@@ -153,7 +153,7 @@ class AudioStreamPlaybackRandomPitch;
class AudioStreamRandomPitch : public AudioStream {
- GDCLASS(AudioStreamRandomPitch, AudioStream)
+ GDCLASS(AudioStreamRandomPitch, AudioStream);
friend class AudioStreamPlaybackRandomPitch;
Set<AudioStreamPlaybackRandomPitch *> playbacks;
@@ -180,7 +180,7 @@ public:
class AudioStreamPlaybackRandomPitch : public AudioStreamPlayback {
- GDCLASS(AudioStreamPlaybackRandomPitch, AudioStreamPlayback)
+ GDCLASS(AudioStreamPlaybackRandomPitch, AudioStreamPlayback);
friend class AudioStreamRandomPitch;
Ref<AudioStreamRandomPitch> random_pitch;
diff --git a/servers/audio/effects/audio_effect_amplify.h b/servers/audio/effects/audio_effect_amplify.h
index b6e2a1d4d8..4a98196d94 100644
--- a/servers/audio/effects/audio_effect_amplify.h
+++ b/servers/audio/effects/audio_effect_amplify.h
@@ -36,7 +36,7 @@
class AudioEffectAmplify;
class AudioEffectAmplifyInstance : public AudioEffectInstance {
- GDCLASS(AudioEffectAmplifyInstance, AudioEffectInstance)
+ GDCLASS(AudioEffectAmplifyInstance, AudioEffectInstance);
friend class AudioEffectAmplify;
Ref<AudioEffectAmplify> base;
@@ -47,7 +47,7 @@ public:
};
class AudioEffectAmplify : public AudioEffect {
- GDCLASS(AudioEffectAmplify, AudioEffect)
+ GDCLASS(AudioEffectAmplify, AudioEffect);
friend class AudioEffectAmplifyInstance;
float volume_db;
diff --git a/servers/audio/effects/audio_effect_chorus.h b/servers/audio/effects/audio_effect_chorus.h
index 9cad2906ff..417cc0c035 100644
--- a/servers/audio/effects/audio_effect_chorus.h
+++ b/servers/audio/effects/audio_effect_chorus.h
@@ -36,7 +36,7 @@
class AudioEffectChorus;
class AudioEffectChorusInstance : public AudioEffectInstance {
- GDCLASS(AudioEffectChorusInstance, AudioEffectInstance)
+ GDCLASS(AudioEffectChorusInstance, AudioEffectInstance);
friend class AudioEffectChorus;
Ref<AudioEffectChorus> base;
@@ -54,7 +54,7 @@ public:
};
class AudioEffectChorus : public AudioEffect {
- GDCLASS(AudioEffectChorus, AudioEffect)
+ GDCLASS(AudioEffectChorus, AudioEffect);
friend class AudioEffectChorusInstance;
diff --git a/servers/audio/effects/audio_effect_compressor.h b/servers/audio/effects/audio_effect_compressor.h
index 3ea3a58cb2..0fe956f60b 100644
--- a/servers/audio/effects/audio_effect_compressor.h
+++ b/servers/audio/effects/audio_effect_compressor.h
@@ -36,7 +36,7 @@
class AudioEffectCompressor;
class AudioEffectCompressorInstance : public AudioEffectInstance {
- GDCLASS(AudioEffectCompressorInstance, AudioEffectInstance)
+ GDCLASS(AudioEffectCompressorInstance, AudioEffectInstance);
friend class AudioEffectCompressor;
Ref<AudioEffectCompressor> base;
@@ -49,7 +49,7 @@ public:
};
class AudioEffectCompressor : public AudioEffect {
- GDCLASS(AudioEffectCompressor, AudioEffect)
+ GDCLASS(AudioEffectCompressor, AudioEffect);
friend class AudioEffectCompressorInstance;
float threshold;
diff --git a/servers/audio/effects/audio_effect_delay.h b/servers/audio/effects/audio_effect_delay.h
index 131b8714a0..ee778c70dc 100644
--- a/servers/audio/effects/audio_effect_delay.h
+++ b/servers/audio/effects/audio_effect_delay.h
@@ -36,7 +36,7 @@
class AudioEffectDelay;
class AudioEffectDelayInstance : public AudioEffectInstance {
- GDCLASS(AudioEffectDelayInstance, AudioEffectInstance)
+ GDCLASS(AudioEffectDelayInstance, AudioEffectInstance);
friend class AudioEffectDelay;
Ref<AudioEffectDelay> base;
@@ -58,7 +58,7 @@ public:
};
class AudioEffectDelay : public AudioEffect {
- GDCLASS(AudioEffectDelay, AudioEffect)
+ GDCLASS(AudioEffectDelay, AudioEffect);
friend class AudioEffectDelayInstance;
enum {
diff --git a/servers/audio/effects/audio_effect_distortion.h b/servers/audio/effects/audio_effect_distortion.h
index 2cbffc81a1..0b5ad0ec9e 100644
--- a/servers/audio/effects/audio_effect_distortion.h
+++ b/servers/audio/effects/audio_effect_distortion.h
@@ -36,7 +36,7 @@
class AudioEffectDistortion;
class AudioEffectDistortionInstance : public AudioEffectInstance {
- GDCLASS(AudioEffectDistortionInstance, AudioEffectInstance)
+ GDCLASS(AudioEffectDistortionInstance, AudioEffectInstance);
friend class AudioEffectDistortion;
Ref<AudioEffectDistortion> base;
float h[2];
@@ -46,7 +46,8 @@ public:
};
class AudioEffectDistortion : public AudioEffect {
- GDCLASS(AudioEffectDistortion, AudioEffect)
+ GDCLASS(AudioEffectDistortion, AudioEffect);
+
public:
enum Mode {
MODE_CLIP,
diff --git a/servers/audio/effects/audio_effect_eq.h b/servers/audio/effects/audio_effect_eq.h
index c9735b9073..dc75e566e7 100644
--- a/servers/audio/effects/audio_effect_eq.h
+++ b/servers/audio/effects/audio_effect_eq.h
@@ -37,7 +37,7 @@
class AudioEffectEQ;
class AudioEffectEQInstance : public AudioEffectInstance {
- GDCLASS(AudioEffectEQInstance, AudioEffectInstance)
+ GDCLASS(AudioEffectEQInstance, AudioEffectInstance);
friend class AudioEffectEQ;
Ref<AudioEffectEQ> base;
@@ -49,7 +49,7 @@ public:
};
class AudioEffectEQ : public AudioEffect {
- GDCLASS(AudioEffectEQ, AudioEffect)
+ GDCLASS(AudioEffectEQ, AudioEffect);
friend class AudioEffectEQInstance;
@@ -75,21 +75,24 @@ public:
};
class AudioEffectEQ6 : public AudioEffectEQ {
- GDCLASS(AudioEffectEQ6, AudioEffectEQ)
+ GDCLASS(AudioEffectEQ6, AudioEffectEQ);
+
public:
AudioEffectEQ6() :
AudioEffectEQ(EQ::PRESET_6_BANDS) {}
};
class AudioEffectEQ10 : public AudioEffectEQ {
- GDCLASS(AudioEffectEQ10, AudioEffectEQ)
+ GDCLASS(AudioEffectEQ10, AudioEffectEQ);
+
public:
AudioEffectEQ10() :
AudioEffectEQ(EQ::PRESET_10_BANDS) {}
};
class AudioEffectEQ21 : public AudioEffectEQ {
- GDCLASS(AudioEffectEQ21, AudioEffectEQ)
+ GDCLASS(AudioEffectEQ21, AudioEffectEQ);
+
public:
AudioEffectEQ21() :
AudioEffectEQ(EQ::PRESET_21_BANDS) {}
diff --git a/servers/audio/effects/audio_effect_filter.h b/servers/audio/effects/audio_effect_filter.h
index fd9a4bcf07..bb0d451522 100644
--- a/servers/audio/effects/audio_effect_filter.h
+++ b/servers/audio/effects/audio_effect_filter.h
@@ -37,7 +37,7 @@
class AudioEffectFilter;
class AudioEffectFilterInstance : public AudioEffectInstance {
- GDCLASS(AudioEffectFilterInstance, AudioEffectInstance)
+ GDCLASS(AudioEffectFilterInstance, AudioEffectInstance);
friend class AudioEffectFilter;
Ref<AudioEffectFilter> base;
@@ -55,7 +55,8 @@ public:
};
class AudioEffectFilter : public AudioEffect {
- GDCLASS(AudioEffectFilter, AudioEffect)
+ GDCLASS(AudioEffectFilter, AudioEffect);
+
public:
enum FilterDB {
FILTER_6DB,
@@ -95,7 +96,7 @@ public:
VARIANT_ENUM_CAST(AudioEffectFilter::FilterDB)
class AudioEffectLowPassFilter : public AudioEffectFilter {
- GDCLASS(AudioEffectLowPassFilter, AudioEffectFilter)
+ GDCLASS(AudioEffectLowPassFilter, AudioEffectFilter);
void _validate_property(PropertyInfo &property) const {
if (property.name == "gain") property.usage = 0;
@@ -107,7 +108,7 @@ public:
};
class AudioEffectHighPassFilter : public AudioEffectFilter {
- GDCLASS(AudioEffectHighPassFilter, AudioEffectFilter)
+ GDCLASS(AudioEffectHighPassFilter, AudioEffectFilter);
void _validate_property(PropertyInfo &property) const {
if (property.name == "gain") property.usage = 0;
}
@@ -118,7 +119,7 @@ public:
};
class AudioEffectBandPassFilter : public AudioEffectFilter {
- GDCLASS(AudioEffectBandPassFilter, AudioEffectFilter)
+ GDCLASS(AudioEffectBandPassFilter, AudioEffectFilter);
void _validate_property(PropertyInfo &property) const {
if (property.name == "gain") property.usage = 0;
}
@@ -129,28 +130,32 @@ public:
};
class AudioEffectNotchFilter : public AudioEffectFilter {
- GDCLASS(AudioEffectNotchFilter, AudioEffectFilter)
+ GDCLASS(AudioEffectNotchFilter, AudioEffectFilter);
+
public:
AudioEffectNotchFilter() :
AudioEffectFilter(AudioFilterSW::NOTCH) {}
};
class AudioEffectBandLimitFilter : public AudioEffectFilter {
- GDCLASS(AudioEffectBandLimitFilter, AudioEffectFilter)
+ GDCLASS(AudioEffectBandLimitFilter, AudioEffectFilter);
+
public:
AudioEffectBandLimitFilter() :
AudioEffectFilter(AudioFilterSW::BANDLIMIT) {}
};
class AudioEffectLowShelfFilter : public AudioEffectFilter {
- GDCLASS(AudioEffectLowShelfFilter, AudioEffectFilter)
+ GDCLASS(AudioEffectLowShelfFilter, AudioEffectFilter);
+
public:
AudioEffectLowShelfFilter() :
AudioEffectFilter(AudioFilterSW::LOWSHELF) {}
};
class AudioEffectHighShelfFilter : public AudioEffectFilter {
- GDCLASS(AudioEffectHighShelfFilter, AudioEffectFilter)
+ GDCLASS(AudioEffectHighShelfFilter, AudioEffectFilter);
+
public:
AudioEffectHighShelfFilter() :
AudioEffectFilter(AudioFilterSW::HIGHSHELF) {}
diff --git a/servers/audio/effects/audio_effect_limiter.h b/servers/audio/effects/audio_effect_limiter.h
index d629166f42..bf7167e3f4 100644
--- a/servers/audio/effects/audio_effect_limiter.h
+++ b/servers/audio/effects/audio_effect_limiter.h
@@ -36,7 +36,7 @@
class AudioEffectLimiter;
class AudioEffectLimiterInstance : public AudioEffectInstance {
- GDCLASS(AudioEffectLimiterInstance, AudioEffectInstance)
+ GDCLASS(AudioEffectLimiterInstance, AudioEffectInstance);
friend class AudioEffectLimiter;
Ref<AudioEffectLimiter> base;
@@ -47,7 +47,7 @@ public:
};
class AudioEffectLimiter : public AudioEffect {
- GDCLASS(AudioEffectLimiter, AudioEffect)
+ GDCLASS(AudioEffectLimiter, AudioEffect);
friend class AudioEffectLimiterInstance;
float threshold;
diff --git a/servers/audio/effects/audio_effect_panner.h b/servers/audio/effects/audio_effect_panner.h
index 4256d05a2f..7bd5a09fc6 100644
--- a/servers/audio/effects/audio_effect_panner.h
+++ b/servers/audio/effects/audio_effect_panner.h
@@ -36,7 +36,7 @@
class AudioEffectPanner;
class AudioEffectPannerInstance : public AudioEffectInstance {
- GDCLASS(AudioEffectPannerInstance, AudioEffectInstance)
+ GDCLASS(AudioEffectPannerInstance, AudioEffectInstance);
friend class AudioEffectPanner;
Ref<AudioEffectPanner> base;
@@ -45,7 +45,7 @@ public:
};
class AudioEffectPanner : public AudioEffect {
- GDCLASS(AudioEffectPanner, AudioEffect)
+ GDCLASS(AudioEffectPanner, AudioEffect);
friend class AudioEffectPannerInstance;
float pan;
diff --git a/servers/audio/effects/audio_effect_phaser.h b/servers/audio/effects/audio_effect_phaser.h
index 264e792be5..b76d6bb29c 100644
--- a/servers/audio/effects/audio_effect_phaser.h
+++ b/servers/audio/effects/audio_effect_phaser.h
@@ -36,7 +36,7 @@
class AudioEffectPhaser;
class AudioEffectPhaserInstance : public AudioEffectInstance {
- GDCLASS(AudioEffectPhaserInstance, AudioEffectInstance)
+ GDCLASS(AudioEffectPhaserInstance, AudioEffectInstance);
friend class AudioEffectPhaser;
Ref<AudioEffectPhaser> base;
@@ -70,7 +70,7 @@ public:
};
class AudioEffectPhaser : public AudioEffect {
- GDCLASS(AudioEffectPhaser, AudioEffect)
+ GDCLASS(AudioEffectPhaser, AudioEffect);
friend class AudioEffectPhaserInstance;
float range_min;
diff --git a/servers/audio/effects/audio_effect_pitch_shift.cpp b/servers/audio/effects/audio_effect_pitch_shift.cpp
index ca2a88f858..c250f2e2bd 100644
--- a/servers/audio/effects/audio_effect_pitch_shift.cpp
+++ b/servers/audio/effects/audio_effect_pitch_shift.cpp
@@ -293,14 +293,16 @@ void AudioEffectPitchShiftInstance::process(const AudioFrame *p_src_frames, Audi
float *out_l = (float *)p_dst_frames;
float *out_r = out_l + 1;
- shift_l.PitchShift(base->pitch_scale, p_frame_count, 2048, 4, sample_rate, in_l, out_l, 2);
- shift_r.PitchShift(base->pitch_scale, p_frame_count, 2048, 4, sample_rate, in_r, out_r, 2);
+ shift_l.PitchShift(base->pitch_scale, p_frame_count, fft_size, base->oversampling, sample_rate, in_l, out_l, 2);
+ shift_r.PitchShift(base->pitch_scale, p_frame_count, fft_size, base->oversampling, sample_rate, in_r, out_r, 2);
}
Ref<AudioEffectInstance> AudioEffectPitchShift::instance() {
Ref<AudioEffectPitchShiftInstance> ins;
ins.instance();
ins->base = Ref<AudioEffectPitchShift>(this);
+ static const int fft_sizes[FFT_SIZE_MAX] = { 256, 512, 1024, 2048, 4096 };
+ ins->fft_size = fft_sizes[fft_size];
return ins;
}
@@ -315,14 +317,50 @@ float AudioEffectPitchShift::get_pitch_scale() const {
return pitch_scale;
}
+void AudioEffectPitchShift::set_oversampling(int p_oversampling) {
+ ERR_FAIL_COND(p_oversampling < 4);
+ oversampling = p_oversampling;
+}
+
+int AudioEffectPitchShift::get_oversampling() const {
+
+ return oversampling;
+}
+
+void AudioEffectPitchShift::set_fft_size(FFT_Size p_fft_size) {
+ ERR_FAIL_INDEX(p_fft_size, FFT_SIZE_MAX);
+ fft_size = p_fft_size;
+}
+
+AudioEffectPitchShift::FFT_Size AudioEffectPitchShift::get_fft_size() const {
+ return fft_size;
+}
+
void AudioEffectPitchShift::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_pitch_scale", "rate"), &AudioEffectPitchShift::set_pitch_scale);
ClassDB::bind_method(D_METHOD("get_pitch_scale"), &AudioEffectPitchShift::get_pitch_scale);
+ ClassDB::bind_method(D_METHOD("set_oversampling", "amount"), &AudioEffectPitchShift::set_oversampling);
+ ClassDB::bind_method(D_METHOD("get_oversampling"), &AudioEffectPitchShift::get_oversampling);
+
+ ClassDB::bind_method(D_METHOD("set_fft_size", "size"), &AudioEffectPitchShift::set_fft_size);
+ ClassDB::bind_method(D_METHOD("get_fft_size"), &AudioEffectPitchShift::get_fft_size);
+
ADD_PROPERTY(PropertyInfo(Variant::REAL, "pitch_scale", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_pitch_scale", "get_pitch_scale");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "oversampling", PROPERTY_HINT_RANGE, "4,32,1"), "set_oversampling", "get_oversampling");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "fft_size", PROPERTY_HINT_ENUM, "256,512,1024,2048,4096"), "set_fft_size", "get_fft_size");
+
+ BIND_ENUM_CONSTANT(FFT_SIZE_256);
+ BIND_ENUM_CONSTANT(FFT_SIZE_512);
+ BIND_ENUM_CONSTANT(FFT_SIZE_1024);
+ BIND_ENUM_CONSTANT(FFT_SIZE_2048);
+ BIND_ENUM_CONSTANT(FFT_SIZE_4096);
+ BIND_ENUM_CONSTANT(FFT_SIZE_MAX);
}
AudioEffectPitchShift::AudioEffectPitchShift() {
pitch_scale = 1.0;
+ oversampling = 4;
+ fft_size = FFT_SIZE_2048;
}
diff --git a/servers/audio/effects/audio_effect_pitch_shift.h b/servers/audio/effects/audio_effect_pitch_shift.h
index febc20e9d5..2028496ebf 100644
--- a/servers/audio/effects/audio_effect_pitch_shift.h
+++ b/servers/audio/effects/audio_effect_pitch_shift.h
@@ -72,10 +72,11 @@ public:
class AudioEffectPitchShift;
class AudioEffectPitchShiftInstance : public AudioEffectInstance {
- GDCLASS(AudioEffectPitchShiftInstance, AudioEffectInstance)
+ GDCLASS(AudioEffectPitchShiftInstance, AudioEffectInstance);
friend class AudioEffectPitchShift;
Ref<AudioEffectPitchShift> base;
+ int fft_size;
SMBPitchShift shift_l;
SMBPitchShift shift_r;
@@ -84,12 +85,23 @@ public:
};
class AudioEffectPitchShift : public AudioEffect {
- GDCLASS(AudioEffectPitchShift, AudioEffect)
+ GDCLASS(AudioEffectPitchShift, AudioEffect);
+public:
friend class AudioEffectPitchShiftInstance;
+ enum FFT_Size {
+ FFT_SIZE_256,
+ FFT_SIZE_512,
+ FFT_SIZE_1024,
+ FFT_SIZE_2048,
+ FFT_SIZE_4096,
+ FFT_SIZE_MAX
+ };
+
float pitch_scale;
- int window_size;
+ int oversampling;
+ FFT_Size fft_size;
float wet;
float dry;
bool filter;
@@ -103,7 +115,15 @@ public:
void set_pitch_scale(float p_pitch_scale);
float get_pitch_scale() const;
+ void set_oversampling(int p_oversampling);
+ int get_oversampling() const;
+
+ void set_fft_size(FFT_Size);
+ FFT_Size get_fft_size() const;
+
AudioEffectPitchShift();
};
+VARIANT_ENUM_CAST(AudioEffectPitchShift::FFT_Size);
+
#endif // AUDIO_EFFECT_PITCH_SHIFT_H
diff --git a/servers/audio/effects/audio_effect_record.cpp b/servers/audio/effects/audio_effect_record.cpp
index abf9d5593c..acf27d2bbf 100644
--- a/servers/audio/effects/audio_effect_record.cpp
+++ b/servers/audio/effects/audio_effect_record.cpp
@@ -216,6 +216,9 @@ Ref<AudioStreamSample> AudioEffectRecord::get_recording() const {
PoolVector<uint8_t> dst_data;
+ ERR_FAIL_COND_V(current_instance.is_null(), NULL);
+ ERR_FAIL_COND_V(current_instance->recording_data.size(), NULL);
+
if (dst_format == AudioStreamSample::FORMAT_8_BITS) {
int data_size = current_instance->recording_data.size();
dst_data.resize(data_size);
diff --git a/servers/audio/effects/audio_effect_record.h b/servers/audio/effects/audio_effect_record.h
index 528c7dbd7c..d9bf39eb5f 100644
--- a/servers/audio/effects/audio_effect_record.h
+++ b/servers/audio/effects/audio_effect_record.h
@@ -43,7 +43,7 @@
class AudioEffectRecord;
class AudioEffectRecordInstance : public AudioEffectInstance {
- GDCLASS(AudioEffectRecordInstance, AudioEffectInstance)
+ GDCLASS(AudioEffectRecordInstance, AudioEffectInstance);
friend class AudioEffectRecord;
Ref<AudioEffectRecord> base;
@@ -77,7 +77,7 @@ public:
};
class AudioEffectRecord : public AudioEffect {
- GDCLASS(AudioEffectRecord, AudioEffect)
+ GDCLASS(AudioEffectRecord, AudioEffect);
friend class AudioEffectRecordInstance;
diff --git a/servers/audio/effects/audio_effect_reverb.h b/servers/audio/effects/audio_effect_reverb.h
index ed76050f24..31a796bf98 100644
--- a/servers/audio/effects/audio_effect_reverb.h
+++ b/servers/audio/effects/audio_effect_reverb.h
@@ -37,7 +37,7 @@
class AudioEffectReverb;
class AudioEffectReverbInstance : public AudioEffectInstance {
- GDCLASS(AudioEffectReverbInstance, AudioEffectInstance)
+ GDCLASS(AudioEffectReverbInstance, AudioEffectInstance);
Ref<AudioEffectReverb> base;
@@ -54,7 +54,7 @@ public:
};
class AudioEffectReverb : public AudioEffect {
- GDCLASS(AudioEffectReverb, AudioEffect)
+ GDCLASS(AudioEffectReverb, AudioEffect);
friend class AudioEffectReverbInstance;
diff --git a/servers/audio/effects/audio_effect_spectrum_analyzer.cpp b/servers/audio/effects/audio_effect_spectrum_analyzer.cpp
index 8e15e9288f..bb1daf04a4 100644
--- a/servers/audio/effects/audio_effect_spectrum_analyzer.cpp
+++ b/servers/audio/effects/audio_effect_spectrum_analyzer.cpp
@@ -1,3 +1,33 @@
+/*************************************************************************/
+/* audio_effect_spectrum_analyzer.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
#include "audio_effect_spectrum_analyzer.h"
#include "servers/audio_server.h"
@@ -81,9 +111,10 @@ void AudioEffectSpectrumAnalyzerInstance::process(const AudioFrame *p_src_frames
float *fftw = temporal_fft.ptrw();
for (int i = 0; i < to_fill; i++) { //left and right buffers
- fftw[(i + temporal_fft_pos) * 2] = p_src_frames[i].l;
+ float window = -0.5 * Math::cos(2.0 * Math_PI * (double)i / (double)to_fill) + 0.5;
+ fftw[(i + temporal_fft_pos) * 2] = window * p_src_frames[i].l;
fftw[(i + temporal_fft_pos) * 2 + 1] = 0;
- fftw[(i + temporal_fft_pos + fft_size * 2) * 2] = p_src_frames[i].r;
+ fftw[(i + temporal_fft_pos + fft_size * 2) * 2] = window * p_src_frames[i].r;
fftw[(i + temporal_fft_pos + fft_size * 2) * 2 + 1] = 0;
}
@@ -200,8 +231,8 @@ Ref<AudioEffectInstance> AudioEffectSpectrumAnalyzer::instance() {
return ins;
}
-void AudioEffectSpectrumAnalyzer::set_buffer_length(float p_volume) {
- buffer_length = p_volume;
+void AudioEffectSpectrumAnalyzer::set_buffer_length(float p_seconds) {
+ buffer_length = p_seconds;
}
float AudioEffectSpectrumAnalyzer::get_buffer_length() const {
diff --git a/servers/audio/effects/audio_effect_spectrum_analyzer.h b/servers/audio/effects/audio_effect_spectrum_analyzer.h
index 0534426da3..27eb88d29f 100644
--- a/servers/audio/effects/audio_effect_spectrum_analyzer.h
+++ b/servers/audio/effects/audio_effect_spectrum_analyzer.h
@@ -1,3 +1,33 @@
+/*************************************************************************/
+/* audio_effect_spectrum_analyzer.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
#ifndef AUDIO_EFFECT_SPECTRUM_ANALYZER_H
#define AUDIO_EFFECT_SPECTRUM_ANALYZER_H
@@ -6,7 +36,7 @@
class AudioEffectSpectrumAnalyzer;
class AudioEffectSpectrumAnalyzerInstance : public AudioEffectInstance {
- GDCLASS(AudioEffectSpectrumAnalyzerInstance, AudioEffectInstance)
+ GDCLASS(AudioEffectSpectrumAnalyzerInstance, AudioEffectInstance);
public:
enum MagnitudeMode {
@@ -38,7 +68,8 @@ public:
VARIANT_ENUM_CAST(AudioEffectSpectrumAnalyzerInstance::MagnitudeMode)
class AudioEffectSpectrumAnalyzer : public AudioEffect {
- GDCLASS(AudioEffectSpectrumAnalyzer, AudioEffect)
+ GDCLASS(AudioEffectSpectrumAnalyzer, AudioEffect);
+
public:
enum FFT_Size {
FFT_SIZE_256,
diff --git a/servers/audio/effects/audio_effect_stereo_enhance.h b/servers/audio/effects/audio_effect_stereo_enhance.h
index 787c351a03..44b7d3eb5c 100644
--- a/servers/audio/effects/audio_effect_stereo_enhance.h
+++ b/servers/audio/effects/audio_effect_stereo_enhance.h
@@ -36,7 +36,7 @@
class AudioEffectStereoEnhance;
class AudioEffectStereoEnhanceInstance : public AudioEffectInstance {
- GDCLASS(AudioEffectStereoEnhanceInstance, AudioEffectInstance)
+ GDCLASS(AudioEffectStereoEnhanceInstance, AudioEffectInstance);
friend class AudioEffectStereoEnhance;
Ref<AudioEffectStereoEnhance> base;
@@ -56,7 +56,7 @@ public:
};
class AudioEffectStereoEnhance : public AudioEffect {
- GDCLASS(AudioEffectStereoEnhance, AudioEffect)
+ GDCLASS(AudioEffectStereoEnhance, AudioEffect);
friend class AudioEffectStereoEnhanceInstance;
float volume_db;
diff --git a/servers/audio/effects/audio_stream_generator.cpp b/servers/audio/effects/audio_stream_generator.cpp
index f4a66b5643..49af63e82a 100644
--- a/servers/audio/effects/audio_stream_generator.cpp
+++ b/servers/audio/effects/audio_stream_generator.cpp
@@ -1,3 +1,33 @@
+/*************************************************************************/
+/* audio_stream_generator.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
#include "audio_stream_generator.h"
void AudioStreamGenerator::set_mix_rate(float p_mix_rate) {
diff --git a/servers/audio/effects/audio_stream_generator.h b/servers/audio/effects/audio_stream_generator.h
index 2082682907..33839d3db8 100644
--- a/servers/audio/effects/audio_stream_generator.h
+++ b/servers/audio/effects/audio_stream_generator.h
@@ -1,11 +1,41 @@
-#ifndef AUDIO_STREAM_USER_FED_H
-#define AUDIO_STREAM_USER_FED_H
+/*************************************************************************/
+/* audio_stream_generator.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef AUDIO_STREAM_GENERATOR_H
+#define AUDIO_STREAM_GENERATOR_H
#include "core/ring_buffer.h"
#include "servers/audio/audio_stream.h"
class AudioStreamGenerator : public AudioStream {
- GDCLASS(AudioStreamGenerator, AudioStream)
+ GDCLASS(AudioStreamGenerator, AudioStream);
float mix_rate;
float buffer_len;
@@ -29,7 +59,7 @@ public:
class AudioStreamGeneratorPlayback : public AudioStreamPlaybackResampled {
- GDCLASS(AudioStreamGeneratorPlayback, AudioStreamPlaybackResampled)
+ GDCLASS(AudioStreamGeneratorPlayback, AudioStreamPlaybackResampled);
friend class AudioStreamGenerator;
RingBuffer<AudioFrame> buffer;
int skips;
@@ -63,4 +93,4 @@ public:
AudioStreamGeneratorPlayback();
};
-#endif // AUDIO_STREAM_USER_FED_H
+#endif // AUDIO_STREAM_GENERATOR_H
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index fc3ecedd03..a6473d69c0 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -944,6 +944,15 @@ bool AudioServer::is_bus_channel_active(int p_bus, int p_channel) const {
return buses[p_bus]->channels[p_channel].active;
}
+void AudioServer::set_global_rate_scale(float p_scale) {
+
+ global_rate_scale = p_scale;
+}
+float AudioServer::get_global_rate_scale() const {
+
+ return global_rate_scale;
+}
+
void AudioServer::init_channels_and_buffers() {
channel_count = get_channel_count();
temp_buffer.resize(channel_count);
@@ -1352,6 +1361,9 @@ void AudioServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_bus_peak_volume_left_db", "bus_idx", "channel"), &AudioServer::get_bus_peak_volume_left_db);
ClassDB::bind_method(D_METHOD("get_bus_peak_volume_right_db", "bus_idx", "channel"), &AudioServer::get_bus_peak_volume_right_db);
+ ClassDB::bind_method(D_METHOD("set_global_rate_scale", "scale"), &AudioServer::set_global_rate_scale);
+ ClassDB::bind_method(D_METHOD("get_global_rate_scale"), &AudioServer::get_global_rate_scale);
+
ClassDB::bind_method(D_METHOD("lock"), &AudioServer::lock);
ClassDB::bind_method(D_METHOD("unlock"), &AudioServer::unlock);
@@ -1372,6 +1384,10 @@ void AudioServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_bus_layout", "bus_layout"), &AudioServer::set_bus_layout);
ClassDB::bind_method(D_METHOD("generate_bus_layout"), &AudioServer::generate_bus_layout);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "bus_count"), "set_bus_count", "get_bus_count");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "device"), "set_device", "get_device");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_rate_scale"), "set_global_rate_scale", "get_global_rate_scale");
+
ADD_SIGNAL(MethodInfo("bus_layout_changed"));
BIND_ENUM_CONSTANT(SPEAKER_MODE_STEREO);
@@ -1396,6 +1412,7 @@ AudioServer::AudioServer() {
#endif
mix_time = 0;
mix_size = 0;
+ global_rate_scale = 1;
}
AudioServer::~AudioServer() {
diff --git a/servers/audio_server.h b/servers/audio_server.h
index 8c0ffd5a6b..b0fff9d4b7 100644
--- a/servers/audio_server.h
+++ b/servers/audio_server.h
@@ -147,7 +147,8 @@ class AudioBusLayout;
class AudioServer : public Object {
- GDCLASS(AudioServer, Object)
+ GDCLASS(AudioServer, Object);
+
public:
//re-expose this here, as AudioDriver is not exposed to script
enum SpeakerMode {
@@ -180,6 +181,8 @@ private:
int channel_count;
int to_mix;
+ float global_rate_scale;
+
struct Bus {
StringName name;
@@ -338,6 +341,9 @@ public:
bool is_bus_channel_active(int p_bus, int p_channel) const;
+ void set_global_rate_scale(float p_scale);
+ float get_global_rate_scale() const;
+
virtual void init();
virtual void finish();
virtual void update();
@@ -390,7 +396,7 @@ VARIANT_ENUM_CAST(AudioServer::SpeakerMode)
class AudioBusLayout : public Resource {
- GDCLASS(AudioBusLayout, Resource)
+ GDCLASS(AudioBusLayout, Resource);
friend class AudioServer;
diff --git a/servers/camera/SCsub b/servers/camera/SCsub
new file mode 100644
index 0000000000..ccc76e823f
--- /dev/null
+++ b/servers/camera/SCsub
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+
+Import('env')
+
+env.add_source_files(env.servers_sources, "*.cpp")
+
+Export('env')
diff --git a/servers/camera/camera_feed.cpp b/servers/camera/camera_feed.cpp
new file mode 100644
index 0000000000..094c83cd7c
--- /dev/null
+++ b/servers/camera/camera_feed.cpp
@@ -0,0 +1,266 @@
+/*************************************************************************/
+/* camera_feed.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "camera_feed.h"
+#include "servers/visual_server.h"
+
+void CameraFeed::_bind_methods() {
+ // The setters prefixed with _ are only exposed so we can have feeds through GDNative!
+ // They should not be called by the end user.
+
+ ClassDB::bind_method(D_METHOD("get_id"), &CameraFeed::get_id);
+ ClassDB::bind_method(D_METHOD("get_name"), &CameraFeed::get_name);
+ ClassDB::bind_method(D_METHOD("_set_name", "name"), &CameraFeed::set_name);
+
+ ClassDB::bind_method(D_METHOD("is_active"), &CameraFeed::is_active);
+ ClassDB::bind_method(D_METHOD("set_active", "active"), &CameraFeed::set_active);
+
+ ClassDB::bind_method(D_METHOD("get_position"), &CameraFeed::get_position);
+ ClassDB::bind_method(D_METHOD("_set_position", "position"), &CameraFeed::set_position);
+
+ // Note, for transform some feeds may override what the user sets (such as ARKit)
+ ClassDB::bind_method(D_METHOD("get_transform"), &CameraFeed::get_transform);
+ ClassDB::bind_method(D_METHOD("set_transform", "transform"), &CameraFeed::set_transform);
+
+ ClassDB::bind_method(D_METHOD("_set_RGB_img", "rgb_img"), &CameraFeed::set_RGB_img);
+ ClassDB::bind_method(D_METHOD("_set_YCbCr_img", "ycbcr_img"), &CameraFeed::set_YCbCr_img);
+ ClassDB::bind_method(D_METHOD("_set_YCbCr_imgs", "y_img", "cbcr_img"), &CameraFeed::set_YCbCr_imgs);
+ ClassDB::bind_method(D_METHOD("_allocate_texture", "width", "height", "format", "texture_type", "data_type"), &CameraFeed::allocate_texture);
+
+ ADD_GROUP("Feed", "feed_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "feed_is_active"), "set_active", "is_active");
+ ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "feed_transform"), "set_transform", "get_transform");
+
+ BIND_ENUM_CONSTANT(FEED_NOIMAGE);
+ BIND_ENUM_CONSTANT(FEED_RGB);
+ BIND_ENUM_CONSTANT(FEED_YCBCR);
+ BIND_ENUM_CONSTANT(FEED_YCBCR_SEP);
+
+ BIND_ENUM_CONSTANT(FEED_UNSPECIFIED);
+ BIND_ENUM_CONSTANT(FEED_FRONT);
+ BIND_ENUM_CONSTANT(FEED_BACK);
+}
+
+int CameraFeed::get_id() const {
+ return id;
+}
+
+bool CameraFeed::is_active() const {
+ return active;
+}
+
+void CameraFeed::set_active(bool p_is_active) {
+ if (p_is_active == active) {
+ // all good
+ } else if (p_is_active) {
+ // attempt to activate this feed
+ if (activate_feed()) {
+ print_line("Activate " + name);
+ active = true;
+ }
+ } else {
+ // just deactivate it
+ deactivate_feed();
+ print_line("Deactivate " + name);
+ active = false;
+ }
+}
+
+String CameraFeed::get_name() const {
+ return name;
+}
+
+void CameraFeed::set_name(String p_name) {
+ name = p_name;
+}
+
+int CameraFeed::get_base_width() const {
+ return base_width;
+}
+
+int CameraFeed::get_base_height() const {
+ return base_height;
+}
+
+CameraFeed::FeedDataType CameraFeed::get_datatype() const {
+ return datatype;
+}
+
+CameraFeed::FeedPosition CameraFeed::get_position() const {
+ return position;
+}
+
+void CameraFeed::set_position(CameraFeed::FeedPosition p_position) {
+ position = p_position;
+}
+
+Transform2D CameraFeed::get_transform() const {
+ return transform;
+}
+
+void CameraFeed::set_transform(const Transform2D &p_transform) {
+ transform = p_transform;
+}
+
+RID CameraFeed::get_texture(CameraServer::FeedImage p_which) {
+ return texture[p_which];
+}
+
+CameraFeed::CameraFeed() {
+ // initialize our feed
+ id = CameraServer::get_singleton()->get_free_id();
+ name = "???";
+ active = false;
+ datatype = CameraFeed::FEED_RGB;
+ position = CameraFeed::FEED_UNSPECIFIED;
+ transform = Transform2D(1.0, 0.0, 0.0, -1.0, 0.0, 1.0);
+
+ // create a texture object
+ VisualServer *vs = VisualServer::get_singleton();
+ texture[CameraServer::FEED_Y_IMAGE] = vs->texture_create(); // also used for RGBA
+ texture[CameraServer::FEED_CBCR_IMAGE] = vs->texture_create();
+}
+
+CameraFeed::CameraFeed(String p_name, FeedPosition p_position) {
+ // initialize our feed
+ id = CameraServer::get_singleton()->get_free_id();
+ base_width = 0;
+ base_height = 0;
+ name = p_name;
+ active = false;
+ datatype = CameraFeed::FEED_NOIMAGE;
+ position = p_position;
+ transform = Transform2D(1.0, 0.0, 0.0, -1.0, 0.0, 1.0);
+
+ // create a texture object
+ VisualServer *vs = VisualServer::get_singleton();
+ texture[CameraServer::FEED_Y_IMAGE] = vs->texture_create(); // also used for RGBA
+ texture[CameraServer::FEED_CBCR_IMAGE] = vs->texture_create();
+}
+
+CameraFeed::~CameraFeed() {
+ // Free our textures
+ VisualServer *vs = VisualServer::get_singleton();
+ vs->free(texture[CameraServer::FEED_Y_IMAGE]);
+ vs->free(texture[CameraServer::FEED_CBCR_IMAGE]);
+}
+
+void CameraFeed::set_RGB_img(Ref<Image> p_rgb_img) {
+ if (active) {
+ VisualServer *vs = VisualServer::get_singleton();
+
+ int new_width = p_rgb_img->get_width();
+ int new_height = p_rgb_img->get_height();
+
+ if ((base_width != new_width) || (base_height != new_height)) {
+ // We're assuming here that our camera image doesn't change around formats etc, allocate the whole lot...
+ base_width = new_width;
+ base_height = new_height;
+
+ vs->texture_allocate(texture[CameraServer::FEED_RGBA_IMAGE], new_width, new_height, 0, Image::FORMAT_RGB8, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAGS_DEFAULT);
+ }
+
+ vs->texture_set_data(texture[CameraServer::FEED_RGBA_IMAGE], p_rgb_img);
+ datatype = CameraFeed::FEED_RGB;
+ }
+}
+
+void CameraFeed::set_YCbCr_img(Ref<Image> p_ycbcr_img) {
+ if (active) {
+ VisualServer *vs = VisualServer::get_singleton();
+
+ int new_width = p_ycbcr_img->get_width();
+ int new_height = p_ycbcr_img->get_height();
+
+ if ((base_width != new_width) || (base_height != new_height)) {
+ // We're assuming here that our camera image doesn't change around formats etc, allocate the whole lot...
+ base_width = new_width;
+ base_height = new_height;
+
+ vs->texture_allocate(texture[CameraServer::FEED_RGBA_IMAGE], new_width, new_height, 0, Image::FORMAT_RGB8, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAGS_DEFAULT);
+ }
+
+ vs->texture_set_data(texture[CameraServer::FEED_RGBA_IMAGE], p_ycbcr_img);
+ datatype = CameraFeed::FEED_YCBCR;
+ }
+}
+
+void CameraFeed::set_YCbCr_imgs(Ref<Image> p_y_img, Ref<Image> p_cbcr_img) {
+ if (active) {
+ VisualServer *vs = VisualServer::get_singleton();
+
+ ///@TODO investigate whether we can use thirdparty/misc/yuv2rgb.h here to convert our YUV data to RGB, our shader approach is potentially faster though..
+ // Wondering about including that into multiple projects, may cause issues.
+ // That said, if we convert to RGB, we could enable using texture resources again...
+
+ int new_y_width = p_y_img->get_width();
+ int new_y_height = p_y_img->get_height();
+ int new_cbcr_width = p_cbcr_img->get_width();
+ int new_cbcr_height = p_cbcr_img->get_height();
+
+ if ((base_width != new_y_width) || (base_height != new_y_height)) {
+ // We're assuming here that our camera image doesn't change around formats etc, allocate the whole lot...
+ base_width = new_y_width;
+ base_height = new_y_height;
+
+ vs->texture_allocate(texture[CameraServer::FEED_Y_IMAGE], new_y_width, new_y_height, 0, Image::FORMAT_R8, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_USED_FOR_STREAMING);
+
+ ///@TODO GLES2 doesn't support FORMAT_RG8, need to do some form of conversion
+ vs->texture_allocate(texture[CameraServer::FEED_CBCR_IMAGE], new_cbcr_width, new_cbcr_height, 0, Image::FORMAT_RG8, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_USED_FOR_STREAMING);
+ }
+
+ vs->texture_set_data(texture[CameraServer::FEED_Y_IMAGE], p_y_img);
+ vs->texture_set_data(texture[CameraServer::FEED_CBCR_IMAGE], p_cbcr_img);
+ datatype = CameraFeed::FEED_YCBCR_SEP;
+ }
+}
+
+void CameraFeed::allocate_texture(int p_width, int p_height, Image::Format p_format, VisualServer::TextureType p_texture_type, FeedDataType p_data_type) {
+ VisualServer *vs = VisualServer::get_singleton();
+
+ if ((base_width != p_width) || (base_height != p_height)) {
+ // We're assuming here that our camera image doesn't change around formats etc, allocate the whole lot...
+ base_width = p_width;
+ base_height = p_height;
+
+ vs->texture_allocate(texture[0], p_width, p_height, 0, p_format, p_texture_type, VS::TEXTURE_FLAGS_DEFAULT);
+ }
+
+ datatype = p_data_type;
+}
+
+bool CameraFeed::activate_feed() {
+ // nothing to do here
+ return true;
+}
+
+void CameraFeed::deactivate_feed() {
+ // nothing to do here
+}
diff --git a/servers/camera/camera_feed.h b/servers/camera/camera_feed.h
new file mode 100644
index 0000000000..0c53ff9309
--- /dev/null
+++ b/servers/camera/camera_feed.h
@@ -0,0 +1,115 @@
+/*************************************************************************/
+/* camera_feed.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef CAMERA_FEED_H
+#define CAMERA_FEED_H
+
+#include "core/image.h"
+#include "core/math/transform_2d.h"
+#include "servers/camera_server.h"
+#include "servers/visual_server.h"
+
+/**
+ @author Bastiaan Olij <mux213@gmail.com>
+
+ The camera server is a singleton object that gives access to the various
+ camera feeds that can be used as the background for our environment.
+**/
+
+class CameraFeed : public Reference {
+ GDCLASS(CameraFeed, Reference);
+
+public:
+ enum FeedDataType {
+ FEED_NOIMAGE, // we don't have an image yet
+ FEED_RGB, // our texture will contain a normal RGB texture that can be used directly
+ FEED_YCBCR, // our texture will contain a YCbCr texture that needs to be converted to RGB before output
+ FEED_YCBCR_SEP // our camera is split into two textures, first plane contains Y data, second plane contains CbCr data
+ };
+
+ enum FeedPosition {
+ FEED_UNSPECIFIED, // we have no idea
+ FEED_FRONT, // this is a camera on the front of the device
+ FEED_BACK // this is a camera on the back of the device
+ };
+
+private:
+ int id; // unique id for this, for internal use in case feeds are removed
+ int base_width;
+ int base_height;
+
+protected:
+ String name; // name of our camera feed
+ FeedDataType datatype; // type of texture data stored
+ FeedPosition position; // position of camera on the device
+ Transform2D transform; // display transform
+
+ bool active; // only when active do we actually update the camera texture each frame
+ RID texture[CameraServer::FEED_IMAGES]; // texture images needed for this
+
+ static void _bind_methods();
+
+public:
+ int get_id() const;
+ bool is_active() const;
+ void set_active(bool p_is_active);
+
+ String get_name() const;
+ void set_name(String p_name);
+
+ int get_base_width() const;
+ int get_base_height() const;
+
+ FeedPosition get_position() const;
+ void set_position(FeedPosition p_position);
+
+ Transform2D get_transform() const;
+ void set_transform(const Transform2D &p_transform);
+
+ RID get_texture(CameraServer::FeedImage p_which);
+
+ CameraFeed();
+ CameraFeed(String p_name, FeedPosition p_position = CameraFeed::FEED_UNSPECIFIED);
+ virtual ~CameraFeed();
+
+ FeedDataType get_datatype() const;
+ void set_RGB_img(Ref<Image> p_rgb_img);
+ void set_YCbCr_img(Ref<Image> p_ycbcr_img);
+ void set_YCbCr_imgs(Ref<Image> p_y_img, Ref<Image> p_cbcr_img);
+ void allocate_texture(int p_width, int p_height, Image::Format p_format, VisualServer::TextureType p_texture_type, FeedDataType p_data_type);
+
+ virtual bool activate_feed();
+ virtual void deactivate_feed();
+};
+
+VARIANT_ENUM_CAST(CameraFeed::FeedDataType);
+VARIANT_ENUM_CAST(CameraFeed::FeedPosition);
+
+#endif /* !CAMERA_FEED_H */
diff --git a/servers/camera_server.cpp b/servers/camera_server.cpp
new file mode 100644
index 0000000000..0f93221072
--- /dev/null
+++ b/servers/camera_server.cpp
@@ -0,0 +1,169 @@
+/*************************************************************************/
+/* camera_server.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "camera_server.h"
+#include "servers/camera/camera_feed.h"
+#include "visual_server.h"
+
+////////////////////////////////////////////////////////
+// CameraServer
+
+void CameraServer::_bind_methods() {
+ 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);
+
+ ClassDB::bind_method(D_METHOD("add_feed", "feed"), &CameraServer::add_feed);
+ ClassDB::bind_method(D_METHOD("remove_feed", "feed"), &CameraServer::remove_feed);
+
+ ADD_SIGNAL(MethodInfo("camera_feed_added", PropertyInfo(Variant::INT, "id")));
+ ADD_SIGNAL(MethodInfo("camera_feed_removed", PropertyInfo(Variant::INT, "id")));
+
+ BIND_ENUM_CONSTANT(FEED_RGBA_IMAGE);
+ BIND_ENUM_CONSTANT(FEED_YCBCR_IMAGE);
+ BIND_ENUM_CONSTANT(FEED_Y_IMAGE);
+ BIND_ENUM_CONSTANT(FEED_CBCR_IMAGE);
+};
+
+CameraServer *CameraServer::singleton = NULL;
+
+CameraServer *CameraServer::get_singleton() {
+ return singleton;
+};
+
+int CameraServer::get_free_id() {
+ bool id_exists = true;
+ int newid = 0;
+
+ // find a free id
+ while (id_exists) {
+ newid++;
+ id_exists = false;
+ for (int i = 0; i < feeds.size() && !id_exists; i++) {
+ if (feeds[i]->get_id() == newid) {
+ id_exists = true;
+ };
+ };
+ };
+
+ return newid;
+};
+
+int CameraServer::get_feed_index(int p_id) {
+ for (int i = 0; i < feeds.size(); i++) {
+ if (feeds[i]->get_id() == p_id) {
+ return i;
+ };
+ };
+
+ return -1;
+};
+
+Ref<CameraFeed> CameraServer::get_feed_by_id(int p_id) {
+ int index = get_feed_index(p_id);
+
+ if (index == -1) {
+ return NULL;
+ } else {
+ return feeds[index];
+ }
+};
+
+void CameraServer::add_feed(const Ref<CameraFeed> &p_feed) {
+ // add our feed
+ feeds.push_back(p_feed);
+
+// record for debugging
+#ifdef DEBUG_ENABLED
+ print_line("Registered camera " + p_feed->get_name() + " with id " + itos(p_feed->get_id()) + " position " + itos(p_feed->get_position()) + " at index " + itos(feeds.size() - 1));
+#endif
+
+ // let whomever is interested know
+ emit_signal("camera_feed_added", p_feed->get_id());
+};
+
+void CameraServer::remove_feed(const Ref<CameraFeed> &p_feed) {
+ for (int i = 0; i < feeds.size(); i++) {
+ if (feeds[i] == p_feed) {
+ int feed_id = p_feed->get_id();
+
+// record for debugging
+#ifdef DEBUG_ENABLED
+ print_line("Removed camera " + p_feed->get_name() + " with id " + itos(feed_id) + " position " + itos(p_feed->get_position()));
+#endif
+
+ // remove it from our array, if this results in our feed being unreferenced it will be destroyed
+ feeds.remove(i);
+
+ // let whomever is interested know
+ emit_signal("camera_feed_removed", feed_id);
+ return;
+ };
+ };
+};
+
+Ref<CameraFeed> CameraServer::get_feed(int p_index) {
+ ERR_FAIL_INDEX_V(p_index, feeds.size(), NULL);
+
+ return feeds[p_index];
+};
+
+int CameraServer::get_feed_count() {
+ return feeds.size();
+};
+
+Array CameraServer::get_feeds() {
+ Array return_feeds;
+ int cc = get_feed_count();
+ return_feeds.resize(cc);
+
+ for (int i = 0; i < feeds.size(); i++) {
+ return_feeds[i] = get_feed(i);
+ };
+
+ return return_feeds;
+};
+
+RID CameraServer::feed_texture(int p_id, CameraServer::FeedImage p_texture) {
+ int index = get_feed_index(p_id);
+ ERR_FAIL_COND_V(index == -1, RID());
+
+ Ref<CameraFeed> feed = get_feed(index);
+
+ return feed->get_texture(p_texture);
+};
+
+CameraServer::CameraServer() {
+ singleton = this;
+};
+
+CameraServer::~CameraServer() {
+ singleton = NULL;
+};
diff --git a/servers/camera_server.h b/servers/camera_server.h
new file mode 100644
index 0000000000..5a62af3d60
--- /dev/null
+++ b/servers/camera_server.h
@@ -0,0 +1,96 @@
+/*************************************************************************/
+/* camera_server.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef CAMERA_SERVER_H
+#define CAMERA_SERVER_H
+
+#include "core/object.h"
+#include "core/os/thread_safe.h"
+#include "core/reference.h"
+#include "core/rid.h"
+#include "core/variant.h"
+
+/**
+ @author Bastiaan Olij <mux213@gmail.com>
+
+ The camera server is a singleton object that gives access to the various
+ camera feeds that can be used as the background for our environment.
+**/
+
+class CameraFeed;
+
+class CameraServer : public Object {
+ GDCLASS(CameraServer, Object);
+ _THREAD_SAFE_CLASS_
+
+public:
+ enum FeedImage {
+ FEED_RGBA_IMAGE = 0,
+ FEED_YCBCR_IMAGE = 0,
+ FEED_Y_IMAGE = 0,
+ FEED_CBCR_IMAGE = 1,
+ FEED_IMAGES = 2
+ };
+
+private:
+protected:
+ Vector<Ref<CameraFeed> > feeds;
+
+ static CameraServer *singleton;
+
+ static void _bind_methods();
+
+public:
+ static CameraServer *get_singleton();
+
+ // 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();
+ int get_feed_index(int p_id);
+ Ref<CameraFeed> get_feed_by_id(int p_id);
+
+ // add and remove feeds
+ void add_feed(const Ref<CameraFeed> &p_feed);
+ void remove_feed(const Ref<CameraFeed> &p_feed);
+
+ // get our feeds
+ Ref<CameraFeed> get_feed(int p_idx);
+ int get_feed_count();
+ Array get_feeds();
+
+ RID feed_texture(int p_id, FeedImage p_texture);
+
+ CameraServer();
+ ~CameraServer();
+};
+
+VARIANT_ENUM_CAST(CameraServer::FeedImage);
+
+#endif /* CAMERA_SERVER_H */
diff --git a/servers/physics/area_sw.cpp b/servers/physics/area_sw.cpp
index 9d68869bc2..ad3e40916d 100644
--- a/servers/physics/area_sw.cpp
+++ b/servers/physics/area_sw.cpp
@@ -250,7 +250,7 @@ AreaSW::AreaSW() :
gravity_is_point = false;
gravity_distance_scale = 0;
point_attenuation = 1;
- angular_damp = 1.0;
+ angular_damp = 0.1;
linear_damp = 0.1;
priority = 0;
set_ray_pickable(false);
diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp
index b4c3670a7b..172a2a3429 100644
--- a/servers/physics/body_sw.cpp
+++ b/servers/physics/body_sw.cpp
@@ -346,8 +346,7 @@ void BodySW::set_state(PhysicsServer::BodyState p_state, const Variant &p_varian
//biased_angular_velocity=Vector3();
set_active(false);
} else {
- if (mode != PhysicsServer::BODY_MODE_STATIC)
- set_active(true);
+ set_active(true);
}
} break;
case PhysicsServer::BODY_STATE_CAN_SLEEP: {
diff --git a/servers/physics/broad_phase_octree.cpp b/servers/physics/broad_phase_octree.cpp
index 94bf274f9c..1b59779bd6 100644
--- a/servers/physics/broad_phase_octree.cpp
+++ b/servers/physics/broad_phase_octree.cpp
@@ -45,7 +45,7 @@ void BroadPhaseOctree::move(ID p_id, const AABB &p_aabb) {
void BroadPhaseOctree::set_static(ID p_id, bool p_static) {
CollisionObjectSW *it = octree.get(p_id);
- octree.set_pairable(p_id, p_static ? false : true, 1 << it->get_type(), p_static ? 0 : 0xFFFFF); //pair everything, don't care 1?
+ octree.set_pairable(p_id, !p_static, 1 << it->get_type(), p_static ? 0 : 0xFFFFF); //pair everything, don't care 1?
}
void BroadPhaseOctree::remove(ID p_id) {
diff --git a/servers/physics/collision_object_sw.cpp b/servers/physics/collision_object_sw.cpp
index b1c21290ab..39de440da2 100644
--- a/servers/physics/collision_object_sw.cpp
+++ b/servers/physics/collision_object_sw.cpp
@@ -76,6 +76,13 @@ void CollisionObjectSW::set_shape_transform(int p_index, const Transform &p_tran
//_shapes_changed();
}
+void CollisionObjectSW::set_shape_as_disabled(int p_idx, bool p_enable) {
+ shapes.write[p_idx].disabled = p_enable;
+ if (!pending_shape_update_list.in_list()) {
+ PhysicsServerSW::singleton->pending_shape_update_list.add(&pending_shape_update_list);
+ }
+}
+
void CollisionObjectSW::remove_shape(ShapeSW *p_shape) {
//remove a shape, all the times it appears
diff --git a/servers/physics/collision_object_sw.h b/servers/physics/collision_object_sw.h
index c2c3fe0e5a..895eda8528 100644
--- a/servers/physics/collision_object_sw.h
+++ b/servers/physics/collision_object_sw.h
@@ -139,8 +139,11 @@ public:
_FORCE_INLINE_ void set_ray_pickable(bool p_enable) { ray_pickable = p_enable; }
_FORCE_INLINE_ bool is_ray_pickable() const { return ray_pickable; }
- _FORCE_INLINE_ void set_shape_as_disabled(int p_idx, bool p_enable) { shapes.write[p_idx].disabled = p_enable; }
- _FORCE_INLINE_ bool is_shape_set_as_disabled(int p_idx) const { return shapes[p_idx].disabled; }
+ void set_shape_as_disabled(int p_idx, bool p_enable);
+ _FORCE_INLINE_ bool is_shape_set_as_disabled(int p_idx) const {
+ CRASH_BAD_INDEX(p_idx, shapes.size());
+ return shapes[p_idx].disabled;
+ }
_FORCE_INLINE_ void set_collision_layer(uint32_t p_layer) { collision_layer = p_layer; }
_FORCE_INLINE_ uint32_t get_collision_layer() const { return collision_layer; }
diff --git a/servers/physics/collision_solver_sat.cpp b/servers/physics/collision_solver_sat.cpp
index 3073cc8b11..a13fa65009 100644
--- a/servers/physics/collision_solver_sat.cpp
+++ b/servers/physics/collision_solver_sat.cpp
@@ -538,8 +538,6 @@ static void _collision_sphere_capsule(const ShapeSW *p_a, const Transform &p_tra
template <bool withMargin>
static void _collision_sphere_cylinder(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
- return;
}
template <bool withMargin>
@@ -835,8 +833,6 @@ static void _collision_box_capsule(const ShapeSW *p_a, const Transform &p_transf
template <bool withMargin>
static void _collision_box_cylinder(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
- return;
}
template <bool withMargin>
@@ -1117,8 +1113,6 @@ static void _collision_capsule_capsule(const ShapeSW *p_a, const Transform &p_tr
template <bool withMargin>
static void _collision_capsule_cylinder(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
- return;
}
template <bool withMargin>
@@ -1243,20 +1237,14 @@ static void _collision_capsule_face(const ShapeSW *p_a, const Transform &p_trans
template <bool withMargin>
static void _collision_cylinder_cylinder(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
- return;
}
template <bool withMargin>
static void _collision_cylinder_convex_polygon(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
- return;
}
template <bool withMargin>
static void _collision_cylinder_face(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
- return;
}
template <bool withMargin>
diff --git a/servers/physics/gjk_epa.cpp b/servers/physics/gjk_epa.cpp
index ae512183fd..1d5ca42838 100644
--- a/servers/physics/gjk_epa.cpp
+++ b/servers/physics/gjk_epa.cpp
@@ -722,7 +722,10 @@ struct GJK
append(m_stock,face);
return(0);
}
- m_status=m_stock.root?eStatus::OutOfVertices:eStatus::OutOfFaces;
+ // -- GODOT start --
+ //m_status=m_stock.root?eStatus::OutOfVertices:eStatus::OutOfFaces;
+ m_status=eStatus::OutOfFaces;
+ // -- GODOT end --
return(0);
}
sFace* findbest()
diff --git a/servers/physics/joints/generic_6dof_joint_sw.cpp b/servers/physics/joints/generic_6dof_joint_sw.cpp
index 813d9b7704..a9fe045856 100644
--- a/servers/physics/joints/generic_6dof_joint_sw.cpp
+++ b/servers/physics/joints/generic_6dof_joint_sw.cpp
@@ -421,7 +421,6 @@ void Generic6DOFJointSW::calcAnchorPos(void) {
const Vector3 &pA = m_calculatedTransformA.origin;
const Vector3 &pB = m_calculatedTransformB.origin;
m_AnchorPos = pA * weight + pB * (real_t(1.0) - weight);
- return;
} // Generic6DOFJointSW::calcAnchorPos()
void Generic6DOFJointSW::set_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param, real_t p_value) {
diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp
index 8b9f210850..f3a4cbed24 100644
--- a/servers/physics/space_sw.cpp
+++ b/servers/physics/space_sw.cpp
@@ -118,7 +118,7 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vecto
if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas))
continue;
- if (p_pick_ray && !(static_cast<CollisionObjectSW *>(space->intersection_query_results[i])->is_ray_pickable()))
+ if (p_pick_ray && !(space->intersection_query_results[i]->is_ray_pickable()))
continue;
if (p_exclude.has(space->intersection_query_results[i]->get_self()))
@@ -439,7 +439,7 @@ bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_
continue;
}
- if (rcd.best_len == 0)
+ if (rcd.best_len == 0 || !rcd.best_object)
return false;
r_info->collider_id = rcd.best_object->get_instance_id();
diff --git a/servers/physics_2d/collision_object_2d_sw.cpp b/servers/physics_2d/collision_object_2d_sw.cpp
index 445a2e0613..f556638db1 100644
--- a/servers/physics_2d/collision_object_2d_sw.cpp
+++ b/servers/physics_2d/collision_object_2d_sw.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "collision_object_2d_sw.h"
+#include "servers/physics_2d/physics_2d_server_sw.h"
#include "space_2d_sw.h"
void CollisionObject2DSW::add_shape(Shape2DSW *p_shape, const Transform2D &p_transform, bool p_disabled) {
@@ -43,8 +44,12 @@ void CollisionObject2DSW::add_shape(Shape2DSW *p_shape, const Transform2D &p_tra
s.one_way_collision_margin = 0;
shapes.push_back(s);
p_shape->add_owner(this);
- _update_shapes();
- _shapes_changed();
+
+ if (!pending_shape_update_list.in_list()) {
+ Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
+ }
+ // _update_shapes();
+ // _shapes_changed();
}
void CollisionObject2DSW::set_shape(int p_index, Shape2DSW *p_shape) {
@@ -54,8 +59,12 @@ void CollisionObject2DSW::set_shape(int p_index, Shape2DSW *p_shape) {
shapes.write[p_index].shape = p_shape;
p_shape->add_owner(this);
- _update_shapes();
- _shapes_changed();
+
+ if (!pending_shape_update_list.in_list()) {
+ Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
+ }
+ // _update_shapes();
+ // _shapes_changed();
}
void CollisionObject2DSW::set_shape_metadata(int p_index, const Variant &p_metadata) {
@@ -70,8 +79,12 @@ void CollisionObject2DSW::set_shape_transform(int p_index, const Transform2D &p_
shapes.write[p_index].xform = p_transform;
shapes.write[p_index].xform_inv = p_transform.affine_inverse();
- _update_shapes();
- _shapes_changed();
+
+ if (!pending_shape_update_list.in_list()) {
+ Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
+ }
+ // _update_shapes();
+ // _shapes_changed();
}
void CollisionObject2DSW::set_shape_as_disabled(int p_idx, bool p_disabled) {
@@ -89,9 +102,15 @@ void CollisionObject2DSW::set_shape_as_disabled(int p_idx, bool p_disabled) {
if (p_disabled && shape.bpid != 0) {
space->get_broadphase()->remove(shape.bpid);
shape.bpid = 0;
- _update_shapes();
+ if (!pending_shape_update_list.in_list()) {
+ Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
+ }
+ //_update_shapes();
} else if (!p_disabled && shape.bpid == 0) {
- _update_shapes(); // automatically adds shape with bpid == 0
+ if (!pending_shape_update_list.in_list()) {
+ Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
+ }
+ //_update_shapes(); // automatically adds shape with bpid == 0
}
}
@@ -122,8 +141,11 @@ void CollisionObject2DSW::remove_shape(int p_index) {
shapes[p_index].shape->remove_owner(this);
shapes.remove(p_index);
- _update_shapes();
- _shapes_changed();
+ if (!pending_shape_update_list.in_list()) {
+ Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
+ }
+ // _update_shapes();
+ // _shapes_changed();
}
void CollisionObject2DSW::_set_static(bool p_static) {
@@ -239,7 +261,8 @@ void CollisionObject2DSW::_shape_changed() {
_shapes_changed();
}
-CollisionObject2DSW::CollisionObject2DSW(Type p_type) {
+CollisionObject2DSW::CollisionObject2DSW(Type p_type) :
+ pending_shape_update_list(this) {
_static = true;
type = p_type;
diff --git a/servers/physics_2d/collision_object_2d_sw.h b/servers/physics_2d/collision_object_2d_sw.h
index fa18e61262..ed59469878 100644
--- a/servers/physics_2d/collision_object_2d_sw.h
+++ b/servers/physics_2d/collision_object_2d_sw.h
@@ -78,6 +78,8 @@ private:
uint32_t collision_layer;
bool _static;
+ SelfList<CollisionObject2DSW> pending_shape_update_list;
+
void _update_shapes();
protected:
diff --git a/servers/physics_2d/joints_2d_sw.cpp b/servers/physics_2d/joints_2d_sw.cpp
index 954b0fa3ea..acdaa6e6df 100644
--- a/servers/physics_2d/joints_2d_sw.cpp
+++ b/servers/physics_2d/joints_2d_sw.cpp
@@ -92,7 +92,7 @@ normal_relative_velocity(Body2DSW *a, Body2DSW *b, Vector2 rA, Vector2 rB, Vecto
bool PinJoint2DSW::setup(real_t p_step) {
Space2DSW *space = A->get_space();
- ERR_FAIL_COND_V(!space, false;)
+ ERR_FAIL_COND_V(!space, false);
rA = A->get_transform().basis_xform(anchor_A);
rB = B ? B->get_transform().basis_xform(anchor_B) : anchor_B;
diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp
index 0efa15d43e..cc656d3b73 100644
--- a/servers/physics_2d/physics_2d_server_sw.cpp
+++ b/servers/physics_2d/physics_2d_server_sw.cpp
@@ -902,6 +902,8 @@ void Physics2DServerSW::body_apply_torque_impulse(RID p_body, real_t p_torque) {
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
+ _update_shapes();
+
body->apply_torque_impulse(p_torque);
}
@@ -910,6 +912,8 @@ void Physics2DServerSW::body_apply_impulse(RID p_body, const Vector2 &p_pos, con
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
+ _update_shapes();
+
body->apply_impulse(p_pos, p_impulse);
body->wakeup();
};
@@ -944,6 +948,8 @@ void Physics2DServerSW::body_set_axis_velocity(RID p_body, const Vector2 &p_axis
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
+ _update_shapes();
+
Vector2 v = body->get_linear_velocity();
Vector2 axis = p_axis_velocity.normalized();
v -= axis * axis.dot(v);
@@ -1052,6 +1058,8 @@ bool Physics2DServerSW::body_test_motion(RID p_body, const Transform2D &p_from,
ERR_FAIL_COND_V(!body->get_space(), false);
ERR_FAIL_COND_V(body->get_space()->is_locked(), false);
+ _update_shapes();
+
return body->get_space()->test_body_motion(body, p_from, p_motion, p_infinite_inertia, p_margin, r_result, p_exclude_raycast_shapes);
}
@@ -1238,6 +1246,8 @@ Physics2DServer::JointType Physics2DServerSW::joint_get_type(RID p_joint) const
void Physics2DServerSW::free(RID p_rid) {
+ _update_shapes(); // just in case
+
if (shape_owner.owns(p_rid)) {
Shape2DSW *shape = shape_owner.get(p_rid);
@@ -1335,6 +1345,8 @@ void Physics2DServerSW::step(real_t p_step) {
if (!active)
return;
+ _update_shapes();
+
doing_sync = false;
last_step = p_step;
@@ -1418,6 +1430,14 @@ void Physics2DServerSW::finish() {
memdelete(direct_state);
};
+void Physics2DServerSW::_update_shapes() {
+
+ while (pending_shape_update_list.first()) {
+ pending_shape_update_list.first()->self()->_shape_changed();
+ pending_shape_update_list.remove(pending_shape_update_list.first());
+ }
+}
+
int Physics2DServerSW::get_process_info(ProcessInfo p_info) {
switch (p_info) {
diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h
index adc011af40..72625c397c 100644
--- a/servers/physics_2d/physics_2d_server_sw.h
+++ b/servers/physics_2d/physics_2d_server_sw.h
@@ -70,6 +70,9 @@ class Physics2DServerSW : public Physics2DServer {
static Physics2DServerSW *singletonsw;
//void _clear_query(Query2DSW *p_query);
+ friend class CollisionObject2DSW;
+ SelfList<CollisionObject2DSW>::List pending_shape_update_list;
+ void _update_shapes();
RID _shape_create(ShapeType p_shape);
diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp
index e2b1bb9da4..7c89c43f36 100644
--- a/servers/physics_2d/space_2d_sw.cpp
+++ b/servers/physics_2d/space_2d_sw.cpp
@@ -442,7 +442,7 @@ bool Physics2DDirectSpaceStateSW::rest_info(RID p_shape, const Transform2D &p_sh
continue;
}
- if (rcd.best_len == 0)
+ if (rcd.best_len == 0 || !rcd.best_object)
return false;
r_info->collider_id = rcd.best_object->get_instance_id();
diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp
index f3394019f5..f7cec6a378 100644
--- a/servers/register_server_types.cpp
+++ b/servers/register_server_types.cpp
@@ -54,6 +54,8 @@
#include "audio/effects/audio_effect_stereo_enhance.h"
#include "audio/effects/audio_stream_generator.h"
#include "audio_server.h"
+#include "camera/camera_feed.h"
+#include "camera_server.h"
#include "core/script_debugger_remote.h"
#include "physics/physics_server_sw.h"
#include "physics_2d/physics_2d_server_sw.h"
@@ -114,6 +116,7 @@ void register_server_types() {
ClassDB::register_virtual_class<PhysicsServer>();
ClassDB::register_virtual_class<Physics2DServer>();
ClassDB::register_class<ARVRServer>();
+ ClassDB::register_class<CameraServer>();
shader_types = memnew(ShaderTypes);
@@ -169,6 +172,8 @@ void register_server_types() {
ClassDB::register_virtual_class<AudioEffectSpectrumAnalyzerInstance>();
}
+ ClassDB::register_class<CameraFeed>();
+
ClassDB::register_virtual_class<Physics2DDirectBodyState>();
ClassDB::register_virtual_class<Physics2DDirectSpaceState>();
ClassDB::register_virtual_class<Physics2DShapeQueryResult>();
@@ -208,4 +213,5 @@ void register_server_singletons() {
Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer", PhysicsServer::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("Physics2DServer", Physics2DServer::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("ARVRServer", ARVRServer::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("CameraServer", CameraServer::get_singleton()));
}
diff --git a/servers/server_wrap_mt_common.h b/servers/server_wrap_mt_common.h
index f0ab256374..a6f595d776 100644
--- a/servers/server_wrap_mt_common.h
+++ b/servers/server_wrap_mt_common.h
@@ -50,7 +50,7 @@
} \
void m_type##_free_cached_ids() { \
while (m_type##_id_pool.size()) { \
- free(m_type##_id_pool.front()->get()); \
+ server_name->free(m_type##_id_pool.front()->get()); \
m_type##_id_pool.pop_front(); \
} \
} \
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index 31888261ec..31b468b50b 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -60,6 +60,7 @@ public:
virtual void environment_set_bg_energy(RID p_env, float p_energy) = 0;
virtual void environment_set_canvas_max_layer(RID p_env, int p_max_layer) = 0;
virtual void environment_set_ambient_light(RID p_env, const Color &p_color, float p_energy = 1.0, float p_sky_contribution = 0.0) = 0;
+ virtual void environment_set_camera_feed_id(RID p_env, int p_camera_feed_id) = 0;
virtual void environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality) = 0;
virtual void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality) = 0;
@@ -204,6 +205,7 @@ public:
virtual uint32_t texture_get_height(RID p_texture) const = 0;
virtual uint32_t texture_get_depth(RID p_texture) const = 0;
virtual void texture_set_size_override(RID p_texture, int p_width, int p_height, int p_depth_3d) = 0;
+ virtual void texture_bind(RID p_texture, uint32_t p_texture_no) = 0;
virtual void texture_set_path(RID p_texture, const String &p_path) = 0;
virtual String texture_get_path(RID p_texture) const = 0;
@@ -1103,7 +1105,7 @@ public:
virtual RasterizerCanvas *get_canvas() = 0;
virtual RasterizerScene *get_scene() = 0;
- virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale) = 0;
+ virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true) = 0;
virtual void initialize() = 0;
virtual void begin_frame(double frame_step) = 0;
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp
index 6efd05593e..42b9f19d9d 100644
--- a/servers/visual/shader_language.cpp
+++ b/servers/visual/shader_language.cpp
@@ -132,6 +132,7 @@ const char *ShaderLanguage::token_names[TK_MAX] = {
"TYPE_SAMPLERCUBE",
"INTERPOLATION_FLAT",
"INTERPOLATION_SMOOTH",
+ "CONST",
"PRECISION_LOW",
"PRECISION_MID",
"PRECISION_HIGH",
@@ -271,6 +272,7 @@ const ShaderLanguage::KeyWord ShaderLanguage::keyword_list[] = {
{ TK_TYPE_SAMPLERCUBE, "samplerCube" },
{ TK_INTERPOLATION_FLAT, "flat" },
{ TK_INTERPOLATION_SMOOTH, "smooth" },
+ { TK_CONST, "const" },
{ TK_PRECISION_LOW, "lowp" },
{ TK_PRECISION_MID, "mediump" },
{ TK_PRECISION_HIGH, "highp" },
@@ -920,6 +922,16 @@ bool ShaderLanguage::_find_identifier(const BlockNode *p_block, const Map<String
return true;
}
+ if (shader->constants.has(p_identifier)) {
+ if (r_data_type) {
+ *r_data_type = shader->constants[p_identifier].type;
+ }
+ if (r_type) {
+ *r_type = IDENTIFIER_CONSTANT;
+ }
+ return true;
+ }
+
for (int i = 0; i < shader->functions.size(); i++) {
if (!shader->functions[i].callable)
@@ -2699,6 +2711,12 @@ bool ShaderLanguage::_validate_assign(Node *p_node, const Map<StringName, BuiltI
return false;
}
+ if (shader->constants.has(var->name)) {
+ if (r_message)
+ *r_message = RTR("Constants cannot be modified.");
+ return false;
+ }
+
if (!(p_builtin_types.has(var->name) && p_builtin_types[var->name].constant)) {
return true;
}
@@ -3993,7 +4011,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
} else {
- //nothng else, so expression
+ //nothing else, so expression
_set_tkpos(pos); //rollback
Node *expr = _parse_and_reduce_expression(p_block, p_builtin_types);
if (!expr)
@@ -4322,24 +4340,30 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
} break;
default: {
- //function
+ //function or constant variable
+ bool is_constant = false;
DataPrecision precision = PRECISION_DEFAULT;
DataType type;
StringName name;
+ if (tk.type == TK_CONST) {
+ is_constant = true;
+ tk = _get_token();
+ }
+
if (is_token_precision(tk.type)) {
precision = get_token_precision(tk.type);
tk = _get_token();
}
if (!is_token_datatype(tk.type)) {
- _set_error("Expected function, uniform or varying ");
+ _set_error("Expected constant, function, uniform or varying ");
return ERR_PARSE_ERROR;
}
if (!is_token_variable_datatype(tk.type)) {
- _set_error("Invalid data type for function return (samplers not allowed)");
+ _set_error("Invalid data type for constants or function return (samplers not allowed)");
return ERR_PARSE_ERROR;
}
@@ -4359,8 +4383,73 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
tk = _get_token();
if (tk.type != TK_PARENTHESIS_OPEN) {
- _set_error("Expected '(' after identifier");
- return ERR_PARSE_ERROR;
+ if (type == TYPE_VOID) {
+ _set_error("Expected '(' after function identifier");
+ return ERR_PARSE_ERROR;
+ }
+
+ //variable
+
+ while (true) {
+ ShaderNode::Constant constant;
+ constant.type = type;
+ constant.precision = precision;
+ constant.initializer = NULL;
+
+ if (tk.type == TK_OP_ASSIGN) {
+
+ if (!is_constant) {
+ _set_error("Expected 'const' keyword before constant definition");
+ return ERR_PARSE_ERROR;
+ }
+
+ //variable created with assignment! must parse an expression
+ Node *expr = _parse_and_reduce_expression(NULL, Map<StringName, BuiltInInfo>());
+ if (!expr)
+ return ERR_PARSE_ERROR;
+
+ if (expr->type != Node::TYPE_CONSTANT) {
+ _set_error("Expected constant expression after '='");
+ return ERR_PARSE_ERROR;
+ }
+
+ constant.initializer = static_cast<ConstantNode *>(expr);
+
+ if (type != expr->get_datatype()) {
+ _set_error("Invalid assignment of '" + get_datatype_name(expr->get_datatype()) + "' to '" + get_datatype_name(type) + "'");
+ return ERR_PARSE_ERROR;
+ }
+ tk = _get_token();
+ } else {
+ _set_error("Expected initialization of constant");
+ return ERR_PARSE_ERROR;
+ }
+
+ shader->constants[name] = constant;
+ if (tk.type == TK_COMMA) {
+ tk = _get_token();
+ if (tk.type != TK_IDENTIFIER) {
+ _set_error("Expected identifier after type");
+ return ERR_PARSE_ERROR;
+ }
+
+ name = tk.text;
+ if (_find_identifier(NULL, Map<StringName, BuiltInInfo>(), name)) {
+ _set_error("Redefinition of '" + String(name) + "'");
+ return ERR_PARSE_ERROR;
+ }
+
+ tk = _get_token();
+
+ } else if (tk.type == TK_SEMICOLON) {
+ break;
+ } else {
+ _set_error("Expected ',' or ';' after constant");
+ return ERR_PARSE_ERROR;
+ }
+ }
+
+ break;
}
Map<StringName, BuiltInInfo> builtin_types;
diff --git a/servers/visual/shader_language.h b/servers/visual/shader_language.h
index 67c273d267..934dc2c403 100644
--- a/servers/visual/shader_language.h
+++ b/servers/visual/shader_language.h
@@ -80,6 +80,7 @@ public:
TK_TYPE_SAMPLERCUBE,
TK_INTERPOLATION_FLAT,
TK_INTERPOLATION_SMOOTH,
+ TK_CONST,
TK_PRECISION_LOW,
TK_PRECISION_MID,
TK_PRECISION_HIGH,
@@ -440,6 +441,13 @@ public:
};
struct ShaderNode : public Node {
+
+ struct Constant {
+ DataType type;
+ DataPrecision precision;
+ ConstantNode *initializer;
+ };
+
struct Function {
StringName name;
FunctionNode *function;
@@ -492,6 +500,7 @@ public:
}
};
+ Map<StringName, Constant> constants;
Map<StringName, Varying> varyings;
Map<StringName, Uniform> uniforms;
Vector<StringName> render_modes;
@@ -632,6 +641,7 @@ private:
IDENTIFIER_FUNCTION_ARGUMENT,
IDENTIFIER_LOCAL_VAR,
IDENTIFIER_BUILTIN_VAR,
+ IDENTIFIER_CONSTANT,
};
bool _find_identifier(const BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types, const StringName &p_identifier, DataType *r_data_type = NULL, IdentifierType *r_type = NULL);
diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp
index bc6010117c..75910ff1c0 100644
--- a/servers/visual/shader_types.cpp
+++ b/servers/visual/shader_types.cpp
@@ -137,6 +137,8 @@ ShaderTypes::ShaderTypes() {
shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4);
shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["NORMAL"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2);
+ shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["UV2"] = constt(ShaderLanguage::TYPE_VEC2);
shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["VIEW"] = constt(ShaderLanguage::TYPE_VEC3);
shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["LIGHT"] = constt(ShaderLanguage::TYPE_VEC3);
shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["LIGHT_COLOR"] = constt(ShaderLanguage::TYPE_VEC3);
diff --git a/servers/visual/visual_server_canvas.cpp b/servers/visual/visual_server_canvas.cpp
index d5e154a7fc..66e2429bd0 100644
--- a/servers/visual/visual_server_canvas.cpp
+++ b/servers/visual/visual_server_canvas.cpp
@@ -783,7 +783,7 @@ void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector
ERR_FAIL_COND(!p_bones.empty() && p_bones.size() != vertex_count * 4);
ERR_FAIL_COND(!p_weights.empty() && p_weights.size() != vertex_count * 4);
- Vector<int> indices = p_indices;
+ const Vector<int> &indices = p_indices;
int count = p_count * 3;
diff --git a/servers/visual/visual_server_canvas.h b/servers/visual/visual_server_canvas.h
index 26424f927e..28a8770c90 100644
--- a/servers/visual/visual_server_canvas.h
+++ b/servers/visual/visual_server_canvas.h
@@ -84,8 +84,8 @@ public:
if (Math::is_equal_approx(p_left->ysort_pos.y, p_right->ysort_pos.y))
return p_left->ysort_pos.x < p_right->ysort_pos.x;
- else
- return p_left->ysort_pos.y < p_right->ysort_pos.y;
+
+ return p_left->ysort_pos.y < p_right->ysort_pos.y;
}
};
diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp
index 310aa16130..d45bda72b7 100644
--- a/servers/visual/visual_server_raster.cpp
+++ b/servers/visual/visual_server_raster.cpp
@@ -153,10 +153,10 @@ int VisualServerRaster::get_render_info(RenderInfo p_info) {
/* TESTING */
-void VisualServerRaster::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale) {
+void VisualServerRaster::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {
redraw_request();
- VSG::rasterizer->set_boot_image(p_image, p_color, p_scale);
+ VSG::rasterizer->set_boot_image(p_image, p_color, p_scale, p_use_filter);
}
void VisualServerRaster::set_default_clear_color(const Color &p_color) {
VSG::viewport->set_default_clear_color(p_color);
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index 921d55556d..f37d651dee 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -159,6 +159,7 @@ public:
BIND1RC(uint32_t, texture_get_height, RID)
BIND1RC(uint32_t, texture_get_depth, RID)
BIND4(texture_set_size_override, RID, int, int, int)
+ BIND2(texture_bind, RID, uint32_t)
BIND3(texture_set_detect_3d_callback, RID, TextureDetectCallback, void *)
BIND3(texture_set_detect_srgb_callback, RID, TextureDetectCallback, void *)
@@ -503,6 +504,7 @@ public:
BIND2(environment_set_bg_energy, RID, float)
BIND2(environment_set_canvas_max_layer, RID, int)
BIND4(environment_set_ambient_light, RID, const Color &, float, float)
+ BIND2(environment_set_camera_feed_id, RID, int)
BIND7(environment_set_ssr, RID, bool, int, float, float, float, bool)
BIND13(environment_set_ssao, RID, bool, float, float, float, float, float, float, float, const Color &, EnvironmentSSAOQuality, EnvironmentSSAOBlur, float)
@@ -685,7 +687,7 @@ public:
/* TESTING */
- virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale);
+ virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true);
virtual void set_default_clear_color(const Color &p_color);
virtual bool has_feature(Features p_feature) const;
diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp
index 3ee23e9290..faf5a1f8fa 100644
--- a/servers/visual/visual_server_scene.cpp
+++ b/servers/visual/visual_server_scene.cpp
@@ -3387,11 +3387,7 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
RID mat = VSG::storage->immediate_get_material(p_instance->base);
- if (!mat.is_valid() || VSG::storage->material_casts_shadows(mat)) {
- can_cast_shadows = true;
- } else {
- can_cast_shadows = false;
- }
+ can_cast_shadows = !mat.is_valid() || VSG::storage->material_casts_shadows(mat);
if (mat.is_valid() && VSG::storage->material_is_animated(mat)) {
is_animated = true;
diff --git a/servers/visual/visual_server_viewport.cpp b/servers/visual/visual_server_viewport.cpp
index b7c54caffd..f8ed035766 100644
--- a/servers/visual/visual_server_viewport.cpp
+++ b/servers/visual/visual_server_viewport.cpp
@@ -253,8 +253,6 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
} else {
_draw_3d(p_viewport, p_eye);
}
-
- scenario_draw_canvas_bg = false;
}
//VSG::canvas_render->canvas_debug_viewport_shadows(lights_with_shadow);
diff --git a/servers/visual/visual_server_viewport.h b/servers/visual/visual_server_viewport.h
index 43bbcb66c3..bdd4c1d4f2 100644
--- a/servers/visual/visual_server_viewport.h
+++ b/servers/visual/visual_server_viewport.h
@@ -138,9 +138,8 @@ public:
if (left_to_screen == right_to_screen) {
return p_left->parent == p_right->self;
- } else {
- return right_to_screen;
}
+ return right_to_screen;
}
};
diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h
index cd24deb60c..24e50eb99e 100644
--- a/servers/visual/visual_server_wrap_mt.h
+++ b/servers/visual/visual_server_wrap_mt.h
@@ -95,6 +95,7 @@ public:
FUNC1RC(uint32_t, texture_get_height, RID)
FUNC1RC(uint32_t, texture_get_depth, RID)
FUNC4(texture_set_size_override, RID, int, int, int)
+ FUNC2(texture_bind, RID, uint32_t)
FUNC3(texture_set_detect_3d_callback, RID, TextureDetectCallback, void *)
FUNC3(texture_set_detect_srgb_callback, RID, TextureDetectCallback, void *)
@@ -430,6 +431,7 @@ public:
FUNC2(environment_set_bg_energy, RID, float)
FUNC2(environment_set_canvas_max_layer, RID, int)
FUNC4(environment_set_ambient_light, RID, const Color &, float, float)
+ FUNC2(environment_set_camera_feed_id, RID, int)
FUNC7(environment_set_ssr, RID, bool, int, float, float, float, bool)
FUNC13(environment_set_ssao, RID, bool, float, float, float, float, float, float, float, const Color &, EnvironmentSSAOQuality, EnvironmentSSAOBlur, float)
@@ -602,7 +604,7 @@ public:
return visual_server->get_render_info(p_info);
}
- FUNC3(set_boot_image, const Ref<Image> &, const Color &, bool)
+ FUNC4(set_boot_image, const Ref<Image> &, const Color &, bool, bool)
FUNC1(set_default_clear_color, const Color &)
FUNC0R(RID, get_test_cube)
diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp
index 0fe00ad61a..c6468694fd 100644
--- a/servers/visual_server.cpp
+++ b/servers/visual_server.cpp
@@ -917,7 +917,7 @@ uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format,
}
r_offsets[i] = elem_size;
continue;
- } break;
+ }
default: {
ERR_FAIL_V(0);
}
@@ -953,15 +953,12 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_prim
switch (var.get_type()) {
case Variant::POOL_VECTOR2_ARRAY: {
PoolVector<Vector2> v2 = var;
- array_len = v2.size();
} break;
case Variant::POOL_VECTOR3_ARRAY: {
PoolVector<Vector3> v3 = var;
- array_len = v3.size();
} break;
default: {
Array v = var;
- array_len = v.size();
} break;
}
@@ -1151,7 +1148,7 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_prim
if (err) {
ERR_EXPLAIN("Invalid array format for surface");
- ERR_FAIL_COND(err != OK);
+ ERR_FAIL();
}
Vector<PoolVector<uint8_t> > blend_shape_data;
@@ -1165,9 +1162,9 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_prim
AABB laabb;
Error err2 = _surface_set_data(p_blend_shapes[i], format & ~ARRAY_FORMAT_INDEX, offsets, total_elem_size, vertex_array_shape, array_len, noindex, 0, laabb, bone_aabb);
aabb.merge_with(laabb);
- if (err2) {
+ if (err2 != OK) {
ERR_EXPLAIN("Invalid blend shape array format for surface");
- ERR_FAIL_COND(err2 != OK);
+ ERR_FAIL();
}
blend_shape_data.push_back(vertex_array_shape);
@@ -1676,6 +1673,7 @@ void VisualServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("texture_set_path", "texture", "path"), &VisualServer::texture_set_path);
ClassDB::bind_method(D_METHOD("texture_get_path", "texture"), &VisualServer::texture_get_path);
ClassDB::bind_method(D_METHOD("texture_set_shrink_all_x2_on_set_data", "shrink"), &VisualServer::texture_set_shrink_all_x2_on_set_data);
+ ClassDB::bind_method(D_METHOD("texture_bind", "texture", "number"), &VisualServer::texture_bind);
ClassDB::bind_method(D_METHOD("texture_debug_usage"), &VisualServer::_texture_debug_usage_bind);
ClassDB::bind_method(D_METHOD("textures_keep_original", "enable"), &VisualServer::textures_keep_original);
@@ -2047,7 +2045,7 @@ void VisualServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_test_texture"), &VisualServer::get_test_texture);
ClassDB::bind_method(D_METHOD("get_white_texture"), &VisualServer::get_white_texture);
- ClassDB::bind_method(D_METHOD("set_boot_image", "image", "color", "scale"), &VisualServer::set_boot_image);
+ ClassDB::bind_method(D_METHOD("set_boot_image", "image", "color", "scale", "use_filter"), &VisualServer::set_boot_image, DEFVAL(true));
ClassDB::bind_method(D_METHOD("set_default_clear_color", "color"), &VisualServer::set_default_clear_color);
ClassDB::bind_method(D_METHOD("has_feature", "feature"), &VisualServer::has_feature);
diff --git a/servers/visual_server.h b/servers/visual_server.h
index 01be996bfc..a84d395e3f 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -140,6 +140,7 @@ public:
virtual uint32_t texture_get_height(RID p_texture) const = 0;
virtual uint32_t texture_get_depth(RID p_texture) const = 0;
virtual void texture_set_size_override(RID p_texture, int p_width, int p_height, int p_depth_3d) = 0;
+ virtual void texture_bind(RID p_texture, uint32_t p_texture_no) = 0;
virtual void texture_set_path(RID p_texture, const String &p_path) = 0;
virtual String texture_get_path(RID p_texture) const = 0;
@@ -707,6 +708,7 @@ public:
ENV_BG_COLOR_SKY,
ENV_BG_CANVAS,
ENV_BG_KEEP,
+ ENV_BG_CAMERA_FEED,
ENV_BG_MAX
};
@@ -718,6 +720,7 @@ public:
virtual void environment_set_bg_energy(RID p_env, float p_energy) = 0;
virtual void environment_set_canvas_max_layer(RID p_env, int p_max_layer) = 0;
virtual void environment_set_ambient_light(RID p_env, const Color &p_color, float p_energy = 1.0, float p_sky_contribution = 0.0) = 0;
+ virtual void environment_set_camera_feed_id(RID p_env, int p_camera_feed_id) = 0;
//set default SSAO options
//set default SSR options
@@ -1029,7 +1032,7 @@ public:
virtual void mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry::MeshData &p_mesh_data);
virtual void mesh_add_surface_from_planes(RID p_mesh, const PoolVector<Plane> &p_planes);
- virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale) = 0;
+ virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true) = 0;
virtual void set_default_clear_color(const Color &p_color) = 0;
enum Features {