diff options
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/gibberish_stream.cpp | 337 | ||||
-rw-r--r-- | scene/resources/gibberish_stream.h | 118 | ||||
-rw-r--r-- | scene/resources/material.cpp | 1 | ||||
-rw-r--r-- | scene/resources/packed_scene.cpp | 12 | ||||
-rw-r--r-- | scene/resources/room.cpp | 3 | ||||
-rw-r--r-- | scene/resources/room.h | 4 | ||||
-rw-r--r-- | scene/resources/scene_format_text.cpp | 4 | ||||
-rw-r--r-- | scene/resources/shape.cpp | 2 | ||||
-rw-r--r-- | scene/resources/theme.cpp | 9 |
9 files changed, 20 insertions, 470 deletions
diff --git a/scene/resources/gibberish_stream.cpp b/scene/resources/gibberish_stream.cpp deleted file mode 100644 index e2994f1419..0000000000 --- a/scene/resources/gibberish_stream.cpp +++ /dev/null @@ -1,337 +0,0 @@ -/*************************************************************************/ -/* gibberish_stream.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#include "gibberish_stream.h" -#include "servers/audio_server.h" - -//TODO: This class needs to be adapted to the new AudioStream API, -// or dropped if nobody cares about fixing it :) (GH-3307) - -#if 0 - -int AudioStreamGibberish::get_channel_count() const { - - return 1; -} - - -static float _get_vol_at_pos(int p_pos, int p_len, int p_x_fade) { - - if (p_pos < p_x_fade) - return float(p_pos)/p_x_fade; - else if (p_pos>(p_len-p_x_fade)) - return float(p_len-p_pos)/p_x_fade; - else - return 1.0; - -} - int AudioStreamGibberish::randomize() { - - if (rand_idx==_rand_pool.size()) { - - for(int i=0;i<_rand_pool.size();i++) { - - SWAP(_rand_pool[i],_rand_pool[Math::rand()%_rand_pool.size()]); - } - rand_idx=0; - } - - return _rand_pool[rand_idx++]; -} - -bool AudioStreamGibberish::mix(int32_t *p_buffer, int p_frames) { - - if (!active) - return false; - - zeromem(p_buffer,p_frames*sizeof(int32_t)); - - if (!paused && active_voices==0) { - - active_voices=1; - playback[0].idx=randomize(); - playback[0].fp_pos=0; - playback[0].scale=Math::random(1,1+pitch_random_scale); - } - - for(int i=0;i<active_voices;i++) { - - RID s = _samples[playback[i].idx]->get_rid(); - - uint64_t fp_pos=playback[i].fp_pos; - const void *data = AudioServer::get_singleton()->sample_get_data_ptr(s); - bool is16 = AudioServer::get_singleton()->sample_get_format(s)==AudioServer::SAMPLE_FORMAT_PCM16; - int skip = AudioServer::get_singleton()->sample_is_stereo(s) ? 1: 0; - uint64_t max = AudioServer::get_singleton()->sample_get_length(s) * uint64_t(FP_LEN); - int mrate = AudioServer::get_singleton()->sample_get_mix_rate(s) * pitch_scale * playback[i].scale; - uint64_t increment = uint64_t(mrate) * uint64_t(FP_LEN) / get_mix_rate(); - - - float vol_begin = _get_vol_at_pos(fp_pos>>FP_BITS,max>>FP_BITS,xfade_time*mrate); - float vol_end = _get_vol_at_pos((fp_pos+p_frames*increment)>>FP_BITS,max>>FP_BITS,xfade_time*mrate); - - int32_t vol = CLAMP(int32_t(vol_begin * 65535),0,65535); - int32_t vol_to = CLAMP(int32_t(vol_end * 65535),0,65535); - int32_t vol_inc = (vol_to-vol)/p_frames; - - bool done=false; - - if (is16) { - - const int16_t *smp = (int16_t*)data; - for(int i=0;i<p_frames;i++) { - - if (fp_pos >= max) { - done=true; - break; - } - - int idx = (fp_pos>>FP_BITS)<<skip; - p_buffer[i]+=int32_t(smp[idx])*vol; - vol+=vol_inc; - - fp_pos+=increment; - } - } else { - - const int8_t *smp = (int8_t*)data; - for(int i=0;i<p_frames;i++) { - - if (fp_pos >= max) { - done=true; - break; - } - - int idx = (fp_pos>>FP_BITS)<<skip; - p_buffer[i]+=(int32_t(smp[idx])<<8)*vol; - vol+=vol_inc; - fp_pos+=increment; - } - - } - - playback[i].fp_pos=fp_pos; - if (!paused && active_voices==1 && (vol_end < vol_begin || done)) { - //xfade to something else i gues - active_voices=2; - playback[1].idx=randomize(); - playback[1].fp_pos=0; - playback[1].scale=Math::random(1,1+pitch_random_scale); - } - - if (done) { - - if (i==0 && active_voices==2) { - playback[0]=playback[1]; - i--; - } - active_voices--; - - } - } - - return true; -} - - -void AudioStreamGibberish::play() { - if (active) - stop(); - - - if (!phonemes.is_valid()) - return; - - - List<StringName> slist; - phonemes->get_sample_list(&slist); - if (slist.size()==0) - return; - - _samples.resize(slist.size()); - _rand_pool.resize(slist.size()); - - int i=0; - for(List<StringName>::Element *E=slist.front();E;E=E->next()) { - - _rand_pool[i]=i; - _samples[i++]=phonemes->get_sample(E->get()); - } - - rand_idx=0; - active_voices=0; - active=true; -} - -void AudioStreamGibberish::stop(){ - - active=false; - - -} - -bool AudioStreamGibberish::is_playing() const { - - return active; -} - - -void AudioStreamGibberish::set_paused(bool p_paused){ - - paused=p_paused; -} - -bool AudioStreamGibberish::is_paused(bool p_paused) const{ - - return paused; -} - -void AudioStreamGibberish::set_loop(bool p_enable){ - - -} - -bool AudioStreamGibberish::has_loop() const{ - - return false; -} - - -float AudioStreamGibberish::get_length() const{ - - return 0; -} - - -String AudioStreamGibberish::get_stream_name() const{ - - return "Gibberish"; -} - - -int AudioStreamGibberish::get_loop_count() const{ - - return 0; -} - - -float AudioStreamGibberish::get_pos() const{ - - return 0; -} - -void AudioStreamGibberish::seek_pos(float p_time){ - - -} - - -AudioStream::UpdateMode AudioStreamGibberish::get_update_mode() const{ - - return AudioStream::UPDATE_NONE; -} - -void AudioStreamGibberish::update(){ - - -} - - -void AudioStreamGibberish::set_phonemes(const Ref<SampleLibrary>& p_phonemes) { - - phonemes=p_phonemes; - -} - -Ref<SampleLibrary> AudioStreamGibberish::get_phonemes() const { - - return phonemes; -} - -void AudioStreamGibberish::set_xfade_time(float p_xfade) { - - xfade_time=p_xfade; -} - -float AudioStreamGibberish::get_xfade_time() const { - - return xfade_time; -} - -void AudioStreamGibberish::set_pitch_scale(float p_scale) { - - pitch_scale=p_scale; -} - -float AudioStreamGibberish::get_pitch_scale() const { - - return pitch_scale; -} - -void AudioStreamGibberish::set_pitch_random_scale(float p_random_scale) { - - pitch_random_scale=p_random_scale; -} - -float AudioStreamGibberish::get_pitch_random_scale() const { - - return pitch_random_scale; -} - -void AudioStreamGibberish::_bind_methods() { - - ClassDB::bind_method(D_METHOD("set_phonemes","phonemes"),&AudioStreamGibberish::set_phonemes); - ClassDB::bind_method(D_METHOD("get_phonemes"),&AudioStreamGibberish::get_phonemes); - - ClassDB::bind_method(D_METHOD("set_pitch_scale","pitch_scale"),&AudioStreamGibberish::set_pitch_scale); - ClassDB::bind_method(D_METHOD("get_pitch_scale"),&AudioStreamGibberish::get_pitch_scale); - - ClassDB::bind_method(D_METHOD("set_pitch_random_scale","pitch_random_scale"),&AudioStreamGibberish::set_pitch_random_scale); - ClassDB::bind_method(D_METHOD("get_pitch_random_scale"),&AudioStreamGibberish::get_pitch_random_scale); - - ClassDB::bind_method(D_METHOD("set_xfade_time","sec"),&AudioStreamGibberish::set_xfade_time); - ClassDB::bind_method(D_METHOD("get_xfade_time"),&AudioStreamGibberish::get_xfade_time); - - ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"phonemes",PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),"set_phonemes","get_phonemes"); - ADD_PROPERTY( PropertyInfo(Variant::REAL,"pitch_scale",PROPERTY_HINT_RANGE,"0.01,64,0.01"),"set_pitch_scale","get_pitch_scale"); - ADD_PROPERTY( PropertyInfo(Variant::REAL,"pitch_random_scale",PROPERTY_HINT_RANGE,"0,64,0.01"),"set_pitch_random_scale","get_pitch_random_scale"); - ADD_PROPERTY( PropertyInfo(Variant::REAL,"xfade_sec",PROPERTY_HINT_RANGE,"0.001,0.5,0.001"),"set_xfade_time","get_xfade_time"); - -} - -AudioStreamGibberish::AudioStreamGibberish() { - - xfade_time=0.1; - pitch_scale=1; - pitch_random_scale=0; - active=false; - paused=false; - active_voices=0; -} -#endif diff --git a/scene/resources/gibberish_stream.h b/scene/resources/gibberish_stream.h deleted file mode 100644 index ebe61382eb..0000000000 --- a/scene/resources/gibberish_stream.h +++ /dev/null @@ -1,118 +0,0 @@ -/*************************************************************************/ -/* gibberish_stream.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#ifndef GIBBERISH_STREAM_H -#define GIBBERISH_STREAM_H - -//TODO: This class needs to be adapted to the new AudioStream API, -// or dropped if nobody cares about fixing it :) (GH-3307) - -#if 0 -#include "scene/resources/audio_stream.h" -#include "scene/resources/sample_library.h" -class AudioStreamGibberish : public AudioStream { - - GDCLASS( AudioStreamGibberish, AudioStream ); - - enum { - - FP_BITS = 12, - FP_LEN = (1<<12), - }; - bool active; - bool paused; - - float xfade_time; - float pitch_scale; - float pitch_random_scale; - Vector<Ref<Sample> > _samples; - Vector<int> _rand_pool; - int rand_idx; - _FORCE_INLINE_ int randomize(); - - struct Playback { - - int idx; - uint64_t fp_pos; - float scale; - }; - - Playback playback[2]; - int active_voices; - - Ref<SampleLibrary> phonemes; -protected: - - virtual int get_channel_count() const; - virtual bool mix(int32_t *p_buffer, int p_frames); - - static void _bind_methods(); - -public: - - void set_phonemes(const Ref<SampleLibrary>& p_phonemes); - Ref<SampleLibrary> get_phonemes() const; - - virtual void play(); - virtual void stop(); - virtual bool is_playing() const; - - virtual void set_paused(bool p_paused); - virtual bool is_paused(bool p_paused) const; - - virtual void set_loop(bool p_enable); - virtual bool has_loop() const; - - virtual float get_length() const; - - virtual String get_stream_name() const; - - virtual int get_loop_count() const; - - virtual float get_pos() const; - virtual void seek_pos(float p_time); - - virtual UpdateMode get_update_mode() const; - virtual void update(); - - void set_xfade_time(float p_xfade); - float get_xfade_time() const; - - void set_pitch_scale(float p_scale); - float get_pitch_scale() const; - - void set_pitch_random_scale(float p_random_scale); - float get_pitch_random_scale() const; - - AudioStreamGibberish(); -}; - -#endif - -#endif // GIBBERISH_STREAM_H diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 555c94a512..f01d9f841b 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "material.h" + #include "scene/scene_string_names.h" void Material::set_next_pass(const Ref<Material> &p_pass) { diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index d7ea675a47..3ce44e2c31 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -151,18 +151,18 @@ Node *SceneState::instance(GenEditState p_edit_state) const { //print_line("created"); //node belongs to this scene and must be created Object *obj = ClassDB::instance(snames[n.type]); - if (!obj || !obj->cast_to<Node>()) { + if (!Object::cast_to<Node>(obj)) { if (obj) { memdelete(obj); obj = NULL; } WARN_PRINT(String("Warning node of type " + snames[n.type].operator String() + " does not exist.").ascii().get_data()); if (n.parent >= 0 && n.parent < nc && ret_nodes[n.parent]) { - if (ret_nodes[n.parent]->cast_to<Spatial>()) { + if (Object::cast_to<Spatial>(ret_nodes[n.parent])) { obj = memnew(Spatial); - } else if (ret_nodes[n.parent]->cast_to<Control>()) { + } else if (Object::cast_to<Control>(ret_nodes[n.parent])) { obj = memnew(Control); - } else if (ret_nodes[n.parent]->cast_to<Node2D>()) { + } else if (Object::cast_to<Node2D>(ret_nodes[n.parent])) { obj = memnew(Node2D); } } @@ -172,7 +172,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const { } } - node = obj->cast_to<Node>(); + node = Object::cast_to<Node>(obj); } else { print_line("wtf class is disabled for: " + itos(n.type)); @@ -754,7 +754,7 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName // only connections that originate or end into main saved scene are saved // everything else is discarded - Node *target = c.target->cast_to<Node>(); + Node *target = Object::cast_to<Node>(c.target); if (!target) { continue; diff --git a/scene/resources/room.cpp b/scene/resources/room.cpp index c89b7c72c7..de238ebcc0 100644 --- a/scene/resources/room.cpp +++ b/scene/resources/room.cpp @@ -30,7 +30,7 @@ #include "room.h" #include "servers/visual_server.h" - +#if 0 RID RoomBounds::get_rid() const { return area; @@ -64,3 +64,4 @@ RoomBounds::~RoomBounds() { VisualServer::get_singleton()->free(area); } +#endif diff --git a/scene/resources/room.h b/scene/resources/room.h index ba5c0eee1c..4b8c837458 100644 --- a/scene/resources/room.h +++ b/scene/resources/room.h @@ -36,6 +36,9 @@ @author Juan Linietsky <reduzio@gmail.com> */ +//left for reference but will be removed when portals are reimplemented using Area +#if 0 + class RoomBounds : public Resource { GDCLASS(RoomBounds, Resource); @@ -57,4 +60,5 @@ public: ~RoomBounds(); }; +#endif #endif // ROOM_H diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp index 49cd030a9a..0cccdc4fbf 100644 --- a/scene/resources/scene_format_text.cpp +++ b/scene/resources/scene_format_text.cpp @@ -239,7 +239,7 @@ Error ResourceInteractiveLoaderText::poll() { return error; } - Resource *r = obj->cast_to<Resource>(); + Resource *r = Object::cast_to<Resource>(obj); if (!r) { error_text += "Can't create sub resource of type, because not a resource: " + type; @@ -305,7 +305,7 @@ Error ResourceInteractiveLoaderText::poll() { return error; } - Resource *r = obj->cast_to<Resource>(); + Resource *r = Object::cast_to<Resource>(obj); if (!r) { error_text += "Can't create sub resource of type, because not a resource: " + res_type; diff --git a/scene/resources/shape.cpp b/scene/resources/shape.cpp index 6be88374e5..d719aa5403 100644 --- a/scene/resources/shape.cpp +++ b/scene/resources/shape.cpp @@ -74,7 +74,7 @@ Ref<ArrayMesh> Shape::get_debug_mesh() { arr.resize(Mesh::ARRAY_MAX); arr[Mesh::ARRAY_VERTEX] = array; - SceneTree *st = OS::get_singleton()->get_main_loop()->cast_to<SceneTree>(); + SceneTree *st = Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop()); debug_mesh_cache->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, arr); diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index ac1bb105ac..c2c7c37762 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -1030,14 +1030,13 @@ RES ResourceFormatLoaderTheme::load(const String &p_path, const String &p_origin ERR_FAIL_V(RES()); } - if (res->cast_to<StyleBox>()) { - + if (Object::cast_to<StyleBox>(*res)) { theme->set_stylebox(item, control, res); - } else if (res->cast_to<Font>()) { + } else if (Object::cast_to<Font>(*res)) { theme->set_font(item, control, res); - } else if (res->cast_to<Font>()) { + } else if (Object::cast_to<Font>(*res)) { theme->set_font(item, control, res); - } else if (res->cast_to<Texture>()) { + } else if (Object::cast_to<Texture>(*res)) { theme->set_icon(item, control, res); } else { memdelete(f); |