diff options
Diffstat (limited to 'servers')
94 files changed, 459 insertions, 334 deletions
diff --git a/servers/SCsub b/servers/SCsub index 252a18ffd3..f4af347fe6 100644 --- a/servers/SCsub +++ b/servers/SCsub @@ -5,8 +5,6 @@ Import('env') env.servers_sources = [] env.add_source_files(env.servers_sources, "*.cpp") -Export('env') - SConscript('arvr/SCsub') SConscript('physics/SCsub') SConscript('physics_2d/SCsub') diff --git a/servers/arvr/SCsub b/servers/arvr/SCsub index ccc76e823f..d730144861 100644 --- a/servers/arvr/SCsub +++ b/servers/arvr/SCsub @@ -3,5 +3,3 @@ Import('env') env.add_source_files(env.servers_sources, "*.cpp") - -Export('env') diff --git a/servers/arvr/arvr_interface.h b/servers/arvr/arvr_interface.h index 910b401db9..b26ee6cb1b 100644 --- a/servers/arvr/arvr_interface.h +++ b/servers/arvr/arvr_interface.h @@ -32,7 +32,7 @@ #define ARVR_INTERFACE_H #include "core/math/camera_matrix.h" -#include "os/thread_safe.h" +#include "core/os/thread_safe.h" #include "scene/main/viewport.h" #include "servers/arvr_server.h" diff --git a/servers/arvr/arvr_positional_tracker.h b/servers/arvr/arvr_positional_tracker.h index 525e47a681..69b89f11d3 100644 --- a/servers/arvr/arvr_positional_tracker.h +++ b/servers/arvr/arvr_positional_tracker.h @@ -31,7 +31,7 @@ #ifndef ARVR_POSITIONAL_TRACKER_H #define ARVR_POSITIONAL_TRACKER_H -#include "os/thread_safe.h" +#include "core/os/thread_safe.h" #include "servers/arvr_server.h" /** diff --git a/servers/arvr_server.cpp b/servers/arvr_server.cpp index 2040377dd4..55f8ea8f5b 100644 --- a/servers/arvr_server.cpp +++ b/servers/arvr_server.cpp @@ -31,7 +31,7 @@ #include "arvr_server.h" #include "arvr/arvr_interface.h" #include "arvr/arvr_positional_tracker.h" -#include "project_settings.h" +#include "core/project_settings.h" ARVRServer *ARVRServer::singleton = NULL; diff --git a/servers/arvr_server.h b/servers/arvr_server.h index 1f4d84fe19..a28b91c225 100644 --- a/servers/arvr_server.h +++ b/servers/arvr_server.h @@ -31,11 +31,11 @@ #ifndef ARVR_SERVER_H #define ARVR_SERVER_H -#include "os/os.h" -#include "os/thread_safe.h" -#include "reference.h" -#include "rid.h" -#include "variant.h" +#include "core/os/os.h" +#include "core/os/thread_safe.h" +#include "core/reference.h" +#include "core/rid.h" +#include "core/variant.h" class ARVRInterface; class ARVRPositionalTracker; @@ -87,7 +87,7 @@ private: uint64_t last_process_usec; /* for frame timing, usec when we did our processing */ uint64_t last_commit_usec; /* for frame timing, usec when we finished committing both eyes */ - uint64_t last_frame_usec; /* time it took between process and commiting, we should probably average this over the last x frames */ + uint64_t last_frame_usec; /* time it took between process and committing, we should probably average this over the last x frames */ protected: static ARVRServer *singleton; diff --git a/servers/audio/SCsub b/servers/audio/SCsub index afaffcfe93..3c18c18043 100644 --- a/servers/audio/SCsub +++ b/servers/audio/SCsub @@ -4,6 +4,4 @@ Import('env') env.add_source_files(env.servers_sources, "*.cpp") -Export('env') - SConscript("effects/SCsub") diff --git a/servers/audio/audio_driver_dummy.cpp b/servers/audio/audio_driver_dummy.cpp index be36c3b748..512ff5da7b 100644 --- a/servers/audio/audio_driver_dummy.cpp +++ b/servers/audio/audio_driver_dummy.cpp @@ -30,8 +30,8 @@ #include "audio_driver_dummy.h" -#include "os/os.h" -#include "project_settings.h" +#include "core/os/os.h" +#include "core/project_settings.h" Error AudioDriverDummy::init() { diff --git a/servers/audio/audio_effect.h b/servers/audio/audio_effect.h index b950e824c0..bbabedbc30 100644 --- a/servers/audio/audio_effect.h +++ b/servers/audio/audio_effect.h @@ -31,8 +31,8 @@ #ifndef AUDIOEFFECT_H #define AUDIOEFFECT_H -#include "audio_frame.h" -#include "resource.h" +#include "core/math/audio_frame.h" +#include "core/resource.h" class AudioEffectInstance : public Reference { GDCLASS(AudioEffectInstance, Reference) diff --git a/servers/audio/audio_filter_sw.h b/servers/audio/audio_filter_sw.h index 4174f9bd51..d137ed8ff9 100644 --- a/servers/audio/audio_filter_sw.h +++ b/servers/audio/audio_filter_sw.h @@ -31,7 +31,7 @@ #ifndef AUDIO_FILTER_SW_H #define AUDIO_FILTER_SW_H -#include "math_funcs.h" +#include "core/math/math_funcs.h" class AudioFilterSW { public: diff --git a/servers/audio/audio_rb_resampler.cpp b/servers/audio/audio_rb_resampler.cpp index 3414351681..84a87de2e2 100644 --- a/servers/audio/audio_rb_resampler.cpp +++ b/servers/audio/audio_rb_resampler.cpp @@ -30,7 +30,7 @@ #include "audio_rb_resampler.h" #include "core/math/math_funcs.h" -#include "os/os.h" +#include "core/os/os.h" #include "servers/audio_server.h" int AudioRBResampler::get_channel_count() const { @@ -82,19 +82,28 @@ uint32_t AudioRBResampler::_resample(AudioFrame *p_dest, int p_todo, int32_t p_i // For now, channels higher than stereo are almost ignored if (C == 4) { + // FIXME: v2 and v3 are not being used (thus were commented out to prevent + // compilation warnings, but they should likely be uncommented *and* used). + // See also C == 6 with similar issues. float v0 = rb[(pos << 2) + 0]; float v1 = rb[(pos << 2) + 1]; + /* float v2 = rb[(pos << 2) + 2]; float v3 = rb[(pos << 2) + 3]; + */ float v0n = rb[(pos_next << 2) + 0]; float v1n = rb[(pos_next << 2) + 1]; + /* float v2n = rb[(pos_next << 2) + 2]; float v3n = rb[(pos_next << 2) + 3]; + */ v0 += (v0n - v0) * frac; v1 += (v1n - v1) * frac; + /* v2 += (v2n - v2) * frac; v3 += (v3n - v3) * frac; + */ p_dest[i] = AudioFrame(v0, v1); } @@ -104,6 +113,7 @@ uint32_t AudioRBResampler::_resample(AudioFrame *p_dest, int p_todo, int32_t p_i // should be done as for C == 2 (C == 4 also has some unused assignments). float v0 = rb[(pos * 6) + 0]; float v1 = rb[(pos * 6) + 1]; + /* float v2 = rb[(pos * 6) + 2]; float v3 = rb[(pos * 6) + 3]; float v4 = rb[(pos * 6) + 4]; @@ -114,6 +124,7 @@ uint32_t AudioRBResampler::_resample(AudioFrame *p_dest, int p_todo, int32_t p_i float v3n = rb[(pos_next * 6) + 3]; float v4n = rb[(pos_next * 6) + 4]; float v5n = rb[(pos_next * 6) + 5]; + */ p_dest[i] = AudioFrame(v0, v1); } @@ -153,7 +164,7 @@ bool AudioRBResampler::mix(AudioFrame *p_dest, int p_frames) { } // Fill zeros (silence) for the rest of frames - for (uint32_t i = target_todo; i < p_frames; i++) { + for (int i = target_todo; i < p_frames; i++) { p_dest[i] = AudioFrame(0, 0); } } diff --git a/servers/audio/audio_rb_resampler.h b/servers/audio/audio_rb_resampler.h index 6ef79c93fa..b21c480fc4 100644 --- a/servers/audio/audio_rb_resampler.h +++ b/servers/audio/audio_rb_resampler.h @@ -31,9 +31,9 @@ #ifndef AUDIO_RB_RESAMPLER_H #define AUDIO_RB_RESAMPLER_H -#include "os/memory.h" +#include "core/os/memory.h" +#include "core/typedefs.h" #include "servers/audio_server.h" -#include "typedefs.h" struct AudioRBResampler { diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp index eef8aba0c4..7de0695e8c 100644 --- a/servers/audio/audio_stream.cpp +++ b/servers/audio/audio_stream.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "audio_stream.h" -#include "os/os.h" +#include "core/os/os.h" ////////////////////////////// @@ -137,7 +137,7 @@ void AudioStreamPlaybackMicrophone::_mix_internal(AudioFrame *p_buffer, int p_fr Vector<int32_t> buf = AudioDriver::get_singleton()->get_input_buffer(); unsigned int input_size = AudioDriver::get_singleton()->get_input_size(); - // p_frames is multipled by two since an AudioFrame is stereo + // p_frames is multiplied by two since an AudioFrame is stereo if ((p_frames + MICROPHONE_PLAYBACK_DELAY * 2) > input_size) { for (int i = 0; i < p_frames; i++) { p_buffer[i] = AudioFrame(0.0f, 0.0f); diff --git a/servers/audio/audio_stream.h b/servers/audio/audio_stream.h index 66e1b6ee2f..2740f86d55 100644 --- a/servers/audio/audio_stream.h +++ b/servers/audio/audio_stream.h @@ -31,8 +31,8 @@ #ifndef AUDIO_STREAM_H #define AUDIO_STREAM_H -#include "image.h" -#include "resource.h" +#include "core/image.h" +#include "core/resource.h" #include "servers/audio/audio_filter_sw.h" #include "servers/audio_server.h" @@ -122,7 +122,7 @@ class AudioStreamPlaybackMicrophone : public AudioStreamPlaybackResampled { GDCLASS(AudioStreamPlaybackMicrophone, AudioStreamPlayback) friend class AudioStreamMicrophone; - const int MICROPHONE_PLAYBACK_DELAY = 256; + static const int MICROPHONE_PLAYBACK_DELAY = 256; bool active; unsigned int input_ofs; diff --git a/servers/audio/effects/SCsub b/servers/audio/effects/SCsub index ccc76e823f..d730144861 100644 --- a/servers/audio/effects/SCsub +++ b/servers/audio/effects/SCsub @@ -3,5 +3,3 @@ Import('env') env.add_source_files(env.servers_sources, "*.cpp") - -Export('env') diff --git a/servers/audio/effects/audio_effect_chorus.cpp b/servers/audio/effects/audio_effect_chorus.cpp index fd9e3311e7..3c88d050f6 100644 --- a/servers/audio/effects/audio_effect_chorus.cpp +++ b/servers/audio/effects/audio_effect_chorus.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "audio_effect_chorus.h" -#include "math_funcs.h" +#include "core/math/math_funcs.h" #include "servers/audio_server.h" void AudioEffectChorusInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) { diff --git a/servers/audio/effects/audio_effect_delay.cpp b/servers/audio/effects/audio_effect_delay.cpp index e3af898afa..abc10ee096 100644 --- a/servers/audio/effects/audio_effect_delay.cpp +++ b/servers/audio/effects/audio_effect_delay.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "audio_effect_delay.h" -#include "math_funcs.h" +#include "core/math/math_funcs.h" #include "servers/audio_server.h" void AudioEffectDelayInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) { diff --git a/servers/audio/effects/audio_effect_distortion.cpp b/servers/audio/effects/audio_effect_distortion.cpp index c9ac0db644..0422083363 100644 --- a/servers/audio/effects/audio_effect_distortion.cpp +++ b/servers/audio/effects/audio_effect_distortion.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "audio_effect_distortion.h" -#include "math_funcs.h" +#include "core/math/math_funcs.h" #include "servers/audio_server.h" void AudioEffectDistortionInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) { diff --git a/servers/audio/effects/audio_effect_phaser.cpp b/servers/audio/effects/audio_effect_phaser.cpp index c0a9bd773d..3151111ec8 100644 --- a/servers/audio/effects/audio_effect_phaser.cpp +++ b/servers/audio/effects/audio_effect_phaser.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "audio_effect_phaser.h" -#include "math_funcs.h" +#include "core/math/math_funcs.h" #include "servers/audio_server.h" void AudioEffectPhaserInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) { diff --git a/servers/audio/effects/audio_effect_pitch_shift.cpp b/servers/audio/effects/audio_effect_pitch_shift.cpp index c6d1217308..f5ca8f2da4 100644 --- a/servers/audio/effects/audio_effect_pitch_shift.cpp +++ b/servers/audio/effects/audio_effect_pitch_shift.cpp @@ -30,7 +30,7 @@ #include "audio_effect_pitch_shift.h" -#include "math_funcs.h" +#include "core/math/math_funcs.h" #include "servers/audio_server.h" /* Thirdparty code, so disable clang-format with Godot style */ diff --git a/servers/audio/effects/audio_effect_record.h b/servers/audio/effects/audio_effect_record.h index e4f5ba8a23..edf8565c06 100644 --- a/servers/audio/effects/audio_effect_record.h +++ b/servers/audio/effects/audio_effect_record.h @@ -31,11 +31,11 @@ #ifndef AUDIOEFFECTRECORD_H #define AUDIOEFFECTRECORD_H +#include "core/io/marshalls.h" +#include "core/os/file_access.h" +#include "core/os/os.h" #include "core/os/thread.h" #include "editor/import/resource_importer_wav.h" -#include "io/marshalls.h" -#include "os/file_access.h" -#include "os/os.h" #include "scene/resources/audio_stream_sample.h" #include "servers/audio/audio_effect.h" #include "servers/audio_server.h" @@ -49,7 +49,7 @@ class AudioEffectRecordInstance : public AudioEffectInstance { bool is_recording; Thread *io_thread; - bool thread_active = false; + bool thread_active; Vector<AudioFrame> ring_buffer; Vector<float> recording_data; @@ -67,6 +67,9 @@ public: void init(); virtual void process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count); virtual bool process_silence(); + + AudioEffectRecordInstance() : + thread_active(false) {} }; class AudioEffectRecord : public AudioEffect { diff --git a/servers/audio/effects/eq.cpp b/servers/audio/effects/eq.cpp index b15fc7ecf4..70ac70a5a8 100644 --- a/servers/audio/effects/eq.cpp +++ b/servers/audio/effects/eq.cpp @@ -31,8 +31,8 @@ // Author: reduzio@gmail.com (C) 2006 #include "eq.h" -#include "error_macros.h" -#include "math_funcs.h" +#include "core/error_macros.h" +#include "core/math/math_funcs.h" #include <math.h> #define POW2(v) ((v) * (v)) diff --git a/servers/audio/effects/eq.h b/servers/audio/effects/eq.h index 5c654529c3..c06f1f8bf8 100644 --- a/servers/audio/effects/eq.h +++ b/servers/audio/effects/eq.h @@ -33,8 +33,8 @@ #ifndef EQ_FILTER_H #define EQ_FILTER_H -#include "typedefs.h" -#include "vector.h" +#include "core/typedefs.h" +#include "core/vector.h" /** @author Juan Linietsky diff --git a/servers/audio/effects/reverb.cpp b/servers/audio/effects/reverb.cpp index 5e31202e58..ef23e4aaf3 100644 --- a/servers/audio/effects/reverb.cpp +++ b/servers/audio/effects/reverb.cpp @@ -31,7 +31,7 @@ // Author: Juan Linietsky <reduzio@gmail.com>, (C) 2006 #include "reverb.h" -#include "math_funcs.h" +#include "core/math/math_funcs.h" #include <math.h> const float Reverb::comb_tunings[MAX_COMBS] = { diff --git a/servers/audio/effects/reverb.h b/servers/audio/effects/reverb.h index c3d3873dcd..03cf197456 100644 --- a/servers/audio/effects/reverb.h +++ b/servers/audio/effects/reverb.h @@ -33,9 +33,9 @@ #ifndef REVERB_H #define REVERB_H -#include "audio_frame.h" -#include "os/memory.h" -#include "typedefs.h" +#include "core/math/audio_frame.h" +#include "core/os/memory.h" +#include "core/typedefs.h" class Reverb { public: diff --git a/servers/audio/reverb_sw.cpp b/servers/audio/reverb_sw.cpp index 52e7699deb..d078da38b4 100644 --- a/servers/audio/reverb_sw.cpp +++ b/servers/audio/reverb_sw.cpp @@ -29,33 +29,21 @@ /*************************************************************************/ #include "reverb_sw.h" -#include "print_string.h" -#include "stdlib.h" + +#include "core/print_string.h" + +#include <stdlib.h> + #define SETMIN(x, y) (x) = MIN((x), (y)) + #define rangeloop(c, min, max) \ for ((c) = (min); (c) < (max); (c)++) #define ABSDIFF(x, y) \ (((x) < (y)) ? ((y) - (x)) : ((x) - (y))) -#ifdef bleh_MSC_VER - -#if _MSC_VER >= 1400 -_FORCE_INLINE_ int32_tMULSHIFT_S32( - int32_t Factor1, - int32_t Factor2, - uint8_t Bits) { - - return __ll_rshift( - __emul(Factor1, Factor2), - Bits); -} -#endif - -#else #define MULSHIFT_S32(Factor1, Factor2, Bits) \ ((int)(((int64_t)(Factor1) * (Factor2)) >> (Bits))) -#endif struct ReverbParamsSW { unsigned int BufferSize; // Required buffer size diff --git a/servers/audio/reverb_sw.h b/servers/audio/reverb_sw.h index 15f9a43183..01977d1f61 100644 --- a/servers/audio/reverb_sw.h +++ b/servers/audio/reverb_sw.h @@ -31,10 +31,10 @@ #ifndef REVERB_SW_H #define REVERB_SW_H -#include "os/memory.h" -#include "typedefs.h" +#include "core/os/memory.h" +#include "core/typedefs.h" -class ReverbParamsSW; +struct ReverbParamsSW; class ReverbSW { public: diff --git a/servers/audio/voice_rb_sw.h b/servers/audio/voice_rb_sw.h index 42045428a8..fc02cc1827 100644 --- a/servers/audio/voice_rb_sw.h +++ b/servers/audio/voice_rb_sw.h @@ -31,7 +31,7 @@ #ifndef VOICE_RB_SW_H #define VOICE_RB_SW_H -#include "os/os.h" +#include "core/os/os.h" #include "servers/audio_server.h" class VoiceRBSW { public: diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index b737f4681d..fead2f54da 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -29,10 +29,10 @@ /*************************************************************************/ #include "audio_server.h" -#include "io/resource_loader.h" -#include "os/file_access.h" -#include "os/os.h" -#include "project_settings.h" +#include "core/io/resource_loader.h" +#include "core/os/file_access.h" +#include "core/os/os.h" +#include "core/project_settings.h" #include "scene/resources/audio_stream_sample.h" #include "servers/audio/audio_driver_dummy.h" #include "servers/audio/effects/audio_effect_compressor.h" @@ -185,9 +185,13 @@ void AudioDriverManager::initialize(int p_driver) { if (drivers[i]->init() == OK) { drivers[i]->set_singleton(); - return; + break; } } + + if (driver_count > 1 && String(AudioDriver::get_singleton()->get_name()) == "Dummy") { + WARN_PRINT("All audio drivers failed, falling back to the dummy driver."); + } } AudioDriver *AudioDriverManager::get_driver(int p_driver) { diff --git a/servers/audio_server.h b/servers/audio_server.h index 2663a0f968..ba6569eb38 100644 --- a/servers/audio_server.h +++ b/servers/audio_server.h @@ -31,11 +31,11 @@ #ifndef AUDIO_SERVER_H #define AUDIO_SERVER_H -#include "audio_frame.h" -#include "object.h" -#include "os/os.h" +#include "core/math/audio_frame.h" +#include "core/object.h" +#include "core/os/os.h" +#include "core/variant.h" #include "servers/audio/audio_effect.h" -#include "variant.h" class AudioDriverDummy; class AudioStream; diff --git a/servers/physics/SCsub b/servers/physics/SCsub index c0ee2cc739..c5cc889112 100644 --- a/servers/physics/SCsub +++ b/servers/physics/SCsub @@ -4,6 +4,4 @@ Import('env') env.add_source_files(env.servers_sources, "*.cpp") -Export('env') - SConscript("joints/SCsub") diff --git a/servers/physics/area_sw.h b/servers/physics/area_sw.h index ae19b0e04e..63a4db5d02 100644 --- a/servers/physics/area_sw.h +++ b/servers/physics/area_sw.h @@ -32,7 +32,7 @@ #define AREA_SW_H #include "collision_object_sw.h" -#include "self_list.h" +#include "core/self_list.h" #include "servers/physics_server.h" //#include "servers/physics/query_sw.h" diff --git a/servers/physics/body_pair_sw.cpp b/servers/physics/body_pair_sw.cpp index 0ce38e4486..357fc05355 100644 --- a/servers/physics/body_pair_sw.cpp +++ b/servers/physics/body_pair_sw.cpp @@ -31,7 +31,7 @@ #include "body_pair_sw.h" #include "collision_solver_sw.h" -#include "os/os.h" +#include "core/os/os.h" #include "space_sw.h" /* diff --git a/servers/physics/body_pair_sw.h b/servers/physics/body_pair_sw.h index fd85d77718..17ff9d6a88 100644 --- a/servers/physics/body_pair_sw.h +++ b/servers/physics/body_pair_sw.h @@ -76,7 +76,6 @@ class BodyPairSW : public ConstraintSW { Contact contacts[MAX_CONTACTS]; int contact_count; bool collided; - int cc; static void _contact_added_callback(const Vector3 &p_point_A, const Vector3 &p_point_B, void *p_userdata); diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp index cc9681193c..36511f78ce 100644 --- a/servers/physics/body_sw.cpp +++ b/servers/physics/body_sw.cpp @@ -755,10 +755,10 @@ void BodySW::set_kinematic_margin(real_t p_margin) { BodySW::BodySW() : CollisionObjectSW(TYPE_BODY), + locked_axis(0), active_list(this), inertia_update_list(this), - direct_state_query_list(this), - locked_axis(0) { + direct_state_query_list(this) { mode = PhysicsServer::BODY_MODE_RIGID; active = true; diff --git a/servers/physics/body_sw.h b/servers/physics/body_sw.h index 9d7b147fd6..0f7797254e 100644 --- a/servers/physics/body_sw.h +++ b/servers/physics/body_sw.h @@ -33,7 +33,7 @@ #include "area_sw.h" #include "collision_object_sw.h" -#include "vset.h" +#include "core/vset.h" class ConstraintSW; diff --git a/servers/physics/broad_phase_basic.cpp b/servers/physics/broad_phase_basic.cpp index 52483a8b14..d55951b39a 100644 --- a/servers/physics/broad_phase_basic.cpp +++ b/servers/physics/broad_phase_basic.cpp @@ -29,8 +29,8 @@ /*************************************************************************/ #include "broad_phase_basic.h" -#include "list.h" -#include "print_string.h" +#include "core/list.h" +#include "core/print_string.h" BroadPhaseSW::ID BroadPhaseBasic::create(CollisionObjectSW *p_object, int p_subindex) { diff --git a/servers/physics/broad_phase_basic.h b/servers/physics/broad_phase_basic.h index 47fcdb3060..500b8544a1 100644 --- a/servers/physics/broad_phase_basic.h +++ b/servers/physics/broad_phase_basic.h @@ -32,7 +32,7 @@ #define BROAD_PHASE_BASIC_H #include "broad_phase_sw.h" -#include "map.h" +#include "core/map.h" class BroadPhaseBasic : public BroadPhaseSW { diff --git a/servers/physics/broad_phase_octree.h b/servers/physics/broad_phase_octree.h index e7028eba98..c4b8ecb299 100644 --- a/servers/physics/broad_phase_octree.h +++ b/servers/physics/broad_phase_octree.h @@ -32,7 +32,7 @@ #define BROAD_PHASE_OCTREE_H #include "broad_phase_sw.h" -#include "octree.h" +#include "core/math/octree.h" class BroadPhaseOctree : public BroadPhaseSW { diff --git a/servers/physics/broad_phase_sw.h b/servers/physics/broad_phase_sw.h index 7559942cd4..2db1c1dd06 100644 --- a/servers/physics/broad_phase_sw.h +++ b/servers/physics/broad_phase_sw.h @@ -31,8 +31,8 @@ #ifndef BROAD_PHASE_SW_H #define BROAD_PHASE_SW_H -#include "aabb.h" -#include "math_funcs.h" +#include "core/math/aabb.h" +#include "core/math/math_funcs.h" class CollisionObjectSW; diff --git a/servers/physics/collision_object_sw.h b/servers/physics/collision_object_sw.h index b6430b38dc..993799ee10 100644 --- a/servers/physics/collision_object_sw.h +++ b/servers/physics/collision_object_sw.h @@ -32,7 +32,7 @@ #define COLLISION_OBJECT_SW_H #include "broad_phase_sw.h" -#include "self_list.h" +#include "core/self_list.h" #include "servers/physics_server.h" #include "shape_sw.h" diff --git a/servers/physics/collision_solver_sat.cpp b/servers/physics/collision_solver_sat.cpp index 294b1df241..087ae570fb 100644 --- a/servers/physics/collision_solver_sat.cpp +++ b/servers/physics/collision_solver_sat.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "collision_solver_sat.h" -#include "geometry.h" +#include "core/math/geometry.h" #define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.02 diff --git a/servers/physics/joints/SCsub b/servers/physics/joints/SCsub index ccc76e823f..d730144861 100644 --- a/servers/physics/joints/SCsub +++ b/servers/physics/joints/SCsub @@ -3,5 +3,3 @@ Import('env') env.add_source_files(env.servers_sources, "*.cpp") - -Export('env') diff --git a/servers/physics/joints/cone_twist_joint_sw.cpp b/servers/physics/joints/cone_twist_joint_sw.cpp index c06f27cc57..37fcde4b76 100644 --- a/servers/physics/joints/cone_twist_joint_sw.cpp +++ b/servers/physics/joints/cone_twist_joint_sw.cpp @@ -332,6 +332,7 @@ void ConeTwistJointSW::set_param(PhysicsServer::ConeTwistJointParam p_param, rea m_relaxationFactor = p_value; } break; + case PhysicsServer::CONE_TWIST_MAX: break; // Can't happen, but silences warning } } @@ -358,6 +359,7 @@ real_t ConeTwistJointSW::get_param(PhysicsServer::ConeTwistJointParam p_param) c return m_relaxationFactor; } break; + case PhysicsServer::CONE_TWIST_MAX: break; // Can't happen, but silences warning } return 0; diff --git a/servers/physics/joints/generic_6dof_joint_sw.cpp b/servers/physics/joints/generic_6dof_joint_sw.cpp index c95e5cef32..9b1a41e80d 100644 --- a/servers/physics/joints/generic_6dof_joint_sw.cpp +++ b/servers/physics/joints/generic_6dof_joint_sw.cpp @@ -497,6 +497,13 @@ void Generic6DOFJointSW::set_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJoi m_angularLimits[p_axis].m_maxLimitForce = p_value; } break; + case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: { + // Not implemented in GodotPhysics backend + } break; + case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: { + // Not implemented in GodotPhysics backend + } break; + case PhysicsServer::G6DOF_JOINT_MAX: break; // Can't happen, but silences warning } } @@ -572,6 +579,13 @@ real_t Generic6DOFJointSW::get_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJ return m_angularLimits[p_axis].m_maxMotorForce; } break; + case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: { + // Not implemented in GodotPhysics backend + } break; + case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: { + // Not implemented in GodotPhysics backend + } break; + case PhysicsServer::G6DOF_JOINT_MAX: break; // Can't happen, but silences warning } return 0; } @@ -593,6 +607,10 @@ void Generic6DOFJointSW::set_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJoin m_angularLimits[p_axis].m_enableMotor = p_value; } break; + case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: { + // Not implemented in GodotPhysics backend + } break; + case PhysicsServer::G6DOF_JOINT_FLAG_MAX: break; // Can't happen, but silences warning } } bool Generic6DOFJointSW::get_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag) const { @@ -611,6 +629,10 @@ bool Generic6DOFJointSW::get_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJoin return m_angularLimits[p_axis].m_enableMotor; } break; + case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: { + // Not implemented in GodotPhysics backend + } break; + case PhysicsServer::G6DOF_JOINT_FLAG_MAX: break; // Can't happen, but silences warning } return 0; diff --git a/servers/physics/joints/hinge_joint_sw.cpp b/servers/physics/joints/hinge_joint_sw.cpp index 368a349632..50de0e871e 100644 --- a/servers/physics/joints/hinge_joint_sw.cpp +++ b/servers/physics/joints/hinge_joint_sw.cpp @@ -409,6 +409,7 @@ void HingeJointSW::set_param(PhysicsServer::HingeJointParam p_param, real_t p_va case PhysicsServer::HINGE_JOINT_LIMIT_RELAXATION: m_relaxationFactor = p_value; break; case PhysicsServer::HINGE_JOINT_MOTOR_TARGET_VELOCITY: m_motorTargetVelocity = p_value; break; case PhysicsServer::HINGE_JOINT_MOTOR_MAX_IMPULSE: m_maxMotorImpulse = p_value; break; + case PhysicsServer::HINGE_JOINT_MAX: break; // Can't happen, but silences warning } } @@ -424,6 +425,7 @@ real_t HingeJointSW::get_param(PhysicsServer::HingeJointParam p_param) const { case PhysicsServer::HINGE_JOINT_LIMIT_RELAXATION: return m_relaxationFactor; case PhysicsServer::HINGE_JOINT_MOTOR_TARGET_VELOCITY: return m_motorTargetVelocity; case PhysicsServer::HINGE_JOINT_MOTOR_MAX_IMPULSE: return m_maxMotorImpulse; + case PhysicsServer::HINGE_JOINT_MAX: break; // Can't happen, but silences warning } return 0; @@ -434,6 +436,7 @@ void HingeJointSW::set_flag(PhysicsServer::HingeJointFlag p_flag, bool p_value) switch (p_flag) { case PhysicsServer::HINGE_JOINT_FLAG_USE_LIMIT: m_useLimit = p_value; break; case PhysicsServer::HINGE_JOINT_FLAG_ENABLE_MOTOR: m_enableAngularMotor = p_value; break; + case PhysicsServer::HINGE_JOINT_FLAG_MAX: break; // Can't happen, but silences warning } } bool HingeJointSW::get_flag(PhysicsServer::HingeJointFlag p_flag) const { @@ -441,6 +444,7 @@ bool HingeJointSW::get_flag(PhysicsServer::HingeJointFlag p_flag) const { switch (p_flag) { case PhysicsServer::HINGE_JOINT_FLAG_USE_LIMIT: return m_useLimit; case PhysicsServer::HINGE_JOINT_FLAG_ENABLE_MOTOR: return m_enableAngularMotor; + case PhysicsServer::HINGE_JOINT_FLAG_MAX: break; // Can't happen, but silences warning } return false; diff --git a/servers/physics/joints/jacobian_entry_sw.h b/servers/physics/joints/jacobian_entry_sw.h index 42c90c9ae9..4bc1255a9a 100644 --- a/servers/physics/joints/jacobian_entry_sw.h +++ b/servers/physics/joints/jacobian_entry_sw.h @@ -50,7 +50,7 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -#include "transform.h" +#include "core/math/transform.h" class JacobianEntrySW { public: diff --git a/servers/physics/joints/slider_joint_sw.cpp b/servers/physics/joints/slider_joint_sw.cpp index c0e9660b22..30700d45f1 100644 --- a/servers/physics/joints/slider_joint_sw.cpp +++ b/servers/physics/joints/slider_joint_sw.cpp @@ -404,6 +404,8 @@ void SliderJointSW::set_param(PhysicsServer::SliderJointParam p_param, real_t p_ case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: m_softnessOrthoAng = p_value; break; case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: m_restitutionOrthoAng = p_value; break; case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: m_dampingOrthoAng = p_value; break; + + case PhysicsServer::SLIDER_JOINT_MAX: break; // Can't happen, but silences warning } } @@ -433,6 +435,8 @@ real_t SliderJointSW::get_param(PhysicsServer::SliderJointParam p_param) const { case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: return m_softnessOrthoAng; case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: return m_restitutionOrthoAng; case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: return m_dampingOrthoAng; + + case PhysicsServer::SLIDER_JOINT_MAX: break; // Can't happen, but silences warning } return 0; diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp index 472283833e..76a6138817 100644 --- a/servers/physics/physics_server_sw.cpp +++ b/servers/physics/physics_server_sw.cpp @@ -32,13 +32,13 @@ #include "broad_phase_basic.h" #include "broad_phase_octree.h" +#include "core/os/os.h" +#include "core/script_language.h" #include "joints/cone_twist_joint_sw.h" #include "joints/generic_6dof_joint_sw.h" #include "joints/hinge_joint_sw.h" #include "joints/pin_joint_sw.h" #include "joints/slider_joint_sw.h" -#include "os/os.h" -#include "script_language.h" RID PhysicsServerSW::shape_create(ShapeType p_shape) { diff --git a/servers/physics/shape_sw.cpp b/servers/physics/shape_sw.cpp index 9d2e5e846d..e1c985f44f 100644 --- a/servers/physics/shape_sw.cpp +++ b/servers/physics/shape_sw.cpp @@ -30,9 +30,9 @@ #include "shape_sw.h" -#include "geometry.h" -#include "quick_hull.h" -#include "sort.h" +#include "core/math/geometry.h" +#include "core/math/quick_hull.h" +#include "core/sort.h" #define _POINT_SNAP 0.001953125 #define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.0002 diff --git a/servers/physics/shape_sw.h b/servers/physics/shape_sw.h index 7be818b23c..073d19e317 100644 --- a/servers/physics/shape_sw.h +++ b/servers/physics/shape_sw.h @@ -31,8 +31,8 @@ #ifndef SHAPE_SW_H #define SHAPE_SW_H -#include "bsp_tree.h" -#include "geometry.h" +#include "core/math/bsp_tree.h" +#include "core/math/geometry.h" #include "servers/physics_server.h" /* diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp index b2ab7bec16..731749b8ce 100644 --- a/servers/physics/space_sw.cpp +++ b/servers/physics/space_sw.cpp @@ -31,8 +31,8 @@ #include "space_sw.h" #include "collision_solver_sw.h" +#include "core/project_settings.h" #include "physics_server_sw.h" -#include "project_settings.h" _FORCE_INLINE_ static bool _can_collide_with(CollisionObjectSW *p_object, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { @@ -105,7 +105,7 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vecto int amount = space->broadphase->cull_segment(begin, end, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); - //todo, create another array tha references results, compute AABBs and check closest point to ray origin, sort, and stop evaluating results when beyond first collision + //todo, create another array that references results, compute AABBs and check closest point to ray origin, sort, and stop evaluating results when beyond first collision bool collided = false; Vector3 res_point, res_normal; diff --git a/servers/physics/space_sw.h b/servers/physics/space_sw.h index e7231df532..d550b374e3 100644 --- a/servers/physics/space_sw.h +++ b/servers/physics/space_sw.h @@ -37,9 +37,9 @@ #include "body_sw.h" #include "broad_phase_sw.h" #include "collision_object_sw.h" -#include "hash_map.h" -#include "project_settings.h" -#include "typedefs.h" +#include "core/hash_map.h" +#include "core/project_settings.h" +#include "core/typedefs.h" class PhysicsDirectSpaceStateSW : public PhysicsDirectSpaceState { diff --git a/servers/physics/step_sw.cpp b/servers/physics/step_sw.cpp index 4128e1ec1a..5238f24b20 100644 --- a/servers/physics/step_sw.cpp +++ b/servers/physics/step_sw.cpp @@ -31,7 +31,7 @@ #include "step_sw.h" #include "joints_sw.h" -#include "os/os.h" +#include "core/os/os.h" void StepSW::_populate_island(BodySW *p_body, BodySW **p_island, ConstraintSW **p_constraint_island) { diff --git a/servers/physics_2d/area_2d_sw.h b/servers/physics_2d/area_2d_sw.h index d2058ad5af..90e30f68bc 100644 --- a/servers/physics_2d/area_2d_sw.h +++ b/servers/physics_2d/area_2d_sw.h @@ -32,7 +32,7 @@ #define AREA_2D_SW_H #include "collision_object_2d_sw.h" -#include "self_list.h" +#include "core/self_list.h" #include "servers/physics_2d_server.h" //#include "servers/physics/query_sw.h" diff --git a/servers/physics_2d/body_2d_sw.h b/servers/physics_2d/body_2d_sw.h index 69184ad484..97dff69a20 100644 --- a/servers/physics_2d/body_2d_sw.h +++ b/servers/physics_2d/body_2d_sw.h @@ -33,7 +33,7 @@ #include "area_2d_sw.h" #include "collision_object_2d_sw.h" -#include "vset.h" +#include "core/vset.h" class Constraint2DSW; diff --git a/servers/physics_2d/broad_phase_2d_basic.h b/servers/physics_2d/broad_phase_2d_basic.h index f0f0b3df88..da5dc38b8e 100644 --- a/servers/physics_2d/broad_phase_2d_basic.h +++ b/servers/physics_2d/broad_phase_2d_basic.h @@ -31,7 +31,7 @@ #ifndef BROAD_PHASE_2D_BASIC_H #define BROAD_PHASE_2D_BASIC_H -#include "map.h" +#include "core/map.h" #include "space_2d_sw.h" class BroadPhase2DBasic : public BroadPhase2DSW { diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.cpp b/servers/physics_2d/broad_phase_2d_hash_grid.cpp index 1a5b2d5e3a..950f0f9d24 100644 --- a/servers/physics_2d/broad_phase_2d_hash_grid.cpp +++ b/servers/physics_2d/broad_phase_2d_hash_grid.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "broad_phase_2d_hash_grid.h" -#include "project_settings.h" +#include "core/project_settings.h" #define LARGE_ELEMENT_FI 1.01239812 diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.h b/servers/physics_2d/broad_phase_2d_hash_grid.h index 5188abc837..0ecb915a7b 100644 --- a/servers/physics_2d/broad_phase_2d_hash_grid.h +++ b/servers/physics_2d/broad_phase_2d_hash_grid.h @@ -32,7 +32,7 @@ #define BROAD_PHASE_2D_HASH_GRID_H #include "broad_phase_2d_sw.h" -#include "map.h" +#include "core/map.h" class BroadPhase2DHashGrid : public BroadPhase2DSW { diff --git a/servers/physics_2d/broad_phase_2d_sw.h b/servers/physics_2d/broad_phase_2d_sw.h index d7d236c4c6..5b512dac76 100644 --- a/servers/physics_2d/broad_phase_2d_sw.h +++ b/servers/physics_2d/broad_phase_2d_sw.h @@ -31,8 +31,8 @@ #ifndef BROAD_PHASE_2D_SW_H #define BROAD_PHASE_2D_SW_H -#include "math_funcs.h" -#include "rect2.h" +#include "core/math/math_funcs.h" +#include "core/math/rect2.h" class CollisionObject2DSW; diff --git a/servers/physics_2d/collision_object_2d_sw.h b/servers/physics_2d/collision_object_2d_sw.h index 393c4a6ed7..f2b2363499 100644 --- a/servers/physics_2d/collision_object_2d_sw.h +++ b/servers/physics_2d/collision_object_2d_sw.h @@ -32,7 +32,7 @@ #define COLLISION_OBJECT_2D_SW_H #include "broad_phase_2d_sw.h" -#include "self_list.h" +#include "core/self_list.h" #include "servers/physics_2d_server.h" #include "shape_2d_sw.h" @@ -112,23 +112,23 @@ public: _FORCE_INLINE_ int get_shape_count() const { return shapes.size(); } _FORCE_INLINE_ Shape2DSW *get_shape(int p_index) const { - ERR_FAIL_INDEX_V(p_index, shapes.size(), NULL); + CRASH_BAD_INDEX(p_index, shapes.size()); return shapes[p_index].shape; } _FORCE_INLINE_ const Transform2D &get_shape_transform(int p_index) const { - ERR_FAIL_INDEX_V(p_index, shapes.size(), Transform2D()); + CRASH_BAD_INDEX(p_index, shapes.size()); return shapes[p_index].xform; } _FORCE_INLINE_ const Transform2D &get_shape_inv_transform(int p_index) const { - ERR_FAIL_INDEX_V(p_index, shapes.size(), Transform2D()); + CRASH_BAD_INDEX(p_index, shapes.size()); return shapes[p_index].xform_inv; } _FORCE_INLINE_ const Rect2 &get_shape_aabb(int p_index) const { - ERR_FAIL_INDEX_V(p_index, shapes.size(), Rect2()); + CRASH_BAD_INDEX(p_index, shapes.size()); return shapes[p_index].aabb_cache; } _FORCE_INLINE_ const Variant &get_shape_metadata(int p_index) const { - ERR_FAIL_INDEX_V(p_index, shapes.size(), Variant()); + CRASH_BAD_INDEX(p_index, shapes.size()); return shapes[p_index].metadata; } @@ -138,16 +138,16 @@ public: void set_shape_as_disabled(int p_idx, bool p_disabled); _FORCE_INLINE_ bool is_shape_set_as_disabled(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, shapes.size(), false); + CRASH_BAD_INDEX(p_idx, shapes.size()); return shapes[p_idx].disabled; } _FORCE_INLINE_ void set_shape_as_one_way_collision(int p_idx, bool p_one_way_collision) { - ERR_FAIL_INDEX(p_idx, shapes.size()); + CRASH_BAD_INDEX(p_idx, shapes.size()); shapes.write[p_idx].one_way_collision = p_one_way_collision; } _FORCE_INLINE_ bool is_shape_set_as_one_way_collision(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, shapes.size(), false); + CRASH_BAD_INDEX(p_idx, shapes.size()); return shapes[p_idx].one_way_collision; } diff --git a/servers/physics_2d/collision_solver_2d_sat.cpp b/servers/physics_2d/collision_solver_2d_sat.cpp index 98fe4adb80..0f32f2ec85 100644 --- a/servers/physics_2d/collision_solver_2d_sat.cpp +++ b/servers/physics_2d/collision_solver_2d_sat.cpp @@ -30,7 +30,7 @@ #include "collision_solver_2d_sat.h" -#include "geometry.h" +#include "core/math/geometry.h" struct _CollectorCallback2D { diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp index 721f21fc40..000e38c4a2 100644 --- a/servers/physics_2d/physics_2d_server_sw.cpp +++ b/servers/physics_2d/physics_2d_server_sw.cpp @@ -32,9 +32,9 @@ #include "broad_phase_2d_basic.h" #include "broad_phase_2d_hash_grid.h" #include "collision_solver_2d_sw.h" -#include "os/os.h" -#include "project_settings.h" -#include "script_language.h" +#include "core/os/os.h" +#include "core/project_settings.h" +#include "core/script_language.h" RID Physics2DServerSW::_shape_create(ShapeType p_shape) { diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.cpp b/servers/physics_2d/physics_2d_server_wrap_mt.cpp index 804b93ecd8..3ded4b717a 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.cpp +++ b/servers/physics_2d/physics_2d_server_wrap_mt.cpp @@ -30,7 +30,7 @@ #include "physics_2d_server_wrap_mt.h" -#include "os/os.h" +#include "core/os/os.h" void Physics2DServerWrapMT::thread_exit() { diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_2d_server_wrap_mt.h index 6b34fb9739..5f5fd3866f 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.h +++ b/servers/physics_2d/physics_2d_server_wrap_mt.h @@ -31,9 +31,9 @@ #ifndef PHYSICS2DSERVERWRAPMT_H #define PHYSICS2DSERVERWRAPMT_H -#include "command_queue_mt.h" -#include "os/thread.h" -#include "project_settings.h" +#include "core/command_queue_mt.h" +#include "core/os/thread.h" +#include "core/project_settings.h" #include "servers/physics_2d_server.h" #ifdef DEBUG_SYNC diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp index dc8ec23e69..94b0a0a0c7 100644 --- a/servers/physics_2d/shape_2d_sw.cpp +++ b/servers/physics_2d/shape_2d_sw.cpp @@ -30,8 +30,8 @@ #include "shape_2d_sw.h" -#include "geometry.h" -#include "sort.h" +#include "core/math/geometry.h" +#include "core/sort.h" void Shape2DSW::configure(const Rect2 &p_aabb) { aabb = p_aabb; diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index 746aa2d49b..f36328c985 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -31,7 +31,7 @@ #include "space_2d_sw.h" #include "collision_solver_2d_sw.h" -#include "pair.h" +#include "core/pair.h" #include "physics_2d_server_sw.h" _FORCE_INLINE_ static bool _can_collide_with(CollisionObject2DSW *p_object, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { @@ -112,7 +112,7 @@ bool Physics2DDirectSpaceStateSW::intersect_ray(const Vector2 &p_from, const Vec int amount = space->broadphase->cull_segment(begin, end, space->intersection_query_results, Space2DSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); - //todo, create another array tha references results, compute AABBs and check closest point to ray origin, sort, and stop evaluating results when beyond first collision + //todo, create another array that references results, compute AABBs and check closest point to ray origin, sort, and stop evaluating results when beyond first collision bool collided = false; Vector2 res_point, res_normal; diff --git a/servers/physics_2d/space_2d_sw.h b/servers/physics_2d/space_2d_sw.h index 6e2e025185..c894eb9c40 100644 --- a/servers/physics_2d/space_2d_sw.h +++ b/servers/physics_2d/space_2d_sw.h @@ -37,9 +37,9 @@ #include "body_pair_2d_sw.h" #include "broad_phase_2d_sw.h" #include "collision_object_2d_sw.h" -#include "hash_map.h" -#include "project_settings.h" -#include "typedefs.h" +#include "core/hash_map.h" +#include "core/project_settings.h" +#include "core/typedefs.h" class Physics2DDirectSpaceStateSW : public Physics2DDirectSpaceState { diff --git a/servers/physics_2d/step_2d_sw.cpp b/servers/physics_2d/step_2d_sw.cpp index d1078f1506..0fb7af0c94 100644 --- a/servers/physics_2d/step_2d_sw.cpp +++ b/servers/physics_2d/step_2d_sw.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "step_2d_sw.h" -#include "os/os.h" +#include "core/os/os.h" void Step2DSW::_populate_island(Body2DSW *p_body, Body2DSW **p_island, Constraint2DSW **p_constraint_island) { diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp index a51b938541..3ca6e29f0b 100644 --- a/servers/physics_2d_server.cpp +++ b/servers/physics_2d_server.cpp @@ -29,9 +29,10 @@ /*************************************************************************/ #include "physics_2d_server.h" + #include "core/method_bind_ext.gen.inc" +#include "core/print_string.h" #include "core/project_settings.h" -#include "print_string.h" Physics2DServer *Physics2DServer::singleton = NULL; @@ -291,6 +292,8 @@ Dictionary Physics2DDirectSpaceState::_intersect_ray(const Vector2 &p_from, cons Array Physics2DDirectSpaceState::_intersect_shape(const Ref<Physics2DShapeQueryParameters> &p_shape_query, int p_max_results) { + ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); + Vector<ShapeResult> sr; sr.resize(p_max_results); int rc = intersect_shape(p_shape_query->shape, p_shape_query->transform, p_shape_query->motion, p_shape_query->margin, sr.ptrw(), sr.size(), p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas); @@ -312,6 +315,8 @@ Array Physics2DDirectSpaceState::_intersect_shape(const Ref<Physics2DShapeQueryP Array Physics2DDirectSpaceState::_cast_motion(const Ref<Physics2DShapeQueryParameters> &p_shape_query) { + ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); + float closest_safe, closest_unsafe; bool res = cast_motion(p_shape_query->shape, p_shape_query->transform, p_shape_query->motion, p_shape_query->margin, closest_safe, closest_unsafe, p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas); if (!res) @@ -353,6 +358,8 @@ Array Physics2DDirectSpaceState::_intersect_point(const Vector2 &p_point, int p_ Array Physics2DDirectSpaceState::_collide_shape(const Ref<Physics2DShapeQueryParameters> &p_shape_query, int p_max_results) { + ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); + Vector<Vector2> ret; ret.resize(p_max_results * 2); int rc = 0; @@ -367,6 +374,8 @@ Array Physics2DDirectSpaceState::_collide_shape(const Ref<Physics2DShapeQueryPar } Dictionary Physics2DDirectSpaceState::_get_rest_info(const Ref<Physics2DShapeQueryParameters> &p_shape_query) { + ERR_FAIL_COND_V(!p_shape_query.is_valid(), Dictionary()); + ShapeRestInfo sri; bool res = rest_info(p_shape_query->shape, p_shape_query->transform, p_shape_query->motion, p_shape_query->margin, &sri, p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas); @@ -396,7 +405,6 @@ void Physics2DDirectSpaceState::_bind_methods() { ClassDB::bind_method(D_METHOD("cast_motion", "shape"), &Physics2DDirectSpaceState::_cast_motion); ClassDB::bind_method(D_METHOD("collide_shape", "shape", "max_results"), &Physics2DDirectSpaceState::_collide_shape, DEFVAL(32)); ClassDB::bind_method(D_METHOD("get_rest_info", "shape"), &Physics2DDirectSpaceState::_get_rest_info); - //ClassDB::bind_method(D_METHOD("cast_motion","shape","xform","motion","exclude","umask"),&Physics2DDirectSpaceState::_intersect_shape,DEFVAL(Array()),DEFVAL(0)); } int Physics2DShapeQueryResult::get_result_count() const { @@ -434,10 +442,6 @@ void Physics2DShapeQueryResult::_bind_methods() { /////////////////////////////// -/*bool Physics2DTestMotionResult::is_colliding() const { - - return colliding; -}*/ Vector2 Physics2DTestMotionResult::get_motion() const { return result.motion; @@ -479,7 +483,6 @@ int Physics2DTestMotionResult::get_collider_shape() const { void Physics2DTestMotionResult::_bind_methods() { - //ClassDB::bind_method(D_METHOD("is_colliding"),&Physics2DTestMotionResult::is_colliding); ClassDB::bind_method(D_METHOD("get_motion"), &Physics2DTestMotionResult::get_motion); ClassDB::bind_method(D_METHOD("get_motion_remainder"), &Physics2DTestMotionResult::get_motion_remainder); ClassDB::bind_method(D_METHOD("get_collision_point"), &Physics2DTestMotionResult::get_collision_point); @@ -628,7 +631,6 @@ void Physics2DServer::_bind_methods() { ClassDB::bind_method(D_METHOD("body_add_collision_exception", "body", "excepted_body"), &Physics2DServer::body_add_collision_exception); ClassDB::bind_method(D_METHOD("body_remove_collision_exception", "body", "excepted_body"), &Physics2DServer::body_remove_collision_exception); - //virtual void body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions)=0; ClassDB::bind_method(D_METHOD("body_set_max_contacts_reported", "body", "amount"), &Physics2DServer::body_set_max_contacts_reported); ClassDB::bind_method(D_METHOD("body_get_max_contacts_reported", "body"), &Physics2DServer::body_get_max_contacts_reported); @@ -662,11 +664,6 @@ void Physics2DServer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &Physics2DServer::get_process_info); - //ClassDB::bind_method(D_METHOD("init"),&Physics2DServer::init); - //ClassDB::bind_method(D_METHOD("step"),&Physics2DServer::step); - //ClassDB::bind_method(D_METHOD("sync"),&Physics2DServer::sync); - //ClassDB::bind_method(D_METHOD("flush_queries"),&Physics2DServer::flush_queries); - BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_RECYCLE_RADIUS); BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_MAX_SEPARATION); BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION); @@ -736,9 +733,6 @@ void Physics2DServer::_bind_methods() { BIND_ENUM_CONSTANT(CCD_MODE_CAST_RAY); BIND_ENUM_CONSTANT(CCD_MODE_CAST_SHAPE); - //BIND_ENUM_CONSTANT( TYPE_BODY ); - //BIND_ENUM_CONSTANT( TYPE_AREA ); - BIND_ENUM_CONSTANT(AREA_BODY_ADDED); BIND_ENUM_CONSTANT(AREA_BODY_REMOVED); @@ -749,7 +743,6 @@ void Physics2DServer::_bind_methods() { Physics2DServer::Physics2DServer() { - //ERR_FAIL_COND( singleton!=NULL ); singleton = this; } diff --git a/servers/physics_2d_server.h b/servers/physics_2d_server.h index 82b4eb75d8..7c23fcdaea 100644 --- a/servers/physics_2d_server.h +++ b/servers/physics_2d_server.h @@ -31,9 +31,9 @@ #ifndef PHYSICS_2D_SERVER_H #define PHYSICS_2D_SERVER_H -#include "object.h" -#include "reference.h" -#include "resource.h" +#include "core/object.h" +#include "core/reference.h" +#include "core/resource.h" class Physics2DDirectSpaceState; @@ -372,7 +372,6 @@ public: BODY_MODE_KINEMATIC, BODY_MODE_RIGID, BODY_MODE_CHARACTER - //BODY_MODE_SOFT ?? }; virtual RID body_create() = 0; @@ -581,9 +580,7 @@ public: INFO_ACTIVE_OBJECTS, INFO_COLLISION_PAIRS, - INFO_ISLAND_COUNT, - INFO_STEP_TIME, - INFO_BROAD_PHASE_TIME + INFO_ISLAND_COUNT }; virtual int get_process_info(ProcessInfo p_info) = 0; diff --git a/servers/physics_server.cpp b/servers/physics_server.cpp index deb3cd9bbe..888e16e0c3 100644 --- a/servers/physics_server.cpp +++ b/servers/physics_server.cpp @@ -30,9 +30,9 @@ #include "physics_server.h" +#include "core/method_bind_ext.gen.inc" +#include "core/print_string.h" #include "core/project_settings.h" -#include "method_bind_ext.gen.inc" -#include "print_string.h" PhysicsServer *PhysicsServer::singleton = NULL; @@ -260,36 +260,6 @@ PhysicsShapeQueryParameters::PhysicsShapeQueryParameters() { ///////////////////////////////////// -/* -Variant PhysicsDirectSpaceState::_intersect_shape(const RID& p_shape, const Transform& p_xform,int p_result_max,const Vector<RID>& p_exclude,uint32_t p_collision_mask) { - - - - ERR_FAIL_INDEX_V(p_result_max,4096,Variant()); - if (p_result_max<=0) - return Variant(); - - Set<RID> exclude; - for(int i=0;i<p_exclude.size();i++) - exclude.insert(p_exclude[i]); - - ShapeResult *res=(ShapeResult*)alloca(p_result_max*sizeof(ShapeResult)); - - int rc = intersect_shape(p_shape,p_xform,0,res,p_result_max,exclude); - - if (rc==0) - return Variant(); - - Ref<PhysicsShapeQueryResult> result = memnew( PhysicsShapeQueryResult ); - result->result.resize(rc); - for(int i=0;i<rc;i++) - result->result[i]=res[i]; - - return result; - -} -*/ - Dictionary PhysicsDirectSpaceState::_intersect_ray(const Vector3 &p_from, const Vector3 &p_to, const Vector<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { RayResult inters; @@ -315,6 +285,8 @@ Dictionary PhysicsDirectSpaceState::_intersect_ray(const Vector3 &p_from, const Array PhysicsDirectSpaceState::_intersect_shape(const Ref<PhysicsShapeQueryParameters> &p_shape_query, int p_max_results) { + ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); + Vector<ShapeResult> sr; sr.resize(p_max_results); int rc = intersect_shape(p_shape_query->shape, p_shape_query->transform, p_shape_query->margin, sr.ptrw(), sr.size(), p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas); @@ -335,6 +307,8 @@ Array PhysicsDirectSpaceState::_intersect_shape(const Ref<PhysicsShapeQueryParam Array PhysicsDirectSpaceState::_cast_motion(const Ref<PhysicsShapeQueryParameters> &p_shape_query, const Vector3 &p_motion) { + ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); + float closest_safe, closest_unsafe; bool res = cast_motion(p_shape_query->shape, p_shape_query->transform, p_motion, p_shape_query->margin, closest_safe, closest_unsafe, p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas); if (!res) @@ -347,6 +321,8 @@ Array PhysicsDirectSpaceState::_cast_motion(const Ref<PhysicsShapeQueryParameter } Array PhysicsDirectSpaceState::_collide_shape(const Ref<PhysicsShapeQueryParameters> &p_shape_query, int p_max_results) { + ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); + Vector<Vector3> ret; ret.resize(p_max_results * 2); int rc = 0; @@ -361,6 +337,8 @@ Array PhysicsDirectSpaceState::_collide_shape(const Ref<PhysicsShapeQueryParamet } Dictionary PhysicsDirectSpaceState::_get_rest_info(const Ref<PhysicsShapeQueryParameters> &p_shape_query) { + ERR_FAIL_COND_V(!p_shape_query.is_valid(), Dictionary()); + ShapeRestInfo sri; bool res = rest_info(p_shape_query->shape, p_shape_query->transform, p_shape_query->margin, &sri, p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas); @@ -383,9 +361,6 @@ PhysicsDirectSpaceState::PhysicsDirectSpaceState() { void PhysicsDirectSpaceState::_bind_methods() { - //ClassDB::bind_method(D_METHOD("intersect_ray","from","to","exclude","umask"),&PhysicsDirectSpaceState::_intersect_ray,DEFVAL(Array()),DEFVAL(0)); - //ClassDB::bind_method(D_METHOD("intersect_shape","shape","xform","result_max","exclude","umask"),&PhysicsDirectSpaceState::_intersect_shape,DEFVAL(Array()),DEFVAL(0)); - ClassDB::bind_method(D_METHOD("intersect_ray", "from", "to", "exclude", "collision_mask", "collide_with_bodies", "collide_with_areas"), &PhysicsDirectSpaceState::_intersect_ray, DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false)); ClassDB::bind_method(D_METHOD("intersect_shape", "shape", "max_results"), &PhysicsDirectSpaceState::_intersect_shape, DEFVAL(32)); ClassDB::bind_method(D_METHOD("cast_motion", "shape", "motion"), &PhysicsDirectSpaceState::_cast_motion); @@ -513,9 +488,6 @@ void PhysicsServer::_bind_methods() { ClassDB::bind_method(D_METHOD("body_set_enable_continuous_collision_detection", "body", "enable"), &PhysicsServer::body_set_enable_continuous_collision_detection); ClassDB::bind_method(D_METHOD("body_is_continuous_collision_detection_enabled", "body"), &PhysicsServer::body_is_continuous_collision_detection_enabled); - //ClassDB::bind_method(D_METHOD("body_set_user_flags","flags""),&PhysicsServer::body_set_shape,DEFVAL(Transform)); - //ClassDB::bind_method(D_METHOD("body_get_user_flags","body","shape_idx","shape"),&PhysicsServer::body_get_shape); - ClassDB::bind_method(D_METHOD("body_set_param", "body", "param", "value"), &PhysicsServer::body_set_param); ClassDB::bind_method(D_METHOD("body_get_param", "body", "param"), &PhysicsServer::body_get_param); @@ -539,7 +511,6 @@ void PhysicsServer::_bind_methods() { ClassDB::bind_method(D_METHOD("body_add_collision_exception", "body", "excepted_body"), &PhysicsServer::body_add_collision_exception); ClassDB::bind_method(D_METHOD("body_remove_collision_exception", "body", "excepted_body"), &PhysicsServer::body_remove_collision_exception); - //virtual void body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions)=0; ClassDB::bind_method(D_METHOD("body_set_max_contacts_reported", "body", "amount"), &PhysicsServer::body_set_max_contacts_reported); ClassDB::bind_method(D_METHOD("body_get_max_contacts_reported", "body"), &PhysicsServer::body_get_max_contacts_reported); @@ -672,28 +643,10 @@ void PhysicsServer::_bind_methods() { ClassDB::bind_method(D_METHOD("generic_6dof_joint_set_flag", "joint", "axis", "flag", "enable"), &PhysicsServer::generic_6dof_joint_set_flag); ClassDB::bind_method(D_METHOD("generic_6dof_joint_get_flag", "joint", "axis", "flag"), &PhysicsServer::generic_6dof_joint_get_flag); - /* - ClassDB::bind_method(D_METHOD("joint_set_param","joint","param","value"),&PhysicsServer::joint_set_param); - ClassDB::bind_method(D_METHOD("joint_get_param","joint","param"),&PhysicsServer::joint_get_param); - - ClassDB::bind_method(D_METHOD("pin_joint_create","anchor","body_a","body_b"),&PhysicsServer::pin_joint_create,DEFVAL(RID())); - ClassDB::bind_method(D_METHOD("groove_joint_create","groove1_a","groove2_a","anchor_b","body_a","body_b"),&PhysicsServer::groove_joint_create,DEFVAL(RID()),DEFVAL(RID())); - ClassDB::bind_method(D_METHOD("damped_spring_joint_create","anchor_a","anchor_b","body_a","body_b"),&PhysicsServer::damped_spring_joint_create,DEFVAL(RID())); - - ClassDB::bind_method(D_METHOD("damped_string_joint_set_param","joint","param","value"),&PhysicsServer::damped_string_joint_set_param,DEFVAL(RID())); - ClassDB::bind_method(D_METHOD("damped_string_joint_get_param","joint","param"),&PhysicsServer::damped_string_joint_get_param); - - ClassDB::bind_method(D_METHOD("joint_get_type","joint"),&PhysicsServer::joint_get_type); -*/ ClassDB::bind_method(D_METHOD("free_rid", "rid"), &PhysicsServer::free); ClassDB::bind_method(D_METHOD("set_active", "active"), &PhysicsServer::set_active); - //ClassDB::bind_method(D_METHOD("init"),&PhysicsServer::init); - //ClassDB::bind_method(D_METHOD("step"),&PhysicsServer::step); - //ClassDB::bind_method(D_METHOD("sync"),&PhysicsServer::sync); - //ClassDB::bind_method(D_METHOD("flush_queries"),&PhysicsServer::flush_queries); - ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &PhysicsServer::get_process_info); BIND_ENUM_CONSTANT(SHAPE_PLANE); @@ -725,7 +678,6 @@ void PhysicsServer::_bind_methods() { BIND_ENUM_CONSTANT(BODY_MODE_STATIC); BIND_ENUM_CONSTANT(BODY_MODE_KINEMATIC); BIND_ENUM_CONSTANT(BODY_MODE_RIGID); - BIND_ENUM_CONSTANT(BODY_MODE_SOFT); BIND_ENUM_CONSTANT(BODY_MODE_CHARACTER); BIND_ENUM_CONSTANT(BODY_PARAM_BOUNCE); @@ -741,17 +693,6 @@ void PhysicsServer::_bind_methods() { BIND_ENUM_CONSTANT(BODY_STATE_ANGULAR_VELOCITY); BIND_ENUM_CONSTANT(BODY_STATE_SLEEPING); BIND_ENUM_CONSTANT(BODY_STATE_CAN_SLEEP); - /* - BIND_ENUM_CONSTANT( JOINT_PIN ); - BIND_ENUM_CONSTANT( JOINT_GROOVE ); - BIND_ENUM_CONSTANT( JOINT_DAMPED_SPRING ); - - BIND_ENUM_CONSTANT( DAMPED_STRING_REST_LENGTH ); - BIND_ENUM_CONSTANT( DAMPED_STRING_STIFFNESS ); - BIND_ENUM_CONSTANT( DAMPED_STRING_DAMPING ); -*/ - //BIND_ENUM_CONSTANT( TYPE_BODY ); - //BIND_ENUM_CONSTANT( TYPE_AREA ); BIND_ENUM_CONSTANT(AREA_BODY_ADDED); BIND_ENUM_CONSTANT(AREA_BODY_REMOVED); diff --git a/servers/physics_server.h b/servers/physics_server.h index f2aa33a6cc..d80d76305a 100644 --- a/servers/physics_server.h +++ b/servers/physics_server.h @@ -31,8 +31,8 @@ #ifndef PHYSICS_SERVER_H #define PHYSICS_SERVER_H -#include "object.h" -#include "resource.h" +#include "core/object.h" +#include "core/resource.h" class PhysicsDirectSpaceState; @@ -360,7 +360,6 @@ public: BODY_MODE_STATIC, BODY_MODE_KINEMATIC, BODY_MODE_RIGID, - BODY_MODE_SOFT, BODY_MODE_CHARACTER }; diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp index 4c764641e3..7deeec676b 100644 --- a/servers/register_server_types.cpp +++ b/servers/register_server_types.cpp @@ -29,8 +29,8 @@ /*************************************************************************/ #include "register_server_types.h" -#include "engine.h" -#include "project_settings.h" +#include "core/engine.h" +#include "core/project_settings.h" #include "arvr/arvr_interface.h" #include "arvr/arvr_positional_tracker.h" @@ -52,12 +52,12 @@ #include "audio/effects/audio_effect_reverb.h" #include "audio/effects/audio_effect_stereo_enhance.h" #include "audio_server.h" +#include "core/script_debugger_remote.h" #include "physics/physics_server_sw.h" #include "physics_2d/physics_2d_server_sw.h" #include "physics_2d/physics_2d_server_wrap_mt.h" #include "physics_2d_server.h" #include "physics_server.h" -#include "script_debugger_remote.h" #include "visual/shader_types.h" #include "visual_server.h" diff --git a/servers/visual/SCsub b/servers/visual/SCsub index ccc76e823f..d730144861 100644 --- a/servers/visual/SCsub +++ b/servers/visual/SCsub @@ -3,5 +3,3 @@ Import('env') env.add_source_files(env.servers_sources, "*.cpp") - -Export('env') diff --git a/servers/visual/default_mouse_cursor.xpm b/servers/visual/default_mouse_cursor.xpm deleted file mode 100644 index 37d437dd15..0000000000 --- a/servers/visual/default_mouse_cursor.xpm +++ /dev/null @@ -1,23 +0,0 @@ -/* XPM */ -static const char * default_mouse_cursor_xpm[] = { -"16 16 4 1", -" c None", -". c #000000", -"+ c #FF00FF", -"@ c #FFFFFF", -"...+++++++++++++", -".@...+++++++++++", -".@@@...+++++++++", -".@@@@@....++++++", -".@@@@@@@@...++++", -".@@@@@@@@@@...++", -".@@@@@@@@@@@@..+", -".@@@@@@@@@@@@@..", -".@@@@@@@@@@@@..+", -".@@@@@@@@@@@..++", -".@@@@@@@@@...+++", -".@@@.....@@..+++", -".....+++.@@@..++", -"++++++++..@@@..+", -"+++++++++..@@@.+", -"++++++++++.....+"}; diff --git a/servers/visual/rasterizer.cpp b/servers/visual/rasterizer.cpp index be46690e55..6c04d1de63 100644 --- a/servers/visual/rasterizer.cpp +++ b/servers/visual/rasterizer.cpp @@ -30,8 +30,8 @@ #include "rasterizer.h" -#include "os/os.h" -#include "print_string.h" +#include "core/os/os.h" +#include "core/print_string.h" Rasterizer *(*Rasterizer::_create_func)() = NULL; diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 49dff0d557..207f13ac1a 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -31,10 +31,10 @@ #ifndef RASTERIZER_H #define RASTERIZER_H -#include "camera_matrix.h" +#include "core/math/camera_matrix.h" #include "servers/visual_server.h" -#include "self_list.h" +#include "core/self_list.h" class RasterizerScene { public: @@ -249,6 +249,7 @@ public: virtual void material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) = 0; virtual Variant material_get_param(RID p_material, const StringName &p_param) const = 0; + virtual Variant material_get_param_default(RID p_material, const StringName &p_param) const = 0; virtual void material_set_line_width(RID p_material, float p_width) = 0; @@ -396,6 +397,7 @@ public: virtual RID reflection_probe_create() = 0; virtual void reflection_probe_set_update_mode(RID p_probe, VS::ReflectionProbeUpdateMode p_mode) = 0; + virtual void reflection_probe_set_resolution(RID p_probe, int p_resolution) = 0; virtual void reflection_probe_set_intensity(RID p_probe, float p_intensity) = 0; virtual void reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient) = 0; virtual void reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy) = 0; @@ -836,6 +838,7 @@ public: bool clip; bool visible; bool behind; + bool update_when_visible; //VS::MaterialBlendMode blend_mode; int light_mask; Vector<Command *> commands; @@ -1037,6 +1040,7 @@ public: copy_back_buffer = NULL; distance_field = false; light_masked = false; + update_when_visible = false; } virtual ~Item() { clear(); @@ -1103,6 +1107,8 @@ public: virtual void end_frame(bool p_swap_buffers) = 0; virtual void finalize() = 0; + virtual bool is_low_end() const = 0; + virtual ~Rasterizer() {} }; diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index ffb130048f..67a810bf1c 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -29,8 +29,8 @@ /*************************************************************************/ #include "shader_language.h" -#include "os/os.h" -#include "print_string.h" +#include "core/os/os.h" +#include "core/print_string.h" static bool _is_text_char(CharType c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_'; @@ -1622,33 +1622,51 @@ const ShaderLanguage::BuiltinFuncDef ShaderLanguage::builtin_func_defs[] = { { "min", TYPE_FLOAT, { TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } }, { "min", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } }, + { "min", TYPE_VEC2, { TYPE_VEC2, TYPE_FLOAT, TYPE_VOID } }, { "min", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } }, + { "min", TYPE_VEC3, { TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, { "min", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VOID } }, + { "min", TYPE_VEC4, { TYPE_VEC4, TYPE_FLOAT, TYPE_VOID } }, { "min", TYPE_INT, { TYPE_INT, TYPE_INT, TYPE_VOID } }, { "min", TYPE_IVEC2, { TYPE_IVEC2, TYPE_IVEC2, TYPE_VOID } }, + { "min", TYPE_IVEC2, { TYPE_IVEC2, TYPE_INT, TYPE_VOID } }, { "min", TYPE_IVEC3, { TYPE_IVEC3, TYPE_IVEC3, TYPE_VOID } }, + { "min", TYPE_IVEC3, { TYPE_IVEC3, TYPE_INT, TYPE_VOID } }, { "min", TYPE_IVEC4, { TYPE_IVEC4, TYPE_IVEC4, TYPE_VOID } }, + { "min", TYPE_IVEC4, { TYPE_IVEC4, TYPE_INT, TYPE_VOID } }, { "min", TYPE_UINT, { TYPE_UINT, TYPE_UINT, TYPE_VOID } }, { "min", TYPE_UVEC2, { TYPE_UVEC2, TYPE_UVEC2, TYPE_VOID } }, + { "min", TYPE_UVEC2, { TYPE_UVEC2, TYPE_UINT, TYPE_VOID } }, { "min", TYPE_UVEC3, { TYPE_UVEC3, TYPE_UVEC3, TYPE_VOID } }, + { "min", TYPE_UVEC3, { TYPE_UVEC3, TYPE_UINT, TYPE_VOID } }, { "min", TYPE_UVEC4, { TYPE_UVEC4, TYPE_UVEC4, TYPE_VOID } }, + { "min", TYPE_UVEC4, { TYPE_UVEC4, TYPE_UINT, TYPE_VOID } }, { "max", TYPE_FLOAT, { TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } }, { "max", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } }, + { "max", TYPE_VEC2, { TYPE_VEC2, TYPE_FLOAT, TYPE_VOID } }, { "max", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } }, + { "max", TYPE_VEC3, { TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, { "max", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VOID } }, + { "max", TYPE_VEC4, { TYPE_VEC4, TYPE_FLOAT, TYPE_VOID } }, { "max", TYPE_INT, { TYPE_INT, TYPE_INT, TYPE_VOID } }, { "max", TYPE_IVEC2, { TYPE_IVEC2, TYPE_IVEC2, TYPE_VOID } }, + { "max", TYPE_IVEC2, { TYPE_IVEC2, TYPE_INT, TYPE_VOID } }, { "max", TYPE_IVEC3, { TYPE_IVEC3, TYPE_IVEC3, TYPE_VOID } }, + { "max", TYPE_IVEC3, { TYPE_IVEC3, TYPE_INT, TYPE_VOID } }, { "max", TYPE_IVEC4, { TYPE_IVEC4, TYPE_IVEC4, TYPE_VOID } }, + { "max", TYPE_IVEC4, { TYPE_IVEC4, TYPE_INT, TYPE_VOID } }, { "max", TYPE_UINT, { TYPE_UINT, TYPE_UINT, TYPE_VOID } }, { "max", TYPE_UVEC2, { TYPE_UVEC2, TYPE_UVEC2, TYPE_VOID } }, + { "max", TYPE_UVEC2, { TYPE_UVEC2, TYPE_UINT, TYPE_VOID } }, { "max", TYPE_UVEC3, { TYPE_UVEC3, TYPE_UVEC3, TYPE_VOID } }, + { "max", TYPE_UVEC3, { TYPE_UVEC3, TYPE_UINT, TYPE_VOID } }, { "max", TYPE_UVEC4, { TYPE_UVEC4, TYPE_UVEC4, TYPE_VOID } }, + { "max", TYPE_UVEC4, { TYPE_UVEC4, TYPE_UINT, TYPE_VOID } }, { "clamp", TYPE_FLOAT, { TYPE_FLOAT, TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } }, { "clamp", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VEC2, TYPE_VOID } }, @@ -2005,10 +2023,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, OperatorNode *p StringName name = static_cast<VariableNode *>(p_func->arguments[0])->name.operator String(); - bool all_const = true; for (int i = 1; i < p_func->arguments.size(); i++) { - if (p_func->arguments[i]->type != Node::TYPE_CONSTANT) - all_const = false; args.push_back(p_func->arguments[i]->get_datatype()); } @@ -2273,6 +2288,105 @@ bool ShaderLanguage::is_sampler_type(DataType p_type) { p_type == TYPE_SAMPLERCUBE; } +Variant ShaderLanguage::constant_value_to_variant(const Vector<ShaderLanguage::ConstantNode::Value> &p_value, DataType p_type) { + if (p_value.size() > 0) { + Variant value; + switch (p_type) { + case ShaderLanguage::TYPE_BOOL: + value = Variant(p_value[0].boolean); + break; + case ShaderLanguage::TYPE_BVEC2: + case ShaderLanguage::TYPE_BVEC3: + case ShaderLanguage::TYPE_BVEC4: + case ShaderLanguage::TYPE_INT: + value = Variant(p_value[0].sint); + break; + case ShaderLanguage::TYPE_IVEC2: + value = Variant(Vector2(p_value[0].sint, p_value[1].sint)); + break; + case ShaderLanguage::TYPE_IVEC3: + value = Variant(Vector3(p_value[0].sint, p_value[1].sint, p_value[2].sint)); + break; + case ShaderLanguage::TYPE_IVEC4: + value = Variant(Plane(p_value[0].sint, p_value[1].sint, p_value[2].sint, p_value[3].sint)); + break; + case ShaderLanguage::TYPE_UINT: + value = Variant(p_value[0].uint); + break; + case ShaderLanguage::TYPE_UVEC2: + value = Variant(Vector2(p_value[0].uint, p_value[1].uint)); + break; + case ShaderLanguage::TYPE_UVEC3: + value = Variant(Vector3(p_value[0].uint, p_value[1].uint, p_value[2].uint)); + break; + case ShaderLanguage::TYPE_UVEC4: + value = Variant(Plane(p_value[0].uint, p_value[1].uint, p_value[2].uint, p_value[3].uint)); + break; + case ShaderLanguage::TYPE_FLOAT: + value = Variant(p_value[0].real); + break; + case ShaderLanguage::TYPE_VEC2: + value = Variant(Vector2(p_value[0].real, p_value[1].real)); + break; + case ShaderLanguage::TYPE_VEC3: + value = Variant(Vector3(p_value[0].real, p_value[1].real, p_value[2].real)); + break; + case ShaderLanguage::TYPE_VEC4: + value = Variant(Plane(p_value[0].real, p_value[1].real, p_value[2].real, p_value[3].real)); + break; + case ShaderLanguage::TYPE_MAT2: + value = Variant(Transform2D(p_value[0].real, p_value[2].real, p_value[1].real, p_value[3].real, 0.0, 0.0)); + break; + case ShaderLanguage::TYPE_MAT3: { + Basis p; + p[0][0] = p_value[0].real; + p[0][1] = p_value[1].real; + p[0][2] = p_value[2].real; + p[1][0] = p_value[3].real; + p[1][1] = p_value[4].real; + p[1][2] = p_value[5].real; + p[2][0] = p_value[6].real; + p[2][1] = p_value[7].real; + p[2][2] = p_value[8].real; + value = Variant(p); + break; + } + case ShaderLanguage::TYPE_MAT4: { + Basis p; + p[0][0] = p_value[0].real; + p[0][1] = p_value[1].real; + p[0][2] = p_value[2].real; + p[1][0] = p_value[4].real; + p[1][1] = p_value[5].real; + p[1][2] = p_value[6].real; + p[2][0] = p_value[8].real; + p[2][1] = p_value[9].real; + p[2][2] = p_value[10].real; + Transform t = Transform(p, Vector3(p_value[3].real, p_value[7].real, p_value[11].real)); + value = Variant(t); + break; + } + case ShaderLanguage::TYPE_ISAMPLER2DARRAY: + case ShaderLanguage::TYPE_ISAMPLER2D: + case ShaderLanguage::TYPE_ISAMPLER3D: + case ShaderLanguage::TYPE_SAMPLER2DARRAY: + case ShaderLanguage::TYPE_SAMPLER2D: + case ShaderLanguage::TYPE_SAMPLER3D: + case ShaderLanguage::TYPE_USAMPLER2DARRAY: + case ShaderLanguage::TYPE_USAMPLER2D: + case ShaderLanguage::TYPE_USAMPLER3D: + case ShaderLanguage::TYPE_SAMPLERCUBE: { + // Texture types, likely not relevant here. + break; + } + case ShaderLanguage::TYPE_VOID: + break; + } + return value; + } + return Variant(); +} + void ShaderLanguage::get_keyword_list(List<String> *r_keywords) { Set<String> kws; @@ -2368,9 +2482,9 @@ int ShaderLanguage::get_cardinality(DataType p_type) { 2, 3, 4, - 2, - 3, 4, + 9, + 16, 1, 1, 1, @@ -2906,6 +3020,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons case TYPE_IVEC2: member_type = TYPE_INT; break; case TYPE_UVEC2: member_type = TYPE_UINT; break; case TYPE_MAT2: member_type = TYPE_VEC2; break; + default: break; } break; @@ -2931,6 +3046,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons case TYPE_IVEC3: member_type = TYPE_INT; break; case TYPE_UVEC3: member_type = TYPE_UINT; break; case TYPE_MAT3: member_type = TYPE_VEC3; break; + default: break; } break; case TYPE_BVEC4: @@ -2955,6 +3071,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons case TYPE_IVEC4: member_type = TYPE_INT; break; case TYPE_UVEC4: member_type = TYPE_UINT; break; case TYPE_MAT4: member_type = TYPE_VEC4; break; + default: break; } break; default: { @@ -3307,7 +3424,9 @@ ShaderLanguage::Node *ShaderLanguage::_reduce_expression(BlockNode *p_block, Sha ERR_FAIL_COND_V(op->arguments[0]->type != Node::TYPE_VARIABLE, p_node); - DataType base = get_scalar_type(op->get_datatype()); + DataType type = op->get_datatype(); + DataType base = get_scalar_type(type); + int cardinality = get_cardinality(type); Vector<ConstantNode::Value> values; @@ -3318,19 +3437,9 @@ ShaderLanguage::Node *ShaderLanguage::_reduce_expression(BlockNode *p_block, Sha ConstantNode *cn = static_cast<ConstantNode *>(op->arguments[i]); if (get_scalar_type(cn->datatype) == base) { - - int cardinality = get_cardinality(op->arguments[i]->get_datatype()); - if (cn->values.size() == cardinality) { - - for (int j = 0; j < cn->values.size(); j++) { - values.push_back(cn->values[j]); - } - } else if (cn->values.size() == 1) { - - for (int j = 0; j < cardinality; j++) { - values.push_back(cn->values[0]); - } - } // else: should be filtered by the parser as it's an invalid constructor + for (int j = 0; j < cn->values.size(); j++) { + values.push_back(cn->values[j]); + } } else if (get_scalar_type(cn->datatype) == cn->datatype) { ConstantNode::Value v; @@ -3347,6 +3456,30 @@ ShaderLanguage::Node *ShaderLanguage::_reduce_expression(BlockNode *p_block, Sha } } + if (values.size() == 1) { + if (type >= TYPE_MAT2 && type <= TYPE_MAT4) { + ConstantNode::Value value = values[0]; + ConstantNode::Value zero; + zero.real = 0.0f; + int size = 2 + (type - TYPE_MAT2); + + values.clear(); + for (int i = 0; i < size; i++) { + for (int j = 0; j < size; j++) { + values.push_back(i == j ? value : zero); + } + } + } else { + ConstantNode::Value value = values[0]; + for (int i = 1; i < cardinality; i++) { + values.push_back(value); + } + } + } else if (values.size() != cardinality) { + ERR_PRINT("Failed to reduce expression, values and cardinality mismatch."); + return p_node; + } + ConstantNode *cn = alloc_node<ConstantNode>(); cn->datatype = op->get_datatype(); cn->values = values; diff --git a/servers/visual/shader_language.h b/servers/visual/shader_language.h index d68f233b2f..08c4d06992 100644 --- a/servers/visual/shader_language.h +++ b/servers/visual/shader_language.h @@ -31,12 +31,12 @@ #ifndef SHADER_LANGUAGE_H #define SHADER_LANGUAGE_H -#include "list.h" -#include "map.h" -#include "string_db.h" -#include "typedefs.h" -#include "ustring.h" -#include "variant.h" +#include "core/list.h" +#include "core/map.h" +#include "core/string_db.h" +#include "core/typedefs.h" +#include "core/ustring.h" +#include "core/variant.h" class ShaderLanguage { @@ -548,6 +548,7 @@ public: static int get_cardinality(DataType p_type); static bool is_scalar_type(DataType p_type); static bool is_sampler_type(DataType p_type); + static Variant constant_value_to_variant(const Vector<ShaderLanguage::ConstantNode::Value> &p_value, DataType p_type); static void get_keyword_list(List<String> *r_keywords); static void get_builtin_funcs(List<String> *r_keywords); diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp index caa454b98e..57e8d86468 100644 --- a/servers/visual/shader_types.cpp +++ b/servers/visual/shader_types.cpp @@ -78,6 +78,7 @@ ShaderTypes::ShaderTypes() { shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["INV_PROJECTION_MATRIX"] = ShaderLanguage::TYPE_MAT4; shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["VIEWPORT_SIZE"] = constt(ShaderLanguage::TYPE_VEC2); + shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["OUTPUT_IS_SRGB"] = constt(ShaderLanguage::TYPE_BOOL); shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["VERTEX"] = constt(ShaderLanguage::TYPE_VEC3); shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4); @@ -112,6 +113,8 @@ ShaderTypes::ShaderTypes() { shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["POINT_COORD"] = constt(ShaderLanguage::TYPE_VEC2); shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["ALPHA_SCISSOR"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["OUTPUT_IS_SRGB"] = constt(ShaderLanguage::TYPE_BOOL); + shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["WORLD_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["INV_CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); @@ -138,6 +141,7 @@ ShaderTypes::ShaderTypes() { shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["ROUGHNESS"] = constt(ShaderLanguage::TYPE_FLOAT); shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["DIFFUSE_LIGHT"] = ShaderLanguage::TYPE_VEC3; shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["SPECULAR_LIGHT"] = ShaderLanguage::TYPE_VEC3; + shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["OUTPUT_IS_SRGB"] = constt(ShaderLanguage::TYPE_BOOL); shader_modes[VS::SHADER_SPATIAL].functions["light"].can_discard = true; diff --git a/servers/visual/shader_types.h b/servers/visual/shader_types.h index 0680ec8242..e195b6ea20 100644 --- a/servers/visual/shader_types.h +++ b/servers/visual/shader_types.h @@ -31,7 +31,7 @@ #ifndef SHADERTYPES_H #define SHADERTYPES_H -#include "ordered_hash_map.h" +#include "core/ordered_hash_map.h" #include "servers/visual_server.h" #include "shader_language.h" diff --git a/servers/visual/visual_server_canvas.cpp b/servers/visual/visual_server_canvas.cpp index 0b4bbffddf..16cda0326d 100644 --- a/servers/visual/visual_server_canvas.cpp +++ b/servers/visual/visual_server_canvas.cpp @@ -30,6 +30,7 @@ #include "visual_server_canvas.h" #include "visual_server_global.h" +#include "visual_server_raster.h" #include "visual_server_viewport.h" void VisualServerCanvas::_render_canvas_item_tree(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, RasterizerCanvas::Light *p_lights) { @@ -119,6 +120,10 @@ void VisualServerCanvas::_render_canvas_item(Item *p_canvas_item, const Transfor ci->copy_back_buffer->screen_rect = xform.xform(ci->copy_back_buffer->rect).clip(p_clip_rect); } + if (ci->update_when_visible) { + VisualServerRaster::redraw_request(); + } + if ((!ci->commands.empty() && p_clip_rect.intersects(global_rect)) || ci->vp_render || ci->copy_back_buffer) { //something to draw? ci->final_transform = xform; @@ -390,6 +395,14 @@ void VisualServerCanvas::canvas_item_set_draw_behind_parent(RID p_item, bool p_e canvas_item->behind = p_enable; } +void VisualServerCanvas::canvas_item_set_update_when_visible(RID p_item, bool p_update) { + + Item *canvas_item = canvas_item_owner.getornull(p_item); + ERR_FAIL_COND(!canvas_item); + + canvas_item->update_when_visible = p_update; +} + void VisualServerCanvas::canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width, bool p_antialiased) { Item *canvas_item = canvas_item_owner.getornull(p_item); diff --git a/servers/visual/visual_server_canvas.h b/servers/visual/visual_server_canvas.h index 4d9398a17e..966b51d341 100644 --- a/servers/visual/visual_server_canvas.h +++ b/servers/visual/visual_server_canvas.h @@ -171,6 +171,8 @@ public: void canvas_item_set_draw_behind_parent(RID p_item, bool p_enable); + void canvas_item_set_update_when_visible(RID p_item, bool p_update); + void canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width = 1.0, bool p_antialiased = false); void canvas_item_add_polyline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width = 1.0, bool p_antialiased = false); void canvas_item_add_multiline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width = 1.0, bool p_antialiased = false); diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index c7d33ec43c..677c323216 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -30,11 +30,10 @@ #include "visual_server_raster.h" -#include "default_mouse_cursor.xpm" -#include "io/marshalls.h" -#include "os/os.h" -#include "project_settings.h" -#include "sort.h" +#include "core/io/marshalls.h" +#include "core/os/os.h" +#include "core/project_settings.h" +#include "core/sort.h" #include "visual_server_canvas.h" #include "visual_server_global.h" #include "visual_server_scene.h" @@ -190,6 +189,9 @@ void VisualServerRaster::call_set_use_vsync(bool p_enable) { OS::get_singleton()->_set_use_vsync(p_enable); } +bool VisualServerRaster::is_low_end() const { + return VSG::rasterizer->is_low_end(); +} VisualServerRaster::VisualServerRaster() { VSG::canvas = memnew(VisualServerCanvas); diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index a00b364565..62ba2eab69 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -31,8 +31,8 @@ #ifndef VISUAL_SERVER_RASTER_H #define VISUAL_SERVER_RASTER_H -#include "allocators.h" -#include "octree.h" +#include "core/allocators.h" +#include "core/math/octree.h" #include "servers/visual/rasterizer.h" #include "servers/visual_server.h" #include "visual_server_canvas.h" @@ -59,7 +59,6 @@ class VisualServerRaster : public VisualServer { }; static int changes; - bool draw_extra_frame; RID test_cube; int black_margin[4]; @@ -203,6 +202,7 @@ public: BIND3(material_set_param, RID, const StringName &, const Variant &) BIND2RC(Variant, material_get_param, RID, const StringName &) + BIND2RC(Variant, material_get_param_default, RID, const StringName &) BIND2(material_set_render_priority, RID, int) BIND2(material_set_line_width, RID, float) @@ -336,6 +336,7 @@ public: BIND2(reflection_probe_set_enable_box_projection, RID, bool) BIND2(reflection_probe_set_enable_shadows, RID, bool) BIND2(reflection_probe_set_cull_mask, RID, uint32_t) + BIND2(reflection_probe_set_resolution, RID, int) /* BAKED LIGHT API */ @@ -574,6 +575,8 @@ public: BIND2(canvas_item_set_visible, RID, bool) BIND2(canvas_item_set_light_mask, RID, int) + BIND2(canvas_item_set_update_when_visible, RID, bool) + BIND2(canvas_item_set_transform, RID, const Transform2D &) BIND2(canvas_item_set_clip, RID, bool) BIND2(canvas_item_set_distance_field_mode, RID, bool) @@ -686,6 +689,8 @@ public: virtual void call_set_use_vsync(bool p_enable); + virtual bool is_low_end() const; + VisualServerRaster(); ~VisualServerRaster(); diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index 1e255591f0..cd0702d20b 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "visual_server_scene.h" -#include "os/os.h" +#include "core/os/os.h" #include "visual_server_global.h" #include "visual_server_raster.h" /* CAMERA API */ @@ -398,6 +398,7 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) { VSG::scene_render->free(gi_probe->probe_instance); } break; + default: {} } if (instance->base_data) { @@ -471,6 +472,7 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) { gi_probe->probe_instance = VSG::scene_render->gi_probe_instance_create(); } break; + default: {} } VSG::storage->instance_add_dependency(p_base, instance); @@ -518,6 +520,7 @@ void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario) { gi_probe_update_list.remove(&gi_probe->update_element); } } break; + default: {} } instance->scenario = NULL; @@ -549,6 +552,7 @@ void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario) { gi_probe_update_list.add(&gi_probe->update_element); } } break; + default: {} } _instance_queue_update(instance, true, true); @@ -649,6 +653,7 @@ void VisualServerScene::instance_set_visible(RID p_instance, bool p_visible) { } } break; + default: {} } } inline bool is_geometry_instance(VisualServer::InstanceType p_type) { @@ -825,6 +830,7 @@ void VisualServerScene::instance_geometry_set_flag(RID p_instance, VS::InstanceF instance->redraw_if_visible = p_enabled; } break; + default: {} } } void VisualServerScene::instance_geometry_set_cast_shadows_setting(RID p_instance, VS::ShadowCastingSetting p_shadow_casting_setting) { @@ -902,7 +908,7 @@ void VisualServerScene::_update_instance(Instance *p_instance) { _update_instance_lightmap_captures(p_instance); } else { if (!p_instance->lightmap_capture_data.empty()) { - !p_instance->lightmap_capture_data.resize(0); //not in use, clear capture data + p_instance->lightmap_capture_data.resize(0); //not in use, clear capture data } } } @@ -1016,7 +1022,6 @@ void VisualServerScene::_update_instance_aabb(Instance *p_instance) { new_aabb = VSG::storage->lightmap_capture_get_bounds(p_instance->base); } break; - default: {} } @@ -1378,9 +1383,12 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons float y_min = 0.f, y_max = 0.f; float z_min = 0.f, z_max = 0.f; + // FIXME: z_max_cam is defined, computed, but not used below when setting up + // ortho_camera. Commented out for now to fix warnings but should be investigated. float x_min_cam = 0.f, x_max_cam = 0.f; float y_min_cam = 0.f, y_max_cam = 0.f; - float z_min_cam = 0.f, z_max_cam = 0.f; + float z_min_cam = 0.f; + //float z_max_cam = 0.f; float bias_scale = 1.0; @@ -1442,7 +1450,7 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons x_min_cam = x_vec.dot(center) - radius; y_max_cam = y_vec.dot(center) + radius; y_min_cam = y_vec.dot(center) - radius; - z_max_cam = z_vec.dot(center) + radius; + //z_max_cam = z_vec.dot(center) + radius; z_min_cam = z_vec.dot(center) - radius; if (depth_range_mode == VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE) { @@ -2133,6 +2141,8 @@ bool VisualServerScene::_render_reflection_probe_step(Instance *p_instance, int Scenario *scenario = p_instance->scenario; ERR_FAIL_COND_V(!scenario, true); + VisualServerRaster::redraw_request(); //update, so it updates in editor + if (p_step == 0) { if (!VSG::scene_render->reflection_probe_instance_begin_render(reflection_probe->instance, scenario->reflection_atlas)) { diff --git a/servers/visual/visual_server_scene.h b/servers/visual/visual_server_scene.h index 12d732724a..87e19bc6b0 100644 --- a/servers/visual/visual_server_scene.h +++ b/servers/visual/visual_server_scene.h @@ -33,12 +33,12 @@ #include "servers/visual/rasterizer.h" -#include "allocators.h" -#include "geometry.h" -#include "octree.h" -#include "os/semaphore.h" -#include "os/thread.h" -#include "self_list.h" +#include "core/allocators.h" +#include "core/math/geometry.h" +#include "core/math/octree.h" +#include "core/os/semaphore.h" +#include "core/os/thread.h" +#include "core/self_list.h" #include "servers/arvr/arvr_interface.h" class VisualServerScene { diff --git a/servers/visual/visual_server_viewport.cpp b/servers/visual/visual_server_viewport.cpp index 90acba306a..b286533590 100644 --- a/servers/visual/visual_server_viewport.cpp +++ b/servers/visual/visual_server_viewport.cpp @@ -30,7 +30,7 @@ #include "visual_server_viewport.h" -#include "project_settings.h" +#include "core/project_settings.h" #include "visual_server_canvas.h" #include "visual_server_global.h" #include "visual_server_scene.h" @@ -294,7 +294,7 @@ void VisualServerViewport::draw_viewports() { arvr_interface->commit_for_eye(ARVRInterface::EYE_RIGHT, vp->render_target, vp->viewport_to_screen_rect); } - // and for our frame timing, mark when we've finished commiting our eyes + // and for our frame timing, mark when we've finished committing our eyes ARVRServer::get_singleton()->_mark_commit(); } else { VSG::rasterizer->set_current_render_target(vp->render_target); diff --git a/servers/visual/visual_server_viewport.h b/servers/visual/visual_server_viewport.h index f915e26b81..978d6ae4ae 100644 --- a/servers/visual/visual_server_viewport.h +++ b/servers/visual/visual_server_viewport.h @@ -31,8 +31,8 @@ #ifndef VISUALSERVERVIEWPORT_H #define VISUALSERVERVIEWPORT_H +#include "core/self_list.h" #include "rasterizer.h" -#include "self_list.h" #include "servers/arvr/arvr_interface.h" #include "servers/visual_server.h" diff --git a/servers/visual/visual_server_wrap_mt.cpp b/servers/visual/visual_server_wrap_mt.cpp index 1cafc47685..f59d8af9cb 100644 --- a/servers/visual/visual_server_wrap_mt.cpp +++ b/servers/visual/visual_server_wrap_mt.cpp @@ -29,8 +29,8 @@ /*************************************************************************/ #include "visual_server_wrap_mt.h" -#include "os/os.h" -#include "project_settings.h" +#include "core/os/os.h" +#include "core/project_settings.h" void VisualServerWrapMT::thread_exit() { diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 3a4d72c793..e4d69121f0 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -31,8 +31,8 @@ #ifndef VISUAL_SERVER_WRAP_MT_H #define VISUAL_SERVER_WRAP_MT_H -#include "command_queue_mt.h" -#include "os/thread.h" +#include "core/command_queue_mt.h" +#include "core/os/thread.h" #include "servers/visual_server.h" /** @@ -137,6 +137,7 @@ public: FUNC3(material_set_param, RID, const StringName &, const Variant &) FUNC2RC(Variant, material_get_param, RID, const StringName &) + FUNC2RC(Variant, material_get_param_default, RID, const StringName &) FUNC2(material_set_render_priority, RID, int) FUNC2(material_set_line_width, RID, float) @@ -270,6 +271,7 @@ public: FUNC2(reflection_probe_set_enable_box_projection, RID, bool) FUNC2(reflection_probe_set_enable_shadows, RID, bool) FUNC2(reflection_probe_set_cull_mask, RID, uint32_t) + FUNC2(reflection_probe_set_resolution, RID, int) /* BAKED LIGHT API */ @@ -490,6 +492,8 @@ public: FUNC2(canvas_item_set_visible, RID, bool) FUNC2(canvas_item_set_light_mask, RID, int) + FUNC2(canvas_item_set_update_when_visible, RID, bool) + FUNC2(canvas_item_set_transform, RID, const Transform2D &) FUNC2(canvas_item_set_clip, RID, bool) FUNC2(canvas_item_set_distance_field_mode, RID, bool) @@ -605,6 +609,10 @@ public: static void set_use_vsync_callback(bool p_enable); + virtual bool is_low_end() const { + return visual_server->is_low_end(); + } + VisualServerWrapMT(VisualServer *p_contained, bool p_create_thread); ~VisualServerWrapMT(); diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 18a04e9a4b..18a239b019 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -30,8 +30,8 @@ #include "visual_server.h" -#include "method_bind_ext.gen.inc" -#include "project_settings.h" +#include "core/method_bind_ext.gen.inc" +#include "core/project_settings.h" VisualServer *VisualServer::singleton = NULL; VisualServer *(*VisualServer::create_func)() = NULL; @@ -1695,6 +1695,7 @@ void VisualServer::_bind_methods() { ClassDB::bind_method(D_METHOD("material_get_shader", "shader_material"), &VisualServer::material_get_shader); ClassDB::bind_method(D_METHOD("material_set_param", "material", "parameter", "value"), &VisualServer::material_set_param); ClassDB::bind_method(D_METHOD("material_get_param", "material", "parameter"), &VisualServer::material_get_param); + ClassDB::bind_method(D_METHOD("material_get_param_default", "material", "parameter"), &VisualServer::material_get_param_default); ClassDB::bind_method(D_METHOD("material_set_render_priority", "material", "priority"), &VisualServer::material_set_render_priority); ClassDB::bind_method(D_METHOD("material_set_line_width", "material", "width"), &VisualServer::material_set_line_width); ClassDB::bind_method(D_METHOD("material_set_next_pass", "material", "next_material"), &VisualServer::material_set_next_pass); @@ -2392,6 +2393,10 @@ VisualServer::VisualServer() { GLOBAL_DEF("rendering/quality/shading/force_vertex_shading", false); GLOBAL_DEF("rendering/quality/shading/force_vertex_shading.mobile", true); + GLOBAL_DEF("rendering/quality/shading/force_lambert_over_burley", false); + GLOBAL_DEF("rendering/quality/shading/force_lambert_over_burley.mobile", true); + GLOBAL_DEF("rendering/quality/shading/force_blinn_over_ggx", false); + GLOBAL_DEF("rendering/quality/shading/force_blinn_over_ggx.mobile", true); GLOBAL_DEF("rendering/quality/depth_prepass/enable", true); GLOBAL_DEF("rendering/quality/depth_prepass/disable_for_vendors", "PowerVR,Mali,Adreno"); diff --git a/servers/visual_server.h b/servers/visual_server.h index fd7f96339e..100bc06db6 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -31,13 +31,13 @@ #ifndef VISUAL_SERVER_H #define VISUAL_SERVER_H -#include "bsp_tree.h" -#include "geometry.h" -#include "image.h" -#include "object.h" -#include "rid.h" -#include "transform_2d.h" -#include "variant.h" +#include "core/image.h" +#include "core/math/bsp_tree.h" +#include "core/math/geometry.h" +#include "core/math/transform_2d.h" +#include "core/object.h" +#include "core/rid.h" +#include "core/variant.h" /** @author Juan Linietsky <reduzio@gmail.com> @@ -209,6 +209,7 @@ public: virtual void material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) = 0; virtual Variant material_get_param(RID p_material, const StringName &p_param) const = 0; + virtual Variant material_get_param_default(RID p_material, const StringName &p_param) const = 0; virtual void material_set_render_priority(RID p_material, int priority) = 0; @@ -489,6 +490,7 @@ public: virtual void reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) = 0; virtual void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) = 0; virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) = 0; + virtual void reflection_probe_set_resolution(RID p_probe, int p_resolution) = 0; /* GI PROBE API */ @@ -863,6 +865,8 @@ public: virtual void canvas_item_set_visible(RID p_item, bool p_visible) = 0; virtual void canvas_item_set_light_mask(RID p_item, int p_mask) = 0; + virtual void canvas_item_set_update_when_visible(RID p_item, bool p_update) = 0; + virtual void canvas_item_set_transform(RID p_item, const Transform2D &p_transform) = 0; virtual void canvas_item_set_clip(RID p_item, bool p_clip) = 0; virtual void canvas_item_set_distance_field_mode(RID p_item, bool p_enable) = 0; @@ -1033,6 +1037,8 @@ public: virtual void call_set_use_vsync(bool p_enable) = 0; + virtual bool is_low_end() const = 0; + VisualServer(); virtual ~VisualServer(); }; |