diff options
| -rw-r--r-- | drivers/wasapi/audio_driver_wasapi.cpp | 17 | ||||
| -rw-r--r-- | modules/gdnative/include/nativescript/godot_nativescript.h | 6 | ||||
| -rw-r--r-- | modules/gdnative/nativescript/nativescript.cpp | 38 | ||||
| -rw-r--r-- | platform/javascript/detect.py | 20 | ||||
| -rw-r--r-- | platform/uwp/detect.py | 2 | ||||
| -rw-r--r-- | scene/2d/tile_map.cpp | 55 | 
6 files changed, 113 insertions, 25 deletions
diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp index 36acfb10d1..aae6c0d308 100644 --- a/drivers/wasapi/audio_driver_wasapi.cpp +++ b/drivers/wasapi/audio_driver_wasapi.cpp @@ -151,7 +151,6 @@ Error AudioDriverWASAPI::init_device(bool reinit) {  	// Since we're using WASAPI Shared Mode we can't control any of these, we just tag along  	wasapi_channels = pwfex->nChannels; -	mix_rate = pwfex->nSamplesPerSec;  	format_tag = pwfex->wFormatTag;  	bits_per_sample = pwfex->wBitsPerSample; @@ -187,7 +186,14 @@ Error AudioDriverWASAPI::init_device(bool reinit) {  		}  	} -	hr = audio_client->Initialize(AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_EVENTCALLBACK, 0, 0, pwfex, NULL); +	DWORD streamflags = AUDCLNT_STREAMFLAGS_EVENTCALLBACK; +	if (mix_rate != pwfex->nSamplesPerSec) { +		streamflags |= AUDCLNT_STREAMFLAGS_RATEADJUST; +		pwfex->nSamplesPerSec = mix_rate; +		pwfex->nAvgBytesPerSec = pwfex->nSamplesPerSec * pwfex->nChannels * (pwfex->wBitsPerSample / 8); +	} + +	hr = audio_client->Initialize(AUDCLNT_SHAREMODE_SHARED, streamflags, 0, 0, pwfex, NULL);  	ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);  	event = CreateEvent(NULL, FALSE, FALSE, NULL); @@ -223,10 +229,11 @@ Error AudioDriverWASAPI::finish_device() {  	if (audio_client) {  		if (active) {  			audio_client->Stop(); -			audio_client->Release(); -			audio_client = NULL;  			active = false;  		} + +		audio_client->Release(); +		audio_client = NULL;  	}  	if (render_client) { @@ -244,6 +251,8 @@ Error AudioDriverWASAPI::finish_device() {  Error AudioDriverWASAPI::init() { +	mix_rate = GLOBAL_DEF("audio/mix_rate", DEFAULT_MIX_RATE); +  	Error err = init_device();  	if (err != OK) {  		ERR_PRINT("WASAPI: init_device error"); diff --git a/modules/gdnative/include/nativescript/godot_nativescript.h b/modules/gdnative/include/nativescript/godot_nativescript.h index 747328bc41..de47ec55cc 100644 --- a/modules/gdnative/include/nativescript/godot_nativescript.h +++ b/modules/gdnative/include/nativescript/godot_nativescript.h @@ -220,10 +220,10 @@ const void GDAPI *godot_nativescript_get_type_tag(const godot_object *p_object);  // instance binding API  typedef struct { -	void *(*alloc_instance_binding_data)(void *, godot_object *); -	void (*free_instance_binding_data)(void *, void *); +	GDCALLINGCONV void *(*alloc_instance_binding_data)(void *, godot_object *); +	GDCALLINGCONV void (*free_instance_binding_data)(void *, void *);  	void *data; -	void (*free_func)(void *); +	GDCALLINGCONV void (*free_func)(void *);  } godot_instance_binding_functions;  int GDAPI godot_nativescript_register_instance_binding_data_functions(godot_instance_binding_functions p_binding_functions); diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 5806ee3f3f..ff31035036 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -881,6 +881,9 @@ NativeScriptInstance::~NativeScriptInstance() {  NativeScriptLanguage *NativeScriptLanguage::singleton;  void NativeScriptLanguage::_unload_stuff(bool p_reload) { + +	Map<String, Ref<GDNative> > erase_and_unload; +  	for (Map<String, Map<StringName, NativeScriptDesc> >::Element *L = library_classes.front(); L; L = L->next()) {  		String lib_path = L->key(); @@ -916,18 +919,6 @@ void NativeScriptLanguage::_unload_stuff(bool p_reload) {  			gdn = E->get();  		} -		if (gdn.is_valid() && gdn->get_library().is_valid()) { -			Ref<GDNativeLibrary> lib = gdn->get_library(); -			void *terminate_fn; -			Error err = gdn->get_symbol(lib->get_symbol_prefix() + _terminate_call_name, terminate_fn, true); - -			if (err == OK) { -				void (*terminate)(void *) = (void (*)(void *))terminate_fn; - -				terminate((void *)&lib_path); -			} -		} -  		for (Map<StringName, NativeScriptDesc>::Element *C = classes.front(); C; C = C->next()) {  			// free property stuff first @@ -952,6 +943,27 @@ void NativeScriptLanguage::_unload_stuff(bool p_reload) {  			if (C->get().destroy_func.free_func)  				C->get().destroy_func.free_func(C->get().destroy_func.method_data);  		} + +		erase_and_unload.insert(lib_path, gdn); +	} + +	for (Map<String, Ref<GDNative> >::Element *E = erase_and_unload.front(); E; E = E->next()) { +		String lib_path = E->key(); +		Ref<GDNative> gdn = E->get(); + +		library_classes.erase(lib_path); + +		if (gdn.is_valid() && gdn->get_library().is_valid()) { +			Ref<GDNativeLibrary> lib = gdn->get_library(); +			void *terminate_fn; +			Error err = gdn->get_symbol(lib->get_symbol_prefix() + _terminate_call_name, terminate_fn, true); + +			if (err == OK) { +				void (*terminate)(void *) = (void (*)(void *))terminate_fn; + +				terminate((void *)&lib_path); +			} +		}  	}  } @@ -1363,6 +1375,7 @@ void NativeReloadNode::_notification(int p_what) {  			MutexLock lock(NSL->mutex);  #endif  			NSL->_unload_stuff(true); +  			for (Map<String, Ref<GDNative> >::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) {  				Ref<GDNative> gdn = L->get(); @@ -1376,7 +1389,6 @@ void NativeReloadNode::_notification(int p_what) {  				}  				gdn->terminate(); -				NSL->library_classes.erase(L->key());  			}  			unloaded = true; diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index 851f4ecb49..be1866987a 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -12,7 +12,7 @@ def get_name():  def can_build(): -    return 'EMSCRIPTEN_ROOT' in os.environ or 'EMSCRIPTEN' in os.environ +    return 'EM_CONFIG' in os.environ or os.path.exists(os.path.expanduser('~/.emscripten'))  def get_opts(): @@ -67,10 +67,20 @@ def configure(env):      ## Compiler configuration      env['ENV'] = os.environ -    if 'EMSCRIPTEN_ROOT' in os.environ: -        env.PrependENVPath('PATH', os.environ['EMSCRIPTEN_ROOT']) -    elif 'EMSCRIPTEN' in os.environ: -        env.PrependENVPath('PATH', os.environ['EMSCRIPTEN']) + +    em_config_file = os.getenv('EM_CONFIG') or os.path.expanduser('~/.emscripten') +    if not os.path.exists(em_config_file): +        raise RuntimeError("Emscripten configuration file '%s' does not exist" % em_config_file) +    with open(em_config_file) as f: +        em_config = {} +        try: +            # Emscripten configuration file is a Python file with simple assignments. +            exec(f.read(), em_config) +        except StandardError as e: +            raise RuntimeError("Emscripten configuration file '%s' is invalid:\n%s" % (em_config_file, e)) +    if 'EMSCRIPTEN_ROOT' not in em_config: +        raise RuntimeError("'EMSCRIPTEN_ROOT' missing in Emscripten configuration file '%s'" % em_config_file) +    env.PrependENVPath('PATH', em_config['EMSCRIPTEN_ROOT'])      env['CC'] = 'emcc'      env['CXX'] = 'em++' diff --git a/platform/uwp/detect.py b/platform/uwp/detect.py index 3ee195e4f9..0e7b125dc5 100644 --- a/platform/uwp/detect.py +++ b/platform/uwp/detect.py @@ -43,6 +43,8 @@ def get_flags():  def configure(env): +    env.msvc = True +      if (env["bits"] != "default"):          print("Error: bits argument is disabled for MSVC")          print(""" diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index b602839b99..c126dd8f6b 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -265,12 +265,18 @@ void TileMap::_update_dirty_quadrants() {  	SceneTree *st = SceneTree::get_singleton();  	Color debug_collision_color; +	Color debug_navigation_color;  	bool debug_shapes = st && st->is_debugging_collisions_hint();  	if (debug_shapes) {  		debug_collision_color = st->get_debug_collisions_color();  	} +	bool debug_navigation = st && st->is_debugging_navigation_hint(); +	if (debug_navigation) { +		debug_navigation_color = st->get_debug_navigation_color(); +	} +  	while (dirty_quadrant_list.first()) {  		Quadrant &q = *dirty_quadrant_list.first()->self(); @@ -497,6 +503,55 @@ void TileMap::_update_dirty_quadrants() {  					np.id = pid;  					np.xform = xform;  					q.navpoly_ids[E->key()] = np; + +					if (debug_navigation) { +						RID debug_navigation_item = vs->canvas_item_create(); +						vs->canvas_item_set_parent(debug_navigation_item, canvas_item); +						vs->canvas_item_set_z_as_relative_to_parent(debug_navigation_item, false); +						vs->canvas_item_set_z_index(debug_navigation_item, VS::CANVAS_ITEM_Z_MAX - 2); // Display one below collision debug + +						if (debug_navigation_item.is_valid()) { +							PoolVector<Vector2> navigation_polygon_vertices = navpoly->get_vertices(); +							int vsize = navigation_polygon_vertices.size(); + +							if (vsize > 2) { +								Vector<Color> colors; +								Vector<Vector2> vertices; +								vertices.resize(vsize); +								colors.resize(vsize); +								{ +									PoolVector<Vector2>::Read vr = navigation_polygon_vertices.read(); +									for (int i = 0; i < vsize; i++) { +										vertices[i] = vr[i]; +										colors[i] = debug_navigation_color; +									} +								} + +								Vector<int> indices; + +								for (int i = 0; i < navpoly->get_polygon_count(); i++) { +									Vector<int> polygon = navpoly->get_polygon(i); + +									for (int j = 2; j < polygon.size(); j++) { + +										int kofs[3] = { 0, j - 1, j }; +										for (int k = 0; k < 3; k++) { + +											int idx = polygon[kofs[k]]; +											ERR_FAIL_INDEX(idx, vsize); +											indices.push_back(idx); +										} +									} +								} +								Transform2D navxform; +								navxform.set_origin(offset.floor()); +								_fix_cell_transform(navxform, c, npoly_ofs + center_ofs, s); + +								vs->canvas_item_set_transform(debug_navigation_item, navxform); +								vs->canvas_item_add_triangle_array(debug_navigation_item, indices, vertices, colors); +							} +						} +					}  				}  			}  |