diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/gdscript/gd_functions.cpp | 64 | ||||
| -rw-r--r-- | modules/gdscript/gd_parser.cpp | 13 | ||||
| -rw-r--r-- | modules/gdscript/gd_tokenizer.cpp | 2 | ||||
| -rw-r--r-- | modules/gdscript/gd_tokenizer.h | 1 | ||||
| -rw-r--r-- | modules/stb_vorbis/SCsub | 10 | ||||
| -rw-r--r-- | modules/stb_vorbis/audio_stream_ogg_vorbis.cpp | 236 | ||||
| -rw-r--r-- | modules/stb_vorbis/audio_stream_ogg_vorbis.h | 84 | ||||
| -rw-r--r-- | modules/stb_vorbis/config.py | 7 | ||||
| -rw-r--r-- | modules/stb_vorbis/register_types.cpp | 44 | ||||
| -rw-r--r-- | modules/stb_vorbis/register_types.h | 30 | ||||
| -rw-r--r-- | modules/visual_script/visual_script_builtin_funcs.cpp | 62 |
11 files changed, 483 insertions, 70 deletions
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index 4f3516c097..d0fc241734 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -159,85 +159,85 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va case MATH_SIN: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::sin(*p_args[0]); + r_ret=Math::sin((double)*p_args[0]); } break; case MATH_COS: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::cos(*p_args[0]); + r_ret=Math::cos((double)*p_args[0]); } break; case MATH_TAN: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::tan(*p_args[0]); + r_ret=Math::tan((double)*p_args[0]); } break; case MATH_SINH: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::sinh(*p_args[0]); + r_ret=Math::sinh((double)*p_args[0]); } break; case MATH_COSH: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::cosh(*p_args[0]); + r_ret=Math::cosh((double)*p_args[0]); } break; case MATH_TANH: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::tanh(*p_args[0]); + r_ret=Math::tanh((double)*p_args[0]); } break; case MATH_ASIN: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::asin(*p_args[0]); + r_ret=Math::asin((double)*p_args[0]); } break; case MATH_ACOS: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::acos(*p_args[0]); + r_ret=Math::acos((double)*p_args[0]); } break; case MATH_ATAN: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::atan(*p_args[0]); + r_ret=Math::atan((double)*p_args[0]); } break; case MATH_ATAN2: { VALIDATE_ARG_COUNT(2); VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); - r_ret=Math::atan2(*p_args[0],*p_args[1]); + r_ret=Math::atan2((double)*p_args[0],(double)*p_args[1]); } break; case MATH_SQRT: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::sqrt(*p_args[0]); + r_ret=Math::sqrt((double)*p_args[0]); } break; case MATH_FMOD: { VALIDATE_ARG_COUNT(2); VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); - r_ret=Math::fmod(*p_args[0],*p_args[1]); + r_ret=Math::fmod((double)*p_args[0],(double)*p_args[1]); } break; case MATH_FPOSMOD: { VALIDATE_ARG_COUNT(2); VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); - r_ret=Math::fposmod(*p_args[0],*p_args[1]); + r_ret=Math::fposmod((double)*p_args[0],(double)*p_args[1]); } break; case MATH_FLOOR: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::floor(*p_args[0]); + r_ret=Math::floor((double)*p_args[0]); } break; case MATH_CEIL: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::ceil(*p_args[0]); + r_ret=Math::ceil((double)*p_args[0]); } break; case MATH_ROUND: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::round(*p_args[0]); + r_ret=Math::round((double)*p_args[0]); } break; case MATH_ABS: { VALIDATE_ARG_COUNT(1); @@ -247,7 +247,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_ret=ABS(i); } else if (p_args[0]->get_type()==Variant::REAL) { - real_t r = *p_args[0]; + double r = *p_args[0]; r_ret=Math::abs(r); } else { @@ -279,58 +279,58 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va VALIDATE_ARG_COUNT(2); VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); - r_ret=Math::pow(*p_args[0],*p_args[1]); + r_ret=Math::pow((double)*p_args[0],(double)*p_args[1]); } break; case MATH_LOG: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::log(*p_args[0]); + r_ret=Math::log((double)*p_args[0]); } break; case MATH_EXP: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::exp(*p_args[0]); + r_ret=Math::exp((double)*p_args[0]); } break; case MATH_ISNAN: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::is_nan(*p_args[0]); + r_ret=Math::is_nan((double)*p_args[0]); } break; case MATH_ISINF: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::is_inf(*p_args[0]); + r_ret=Math::is_inf((double)*p_args[0]); } break; case MATH_EASE: { VALIDATE_ARG_COUNT(2); VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); - r_ret=Math::ease(*p_args[0],*p_args[1]); + r_ret=Math::ease((double)*p_args[0],(double)*p_args[1]); } break; case MATH_DECIMALS: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::step_decimals(*p_args[0]); + r_ret=Math::step_decimals((double)*p_args[0]); } break; case MATH_STEPIFY: { VALIDATE_ARG_COUNT(2); VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); - r_ret=Math::stepify(*p_args[0],*p_args[1]); + r_ret=Math::stepify((double)*p_args[0],(double)*p_args[1]); } break; case MATH_LERP: { VALIDATE_ARG_COUNT(3); VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); VALIDATE_ARG_NUM(2); - r_ret=Math::lerp(*p_args[0],*p_args[1],*p_args[2]); + r_ret=Math::lerp((double)*p_args[0],(double)*p_args[1],(double)*p_args[2]); } break; case MATH_DECTIME: { VALIDATE_ARG_COUNT(3); VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); VALIDATE_ARG_NUM(2); - r_ret=Math::dectime(*p_args[0],*p_args[1],*p_args[2]); + r_ret=Math::dectime((double)*p_args[0],(double)*p_args[1],(double)*p_args[2]); } break; case MATH_RANDOMIZE: { Math::randomize(); @@ -346,7 +346,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va VALIDATE_ARG_COUNT(2); VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); - r_ret=Math::random(*p_args[0],*p_args[1]); + r_ret=Math::random((double)*p_args[0],(double)*p_args[1]); } break; case MATH_SEED: { VALIDATE_ARG_COUNT(1); @@ -369,22 +369,22 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va case MATH_DEG2RAD: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::deg2rad(*p_args[0]); + r_ret=Math::deg2rad((double)*p_args[0]); } break; case MATH_RAD2DEG: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::rad2deg(*p_args[0]); + r_ret=Math::rad2deg((double)*p_args[0]); } break; case MATH_LINEAR2DB: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::linear2db(*p_args[0]); + r_ret=Math::linear2db((double)*p_args[0]); } break; case MATH_DB2LINEAR: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::db2linear(*p_args[0]); + r_ret=Math::db2linear((double)*p_args[0]); } break; case LOGIC_MAX: { VALIDATE_ARG_COUNT(2); diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 70659326e5..34c39c8024 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -1704,7 +1704,7 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) } switch (token) { - // dictionary + // array case GDTokenizer::TK_BRACKET_OPEN: { tokenizer->advance(); pattern->pt_type = GDParser::PatternNode::PT_ARRAY; @@ -1759,7 +1759,7 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) pattern->bind = tokenizer->get_token_identifier(); tokenizer->advance(); } break; - // array + // dictionary case GDTokenizer::TK_CURLY_BRACKET_OPEN: { tokenizer->advance(); pattern->pt_type = GDParser::PatternNode::PT_DICTIONARY; @@ -1826,17 +1826,16 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) } } } break; + case GDTokenizer::TK_WILDCARD: { + tokenizer->advance(); + pattern->pt_type = PatternNode::PT_WILDCARD; + } break; // all the constants like strings and numbers default: { Node *value = _parse_and_reduce_expression(pattern, p_static); if (error_set) { return NULL; } - if (value->type == Node::TYPE_IDENTIFIER && static_cast<IdentifierNode*>(value)->name == "_") { - // wildcard pattern - pattern->pt_type = PatternNode::PT_WILDCARD; - break; - } if (value->type != Node::TYPE_IDENTIFIER && value->type != Node::TYPE_CONSTANT) { _set_error("Only constant expressions or variables allowed in a pattern"); diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp index 70fc991bcc..5be2a2beae 100644 --- a/modules/gdscript/gd_tokenizer.cpp +++ b/modules/gdscript/gd_tokenizer.cpp @@ -119,6 +119,7 @@ const char* GDTokenizer::token_names[TK_MAX]={ "':'", "'\\n'", "PI", +"_", "Error", "EOF", "Cursor"}; @@ -899,6 +900,7 @@ void GDTokenizerText::_advance() { {TK_CF_PASS,"pass"}, {TK_SELF,"self"}, {TK_CONST_PI,"PI"}, + {TK_WILDCARD,"_"}, {TK_ERROR,NULL} }; diff --git a/modules/gdscript/gd_tokenizer.h b/modules/gdscript/gd_tokenizer.h index 9a6f4df9c4..5d955ff1ae 100644 --- a/modules/gdscript/gd_tokenizer.h +++ b/modules/gdscript/gd_tokenizer.h @@ -127,6 +127,7 @@ public: TK_DOLLAR, TK_NEWLINE, TK_CONST_PI, + TK_WILDCARD, TK_ERROR, TK_EOF, TK_CURSOR, //used for code completion diff --git a/modules/stb_vorbis/SCsub b/modules/stb_vorbis/SCsub new file mode 100644 index 0000000000..897d05961c --- /dev/null +++ b/modules/stb_vorbis/SCsub @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +Import('env') +Import('env_modules') + +# Thirdparty source files + +env_stb_vorbis = env_modules.Clone() + +env_stb_vorbis.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp new file mode 100644 index 0000000000..31bf5ac292 --- /dev/null +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp @@ -0,0 +1,236 @@ + +#include "audio_stream_ogg_vorbis.h" +#include "thirdparty/stb_vorbis/stb_vorbis.c" +#include "os/file_access.h" + + +void AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame* p_buffer,int p_frames) { + + ERR_FAIL_COND(!active); + + int todo=p_frames; + + while(todo) { + + int mixed = stb_vorbis_get_samples_float_interleaved(ogg_stream,2,(float*)p_buffer,todo*2); + todo-=mixed; + + if (todo) { + //end of file! + if (false) { + //loop + seek_pos(0); + loops++; + } else { + for(int i=mixed;i<p_frames;i++) { + p_buffer[i]=AudioFrame(0,0); + } + active=false; + } + } + } + + +} + +float AudioStreamPlaybackOGGVorbis::get_stream_sampling_rate() { + + return vorbis_stream->sample_rate; +} + + +void AudioStreamPlaybackOGGVorbis::start(float p_from_pos) { + + seek_pos(p_from_pos); + active=true; + loops=0; + _begin_resample(); + + +} + +void AudioStreamPlaybackOGGVorbis::stop() { + + active=false; +} +bool AudioStreamPlaybackOGGVorbis::is_playing() const { + + return active; +} + +int AudioStreamPlaybackOGGVorbis::get_loop_count() const { + + return loops; +} + +float AudioStreamPlaybackOGGVorbis::get_pos() const { + + return float(frames_mixed)/vorbis_stream->sample_rate; +} +void AudioStreamPlaybackOGGVorbis::seek_pos(float p_time) { + + if (!active) + return; + + stb_vorbis_seek(ogg_stream, uint32_t(p_time*vorbis_stream->sample_rate)); +} + +float AudioStreamPlaybackOGGVorbis::get_length() const { + + return vorbis_stream->length; +} + +AudioStreamPlaybackOGGVorbis::~AudioStreamPlaybackOGGVorbis() { + if (ogg_alloc.alloc_buffer) { + AudioServer::get_singleton()->audio_data_free(ogg_alloc.alloc_buffer); + stb_vorbis_close(ogg_stream); + } +} + +Ref<AudioStreamPlayback> AudioStreamOGGVorbis::instance_playback() { + + + + Ref<AudioStreamPlaybackOGGVorbis> ovs; + printf("instance at %p, data %p\n",this,data); + + ERR_FAIL_COND_V(data==NULL,ovs); + + ovs.instance(); + ovs->vorbis_stream=Ref<AudioStreamOGGVorbis>(this); + ovs->ogg_alloc.alloc_buffer=(char*)AudioServer::get_singleton()->audio_data_alloc(decode_mem_size); + ovs->ogg_alloc.alloc_buffer_length_in_bytes=decode_mem_size; + ovs->frames_mixed=0; + ovs->active=false; + ovs->loops=0; + int error ; + ovs->ogg_stream = stb_vorbis_open_memory( (const unsigned char*)data, data_len, &error, &ovs->ogg_alloc ); + if (!ovs->ogg_stream) { + + AudioServer::get_singleton()->audio_data_free(ovs->ogg_alloc.alloc_buffer); + ovs->ogg_alloc.alloc_buffer=NULL; + ERR_FAIL_COND_V(!ovs->ogg_stream,Ref<AudioStreamPlaybackOGGVorbis>()); + } + + return ovs; +} + +String AudioStreamOGGVorbis::get_stream_name() const { + + return "";//return stream_name; +} + +Error AudioStreamOGGVorbis::setup(const uint8_t *p_data,uint32_t p_data_len) { + + +#define MAX_TEST_MEM (1<<20) + + uint32_t alloc_try=1024; + PoolVector<char> alloc_mem; + PoolVector<char>::Write w; + stb_vorbis * ogg_stream=NULL; + stb_vorbis_alloc ogg_alloc; + + while(alloc_try<MAX_TEST_MEM) { + + alloc_mem.resize(alloc_try); + w = alloc_mem.write(); + + ogg_alloc.alloc_buffer=w.ptr(); + ogg_alloc.alloc_buffer_length_in_bytes=alloc_try; + + int error; + ogg_stream = stb_vorbis_open_memory( (const unsigned char*)p_data, p_data_len, &error, &ogg_alloc ); + + if (!ogg_stream && error==VORBIS_outofmem) { + w = PoolVector<char>::Write(); + alloc_try*=2; + } else { + break; + } + } + ERR_FAIL_COND_V(alloc_try==MAX_TEST_MEM,ERR_OUT_OF_MEMORY); + ERR_FAIL_COND_V(ogg_stream==NULL,ERR_FILE_CORRUPT); + + stb_vorbis_info info = stb_vorbis_get_info(ogg_stream); + + channels = info.channels; + sample_rate = info.sample_rate; + decode_mem_size = alloc_try; + //does this work? (it's less mem..) + //decode_mem_size = ogg_alloc.alloc_buffer_length_in_bytes + info.setup_memory_required + info.temp_memory_required + info.max_frame_size; + + //print_line("succeded "+itos(ogg_alloc.alloc_buffer_length_in_bytes)+" setup "+itos(info.setup_memory_required)+" setup temp "+itos(info.setup_temp_memory_required)+" temp "+itos(info.temp_memory_required)+" maxframe"+itos(info.max_frame_size)); + + length=stb_vorbis_stream_length_in_seconds(ogg_stream); + stb_vorbis_close(ogg_stream); + + data = AudioServer::get_singleton()->audio_data_alloc(p_data_len,p_data); + data_len=p_data_len; + + printf("create at %p, data %p\n",this,data); + return OK; +} + +AudioStreamOGGVorbis::AudioStreamOGGVorbis() { + + + data=NULL; + length=0; + sample_rate=1; + channels=1; + decode_mem_size=0; +} + + + + +RES ResourceFormatLoaderAudioStreamOGGVorbis::load(const String &p_path, const String& p_original_path, Error *r_error) { + if (r_error) + *r_error=OK; + + FileAccess *f = FileAccess::open(p_path,FileAccess::READ); + if (!f) { + *r_error=ERR_CANT_OPEN; + ERR_FAIL_COND_V(!f,RES()); + } + + size_t len = f->get_len(); + + PoolVector<uint8_t> data; + data.resize(len); + PoolVector<uint8_t>::Write w = data.write(); + + f->get_buffer(w.ptr(),len); + + memdelete(f); + + Ref<AudioStreamOGGVorbis> ogg_stream; + ogg_stream.instance(); + + Error err = ogg_stream->setup(w.ptr(),len); + + if (err!=OK) { + *r_error=err; + ogg_stream.unref(); + ERR_FAIL_V(RES()); + } + + return ogg_stream; +} + +void ResourceFormatLoaderAudioStreamOGGVorbis::get_recognized_extensions(List<String> *p_extensions) const { + + p_extensions->push_back("ogg"); +} +String ResourceFormatLoaderAudioStreamOGGVorbis::get_resource_type(const String &p_path) const { + + if (p_path.get_extension().to_lower()=="ogg") + return "AudioStreamOGGVorbis"; + return ""; +} + +bool ResourceFormatLoaderAudioStreamOGGVorbis::handles_type(const String& p_type) const { + return (p_type=="AudioStream" || p_type=="AudioStreamOGG" || p_type=="AudioStreamOGGVorbis"); +} + diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.h b/modules/stb_vorbis/audio_stream_ogg_vorbis.h new file mode 100644 index 0000000000..4555423f85 --- /dev/null +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.h @@ -0,0 +1,84 @@ +#ifndef AUDIO_STREAM_STB_VORBIS_H +#define AUDIO_STREAM_STB_VORBIS_H + +#include "servers/audio/audio_stream.h" +#include "io/resource_loader.h" + +#define STB_VORBIS_HEADER_ONLY +#include "thirdparty/stb_vorbis/stb_vorbis.c" +#undef STB_VORBIS_HEADER_ONLY + + +class AudioStreamOGGVorbis; + +class AudioStreamPlaybackOGGVorbis : public AudioStreamPlaybackResampled { + + GDCLASS( AudioStreamPlaybackOGGVorbis, AudioStreamPlaybackResampled ) + + stb_vorbis * ogg_stream; + stb_vorbis_alloc ogg_alloc; + uint32_t frames_mixed; + bool active; + int loops; + +friend class AudioStreamOGGVorbis; + + Ref<AudioStreamOGGVorbis> vorbis_stream; +protected: + + virtual void _mix_internal(AudioFrame* p_buffer, int p_frames); + virtual float get_stream_sampling_rate(); + +public: + virtual void start(float p_from_pos=0.0); + virtual void stop(); + virtual bool is_playing() const; + + virtual int get_loop_count() const; //times it looped + + virtual float get_pos() const; + virtual void seek_pos(float p_time); + + virtual float get_length() const; //if supported, otherwise return 0 + + AudioStreamPlaybackOGGVorbis() { } + ~AudioStreamPlaybackOGGVorbis(); +}; + +class AudioStreamOGGVorbis : public AudioStream { + + GDCLASS( AudioStreamOGGVorbis, AudioStream ) + OBJ_SAVE_TYPE( AudioStream ) //children are all saved as AudioStream, so they can be exchanged + +friend class AudioStreamPlaybackOGGVorbis; + + void *data; + uint32_t data_len; + + int decode_mem_size; + float sample_rate; + int channels; + float length; + +public: + + + virtual Ref<AudioStreamPlayback> instance_playback(); + virtual String get_stream_name() const; + + Error setup(const uint8_t *p_data, uint32_t p_data_len); + + AudioStreamOGGVorbis(); +}; + +class ResourceFormatLoaderAudioStreamOGGVorbis : public ResourceFormatLoader { +public: + virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL); + virtual void get_recognized_extensions(List<String> *p_extensions) const; + virtual bool handles_type(const String& p_type) const; + virtual String get_resource_type(const String &p_path) const; +}; + + + +#endif diff --git a/modules/stb_vorbis/config.py b/modules/stb_vorbis/config.py new file mode 100644 index 0000000000..fb920482f5 --- /dev/null +++ b/modules/stb_vorbis/config.py @@ -0,0 +1,7 @@ + +def can_build(platform): + return True + + +def configure(env): + pass diff --git a/modules/stb_vorbis/register_types.cpp b/modules/stb_vorbis/register_types.cpp new file mode 100644 index 0000000000..143ad6f47e --- /dev/null +++ b/modules/stb_vorbis/register_types.cpp @@ -0,0 +1,44 @@ +/*************************************************************************/ +/* register_types.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "register_types.h" +#include "audio_stream_ogg_vorbis.h" + +static ResourceFormatLoaderAudioStreamOGGVorbis *vorbis_stream_loader = NULL; + +void register_stb_vorbis_types() { + + vorbis_stream_loader = memnew( ResourceFormatLoaderAudioStreamOGGVorbis ); + ResourceLoader::add_resource_format_loader(vorbis_stream_loader); + ClassDB::register_class<AudioStreamOGGVorbis>(); +} + +void unregister_stb_vorbis_types() { + + memdelete( vorbis_stream_loader ); +} diff --git a/modules/stb_vorbis/register_types.h b/modules/stb_vorbis/register_types.h new file mode 100644 index 0000000000..2824aa9f0c --- /dev/null +++ b/modules/stb_vorbis/register_types.h @@ -0,0 +1,30 @@ +/*************************************************************************/ +/* register_types.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +void register_stb_vorbis_types(); +void unregister_stb_vorbis_types(); diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp index 169af6fbec..a0f23a511f 100644 --- a/modules/visual_script/visual_script_builtin_funcs.cpp +++ b/modules/visual_script/visual_script_builtin_funcs.cpp @@ -610,85 +610,85 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func,const Variant** p_inp case VisualScriptBuiltinFunc::MATH_SIN: { VALIDATE_ARG_NUM(0); - *r_return=Math::sin(*p_inputs[0]); + *r_return=Math::sin((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_COS: { VALIDATE_ARG_NUM(0); - *r_return=Math::cos(*p_inputs[0]); + *r_return=Math::cos((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_TAN: { VALIDATE_ARG_NUM(0); - *r_return=Math::tan(*p_inputs[0]); + *r_return=Math::tan((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_SINH: { VALIDATE_ARG_NUM(0); - *r_return=Math::sinh(*p_inputs[0]); + *r_return=Math::sinh((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_COSH: { VALIDATE_ARG_NUM(0); - *r_return=Math::cosh(*p_inputs[0]); + *r_return=Math::cosh((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_TANH: { VALIDATE_ARG_NUM(0); - *r_return=Math::tanh(*p_inputs[0]); + *r_return=Math::tanh((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_ASIN: { VALIDATE_ARG_NUM(0); - *r_return=Math::asin(*p_inputs[0]); + *r_return=Math::asin((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_ACOS: { VALIDATE_ARG_NUM(0); - *r_return=Math::acos(*p_inputs[0]); + *r_return=Math::acos((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_ATAN: { VALIDATE_ARG_NUM(0); - *r_return=Math::atan(*p_inputs[0]); + *r_return=Math::atan((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_ATAN2: { VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); - *r_return=Math::atan2(*p_inputs[0],*p_inputs[1]); + *r_return=Math::atan2((double)*p_inputs[0],(double)*p_inputs[1]); } break; case VisualScriptBuiltinFunc::MATH_SQRT: { VALIDATE_ARG_NUM(0); - *r_return=Math::sqrt(*p_inputs[0]); + *r_return=Math::sqrt((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_FMOD: { VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); - *r_return=Math::fmod(*p_inputs[0],*p_inputs[1]); + *r_return=Math::fmod((double)*p_inputs[0],(double)*p_inputs[1]); } break; case VisualScriptBuiltinFunc::MATH_FPOSMOD: { VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); - *r_return=Math::fposmod(*p_inputs[0],*p_inputs[1]); + *r_return=Math::fposmod((double)*p_inputs[0],(double)*p_inputs[1]); } break; case VisualScriptBuiltinFunc::MATH_FLOOR: { VALIDATE_ARG_NUM(0); - *r_return=Math::floor(*p_inputs[0]); + *r_return=Math::floor((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_CEIL: { VALIDATE_ARG_NUM(0); - *r_return=Math::ceil(*p_inputs[0]); + *r_return=Math::ceil((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_ROUND: { VALIDATE_ARG_NUM(0); - *r_return=Math::round(*p_inputs[0]); + *r_return=Math::round((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_ABS: { @@ -730,58 +730,58 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func,const Variant** p_inp VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); - *r_return=Math::pow(*p_inputs[0],*p_inputs[1]); + *r_return=Math::pow((double)*p_inputs[0],(double)*p_inputs[1]); } break; case VisualScriptBuiltinFunc::MATH_LOG: { VALIDATE_ARG_NUM(0); - *r_return=Math::log(*p_inputs[0]); + *r_return=Math::log((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_EXP: { VALIDATE_ARG_NUM(0); - *r_return=Math::exp(*p_inputs[0]); + *r_return=Math::exp((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_ISNAN: { VALIDATE_ARG_NUM(0); - *r_return=Math::is_nan(*p_inputs[0]); + *r_return=Math::is_nan((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_ISINF: { VALIDATE_ARG_NUM(0); - *r_return=Math::is_inf(*p_inputs[0]); + *r_return=Math::is_inf((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_EASE: { VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); - *r_return=Math::ease(*p_inputs[0],*p_inputs[1]); + *r_return=Math::ease((double)*p_inputs[0],(double)*p_inputs[1]); } break; case VisualScriptBuiltinFunc::MATH_DECIMALS: { VALIDATE_ARG_NUM(0); - *r_return=Math::step_decimals(*p_inputs[0]); + *r_return=Math::step_decimals((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_STEPIFY: { VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); - *r_return=Math::stepify(*p_inputs[0],*p_inputs[1]); + *r_return=Math::stepify((double)*p_inputs[0],(double)*p_inputs[1]); } break; case VisualScriptBuiltinFunc::MATH_LERP: { VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); VALIDATE_ARG_NUM(2); - *r_return=Math::lerp(*p_inputs[0],*p_inputs[1],*p_inputs[2]); + *r_return=Math::lerp((double)*p_inputs[0],(double)*p_inputs[1],(double)*p_inputs[2]); } break; case VisualScriptBuiltinFunc::MATH_DECTIME: { VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); VALIDATE_ARG_NUM(2); - *r_return=Math::dectime(*p_inputs[0],*p_inputs[1],*p_inputs[2]); + *r_return=Math::dectime((double)*p_inputs[0],(double)*p_inputs[1],(double)*p_inputs[2]); } break; case VisualScriptBuiltinFunc::MATH_RANDOMIZE: { Math::randomize(); @@ -797,7 +797,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func,const Variant** p_inp VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); - *r_return=Math::random(*p_inputs[0],*p_inputs[1]); + *r_return=Math::random((double)*p_inputs[0],(double)*p_inputs[1]); } break; case VisualScriptBuiltinFunc::MATH_SEED: { @@ -820,22 +820,22 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func,const Variant** p_inp case VisualScriptBuiltinFunc::MATH_DEG2RAD: { VALIDATE_ARG_NUM(0); - *r_return=Math::deg2rad(*p_inputs[0]); + *r_return=Math::deg2rad((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_RAD2DEG: { VALIDATE_ARG_NUM(0); - *r_return=Math::rad2deg(*p_inputs[0]); + *r_return=Math::rad2deg((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_LINEAR2DB: { VALIDATE_ARG_NUM(0); - *r_return=Math::linear2db(*p_inputs[0]); + *r_return=Math::linear2db((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::MATH_DB2LINEAR: { VALIDATE_ARG_NUM(0); - *r_return=Math::db2linear(*p_inputs[0]); + *r_return=Math::db2linear((double)*p_inputs[0]); } break; case VisualScriptBuiltinFunc::LOGIC_MAX: { |