Merge pull request #58182 from akien-mga/style-cleanup-if-semicolons-deadcode
This commit is contained in:
commit
51a00c2855
@ -2291,8 +2291,8 @@ void Engine::register_singleton(const StringName &p_name, Object *p_object) {
|
||||
s.ptr = p_object;
|
||||
s.user_created = true;
|
||||
::Engine::get_singleton()->add_singleton(s);
|
||||
;
|
||||
}
|
||||
|
||||
void Engine::unregister_singleton(const StringName &p_name) {
|
||||
ERR_FAIL_COND_MSG(!has_singleton(p_name), "Attempt to remove unregistered singleton: " + String(p_name));
|
||||
ERR_FAIL_COND_MSG(!::Engine::get_singleton()->is_singleton_user_created(p_name), "Attempt to remove non-user created singleton: " + String(p_name));
|
||||
|
@ -1145,7 +1145,6 @@ Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, J
|
||||
// It doesn't make sense for a full axis to map to a button,
|
||||
// but keeping as a default for a trigger with a positive half-axis.
|
||||
event.value = (shifted_positive_value * 2) - 1;
|
||||
;
|
||||
break;
|
||||
}
|
||||
return event;
|
||||
|
@ -1417,19 +1417,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
|
||||
d.get_key_list(&keys);
|
||||
|
||||
for (const Variant &E : keys) {
|
||||
/*
|
||||
CharString utf8 = E->->utf8();
|
||||
|
||||
if (buf) {
|
||||
encode_uint32(utf8.length()+1,buf);
|
||||
buf+=4;
|
||||
memcpy(buf,utf8.get_data(),utf8.length()+1);
|
||||
}
|
||||
|
||||
r_len+=4+utf8.length()+1;
|
||||
while (r_len%4)
|
||||
r_len++; //pad
|
||||
*/
|
||||
int len;
|
||||
Error err = encode_variant(E, buf, len, p_full_objects, p_depth + 1);
|
||||
ERR_FAIL_COND_V(err, err);
|
||||
|
@ -1607,11 +1607,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
|
||||
d.get_key_list(&keys);
|
||||
|
||||
for (const Variant &E : keys) {
|
||||
/*
|
||||
if (!_check_type(dict[E]))
|
||||
continue;
|
||||
*/
|
||||
|
||||
write_variant(f, E, resource_map, external_resources, string_map);
|
||||
write_variant(f, d[E], resource_map, external_resources, string_map);
|
||||
}
|
||||
|
@ -672,10 +672,6 @@ int ResourceLoader::get_import_order(const String &p_path) {
|
||||
if (!loader[i]->recognize_path(local_path)) {
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
|
||||
continue;
|
||||
*/
|
||||
|
||||
return loader[i]->get_import_order(p_path);
|
||||
}
|
||||
@ -690,10 +686,6 @@ String ResourceLoader::get_import_group_file(const String &p_path) {
|
||||
if (!loader[i]->recognize_path(local_path)) {
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
|
||||
continue;
|
||||
*/
|
||||
|
||||
return loader[i]->get_import_group_file(p_path);
|
||||
}
|
||||
@ -708,10 +700,6 @@ bool ResourceLoader::is_import_valid(const String &p_path) {
|
||||
if (!loader[i]->recognize_path(local_path)) {
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
|
||||
continue;
|
||||
*/
|
||||
|
||||
return loader[i]->is_import_valid(p_path);
|
||||
}
|
||||
@ -726,10 +714,6 @@ bool ResourceLoader::is_imported(const String &p_path) {
|
||||
if (!loader[i]->recognize_path(local_path)) {
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
|
||||
continue;
|
||||
*/
|
||||
|
||||
return loader[i]->is_imported(p_path);
|
||||
}
|
||||
@ -744,10 +728,6 @@ void ResourceLoader::get_dependencies(const String &p_path, List<String> *p_depe
|
||||
if (!loader[i]->recognize_path(local_path)) {
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
|
||||
continue;
|
||||
*/
|
||||
|
||||
loader[i]->get_dependencies(local_path, p_dependencies, p_add_types);
|
||||
}
|
||||
@ -760,10 +740,6 @@ Error ResourceLoader::rename_dependencies(const String &p_path, const Map<String
|
||||
if (!loader[i]->recognize_path(local_path)) {
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
|
||||
continue;
|
||||
*/
|
||||
|
||||
return loader[i]->rename_dependencies(local_path, p_map);
|
||||
}
|
||||
|
@ -508,10 +508,11 @@ bool _cull_convex_iterative(uint32_t p_node_id, CullParams &r_params, bool p_ful
|
||||
uint32_t child_id = leaf.get_item_ref_id(n);
|
||||
|
||||
// full up with results? exit early, no point in further testing
|
||||
if (!_cull_hit(child_id, r_params))
|
||||
if (!_cull_hit(child_id, r_params)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // BVH_CONVEX_CULL_OPTIMIZED
|
||||
} // if not fully within
|
||||
} else {
|
||||
|
@ -1,8 +1,9 @@
|
||||
public:
|
||||
#ifdef BVH_VERBOSE
|
||||
void _debug_recursive_print_tree(int p_tree_id) const {
|
||||
if (_root_node_id[p_tree_id] != BVHCommon::INVALID)
|
||||
if (_root_node_id[p_tree_id] != BVHCommon::INVALID) {
|
||||
_debug_recursive_print_tree_node(_root_node_id[p_tree_id]);
|
||||
}
|
||||
}
|
||||
|
||||
String _debug_aabb_to_string(const BVHABB_CLASS &aabb) const {
|
||||
@ -42,8 +43,9 @@ void _debug_recursive_print_tree_node(uint32_t p_node_id, int depth = 0) const {
|
||||
|
||||
sz += "[";
|
||||
for (int n = 0; n < leaf.num_items; n++) {
|
||||
if (n)
|
||||
if (n) {
|
||||
sz += ", ";
|
||||
}
|
||||
sz += "r";
|
||||
sz += itos(leaf.get_item_ref_id(n));
|
||||
}
|
||||
|
@ -211,11 +211,6 @@ private:
|
||||
E = pair_map.insert(key, pdata);
|
||||
E->get().eA = p_A->pair_list.push_back(&E->get());
|
||||
E->get().eB = p_B->pair_list.push_back(&E->get());
|
||||
|
||||
/*
|
||||
if (pair_callback)
|
||||
pair_callback(pair_callback_userdata,p_A->userdata,p_B->userdata);
|
||||
*/
|
||||
} else {
|
||||
E->get().refcount++;
|
||||
}
|
||||
@ -854,11 +849,6 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const AABB &p_aabb) {
|
||||
Octant *o = F->get().octant;
|
||||
typename List<typename Element::OctantOwner, AL>::Element *N = F->next();
|
||||
|
||||
/*
|
||||
if (!use_pairs)
|
||||
o->elements.erase( F->get().E );
|
||||
*/
|
||||
|
||||
if (use_pairs && e.pairable) {
|
||||
o->pairable_elements.erase(F->get().E);
|
||||
} else {
|
||||
|
@ -402,13 +402,9 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid
|
||||
#endif
|
||||
}
|
||||
|
||||
//try built-in setgetter
|
||||
// Try built-in setter.
|
||||
{
|
||||
if (ClassDB::set_property(this, p_name, p_value, r_valid)) {
|
||||
/*
|
||||
if (r_valid)
|
||||
*r_valid=true;
|
||||
*/
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -421,7 +417,6 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid
|
||||
return;
|
||||
|
||||
} else if (p_name == CoreStringNames::get_singleton()->_meta) {
|
||||
//set_meta(p_name,p_value);
|
||||
metadata = p_value.duplicate();
|
||||
if (r_valid) {
|
||||
*r_valid = true;
|
||||
@ -429,7 +424,7 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid
|
||||
return;
|
||||
}
|
||||
|
||||
//something inside the object... :|
|
||||
// Something inside the object... :|
|
||||
bool success = _setv(p_name, p_value);
|
||||
if (success) {
|
||||
if (r_valid) {
|
||||
@ -485,7 +480,7 @@ Variant Object::get(const StringName &p_name, bool *r_valid) const {
|
||||
#endif
|
||||
}
|
||||
|
||||
//try built-in setgetter
|
||||
// Try built-in getter.
|
||||
{
|
||||
if (ClassDB::get_property(const_cast<Object *>(this), p_name, ret)) {
|
||||
if (r_valid) {
|
||||
@ -510,7 +505,7 @@ Variant Object::get(const StringName &p_name, bool *r_valid) const {
|
||||
return ret;
|
||||
|
||||
} else {
|
||||
//something inside the object... :|
|
||||
// Something inside the object... :|
|
||||
bool success = _getv(p_name, ret);
|
||||
if (success) {
|
||||
if (r_valid) {
|
||||
|
@ -245,13 +245,7 @@ struct MethodInfo {
|
||||
MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5);
|
||||
};
|
||||
|
||||
// old cast_to
|
||||
//if ( is_type(T::get_class_static()) )
|
||||
//return static_cast<T*>(this);
|
||||
////else
|
||||
//return nullptr;
|
||||
|
||||
// API used to extend in GDNative and other C compatible compiled languages
|
||||
// API used to extend in GDNative and other C compatible compiled languages.
|
||||
class MethodBind;
|
||||
|
||||
struct ObjectNativeExtension {
|
||||
@ -297,8 +291,10 @@ struct ObjectNativeExtension {
|
||||
#define GDVIRTUAL_IS_OVERRIDDEN_PTR(m_obj, m_name) m_obj->_gdvirtual_##m_name##_overridden()
|
||||
|
||||
/*
|
||||
the following is an incomprehensible blob of hacks and workarounds to compensate for many of the fallencies in C++. As a plus, this macro pretty much alone defines the object model.
|
||||
*/
|
||||
* The following is an incomprehensible blob of hacks and workarounds to
|
||||
* compensate for many of the fallacies in C++. As a plus, this macro pretty
|
||||
* much alone defines the object model.
|
||||
*/
|
||||
|
||||
#define REVERSE_GET_PROPERTY_LIST \
|
||||
public: \
|
||||
@ -534,7 +530,7 @@ private:
|
||||
Set<String> editor_section_folding;
|
||||
#endif
|
||||
ScriptInstance *script_instance = nullptr;
|
||||
Variant script; //reference does not yet exist, store it in a
|
||||
Variant script; // Reference does not exist yet, store it in a Variant.
|
||||
Dictionary metadata;
|
||||
mutable StringName _class_name;
|
||||
mutable const StringName *_class_ptr = nullptr;
|
||||
@ -583,6 +579,7 @@ protected:
|
||||
}
|
||||
return can_die;
|
||||
}
|
||||
|
||||
friend class NativeExtensionMethodBind;
|
||||
_ALWAYS_INLINE_ const ObjectNativeExtension *_get_extension() const { return _extension; }
|
||||
_ALWAYS_INLINE_ GDExtensionClassInstancePtr _get_extension_instance() const { return _extension_instance; }
|
||||
@ -617,9 +614,6 @@ protected:
|
||||
static void get_valid_parents_static(List<String> *p_parents);
|
||||
static void _get_valid_parents_static(List<String> *p_parents);
|
||||
|
||||
//Variant _call_bind(const StringName& p_name, const Variant& p_arg1 = Variant(), const Variant& p_arg2 = Variant(), const Variant& p_arg3 = Variant(), const Variant& p_arg4 = Variant());
|
||||
//void _call_deferred_bind(const StringName& p_name, const Variant& p_arg1 = Variant(), const Variant& p_arg2 = Variant(), const Variant& p_arg3 = Variant(), const Variant& p_arg4 = Variant());
|
||||
|
||||
Variant _call_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
|
||||
Variant _call_deferred_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
|
||||
|
||||
@ -641,7 +635,7 @@ protected:
|
||||
|
||||
void _disconnect(const StringName &p_signal, const Callable &p_callable, bool p_force = false);
|
||||
|
||||
public: //should be protected, but bug in clang++
|
||||
public: // Should be protected, but bug in clang++.
|
||||
static void initialize_class();
|
||||
_FORCE_INLINE_ static void register_custom_data_to_otdb() {}
|
||||
|
||||
@ -729,8 +723,6 @@ public:
|
||||
}
|
||||
|
||||
/* IAPI */
|
||||
//void set(const String& p_name, const Variant& p_value);
|
||||
//Variant get(const String& p_name) const;
|
||||
|
||||
void set(const StringName &p_name, const Variant &p_value, bool *r_valid = nullptr);
|
||||
Variant get(const StringName &p_name, bool *r_valid = nullptr) const;
|
||||
@ -748,7 +740,7 @@ public:
|
||||
void notification(int p_notification, bool p_reversed = false);
|
||||
virtual String to_string();
|
||||
|
||||
//used mainly by script, get and set all INCLUDING string
|
||||
// Used mainly by script, get and set all INCLUDING string.
|
||||
virtual Variant getvar(const Variant &p_key, bool *r_valid = nullptr) const;
|
||||
virtual void setvar(const Variant &p_key, const Variant &p_value, bool *r_valid = nullptr);
|
||||
|
||||
@ -757,8 +749,6 @@ public:
|
||||
void set_script(const Variant &p_script);
|
||||
Variant get_script() const;
|
||||
|
||||
/* SCRIPT */
|
||||
|
||||
bool has_meta(const StringName &p_name) const;
|
||||
void set_meta(const StringName &p_name, const Variant &p_value);
|
||||
void remove_meta(const StringName &p_name);
|
||||
@ -768,13 +758,15 @@ public:
|
||||
#ifdef TOOLS_ENABLED
|
||||
void set_edited(bool p_edited);
|
||||
bool is_edited() const;
|
||||
uint32_t get_edited_version() const; //this function is used to check when something changed beyond a point, it's used mainly for generating previews
|
||||
// This function is used to check when something changed beyond a point, it's used mainly for generating previews.
|
||||
uint32_t get_edited_version() const;
|
||||
#endif
|
||||
|
||||
void set_script_instance(ScriptInstance *p_instance);
|
||||
_FORCE_INLINE_ ScriptInstance *get_script_instance() const { return script_instance; }
|
||||
|
||||
void set_script_and_instance(const Variant &p_script, ScriptInstance *p_instance); //some script languages can't control instance creation, so this function eases the process
|
||||
// Some script languages can't control instance creation, so this function eases the process.
|
||||
void set_script_and_instance(const Variant &p_script, ScriptInstance *p_instance);
|
||||
|
||||
void add_user_signal(const MethodInfo &p_signal);
|
||||
Error emit_signal(const StringName &p_name, VARIANT_ARG_LIST);
|
||||
@ -803,10 +795,11 @@ public:
|
||||
|
||||
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
|
||||
|
||||
String tr(const StringName &p_message, const StringName &p_context = "") const; // translate message (internationalization)
|
||||
// Translate message (internationalization).
|
||||
String tr(const StringName &p_message, const StringName &p_context = "") const;
|
||||
String tr_n(const StringName &p_message, const StringName &p_message_plural, int p_n, const StringName &p_context = "") const;
|
||||
|
||||
bool _is_queued_for_deletion = false; // set to true by SceneTree::queue_delete()
|
||||
bool _is_queued_for_deletion = false; // Set to true by SceneTree::queue_delete().
|
||||
bool is_queued_for_deletion() const;
|
||||
|
||||
_FORCE_INLINE_ void set_message_translation(bool p_enable) { _can_translate = p_enable; }
|
||||
@ -838,14 +831,14 @@ bool predelete_handler(Object *p_object);
|
||||
void postinitialize_handler(Object *p_object);
|
||||
|
||||
class ObjectDB {
|
||||
//this needs to add up to 63, 1 bit is for reference
|
||||
// This needs to add up to 63, 1 bit is for reference.
|
||||
#define OBJECTDB_VALIDATOR_BITS 39
|
||||
#define OBJECTDB_VALIDATOR_MASK ((uint64_t(1) << OBJECTDB_VALIDATOR_BITS) - 1)
|
||||
#define OBJECTDB_SLOT_MAX_COUNT_BITS 24
|
||||
#define OBJECTDB_SLOT_MAX_COUNT_MASK ((uint64_t(1) << OBJECTDB_SLOT_MAX_COUNT_BITS) - 1)
|
||||
#define OBJECTDB_REFERENCE_BIT (uint64_t(1) << (OBJECTDB_SLOT_MAX_COUNT_BITS + OBJECTDB_VALIDATOR_BITS))
|
||||
|
||||
struct ObjectSlot { //128 bits per slot
|
||||
struct ObjectSlot { // 128 bits per slot.
|
||||
uint64_t validator : OBJECTDB_VALIDATOR_BITS;
|
||||
uint64_t next_free : OBJECTDB_SLOT_MAX_COUNT_BITS;
|
||||
uint64_t is_ref_counted : 1;
|
||||
@ -875,7 +868,7 @@ public:
|
||||
uint64_t id = p_instance_id;
|
||||
uint32_t slot = id & OBJECTDB_SLOT_MAX_COUNT_MASK;
|
||||
|
||||
ERR_FAIL_COND_V(slot >= slot_max, nullptr); //this should never happen unless RID is corrupted
|
||||
ERR_FAIL_COND_V(slot >= slot_max, nullptr); // This should never happen unless RID is corrupted.
|
||||
|
||||
spin_lock.lock();
|
||||
|
||||
|
@ -391,16 +391,18 @@ bool OS::has_feature(const String &p_feature) {
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
if (p_feature == "release")
|
||||
if (p_feature == "release") {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#ifdef TOOLS_ENABLED
|
||||
if (p_feature == "editor") {
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
if (p_feature == "standalone")
|
||||
if (p_feature == "standalone") {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (sizeof(void *) == 8 && p_feature == "64") {
|
||||
|
@ -41,7 +41,7 @@ class SpinLock {
|
||||
public:
|
||||
_ALWAYS_INLINE_ void lock() {
|
||||
while (locked.test_and_set(std::memory_order_acquire)) {
|
||||
;
|
||||
// Continue.
|
||||
}
|
||||
}
|
||||
_ALWAYS_INLINE_ void unlock() {
|
||||
|
@ -245,8 +245,9 @@ namespace godot {
|
||||
namespace details {
|
||||
inline String enum_qualified_name_to_class_info_name(const String &p_qualified_name) {
|
||||
Vector<String> parts = p_qualified_name.split("::", false);
|
||||
if (parts.size() <= 2)
|
||||
if (parts.size() <= 2) {
|
||||
return String(".").join(parts);
|
||||
}
|
||||
// Contains namespace. We only want the class and enum names.
|
||||
return parts[parts.size() - 2] + "." + parts[parts.size() - 1];
|
||||
}
|
||||
|
@ -174,9 +174,9 @@ OSStatus AudioDriverCoreAudio::output_callback(void *inRefCon,
|
||||
for (unsigned int i = 0; i < ioData->mNumberBuffers; i++) {
|
||||
AudioBuffer *abuf = &ioData->mBuffers[i];
|
||||
memset(abuf->mData, 0, abuf->mDataByteSize);
|
||||
};
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
ad->start_counting_ticks();
|
||||
|
||||
@ -195,14 +195,14 @@ OSStatus AudioDriverCoreAudio::output_callback(void *inRefCon,
|
||||
|
||||
frames_left -= frames;
|
||||
out += frames * ad->channels;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
ad->stop_counting_ticks();
|
||||
ad->unlock();
|
||||
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
OSStatus AudioDriverCoreAudio::input_callback(void *inRefCon,
|
||||
AudioUnitRenderActionFlags *ioActionFlags,
|
||||
@ -251,7 +251,7 @@ void AudioDriverCoreAudio::start() {
|
||||
active = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void AudioDriverCoreAudio::stop() {
|
||||
if (active) {
|
||||
@ -266,19 +266,19 @@ void AudioDriverCoreAudio::stop() {
|
||||
|
||||
int AudioDriverCoreAudio::get_mix_rate() const {
|
||||
return mix_rate;
|
||||
};
|
||||
}
|
||||
|
||||
AudioDriver::SpeakerMode AudioDriverCoreAudio::get_speaker_mode() const {
|
||||
return get_speaker_mode_by_total_channels(channels);
|
||||
};
|
||||
}
|
||||
|
||||
void AudioDriverCoreAudio::lock() {
|
||||
mutex.lock();
|
||||
};
|
||||
}
|
||||
|
||||
void AudioDriverCoreAudio::unlock() {
|
||||
mutex.unlock();
|
||||
};
|
||||
}
|
||||
|
||||
bool AudioDriverCoreAudio::try_lock() {
|
||||
return mutex.try_lock() == OK;
|
||||
@ -521,8 +521,9 @@ Array AudioDriverCoreAudio::_get_device_list(bool capture) {
|
||||
AudioObjectGetPropertyData(audioDevices[i], &prop, 0, nullptr, &size, bufferList);
|
||||
|
||||
UInt32 channelCount = 0;
|
||||
for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++)
|
||||
for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++) {
|
||||
channelCount += bufferList->mBuffers[j].mNumberChannels;
|
||||
}
|
||||
|
||||
memfree(bufferList);
|
||||
|
||||
@ -579,8 +580,9 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
|
||||
AudioObjectGetPropertyData(audioDevices[i], &prop, 0, nullptr, &size, bufferList);
|
||||
|
||||
UInt32 channelCount = 0;
|
||||
for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++)
|
||||
for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++) {
|
||||
channelCount += bufferList->mBuffers[j].mNumberChannels;
|
||||
}
|
||||
|
||||
memfree(bufferList);
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "rasterizer_scene_gles3.h"
|
||||
|
||||
#ifdef GLES3_ENABLED
|
||||
|
||||
// TODO: 3D support not implemented yet.
|
||||
|
@ -29,6 +29,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "rasterizer_storage_gles3.h"
|
||||
|
||||
#ifdef GLES3_ENABLED
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
@ -3716,10 +3717,11 @@ void RasterizerStorageGLES3::canvas_light_occluder_set_polylines(RID p_occluder,
|
||||
co->lines = p_lines;
|
||||
|
||||
if (p_lines.size() != co->len) {
|
||||
if (co->index_id)
|
||||
if (co->index_id) {
|
||||
glDeleteBuffers(1, &co->index_id);
|
||||
if (co->vertex_id)
|
||||
} if (co->vertex_id) {
|
||||
glDeleteBuffers(1, &co->vertex_id);
|
||||
}
|
||||
|
||||
co->index_id = 0;
|
||||
co->vertex_id = 0;
|
||||
@ -4014,10 +4016,12 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
|
||||
|
||||
} else if (canvas_occluder_owner.owns(p_rid)) {
|
||||
CanvasOccluder *co = canvas_occluder_owner.get_or_null(p_rid);
|
||||
if (co->index_id)
|
||||
if (co->index_id) {
|
||||
glDeleteBuffers(1, &co->index_id);
|
||||
if (co->vertex_id)
|
||||
}
|
||||
if (co->vertex_id) {
|
||||
glDeleteBuffers(1, &co->vertex_id);
|
||||
}
|
||||
|
||||
canvas_occluder_owner.free(p_rid);
|
||||
memdelete(co);
|
||||
|
@ -29,6 +29,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "shader_gles3.h"
|
||||
|
||||
#ifdef GLES3_ENABLED
|
||||
|
||||
#include "core/io/compression.h"
|
||||
|
@ -29,6 +29,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "texture_loader_gles3.h"
|
||||
|
||||
#ifdef GLES3_ENABLED
|
||||
|
||||
#include "core/io/file_access.h"
|
||||
|
@ -46,7 +46,7 @@ Error ResourceSaverPNG::save(const String &p_path, const RES &p_resource, uint32
|
||||
Error err = save_image(p_path, img);
|
||||
|
||||
return err;
|
||||
};
|
||||
}
|
||||
|
||||
Error ResourceSaverPNG::save_image(const String &p_path, const Ref<Image> &p_img) {
|
||||
Vector<uint8_t> buffer;
|
||||
@ -89,4 +89,4 @@ void ResourceSaverPNG::get_recognized_extensions(const RES &p_resource, List<Str
|
||||
ResourceSaverPNG::ResourceSaverPNG() {
|
||||
Image::save_png_func = &save_image;
|
||||
Image::save_png_buffer_func = &save_image_to_buffer;
|
||||
};
|
||||
}
|
||||
|
@ -138,9 +138,9 @@ uint64_t DirAccessUnix::get_modified_time(String p_file) {
|
||||
return flags.st_mtime;
|
||||
} else {
|
||||
ERR_FAIL_V(0);
|
||||
};
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
String DirAccessUnix::get_next() {
|
||||
if (!dir_stream) {
|
||||
@ -320,11 +320,11 @@ Error DirAccessUnix::make_dir(String p_dir) {
|
||||
|
||||
if (success) {
|
||||
return OK;
|
||||
};
|
||||
}
|
||||
|
||||
if (err == EEXIST) {
|
||||
return ERR_ALREADY_EXISTS;
|
||||
};
|
||||
}
|
||||
|
||||
return ERR_CANT_CREATE;
|
||||
}
|
||||
@ -474,14 +474,14 @@ uint64_t DirAccessUnix::get_space_left() {
|
||||
struct statvfs vfs;
|
||||
if (statvfs(current_dir.utf8().get_data(), &vfs) != 0) {
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
return (uint64_t)vfs.f_bavail * (uint64_t)vfs.f_frsize;
|
||||
#else
|
||||
// FIXME: Implement this.
|
||||
return 0;
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
String DirAccessUnix::get_filesystem_type() const {
|
||||
return ""; //TODO this should be implemented
|
||||
|
@ -246,7 +246,7 @@ uint64_t FileAccessUnix::get_buffer(uint8_t *p_dst, uint64_t p_length) const {
|
||||
uint64_t read = fread(p_dst, 1, p_length, f);
|
||||
check_errors();
|
||||
return read;
|
||||
};
|
||||
}
|
||||
|
||||
Error FileAccessUnix::get_error() const {
|
||||
return last_error;
|
||||
@ -285,8 +285,9 @@ bool FileAccessUnix::file_exists(const String &p_path) {
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
if (_access(filename.utf8().get_data(), 4) == -1)
|
||||
if (_access(filename.utf8().get_data(), 4) == -1) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// See if this is a regular file
|
||||
@ -309,7 +310,7 @@ uint64_t FileAccessUnix::_get_modified_time(const String &p_file) {
|
||||
} else {
|
||||
print_verbose("Failed to get modified time for: " + p_file + "");
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t FileAccessUnix::_get_unix_permissions(const String &p_file) {
|
||||
@ -321,7 +322,7 @@ uint32_t FileAccessUnix::_get_unix_permissions(const String &p_file) {
|
||||
return flags.st_mode & 0x7FF; //only permissions
|
||||
} else {
|
||||
ERR_FAIL_V_MSG(0, "Failed to get unix permissions for: " + p_file + ".");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Error FileAccessUnix::_set_unix_permissions(const String &p_file, uint32_t p_permissions) {
|
||||
|
@ -72,10 +72,10 @@ static IPAddress _sockaddr2ip(struct sockaddr *p_addr) {
|
||||
} else if (p_addr->sa_family == AF_INET6) {
|
||||
struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)p_addr;
|
||||
ip.set_ipv6(addr6->sin6_addr.s6_addr);
|
||||
};
|
||||
}
|
||||
|
||||
return ip;
|
||||
};
|
||||
}
|
||||
|
||||
void IPUnix::_resolve_hostname(List<IPAddress> &r_addresses, const String &p_hostname, Type p_type) const {
|
||||
struct addrinfo hints;
|
||||
@ -90,14 +90,14 @@ void IPUnix::_resolve_hostname(List<IPAddress> &r_addresses, const String &p_hos
|
||||
} else {
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_flags = AI_ADDRCONFIG;
|
||||
};
|
||||
}
|
||||
hints.ai_flags &= ~AI_NUMERICHOST;
|
||||
|
||||
int s = getaddrinfo(p_hostname.utf8().get_data(), nullptr, &hints, &result);
|
||||
if (s != 0) {
|
||||
ERR_PRINT("getaddrinfo failed! Cannot resolve hostname.");
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
if (result == nullptr || result->ai_addr == nullptr) {
|
||||
ERR_PRINT("Invalid response from getaddrinfo");
|
||||
@ -105,7 +105,7 @@ void IPUnix::_resolve_hostname(List<IPAddress> &r_addresses, const String &p_hos
|
||||
freeaddrinfo(result);
|
||||
}
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
struct addrinfo *next = result;
|
||||
|
||||
@ -138,8 +138,9 @@ void IPUnix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) con
|
||||
for (int i = 0; i < hostnames->Size; i++) {
|
||||
auto hostname = hostnames->GetAt(i);
|
||||
|
||||
if (hostname->Type != HostNameType::Ipv4 && hostname->Type != HostNameType::Ipv6)
|
||||
if (hostname->Type != HostNameType::Ipv4 && hostname->Type != HostNameType::Ipv6) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = hostname->RawName->Data();
|
||||
Map<String, Interface_Info>::Element *E = r_interfaces->find(name);
|
||||
@ -171,14 +172,14 @@ void IPUnix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) con
|
||||
nullptr, addrs, &buf_size);
|
||||
if (err == NO_ERROR) {
|
||||
break;
|
||||
};
|
||||
}
|
||||
memfree(addrs);
|
||||
if (err == ERROR_BUFFER_OVERFLOW) {
|
||||
continue; // will go back and alloc the right size
|
||||
};
|
||||
}
|
||||
|
||||
ERR_FAIL_MSG("Call to GetAdaptersAddresses failed with error " + itos(err) + ".");
|
||||
};
|
||||
}
|
||||
|
||||
IP_ADAPTER_ADDRESSES *adapter = addrs;
|
||||
|
||||
@ -191,19 +192,21 @@ void IPUnix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) con
|
||||
IP_ADAPTER_UNICAST_ADDRESS *address = adapter->FirstUnicastAddress;
|
||||
while (address != nullptr) {
|
||||
int family = address->Address.lpSockaddr->sa_family;
|
||||
if (family != AF_INET && family != AF_INET6)
|
||||
if (family != AF_INET && family != AF_INET6) {
|
||||
continue;
|
||||
}
|
||||
info.ip_addresses.push_front(_sockaddr2ip(address->Address.lpSockaddr));
|
||||
address = address->Next;
|
||||
}
|
||||
adapter = adapter->Next;
|
||||
// Only add interface if it has at least one IP
|
||||
if (info.ip_addresses.size() > 0)
|
||||
if (info.ip_addresses.size() > 0) {
|
||||
r_interfaces->insert(info.name, info);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
memfree(addrs);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -147,7 +147,7 @@ void NetSocketPosix::_set_ip_port(struct sockaddr_storage *p_addr, IPAddress *r_
|
||||
if (r_port) {
|
||||
*r_port = ntohs(addr6->sin6_port);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
NetSocket *NetSocketPosix::_create_func() {
|
||||
@ -325,8 +325,9 @@ Error NetSocketPosix::open(Type p_sock_type, IP::Type &ip_type) {
|
||||
|
||||
#if defined(__OpenBSD__)
|
||||
// OpenBSD does not support dual stacking, fallback to IPv4 only.
|
||||
if (ip_type == IP::TYPE_ANY)
|
||||
if (ip_type == IP::TYPE_ANY) {
|
||||
ip_type = IP::TYPE_IPV4;
|
||||
}
|
||||
#endif
|
||||
|
||||
int family = ip_type == IP::TYPE_IPV4 ? AF_INET : AF_INET6;
|
||||
@ -420,7 +421,7 @@ Error NetSocketPosix::listen(int p_max_pending) {
|
||||
print_verbose("Failed to listen from socket.");
|
||||
close();
|
||||
return FAILED;
|
||||
};
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
@ -494,8 +495,9 @@ Error NetSocketPosix::poll(PollType p_type, int p_timeout) const {
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
if (ret == 0)
|
||||
if (ret == 0) {
|
||||
return ERR_BUSY;
|
||||
}
|
||||
|
||||
if (FD_ISSET(_sock, &ex)) {
|
||||
_get_socket_error();
|
||||
@ -503,10 +505,12 @@ Error NetSocketPosix::poll(PollType p_type, int p_timeout) const {
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
if (rdp && FD_ISSET(_sock, rdp))
|
||||
if (rdp && FD_ISSET(_sock, rdp)) {
|
||||
ready = true;
|
||||
if (wrp && FD_ISSET(_sock, wrp))
|
||||
}
|
||||
if (wrp && FD_ISSET(_sock, wrp)) {
|
||||
ready = true;
|
||||
}
|
||||
|
||||
return ready ? OK : ERR_BUSY;
|
||||
#else
|
||||
|
@ -106,7 +106,7 @@ static void _setup_clock() {
|
||||
|
||||
void OS_Unix::debug_break() {
|
||||
assert(false);
|
||||
};
|
||||
}
|
||||
|
||||
static void handle_interrupt(int sig) {
|
||||
if (!EngineDebugger::is_active()) {
|
||||
@ -198,7 +198,7 @@ double OS_Unix::get_unix_time() const {
|
||||
struct timeval tv_now;
|
||||
gettimeofday(&tv_now, nullptr);
|
||||
return (double)tv_now.tv_sec + double(tv_now.tv_usec) / 1000000;
|
||||
};
|
||||
}
|
||||
|
||||
OS::Date OS_Unix::get_date(bool p_utc) const {
|
||||
time_t t = time(nullptr);
|
||||
@ -410,7 +410,7 @@ Error OS_Unix::kill(const ProcessID &p_pid) {
|
||||
|
||||
int OS_Unix::get_process_id() const {
|
||||
return getpid();
|
||||
};
|
||||
}
|
||||
|
||||
bool OS_Unix::has_environment(const String &p_var) const {
|
||||
return getenv(p_var.utf8().get_data()) != nullptr;
|
||||
@ -555,8 +555,9 @@ String OS_Unix::get_executable_path() const {
|
||||
|
||||
char *resolved_path = new char[buff_size + 1];
|
||||
|
||||
if (_NSGetExecutablePath(resolved_path, &buff_size) == 1)
|
||||
if (_NSGetExecutablePath(resolved_path, &buff_size) == 1) {
|
||||
WARN_PRINT("MAXPATHLEN is too small");
|
||||
}
|
||||
|
||||
String path(resolved_path);
|
||||
delete[] resolved_path;
|
||||
|
@ -31,7 +31,9 @@
|
||||
#ifdef UNIX_ENABLED
|
||||
|
||||
#include "syslog_logger.h"
|
||||
|
||||
#include "core/string/print_string.h"
|
||||
|
||||
#include <syslog.h>
|
||||
|
||||
void SyslogLogger::logv(const char *p_format, va_list p_list, bool p_err) {
|
||||
|
@ -1200,7 +1200,7 @@ uint32_t RenderingDeviceVulkan::get_image_required_mipmaps(uint32_t p_width, uin
|
||||
d = MAX(1, d >> 1);
|
||||
|
||||
mipmaps++;
|
||||
};
|
||||
}
|
||||
|
||||
return mipmaps;
|
||||
}
|
||||
@ -3679,7 +3679,7 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
|
||||
// Set view masks for each subpass
|
||||
for (uint32_t i = 0; i < subpasses.size(); i++) {
|
||||
view_masks.push_back(view_mask);
|
||||
};
|
||||
}
|
||||
|
||||
render_pass_multiview_create_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO;
|
||||
render_pass_multiview_create_info.pNext = nullptr;
|
||||
@ -6326,7 +6326,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma
|
||||
|
||||
attachment_states.push_back(state);
|
||||
idx++;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(attachment_states.size() != p_blend_state.attachments.size(), RID());
|
||||
@ -9013,49 +9013,49 @@ uint64_t RenderingDeviceVulkan::get_driver_resource(DriverResource p_resource, R
|
||||
switch (p_resource) {
|
||||
case DRIVER_RESOURCE_VULKAN_DEVICE: {
|
||||
return (uint64_t)context->get_device();
|
||||
}; break;
|
||||
} break;
|
||||
case DRIVER_RESOURCE_VULKAN_PHYSICAL_DEVICE: {
|
||||
return (uint64_t)context->get_physical_device();
|
||||
}; break;
|
||||
} break;
|
||||
case DRIVER_RESOURCE_VULKAN_INSTANCE: {
|
||||
return (uint64_t)context->get_instance();
|
||||
}; break;
|
||||
} break;
|
||||
case DRIVER_RESOURCE_VULKAN_QUEUE: {
|
||||
return (uint64_t)context->get_graphics_queue();
|
||||
}; break;
|
||||
} break;
|
||||
case DRIVER_RESOURCE_VULKAN_QUEUE_FAMILY_INDEX: {
|
||||
return context->get_graphics_queue_family_index();
|
||||
}; break;
|
||||
} break;
|
||||
case DRIVER_RESOURCE_VULKAN_IMAGE: {
|
||||
Texture *tex = texture_owner.get_or_null(p_rid);
|
||||
ERR_FAIL_NULL_V(tex, 0);
|
||||
|
||||
return (uint64_t)tex->image;
|
||||
}; break;
|
||||
} break;
|
||||
case DRIVER_RESOURCE_VULKAN_IMAGE_VIEW: {
|
||||
Texture *tex = texture_owner.get_or_null(p_rid);
|
||||
ERR_FAIL_NULL_V(tex, 0);
|
||||
|
||||
return (uint64_t)tex->view;
|
||||
}; break;
|
||||
} break;
|
||||
case DRIVER_RESOURCE_VULKAN_IMAGE_NATIVE_TEXTURE_FORMAT: {
|
||||
Texture *tex = texture_owner.get_or_null(p_rid);
|
||||
ERR_FAIL_NULL_V(tex, 0);
|
||||
|
||||
return vulkan_formats[tex->format];
|
||||
}; break;
|
||||
} break;
|
||||
case DRIVER_RESOURCE_VULKAN_SAMPLER: {
|
||||
VkSampler *sampler = sampler_owner.get_or_null(p_rid);
|
||||
ERR_FAIL_NULL_V(sampler, 0);
|
||||
|
||||
return uint64_t(*sampler);
|
||||
}; break;
|
||||
} break;
|
||||
case DRIVER_RESOURCE_VULKAN_DESCRIPTOR_SET: {
|
||||
UniformSet *uniform_set = uniform_set_owner.get_or_null(p_rid);
|
||||
ERR_FAIL_NULL_V(uniform_set, 0);
|
||||
|
||||
return uint64_t(uniform_set->descriptor_set);
|
||||
}; break;
|
||||
} break;
|
||||
case DRIVER_RESOURCE_VULKAN_BUFFER: {
|
||||
Buffer *buffer = nullptr;
|
||||
if (vertex_buffer_owner.owns(p_rid)) {
|
||||
@ -9073,23 +9073,23 @@ uint64_t RenderingDeviceVulkan::get_driver_resource(DriverResource p_resource, R
|
||||
ERR_FAIL_NULL_V(buffer, 0);
|
||||
|
||||
return uint64_t(buffer->buffer);
|
||||
}; break;
|
||||
} break;
|
||||
case DRIVER_RESOURCE_VULKAN_COMPUTE_PIPELINE: {
|
||||
ComputePipeline *compute_pipeline = compute_pipeline_owner.get_or_null(p_rid);
|
||||
ERR_FAIL_NULL_V(compute_pipeline, 0);
|
||||
|
||||
return uint64_t(compute_pipeline->pipeline);
|
||||
}; break;
|
||||
} break;
|
||||
case DRIVER_RESOURCE_VULKAN_RENDER_PIPELINE: {
|
||||
RenderPipeline *render_pipeline = render_pipeline_owner.get_or_null(p_rid);
|
||||
ERR_FAIL_NULL_V(render_pipeline, 0);
|
||||
|
||||
return uint64_t(render_pipeline->pipeline);
|
||||
}; break;
|
||||
} break;
|
||||
default: {
|
||||
// not supported for this driver
|
||||
return 0;
|
||||
}; break;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -454,8 +454,9 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c
|
||||
|
||||
Error AudioDriverWASAPI::init_render_device(bool reinit) {
|
||||
Error err = audio_device_init(&audio_output, false, reinit);
|
||||
if (err != OK)
|
||||
if (err != OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
switch (audio_output.channels) {
|
||||
case 2: // Stereo
|
||||
@ -485,8 +486,9 @@ Error AudioDriverWASAPI::init_render_device(bool reinit) {
|
||||
|
||||
Error AudioDriverWASAPI::init_capture_device(bool reinit) {
|
||||
Error err = audio_device_init(&audio_input, true, reinit);
|
||||
if (err != OK)
|
||||
if (err != OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
// Get the max frames
|
||||
UINT32 max_frames;
|
||||
|
@ -87,7 +87,7 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) {
|
||||
if (!S_ISREG(st.st_mode)) {
|
||||
return ERR_FILE_CANT_OPEN;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
// Windows is case insensitive, but all other platforms are sensitive to it
|
||||
@ -269,7 +269,7 @@ uint64_t FileAccessWindows::get_buffer(uint8_t *p_dst, uint64_t p_length) const
|
||||
uint64_t read = fread(p_dst, 1, p_length, f);
|
||||
check_errors();
|
||||
return read;
|
||||
};
|
||||
}
|
||||
|
||||
Error FileAccessWindows::get_error() const {
|
||||
return last_error;
|
||||
@ -326,8 +326,9 @@ bool FileAccessWindows::file_exists(const String &p_name) {
|
||||
|
||||
uint64_t FileAccessWindows::_get_modified_time(const String &p_file) {
|
||||
String file = fix_path(p_file);
|
||||
if (file.ends_with("/") && file != "/")
|
||||
if (file.ends_with("/") && file != "/") {
|
||||
file = file.substr(0, file.length() - 1);
|
||||
}
|
||||
|
||||
struct _stat st;
|
||||
int rv = _wstat((LPCWSTR)(file.utf16().get_data()), &st);
|
||||
|
@ -1289,10 +1289,6 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
|
||||
// 3-move the keys (re insert them)
|
||||
for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) {
|
||||
float newpos = editor->snap_time(animation->track_get_key_time(E->get().first, E->get().second) + moving_selection_offset.x);
|
||||
/*
|
||||
if (newpos<0)
|
||||
continue; //no add at the beginning
|
||||
*/
|
||||
Array key = animation->track_get_key_value(E->get().first, E->get().second);
|
||||
float h = key[0];
|
||||
h += moving_selection_offset.y;
|
||||
@ -1303,10 +1299,6 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
|
||||
// 4-(undo) remove inserted keys
|
||||
for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) {
|
||||
float newpos = editor->snap_time(animation->track_get_key_time(E->get().first, E->get().second) + moving_selection_offset.x);
|
||||
/*
|
||||
if (newpos<0)
|
||||
continue; //no remove what no inserted
|
||||
*/
|
||||
undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", E->get().first, newpos);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,6 @@ void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) {
|
||||
}
|
||||
|
||||
frame_metrics.write[last_metric] = p_metric;
|
||||
// _make_metric_ptrs(frame_metrics.write[last_metric]);
|
||||
|
||||
List<String> stack;
|
||||
for (int i = 0; i < frame_metrics[last_metric].areas.size(); i++) {
|
||||
@ -482,19 +481,6 @@ void EditorVisualProfiler::_graph_tex_draw() {
|
||||
|
||||
graph->draw_string(font, Vector2(font->get_string_size("X", font_size).x, font->get_ascent(font_size) + 2), "CPU:", HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(1, 1, 1, 0.8));
|
||||
graph->draw_string(font, Vector2(font->get_string_size("X", font_size).x + graph->get_size().width / 2, font->get_ascent(font_size) + 2), "GPU:", HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(1, 1, 1, 0.8));
|
||||
|
||||
/*
|
||||
if (hover_metric != -1 && frame_metrics[hover_metric].valid) {
|
||||
int max_frames = frame_metrics.size();
|
||||
int frame = frame_metrics[hover_metric].frame_number - (frame_metrics[last_metric].frame_number - max_frames + 1);
|
||||
if (frame < 0)
|
||||
frame = 0;
|
||||
|
||||
int cur_x = frame * graph->get_size().x / max_frames;
|
||||
|
||||
graph->draw_line(Vector2(cur_x, 0), Vector2(cur_x, graph->get_size().y), Color(1, 1, 1, 0.4));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void EditorVisualProfiler::_graph_tex_mouse_exit() {
|
||||
|
@ -589,11 +589,6 @@ void EditorData::remove_scene(int p_idx) {
|
||||
}
|
||||
|
||||
bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, Set<String> &checked_paths) {
|
||||
/*
|
||||
if (p_root!=p_node && p_node->get_owner()!=p_root && !p_root->is_editable_instance(p_node->get_owner()))
|
||||
return false;
|
||||
*/
|
||||
|
||||
Ref<SceneState> ss;
|
||||
|
||||
if (p_node == p_root) {
|
||||
|
@ -1867,7 +1867,6 @@ int EditorInspectorArray::_drop_position() const {
|
||||
|
||||
void EditorInspectorArray::_new_size_line_edit_text_changed(String p_text) {
|
||||
bool valid = false;
|
||||
;
|
||||
if (p_text.is_valid_int()) {
|
||||
int val = p_text.to_int();
|
||||
if (val > 0 && val != count) {
|
||||
@ -1879,7 +1878,6 @@ void EditorInspectorArray::_new_size_line_edit_text_changed(String p_text) {
|
||||
|
||||
void EditorInspectorArray::_new_size_line_edit_text_submitted(String p_text) {
|
||||
bool valid = false;
|
||||
;
|
||||
if (p_text.is_valid_int()) {
|
||||
int val = p_text.to_int();
|
||||
if (val > 0 && val != count) {
|
||||
|
@ -3916,8 +3916,9 @@ Ref<Script> EditorNode::get_object_custom_type_base(const Object *p_object) cons
|
||||
if (script.is_valid()) {
|
||||
// Uncommenting would break things! Consider adding a parameter if you need it.
|
||||
// StringName name = EditorNode::get_editor_data().script_class_get_name(base_script->get_path());
|
||||
// if (name != StringName())
|
||||
// if (name != StringName()) {
|
||||
// return name;
|
||||
// }
|
||||
|
||||
// should probably be deprecated in 4.x
|
||||
StringName base = script->get_instance_base_type();
|
||||
@ -5745,7 +5746,6 @@ static void _execute_thread(void *p_ud) {
|
||||
}
|
||||
|
||||
eta->done.set();
|
||||
;
|
||||
}
|
||||
|
||||
int EditorNode::execute_and_show_output(const String &p_title, const String &p_path, const List<String> &p_arguments, bool p_close_on_ok, bool p_close_on_errors) {
|
||||
|
@ -1009,11 +1009,6 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name
|
||||
String source = _uri_to_id(parser.get_attribute_value("source"));
|
||||
|
||||
if (semantic == "TEXCOORD") {
|
||||
/*
|
||||
if (parser.has_attribute("set"))// a texcoord
|
||||
semantic+=parser.get_attribute_value("set");
|
||||
else
|
||||
semantic="TEXCOORD0";*/
|
||||
semantic = "TEXCOORD" + itos(last_ref++);
|
||||
}
|
||||
int offset = parser.get_attribute_value("offset").to_int();
|
||||
@ -1194,11 +1189,6 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) {
|
||||
|
||||
skindata.weights = weights;
|
||||
}
|
||||
/*
|
||||
else if (!parser.is_empty())
|
||||
parser.skip_section();
|
||||
*/
|
||||
|
||||
} else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "skin") {
|
||||
break;
|
||||
}
|
||||
@ -1258,19 +1248,8 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) {
|
||||
}
|
||||
} else if (section == "Name_array" || section == "IDREF_array") {
|
||||
// create a new array and read it.
|
||||
|
||||
/*
|
||||
if (section=="IDREF_array")
|
||||
morphdata.use_idrefs=true;
|
||||
*/
|
||||
if (morphdata.sources.has(current_source)) {
|
||||
morphdata.sources[current_source].sarray = _read_string_array(parser);
|
||||
/*
|
||||
if (section=="IDREF_array") {
|
||||
Vector<String> sa = morphdata.sources[current_source].sarray;
|
||||
for(int i=0;i<sa.size();i++)
|
||||
state.idref_joints.insert(sa[i]);
|
||||
}*/
|
||||
COLLADA_PRINT("section: " + current_source + " read " + itos(morphdata.sources[current_source].array.size()) + " values.");
|
||||
}
|
||||
} else if (section == "technique_common") {
|
||||
@ -1303,11 +1282,6 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) {
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
else if (!parser.is_empty())
|
||||
parser.skip_section();
|
||||
*/
|
||||
|
||||
} else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "morph") {
|
||||
break;
|
||||
}
|
||||
|
@ -317,8 +317,6 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
|
||||
ERR_FAIL_INDEX_V(vtx, vertices.size(), ERR_FILE_CORRUPT);
|
||||
|
||||
Vector3 vertex = vertices[vtx];
|
||||
//if (weld_vertices)
|
||||
// vertex.snap(Vector3(weld_tolerance, weld_tolerance, weld_tolerance));
|
||||
if (!smoothing) {
|
||||
smooth_group++;
|
||||
}
|
||||
|
@ -28,8 +28,8 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef RESOURCEIMPORTWAV_H
|
||||
#define RESOURCEIMPORTWAV_H
|
||||
#ifndef RESOURCE_IMPORTER_WAV_H
|
||||
#define RESOURCE_IMPORTER_WAV_H
|
||||
|
||||
#include "core/io/resource_importer.h"
|
||||
|
||||
@ -50,9 +50,6 @@ public:
|
||||
virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
|
||||
static void _compress_ima_adpcm(const Vector<float> &p_data, Vector<uint8_t> &dst_data) {
|
||||
/*p_sample_data->data = (void*)malloc(len);
|
||||
xm_s8 *dataptr=(xm_s8*)p_sample_data->data;*/
|
||||
|
||||
static const int16_t _ima_adpcm_step_table[89] = {
|
||||
7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
|
||||
19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
|
||||
@ -81,15 +78,14 @@ public:
|
||||
|
||||
int i, step_idx = 0, prev = 0;
|
||||
uint8_t *out = w;
|
||||
//int16_t xm_prev=0;
|
||||
const float *in = p_data.ptr();
|
||||
|
||||
/* initial value is zero */
|
||||
// Initial value is zero.
|
||||
*(out++) = 0;
|
||||
*(out++) = 0;
|
||||
/* Table index initial value */
|
||||
// Table index initial value.
|
||||
*(out++) = 0;
|
||||
/* unused */
|
||||
// Unused.
|
||||
*(out++) = 0;
|
||||
|
||||
for (i = 0; i < datalen; i++) {
|
||||
@ -101,15 +97,8 @@ public:
|
||||
xm_sample = 0;
|
||||
} else {
|
||||
xm_sample = CLAMP(in[i] * 32767.0, -32768, 32767);
|
||||
/*
|
||||
if (xm_sample==32767 || xm_sample==-32768)
|
||||
printf("clippy!\n",xm_sample);
|
||||
*/
|
||||
}
|
||||
|
||||
//xm_sample=xm_sample+xm_prev;
|
||||
//xm_prev=xm_sample;
|
||||
|
||||
diff = (int)xm_sample - prev;
|
||||
|
||||
nibble = 0;
|
||||
@ -129,7 +118,7 @@ public:
|
||||
|
||||
step >>= 1;
|
||||
mask >>= 1;
|
||||
};
|
||||
}
|
||||
|
||||
if (nibble & 8) {
|
||||
prev -= vpdiff;
|
||||
@ -137,20 +126,10 @@ public:
|
||||
prev += vpdiff;
|
||||
}
|
||||
|
||||
if (prev > 32767) {
|
||||
//printf("%i,xms %i, prev %i,diff %i, vpdiff %i, clip up %i\n",i,xm_sample,prev,diff,vpdiff,prev);
|
||||
prev = 32767;
|
||||
} else if (prev < -32768) {
|
||||
//printf("%i,xms %i, prev %i,diff %i, vpdiff %i, clip down %i\n",i,xm_sample,prev,diff,vpdiff,prev);
|
||||
prev = -32768;
|
||||
}
|
||||
prev = CLAMP(prev, -32768, 32767);
|
||||
|
||||
step_idx += _ima_adpcm_index_table[nibble];
|
||||
if (step_idx < 0) {
|
||||
step_idx = 0;
|
||||
} else if (step_idx > 88) {
|
||||
step_idx = 88;
|
||||
}
|
||||
step_idx = CLAMP(step_idx, 0, 88);
|
||||
|
||||
if (i & 1) {
|
||||
*out |= nibble << 4;
|
||||
@ -158,7 +137,6 @@ public:
|
||||
} else {
|
||||
*out = nibble;
|
||||
}
|
||||
/*dataptr[i]=prev>>8;*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,4 +145,4 @@ public:
|
||||
ResourceImporterWAV();
|
||||
};
|
||||
|
||||
#endif // RESOURCEIMPORTWAV_H
|
||||
#endif // RESOURCE_IMPORTER_WAV_H
|
||||
|
@ -1069,7 +1069,6 @@ void EditorNode3DGizmoPlugin::_bind_methods() {
|
||||
GDVIRTUAL_BIND(_get_subgizmo_transform, "gizmo", "subgizmo_id");
|
||||
GDVIRTUAL_BIND(_set_subgizmo_transform, "gizmo", "subgizmo_id", "transform");
|
||||
GDVIRTUAL_BIND(_commit_subgizmos, "gizmo", "ids", "restores", "cancel");
|
||||
;
|
||||
}
|
||||
|
||||
bool EditorNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
|
||||
|
@ -1070,7 +1070,7 @@ void Polygon2DEditor::_uv_draw() {
|
||||
if (uv_create && i == uvs.size() - 1) {
|
||||
next_point = uv_create_to;
|
||||
}
|
||||
if (i < uv_draw_max /*&& polygons.size() == 0 && polygon_create.size() == 0*/) { //if using or creating polygons, do not show outline (will show polygons instead)
|
||||
if (i < uv_draw_max) { // If using or creating polygons, do not show outline (will show polygons instead).
|
||||
uv_edit_draw->draw_line(mtx.xform(uvs[i]), mtx.xform(next_point), poly_line_color, Math::round(EDSCALE));
|
||||
}
|
||||
}
|
||||
|
@ -464,14 +464,6 @@ void ShaderEditor::_bind_methods() {
|
||||
}
|
||||
|
||||
void ShaderEditor::ensure_select_current() {
|
||||
/*
|
||||
if (tab_container->get_child_count() && tab_container->get_current_tab()>=0) {
|
||||
ShaderTextEditor *ste = Object::cast_to<ShaderTextEditor>(tab_container->get_child(tab_container->get_current_tab()));
|
||||
if (!ste)
|
||||
return;
|
||||
Ref<Shader> shader = ste->get_edited_shader();
|
||||
get_scene()->get_root_node()->call("_resource_selected",shader);
|
||||
}*/
|
||||
}
|
||||
|
||||
void ShaderEditor::goto_line_selection(int p_line, int p_begin, int p_end) {
|
||||
|
@ -32,7 +32,6 @@
|
||||
|
||||
#include "core/os/os.h"
|
||||
#include "servers/rendering_server.h"
|
||||
#include "texture_basisu.h"
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
#include <encoder/basisu_comp.h>
|
||||
@ -272,7 +271,6 @@ void register_basis_universal_types() {
|
||||
Image::basis_universal_packer = basis_universal_packer;
|
||||
#endif
|
||||
Image::basis_universal_unpacker = basis_universal_unpacker;
|
||||
//GDREGISTER_CLASS(TextureBasisU);
|
||||
}
|
||||
|
||||
void unregister_basis_universal_types() {
|
||||
|
@ -1,218 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* texture_basisu.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 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 "texture_basisu.h"
|
||||
#if 0
|
||||
#include "core/os/os.h"
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
#include <encoder/basisu_comp.h>
|
||||
#endif
|
||||
|
||||
#include <transcoder/basisu_transcoder.h>
|
||||
|
||||
void TextureBasisU::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_basisu_data", "data"), &TextureBasisU::set_basisu_data);
|
||||
ClassDB::bind_method(D_METHOD("get_basisu_data"), &TextureBasisU::get_data);
|
||||
ClassDB::bind_method(D_METHOD("import"), &TextureBasisU::import);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "basisu_data"), "set_basisu_data", "get_basisu_data");
|
||||
};
|
||||
|
||||
int TextureBasisU::get_width() const {
|
||||
return tex_size.x;
|
||||
};
|
||||
|
||||
int TextureBasisU::get_height() const {
|
||||
return tex_size.y;
|
||||
};
|
||||
|
||||
RID TextureBasisU::get_rid() const {
|
||||
return texture;
|
||||
};
|
||||
|
||||
|
||||
bool TextureBasisU::has_alpha() const {
|
||||
return false;
|
||||
};
|
||||
|
||||
void TextureBasisU::set_flags(uint32_t p_flags) {
|
||||
flags = p_flags;
|
||||
RenderingServer::get_singleton()->texture_set_flags(texture, p_flags);
|
||||
};
|
||||
|
||||
uint32_t TextureBasisU::get_flags() const {
|
||||
return flags;
|
||||
};
|
||||
|
||||
|
||||
void TextureBasisU::set_basisu_data(const Vector<uint8_t>& p_data) {
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
data = p_data;
|
||||
#endif
|
||||
|
||||
const uint8_t* r = p_data.ptr();
|
||||
const void* ptr = r.ptr();
|
||||
int size = p_data.size();
|
||||
|
||||
basist::transcoder_texture_format format;
|
||||
Image::Format imgfmt;
|
||||
|
||||
if (OS::get_singleton()->has_feature("s3tc")) {
|
||||
format = basist::cTFBC3; // get this from renderer
|
||||
imgfmt = Image::FORMAT_DXT5;
|
||||
|
||||
} else if (OS::get_singleton()->has_feature("etc2")) {
|
||||
format = basist::cTFETC2;
|
||||
imgfmt = Image::FORMAT_ETC2_RGBA8;
|
||||
};
|
||||
|
||||
basist::basisu_transcoder tr(nullptr);
|
||||
|
||||
ERR_FAIL_COND(!tr.validate_header(ptr, size));
|
||||
|
||||
basist::basisu_image_info info;
|
||||
tr.get_image_info(ptr, size, info, 0);
|
||||
tex_size = Size2(info.m_width, info.m_height);
|
||||
|
||||
int block_size = basist::basis_get_bytes_per_block(format);
|
||||
Vector<uint8_t> gpudata;
|
||||
gpudata.resize(info.m_total_blocks * block_size);
|
||||
|
||||
{
|
||||
uint8_t* w = gpudata.ptrw();
|
||||
uint8_t* dst = w.ptr();
|
||||
for (int i=0; i<gpudata.size(); i++)
|
||||
dst[i] = 0x00;
|
||||
|
||||
int ofs = 0;
|
||||
tr.start_transcoding(ptr, size);
|
||||
for (int i=0; i<info.m_total_levels; i++) {
|
||||
basist::basisu_image_level_info level;
|
||||
tr.get_image_level_info(ptr, size, level, 0, i);
|
||||
|
||||
bool ret = tr.transcode_image_level(ptr, size, 0, i, dst + ofs, level.m_total_blocks - i, format);
|
||||
if (!ret) {
|
||||
printf("failed! on level %i\n", i);
|
||||
break;
|
||||
};
|
||||
|
||||
ofs += level.m_total_blocks * block_size;
|
||||
};
|
||||
};
|
||||
|
||||
Ref<Image> img;
|
||||
img.instantiate();
|
||||
img->create(info.m_width, info.m_height, info.m_total_levels > 1, imgfmt, gpudata);
|
||||
|
||||
RenderingServer::get_singleton()->texture_allocate(texture, tex_size.x, tex_size.y, 0, img->get_format(), RS::TEXTURE_TYPE_2D, flags);
|
||||
RenderingServer::get_singleton()->texture_set_data(texture, img);
|
||||
};
|
||||
|
||||
Error TextureBasisU::import(const Ref<Image>& p_img) {
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
Vector<uint8_t> budata;
|
||||
|
||||
{
|
||||
Image::Format format = p_img->get_format();
|
||||
if (format != Image::FORMAT_RGB8 && format != Image::FORMAT_RGBA8) {
|
||||
ERR_FAIL_V(ERR_INVALID_PARAMETER);
|
||||
return ERR_INVALID_PARAMETER;
|
||||
};
|
||||
|
||||
Ref<Image> copy = p_img->duplicate();
|
||||
if (format == Image::FORMAT_RGB8)
|
||||
copy->convert(Image::FORMAT_RGBA8);
|
||||
|
||||
basisu::image buimg(p_img->get_width(), p_img->get_height());
|
||||
int size = p_img->get_width() * p_img->get_height() * 4;
|
||||
|
||||
Vector<uint8_t> vec = copy->get_data();
|
||||
{
|
||||
const uint8_t* r = vec.ptr();
|
||||
memcpy(buimg.get_ptr(), r.ptr(), size);
|
||||
};
|
||||
|
||||
basisu::basis_compressor_params params;
|
||||
params.m_max_endpoint_clusters = 512;
|
||||
params.m_max_selector_clusters = 512;
|
||||
params.m_multithreading = true;
|
||||
|
||||
basisu::job_pool jpool(1);
|
||||
params.m_pJob_pool = &jpool;
|
||||
|
||||
params.m_mip_gen = p_img->get_mipmap_count() > 0;
|
||||
params.m_source_images.push_back(buimg);
|
||||
|
||||
basisu::basis_compressor c;
|
||||
c.init(params);
|
||||
|
||||
int buerr = c.process();
|
||||
if (buerr != basisu::basis_compressor::cECSuccess) {
|
||||
ERR_FAIL_V(ERR_INVALID_PARAMETER);
|
||||
return ERR_INVALID_PARAMETER;
|
||||
};
|
||||
|
||||
const basisu::uint8_vec& buvec = c.get_output_basis_file();
|
||||
budata.resize(buvec.size());
|
||||
|
||||
{
|
||||
uint8_t* w = budata.ptrw();
|
||||
memcpy(w.ptr(), &buvec[0], budata.size());
|
||||
};
|
||||
};
|
||||
|
||||
set_basisu_data(budata);
|
||||
|
||||
return OK;
|
||||
#else
|
||||
|
||||
return ERR_UNAVAILABLE;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
Vector<uint8_t> TextureBasisU::get_basisu_data() const {
|
||||
return data;
|
||||
};
|
||||
|
||||
TextureBasisU::TextureBasisU() {
|
||||
texture = RenderingServer::get_singleton()->texture_create();
|
||||
};
|
||||
|
||||
|
||||
TextureBasisU::~TextureBasisU() {
|
||||
RenderingServer::get_singleton()->free(texture);
|
||||
};
|
||||
|
||||
#endif
|
@ -1,80 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* texture_basisu.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 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 BASIS_UNIVERSAL_TEXTURE_BASISU_H
|
||||
#define BASIS_UNIVERSAL_TEXTURE_BASISU_H
|
||||
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
#include <encoder/basisu_comp.h>
|
||||
#endif
|
||||
|
||||
#include <transcoder/basisu_transcoder.h>
|
||||
|
||||
#if 0
|
||||
class TextureBasisU : public Texture {
|
||||
GDCLASS(TextureBasisU, Texture);
|
||||
RES_BASE_EXTENSION("butex");
|
||||
|
||||
RID texture;
|
||||
Size2 tex_size;
|
||||
|
||||
uint32_t flags = FLAGS_DEFAULT;
|
||||
|
||||
Vector<uint8_t> data;
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
|
||||
virtual int get_width() const;
|
||||
virtual int get_height() const;
|
||||
virtual RID get_rid() const;
|
||||
virtual bool has_alpha() const;
|
||||
|
||||
virtual void set_flags(uint32_t p_flags);
|
||||
virtual uint32_t get_flags() const;
|
||||
|
||||
|
||||
Error import(const Ref<Image> &p_img);
|
||||
|
||||
void set_basisu_data(const Vector<uint8_t>& p_data);
|
||||
|
||||
Vector<uint8_t> get_basisu_data() const;
|
||||
String get_img_path() const;
|
||||
|
||||
TextureBasisU();
|
||||
~TextureBasisU();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BASIS_UNIVERSAL_TEXTURE_BASISU_H
|
@ -334,7 +334,6 @@ real_t SliderJointBullet::getMaxAngMotorForce() {
|
||||
|
||||
real_t SliderJointBullet::getLinearPos() {
|
||||
return sliderConstraint->getLinearPos();
|
||||
;
|
||||
}
|
||||
|
||||
void SliderJointBullet::set_param(PhysicsServer3D::SliderJointParam p_param, real_t p_value) {
|
||||
|
@ -212,32 +212,6 @@ MeshGeometry::MeshGeometry(uint64_t id, const ElementPtr element, const std::str
|
||||
m_normals = resolve_vertex_data_array<Vector3>(layer_scope, MappingInformationType, ReferenceInformationType, "Normals");
|
||||
} else if (layer_type_name == "LayerElementColor") {
|
||||
m_colors = resolve_vertex_data_array<Color>(layer_scope, MappingInformationType, ReferenceInformationType, "Colors", "ColorIndex");
|
||||
// NOTE: this is a useful sanity check to ensure you're getting any color data which is not default.
|
||||
// const Color first_color_check = m_colors.data[0];
|
||||
// bool colors_are_all_the_same = true;
|
||||
// size_t i = 1;
|
||||
// for(i = 1; i < m_colors.data.size(); i++)
|
||||
// {
|
||||
// const Color current_color = m_colors.data[i];
|
||||
// if(current_color.is_equal_approx(first_color_check))
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// colors_are_all_the_same = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(colors_are_all_the_same)
|
||||
// {
|
||||
// print_error("Color serialisation is not working for vertex colors some should be different in the test asset.");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// print_verbose("Color array has unique colors at index: " + itos(i));
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,8 +53,9 @@ class CSharpLanguage;
|
||||
#ifdef NO_SAFE_CAST
|
||||
template <typename TScriptInstance, typename TScriptLanguage>
|
||||
TScriptInstance *cast_script_instance(ScriptInstance *p_inst) {
|
||||
if (!p_inst)
|
||||
if (!p_inst) {
|
||||
return nullptr;
|
||||
}
|
||||
return p_inst->get_language() == TScriptLanguage::get_singleton() ? static_cast<TScriptInstance *>(p_inst) : nullptr;
|
||||
}
|
||||
#else
|
||||
|
@ -2149,8 +2149,9 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) {
|
||||
}
|
||||
|
||||
output.append("#ifdef TOOLS_ENABLED\n");
|
||||
for (const InternalCall &internal_call : editor_custom_icalls)
|
||||
for (const InternalCall &internal_call : editor_custom_icalls) {
|
||||
ADD_INTERNAL_CALL_REGISTRATION(internal_call);
|
||||
}
|
||||
output.append("#endif // TOOLS_ENABLED\n");
|
||||
|
||||
for (const InternalCall &internal_call : method_icalls) {
|
||||
|
@ -151,8 +151,9 @@ void gd_mono_debug_init() {
|
||||
.utf8();
|
||||
}
|
||||
#else
|
||||
if (da_args.length() == 0)
|
||||
if (da_args.length() == 0) {
|
||||
return; // Exported games don't use the project settings to setup the debugger agent
|
||||
}
|
||||
#endif
|
||||
|
||||
// Debugging enabled
|
||||
@ -226,8 +227,9 @@ void GDMono::add_mono_shared_libs_dir_to_path() {
|
||||
path_value += mono_reg_info.bin_dir;
|
||||
}
|
||||
#else
|
||||
if (DirAccess::exists(bundled_bin_dir))
|
||||
if (DirAccess::exists(bundled_bin_dir)) {
|
||||
path_value += bundled_bin_dir;
|
||||
}
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
#else
|
||||
@ -1269,8 +1271,9 @@ GDMono::~GDMono() {
|
||||
|
||||
print_verbose("Mono: Finalizing scripts domain...");
|
||||
|
||||
if (mono_domain_get() != root_domain)
|
||||
if (mono_domain_get() != root_domain) {
|
||||
mono_domain_set(root_domain, true);
|
||||
}
|
||||
|
||||
finalizing_scripts_domain = true;
|
||||
|
||||
|
@ -134,8 +134,9 @@ String determine_app_native_lib_dir() {
|
||||
}
|
||||
|
||||
String get_app_native_lib_dir() {
|
||||
if (app_native_lib_dir_cache.is_empty())
|
||||
if (app_native_lib_dir_cache.is_empty()) {
|
||||
app_native_lib_dir_cache = determine_app_native_lib_dir();
|
||||
}
|
||||
return app_native_lib_dir_cache;
|
||||
}
|
||||
|
||||
@ -144,10 +145,11 @@ int gd_mono_convert_dl_flags(int flags) {
|
||||
|
||||
int lflags = flags & MONO_DL_LOCAL ? 0 : RTLD_GLOBAL;
|
||||
|
||||
if (flags & MONO_DL_LAZY)
|
||||
if (flags & MONO_DL_LAZY) {
|
||||
lflags |= RTLD_LAZY;
|
||||
else
|
||||
} else {
|
||||
lflags |= RTLD_NOW;
|
||||
}
|
||||
|
||||
return lflags;
|
||||
}
|
||||
@ -164,8 +166,9 @@ void *godot_dl_handle = nullptr;
|
||||
|
||||
void *try_dlopen(const String &p_so_path, int p_flags) {
|
||||
if (!FileAccess::exists(p_so_path)) {
|
||||
if (OS::get_singleton()->is_stdout_verbose())
|
||||
if (OS::get_singleton()->is_stdout_verbose()) {
|
||||
OS::get_singleton()->print("Cannot find shared library: '%s'\n", p_so_path.utf8().get_data());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -174,13 +177,15 @@ void *try_dlopen(const String &p_so_path, int p_flags) {
|
||||
void *handle = dlopen(p_so_path.utf8().get_data(), lflags);
|
||||
|
||||
if (!handle) {
|
||||
if (OS::get_singleton()->is_stdout_verbose())
|
||||
if (OS::get_singleton()->is_stdout_verbose()) {
|
||||
OS::get_singleton()->print("Failed to open shared library: '%s'. Error: '%s'\n", p_so_path.utf8().get_data(), dlerror());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (OS::get_singleton()->is_stdout_verbose())
|
||||
if (OS::get_singleton()->is_stdout_verbose()) {
|
||||
OS::get_singleton()->print("Successfully loaded shared library: '%s'\n", p_so_path.utf8().get_data());
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
@ -217,20 +222,23 @@ void *gd_mono_android_dlopen(const char *p_name, int p_flags, char **r_err, void
|
||||
void *gd_mono_android_dlsym(void *p_handle, const char *p_name, char **r_err, void *p_user_data) {
|
||||
void *sym_addr = dlsym(p_handle, p_name);
|
||||
|
||||
if (sym_addr)
|
||||
if (sym_addr) {
|
||||
return sym_addr;
|
||||
}
|
||||
|
||||
if (p_handle == mono_dl_handle && godot_dl_handle) {
|
||||
// Looking up for '__Internal' P/Invoke. We want to search in both the Mono and Godot shared libraries.
|
||||
// This is needed to resolve the monodroid P/Invoke functions that are defined at the bottom of the file.
|
||||
sym_addr = dlsym(godot_dl_handle, p_name);
|
||||
|
||||
if (sym_addr)
|
||||
if (sym_addr) {
|
||||
return sym_addr;
|
||||
}
|
||||
}
|
||||
|
||||
if (r_err)
|
||||
if (r_err) {
|
||||
*r_err = str_format_new("%s\n", dlerror());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@ -239,8 +247,9 @@ void *gd_mono_android_dlclose(void *p_handle, void *p_user_data) {
|
||||
dlclose(p_handle);
|
||||
|
||||
// Not sure if this ever happens. Does Mono close the handle for the main module?
|
||||
if (p_handle == mono_dl_handle)
|
||||
if (p_handle == mono_dl_handle) {
|
||||
mono_dl_handle = nullptr;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@ -292,13 +301,15 @@ MonoBoolean _gd_mono_init_cert_store() {
|
||||
|
||||
ScopedLocalRef<jobject> certStoreLocal(env, env->CallStaticObjectMethod(keyStoreClass, getInstance, androidCAStoreString.get()));
|
||||
|
||||
if (jni_exception_check(env))
|
||||
if (jni_exception_check(env)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
env->CallVoidMethod(certStoreLocal, load, nullptr);
|
||||
|
||||
if (jni_exception_check(env))
|
||||
if (jni_exception_check(env)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
certStore = env->NewGlobalRef(certStoreLocal);
|
||||
|
||||
@ -309,8 +320,9 @@ MonoArray *_gd_mono_android_cert_store_lookup(MonoString *p_alias) {
|
||||
// The JNI code is the equivalent of:
|
||||
//
|
||||
// Certificate certificate = certStore.getCertificate(alias);
|
||||
// if (certificate == null)
|
||||
// if (certificate == null) {
|
||||
// return null;
|
||||
// }
|
||||
// return certificate.getEncoded();
|
||||
|
||||
MonoError mono_error;
|
||||
@ -340,8 +352,9 @@ MonoArray *_gd_mono_android_cert_store_lookup(MonoString *p_alias) {
|
||||
|
||||
ScopedLocalRef<jobject> certificate(env, env->CallObjectMethod(certStore, getCertificate, js_alias.get()));
|
||||
|
||||
if (!certificate)
|
||||
if (!certificate) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ScopedLocalRef<jbyteArray> encoded(env, (jbyteArray)env->CallObjectMethod(certificate, getEncoded));
|
||||
jsize encodedLength = env->GetArrayLength(encoded);
|
||||
@ -374,11 +387,13 @@ void initialize() {
|
||||
void cleanup() {
|
||||
// This is called after shutting down the Mono runtime
|
||||
|
||||
if (mono_dl_handle)
|
||||
if (mono_dl_handle) {
|
||||
gd_mono_android_dlclose(mono_dl_handle, nullptr);
|
||||
}
|
||||
|
||||
if (godot_dl_handle)
|
||||
if (godot_dl_handle) {
|
||||
gd_mono_android_dlclose(godot_dl_handle, nullptr);
|
||||
}
|
||||
|
||||
JNIEnv *env = get_jni_env();
|
||||
|
||||
@ -431,8 +446,9 @@ GD_PINVOKE_EXPORT mono_bool _monodroid_get_network_interface_up_state(const char
|
||||
//
|
||||
// NetworkInterface.getByName(p_ifname).isUp()
|
||||
|
||||
if (!r_is_up || !p_ifname || strlen(p_ifname) == 0)
|
||||
if (!r_is_up || !p_ifname || strlen(p_ifname) == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
*r_is_up = 0;
|
||||
|
||||
@ -450,8 +466,9 @@ GD_PINVOKE_EXPORT mono_bool _monodroid_get_network_interface_up_state(const char
|
||||
ScopedLocalRef<jstring> js_ifname(env, env->NewStringUTF(p_ifname));
|
||||
ScopedLocalRef<jobject> networkInterface(env, env->CallStaticObjectMethod(networkInterfaceClass, getByName, js_ifname.get()));
|
||||
|
||||
if (!networkInterface)
|
||||
if (!networkInterface) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
*r_is_up = (mono_bool)env->CallBooleanMethod(networkInterface, isUp);
|
||||
|
||||
@ -463,8 +480,9 @@ GD_PINVOKE_EXPORT mono_bool _monodroid_get_network_interface_supports_multicast(
|
||||
//
|
||||
// NetworkInterface.getByName(p_ifname).supportsMulticast()
|
||||
|
||||
if (!r_supports_multicast || !p_ifname || strlen(p_ifname) == 0)
|
||||
if (!r_supports_multicast || !p_ifname || strlen(p_ifname) == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
*r_supports_multicast = 0;
|
||||
|
||||
@ -482,8 +500,9 @@ GD_PINVOKE_EXPORT mono_bool _monodroid_get_network_interface_supports_multicast(
|
||||
ScopedLocalRef<jstring> js_ifname(env, env->NewStringUTF(p_ifname));
|
||||
ScopedLocalRef<jobject> networkInterface(env, env->CallStaticObjectMethod(networkInterfaceClass, getByName, js_ifname.get()));
|
||||
|
||||
if (!networkInterface)
|
||||
if (!networkInterface) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
*r_supports_multicast = (mono_bool)env->CallBooleanMethod(networkInterface, supportsMulticast);
|
||||
|
||||
@ -528,8 +547,9 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn
|
||||
|
||||
ScopedLocalRef<jobject> connectivityManager(env, env->CallObjectMethod(applicationContext, getSystemService, connectivityServiceString.get()));
|
||||
|
||||
if (!connectivityManager)
|
||||
if (!connectivityManager) {
|
||||
return;
|
||||
}
|
||||
|
||||
ScopedLocalRef<jclass> connectivityManagerClass(env, env->FindClass("android/net/ConnectivityManager"));
|
||||
ERR_FAIL_NULL(connectivityManagerClass);
|
||||
@ -539,8 +559,9 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn
|
||||
|
||||
ScopedLocalRef<jobject> activeNetwork(env, env->CallObjectMethod(connectivityManager, getActiveNetwork));
|
||||
|
||||
if (!activeNetwork)
|
||||
if (!activeNetwork) {
|
||||
return;
|
||||
}
|
||||
|
||||
jmethodID getLinkProperties = env->GetMethodID(connectivityManagerClass,
|
||||
"getLinkProperties", "(Landroid/net/Network;)Landroid/net/LinkProperties;");
|
||||
@ -548,8 +569,9 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn
|
||||
|
||||
ScopedLocalRef<jobject> linkProperties(env, env->CallObjectMethod(connectivityManager, getLinkProperties, activeNetwork.get()));
|
||||
|
||||
if (!linkProperties)
|
||||
if (!linkProperties) {
|
||||
return;
|
||||
}
|
||||
|
||||
ScopedLocalRef<jclass> linkPropertiesClass(env, env->FindClass("android/net/LinkProperties"));
|
||||
ERR_FAIL_NULL(linkPropertiesClass);
|
||||
@ -559,8 +581,9 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn
|
||||
|
||||
ScopedLocalRef<jobject> dnsServers(env, env->CallObjectMethod(linkProperties, getDnsServers));
|
||||
|
||||
if (!dnsServers)
|
||||
if (!dnsServers) {
|
||||
return;
|
||||
}
|
||||
|
||||
ScopedLocalRef<jclass> listClass(env, env->FindClass("java/util/List"));
|
||||
ERR_FAIL_NULL(listClass);
|
||||
@ -570,11 +593,13 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn
|
||||
|
||||
int dnsServersCount = env->CallIntMethod(dnsServers, listSize);
|
||||
|
||||
if (dnsServersCount > dns_servers_len)
|
||||
if (dnsServersCount > dns_servers_len) {
|
||||
dnsServersCount = dns_servers_len;
|
||||
}
|
||||
|
||||
if (dnsServersCount <= 0)
|
||||
if (dnsServersCount <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
jmethodID listGet = env->GetMethodID(listClass, "get", "(I)Ljava/lang/Object;");
|
||||
ERR_FAIL_NULL(listGet);
|
||||
@ -587,8 +612,9 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn
|
||||
|
||||
for (int i = 0; i < dnsServersCount; i++) {
|
||||
ScopedLocalRef<jobject> dnsServer(env, env->CallObjectMethod(dnsServers, listGet, (jint)i));
|
||||
if (!dnsServer)
|
||||
if (!dnsServer) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ScopedLocalRef<jstring> hostAddress(env, (jstring)env->CallObjectMethod(dnsServer, getHostAddress));
|
||||
const char *host_address = env->GetStringUTFChars(hostAddress, 0);
|
||||
@ -603,8 +629,9 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn
|
||||
}
|
||||
|
||||
GD_PINVOKE_EXPORT int32_t _monodroid_get_dns_servers(void **r_dns_servers_array) {
|
||||
if (!r_dns_servers_array)
|
||||
if (!r_dns_servers_array) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*r_dns_servers_array = nullptr;
|
||||
|
||||
@ -661,13 +688,15 @@ GD_PINVOKE_EXPORT const char *_monodroid_timezone_get_default_id() {
|
||||
|
||||
ScopedLocalRef<jobject> defaultTimeZone(env, env->CallStaticObjectMethod(timeZoneClass, getDefault));
|
||||
|
||||
if (!defaultTimeZone)
|
||||
if (!defaultTimeZone) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ScopedLocalRef<jstring> defaultTimeZoneID(env, (jstring)env->CallObjectMethod(defaultTimeZone, getID));
|
||||
|
||||
if (!defaultTimeZoneID)
|
||||
if (!defaultTimeZoneID) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *default_time_zone_id = env->GetStringUTFChars(defaultTimeZoneID, 0);
|
||||
|
||||
|
@ -94,8 +94,9 @@ GD_PINVOKE_EXPORT const char *xamarin_get_locale_country_code() {
|
||||
GD_PINVOKE_EXPORT void xamarin_log(const uint16_t *p_unicode_message) {
|
||||
int length = 0;
|
||||
const uint16_t *ptr = p_unicode_message;
|
||||
while (*ptr++)
|
||||
while (*ptr++) {
|
||||
length += sizeof(uint16_t);
|
||||
}
|
||||
NSString *msg = [[NSString alloc] initWithBytes:p_unicode_message length:length encoding:NSUTF16LittleEndianStringEncoding];
|
||||
|
||||
os_log_info(OS_LOG_DEFAULT, "%{public}@", msg);
|
||||
|
@ -60,8 +60,9 @@ REGSAM _get_bitness_sam() {
|
||||
LONG _RegOpenKey(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult) {
|
||||
LONG res = RegOpenKeyExW(hKey, lpSubKey, 0, KEY_READ, phkResult);
|
||||
|
||||
if (res != ERROR_SUCCESS)
|
||||
if (res != ERROR_SUCCESS) {
|
||||
res = RegOpenKeyExW(hKey, lpSubKey, 0, KEY_READ | _get_bitness_sam(), phkResult);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -92,31 +93,37 @@ LONG _find_mono_in_reg(const String &p_subkey, MonoRegInfo &r_info, bool p_old_r
|
||||
HKEY hKey;
|
||||
LONG res = _RegOpenKey(HKEY_LOCAL_MACHINE, (LPCWSTR)(p_subkey.utf16().get_data()), &hKey);
|
||||
|
||||
if (res != ERROR_SUCCESS)
|
||||
goto cleanup;
|
||||
|
||||
if (!p_old_reg) {
|
||||
res = _RegKeyQueryString(hKey, "Version", r_info.version);
|
||||
if (res != ERROR_SUCCESS)
|
||||
if (res != ERROR_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
res = _RegKeyQueryString(hKey, "SdkInstallRoot", r_info.install_root_dir);
|
||||
if (res != ERROR_SUCCESS)
|
||||
if (!p_old_reg) {
|
||||
res = _RegKeyQueryString(hKey, "Version", r_info.version);
|
||||
if (res != ERROR_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
res = _RegKeyQueryString(hKey, "SdkInstallRoot", r_info.install_root_dir);
|
||||
if (res != ERROR_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
res = _RegKeyQueryString(hKey, "FrameworkAssemblyDirectory", r_info.assembly_dir);
|
||||
if (res != ERROR_SUCCESS)
|
||||
if (res != ERROR_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
res = _RegKeyQueryString(hKey, "MonoConfigDir", r_info.config_dir);
|
||||
if (res != ERROR_SUCCESS)
|
||||
if (res != ERROR_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (r_info.install_root_dir.ends_with("\\"))
|
||||
if (r_info.install_root_dir.ends_with("\\")) {
|
||||
r_info.bin_dir = r_info.install_root_dir + "bin";
|
||||
else
|
||||
} else {
|
||||
r_info.bin_dir = r_info.install_root_dir + "\\bin";
|
||||
}
|
||||
|
||||
cleanup:
|
||||
RegCloseKey(hKey);
|
||||
@ -129,8 +136,9 @@ LONG _find_mono_in_reg_old(const String &p_subkey, MonoRegInfo &r_info) {
|
||||
HKEY hKey;
|
||||
LONG res = _RegOpenKey(HKEY_LOCAL_MACHINE, (LPCWSTR)(p_subkey.utf16().get_data()), &hKey);
|
||||
|
||||
if (res != ERROR_SUCCESS)
|
||||
if (res != ERROR_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
res = _RegKeyQueryString(hKey, "DefaultCLR", default_clr);
|
||||
|
||||
@ -147,11 +155,13 @@ cleanup:
|
||||
MonoRegInfo find_mono() {
|
||||
MonoRegInfo info;
|
||||
|
||||
if (_find_mono_in_reg("Software\\Mono", info) == ERROR_SUCCESS)
|
||||
if (_find_mono_in_reg("Software\\Mono", info) == ERROR_SUCCESS) {
|
||||
return info;
|
||||
}
|
||||
|
||||
if (_find_mono_in_reg_old("Software\\Novell\\Mono", info) == ERROR_SUCCESS)
|
||||
if (_find_mono_in_reg_old("Software\\Novell\\Mono", info) == ERROR_SUCCESS) {
|
||||
return info;
|
||||
}
|
||||
|
||||
return MonoRegInfo();
|
||||
}
|
||||
@ -212,13 +222,15 @@ String find_msbuild_tools_path() {
|
||||
HKEY hKey;
|
||||
LONG res = _RegOpenKey(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\14.0", &hKey);
|
||||
|
||||
if (res != ERROR_SUCCESS)
|
||||
if (res != ERROR_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
res = _RegKeyQueryString(hKey, "MSBuildToolsPath", msbuild_tools_path);
|
||||
|
||||
if (res != ERROR_SUCCESS)
|
||||
if (res != ERROR_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
RegCloseKey(hKey);
|
||||
|
@ -57,8 +57,9 @@ String cwd() {
|
||||
|
||||
Char16String buffer;
|
||||
buffer.resize((int)expected_size);
|
||||
if (::GetCurrentDirectoryW(expected_size, (wchar_t *)buffer.ptrw()) == 0)
|
||||
if (::GetCurrentDirectoryW(expected_size, (wchar_t *)buffer.ptrw()) == 0) {
|
||||
return ".";
|
||||
}
|
||||
|
||||
String result;
|
||||
if (result.parse_utf16(buffer.ptr())) {
|
||||
@ -95,8 +96,9 @@ String realpath(const String &p_path) {
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
||||
nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
if (hFile == INVALID_HANDLE_VALUE) {
|
||||
return p_path;
|
||||
}
|
||||
|
||||
const DWORD expected_size = ::GetFinalPathNameByHandleW(hFile, nullptr, 0, FILE_NAME_NORMALIZED);
|
||||
|
||||
@ -177,8 +179,9 @@ String relative_to_impl(const String &p_path, const String &p_relative_to) {
|
||||
#ifdef WINDOWS_ENABLED
|
||||
String get_drive_letter(const String &p_norm_path) {
|
||||
int idx = p_norm_path.find(":/");
|
||||
if (idx != -1 && idx < p_norm_path.find("/"))
|
||||
if (idx != -1 && idx < p_norm_path.find("/")) {
|
||||
return p_norm_path.substr(0, idx + 1);
|
||||
}
|
||||
return String();
|
||||
}
|
||||
#endif
|
||||
|
@ -930,8 +930,6 @@ void VisualScript::get_script_property_list(List<PropertyInfo> *p_list) const {
|
||||
get_variable_list(&vars);
|
||||
|
||||
for (const StringName &E : vars) {
|
||||
//if (!variables[E]._export)
|
||||
// continue;
|
||||
PropertyInfo pi = variables[E].info;
|
||||
pi.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE;
|
||||
p_list->push_back(pi);
|
||||
|
@ -31,6 +31,7 @@
|
||||
#ifdef JAVASCRIPT_ENABLED
|
||||
|
||||
#include "webrtc_data_channel_js.h"
|
||||
|
||||
#include "emscripten.h"
|
||||
|
||||
extern "C" {
|
||||
@ -104,8 +105,9 @@ int WebRTCDataChannelJS::get_available_packet_count() const {
|
||||
Error WebRTCDataChannelJS::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
|
||||
ERR_FAIL_COND_V(get_ready_state() != STATE_OPEN, ERR_UNCONFIGURED);
|
||||
|
||||
if (queue_count == 0)
|
||||
if (queue_count == 0) {
|
||||
return ERR_UNAVAILABLE;
|
||||
}
|
||||
|
||||
uint32_t to_read = 0;
|
||||
uint32_t left = 0;
|
||||
|
@ -31,6 +31,7 @@
|
||||
#ifdef JAVASCRIPT_ENABLED
|
||||
|
||||
#include "emws_client.h"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/io/ip.h"
|
||||
#include "emscripten.h"
|
||||
@ -45,8 +46,9 @@ void EMWSClient::_esws_on_message(void *obj, const uint8_t *p_data, int p_data_s
|
||||
EMWSClient *client = static_cast<EMWSClient *>(obj);
|
||||
|
||||
Error err = static_cast<EMWSPeer *>(*client->get_peer(1))->read_msg(p_data, p_data_size, p_is_string == 1);
|
||||
if (err == OK)
|
||||
if (err == OK) {
|
||||
client->_on_peer_packet();
|
||||
}
|
||||
}
|
||||
|
||||
void EMWSClient::_esws_on_error(void *obj) {
|
||||
@ -71,8 +73,9 @@ Error EMWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port,
|
||||
|
||||
String proto_string;
|
||||
for (int i = 0; i < p_protocols.size(); i++) {
|
||||
if (i != 0)
|
||||
if (i != 0) {
|
||||
proto_string += ",";
|
||||
}
|
||||
proto_string += p_protocols[i];
|
||||
}
|
||||
|
||||
@ -109,8 +112,9 @@ Ref<WebSocketPeer> EMWSClient::get_peer(int p_peer_id) const {
|
||||
|
||||
MultiplayerPeer::ConnectionStatus EMWSClient::get_connection_status() const {
|
||||
if (_peer->is_connected_to_host()) {
|
||||
if (_is_connecting)
|
||||
if (_is_connecting) {
|
||||
return CONNECTION_CONNECTING;
|
||||
}
|
||||
return CONNECTION_CONNECTED;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#ifdef JAVASCRIPT_ENABLED
|
||||
|
||||
#include "emws_peer.h"
|
||||
|
||||
#include "core/io/ip.h"
|
||||
|
||||
void EMWSPeer::set_sock(int p_sock, unsigned int p_in_buf_size, unsigned int p_in_pkt_size, unsigned int p_out_buf_size) {
|
||||
@ -66,8 +67,9 @@ Error EMWSPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
|
||||
}
|
||||
|
||||
Error EMWSPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
|
||||
if (_in_buffer.packets_left() == 0)
|
||||
if (_in_buffer.packets_left() == 0) {
|
||||
return ERR_UNAVAILABLE;
|
||||
}
|
||||
|
||||
int read = 0;
|
||||
Error err = _in_buffer.read_packet(_packet_buffer.ptrw(), _packet_buffer.size(), &_is_string, read);
|
||||
@ -109,7 +111,7 @@ void EMWSPeer::close(int p_code, String p_reason) {
|
||||
|
||||
IPAddress EMWSPeer::get_connected_host() const {
|
||||
ERR_FAIL_V_MSG(IPAddress(), "Not supported in HTML5 export.");
|
||||
};
|
||||
}
|
||||
|
||||
uint16_t EMWSPeer::get_connected_port() const {
|
||||
ERR_FAIL_V_MSG(0, "Not supported in HTML5 export.");
|
||||
|
@ -31,11 +31,13 @@
|
||||
#ifdef JAVASCRIPT_ENABLED
|
||||
|
||||
#include "webxr_interface_js.h"
|
||||
|
||||
#include "core/input/input.h"
|
||||
#include "core/os/os.h"
|
||||
#include "emscripten.h"
|
||||
#include "godot_webxr.h"
|
||||
#include "servers/rendering/renderer_compositor.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
void _emwebxr_on_session_supported(char *p_session_mode, int p_supported) {
|
||||
@ -481,7 +483,6 @@ void WebXRInterfaceJS::_update_tracker(int p_controller_id) {
|
||||
sprintf(name, "axis_%i", i);
|
||||
|
||||
float value = *((float *)axes + (i + 1));
|
||||
;
|
||||
tracker->set_input(name, value);
|
||||
}
|
||||
free(axes);
|
||||
|
@ -165,8 +165,9 @@ void AndroidInputHandler::process_touch(int p_event, int p_pointer, const Vector
|
||||
|
||||
ERR_CONTINUE(idx == -1);
|
||||
|
||||
if (touch[i].pos == p_points[idx].pos)
|
||||
continue; //no move unncesearily
|
||||
if (touch[i].pos == p_points[idx].pos) {
|
||||
continue; // Don't move unnecessarily.
|
||||
}
|
||||
|
||||
Ref<InputEventScreenDrag> ev;
|
||||
ev.instantiate();
|
||||
|
@ -31,10 +31,10 @@
|
||||
#ifndef JNI_SINGLETON_H
|
||||
#define JNI_SINGLETON_H
|
||||
|
||||
#include <core/config/engine.h>
|
||||
#include <core/variant/variant.h>
|
||||
#include "core/config/engine.h"
|
||||
#include "core/variant/variant.h"
|
||||
#ifdef ANDROID_ENABLED
|
||||
#include <platform/android/jni_utils.h>
|
||||
#include "platform/android/jni_utils.h"
|
||||
#endif
|
||||
|
||||
class JNISingleton : public Object {
|
||||
@ -93,9 +93,10 @@ public:
|
||||
for (int i = 0; i < p_argcount; i++) {
|
||||
jvalret vr = _variant_to_jvalue(env, E->get().argtypes[i], p_args[i]);
|
||||
v[i] = vr.val;
|
||||
if (vr.obj)
|
||||
if (vr.obj) {
|
||||
to_erase.push_back(vr.obj);
|
||||
}
|
||||
}
|
||||
|
||||
Variant ret;
|
||||
|
||||
@ -197,19 +198,20 @@ public:
|
||||
}
|
||||
|
||||
void add_signal(const StringName &p_name, const Vector<Variant::Type> &p_args) {
|
||||
if (p_args.size() == 0)
|
||||
if (p_args.size() == 0) {
|
||||
ADD_SIGNAL(MethodInfo(p_name));
|
||||
else if (p_args.size() == 1)
|
||||
} else if (p_args.size() == 1) {
|
||||
ADD_SIGNAL(MethodInfo(p_name, PropertyInfo(p_args[0], "arg1")));
|
||||
else if (p_args.size() == 2)
|
||||
} else if (p_args.size() == 2) {
|
||||
ADD_SIGNAL(MethodInfo(p_name, PropertyInfo(p_args[0], "arg1"), PropertyInfo(p_args[1], "arg2")));
|
||||
else if (p_args.size() == 3)
|
||||
} else if (p_args.size() == 3) {
|
||||
ADD_SIGNAL(MethodInfo(p_name, PropertyInfo(p_args[0], "arg1"), PropertyInfo(p_args[1], "arg2"), PropertyInfo(p_args[2], "arg3")));
|
||||
else if (p_args.size() == 4)
|
||||
} else if (p_args.size() == 4) {
|
||||
ADD_SIGNAL(MethodInfo(p_name, PropertyInfo(p_args[0], "arg1"), PropertyInfo(p_args[1], "arg2"), PropertyInfo(p_args[2], "arg3"), PropertyInfo(p_args[3], "arg4")));
|
||||
else if (p_args.size() == 5)
|
||||
} else if (p_args.size() == 5) {
|
||||
ADD_SIGNAL(MethodInfo(p_name, PropertyInfo(p_args[0], "arg1"), PropertyInfo(p_args[1], "arg2"), PropertyInfo(p_args[2], "arg3"), PropertyInfo(p_args[3], "arg4"), PropertyInfo(p_args[4], "arg5")));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -56,8 +56,9 @@ void AudioDriverOpenSL::_buffer_callback(
|
||||
}
|
||||
}
|
||||
|
||||
if (mix)
|
||||
if (mix) {
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
const int32_t *src_buff = mixdown_buffer;
|
||||
|
||||
@ -312,13 +313,15 @@ AudioDriver::SpeakerMode AudioDriverOpenSL::get_speaker_mode() const {
|
||||
}
|
||||
|
||||
void AudioDriverOpenSL::lock() {
|
||||
if (active)
|
||||
if (active) {
|
||||
mutex.lock();
|
||||
}
|
||||
}
|
||||
|
||||
void AudioDriverOpenSL::unlock() {
|
||||
if (active)
|
||||
if (active) {
|
||||
mutex.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void AudioDriverOpenSL::finish() {
|
||||
|
@ -29,6 +29,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "dir_access_jandroid.h"
|
||||
|
||||
#include "core/string/print_string.h"
|
||||
#include "file_access_android.h"
|
||||
#include "string_android.h"
|
||||
@ -51,8 +52,9 @@ Error DirAccessJAndroid::list_dir_begin() {
|
||||
|
||||
jstring js = env->NewStringUTF(current_dir.utf8().get_data());
|
||||
int res = env->CallIntMethod(io, _dir_open, js);
|
||||
if (res <= 0)
|
||||
if (res <= 0) {
|
||||
return ERR_CANT_OPEN;
|
||||
}
|
||||
|
||||
id = res;
|
||||
|
||||
@ -64,8 +66,9 @@ String DirAccessJAndroid::get_next() {
|
||||
|
||||
JNIEnv *env = get_jni_env();
|
||||
jstring str = (jstring)env->CallObjectMethod(io, _dir_next, id);
|
||||
if (!str)
|
||||
if (!str) {
|
||||
return "";
|
||||
}
|
||||
|
||||
String ret = jstring_to_string((jstring)str, env);
|
||||
env->DeleteLocalRef((jobject)str);
|
||||
@ -83,8 +86,9 @@ bool DirAccessJAndroid::current_is_hidden() const {
|
||||
}
|
||||
|
||||
void DirAccessJAndroid::list_dir_end() {
|
||||
if (id == 0)
|
||||
if (id == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEnv *env = get_jni_env();
|
||||
env->CallVoidMethod(io, _dir_close, id);
|
||||
@ -102,22 +106,25 @@ String DirAccessJAndroid::get_drive(int p_drive) {
|
||||
Error DirAccessJAndroid::change_dir(String p_dir) {
|
||||
JNIEnv *env = get_jni_env();
|
||||
|
||||
if (p_dir.is_empty() || p_dir == "." || (p_dir == ".." && current_dir.is_empty()))
|
||||
if (p_dir.is_empty() || p_dir == "." || (p_dir == ".." && current_dir.is_empty())) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
String new_dir;
|
||||
|
||||
if (p_dir != "res://" && p_dir.length() > 1 && p_dir.ends_with("/"))
|
||||
if (p_dir != "res://" && p_dir.length() > 1 && p_dir.ends_with("/")) {
|
||||
p_dir = p_dir.substr(0, p_dir.length() - 1);
|
||||
}
|
||||
|
||||
if (p_dir.begins_with("/"))
|
||||
if (p_dir.begins_with("/")) {
|
||||
new_dir = p_dir.substr(1, p_dir.length());
|
||||
else if (p_dir.begins_with("res://"))
|
||||
} else if (p_dir.begins_with("res://")) {
|
||||
new_dir = p_dir.substr(6, p_dir.length());
|
||||
else if (current_dir.is_empty())
|
||||
} else if (current_dir.is_empty()) {
|
||||
new_dir = p_dir;
|
||||
else
|
||||
} else {
|
||||
new_dir = current_dir.plus_file(p_dir);
|
||||
}
|
||||
|
||||
//test if newdir exists
|
||||
new_dir = new_dir.simplify_path();
|
||||
@ -125,8 +132,9 @@ Error DirAccessJAndroid::change_dir(String p_dir) {
|
||||
jstring js = env->NewStringUTF(new_dir.utf8().get_data());
|
||||
int res = env->CallIntMethod(io, _dir_open, js);
|
||||
env->DeleteLocalRef(js);
|
||||
if (res <= 0)
|
||||
if (res <= 0) {
|
||||
return ERR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
env->CallVoidMethod(io, _dir_close, res);
|
||||
|
||||
@ -141,10 +149,11 @@ String DirAccessJAndroid::get_current_dir(bool p_include_drive) {
|
||||
|
||||
bool DirAccessJAndroid::file_exists(String p_file) {
|
||||
String sd;
|
||||
if (current_dir.is_empty())
|
||||
if (current_dir.is_empty()) {
|
||||
sd = p_file;
|
||||
else
|
||||
} else {
|
||||
sd = current_dir.plus_file(p_file);
|
||||
}
|
||||
|
||||
FileAccessAndroid *f = memnew(FileAccessAndroid);
|
||||
bool exists = f->file_exists(sd);
|
||||
@ -158,27 +167,30 @@ bool DirAccessJAndroid::dir_exists(String p_dir) {
|
||||
|
||||
String sd;
|
||||
|
||||
if (current_dir.is_empty())
|
||||
if (current_dir.is_empty()) {
|
||||
sd = p_dir;
|
||||
else {
|
||||
if (p_dir.is_relative_path())
|
||||
} else {
|
||||
if (p_dir.is_relative_path()) {
|
||||
sd = current_dir.plus_file(p_dir);
|
||||
else
|
||||
} else {
|
||||
sd = fix_path(p_dir);
|
||||
}
|
||||
}
|
||||
|
||||
String path = sd.simplify_path();
|
||||
|
||||
if (path.begins_with("/"))
|
||||
if (path.begins_with("/")) {
|
||||
path = path.substr(1, path.length());
|
||||
else if (path.begins_with("res://"))
|
||||
} else if (path.begins_with("res://")) {
|
||||
path = path.substr(6, path.length());
|
||||
}
|
||||
|
||||
jstring js = env->NewStringUTF(path.utf8().get_data());
|
||||
int res = env->CallIntMethod(io, _dir_open, js);
|
||||
env->DeleteLocalRef(js);
|
||||
if (res <= 0)
|
||||
if (res <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
env->CallVoidMethod(io, _dir_close, res);
|
||||
|
||||
|
@ -29,30 +29,28 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "file_access_android.h"
|
||||
|
||||
#include "core/string/print_string.h"
|
||||
|
||||
AAssetManager *FileAccessAndroid::asset_manager = nullptr;
|
||||
|
||||
/*void FileAccessAndroid::make_default() {
|
||||
create_func=create_android;
|
||||
}*/
|
||||
|
||||
FileAccess *FileAccessAndroid::create_android() {
|
||||
return memnew(FileAccessAndroid);
|
||||
}
|
||||
|
||||
Error FileAccessAndroid::_open(const String &p_path, int p_mode_flags) {
|
||||
String path = fix_path(p_path).simplify_path();
|
||||
if (path.begins_with("/"))
|
||||
if (path.begins_with("/")) {
|
||||
path = path.substr(1, path.length());
|
||||
else if (path.begins_with("res://"))
|
||||
} else if (path.begins_with("res://")) {
|
||||
path = path.substr(6, path.length());
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(p_mode_flags & FileAccess::WRITE, ERR_UNAVAILABLE); //can't write on android..
|
||||
a = AAssetManager_open(asset_manager, path.utf8().get_data(), AASSET_MODE_STREAMING);
|
||||
if (!a)
|
||||
if (!a) {
|
||||
return ERR_CANT_OPEN;
|
||||
//ERR_FAIL_COND_V(!a,ERR_FILE_NOT_FOUND);
|
||||
}
|
||||
len = AAsset_getLength(a);
|
||||
pos = 0;
|
||||
eof = false;
|
||||
@ -61,8 +59,9 @@ Error FileAccessAndroid::_open(const String &p_path, int p_mode_flags) {
|
||||
}
|
||||
|
||||
void FileAccessAndroid::close() {
|
||||
if (!a)
|
||||
if (!a) {
|
||||
return;
|
||||
}
|
||||
AAsset_close(a);
|
||||
a = nullptr;
|
||||
}
|
||||
@ -146,15 +145,17 @@ void FileAccessAndroid::store_8(uint8_t p_dest) {
|
||||
|
||||
bool FileAccessAndroid::file_exists(const String &p_path) {
|
||||
String path = fix_path(p_path).simplify_path();
|
||||
if (path.begins_with("/"))
|
||||
if (path.begins_with("/")) {
|
||||
path = path.substr(1, path.length());
|
||||
else if (path.begins_with("res://"))
|
||||
} else if (path.begins_with("res://")) {
|
||||
path = path.substr(6, path.length());
|
||||
}
|
||||
|
||||
AAsset *at = AAssetManager_open(asset_manager, path.utf8().get_data(), AASSET_MODE_STREAMING);
|
||||
|
||||
if (!at)
|
||||
if (!at) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AAsset_close(at);
|
||||
return true;
|
||||
|
@ -147,8 +147,9 @@ public class GLUtils {
|
||||
Log.i(TAG, String.format(" %s: %d\n", name, value[0]));
|
||||
} else {
|
||||
// Log.w(TAG, String.format(" %s: failed\n", name));
|
||||
while (egl.eglGetError() != EGL10.EGL_SUCCESS)
|
||||
;
|
||||
while (egl.eglGetError() != EGL10.EGL_SUCCESS) {
|
||||
// Continue.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,13 +29,15 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "api/java_class_wrapper.h"
|
||||
|
||||
#include "string_android.h"
|
||||
#include "thread_jandroid.h"
|
||||
|
||||
bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error, Variant &ret) {
|
||||
Map<StringName, List<MethodInfo>>::Element *M = methods.find(p_method);
|
||||
if (!M)
|
||||
if (!M) {
|
||||
return false;
|
||||
}
|
||||
|
||||
JNIEnv *env = get_jni_env();
|
||||
ERR_FAIL_COND_V(env == nullptr, false);
|
||||
@ -68,8 +70,9 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
|
||||
//bug?
|
||||
} break;
|
||||
case ARG_TYPE_BOOLEAN: {
|
||||
if (p_args[i]->get_type() != Variant::BOOL)
|
||||
if (p_args[i]->get_type() != Variant::BOOL) {
|
||||
arg_expected = Variant::BOOL;
|
||||
}
|
||||
} break;
|
||||
case ARG_NUMBER_CLASS_BIT | ARG_TYPE_BYTE:
|
||||
case ARG_NUMBER_CLASS_BIT | ARG_TYPE_CHAR:
|
||||
@ -81,27 +84,27 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
|
||||
case ARG_TYPE_SHORT:
|
||||
case ARG_TYPE_INT:
|
||||
case ARG_TYPE_LONG: {
|
||||
if (!p_args[i]->is_num())
|
||||
if (!p_args[i]->is_num()) {
|
||||
arg_expected = Variant::INT;
|
||||
|
||||
}
|
||||
} break;
|
||||
case ARG_NUMBER_CLASS_BIT | ARG_TYPE_FLOAT:
|
||||
case ARG_NUMBER_CLASS_BIT | ARG_TYPE_DOUBLE:
|
||||
case ARG_TYPE_FLOAT:
|
||||
case ARG_TYPE_DOUBLE: {
|
||||
if (!p_args[i]->is_num())
|
||||
if (!p_args[i]->is_num()) {
|
||||
arg_expected = Variant::FLOAT;
|
||||
|
||||
}
|
||||
} break;
|
||||
case ARG_TYPE_STRING: {
|
||||
if (p_args[i]->get_type() != Variant::STRING)
|
||||
if (p_args[i]->get_type() != Variant::STRING) {
|
||||
arg_expected = Variant::STRING;
|
||||
|
||||
}
|
||||
} break;
|
||||
case ARG_TYPE_CLASS: {
|
||||
if (p_args[i]->get_type() != Variant::OBJECT)
|
||||
if (p_args[i]->get_type() != Variant::OBJECT) {
|
||||
arg_expected = Variant::OBJECT;
|
||||
else {
|
||||
} else {
|
||||
Ref<RefCounted> ref = *p_args[i];
|
||||
if (!ref.is_null()) {
|
||||
if (Object::cast_to<JavaObject>(ref.ptr())) {
|
||||
@ -118,12 +121,11 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} break;
|
||||
default: {
|
||||
if (p_args[i]->get_type() != Variant::ARRAY)
|
||||
if (p_args[i]->get_type() != Variant::ARRAY) {
|
||||
arg_expected = Variant::ARRAY;
|
||||
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
@ -135,15 +137,17 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!valid)
|
||||
if (!valid) {
|
||||
continue;
|
||||
}
|
||||
|
||||
method = &E;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!method)
|
||||
if (!method) {
|
||||
return true; //no version convinces
|
||||
}
|
||||
|
||||
r_error.error = Callable::CallError::CALL_OK;
|
||||
|
||||
@ -780,9 +784,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
jobject o = env->GetObjectArrayElement(arr, i);
|
||||
if (!o)
|
||||
if (!o) {
|
||||
ret.push_back(Variant());
|
||||
else {
|
||||
} else {
|
||||
bool val = env->CallBooleanMethod(o, JavaClassWrapper::singleton->Boolean_booleanValue);
|
||||
ret.push_back(val);
|
||||
}
|
||||
@ -801,9 +805,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
jobject o = env->GetObjectArrayElement(arr, i);
|
||||
if (!o)
|
||||
if (!o) {
|
||||
ret.push_back(Variant());
|
||||
else {
|
||||
} else {
|
||||
int val = env->CallByteMethod(o, JavaClassWrapper::singleton->Byte_byteValue);
|
||||
ret.push_back(val);
|
||||
}
|
||||
@ -821,9 +825,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
jobject o = env->GetObjectArrayElement(arr, i);
|
||||
if (!o)
|
||||
if (!o) {
|
||||
ret.push_back(Variant());
|
||||
else {
|
||||
} else {
|
||||
int val = env->CallCharMethod(o, JavaClassWrapper::singleton->Character_characterValue);
|
||||
ret.push_back(val);
|
||||
}
|
||||
@ -841,9 +845,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
jobject o = env->GetObjectArrayElement(arr, i);
|
||||
if (!o)
|
||||
if (!o) {
|
||||
ret.push_back(Variant());
|
||||
else {
|
||||
} else {
|
||||
int val = env->CallShortMethod(o, JavaClassWrapper::singleton->Short_shortValue);
|
||||
ret.push_back(val);
|
||||
}
|
||||
@ -861,9 +865,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
jobject o = env->GetObjectArrayElement(arr, i);
|
||||
if (!o)
|
||||
if (!o) {
|
||||
ret.push_back(Variant());
|
||||
else {
|
||||
} else {
|
||||
int val = env->CallIntMethod(o, JavaClassWrapper::singleton->Integer_integerValue);
|
||||
ret.push_back(val);
|
||||
}
|
||||
@ -881,9 +885,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
jobject o = env->GetObjectArrayElement(arr, i);
|
||||
if (!o)
|
||||
if (!o) {
|
||||
ret.push_back(Variant());
|
||||
else {
|
||||
} else {
|
||||
int64_t val = env->CallLongMethod(o, JavaClassWrapper::singleton->Long_longValue);
|
||||
ret.push_back(val);
|
||||
}
|
||||
@ -901,9 +905,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
jobject o = env->GetObjectArrayElement(arr, i);
|
||||
if (!o)
|
||||
if (!o) {
|
||||
ret.push_back(Variant());
|
||||
else {
|
||||
} else {
|
||||
float val = env->CallFloatMethod(o, JavaClassWrapper::singleton->Float_floatValue);
|
||||
ret.push_back(val);
|
||||
}
|
||||
@ -921,9 +925,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
jobject o = env->GetObjectArrayElement(arr, i);
|
||||
if (!o)
|
||||
if (!o) {
|
||||
ret.push_back(Variant());
|
||||
else {
|
||||
} else {
|
||||
double val = env->CallDoubleMethod(o, JavaClassWrapper::singleton->Double_doubleValue);
|
||||
ret.push_back(val);
|
||||
}
|
||||
@ -942,9 +946,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
jobject o = env->GetObjectArrayElement(arr, i);
|
||||
if (!o)
|
||||
if (!o) {
|
||||
ret.push_back(Variant());
|
||||
else {
|
||||
} else {
|
||||
String val = jstring_to_string((jstring)o, env);
|
||||
ret.push_back(val);
|
||||
}
|
||||
@ -962,8 +966,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
|
||||
}
|
||||
|
||||
Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
|
||||
if (class_cache.has(p_class))
|
||||
if (class_cache.has(p_class)) {
|
||||
return class_cache[p_class];
|
||||
}
|
||||
|
||||
JNIEnv *env = get_jni_env();
|
||||
ERR_FAIL_COND_V(env == nullptr, Ref<JavaClass>());
|
||||
@ -971,10 +976,6 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
|
||||
jclass bclass = env->FindClass(p_class.utf8().get_data());
|
||||
ERR_FAIL_COND_V(!bclass, Ref<JavaClass>());
|
||||
|
||||
//jmethodID getDeclaredMethods = env->GetMethodID(bclass,"getDeclaredMethods", "()[Ljava/lang/reflect/Method;");
|
||||
|
||||
//ERR_FAIL_COND_V(!getDeclaredMethods,Ref<JavaClass>());
|
||||
|
||||
jobjectArray methods = (jobjectArray)env->CallObjectMethod(bclass, getDeclaredMethods);
|
||||
|
||||
ERR_FAIL_COND_V(!methods, Ref<JavaClass>());
|
||||
@ -1057,8 +1058,9 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
|
||||
float new_likeliness = 0;
|
||||
float existing_likeliness = 0;
|
||||
|
||||
if (E->get().param_types.size() != mi.param_types.size())
|
||||
if (E->get().param_types.size() != mi.param_types.size()) {
|
||||
continue;
|
||||
}
|
||||
bool valid = true;
|
||||
for (int j = 0; j < E->get().param_types.size(); j++) {
|
||||
Variant::Type _new;
|
||||
@ -1075,8 +1077,9 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
|
||||
existing_likeliness = existing_l;
|
||||
}
|
||||
|
||||
if (!valid)
|
||||
if (!valid) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (new_likeliness > existing_likeliness) {
|
||||
java_class->methods[str_method].erase(E);
|
||||
@ -1087,10 +1090,11 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
|
||||
}
|
||||
|
||||
if (!discard) {
|
||||
if (mi._static)
|
||||
if (mi._static) {
|
||||
mi.method = env->GetStaticMethodID(bclass, str_method.utf8().get_data(), signature.utf8().get_data());
|
||||
else
|
||||
} else {
|
||||
mi.method = env->GetMethodID(bclass, str_method.utf8().get_data(), signature.utf8().get_data());
|
||||
}
|
||||
|
||||
ERR_CONTINUE(!mi.method);
|
||||
|
||||
@ -1100,7 +1104,7 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
|
||||
env->DeleteLocalRef(obj);
|
||||
env->DeleteLocalRef(param_types);
|
||||
env->DeleteLocalRef(return_type);
|
||||
};
|
||||
}
|
||||
|
||||
env->DeleteLocalRef(methods);
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "java_godot_io_wrapper.h"
|
||||
|
||||
#include "core/error/error_list.h"
|
||||
|
||||
// JNIEnv is only valid within the thread it belongs to, in a multi threading environment
|
||||
|
@ -200,8 +200,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *en
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jclass clazz) {
|
||||
if (step.get() == 0)
|
||||
if (step.get() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DisplayServerAndroid *dsa = Object::cast_to<DisplayServerAndroid>(DisplayServer::get_singleton())) {
|
||||
dsa->send_window_event(DisplayServer::WINDOW_EVENT_GO_BACK_REQUEST);
|
||||
@ -209,8 +210,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jcl
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jclass clazz) {
|
||||
if (step.get() == -1)
|
||||
if (step.get() == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (step.get() == 0) {
|
||||
// Since Godot is initialized on the UI thread, main_thread_id was set to that thread's id,
|
||||
@ -243,8 +245,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jcl
|
||||
}
|
||||
|
||||
void touch_preprocessing(JNIEnv *env, jclass clazz, jint input_device, jint ev, jint pointer, jint pointer_count, jfloatArray positions, jint buttons_mask, jfloat vertical_factor, jfloat horizontal_factor) {
|
||||
if (step.get() <= 0)
|
||||
if (step.get() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Vector<AndroidInputHandler::TouchPos> points;
|
||||
for (int i = 0; i < pointer_count; i++) {
|
||||
@ -279,32 +282,36 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_touch__IIII_3FIFF(JNI
|
||||
|
||||
// Called on the UI thread
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_hover(JNIEnv *env, jclass clazz, jint p_type, jfloat p_x, jfloat p_y) {
|
||||
if (step.get() <= 0)
|
||||
if (step.get() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
input_handler->process_hover(p_type, Point2(p_x, p_y));
|
||||
}
|
||||
|
||||
// Called on the UI thread
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_doubleTap(JNIEnv *env, jclass clazz, jint p_button_mask, jint p_x, jint p_y) {
|
||||
if (step.get() <= 0)
|
||||
if (step.get() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
input_handler->process_double_tap(p_button_mask, Point2(p_x, p_y));
|
||||
}
|
||||
|
||||
// Called on the UI thread
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_scroll(JNIEnv *env, jclass clazz, jint p_x, jint p_y) {
|
||||
if (step.get() <= 0)
|
||||
if (step.get() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
input_handler->process_scroll(Point2(p_x, p_y));
|
||||
}
|
||||
|
||||
// Called on the UI thread
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv *env, jclass clazz, jint p_device, jint p_button, jboolean p_pressed) {
|
||||
if (step.get() <= 0)
|
||||
if (step.get() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
AndroidInputHandler::JoypadEvent jevent;
|
||||
jevent.device = p_device;
|
||||
@ -369,8 +376,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyconnectionchanged(
|
||||
|
||||
// Called on the UI thread
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv *env, jclass clazz, jint p_keycode, jint p_scancode, jint p_unicode_char, jboolean p_pressed) {
|
||||
if (step.get() <= 0)
|
||||
if (step.get() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
input_handler->process_key_event(p_keycode, p_scancode, p_unicode_char, p_pressed);
|
||||
}
|
||||
@ -392,15 +400,17 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gyroscope(JNIEnv *env
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusin(JNIEnv *env, jclass clazz) {
|
||||
if (step.get() <= 0)
|
||||
if (step.get() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
os_android->main_loop_focusin();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusout(JNIEnv *env, jclass clazz) {
|
||||
if (step.get() <= 0)
|
||||
if (step.get() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
os_android->main_loop_focusout();
|
||||
}
|
||||
@ -426,13 +436,14 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *en
|
||||
for (int i = 0; i < count; i++) {
|
||||
jobject obj = env->GetObjectArrayElement(params, i);
|
||||
Variant v;
|
||||
if (obj)
|
||||
if (obj) {
|
||||
v = _jobject_to_variant(env, obj);
|
||||
}
|
||||
memnew_placement(&vlist[i], Variant);
|
||||
vlist[i] = v;
|
||||
vptr[i] = &vlist[i];
|
||||
env->DeleteLocalRef(obj);
|
||||
};
|
||||
}
|
||||
|
||||
Callable::CallError err;
|
||||
obj->call(str_method, (const Variant **)vptr, count, err);
|
||||
@ -455,10 +466,11 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *
|
||||
|
||||
for (int i = 0; i < MIN(count, VARIANT_ARG_MAX); i++) {
|
||||
jobject obj = env->GetObjectArrayElement(params, i);
|
||||
if (obj)
|
||||
if (obj) {
|
||||
args[i] = _jobject_to_variant(env, obj);
|
||||
}
|
||||
env->DeleteLocalRef(obj);
|
||||
};
|
||||
}
|
||||
|
||||
static_assert(VARIANT_ARG_MAX == 8, "This code needs to be updated if VARIANT_ARG_MAX != 8");
|
||||
obj->call_deferred(str_method, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
|
||||
@ -478,8 +490,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_requestPermissionResu
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererResumed(JNIEnv *env, jclass clazz) {
|
||||
if (step.get() <= 0)
|
||||
if (step.get() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (os_android->get_main_loop()) {
|
||||
os_android->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_RESUMED);
|
||||
@ -487,8 +500,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererResumed(JNI
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererPaused(JNIEnv *env, jclass clazz) {
|
||||
if (step.get() <= 0)
|
||||
if (step.get() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (os_android->get_main_loop()) {
|
||||
os_android->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_PAUSED);
|
||||
|
@ -92,8 +92,9 @@ jobject GodotJavaWrapper::get_activity() {
|
||||
|
||||
jobject GodotJavaWrapper::get_member_object(const char *p_name, const char *p_class, JNIEnv *p_env) {
|
||||
if (godot_class) {
|
||||
if (p_env == nullptr)
|
||||
if (p_env == nullptr) {
|
||||
p_env = get_jni_env();
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(p_env == nullptr, nullptr);
|
||||
|
||||
@ -129,8 +130,9 @@ GodotJavaViewWrapper *GodotJavaWrapper::get_godot_view() {
|
||||
|
||||
void GodotJavaWrapper::on_video_init(JNIEnv *p_env) {
|
||||
if (_on_video_init) {
|
||||
if (p_env == nullptr)
|
||||
if (p_env == nullptr) {
|
||||
p_env = get_jni_env();
|
||||
}
|
||||
ERR_FAIL_COND(p_env == nullptr);
|
||||
|
||||
p_env->CallVoidMethod(godot_instance, _on_video_init);
|
||||
@ -158,8 +160,9 @@ void GodotJavaWrapper::on_godot_main_loop_started(JNIEnv *p_env) {
|
||||
|
||||
void GodotJavaWrapper::restart(JNIEnv *p_env) {
|
||||
if (_restart) {
|
||||
if (p_env == nullptr)
|
||||
if (p_env == nullptr) {
|
||||
p_env = get_jni_env();
|
||||
}
|
||||
ERR_FAIL_COND(p_env == nullptr);
|
||||
|
||||
p_env->CallVoidMethod(godot_instance, _restart);
|
||||
@ -168,8 +171,9 @@ void GodotJavaWrapper::restart(JNIEnv *p_env) {
|
||||
|
||||
void GodotJavaWrapper::force_quit(JNIEnv *p_env) {
|
||||
if (_finish) {
|
||||
if (p_env == nullptr)
|
||||
if (p_env == nullptr) {
|
||||
p_env = get_jni_env();
|
||||
}
|
||||
ERR_FAIL_COND(p_env == nullptr);
|
||||
|
||||
p_env->CallVoidMethod(godot_instance, _finish);
|
||||
|
@ -46,7 +46,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
|
||||
env->DeleteLocalRef(bclass);
|
||||
} else {
|
||||
v.val.z = *p_arg;
|
||||
};
|
||||
}
|
||||
} break;
|
||||
case Variant::INT: {
|
||||
if (force_jobject) {
|
||||
@ -61,7 +61,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
|
||||
|
||||
} else {
|
||||
v.val.i = *p_arg;
|
||||
};
|
||||
}
|
||||
} break;
|
||||
case Variant::FLOAT: {
|
||||
if (force_jobject) {
|
||||
@ -76,7 +76,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
|
||||
|
||||
} else {
|
||||
v.val.f = *p_arg;
|
||||
};
|
||||
}
|
||||
} break;
|
||||
case Variant::STRING: {
|
||||
String s = *p_arg;
|
||||
@ -111,7 +111,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
|
||||
jstring str = env->NewStringUTF(String(keys[j]).utf8().get_data());
|
||||
env->SetObjectArrayElement(jkeys, j, str);
|
||||
env->DeleteLocalRef(str);
|
||||
};
|
||||
}
|
||||
|
||||
jmethodID set_keys = env->GetMethodID(dclass, "set_keys", "([Ljava/lang/String;)V");
|
||||
jvalue val;
|
||||
@ -128,7 +128,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
|
||||
if (v.obj) {
|
||||
env->DeleteLocalRef(v.obj);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
jmethodID set_values = env->GetMethodID(dclass, "set_values", "([Ljava/lang/Object;)V");
|
||||
val.l = jvalues;
|
||||
@ -205,7 +205,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
|
||||
|
||||
if (name == "java.lang.String") {
|
||||
return jstring_to_string((jstring)obj, env);
|
||||
};
|
||||
}
|
||||
|
||||
if (name == "[Ljava.lang.String;") {
|
||||
jobjectArray arr = (jobjectArray)obj;
|
||||
@ -219,20 +219,20 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
|
||||
}
|
||||
|
||||
return sarr;
|
||||
};
|
||||
}
|
||||
|
||||
if (name == "java.lang.Boolean") {
|
||||
jmethodID boolValue = env->GetMethodID(c, "booleanValue", "()Z");
|
||||
bool ret = env->CallBooleanMethod(obj, boolValue);
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
if (name == "java.lang.Integer" || name == "java.lang.Long") {
|
||||
jclass nclass = env->FindClass("java/lang/Number");
|
||||
jmethodID longValue = env->GetMethodID(nclass, "longValue", "()J");
|
||||
jlong ret = env->CallLongMethod(obj, longValue);
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
if (name == "[I") {
|
||||
jintArray arr = (jintArray)obj;
|
||||
@ -243,7 +243,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
|
||||
int *w = sarr.ptrw();
|
||||
env->GetIntArrayRegion(arr, 0, fCount, w);
|
||||
return sarr;
|
||||
};
|
||||
}
|
||||
|
||||
if (name == "[B") {
|
||||
jbyteArray arr = (jbyteArray)obj;
|
||||
@ -254,14 +254,14 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
|
||||
uint8_t *w = sarr.ptrw();
|
||||
env->GetByteArrayRegion(arr, 0, fCount, reinterpret_cast<signed char *>(w));
|
||||
return sarr;
|
||||
};
|
||||
}
|
||||
|
||||
if (name == "java.lang.Float" || name == "java.lang.Double") {
|
||||
jclass nclass = env->FindClass("java/lang/Number");
|
||||
jmethodID doubleValue = env->GetMethodID(nclass, "doubleValue", "()D");
|
||||
double ret = env->CallDoubleMethod(obj, doubleValue);
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
if (name == "[D") {
|
||||
jdoubleArray arr = (jdoubleArray)obj;
|
||||
@ -275,9 +275,9 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
|
||||
double n;
|
||||
env->GetDoubleArrayRegion(arr, i, 1, &n);
|
||||
w[i] = n;
|
||||
};
|
||||
}
|
||||
return sarr;
|
||||
};
|
||||
}
|
||||
|
||||
if (name == "[F") {
|
||||
jfloatArray arr = (jfloatArray)obj;
|
||||
@ -291,9 +291,9 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
|
||||
float n;
|
||||
env->GetFloatArrayRegion(arr, i, 1, &n);
|
||||
w[i] = n;
|
||||
};
|
||||
}
|
||||
return sarr;
|
||||
};
|
||||
}
|
||||
|
||||
if (name == "[Ljava.lang.Object;") {
|
||||
jobjectArray arr = (jobjectArray)obj;
|
||||
@ -308,7 +308,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
|
||||
}
|
||||
|
||||
return varr;
|
||||
};
|
||||
}
|
||||
|
||||
if (name == "java.util.HashMap" || name == "org.godotengine.godot.Dictionary") {
|
||||
Dictionary ret;
|
||||
@ -327,10 +327,10 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
|
||||
|
||||
for (int i = 0; i < keys.size(); i++) {
|
||||
ret[keys[i]] = vals[i];
|
||||
};
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
env->DeleteLocalRef(c);
|
||||
|
||||
@ -359,8 +359,9 @@ Variant::Type get_jni_type(const String &p_type) {
|
||||
int idx = 0;
|
||||
|
||||
while (_type_to_vtype[idx].name) {
|
||||
if (p_type == _type_to_vtype[idx].name)
|
||||
if (p_type == _type_to_vtype[idx].name) {
|
||||
return _type_to_vtype[idx].type;
|
||||
}
|
||||
|
||||
idx++;
|
||||
}
|
||||
@ -390,8 +391,9 @@ const char *get_jni_sig(const String &p_type) {
|
||||
int idx = 0;
|
||||
|
||||
while (_type_to_vtype[idx].name) {
|
||||
if (p_type == _type_to_vtype[idx].name)
|
||||
if (p_type == _type_to_vtype[idx].name) {
|
||||
return _type_to_vtype[idx].sig;
|
||||
}
|
||||
|
||||
idx++;
|
||||
}
|
||||
|
@ -77,18 +77,21 @@ NetSocketAndroid::~NetSocketAndroid() {
|
||||
|
||||
void NetSocketAndroid::close() {
|
||||
NetSocketPosix::close();
|
||||
if (wants_broadcast)
|
||||
if (wants_broadcast) {
|
||||
multicast_lock_release();
|
||||
if (multicast_groups)
|
||||
}
|
||||
if (multicast_groups) {
|
||||
multicast_lock_release();
|
||||
}
|
||||
wants_broadcast = false;
|
||||
multicast_groups = 0;
|
||||
}
|
||||
|
||||
Error NetSocketAndroid::set_broadcasting_enabled(bool p_enabled) {
|
||||
Error err = NetSocketPosix::set_broadcasting_enabled(p_enabled);
|
||||
if (err != OK)
|
||||
if (err != OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (p_enabled != wants_broadcast) {
|
||||
if (p_enabled) {
|
||||
@ -105,11 +108,13 @@ Error NetSocketAndroid::set_broadcasting_enabled(bool p_enabled) {
|
||||
|
||||
Error NetSocketAndroid::join_multicast_group(const IPAddress &p_multi_address, String p_if_name) {
|
||||
Error err = NetSocketPosix::join_multicast_group(p_multi_address, p_if_name);
|
||||
if (err != OK)
|
||||
if (err != OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (!multicast_groups)
|
||||
if (!multicast_groups) {
|
||||
multicast_lock_acquire();
|
||||
}
|
||||
multicast_groups++;
|
||||
|
||||
return OK;
|
||||
@ -117,14 +122,16 @@ Error NetSocketAndroid::join_multicast_group(const IPAddress &p_multi_address, S
|
||||
|
||||
Error NetSocketAndroid::leave_multicast_group(const IPAddress &p_multi_address, String p_if_name) {
|
||||
Error err = NetSocketPosix::leave_multicast_group(p_multi_address, p_if_name);
|
||||
if (err != OK)
|
||||
if (err != OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(multicast_groups == 0, ERR_BUG);
|
||||
|
||||
multicast_groups--;
|
||||
if (!multicast_groups)
|
||||
if (!multicast_groups) {
|
||||
multicast_lock_release();
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
@ -81,17 +81,18 @@ void OS_Android::alert(const String &p_alert, const String &p_title) {
|
||||
void OS_Android::initialize_core() {
|
||||
OS_Unix::initialize_core();
|
||||
|
||||
if (use_apk_expansion)
|
||||
if (use_apk_expansion) {
|
||||
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_RESOURCES);
|
||||
else {
|
||||
} else {
|
||||
FileAccess::make_default<FileAccessAndroid>(FileAccess::ACCESS_RESOURCES);
|
||||
}
|
||||
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_USERDATA);
|
||||
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_FILESYSTEM);
|
||||
if (use_apk_expansion)
|
||||
if (use_apk_expansion) {
|
||||
DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_RESOURCES);
|
||||
else
|
||||
} else {
|
||||
DirAccess::make_default<DirAccessJAndroid>(DirAccess::ACCESS_RESOURCES);
|
||||
}
|
||||
DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_USERDATA);
|
||||
DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_FILESYSTEM);
|
||||
|
||||
@ -162,20 +163,23 @@ MainLoop *OS_Android::get_main_loop() const {
|
||||
}
|
||||
|
||||
void OS_Android::main_loop_begin() {
|
||||
if (main_loop)
|
||||
if (main_loop) {
|
||||
main_loop->initialize();
|
||||
}
|
||||
}
|
||||
|
||||
bool OS_Android::main_loop_iterate() {
|
||||
if (!main_loop)
|
||||
if (!main_loop) {
|
||||
return false;
|
||||
}
|
||||
DisplayServerAndroid::get_singleton()->process_events();
|
||||
return Main::iteration();
|
||||
}
|
||||
|
||||
void OS_Android::main_loop_end() {
|
||||
if (main_loop)
|
||||
if (main_loop) {
|
||||
main_loop->finalize();
|
||||
}
|
||||
}
|
||||
|
||||
void OS_Android::main_loop_focusout() {
|
||||
@ -207,8 +211,9 @@ String OS_Android::get_locale() const {
|
||||
|
||||
String OS_Android::get_model_name() const {
|
||||
String model = godot_io_java->get_model();
|
||||
if (!model.is_empty())
|
||||
if (!model.is_empty()) {
|
||||
return model;
|
||||
}
|
||||
|
||||
return OS_Unix::get_model_name();
|
||||
}
|
||||
@ -218,8 +223,9 @@ String OS_Android::get_data_path() const {
|
||||
}
|
||||
|
||||
String OS_Android::get_user_data_dir() const {
|
||||
if (!data_dir_cache.is_empty())
|
||||
if (!data_dir_cache.is_empty()) {
|
||||
return data_dir_cache;
|
||||
}
|
||||
|
||||
String data_dir = godot_io_java->get_user_data_dir();
|
||||
if (!data_dir.is_empty()) {
|
||||
@ -230,8 +236,9 @@ String OS_Android::get_user_data_dir() const {
|
||||
}
|
||||
|
||||
String OS_Android::get_cache_path() const {
|
||||
if (!cache_dir_cache.is_empty())
|
||||
if (!cache_dir_cache.is_empty()) {
|
||||
return cache_dir_cache;
|
||||
}
|
||||
|
||||
String cache_dir = godot_io_java->get_cache_dir();
|
||||
if (!cache_dir.is_empty()) {
|
||||
@ -243,8 +250,9 @@ String OS_Android::get_cache_path() const {
|
||||
|
||||
String OS_Android::get_unique_id() const {
|
||||
String unique_id = godot_io_java->get_unique_id();
|
||||
if (!unique_id.is_empty())
|
||||
if (!unique_id.is_empty()) {
|
||||
return unique_id;
|
||||
}
|
||||
|
||||
return OS::get_unique_id();
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#import "app_delegate.h"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "drivers/coreaudio/audio_driver_coreaudio.h"
|
||||
#import "godot_view.h"
|
||||
@ -76,7 +77,7 @@ static ViewController *mainViewController = nil;
|
||||
// bail, things did not go very well for us, should probably output a message on screen with our error code...
|
||||
exit(0);
|
||||
return NO;
|
||||
};
|
||||
}
|
||||
|
||||
ViewController *viewController = [[ViewController alloc] init];
|
||||
viewController.godotView.useCADisplayLink = bool(GLOBAL_DEF("display.iOS/use_cadisplaylink", true)) ? YES : NO;
|
||||
@ -99,7 +100,7 @@ static ViewController *mainViewController = nil;
|
||||
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];
|
||||
|
||||
return YES;
|
||||
};
|
||||
}
|
||||
|
||||
- (void)onAudioInterruption:(NSNotification *)notification {
|
||||
if ([notification.name isEqualToString:AVAudioSessionInterruptionNotification]) {
|
||||
@ -111,17 +112,17 @@ static ViewController *mainViewController = nil;
|
||||
OSIPhone::get_singleton()->on_focus_in();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
|
||||
if (OS::get_singleton()->get_main_loop()) {
|
||||
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_OS_MEMORY_WARNING);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
iphone_finish();
|
||||
};
|
||||
}
|
||||
|
||||
// When application goes to background (e.g. user switches to another app or presses Home),
|
||||
// then applicationWillResignActive -> applicationDidEnterBackground are called.
|
||||
|
@ -29,6 +29,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#import "display_layer.h"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/os/keyboard.h"
|
||||
#include "display_server_iphone.h"
|
||||
@ -153,17 +154,6 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
// if (OS::get_singleton()) {
|
||||
// OS::VideoMode vm;
|
||||
// vm.fullscreen = true;
|
||||
// vm.width = backingWidth;
|
||||
// vm.height = backingHeight;
|
||||
// vm.resizable = false;
|
||||
// OS::get_singleton()->set_video_mode(vm);
|
||||
// OSIPhone::get_singleton()->set_base_framebuffer(viewFramebuffer);
|
||||
// };
|
||||
// gl_view_base_fb = viewFramebuffer;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "display_server_iphone.h"
|
||||
|
||||
#import "app_delegate.h"
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/io/file_access_pack.h"
|
||||
@ -231,7 +232,7 @@ void DisplayServerIPhone::touch_press(int p_idx, int p_x, int p_y, bool p_presse
|
||||
ev->set_position(Vector2(p_x, p_y));
|
||||
perform_event(ev);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void DisplayServerIPhone::touch_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y) {
|
||||
if (!GLOBAL_DEF("debug/disable_touch", false)) {
|
||||
@ -241,16 +242,16 @@ void DisplayServerIPhone::touch_drag(int p_idx, int p_prev_x, int p_prev_y, int
|
||||
ev->set_position(Vector2(p_x, p_y));
|
||||
ev->set_relative(Vector2(p_x - p_prev_x, p_y - p_prev_y));
|
||||
perform_event(ev);
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayServerIPhone::perform_event(const Ref<InputEvent> &p_event) {
|
||||
Input::get_singleton()->parse_input_event(p_event);
|
||||
};
|
||||
}
|
||||
|
||||
void DisplayServerIPhone::touches_cancelled(int p_idx) {
|
||||
touch_press(p_idx, -1, -1, false, false);
|
||||
};
|
||||
}
|
||||
|
||||
// MARK: Keyboard
|
||||
|
||||
@ -263,13 +264,13 @@ void DisplayServerIPhone::key(Key p_key, bool p_pressed) {
|
||||
ev->set_physical_keycode(p_key);
|
||||
ev->set_unicode((char32_t)p_key);
|
||||
perform_event(ev);
|
||||
};
|
||||
}
|
||||
|
||||
// MARK: Motion
|
||||
|
||||
void DisplayServerIPhone::update_gravity(float p_x, float p_y, float p_z) {
|
||||
Input::get_singleton()->set_gravity(Vector3(p_x, p_y, p_z));
|
||||
};
|
||||
}
|
||||
|
||||
void DisplayServerIPhone::update_accelerometer(float p_x, float p_y, float p_z) {
|
||||
// Found out the Z should not be negated! Pass as is!
|
||||
@ -279,15 +280,15 @@ void DisplayServerIPhone::update_accelerometer(float p_x, float p_y, float p_z)
|
||||
p_z / kDisplayServerIPhoneAcceleration);
|
||||
|
||||
Input::get_singleton()->set_accelerometer(v_accelerometer);
|
||||
};
|
||||
}
|
||||
|
||||
void DisplayServerIPhone::update_magnetometer(float p_x, float p_y, float p_z) {
|
||||
Input::get_singleton()->set_magnetometer(Vector3(p_x, p_y, p_z));
|
||||
};
|
||||
}
|
||||
|
||||
void DisplayServerIPhone::update_gyroscope(float p_x, float p_y, float p_z) {
|
||||
Input::get_singleton()->set_gyroscope(Vector3(p_x, p_y, p_z));
|
||||
};
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
|
||||
@ -520,7 +521,7 @@ void DisplayServerIPhone::window_move_to_foreground(WindowID p_window) {
|
||||
|
||||
float DisplayServerIPhone::screen_get_max_scale() const {
|
||||
return screen_get_scale(SCREEN_OF_MAIN_WINDOW);
|
||||
};
|
||||
}
|
||||
|
||||
void DisplayServerIPhone::screen_set_orientation(DisplayServer::ScreenOrientation p_orientation, int p_screen) {
|
||||
screen_orientation = p_orientation;
|
||||
|
@ -53,7 +53,7 @@ int add_path(int p_argc, char **p_args) {
|
||||
p_args[p_argc] = nullptr;
|
||||
|
||||
return p_argc;
|
||||
};
|
||||
}
|
||||
|
||||
int add_cmdline(int p_argc, char **p_args) {
|
||||
NSArray *arr = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_cmdline"];
|
||||
@ -67,12 +67,12 @@ int add_cmdline(int p_argc, char **p_args) {
|
||||
continue;
|
||||
}
|
||||
p_args[p_argc++] = (char *)[str cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
};
|
||||
}
|
||||
|
||||
p_args[p_argc] = nullptr;
|
||||
|
||||
return p_argc;
|
||||
};
|
||||
}
|
||||
|
||||
int iphone_main(int argc, char **argv, String data_dir, String cache_dir) {
|
||||
size_t len = strlen(argv[0]);
|
||||
@ -103,7 +103,7 @@ int iphone_main(int argc, char **argv, String data_dir, String cache_dir) {
|
||||
char *fargv[64];
|
||||
for (int i = 0; i < argc; i++) {
|
||||
fargv[i] = argv[i];
|
||||
};
|
||||
}
|
||||
fargv[argc] = nullptr;
|
||||
argc = add_path(argc, fargv);
|
||||
argc = add_cmdline(argc, fargv);
|
||||
@ -119,10 +119,10 @@ int iphone_main(int argc, char **argv, String data_dir, String cache_dir) {
|
||||
os->initialize_modules();
|
||||
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
void iphone_finish() {
|
||||
printf("iphone_finish\n");
|
||||
Main::cleanup();
|
||||
delete os;
|
||||
};
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#import "godot_view.h"
|
||||
|
||||
#include "core/os/keyboard.h"
|
||||
#include "core/string/ustring.h"
|
||||
#import "display_layer.h"
|
||||
@ -226,8 +227,9 @@ static const float earth_gravity = 9.80665;
|
||||
[self.displayLink setPaused:YES];
|
||||
|
||||
// Process all input events
|
||||
while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.0, TRUE) == kCFRunLoopRunHandledSource)
|
||||
;
|
||||
while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.0, TRUE) == kCFRunLoopRunHandledSource) {
|
||||
// Continue.
|
||||
}
|
||||
|
||||
// We are good to go, resume the CADisplayLink
|
||||
[self.displayLink setPaused:NO];
|
||||
|
@ -29,6 +29,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#import "godot_view_gesture_recognizer.h"
|
||||
|
||||
#import "godot_view.h"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
|
@ -29,6 +29,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#import "godot_view_renderer.h"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/os/keyboard.h"
|
||||
#import "display_server_iphone.h"
|
||||
@ -101,7 +102,7 @@
|
||||
double dval = [n doubleValue];
|
||||
|
||||
ProjectSettings::get_singleton()->set("Info.plist/" + ukey, dval);
|
||||
};
|
||||
}
|
||||
// do stuff
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "ios.h"
|
||||
|
||||
#import "app_delegate.h"
|
||||
#import "view_controller.h"
|
||||
#import <UIKit/UIKit.h>
|
||||
@ -36,7 +37,7 @@
|
||||
|
||||
void iOS::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_rate_url", "app_id"), &iOS::get_rate_url);
|
||||
};
|
||||
}
|
||||
|
||||
void iOS::alert(const char *p_alert, const char *p_title) {
|
||||
NSString *title = [NSString stringWithUTF8String:p_title];
|
||||
@ -75,6 +76,6 @@ String iOS::get_rate_url(int p_app_id) const {
|
||||
|
||||
printf("returning rate url %s\n", ret.utf8().get_data());
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
iOS::iOS() {}
|
||||
|
@ -29,6 +29,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#import "joypad_iphone.h"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "drivers/coreaudio/audio_driver_coreaudio.h"
|
||||
#include "main/main.h"
|
||||
@ -139,10 +140,10 @@ void JoypadIPhone::start_processing() {
|
||||
for (NSNumber *key in keys) {
|
||||
int joy_id = [key intValue];
|
||||
return joy_id;
|
||||
};
|
||||
}
|
||||
|
||||
return -1;
|
||||
};
|
||||
}
|
||||
|
||||
- (void)addiOSJoypad:(GCController *)controller {
|
||||
// get a new id for our controller
|
||||
@ -156,7 +157,7 @@ void JoypadIPhone::start_processing() {
|
||||
// assign our player index
|
||||
if (controller.playerIndex == GCControllerPlayerIndexUnset) {
|
||||
controller.playerIndex = [self getFreePlayerIndex];
|
||||
};
|
||||
}
|
||||
|
||||
// tell Godot about our new controller
|
||||
Input::get_singleton()->joy_connection_changed(joy_id, true, String::utf8([controller.vendorName UTF8String]));
|
||||
@ -202,8 +203,8 @@ void JoypadIPhone::start_processing() {
|
||||
|
||||
// and remove it from our dictionary
|
||||
[self.connectedJoypads removeObjectForKey:key];
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
- (GCControllerPlayerIndex)getFreePlayerIndex {
|
||||
bool have_player_1 = false;
|
||||
@ -223,9 +224,9 @@ void JoypadIPhone::start_processing() {
|
||||
have_player_3 = true;
|
||||
} else if (controller.playerIndex == GCControllerPlayerIndex4) {
|
||||
have_player_4 = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!have_player_1) {
|
||||
return GCControllerPlayerIndex1;
|
||||
@ -237,7 +238,7 @@ void JoypadIPhone::start_processing() {
|
||||
return GCControllerPlayerIndex4;
|
||||
} else {
|
||||
return GCControllerPlayerIndexUnset;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setControllerInputHandler:(GCController *)controller {
|
||||
@ -285,7 +286,7 @@ void JoypadIPhone::start_processing() {
|
||||
gamepad.dpad.left.isPressed);
|
||||
Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_RIGHT,
|
||||
gamepad.dpad.right.isPressed);
|
||||
};
|
||||
}
|
||||
|
||||
if (element == gamepad.leftThumbstick) {
|
||||
float value = gamepad.leftThumbstick.xAxis.value;
|
||||
@ -303,7 +304,7 @@ void JoypadIPhone::start_processing() {
|
||||
} else if (element == gamepad.rightTrigger) {
|
||||
float value = gamepad.rightTrigger.value;
|
||||
Input::get_singleton()->joy_axis(joy_id, JoyAxis::TRIGGER_RIGHT, value);
|
||||
};
|
||||
}
|
||||
};
|
||||
} else if (controller.microGamepad != nil) {
|
||||
// micro gamepads were added in OS 9 and feature just 2 buttons and a d-pad
|
||||
@ -329,7 +330,7 @@ void JoypadIPhone::start_processing() {
|
||||
gamepad.dpad.down.isPressed);
|
||||
Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_LEFT, gamepad.dpad.left.isPressed);
|
||||
Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_RIGHT, gamepad.dpad.right.isPressed);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -338,6 +339,6 @@ void JoypadIPhone::start_processing() {
|
||||
|
||||
///@TODO need to add support for controllerPausedHandler which should be a
|
||||
/// toggle
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -31,6 +31,7 @@
|
||||
#ifdef IPHONE_ENABLED
|
||||
|
||||
#include "os_iphone.h"
|
||||
|
||||
#import "app_delegate.h"
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/io/dir_access.h"
|
||||
@ -169,7 +170,7 @@ void OSIPhone::delete_main_loop() {
|
||||
if (main_loop) {
|
||||
main_loop->finalize();
|
||||
memdelete(main_loop);
|
||||
};
|
||||
}
|
||||
|
||||
main_loop = nullptr;
|
||||
}
|
||||
@ -198,7 +199,7 @@ void OSIPhone::finalize() {
|
||||
deinitialize_modules();
|
||||
|
||||
// Already gets called
|
||||
// delete_main_loop();
|
||||
//delete_main_loop();
|
||||
}
|
||||
|
||||
// MARK: Dynamic Libraries
|
||||
@ -231,12 +232,13 @@ Error OSIPhone::get_dynamic_library_symbol_handle(void *p_library_handle, const
|
||||
|
||||
String OSIPhone::get_name() const {
|
||||
return "iOS";
|
||||
};
|
||||
}
|
||||
|
||||
String OSIPhone::get_model_name() const {
|
||||
String model = ios->get_model();
|
||||
if (model != "")
|
||||
if (model != "") {
|
||||
return model;
|
||||
}
|
||||
|
||||
return OS_Unix::get_model_name();
|
||||
}
|
||||
@ -254,7 +256,7 @@ Error OSIPhone::shell_open(String p_uri) {
|
||||
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
|
||||
|
||||
return OK;
|
||||
};
|
||||
}
|
||||
|
||||
void OSIPhone::set_user_data_dir(String p_dir) {
|
||||
DirAccess *da = DirAccess::open(p_dir);
|
||||
|
@ -203,7 +203,7 @@
|
||||
case DisplayServer::SCREEN_LANDSCAPE:
|
||||
return UIInterfaceOrientationMaskLandscapeLeft;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
- (BOOL)prefersStatusBarHidden {
|
||||
return YES;
|
||||
|
@ -28,7 +28,7 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "platform/javascript/display_server_javascript.h"
|
||||
#include "display_server_javascript.h"
|
||||
|
||||
#ifdef GLES3_ENABLED
|
||||
#include "drivers/gles3/rasterizer_gles3.h"
|
||||
@ -325,12 +325,13 @@ void DisplayServerJavaScript::cursor_set_custom_image(const RES &p_cursor, Curso
|
||||
|
||||
image = image->duplicate();
|
||||
|
||||
if (atlas_texture.is_valid())
|
||||
if (atlas_texture.is_valid()) {
|
||||
image->crop_from_point(
|
||||
atlas_rect.position.x,
|
||||
atlas_rect.position.y,
|
||||
texture_size.width,
|
||||
texture_size.height);
|
||||
}
|
||||
|
||||
if (image->get_format() != Image::FORMAT_RGBA8) {
|
||||
image->convert(Image::FORMAT_RGBA8);
|
||||
@ -618,8 +619,9 @@ void DisplayServerJavaScript::set_icon(const Ref<Image> &p_icon) {
|
||||
ERR_FAIL_COND(icon->decompress() != OK);
|
||||
}
|
||||
if (icon->get_format() != Image::FORMAT_RGBA8) {
|
||||
if (icon == p_icon)
|
||||
if (icon == p_icon) {
|
||||
icon = icon->duplicate();
|
||||
}
|
||||
icon->convert(Image::FORMAT_RGBA8);
|
||||
}
|
||||
|
||||
@ -891,8 +893,9 @@ Size2i DisplayServerJavaScript::window_get_real_size(WindowID p_window) const {
|
||||
}
|
||||
|
||||
void DisplayServerJavaScript::window_set_mode(WindowMode p_mode, WindowID p_window) {
|
||||
if (window_mode == p_mode)
|
||||
if (window_mode == p_mode) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (p_mode) {
|
||||
case WINDOW_MODE_WINDOWED: {
|
||||
|
@ -29,6 +29,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "api/javascript_singleton.h"
|
||||
|
||||
#include "emscripten.h"
|
||||
#include "os_javascript.h"
|
||||
|
||||
|
@ -175,7 +175,7 @@ String OS_JavaScript::get_name() const {
|
||||
|
||||
String OS_JavaScript::get_user_data_dir() const {
|
||||
return "/userfs";
|
||||
};
|
||||
}
|
||||
|
||||
String OS_JavaScript::get_cache_path() const {
|
||||
return "/home/web_user/.cache";
|
||||
|
@ -4794,7 +4794,7 @@ DisplayServerX11::~DisplayServerX11() {
|
||||
if (img[i] != nullptr) {
|
||||
XcursorImageDestroy(img[i]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (xim) {
|
||||
XCloseIM(xim);
|
||||
|
@ -238,7 +238,7 @@ void JoypadLinux::close_joypad(int p_id) {
|
||||
if (p_id == -1) {
|
||||
for (int i = 0; i < JOYPADS_MAX; i++) {
|
||||
close_joypad(i);
|
||||
};
|
||||
}
|
||||
return;
|
||||
} else if (p_id < 0) {
|
||||
return;
|
||||
@ -251,7 +251,7 @@ void JoypadLinux::close_joypad(int p_id) {
|
||||
joy.fd = -1;
|
||||
attached_devices.remove_at(attached_devices.find(joy.devpath));
|
||||
input->joy_connection_changed(p_id, false, "");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
static String _hex_str(uint8_t p_byte) {
|
||||
@ -516,7 +516,7 @@ void JoypadLinux::process_joypads() {
|
||||
}
|
||||
if (len == 0 || (len < 0 && errno != EAGAIN)) {
|
||||
close_joypad(i);
|
||||
};
|
||||
}
|
||||
|
||||
if (joy->force_feedback) {
|
||||
uint64_t timestamp = input->get_joy_vibration_timestamp(i);
|
||||
|
@ -356,7 +356,7 @@ void OS_LinuxBSD::run() {
|
||||
if (Main::iteration()) {
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
main_loop->finalize();
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "vulkan_context_x11.h"
|
||||
|
||||
#ifdef USE_VOLK
|
||||
#include <volk.h>
|
||||
#else
|
||||
|
@ -89,8 +89,9 @@ static void handle_crash(int sig) {
|
||||
fprintf(stderr, "\n================================================================\n");
|
||||
fprintf(stderr, "%s: Program crashed with signal %d\n", __FUNCTION__, sig);
|
||||
|
||||
if (OS::get_singleton()->get_main_loop())
|
||||
if (OS::get_singleton()->get_main_loop()) {
|
||||
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_CRASH);
|
||||
}
|
||||
|
||||
// Print the engine version just before, so that people are reminded to include the version in backtrace reports.
|
||||
if (String(VERSION_HASH).is_empty()) {
|
||||
@ -119,10 +120,11 @@ static void handle_crash(int sig) {
|
||||
snprintf(fname, 1024, "%s", demangled);
|
||||
}
|
||||
|
||||
if (demangled)
|
||||
if (demangled) {
|
||||
free(demangled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String output = fname;
|
||||
|
||||
@ -177,8 +179,9 @@ CrashHandler::~CrashHandler() {
|
||||
}
|
||||
|
||||
void CrashHandler::disable() {
|
||||
if (disabled)
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef CRASH_HANDLER_ENABLED
|
||||
signal(SIGSEGV, nullptr);
|
||||
|
@ -790,12 +790,13 @@ String DisplayServerOSX::global_menu_get_item_submenu(const String &p_menu_root,
|
||||
const NSMenu *sub_menu = [menu_item submenu];
|
||||
if (sub_menu) {
|
||||
for (Map<String, NSMenu *>::Element *E = submenu.front(); E; E = E->next()) {
|
||||
if (E->get() == sub_menu)
|
||||
if (E->get() == sub_menu) {
|
||||
return E->key();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return String();
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ int main(int argc, char **argv) {
|
||||
first_arg = i + 2;
|
||||
}
|
||||
printf("%i: %s\n", i, argv[i]);
|
||||
};
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
// Lets report the path we made current after all that.
|
||||
@ -84,4 +84,4 @@ int main(int argc, char **argv) {
|
||||
Main::cleanup();
|
||||
|
||||
return os.get_exit_code();
|
||||
};
|
||||
}
|
||||
|
@ -322,11 +322,12 @@ bool JoypadOSX::configure_joypad(IOHIDDeviceRef p_device_ref, joypad *p_joy) {
|
||||
// Bluetooth device.
|
||||
String guid = "05000000";
|
||||
for (int i = 0; i < 12; i++) {
|
||||
if (i < name.size())
|
||||
if (i < name.size()) {
|
||||
guid += _hex_str(name[i]);
|
||||
else
|
||||
} else {
|
||||
guid += "00";
|
||||
}
|
||||
}
|
||||
input->joy_connection_changed(id, true, name, guid);
|
||||
}
|
||||
|
||||
@ -381,8 +382,9 @@ bool joypad::check_ff_features() {
|
||||
if (ret == FF_OK && (features.supportedEffects & FFCAP_ET_CONSTANTFORCE)) {
|
||||
uint32_t val;
|
||||
ret = FFDeviceGetForceFeedbackProperty(ff_device, FFPROP_FFGAIN, &val, sizeof(val));
|
||||
if (ret != FF_OK)
|
||||
if (ret != FF_OK) {
|
||||
return false;
|
||||
}
|
||||
int num_axes = features.numFfAxes;
|
||||
ff_axes = (DWORD *)memalloc(sizeof(DWORD) * num_axes);
|
||||
ff_directions = (LONG *)memalloc(sizeof(LONG) * num_axes);
|
||||
@ -509,17 +511,19 @@ void JoypadOSX::joypad_vibration_stop(int p_id, uint64_t p_timestamp) {
|
||||
|
||||
int JoypadOSX::get_joy_index(int p_id) const {
|
||||
for (int i = 0; i < device_list.size(); i++) {
|
||||
if (device_list[i].id == p_id)
|
||||
if (device_list[i].id == p_id) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int JoypadOSX::get_joy_ref(IOHIDDeviceRef p_device) const {
|
||||
for (int i = 0; i < device_list.size(); i++) {
|
||||
if (device_list[i].device_ref == p_device)
|
||||
if (device_list[i].device_ref == p_device) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -441,7 +441,7 @@ void OS_OSX::run() {
|
||||
} @catch (NSException *exception) {
|
||||
ERR_PRINT("NSException: " + String::utf8([exception reason].UTF8String));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
main_loop->finalize();
|
||||
}
|
||||
|
@ -40,10 +40,11 @@ void OSXTerminalLogger::log_error(const char *p_function, const char *p_file, in
|
||||
}
|
||||
|
||||
const char *err_details;
|
||||
if (p_rationale && p_rationale[0])
|
||||
if (p_rationale && p_rationale[0]) {
|
||||
err_details = p_rationale;
|
||||
else
|
||||
} else {
|
||||
err_details = p_code;
|
||||
}
|
||||
|
||||
switch (p_type) {
|
||||
case ERR_WARNING:
|
||||
|
@ -177,7 +177,7 @@ static MouseButton _get_button(Windows::UI::Input::PointerPoint ^ pt) {
|
||||
#endif
|
||||
|
||||
return MOUSE_BUTTON_NONE;
|
||||
};
|
||||
}
|
||||
|
||||
static bool _is_touch(Windows::UI::Input::PointerPoint ^ pointerPoint) {
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
@ -231,11 +231,11 @@ static Windows::Foundation::Point _get_pixel_position(CoreWindow ^ window, Windo
|
||||
outputPosition.Y *= vm.height;
|
||||
|
||||
return outputPosition;
|
||||
};
|
||||
}
|
||||
|
||||
static int _get_finger(uint32_t p_touch_id) {
|
||||
return p_touch_id % 31; // for now
|
||||
};
|
||||
}
|
||||
|
||||
void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args, bool p_pressed, bool p_is_wheel) {
|
||||
Windows::UI::Input::PointerPoint ^ point = args->CurrentPoint;
|
||||
@ -281,15 +281,15 @@ void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Cor
|
||||
os->input_event(mouse_button);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void App::OnPointerPressed(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) {
|
||||
pointer_event(sender, args, true);
|
||||
};
|
||||
}
|
||||
|
||||
void App::OnPointerReleased(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) {
|
||||
pointer_event(sender, args, false);
|
||||
};
|
||||
}
|
||||
|
||||
void App::OnPointerWheelChanged(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) {
|
||||
pointer_event(sender, args, true, true);
|
||||
@ -416,8 +416,9 @@ void App::Load(Platform::String ^ entryPoint) {
|
||||
|
||||
// This method is called after the window becomes active.
|
||||
void App::Run() {
|
||||
if (Main::start())
|
||||
if (Main::start()) {
|
||||
os->run();
|
||||
}
|
||||
}
|
||||
|
||||
// Terminate events do not cause Uninitialize to be called. It will be called if your IFrameworkView
|
||||
|
@ -36,26 +36,26 @@ using Platform::Exception;
|
||||
|
||||
void ContextEGL_UWP::release_current() {
|
||||
eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, mEglContext);
|
||||
};
|
||||
}
|
||||
|
||||
void ContextEGL_UWP::make_current() {
|
||||
eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext);
|
||||
};
|
||||
}
|
||||
|
||||
int ContextEGL_UWP::get_window_width() {
|
||||
return width;
|
||||
};
|
||||
}
|
||||
|
||||
int ContextEGL_UWP::get_window_height() {
|
||||
return height;
|
||||
};
|
||||
}
|
||||
|
||||
void ContextEGL_UWP::reset() {
|
||||
cleanup();
|
||||
|
||||
window = CoreWindow::GetForCurrentThread();
|
||||
initialize();
|
||||
};
|
||||
}
|
||||
|
||||
void ContextEGL_UWP::swap_buffers() {
|
||||
if (eglSwapBuffers(mEglDisplay, mEglSurface) != EGL_TRUE) {
|
||||
@ -66,7 +66,7 @@ void ContextEGL_UWP::swap_buffers() {
|
||||
|
||||
// tell rasterizer to reload textures and stuff?
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Error ContextEGL_UWP::initialize() {
|
||||
EGLint configAttribList[] = {
|
||||
@ -170,7 +170,7 @@ Error ContextEGL_UWP::initialize() {
|
||||
}
|
||||
} catch (...) {
|
||||
return FAILED;
|
||||
};
|
||||
}
|
||||
|
||||
mEglDisplay = display;
|
||||
mEglSurface = surface;
|
||||
@ -180,7 +180,7 @@ Error ContextEGL_UWP::initialize() {
|
||||
eglQuerySurface(display, surface, EGL_HEIGHT, &height);
|
||||
|
||||
return OK;
|
||||
};
|
||||
}
|
||||
|
||||
void ContextEGL_UWP::cleanup() {
|
||||
if (mEglDisplay != EGL_NO_DISPLAY && mEglSurface != EGL_NO_SURFACE) {
|
||||
@ -197,7 +197,7 @@ void ContextEGL_UWP::cleanup() {
|
||||
eglTerminate(mEglDisplay);
|
||||
mEglDisplay = EGL_NO_DISPLAY;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ContextEGL_UWP::ContextEGL_UWP(CoreWindow ^ p_window, Driver p_driver) :
|
||||
mEglDisplay(EGL_NO_DISPLAY),
|
||||
@ -209,4 +209,4 @@ ContextEGL_UWP::ContextEGL_UWP(CoreWindow ^ p_window, Driver p_driver) :
|
||||
|
||||
ContextEGL_UWP::~ContextEGL_UWP() {
|
||||
cleanup();
|
||||
};
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "joypad_uwp.h"
|
||||
|
||||
#include "core/os/os.h"
|
||||
|
||||
using namespace Windows::Gaming::Input;
|
||||
@ -45,8 +46,9 @@ void JoypadUWP::process_controllers() {
|
||||
for (int i = 0; i < MAX_CONTROLLERS; i++) {
|
||||
ControllerDevice &joy = controllers[i];
|
||||
|
||||
if (!joy.connected)
|
||||
if (!joy.connected) {
|
||||
break;
|
||||
}
|
||||
|
||||
switch (joy.type) {
|
||||
case ControllerType::GAMEPAD_CONTROLLER: {
|
||||
@ -76,9 +78,10 @@ void JoypadUWP::process_controllers() {
|
||||
}
|
||||
} else if (joy.vibrating && joy.ff_end_timestamp != 0) {
|
||||
uint64_t current_time = OS::get_singleton()->get_ticks_usec();
|
||||
if (current_time >= joy.ff_end_timestamp)
|
||||
if (current_time >= joy.ff_end_timestamp) {
|
||||
joypad_vibration_stop(i, current_time);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@ -87,8 +90,9 @@ void JoypadUWP::process_controllers() {
|
||||
}
|
||||
|
||||
JoypadUWP::JoypadUWP() {
|
||||
for (int i = 0; i < MAX_CONTROLLERS; i++)
|
||||
for (int i = 0; i < MAX_CONTROLLERS; i++) {
|
||||
controllers[i].id = i;
|
||||
}
|
||||
}
|
||||
|
||||
JoypadUWP::JoypadUWP(InputDefault *p_input) {
|
||||
|
@ -95,12 +95,12 @@ void OS_UWP::set_window_fullscreen(bool p_enabled) {
|
||||
|
||||
video_mode.fullscreen = view->IsFullScreenMode;
|
||||
|
||||
if (video_mode.fullscreen == p_enabled)
|
||||
if (video_mode.fullscreen == p_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_enabled) {
|
||||
video_mode.fullscreen = view->TryEnterFullScreenMode();
|
||||
|
||||
} else {
|
||||
view->ExitFullScreenMode();
|
||||
video_mode.fullscreen = false;
|
||||
@ -112,13 +112,15 @@ bool OS_UWP::is_window_fullscreen() const {
|
||||
}
|
||||
|
||||
void OS_UWP::set_keep_screen_on(bool p_enabled) {
|
||||
if (is_keep_screen_on() == p_enabled)
|
||||
if (is_keep_screen_on() == p_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_enabled)
|
||||
if (p_enabled) {
|
||||
display_request->RequestActive();
|
||||
else
|
||||
} else {
|
||||
display_request->RequestRelease();
|
||||
}
|
||||
|
||||
OS::set_keep_screen_on(p_enabled);
|
||||
}
|
||||
@ -150,7 +152,7 @@ void OS_UWP::set_window(Windows::UI::Core::CoreWindow ^ p_window) {
|
||||
|
||||
void OS_UWP::screen_size_changed() {
|
||||
gl_context->reset();
|
||||
};
|
||||
}
|
||||
|
||||
Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
main_loop = nullptr;
|
||||
@ -269,8 +271,9 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
|
||||
|
||||
_ensure_user_data_dir();
|
||||
|
||||
if (is_keep_screen_on())
|
||||
if (is_keep_screen_on()) {
|
||||
display_request->RequestActive();
|
||||
}
|
||||
|
||||
set_keep_screen_on(GLOBAL_DEF("display/window/energy_saving/keep_screen_on", true));
|
||||
|
||||
@ -283,22 +286,24 @@ void OS_UWP::set_clipboard(const String &p_text) {
|
||||
clip->SetText(ref new Platform::String((LPCWSTR)(p_text.utf16().get_data())));
|
||||
|
||||
Clipboard::SetContent(clip);
|
||||
};
|
||||
}
|
||||
|
||||
String OS_UWP::get_clipboard() const {
|
||||
if (managed_object->clipboard != nullptr)
|
||||
if (managed_object->clipboard != nullptr) {
|
||||
return managed_object->clipboard->Data();
|
||||
else
|
||||
} else {
|
||||
return "";
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void OS_UWP::input_event(const Ref<InputEvent> &p_event) {
|
||||
input->parse_input_event(p_event);
|
||||
};
|
||||
}
|
||||
|
||||
void OS_UWP::delete_main_loop() {
|
||||
if (main_loop)
|
||||
if (main_loop) {
|
||||
memdelete(main_loop);
|
||||
}
|
||||
main_loop = nullptr;
|
||||
}
|
||||
|
||||
@ -308,16 +313,18 @@ void OS_UWP::set_main_loop(MainLoop *p_main_loop) {
|
||||
}
|
||||
|
||||
void OS_UWP::finalize() {
|
||||
if (main_loop)
|
||||
if (main_loop) {
|
||||
memdelete(main_loop);
|
||||
}
|
||||
|
||||
main_loop = nullptr;
|
||||
|
||||
rendering_server->finish();
|
||||
memdelete(rendering_server);
|
||||
#ifdef GLES3_ENABLED
|
||||
if (gl_context)
|
||||
if (gl_context) {
|
||||
memdelete(gl_context);
|
||||
}
|
||||
#endif
|
||||
|
||||
memdelete(input);
|
||||
@ -472,8 +479,9 @@ OS::Time OS_UWP::get_time(bool p_utc) const {
|
||||
OS::TimeZoneInfo OS_UWP::get_time_zone_info() const {
|
||||
TIME_ZONE_INFORMATION info;
|
||||
bool daylight = false;
|
||||
if (GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT)
|
||||
if (GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT) {
|
||||
daylight = true;
|
||||
}
|
||||
|
||||
TimeZoneInfo ret;
|
||||
if (daylight) {
|
||||
@ -507,7 +515,7 @@ uint64_t OS_UWP::get_unix_time() const {
|
||||
SystemTimeToFileTime(&ep, &fep);
|
||||
|
||||
return (*(uint64_t *)&ft - *(uint64_t *)&fep) / 10000000;
|
||||
};
|
||||
}
|
||||
|
||||
void OS_UWP::delay_usec(uint32_t p_usec) const {
|
||||
int msec = p_usec < 1000 ? 1 : p_usec / 1000;
|
||||
@ -590,8 +598,9 @@ void OS_UWP::queue_key_event(KeyEvent &p_event) {
|
||||
void OS_UWP::set_cursor_shape(CursorShape p_shape) {
|
||||
ERR_FAIL_INDEX(p_shape, CURSOR_MAX);
|
||||
|
||||
if (cursor_shape == p_shape)
|
||||
if (cursor_shape == p_shape) {
|
||||
return;
|
||||
}
|
||||
|
||||
static const CoreCursorType uwp_cursors[CURSOR_MAX] = {
|
||||
CoreCursorType::Arrow,
|
||||
@ -628,15 +637,15 @@ void OS_UWP::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
|
||||
|
||||
Error OS_UWP::execute(const String &p_path, const List<String> &p_arguments, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex, bool p_open_console) {
|
||||
return FAILED;
|
||||
};
|
||||
}
|
||||
|
||||
Error OS_UWP::create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id, bool p_open_console) {
|
||||
return FAILED;
|
||||
};
|
||||
}
|
||||
|
||||
Error OS_UWP::kill(const ProcessID &p_pid) {
|
||||
return FAILED;
|
||||
};
|
||||
}
|
||||
|
||||
Error OS_UWP::set_cwd(const String &p_cwd) {
|
||||
return FAILED;
|
||||
@ -651,11 +660,11 @@ void OS_UWP::set_icon(const Ref<Image> &p_icon) {
|
||||
|
||||
bool OS_UWP::has_environment(const String &p_var) const {
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
String OS_UWP::get_environment(const String &p_var) const {
|
||||
return "";
|
||||
};
|
||||
}
|
||||
|
||||
bool OS_UWP::set_environment(const String &p_var, const String &p_value) const {
|
||||
return false;
|
||||
@ -751,8 +760,9 @@ Error OS_UWP::get_dynamic_library_symbol_handle(void *p_library_handle, const St
|
||||
}
|
||||
|
||||
void OS_UWP::run() {
|
||||
if (!main_loop)
|
||||
if (!main_loop) {
|
||||
return;
|
||||
}
|
||||
|
||||
main_loop->init();
|
||||
|
||||
@ -763,12 +773,14 @@ void OS_UWP::run() {
|
||||
|
||||
while (!force_quit) {
|
||||
CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
|
||||
if (managed_object->alert_close_handle)
|
||||
if (managed_object->alert_close_handle) {
|
||||
continue;
|
||||
}
|
||||
process_events(); // get rid of pending events
|
||||
if (Main::iteration())
|
||||
if (Main::iteration()) {
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
main_loop->finish();
|
||||
}
|
||||
|
@ -80,8 +80,9 @@ public:
|
||||
|
||||
std::string name() { return std::string(sym->Name); }
|
||||
std::string undecorated_name() {
|
||||
if (*sym->Name == '\0')
|
||||
if (*sym->Name == '\0') {
|
||||
return "<couldn't map PC to fn name>";
|
||||
}
|
||||
std::vector<char> und_name(max_name_len);
|
||||
UnDecorateSymbolName(sym->Name, &und_name[0], max_name_len, UNDNAME_COMPLETE);
|
||||
return std::string(&und_name[0], strlen(&und_name[0]));
|
||||
@ -131,12 +132,14 @@ DWORD CrashHandlerException(EXCEPTION_POINTERS *ep) {
|
||||
fprintf(stderr, "\n================================================================\n");
|
||||
fprintf(stderr, "%s: Program crashed\n", __FUNCTION__);
|
||||
|
||||
if (OS::get_singleton()->get_main_loop())
|
||||
if (OS::get_singleton()->get_main_loop()) {
|
||||
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_CRASH);
|
||||
}
|
||||
|
||||
// Load the symbols:
|
||||
if (!SymInitialize(process, nullptr, false))
|
||||
if (!SymInitialize(process, nullptr, false)) {
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
SymSetOptions(SymGetOptions() | SYMOPT_LOAD_LINES | SYMOPT_UNDNAME);
|
||||
EnumProcessModules(process, &module_handles[0], module_handles.size() * sizeof(HMODULE), &cbNeeded);
|
||||
@ -193,18 +196,21 @@ DWORD CrashHandlerException(EXCEPTION_POINTERS *ep) {
|
||||
if (frame.AddrPC.Offset != 0) {
|
||||
std::string fnName = symbol(process, frame.AddrPC.Offset).undecorated_name();
|
||||
|
||||
if (SymGetLineFromAddr64(process, frame.AddrPC.Offset, &offset_from_symbol, &line))
|
||||
if (SymGetLineFromAddr64(process, frame.AddrPC.Offset, &offset_from_symbol, &line)) {
|
||||
fprintf(stderr, "[%d] %s (%s:%d)\n", n, fnName.c_str(), line.FileName, line.LineNumber);
|
||||
else
|
||||
} else {
|
||||
fprintf(stderr, "[%d] %s\n", n, fnName.c_str());
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "[%d] ???\n", n);
|
||||
}
|
||||
|
||||
n++;
|
||||
}
|
||||
|
||||
if (!StackWalk64(image_type, process, hThread, &frame, context, nullptr, SymFunctionTableAccess64, SymGetModuleBase64, nullptr))
|
||||
if (!StackWalk64(image_type, process, hThread, &frame, context, nullptr, SymFunctionTableAccess64, SymGetModuleBase64, nullptr)) {
|
||||
break;
|
||||
}
|
||||
} while (frame.AddrReturn.Offset != 0 && n < 256);
|
||||
|
||||
fprintf(stderr, "-- END OF BACKTRACE --\n");
|
||||
@ -225,8 +231,9 @@ CrashHandler::~CrashHandler() {
|
||||
}
|
||||
|
||||
void CrashHandler::disable() {
|
||||
if (disabled)
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
disabled = true;
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ String DisplayServerWindows::clipboard_get() const {
|
||||
String ret;
|
||||
if (!OpenClipboard(windows[last_focused_window].hWnd)) {
|
||||
ERR_FAIL_V_MSG("", "Unable to open clipboard.");
|
||||
};
|
||||
}
|
||||
|
||||
if (IsClipboardFormatAvailable(CF_UNICODETEXT)) {
|
||||
HGLOBAL mem = GetClipboardData(CF_UNICODETEXT);
|
||||
@ -240,8 +240,8 @@ String DisplayServerWindows::clipboard_get() const {
|
||||
if (ptr != nullptr) {
|
||||
ret = String::utf16((const char16_t *)ptr);
|
||||
GlobalUnlock(mem);
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
} else if (IsClipboardFormatAvailable(CF_TEXT)) {
|
||||
HGLOBAL mem = GetClipboardData(CF_UNICODETEXT);
|
||||
@ -250,9 +250,9 @@ String DisplayServerWindows::clipboard_get() const {
|
||||
if (ptr != nullptr) {
|
||||
ret.parse_utf8((const char *)ptr);
|
||||
GlobalUnlock(mem);
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CloseClipboard();
|
||||
|
||||
@ -422,8 +422,9 @@ static int QueryDpiForMonitor(HMONITOR hmon, _MonitorDpiType dpiType = MDT_Defau
|
||||
getDPIForMonitor = Shcore ? (GetDPIForMonitor_t)GetProcAddress(Shcore, "GetDpiForMonitor") : nullptr;
|
||||
|
||||
if ((Shcore == nullptr) || (getDPIForMonitor == nullptr)) {
|
||||
if (Shcore)
|
||||
if (Shcore) {
|
||||
FreeLibrary(Shcore);
|
||||
}
|
||||
Shcore = (HMODULE)INVALID_HANDLE_VALUE;
|
||||
}
|
||||
}
|
||||
@ -1326,8 +1327,9 @@ void DisplayServerWindows::window_set_ime_position(const Point2i &p_pos, WindowI
|
||||
wd.im_position = p_pos;
|
||||
|
||||
HIMC himc = ImmGetContext(wd.hWnd);
|
||||
if (himc == (HIMC)0)
|
||||
if (himc == (HIMC)0) {
|
||||
return;
|
||||
}
|
||||
|
||||
COMPOSITIONFORM cps;
|
||||
cps.dwStyle = CFS_FORCE_POSITION;
|
||||
@ -2026,7 +2028,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
} else {
|
||||
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
WindowID window_id = INVALID_WINDOW_ID;
|
||||
bool window_created = false;
|
||||
@ -2131,9 +2133,10 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
case SC_MONITORPOWER: // Monitor trying to enter powersave?
|
||||
return 0; // Prevent from happening.
|
||||
case SC_KEYMENU:
|
||||
if ((lParam >> 16) <= 0)
|
||||
if ((lParam >> 16) <= 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case WM_CLOSE: // Did we receive a close message?
|
||||
{
|
||||
@ -2164,8 +2167,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize)
|
||||
if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize) {
|
||||
OutputDebugString(TEXT("GetRawInputData does not return correct size !\n"));
|
||||
}
|
||||
|
||||
RAWINPUT *raw = (RAWINPUT *)lpb;
|
||||
|
||||
@ -2260,8 +2264,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
ScreenToClient(windows[window_id].hWnd, &coords);
|
||||
|
||||
// Don't calculate relative mouse movement if we don't have focus in CAPTURED mode.
|
||||
if (!windows[window_id].window_has_focus && mouse_mode == MOUSE_MODE_CAPTURED)
|
||||
if (!windows[window_id].window_has_focus && mouse_mode == MOUSE_MODE_CAPTURED) {
|
||||
break;
|
||||
}
|
||||
|
||||
Ref<InputEventMouseMotion> mm;
|
||||
mm.instantiate();
|
||||
@ -2306,9 +2311,10 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
mm->set_relative(Vector2(mm->get_position() - Vector2(old_x, old_y)));
|
||||
old_x = mm->get_position().x;
|
||||
old_y = mm->get_position().y;
|
||||
if (windows[window_id].window_has_focus)
|
||||
if (windows[window_id].window_has_focus) {
|
||||
Input::get_singleton()->parse_input_event(mm);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
} break;
|
||||
@ -2547,8 +2553,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
mm->set_relative(Vector2(mm->get_position() - Vector2(old_x, old_y)));
|
||||
old_x = mm->get_position().x;
|
||||
old_y = mm->get_position().y;
|
||||
if (windows[window_id].window_has_focus)
|
||||
if (windows[window_id].window_has_focus) {
|
||||
Input::get_singleton()->parse_input_event(mm);
|
||||
}
|
||||
|
||||
} break;
|
||||
case WM_LBUTTONDOWN:
|
||||
@ -2694,8 +2701,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
if (uMsg != WM_MOUSEWHEEL && uMsg != WM_MOUSEHWHEEL) {
|
||||
if (mb->is_pressed()) {
|
||||
if (++pressrc > 0 && mouse_mode != MOUSE_MODE_CAPTURED)
|
||||
if (++pressrc > 0 && mouse_mode != MOUSE_MODE_CAPTURED) {
|
||||
SetCapture(hWnd);
|
||||
}
|
||||
} else {
|
||||
if (--pressrc <= 0) {
|
||||
if (mouse_mode != MOUSE_MODE_CAPTURED) {
|
||||
@ -2823,15 +2831,18 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
case WM_SYSKEYUP:
|
||||
case WM_KEYUP:
|
||||
case WM_KEYDOWN: {
|
||||
if (wParam == VK_SHIFT)
|
||||
if (wParam == VK_SHIFT) {
|
||||
shift_mem = (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN);
|
||||
if (wParam == VK_CONTROL)
|
||||
}
|
||||
if (wParam == VK_CONTROL) {
|
||||
control_mem = (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN);
|
||||
}
|
||||
if (wParam == VK_MENU) {
|
||||
alt_mem = (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN);
|
||||
if (lParam & (1 << 24))
|
||||
if (lParam & (1 << 24)) {
|
||||
gr_mem = alt_mem;
|
||||
}
|
||||
}
|
||||
|
||||
if (mouse_mode == MOUSE_MODE_CAPTURED) {
|
||||
// When SetCapture is used, ALT+F4 hotkey is ignored by Windows, so handle it ourselves
|
||||
@ -2839,10 +2850,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
_send_window_event(windows[window_id], WINDOW_EVENT_CLOSE_REQUEST);
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (wParam==VK_WIN) TODO wtf is this?
|
||||
meta_mem=uMsg==WM_KEYDOWN;
|
||||
*/
|
||||
[[fallthrough]];
|
||||
}
|
||||
case WM_CHAR: {
|
||||
@ -2857,10 +2864,12 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
ke.uMsg = uMsg;
|
||||
ke.window_id = window_id;
|
||||
|
||||
if (ke.uMsg == WM_SYSKEYDOWN)
|
||||
if (ke.uMsg == WM_SYSKEYDOWN) {
|
||||
ke.uMsg = WM_KEYDOWN;
|
||||
if (ke.uMsg == WM_SYSKEYUP)
|
||||
}
|
||||
if (ke.uMsg == WM_SYSKEYUP) {
|
||||
ke.uMsg = WM_KEYUP;
|
||||
}
|
||||
|
||||
ke.wParam = wParam;
|
||||
ke.lParam = lParam;
|
||||
@ -2888,7 +2897,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
_drag_event(window_id, touch_pos.x, touch_pos.y, ti.dwID);
|
||||
} else if (ti.dwFlags & (TOUCHEVENTF_UP | TOUCHEVENTF_DOWN)) {
|
||||
_touch_event(window_id, ti.dwFlags & TOUCHEVENTF_DOWN, touch_pos.x, touch_pos.y, ti.dwID);
|
||||
};
|
||||
}
|
||||
}
|
||||
bHandled = TRUE;
|
||||
} else {
|
||||
@ -2901,7 +2910,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
if (bHandled) {
|
||||
CloseTouchInputHandle((HTOUCHINPUT)lParam);
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
} break;
|
||||
case WM_DEVICECHANGE: {
|
||||
@ -2955,8 +2964,8 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
default: {
|
||||
if (user_proc) {
|
||||
return CallWindowProcW(user_proc, hWnd, uMsg, wParam, lParam);
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
||||
@ -2964,10 +2973,11 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
DisplayServerWindows *ds_win = static_cast<DisplayServerWindows *>(DisplayServer::get_singleton());
|
||||
if (ds_win)
|
||||
if (ds_win) {
|
||||
return ds_win->WndProc(hWnd, uMsg, wParam, lParam);
|
||||
else
|
||||
} else {
|
||||
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayServerWindows::_process_activate_event(WindowID p_window_id, WPARAM wParam, LPARAM lParam) {
|
||||
@ -3034,8 +3044,9 @@ void DisplayServerWindows::_process_key_events() {
|
||||
k->set_ctrl_pressed(false);
|
||||
}
|
||||
|
||||
if (k->get_unicode() < 32)
|
||||
if (k->get_unicode() < 32) {
|
||||
k->set_unicode(0);
|
||||
}
|
||||
|
||||
Input::get_singleton()->parse_input_event(k);
|
||||
} else {
|
||||
@ -3090,8 +3101,9 @@ void DisplayServerWindows::_process_key_events() {
|
||||
k->set_ctrl_pressed(false);
|
||||
}
|
||||
|
||||
if (k->get_unicode() < 32)
|
||||
if (k->get_unicode() < 32) {
|
||||
k->set_unicode(0);
|
||||
}
|
||||
|
||||
k->set_echo((ke.uMsg == WM_KEYDOWN && (ke.lParam & (1 << 30))));
|
||||
|
||||
@ -3395,7 +3407,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = hInstance ? hInstance : GetModuleHandle(nullptr);
|
||||
wc.hIcon = LoadIcon(nullptr, IDI_WINLOGO);
|
||||
wc.hCursor = nullptr; //LoadCursor(nullptr, IDC_ARROW);
|
||||
wc.hCursor = nullptr;
|
||||
wc.hbrBackground = nullptr;
|
||||
wc.lpszMenuName = nullptr;
|
||||
wc.lpszClassName = L"Engine";
|
||||
@ -3446,7 +3458,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
|
||||
return;
|
||||
}
|
||||
|
||||
// gl_manager->set_use_vsync(current_videomode.use_vsync);
|
||||
//gl_manager->set_use_vsync(current_videomode.use_vsync);
|
||||
RasterizerGLES3::make_current();
|
||||
}
|
||||
#endif
|
||||
@ -3476,14 +3488,13 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
|
||||
}
|
||||
#endif
|
||||
|
||||
//set_ime_active(false);
|
||||
|
||||
if (!OS::get_singleton()->is_in_low_processor_usage_mode()) {
|
||||
SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);
|
||||
DWORD index = 0;
|
||||
HANDLE handle = AvSetMmThreadCharacteristics("Games", &index);
|
||||
if (handle)
|
||||
if (handle) {
|
||||
AvSetMmThreadPriority(handle, AVRT_PRIORITY_CRITICAL);
|
||||
}
|
||||
|
||||
// This is needed to make sure that background work does not starve the main thread.
|
||||
// This is only setting the priority of this thread, not the whole process.
|
||||
@ -3537,7 +3548,7 @@ DisplayServerWindows::~DisplayServerWindows() {
|
||||
|
||||
if (user_proc) {
|
||||
SetWindowLongPtr(windows[MAIN_WINDOW_ID].hWnd, GWLP_WNDPROC, (LONG_PTR)user_proc);
|
||||
};
|
||||
}
|
||||
|
||||
#ifdef GLES3_ENABLED
|
||||
// destroy windows .. NYI?
|
||||
|
@ -56,14 +56,9 @@ typedef HGLRC(APIENTRY *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC, HGLRC, const int
|
||||
|
||||
int GLManager_Windows::_find_or_create_display(GLWindow &win) {
|
||||
// find display NYI, only 1 supported so far
|
||||
if (_displays.size())
|
||||
if (_displays.size()) {
|
||||
return 0;
|
||||
|
||||
// for (unsigned int n = 0; n < _displays.size(); n++) {
|
||||
// const GLDisplay &d = _displays[n];
|
||||
// if (d.x11_display == p_x11_display)
|
||||
// return n;
|
||||
// }
|
||||
}
|
||||
|
||||
// create
|
||||
GLDisplay d_temp = {};
|
||||
@ -230,23 +225,27 @@ void GLManager_Windows::window_destroy(DisplayServer::WindowID p_window_id) {
|
||||
}
|
||||
|
||||
void GLManager_Windows::release_current() {
|
||||
if (!_current_window)
|
||||
if (!_current_window) {
|
||||
return;
|
||||
}
|
||||
|
||||
wglMakeCurrent(_current_window->hDC, nullptr);
|
||||
}
|
||||
|
||||
void GLManager_Windows::window_make_current(DisplayServer::WindowID p_window_id) {
|
||||
if (p_window_id == -1)
|
||||
if (p_window_id == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
GLWindow &win = _windows[p_window_id];
|
||||
if (!win.in_use)
|
||||
if (!win.in_use) {
|
||||
return;
|
||||
}
|
||||
|
||||
// noop
|
||||
if (&win == _current_window)
|
||||
if (&win == _current_window) {
|
||||
return;
|
||||
}
|
||||
|
||||
const GLDisplay &disp = get_display(win.gldisplay_id);
|
||||
wglMakeCurrent(win.hDC, disp.hRC);
|
||||
@ -255,8 +254,9 @@ void GLManager_Windows::window_make_current(DisplayServer::WindowID p_window_id)
|
||||
}
|
||||
|
||||
void GLManager_Windows::make_current() {
|
||||
if (!_current_window)
|
||||
if (!_current_window) {
|
||||
return;
|
||||
}
|
||||
if (!_current_window->in_use) {
|
||||
WARN_PRINT("current window not in use!");
|
||||
return;
|
||||
@ -269,8 +269,9 @@ void GLManager_Windows::swap_buffers() {
|
||||
// NO NEED TO CALL SWAP BUFFERS for each window...
|
||||
// see https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glXSwapBuffers.xml
|
||||
|
||||
if (!_current_window)
|
||||
if (!_current_window) {
|
||||
return;
|
||||
}
|
||||
if (!_current_window->in_use) {
|
||||
WARN_PRINT("current window not in use!");
|
||||
return;
|
||||
@ -304,13 +305,16 @@ void GLManager_Windows::set_use_vsync(bool p_use) {
|
||||
if (!setup) {
|
||||
setup = true;
|
||||
String extensions = glXQueryExtensionsString(x11_display, DefaultScreen(x11_display));
|
||||
if (extensions.find("GLX_EXT_swap_control") != -1)
|
||||
if (extensions.find("GLX_EXT_swap_control") != -1) {
|
||||
glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddressARB((const GLubyte *)"glXSwapIntervalEXT");
|
||||
if (extensions.find("GLX_MESA_swap_control") != -1)
|
||||
}
|
||||
if (extensions.find("GLX_MESA_swap_control") != -1) {
|
||||
glXSwapIntervalMESA = (PFNGLXSWAPINTERVALSGIPROC)glXGetProcAddressARB((const GLubyte *)"glXSwapIntervalMESA");
|
||||
if (extensions.find("GLX_SGI_swap_control") != -1)
|
||||
}
|
||||
if (extensions.find("GLX_SGI_swap_control") != -1) {
|
||||
glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)glXGetProcAddressARB((const GLubyte *)"glXSwapIntervalSGI");
|
||||
}
|
||||
}
|
||||
int val = p_use ? 1 : 0;
|
||||
if (glXSwapIntervalMESA) {
|
||||
glXSwapIntervalMESA(val);
|
||||
@ -319,8 +323,9 @@ void GLManager_Windows::set_use_vsync(bool p_use) {
|
||||
} else if (glXSwapIntervalEXT) {
|
||||
GLXDrawable drawable = glXGetCurrentDrawable();
|
||||
glXSwapIntervalEXT(x11_display, drawable, val);
|
||||
} else
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
use_vsync = p_use;
|
||||
*/
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user