mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-07 00:25:54 +01:00
More version check cleanups.
This commit is contained in:
parent
32acbf4252
commit
1f0652741c
@ -115,11 +115,7 @@ Dictionary SpeciesInstance::_to_dict() {
|
|||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
void SpeciesInstance::_from_dict(const Dictionary &dict) {
|
void SpeciesInstance::_from_dict(const Dictionary &dict) {
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
ERR_FAIL_COND(dict.is_empty());
|
|
||||||
#else
|
|
||||||
ERR_FAIL_COND(dict.empty());
|
ERR_FAIL_COND(dict.empty());
|
||||||
#endif
|
|
||||||
|
|
||||||
_id = dict.get("id", 0);
|
_id = dict.get("id", 0);
|
||||||
set_species_path(dict.get("species_path", ""));
|
set_species_path(dict.get("species_path", ""));
|
||||||
|
@ -124,7 +124,6 @@ void ESSResourceDBFolders::add_resource(const Ref<Resource> &resource) {
|
|||||||
Ref<Resource> ESSResourceDBFolders::load_resource(const String &path, const String &type_hint) {
|
Ref<Resource> ESSResourceDBFolders::load_resource(const String &path, const String &type_hint) {
|
||||||
_ResourceLoader *rl = _ResourceLoader::get_singleton();
|
_ResourceLoader *rl = _ResourceLoader::get_singleton();
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
Ref<ResourceInteractiveLoader> resl = rl->load_interactive(path, type_hint);
|
Ref<ResourceInteractiveLoader> resl = rl->load_interactive(path, type_hint);
|
||||||
|
|
||||||
ERR_FAIL_COND_V(!resl.is_valid(), Ref<Resource>());
|
ERR_FAIL_COND_V(!resl.is_valid(), Ref<Resource>());
|
||||||
@ -132,9 +131,6 @@ Ref<Resource> ESSResourceDBFolders::load_resource(const String &path, const Stri
|
|||||||
resl->wait();
|
resl->wait();
|
||||||
|
|
||||||
return resl->get_resource();
|
return resl->get_resource();
|
||||||
#else
|
|
||||||
return rl->load(path, type_hint);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ESSResourceDBFolders::ESSResourceDBFolders() {
|
ESSResourceDBFolders::ESSResourceDBFolders() {
|
||||||
|
@ -30,11 +30,7 @@ void ESSEditorPlugin::fix_ids(Variant param) {
|
|||||||
ESSEditorPlugin::ESSEditorPlugin(EditorNode *p_node) {
|
ESSEditorPlugin::ESSEditorPlugin(EditorNode *p_node) {
|
||||||
editor = p_node;
|
editor = p_node;
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
//editor->add_tool_menu_item("ESS: make ids unique", this, "fix_ids");
|
|
||||||
#else
|
|
||||||
editor->add_tool_menu_item("ESS: make ids unique", this, "fix_ids");
|
editor->add_tool_menu_item("ESS: make ids unique", this, "fix_ids");
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ESSEditorPlugin::~ESSEditorPlugin() {
|
ESSEditorPlugin::~ESSEditorPlugin() {
|
||||||
|
@ -39,11 +39,7 @@ Dictionary EntityDataContainer::_to_dict() {
|
|||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
void EntityDataContainer::_from_dict(const Dictionary &dict) {
|
void EntityDataContainer::_from_dict(const Dictionary &dict) {
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
ERR_FAIL_COND(dict.is_empty());
|
|
||||||
#else
|
|
||||||
ERR_FAIL_COND(dict.empty());
|
ERR_FAIL_COND(dict.empty());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityDataContainer::EntityDataContainer() {
|
EntityDataContainer::EntityDataContainer() {
|
||||||
|
@ -286,11 +286,7 @@ Dictionary EntityResource::_to_dict() {
|
|||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
void EntityResource::_from_dict(const Dictionary &dict) {
|
void EntityResource::_from_dict(const Dictionary &dict) {
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
ERR_FAIL_COND(dict.is_empty());
|
|
||||||
#else
|
|
||||||
ERR_FAIL_COND(dict.empty());
|
ERR_FAIL_COND(dict.empty());
|
||||||
#endif
|
|
||||||
|
|
||||||
_dirty = dict.get("dirty", false);
|
_dirty = dict.get("dirty", false);
|
||||||
_should_process = dict.get("should_process", false);
|
_should_process = dict.get("should_process", false);
|
||||||
|
@ -205,11 +205,7 @@ Dictionary SpellCastInfo::to_dict() {
|
|||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
void SpellCastInfo::from_dict(const Dictionary &dict) {
|
void SpellCastInfo::from_dict(const Dictionary &dict) {
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
ERR_FAIL_COND(dict.is_empty());
|
|
||||||
#else
|
|
||||||
ERR_FAIL_COND(dict.empty());
|
ERR_FAIL_COND(dict.empty());
|
||||||
#endif
|
|
||||||
|
|
||||||
_has_cast_time = dict.get("has_cast_time", true);
|
_has_cast_time = dict.get("has_cast_time", true);
|
||||||
_cast_time = dict.get("cast_time", 0);
|
_cast_time = dict.get("cast_time", 0);
|
||||||
|
@ -201,11 +201,7 @@ Dictionary SpellDamageInfo::to_dict() {
|
|||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
void SpellDamageInfo::from_dict(const Dictionary &dict) {
|
void SpellDamageInfo::from_dict(const Dictionary &dict) {
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
ERR_FAIL_COND(dict.is_empty());
|
|
||||||
#else
|
|
||||||
ERR_FAIL_COND(dict.empty());
|
ERR_FAIL_COND(dict.empty());
|
||||||
#endif
|
|
||||||
|
|
||||||
_immune = dict.get("immune", true);
|
_immune = dict.get("immune", true);
|
||||||
_damage = dict.get("damage", 0);
|
_damage = dict.get("damage", 0);
|
||||||
|
@ -202,11 +202,7 @@ Dictionary SpellHealInfo::to_dict() {
|
|||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
void SpellHealInfo::from_dict(const Dictionary &dict) {
|
void SpellHealInfo::from_dict(const Dictionary &dict) {
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
ERR_FAIL_COND(dict.is_empty());
|
|
||||||
#else
|
|
||||||
ERR_FAIL_COND(dict.empty());
|
ERR_FAIL_COND(dict.empty());
|
||||||
#endif
|
|
||||||
|
|
||||||
_immune = dict.get("immune", true);
|
_immune = dict.get("immune", true);
|
||||||
_heal = dict.get("heal", 0);
|
_heal = dict.get("heal", 0);
|
||||||
@ -237,7 +233,6 @@ SpellHealInfo::~SpellHealInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpellHealInfo::_bind_methods() {
|
void SpellHealInfo::_bind_methods() {
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_immune"), &SpellHealInfo::get_immune);
|
ClassDB::bind_method(D_METHOD("get_immune"), &SpellHealInfo::get_immune);
|
||||||
ClassDB::bind_method(D_METHOD("set_immune", "value"), &SpellHealInfo::set_immune);
|
ClassDB::bind_method(D_METHOD("set_immune", "value"), &SpellHealInfo::set_immune);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "immune"), "set_immune", "get_immune");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "immune"), "set_immune", "get_immune");
|
||||||
|
@ -93,11 +93,7 @@ Dictionary ActionBarButtonEntry::to_dict() const {
|
|||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
void ActionBarButtonEntry::from_dict(const Dictionary &dict) {
|
void ActionBarButtonEntry::from_dict(const Dictionary &dict) {
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
ERR_FAIL_COND(dict.is_empty());
|
|
||||||
#else
|
|
||||||
ERR_FAIL_COND(dict.empty());
|
ERR_FAIL_COND(dict.empty());
|
||||||
#endif
|
|
||||||
|
|
||||||
_action_bar_id = dict.get("action_bar_id", 0);
|
_action_bar_id = dict.get("action_bar_id", 0);
|
||||||
_slot_id = dict.get("slot_id", 0);
|
_slot_id = dict.get("slot_id", 0);
|
||||||
|
@ -117,11 +117,7 @@ Dictionary ActionBarEntry::to_dict() const {
|
|||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
void ActionBarEntry::from_dict(const Dictionary &dict) {
|
void ActionBarEntry::from_dict(const Dictionary &dict) {
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
ERR_FAIL_COND(dict.is_empty());
|
|
||||||
#else
|
|
||||||
ERR_FAIL_COND(dict.empty());
|
ERR_FAIL_COND(dict.empty());
|
||||||
#endif
|
|
||||||
|
|
||||||
for (int i = 0; i < _button_entries.size(); ++i) {
|
for (int i = 0; i < _button_entries.size(); ++i) {
|
||||||
_button_entries.get(i)->set_owner(NULL);
|
_button_entries.get(i)->set_owner(NULL);
|
||||||
|
@ -134,13 +134,8 @@ Dictionary ActionBarProfile::to_dict() const {
|
|||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
void ActionBarProfile::from_dict(const Dictionary &dict) {
|
void ActionBarProfile::from_dict(const Dictionary &dict) {
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
if (dict.is_empty())
|
|
||||||
return;
|
|
||||||
#else
|
|
||||||
if (dict.empty())
|
if (dict.empty())
|
||||||
return;
|
return;
|
||||||
#endif
|
|
||||||
|
|
||||||
for (int i = 0; i < _action_bars.size(); ++i) {
|
for (int i = 0; i < _action_bars.size(); ++i) {
|
||||||
_action_bars.get(i)->set_owner(NULL);
|
_action_bars.get(i)->set_owner(NULL);
|
||||||
|
@ -127,11 +127,7 @@ Dictionary ClassProfile::to_dict() const {
|
|||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
void ClassProfile::from_dict(const Dictionary &dict) {
|
void ClassProfile::from_dict(const Dictionary &dict) {
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
ERR_FAIL_COND(dict.is_empty());
|
|
||||||
#else
|
|
||||||
ERR_FAIL_COND(dict.empty());
|
ERR_FAIL_COND(dict.empty());
|
||||||
#endif
|
|
||||||
|
|
||||||
_character_class_name = dict.get("character_class_name", "");
|
_character_class_name = dict.get("character_class_name", "");
|
||||||
_class_path = dict.get("class_path", "");
|
_class_path = dict.get("class_path", "");
|
||||||
|
@ -146,11 +146,7 @@ Dictionary PlayerProfile::to_dict() const {
|
|||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
void PlayerProfile::from_dict(const Dictionary &dict) {
|
void PlayerProfile::from_dict(const Dictionary &dict) {
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
ERR_FAIL_COND(dict.is_empty());
|
|
||||||
#else
|
|
||||||
ERR_FAIL_COND(dict.empty());
|
ERR_FAIL_COND(dict.empty());
|
||||||
#endif
|
|
||||||
|
|
||||||
clear_class_profiles();
|
clear_class_profiles();
|
||||||
|
|
||||||
|
@ -663,7 +663,6 @@ void ESS::material_cache_unref(const uint64_t key) {
|
|||||||
Ref<Resource> ESS::load_resource(const String &path, const String &type_hint) {
|
Ref<Resource> ESS::load_resource(const String &path, const String &type_hint) {
|
||||||
_ResourceLoader *rl = _ResourceLoader::get_singleton();
|
_ResourceLoader *rl = _ResourceLoader::get_singleton();
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
Ref<ResourceInteractiveLoader> resl = rl->load_interactive(path, type_hint);
|
Ref<ResourceInteractiveLoader> resl = rl->load_interactive(path, type_hint);
|
||||||
|
|
||||||
ERR_FAIL_COND_V(!resl.is_valid(), Ref<Resource>());
|
ERR_FAIL_COND_V(!resl.is_valid(), Ref<Resource>());
|
||||||
@ -671,9 +670,6 @@ Ref<Resource> ESS::load_resource(const String &path, const String &type_hint) {
|
|||||||
resl->wait();
|
resl->wait();
|
||||||
|
|
||||||
return resl->get_resource();
|
return resl->get_resource();
|
||||||
#else
|
|
||||||
return rl->load(path, type_hint);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ESS::_bind_methods() {
|
void ESS::_bind_methods() {
|
||||||
@ -910,11 +906,7 @@ ESS::ESS() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TEXTURE_PACKER_PRESENT
|
#ifdef TEXTURE_PACKER_PRESENT
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
_texture_flags = GLOBAL_DEF("ess/material_cache/texture_flags", Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER);
|
_texture_flags = GLOBAL_DEF("ess/material_cache/texture_flags", Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER);
|
||||||
#else
|
|
||||||
_texture_flags = GLOBAL_DEF("ess/material_cache/texture_flags", 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_max_atlas_size = GLOBAL_DEF("ess/material_cache/max_atlas_size", 1024);
|
_max_atlas_size = GLOBAL_DEF("ess/material_cache/max_atlas_size", 1024);
|
||||||
_keep_original_atlases = GLOBAL_DEF("ess/material_cache/keep_original_atlases", false);
|
_keep_original_atlases = GLOBAL_DEF("ess/material_cache/keep_original_atlases", false);
|
||||||
|
@ -165,11 +165,7 @@ Dictionary ProfileManager::to_dict() const {
|
|||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
void ProfileManager::from_dict(const Dictionary &dict) {
|
void ProfileManager::from_dict(const Dictionary &dict) {
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
ERR_FAIL_COND(dict.is_empty());
|
|
||||||
#else
|
|
||||||
ERR_FAIL_COND(dict.empty());
|
ERR_FAIL_COND(dict.empty());
|
||||||
#endif
|
|
||||||
|
|
||||||
clears_player_profiles();
|
clears_player_profiles();
|
||||||
|
|
||||||
|
@ -190,11 +190,7 @@ Dictionary EntityCreateInfo::_to_dict() {
|
|||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
void EntityCreateInfo::_from_dict(const Dictionary &dict) {
|
void EntityCreateInfo::_from_dict(const Dictionary &dict) {
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
ERR_FAIL_COND(dict.is_empty());
|
|
||||||
#else
|
|
||||||
ERR_FAIL_COND(dict.empty());
|
ERR_FAIL_COND(dict.empty());
|
||||||
#endif
|
|
||||||
|
|
||||||
_guid = dict.get("guid", 0);
|
_guid = dict.get("guid", 0);
|
||||||
_networked = dict.get("networked", false);
|
_networked = dict.get("networked", false);
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
#include "fastnoise_noise_params.h"
|
#include "fastnoise_noise_params.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
|
||||||
|
|
||||||
#if VERSION_MAJOR >= 4
|
|
||||||
#define REAL FLOAT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void FastnoiseNoiseParams::setup_noise(Ref<FastNoise> noise) {
|
void FastnoiseNoiseParams::setup_noise(Ref<FastNoise> noise) {
|
||||||
noise->set_seed(_seed);
|
noise->set_seed(_seed);
|
||||||
noise->set_noise_type(_noise_type);
|
noise->set_noise_type(_noise_type);
|
||||||
|
@ -1,13 +1,7 @@
|
|||||||
#ifndef FASTNOISE_NOISE_PARAMS_H
|
#ifndef FASTNOISE_NOISE_PARAMS_H
|
||||||
#define FASTNOISE_NOISE_PARAMS_H
|
#define FASTNOISE_NOISE_PARAMS_H
|
||||||
|
|
||||||
#include "core/version.h"
|
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
#include "core/io/resource.h"
|
|
||||||
#else
|
|
||||||
#include "core/resource.h"
|
#include "core/resource.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "noise.h"
|
#include "noise.h"
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,25 +1,12 @@
|
|||||||
#ifndef FASTNOISE_NOISE_H
|
#ifndef FASTNOISE_NOISE_H
|
||||||
#define FASTNOISE_NOISE_H
|
#define FASTNOISE_NOISE_H
|
||||||
|
|
||||||
#include "core/version.h"
|
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
#include "core/object/reference.h"
|
|
||||||
#include "core/string/ustring.h"
|
|
||||||
#else
|
|
||||||
#include "core/reference.h"
|
#include "core/reference.h"
|
||||||
#include "core/ustring.h"
|
#include "core/ustring.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "lib/FastNoise.h"
|
#include "lib/FastNoise.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
#include "core/pool_vector.h"
|
#include "core/pool_vector.h"
|
||||||
#else
|
|
||||||
typedef PackedInt64Array PoolIntArray;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef fastnoise::FastNoise _FastNoise;
|
typedef fastnoise::FastNoise _FastNoise;
|
||||||
|
|
||||||
@ -155,14 +142,12 @@ public:
|
|||||||
float get_noise_2dv(Vector2 pos) { return _noise.GetNoise(pos.x, pos.y); }
|
float get_noise_2dv(Vector2 pos) { return _noise.GetNoise(pos.x, pos.y); }
|
||||||
float get_noise_3dv(Vector3 pos) { return _noise.GetNoise(pos.x, pos.y, pos.z); }
|
float get_noise_3dv(Vector3 pos) { return _noise.GetNoise(pos.x, pos.y, pos.z); }
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
_FastNoise _noise;
|
_FastNoise _noise;
|
||||||
Ref<FastNoise> _cellular_lookup_ref;
|
Ref<FastNoise> _cellular_lookup_ref;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Make Variant happy with custom enums
|
// Make Variant happy with custom enums
|
||||||
@ -172,6 +157,4 @@ VARIANT_ENUM_CAST(FastNoise::Interpolation)
|
|||||||
VARIANT_ENUM_CAST(FastNoise::CellularDistanceFunction)
|
VARIANT_ENUM_CAST(FastNoise::CellularDistanceFunction)
|
||||||
VARIANT_ENUM_CAST(FastNoise::CellularReturnType)
|
VARIANT_ENUM_CAST(FastNoise::CellularReturnType)
|
||||||
|
|
||||||
|
|
||||||
#endif // FASTNOISE_NOISE_H
|
#endif // FASTNOISE_NOISE_H
|
||||||
|
|
||||||
|
@ -2,25 +2,15 @@
|
|||||||
|
|
||||||
#include "core/version.h"
|
#include "core/version.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
#include "core/class_db.h"
|
#include "core/class_db.h"
|
||||||
#else
|
|
||||||
#include "core/object/class_db.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "noise.h"
|
|
||||||
#include "fastnoise_noise_params.h"
|
#include "fastnoise_noise_params.h"
|
||||||
|
#include "noise.h"
|
||||||
|
|
||||||
void register_fastnoise_types() {
|
void register_fastnoise_types() {
|
||||||
|
|
||||||
ClassDB::register_class<FastNoise>();
|
ClassDB::register_class<FastNoise>();
|
||||||
ClassDB::register_class<FastnoiseNoiseParams>();
|
ClassDB::register_class<FastnoiseNoiseParams>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void unregister_fastnoise_types() {
|
void unregister_fastnoise_types() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,16 +22,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "mesh_data_resource.h"
|
#include "mesh_data_resource.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
|
||||||
|
|
||||||
#if VERSION_MAJOR >= 4
|
|
||||||
#include "core/variant/variant.h"
|
|
||||||
|
|
||||||
#define PoolVector Vector
|
|
||||||
#define POOL_INT_ARRAY PACKED_INT_ARRAY
|
|
||||||
#else
|
|
||||||
#include "core/variant.h"
|
#include "core/variant.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
const String MeshDataResource::BINDING_STRING_COLLIDER_TYPE = "None,Trimesh Collision Shape,Single Convex Collision Shape,Multiple Convex Collision Shapes,Approximated Box,Approximated Capsule,Approximated Cylinder,Approximated Sphere";
|
const String MeshDataResource::BINDING_STRING_COLLIDER_TYPE = "None,Trimesh Collision Shape,Single Convex Collision Shape,Multiple Convex Collision Shapes,Approximated Box,Approximated Capsule,Approximated Cylinder,Approximated Sphere";
|
||||||
|
|
||||||
@ -85,13 +76,8 @@ int MeshDataResource::get_collision_shape_count() const {
|
|||||||
Vector<Variant> MeshDataResource::get_collision_shapes() {
|
Vector<Variant> MeshDataResource::get_collision_shapes() {
|
||||||
Vector<Variant> r;
|
Vector<Variant> r;
|
||||||
for (int i = 0; i < _collision_shapes.size(); i++) {
|
for (int i = 0; i < _collision_shapes.size(); i++) {
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
r.push_back(_collision_shapes[i].transform);
|
r.push_back(_collision_shapes[i].transform);
|
||||||
r.push_back(_collision_shapes[i].shape.get_ref_ptr());
|
r.push_back(_collision_shapes[i].shape.get_ref_ptr());
|
||||||
#else
|
|
||||||
r.push_back(_collision_shapes[i].transform);
|
|
||||||
r.push_back(_collision_shapes[i].shape);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -296,12 +282,9 @@ void MeshDataResource::recompute_aabb() {
|
|||||||
if (vertices_2d.size() > 0) {
|
if (vertices_2d.size() > 0) {
|
||||||
AABB aabb;
|
AABB aabb;
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
PoolVector<Vector2>::Read r = vertices_2d.read();
|
PoolVector<Vector2>::Read r = vertices_2d.read();
|
||||||
const Vector2 *vtx = r.ptr();
|
const Vector2 *vtx = r.ptr();
|
||||||
#else
|
|
||||||
const Vector2 *vtx = vertices.ptr();
|
|
||||||
#endif
|
|
||||||
int len = vertices_2d.size();
|
int len = vertices_2d.size();
|
||||||
aabb.position = Vector3(vtx[0].x, vtx[0].y, 0);
|
aabb.position = Vector3(vtx[0].x, vtx[0].y, 0);
|
||||||
|
|
||||||
@ -320,12 +303,8 @@ void MeshDataResource::recompute_aabb() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
PoolVector<Vector3>::Read r = vertices.read();
|
PoolVector<Vector3>::Read r = vertices.read();
|
||||||
const Vector3 *vtx = r.ptr();
|
const Vector3 *vtx = r.ptr();
|
||||||
#else
|
|
||||||
const Vector3 *vtx = vertices.ptr();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
AABB aabb;
|
AABB aabb;
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
|
@ -22,39 +22,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "core/version.h"
|
|
||||||
|
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
#include "core/io/resource.h"
|
|
||||||
#include "core/variant/array.h"
|
|
||||||
#include "core/variant/variant.h"
|
|
||||||
|
|
||||||
#include "core/math/transform_3d.h"
|
|
||||||
typedef class Transform3D Transform;
|
|
||||||
|
|
||||||
#define PoolIntArray PackedInt64Array
|
|
||||||
|
|
||||||
#else
|
|
||||||
#include "core/resource.h"
|
|
||||||
#include "core/array.h"
|
#include "core/array.h"
|
||||||
#include "core/variant.h"
|
|
||||||
#include "core/pool_vector.h"
|
#include "core/pool_vector.h"
|
||||||
#endif
|
#include "core/resource.h"
|
||||||
|
#include "core/variant.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "core/version.h"
|
||||||
#include "scene/resources/mesh.h"
|
#include "scene/resources/mesh.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
#include "scene/resources/shape.h"
|
#include "scene/resources/shape.h"
|
||||||
#else
|
|
||||||
#include "scene/resources/shape_3d.h"
|
|
||||||
|
|
||||||
#define Shape Shape3D
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class MeshDataResource : public Resource {
|
class MeshDataResource : public Resource {
|
||||||
GDCLASS(MeshDataResource, Resource);
|
GDCLASS(MeshDataResource, Resource);
|
||||||
|
@ -31,11 +31,7 @@ void MeshDataResourceCollection::add_mdr(Ref<MeshDataResource> mdr) {
|
|||||||
Vector<Variant> MeshDataResourceCollection::get_mdrs() {
|
Vector<Variant> MeshDataResourceCollection::get_mdrs() {
|
||||||
Vector<Variant> r;
|
Vector<Variant> r;
|
||||||
for (int i = 0; i < _mdrs.size(); i++) {
|
for (int i = 0; i < _mdrs.size(); i++) {
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
r.push_back(_mdrs[i].get_ref_ptr());
|
r.push_back(_mdrs[i].get_ref_ptr());
|
||||||
#else
|
|
||||||
r.push_back(_mdrs[i]);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -22,18 +22,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "core/version.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
#include "core/io/resource.h"
|
|
||||||
#include "core/templates/vector.h"
|
|
||||||
#else
|
|
||||||
#include "core/resource.h"
|
#include "core/resource.h"
|
||||||
#include "core/vector.h"
|
#include "core/vector.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "mesh_data_resource.h"
|
#include "mesh_data_resource.h"
|
||||||
|
|
||||||
|
@ -5,15 +5,9 @@
|
|||||||
#include "core/version.h"
|
#include "core/version.h"
|
||||||
#include "scene/resources/texture.h"
|
#include "scene/resources/texture.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
#include "core/image.h"
|
#include "core/image.h"
|
||||||
|
|
||||||
#define GET_WORLD get_world
|
#define GET_WORLD get_world
|
||||||
#else
|
|
||||||
#include "core/io/image.h"
|
|
||||||
|
|
||||||
#define GET_WORLD get_world_3d
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if TEXTURE_PACKER_PRESENT
|
#if TEXTURE_PACKER_PRESENT
|
||||||
#include "../../texture_packer/texture_resource/packer_image_resource.h"
|
#include "../../texture_packer/texture_resource/packer_image_resource.h"
|
||||||
@ -184,11 +178,7 @@ void MeshDataInstance::setup_material_texture() {
|
|||||||
|
|
||||||
Ref<ImageTexture> tex;
|
Ref<ImageTexture> tex;
|
||||||
tex.instance();
|
tex.instance();
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
tex->create_from_image(i, 0);
|
tex->create_from_image(i, 0);
|
||||||
#else
|
|
||||||
tex->create_from_image(i);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (sm.is_valid()) {
|
if (sm.is_valid()) {
|
||||||
sm->set_texture(SpatialMaterial::TEXTURE_ALBEDO, tex);
|
sm->set_texture(SpatialMaterial::TEXTURE_ALBEDO, tex);
|
||||||
@ -214,9 +204,7 @@ MeshDataInstance::MeshDataInstance() {
|
|||||||
_snap_to_mesh = false;
|
_snap_to_mesh = false;
|
||||||
_snap_axis = Vector3(0, -1, 0);
|
_snap_axis = Vector3(0, -1, 0);
|
||||||
|
|
||||||
#if VERSION_MINOR >= 4
|
|
||||||
set_portal_mode(PORTAL_MODE_GLOBAL);
|
set_portal_mode(PORTAL_MODE_GLOBAL);
|
||||||
#endif
|
|
||||||
|
|
||||||
//set_notify_transform(true);
|
//set_notify_transform(true);
|
||||||
}
|
}
|
||||||
|
@ -22,21 +22,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "core/version.h"
|
||||||
#include "scene/resources/texture.h"
|
#include "scene/resources/texture.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
#include "scene/3d/visual_instance.h"
|
#include "scene/3d/visual_instance.h"
|
||||||
#else
|
|
||||||
#include "scene/3d/node_3d.h"
|
|
||||||
|
|
||||||
#define SpatialMaterial StandardMaterial3D
|
|
||||||
#define Spatial Node3D
|
|
||||||
#define Texture Texture2D
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "core/math/vector3.h"
|
#include "core/math/vector3.h"
|
||||||
|
|
||||||
|
@ -5,11 +5,7 @@
|
|||||||
#include "core/version.h"
|
#include "core/version.h"
|
||||||
#include "scene/resources/texture.h"
|
#include "scene/resources/texture.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
#include "core/image.h"
|
#include "core/image.h"
|
||||||
#else
|
|
||||||
#include "core/io/image.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if TEXTURE_PACKER_PRESENT
|
#if TEXTURE_PACKER_PRESENT
|
||||||
#include "../../texture_packer/texture_resource/packer_image_resource.h"
|
#include "../../texture_packer/texture_resource/packer_image_resource.h"
|
||||||
|
@ -22,10 +22,6 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "mdr_import_plugin_base.h"
|
#include "mdr_import_plugin_base.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
|
|
||||||
#include "scene/resources/box_shape.h"
|
#include "scene/resources/box_shape.h"
|
||||||
#include "scene/resources/capsule_shape.h"
|
#include "scene/resources/capsule_shape.h"
|
||||||
#include "scene/resources/concave_polygon_shape.h"
|
#include "scene/resources/concave_polygon_shape.h"
|
||||||
@ -34,41 +30,6 @@ SOFTWARE.
|
|||||||
#include "scene/resources/shape.h"
|
#include "scene/resources/shape.h"
|
||||||
#include "scene/resources/sphere_shape.h"
|
#include "scene/resources/sphere_shape.h"
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include "scene/resources/box_shape_3d.h"
|
|
||||||
#include "scene/resources/capsule_shape_3d.h"
|
|
||||||
#include "scene/resources/concave_polygon_shape_3d.h"
|
|
||||||
#include "scene/resources/convex_polygon_shape_3d.h"
|
|
||||||
#include "scene/resources/cylinder_shape_3d.h"
|
|
||||||
#include "scene/resources/shape_3d.h"
|
|
||||||
#include "scene/resources/sphere_shape_3d.h"
|
|
||||||
|
|
||||||
#define BoxShape BoxShape3D
|
|
||||||
#define CapsuleShape CapsuleShape3D
|
|
||||||
#define ConcavePolygonShape ConcavePolygonShape3D
|
|
||||||
#define ConvexPolygonShape ConvexPolygonShape3D
|
|
||||||
#define CylinderShape CylinderShape3D
|
|
||||||
#define Shape Shape3D
|
|
||||||
#define SphereShape SphereShape3D
|
|
||||||
|
|
||||||
#define PoolVector3Array PackedVector3Array
|
|
||||||
#define PoolVector2Array PackedVector2Array
|
|
||||||
#define PoolColorArray PackedColorArray
|
|
||||||
#define PoolIntArray PackedInt64Array
|
|
||||||
#define PoolRealArray PackedFloat32Array
|
|
||||||
#define PoolByteArray PackedByteArray
|
|
||||||
|
|
||||||
typedef class RenderingServer VisualServer;
|
|
||||||
typedef class RenderingServer VS;
|
|
||||||
|
|
||||||
template <class N>
|
|
||||||
class Vector;
|
|
||||||
template <class N>
|
|
||||||
using PoolVector = Vector<N>;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MESH_UTILS_PRESENT
|
#if MESH_UTILS_PRESENT
|
||||||
#include "../../mesh_utils/mesh_utils.h"
|
#include "../../mesh_utils/mesh_utils.h"
|
||||||
#endif
|
#endif
|
||||||
@ -517,11 +478,7 @@ void MDRImportPluginBase::add_colliders(Ref<MeshDataResource> mdr, Ref<ArrayMesh
|
|||||||
AABB aabb = m->get_aabb();
|
AABB aabb = m->get_aabb();
|
||||||
Vector3 size = aabb.get_size();
|
Vector3 size = aabb.get_size();
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
shape->set_size(size * 0.5);
|
|
||||||
#else
|
|
||||||
shape->set_extents(size * 0.5);
|
shape->set_extents(size * 0.5);
|
||||||
#endif
|
|
||||||
|
|
||||||
Vector3 pos = aabb.position;
|
Vector3 pos = aabb.position;
|
||||||
pos += size / 2.0;
|
pos += size / 2.0;
|
||||||
@ -825,11 +782,7 @@ Ref<Shape> MDRImportPluginBase::scale_shape(Ref<Shape> shape, const Vector3 &sca
|
|||||||
if (Object::cast_to<BoxShape>(*shape)) {
|
if (Object::cast_to<BoxShape>(*shape)) {
|
||||||
Ref<BoxShape> bs = shape;
|
Ref<BoxShape> bs = shape;
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
bs->set_size(bs->get_size() * scale);
|
|
||||||
#else
|
|
||||||
bs->set_extents(bs->get_extents() * scale);
|
bs->set_extents(bs->get_extents() * scale);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Object::cast_to<CapsuleShape>(*shape)) {
|
if (Object::cast_to<CapsuleShape>(*shape)) {
|
||||||
|
@ -27,13 +27,8 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "core/version.h"
|
#include "core/version.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
#include "core/string/ustring.h"
|
|
||||||
#include "core/variant/array.h"
|
|
||||||
#else
|
|
||||||
#include "core/array.h"
|
#include "core/array.h"
|
||||||
#include "core/ustring.h"
|
#include "core/ustring.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../mesh_data_resource_collection.h"
|
#include "../mesh_data_resource_collection.h"
|
||||||
#include "core/io/resource_saver.h"
|
#include "core/io/resource_saver.h"
|
||||||
@ -49,21 +44,9 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "core/version.h"
|
#include "core/version.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
#include "scene/3d/mesh_instance.h"
|
#include "scene/3d/mesh_instance.h"
|
||||||
|
|
||||||
#if VERSION_MINOR < 4
|
|
||||||
#include "editor/import/editor_scene_importer_gltf.h"
|
|
||||||
#else
|
|
||||||
#include "../../gltf/editor_scene_importer_gltf.h"
|
#include "../../gltf/editor_scene_importer_gltf.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
|
||||||
#include "../../gltf/editor_scene_importer_gltf.h"
|
|
||||||
#include "scene/3d/mesh_instance_3d.h"
|
|
||||||
|
|
||||||
#define MeshInstance MeshInstance3D
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class MDRImportPluginBase : public EditorImportPlugin {
|
class MDRImportPluginBase : public EditorImportPlugin {
|
||||||
GDCLASS(MDRImportPluginBase, EditorImportPlugin);
|
GDCLASS(MDRImportPluginBase, EditorImportPlugin);
|
||||||
|
@ -60,11 +60,7 @@ Error EditorImportGLTFMdr::import(const String &p_source_file, const String &p_s
|
|||||||
|
|
||||||
Error erri;
|
Error erri;
|
||||||
|
|
||||||
#if VERSION_MAJOR == 3 && VERSION_MINOR > 4
|
|
||||||
Node *n = _importer->import_scene(p_source_file, 0, 15, 0, nullptr, &erri);
|
Node *n = _importer->import_scene(p_source_file, 0, 15, 0, nullptr, &erri);
|
||||||
#else
|
|
||||||
Node *n = _importer->import_scene(p_source_file, 0, 15, nullptr, &erri);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ERR_FAIL_COND_V(!n, Error::ERR_PARSE_ERROR);
|
ERR_FAIL_COND_V(!n, Error::ERR_PARSE_ERROR);
|
||||||
|
|
||||||
|
@ -22,18 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "core/version.h"
|
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
#include "core/string/ustring.h"
|
|
||||||
#include "core/variant/array.h"
|
|
||||||
#else
|
|
||||||
#include "core/ustring.h"
|
|
||||||
#include "core/array.h"
|
#include "core/array.h"
|
||||||
#endif
|
#include "core/ustring.h"
|
||||||
|
|
||||||
#include "../plugin/mdr_import_plugin_base.h"
|
#include "../plugin/mdr_import_plugin_base.h"
|
||||||
|
|
||||||
@ -47,26 +37,10 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "core/math/transform.h"
|
#include "core/math/transform.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
|
|
||||||
#if VERSION_MINOR < 4
|
|
||||||
#include "editor/import/editor_scene_importer_gltf.h"
|
|
||||||
#else
|
|
||||||
#include "../../gltf/editor_scene_importer_gltf.h"
|
#include "../../gltf/editor_scene_importer_gltf.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "scene/3d/mesh_instance.h"
|
#include "scene/3d/mesh_instance.h"
|
||||||
#else
|
|
||||||
#include "../../gltf/editor_scene_importer_gltf.h"
|
|
||||||
#include "scene/3d/mesh_instance_3d.h"
|
|
||||||
|
|
||||||
#define MeshInstance MeshInstance3D
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class EditorImportGLTFMdr : public MDRImportPluginBase {
|
class EditorImportGLTFMdr : public MDRImportPluginBase {
|
||||||
|
|
||||||
GDCLASS(EditorImportGLTFMdr, MDRImportPluginBase);
|
GDCLASS(EditorImportGLTFMdr, MDRImportPluginBase);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -22,23 +22,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "core/version.h"
|
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
#include "core/string/ustring.h"
|
|
||||||
#else
|
|
||||||
#include "core/ustring.h"
|
#include "core/ustring.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "editor/editor_plugin.h"
|
#include "editor/editor_plugin.h"
|
||||||
|
|
||||||
#include "editor_import_gltf_mdr.h"
|
#include "editor_import_gltf_mdr.h"
|
||||||
|
|
||||||
class EditorPluginGLTFMdr : public EditorPlugin {
|
class EditorPluginGLTFMdr : public EditorPlugin {
|
||||||
|
|
||||||
GDCLASS(EditorPluginGLTFMdr, EditorPlugin);
|
GDCLASS(EditorPluginGLTFMdr, EditorPlugin);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -27,16 +27,8 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "core/version.h"
|
#include "core/version.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
#include "core/object/ref_counted.h"
|
|
||||||
#ifndef Reference
|
|
||||||
#define Reference RefCounted
|
|
||||||
#endif
|
|
||||||
#include "core/variant/array.h"
|
|
||||||
#else
|
|
||||||
#include "core/reference.h"
|
|
||||||
#include "core/array.h"
|
#include "core/array.h"
|
||||||
#endif
|
#include "core/reference.h"
|
||||||
|
|
||||||
#include "simplify.h"
|
#include "simplify.h"
|
||||||
|
|
||||||
|
@ -24,26 +24,14 @@ SOFTWARE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "core/color.h"
|
||||||
|
|
||||||
|
|
||||||
#include "core/version.h"
|
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
#include "core/object/reference.h"
|
|
||||||
#include "core/templates/vector.h"
|
|
||||||
#include "core/math/color.h"
|
|
||||||
#else
|
|
||||||
#include "core/reference.h"
|
#include "core/reference.h"
|
||||||
#include "core/vector.h"
|
#include "core/vector.h"
|
||||||
#include "core/color.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
|
||||||
#include pool_vector_h
|
#include pool_vector_h
|
||||||
include_pool_vector
|
include_pool_vector
|
||||||
|
|
||||||
#include mesh_instance_h
|
#include mesh_instance_h
|
||||||
|
|
||||||
#include "core/math/rect2.h"
|
#include "core/math/rect2.h"
|
||||||
@ -62,7 +50,6 @@ include_pool_vector
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
struct Vertex {
|
struct Vertex {
|
||||||
|
|
||||||
Vector3 vertex;
|
Vector3 vertex;
|
||||||
Color color;
|
Color color;
|
||||||
Vector3 normal; // normal, binormal, tangent
|
Vector3 normal; // normal, binormal, tangent
|
||||||
|
@ -22,17 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "core/variant.h"
|
#include "core/variant.h"
|
||||||
#include "core/version.h"
|
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
#include "core/object/object.h"
|
|
||||||
#else
|
|
||||||
#include "core/object.h"
|
#include "core/object.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "scene/resources/texture.h"
|
#include "scene/resources/texture.h"
|
||||||
|
|
||||||
|
@ -26,11 +26,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "core/version.h"
|
#include "core/version.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
#include "core/config/engine.h"
|
|
||||||
#else
|
|
||||||
#include "core/engine.h"
|
#include "core/engine.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "fast_quadratic_mesh_simplifier.h"
|
#include "fast_quadratic_mesh_simplifier.h"
|
||||||
#include "mesh_merger.h"
|
#include "mesh_merger.h"
|
||||||
|
@ -16,13 +16,8 @@
|
|||||||
|
|
||||||
#include "core/version.h"
|
#include "core/version.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
#include "core/string/ustring.h"
|
|
||||||
#include "core/variant/array.h"
|
|
||||||
#else
|
|
||||||
#include "core/ustring.h"
|
|
||||||
#include "core/array.h"
|
#include "core/array.h"
|
||||||
#endif
|
#include "core/ustring.h"
|
||||||
|
|
||||||
#include "core/math/vector2.h"
|
#include "core/math/vector2.h"
|
||||||
#include "core/math/vector3.h"
|
#include "core/math/vector3.h"
|
||||||
@ -34,18 +29,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "core/version.h"
|
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
#include "servers/visual_server.h"
|
#include "servers/visual_server.h"
|
||||||
#else
|
|
||||||
#include "servers/rendering_server.h"
|
|
||||||
|
|
||||||
typedef class RenderingServer VisualServer;
|
|
||||||
typedef class RenderingServer VS;
|
|
||||||
|
|
||||||
#define PoolVector Vector
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace Simplify {
|
namespace Simplify {
|
||||||
|
|
||||||
@ -116,10 +100,13 @@ struct vec3f {
|
|||||||
vec3f a = v, b = *this;
|
vec3f a = v, b = *this;
|
||||||
double dot = v.x * x + v.y * y + v.z * z;
|
double dot = v.x * x + v.y * y + v.z * z;
|
||||||
double len = a.length() * b.length();
|
double len = a.length() * b.length();
|
||||||
if (len == 0) len = 0.00001f;
|
if (len == 0)
|
||||||
|
len = 0.00001f;
|
||||||
double input = dot / len;
|
double input = dot / len;
|
||||||
if (input < -1) input = -1;
|
if (input < -1)
|
||||||
if (input > 1) input = 1;
|
input = -1;
|
||||||
|
if (input > 1)
|
||||||
|
input = 1;
|
||||||
return (double)acos(input);
|
return (double)acos(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +114,8 @@ struct vec3f {
|
|||||||
vec3f a = v, b = *this;
|
vec3f a = v, b = *this;
|
||||||
double dot = a.x * b.x + a.y * b.y + a.z * b.z;
|
double dot = a.x * b.x + a.y * b.y + a.z * b.z;
|
||||||
double len = a.length() * b.length();
|
double len = a.length() * b.length();
|
||||||
if (len == 0) len = 1;
|
if (len == 0)
|
||||||
|
len = 1;
|
||||||
|
|
||||||
vec3f plane;
|
vec3f plane;
|
||||||
plane.cross(b, w);
|
plane.cross(b, w);
|
||||||
@ -153,12 +141,18 @@ struct vec3f {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inline void clamp(double min, double max) {
|
inline void clamp(double min, double max) {
|
||||||
if (x < min) x = min;
|
if (x < min)
|
||||||
if (y < min) y = min;
|
x = min;
|
||||||
if (z < min) z = min;
|
if (y < min)
|
||||||
if (x > max) x = max;
|
y = min;
|
||||||
if (y > max) y = max;
|
if (z < min)
|
||||||
if (z > max) z = max;
|
z = min;
|
||||||
|
if (x > max)
|
||||||
|
x = max;
|
||||||
|
if (y > max)
|
||||||
|
y = max;
|
||||||
|
if (z > max)
|
||||||
|
z = max;
|
||||||
}
|
}
|
||||||
inline vec3f rot_z(double a) {
|
inline vec3f rot_z(double a) {
|
||||||
double yy = cos(a) * y + sin(a) * x;
|
double yy = cos(a) * y + sin(a) * x;
|
||||||
@ -258,7 +252,6 @@ static double min(double v1, double v2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SymetricMatrix {
|
class SymetricMatrix {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
|
|
||||||
@ -344,7 +337,6 @@ static bool compare_border_vertex(const BorderVertex &i1, const BorderVertex &i2
|
|||||||
}
|
}
|
||||||
|
|
||||||
class FQMS {
|
class FQMS {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct Triangle {
|
struct Triangle {
|
||||||
int v[3];
|
int v[3];
|
||||||
@ -408,7 +400,8 @@ public:
|
|||||||
int triangle_count = triangles.size();
|
int triangle_count = triangles.size();
|
||||||
|
|
||||||
for (int iteration = 0; iteration < _max_iteration_count; iteration++) {
|
for (int iteration = 0; iteration < _max_iteration_count; iteration++) {
|
||||||
if (triangle_count - deleted_triangles <= target_count) break;
|
if (triangle_count - deleted_triangles <= target_count)
|
||||||
|
break;
|
||||||
|
|
||||||
// update mesh once in a while
|
// update mesh once in a while
|
||||||
if (iteration % 5 == 0) {
|
if (iteration % 5 == 0) {
|
||||||
@ -448,7 +441,6 @@ public:
|
|||||||
|
|
||||||
for (int j = 0; j < 3; ++j) {
|
for (int j = 0; j < 3; ++j) {
|
||||||
if (t.err[j] < threshold) {
|
if (t.err[j] < threshold) {
|
||||||
|
|
||||||
int i0 = t.v[j];
|
int i0 = t.v[j];
|
||||||
Vertex &v0 = vertices[i0];
|
Vertex &v0 = vertices[i0];
|
||||||
int i1 = t.v[(j + 1) % 3];
|
int i1 = t.v[(j + 1) % 3];
|
||||||
@ -496,7 +488,8 @@ public:
|
|||||||
|
|
||||||
if (tcount <= v0.tcount) {
|
if (tcount <= v0.tcount) {
|
||||||
// save ram
|
// save ram
|
||||||
if (tcount) memcpy(&refs[v0.tstart], &refs[tstart], tcount * sizeof(Ref));
|
if (tcount)
|
||||||
|
memcpy(&refs[v0.tstart], &refs[tstart], tcount * sizeof(Ref));
|
||||||
} else {
|
} else {
|
||||||
// append
|
// append
|
||||||
v0.tstart = tstart;
|
v0.tstart = tstart;
|
||||||
@ -508,7 +501,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// done?
|
// done?
|
||||||
if (triangle_count - deleted_triangles <= target_count) break;
|
if (triangle_count - deleted_triangles <= target_count)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// clean up mesh
|
// clean up mesh
|
||||||
@ -604,7 +598,8 @@ public:
|
|||||||
|
|
||||||
if (tcount <= v0.tcount) {
|
if (tcount <= v0.tcount) {
|
||||||
// save ram
|
// save ram
|
||||||
if (tcount) memcpy(&refs[v0.tstart], &refs[tstart], tcount * sizeof(Ref));
|
if (tcount)
|
||||||
|
memcpy(&refs[v0.tstart], &refs[tstart], tcount * sizeof(Ref));
|
||||||
} else {
|
} else {
|
||||||
// append
|
// append
|
||||||
v0.tstart = tstart;
|
v0.tstart = tstart;
|
||||||
@ -628,7 +623,6 @@ public:
|
|||||||
// Check if a triangle flips when this edge is removed
|
// Check if a triangle flips when this edge is removed
|
||||||
|
|
||||||
bool flipped(vec3f p, int i0, int i1, Vertex &v0, Vertex &v1, std::vector<int> &deleted) {
|
bool flipped(vec3f p, int i0, int i1, Vertex &v0, Vertex &v1, std::vector<int> &deleted) {
|
||||||
|
|
||||||
for (int k = 0; k < v0.tcount; ++k) {
|
for (int k = 0; k < v0.tcount; ++k) {
|
||||||
Triangle &t = triangles[refs[v0.tstart + k].tid];
|
Triangle &t = triangles[refs[v0.tstart + k].tid];
|
||||||
|
|
||||||
@ -648,12 +642,14 @@ public:
|
|||||||
d1.normalize();
|
d1.normalize();
|
||||||
vec3f d2 = vertices[id2].p - p;
|
vec3f d2 = vertices[id2].p - p;
|
||||||
d2.normalize();
|
d2.normalize();
|
||||||
if (fabs(d1.dot(d2)) > 0.999) return true;
|
if (fabs(d1.dot(d2)) > 0.999)
|
||||||
|
return true;
|
||||||
vec3f n;
|
vec3f n;
|
||||||
n.cross(d1, d2);
|
n.cross(d1, d2);
|
||||||
n.normalize();
|
n.normalize();
|
||||||
deleted[k] = 0;
|
deleted[k] = 0;
|
||||||
if (n.dot(t.n) < 0.2) return true;
|
if (n.dot(t.n) < 0.2)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1018,7 +1014,6 @@ public:
|
|||||||
double error = 0;
|
double error = 0;
|
||||||
double det = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
|
double det = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
|
||||||
if (det != 0 && !border) {
|
if (det != 0 && !border) {
|
||||||
|
|
||||||
// q_delta is invertible
|
// q_delta is invertible
|
||||||
p_result.x = -1 / det * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8)); // vx = A41/det(q_delta)
|
p_result.x = -1 / det * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8)); // vx = A41/det(q_delta)
|
||||||
p_result.y = 1 / det * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8)); // vy = A42/det(q_delta)
|
p_result.y = 1 / det * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8)); // vy = A42/det(q_delta)
|
||||||
@ -1034,9 +1029,12 @@ public:
|
|||||||
double error2 = vertex_error(q, p2.x, p2.y, p2.z);
|
double error2 = vertex_error(q, p2.x, p2.y, p2.z);
|
||||||
double error3 = vertex_error(q, p3.x, p3.y, p3.z);
|
double error3 = vertex_error(q, p3.x, p3.y, p3.z);
|
||||||
error = min(error1, min(error2, error3));
|
error = min(error1, min(error2, error3));
|
||||||
if (error1 == error) p_result = p1;
|
if (error1 == error)
|
||||||
if (error2 == error) p_result = p2;
|
p_result = p1;
|
||||||
if (error3 == error) p_result = p3;
|
if (error2 == error)
|
||||||
|
p_result = p2;
|
||||||
|
if (error3 == error)
|
||||||
|
p_result = p3;
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,6 @@ void PropEditorPlugin::convert_scene(Node *root, const String &path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PropEditorPlugin::find_room_points(Variant param) {
|
void PropEditorPlugin::find_room_points(Variant param) {
|
||||||
#if VERSION_MINOR >= 4
|
|
||||||
SceneTree *st = SceneTree::get_singleton();
|
SceneTree *st = SceneTree::get_singleton();
|
||||||
|
|
||||||
if (st) {
|
if (st) {
|
||||||
@ -82,7 +81,6 @@ void PropEditorPlugin::find_room_points(Variant param) {
|
|||||||
PropUtils::get_singleton()->generate_room_points_node(scene);
|
PropUtils::get_singleton()->generate_room_points_node(scene);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropEditorPlugin::_quick_convert_button_pressed() {
|
void PropEditorPlugin::_quick_convert_button_pressed() {
|
||||||
|
@ -95,7 +95,6 @@ void PropUtils::_convert_tree(Ref<PropData> prop_data, Node *node, const Transfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#if VERSION_MINOR >= 4
|
|
||||||
//only handle the first encountered room per prop
|
//only handle the first encountered room per prop
|
||||||
if (!prop_data->get_is_room()) {
|
if (!prop_data->get_is_room()) {
|
||||||
Room *r = Object::cast_to<Room>(sp);
|
Room *r = Object::cast_to<Room>(sp);
|
||||||
@ -108,7 +107,6 @@ void PropUtils::_convert_tree(Ref<PropData> prop_data, Node *node, const Transfo
|
|||||||
prop_data->set_room_bounds(points);
|
prop_data->set_room_bounds(points);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
for (int i = 0; i < node->get_child_count(); ++i) {
|
for (int i = 0; i < node->get_child_count(); ++i) {
|
||||||
Node *child = node->get_child(i);
|
Node *child = node->get_child(i);
|
||||||
@ -125,7 +123,6 @@ void PropUtils::_convert_tree(Ref<PropData> prop_data, Node *node, const Transfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VERSION_MINOR >= 4
|
|
||||||
bool PropUtils::generate_room_points_node(Node *node) {
|
bool PropUtils::generate_room_points_node(Node *node) {
|
||||||
ERR_FAIL_COND_V(!ObjectDB::instance_validate(node), false);
|
ERR_FAIL_COND_V(!ObjectDB::instance_validate(node), false);
|
||||||
|
|
||||||
@ -448,8 +445,6 @@ void PropUtils::get_mesh_arrays(Node *node, Vector<PoolVector<Vector3>> *arrs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int PropUtils::add_processor(const Ref<PropDataEntry> &processor) {
|
int PropUtils::add_processor(const Ref<PropDataEntry> &processor) {
|
||||||
ERR_FAIL_COND_V(!processor.is_valid(), 0);
|
ERR_FAIL_COND_V(!processor.is_valid(), 0);
|
||||||
|
|
||||||
|
@ -279,10 +279,8 @@ TiledWall::TiledWall() {
|
|||||||
|
|
||||||
_physics_body_rid = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC);
|
_physics_body_rid = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC);
|
||||||
|
|
||||||
#if VERSION_MINOR >= 4
|
|
||||||
//temporary
|
//temporary
|
||||||
set_portal_mode(PORTAL_MODE_GLOBAL);
|
set_portal_mode(PORTAL_MODE_GLOBAL);
|
||||||
#endif
|
|
||||||
|
|
||||||
_mesher.instance();
|
_mesher.instance();
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,6 @@ void Prop2DEditorPlugin::convert_scene(Node *root, const String &path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Prop2DEditorPlugin::find_room_points(Variant param) {
|
void Prop2DEditorPlugin::find_room_points(Variant param) {
|
||||||
#if VERSION_MINOR >= 4
|
|
||||||
SceneTree *st = SceneTree::get_singleton();
|
SceneTree *st = SceneTree::get_singleton();
|
||||||
|
|
||||||
if (st) {
|
if (st) {
|
||||||
@ -82,7 +81,6 @@ void Prop2DEditorPlugin::find_room_points(Variant param) {
|
|||||||
//Prop2DUtils::get_singleton()->generate_room_points_node(scene);
|
//Prop2DUtils::get_singleton()->generate_room_points_node(scene);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Prop2DEditorPlugin::_quick_convert_button_pressed() {
|
void Prop2DEditorPlugin::_quick_convert_button_pressed() {
|
||||||
|
@ -35,12 +35,10 @@
|
|||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "scene/2d/area_2d.h"
|
#include "scene/2d/area_2d.h"
|
||||||
#include "scene/2d/collision_object_2d.h"
|
#include "scene/2d/collision_object_2d.h"
|
||||||
#include "servers/physics_2d_server.h"
|
|
||||||
#include "scene/resources/world_2d.h"
|
#include "scene/resources/world_2d.h"
|
||||||
|
#include "servers/physics_2d_server.h"
|
||||||
|
|
||||||
#if VERSION_MINOR >= 5
|
|
||||||
#include "servers/navigation_2d_server.h"
|
#include "servers/navigation_2d_server.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
int RTileMap::_get_quadrant_size() const {
|
int RTileMap::_get_quadrant_size() const {
|
||||||
if (y_sort_mode) {
|
if (y_sort_mode) {
|
||||||
@ -84,11 +82,7 @@ void RTileMap::_notification(int p_what) {
|
|||||||
Quadrant &q = E->get();
|
Quadrant &q = E->get();
|
||||||
if (navigation) {
|
if (navigation) {
|
||||||
for (Map<PosKey, Quadrant::NavPoly>::Element *F = q.navpoly_ids.front(); F; F = F->next()) {
|
for (Map<PosKey, Quadrant::NavPoly>::Element *F = q.navpoly_ids.front(); F; F = F->next()) {
|
||||||
#if VERSION_MINOR < 5
|
|
||||||
navigation->navpoly_remove(F->get().id);
|
|
||||||
#else
|
|
||||||
Navigation2DServer::get_singleton()->region_set_map(F->get().region, RID());
|
Navigation2DServer::get_singleton()->region_set_map(F->get().region, RID());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
q.navpoly_ids.clear();
|
q.navpoly_ids.clear();
|
||||||
}
|
}
|
||||||
@ -172,11 +166,7 @@ void RTileMap::_update_quadrant_transform() {
|
|||||||
|
|
||||||
if (navigation) {
|
if (navigation) {
|
||||||
for (Map<PosKey, Quadrant::NavPoly>::Element *F = q.navpoly_ids.front(); F; F = F->next()) {
|
for (Map<PosKey, Quadrant::NavPoly>::Element *F = q.navpoly_ids.front(); F; F = F->next()) {
|
||||||
#if VERSION_MINOR < 5
|
|
||||||
navigation->navpoly_set_transform(F->get().id, nav_rel * F->get().xform);
|
|
||||||
#else
|
|
||||||
Navigation2DServer::get_singleton()->region_set_transform(F->get().region, nav_rel * F->get().xform);
|
Navigation2DServer::get_singleton()->region_set_transform(F->get().region, nav_rel * F->get().xform);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,11 +393,7 @@ void RTileMap::update_dirty_quadrants() {
|
|||||||
|
|
||||||
if (navigation) {
|
if (navigation) {
|
||||||
for (Map<PosKey, Quadrant::NavPoly>::Element *E = q.navpoly_ids.front(); E; E = E->next()) {
|
for (Map<PosKey, Quadrant::NavPoly>::Element *E = q.navpoly_ids.front(); E; E = E->next()) {
|
||||||
#if VERSION_MINOR < 5
|
|
||||||
navigation->navpoly_remove(E->get().id);
|
|
||||||
#else
|
|
||||||
Navigation2DServer::get_singleton()->region_set_map(E->get().region, RID());
|
Navigation2DServer::get_singleton()->region_set_map(E->get().region, RID());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
q.navpoly_ids.clear();
|
q.navpoly_ids.clear();
|
||||||
}
|
}
|
||||||
@ -654,20 +640,12 @@ void RTileMap::update_dirty_quadrants() {
|
|||||||
xform.set_origin(offset.floor() + q.pos);
|
xform.set_origin(offset.floor() + q.pos);
|
||||||
_fix_cell_transform(xform, c, npoly_ofs, s);
|
_fix_cell_transform(xform, c, npoly_ofs, s);
|
||||||
|
|
||||||
#if VERSION_MINOR < 5
|
|
||||||
int pid = navigation->navpoly_add(navpoly, nav_rel * xform);
|
|
||||||
#else
|
|
||||||
RID region = Navigation2DServer::get_singleton()->region_create();
|
RID region = Navigation2DServer::get_singleton()->region_create();
|
||||||
Navigation2DServer::get_singleton()->region_set_map(region, navigation->get_rid());
|
Navigation2DServer::get_singleton()->region_set_map(region, navigation->get_rid());
|
||||||
Navigation2DServer::get_singleton()->region_set_transform(region, nav_rel * xform);
|
Navigation2DServer::get_singleton()->region_set_transform(region, nav_rel * xform);
|
||||||
Navigation2DServer::get_singleton()->region_set_navpoly(region, navpoly);
|
Navigation2DServer::get_singleton()->region_set_navpoly(region, navpoly);
|
||||||
#endif
|
|
||||||
Quadrant::NavPoly np;
|
Quadrant::NavPoly np;
|
||||||
#if VERSION_MINOR < 5
|
|
||||||
np.id = pid;
|
|
||||||
#else
|
|
||||||
np.region = region;
|
np.region = region;
|
||||||
#endif
|
|
||||||
np.xform = xform;
|
np.xform = xform;
|
||||||
q.navpoly_ids[E->key()] = np;
|
q.navpoly_ids[E->key()] = np;
|
||||||
|
|
||||||
@ -861,11 +839,7 @@ void RTileMap::_erase_quadrant(Map<PosKey, Quadrant>::Element *Q) {
|
|||||||
|
|
||||||
if (navigation) {
|
if (navigation) {
|
||||||
for (Map<PosKey, Quadrant::NavPoly>::Element *E = q.navpoly_ids.front(); E; E = E->next()) {
|
for (Map<PosKey, Quadrant::NavPoly>::Element *E = q.navpoly_ids.front(); E; E = E->next()) {
|
||||||
#if VERSION_MINOR < 5
|
|
||||||
navigation->navpoly_remove(E->get().id);
|
|
||||||
#else
|
|
||||||
Navigation2DServer::get_singleton()->region_set_map(E->get().region, RID());
|
Navigation2DServer::get_singleton()->region_set_map(E->get().region, RID());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
q.navpoly_ids.clear();
|
q.navpoly_ids.clear();
|
||||||
}
|
}
|
||||||
|
@ -30,15 +30,12 @@
|
|||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "core/self_list.h"
|
#include "core/self_list.h"
|
||||||
|
#include "core/version.h"
|
||||||
#include "core/vset.h"
|
#include "core/vset.h"
|
||||||
#include "scene/2d/navigation_2d.h"
|
#include "scene/2d/navigation_2d.h"
|
||||||
#include "scene/2d/node_2d.h"
|
#include "scene/2d/node_2d.h"
|
||||||
#include "tile_set.h"
|
#include "tile_set.h"
|
||||||
#include "core/version.h"
|
|
||||||
|
|
||||||
#include "../fastnoise/noise.h"
|
#include "../fastnoise/noise.h"
|
||||||
|
|
||||||
@ -149,11 +146,7 @@ private:
|
|||||||
SelfList<Quadrant> dirty_list;
|
SelfList<Quadrant> dirty_list;
|
||||||
|
|
||||||
struct NavPoly {
|
struct NavPoly {
|
||||||
#if VERSION_MINOR < 5
|
|
||||||
int id;
|
|
||||||
#else
|
|
||||||
RID region;
|
RID region;
|
||||||
#endif
|
|
||||||
Transform2D xform;
|
Transform2D xform;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2133,18 +2133,10 @@ void RTileMapEditorPlugin::_notification(int p_what) {
|
|||||||
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
|
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
|
||||||
switch ((int)EditorSettings::get_singleton()->get("editors/tile_map/editor_side")) {
|
switch ((int)EditorSettings::get_singleton()->get("editors/tile_map/editor_side")) {
|
||||||
case 0: { // Left.
|
case 0: { // Left.
|
||||||
#if VERSION_MINOR < 5
|
|
||||||
CanvasItemEditor::get_singleton()->get_palette_split()->move_child(tile_map_editor, 0);
|
|
||||||
#else
|
|
||||||
CanvasItemEditor::get_singleton()->move_control_to_left_panel(tile_map_editor);
|
CanvasItemEditor::get_singleton()->move_control_to_left_panel(tile_map_editor);
|
||||||
#endif
|
|
||||||
} break;
|
} break;
|
||||||
case 1: { // Right.
|
case 1: { // Right.
|
||||||
#if VERSION_MINOR < 5
|
|
||||||
CanvasItemEditor::get_singleton()->get_palette_split()->move_child(tile_map_editor, 1);
|
|
||||||
#else
|
|
||||||
CanvasItemEditor::get_singleton()->move_control_to_right_panel(tile_map_editor);
|
CanvasItemEditor::get_singleton()->move_control_to_right_panel(tile_map_editor);
|
||||||
#endif
|
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,11 +26,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "core/version.h"
|
#include "core/version.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
#include "core/config/engine.h"
|
|
||||||
#else
|
|
||||||
#include "core/engine.h"
|
#include "core/engine.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "thread_pool.h"
|
#include "thread_pool.h"
|
||||||
#include "thread_pool_execute_job.h"
|
#include "thread_pool_execute_job.h"
|
||||||
@ -39,7 +35,6 @@ SOFTWARE.
|
|||||||
static ThreadPool *thread_pool = NULL;
|
static ThreadPool *thread_pool = NULL;
|
||||||
|
|
||||||
void register_thread_pool_types() {
|
void register_thread_pool_types() {
|
||||||
|
|
||||||
ClassDB::register_class<ThreadPoolJob>();
|
ClassDB::register_class<ThreadPoolJob>();
|
||||||
ClassDB::register_class<ThreadPoolExecuteJob>();
|
ClassDB::register_class<ThreadPoolExecuteJob>();
|
||||||
|
|
||||||
|
@ -27,27 +27,15 @@ SOFTWARE.
|
|||||||
void BSInputEventKey::from_input_event_key(const Ref<InputEventKey> event) {
|
void BSInputEventKey::from_input_event_key(const Ref<InputEventKey> event) {
|
||||||
set_device(event->get_device());
|
set_device(event->get_device());
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
set_shift(event->get_shift());
|
set_shift(event->get_shift());
|
||||||
set_alt(event->get_alt());
|
set_alt(event->get_alt());
|
||||||
set_control(event->get_control());
|
set_control(event->get_control());
|
||||||
set_metakey(event->get_metakey());
|
set_metakey(event->get_metakey());
|
||||||
set_command(event->get_command());
|
set_command(event->get_command());
|
||||||
#else
|
|
||||||
set_shift_pressed(event->is_shift_pressed());
|
|
||||||
set_alt_pressed(event->is_alt_pressed());
|
|
||||||
set_ctrl_pressed(event->is_ctrl_pressed());
|
|
||||||
set_meta_pressed(event->is_meta_pressed());
|
|
||||||
set_command_pressed(event->is_command_pressed());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
set_pressed(event->is_pressed());
|
set_pressed(event->is_pressed());
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
set_scancode(event->get_scancode());
|
set_scancode(event->get_scancode());
|
||||||
#else
|
|
||||||
set_keycode(event->get_keycode());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
set_unicode(event->get_unicode());
|
set_unicode(event->get_unicode());
|
||||||
set_echo(event->is_echo());
|
set_echo(event->is_echo());
|
||||||
@ -58,13 +46,8 @@ bool BSInputEventKey::action_match(const Ref<InputEvent> &p_event, bool p_exact_
|
|||||||
if (key.is_null())
|
if (key.is_null())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
uint32_t code = get_scancode_with_modifiers();
|
uint32_t code = get_scancode_with_modifiers();
|
||||||
uint32_t event_code = key->get_scancode_with_modifiers();
|
uint32_t event_code = key->get_scancode_with_modifiers();
|
||||||
#else
|
|
||||||
Key code = get_keycode_with_modifiers();
|
|
||||||
Key event_code = key->get_keycode_with_modifiers();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool match = (code == event_code);
|
bool match = (code == event_code);
|
||||||
if (match) {
|
if (match) {
|
||||||
|
@ -27,11 +27,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "core/version.h"
|
#include "core/version.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
#include "core/os/input_event.h"
|
#include "core/os/input_event.h"
|
||||||
#else
|
|
||||||
#include "core/input/input_event.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class BSInputEventKey : public InputEventKey {
|
class BSInputEventKey : public InputEventKey {
|
||||||
GDCLASS(BSInputEventKey, InputEventKey);
|
GDCLASS(BSInputEventKey, InputEventKey);
|
||||||
|
@ -30,16 +30,10 @@
|
|||||||
|
|
||||||
#include "input_map_editor.h"
|
#include "input_map_editor.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
#include "core/string/ustring.h"
|
|
||||||
#else
|
|
||||||
#include "core/global_constants.h"
|
#include "core/global_constants.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/project_settings.h"
|
||||||
#include "core/translation.h"
|
#include "core/translation.h"
|
||||||
#include "core/ustring.h"
|
#include "core/ustring.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "editor/editor_export.h"
|
#include "editor/editor_export.h"
|
||||||
@ -49,19 +43,10 @@
|
|||||||
|
|
||||||
#include "core/version.h"
|
#include "core/version.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
#include "core/input_map.h"
|
#include "core/input_map.h"
|
||||||
#define CONNECT(sig, obj, target_method_class, method) connect(sig, obj, #method)
|
#define CONNECT(sig, obj, target_method_class, method) connect(sig, obj, #method)
|
||||||
#else
|
|
||||||
#include "core/input/input_map.h"
|
|
||||||
#define CONNECT(sig, obj, target_method_class, method) connect(sig, callable_mp(obj, &target_method_class::method))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
static const char *_button_names[JOY_BUTTON_MAX] = {
|
static const char *_button_names[JOY_BUTTON_MAX] = {
|
||||||
#else
|
|
||||||
static const char *_button_names[static_cast<int>(JoyButton::MAX)] = {
|
|
||||||
#endif
|
|
||||||
"DualShock Cross, Xbox A, Nintendo B",
|
"DualShock Cross, Xbox A, Nintendo B",
|
||||||
"DualShock Circle, Xbox B, Nintendo A",
|
"DualShock Circle, Xbox B, Nintendo A",
|
||||||
"DualShock Square, Xbox X, Nintendo Y",
|
"DualShock Square, Xbox X, Nintendo Y",
|
||||||
@ -80,11 +65,7 @@ static const char *_button_names[static_cast<int>(JoyButton::MAX)] = {
|
|||||||
"D-Pad Right"
|
"D-Pad Right"
|
||||||
};
|
};
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
static const char *_axis_names[JOY_AXIS_MAX * 2] = {
|
static const char *_axis_names[JOY_AXIS_MAX * 2] = {
|
||||||
#else
|
|
||||||
static const char *_axis_names[static_cast<int>(JoyAxis::MAX) * 2] = {
|
|
||||||
#endif
|
|
||||||
" (Left Stick Left)",
|
" (Left Stick Left)",
|
||||||
" (Left Stick Right)",
|
" (Left Stick Right)",
|
||||||
" (Left Stick Up)",
|
" (Left Stick Up)",
|
||||||
@ -112,11 +93,7 @@ void InputMapEditor::_notification(int p_what) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool _validate_action_name(const String &p_name) {
|
static bool _validate_action_name(const String &p_name) {
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
const CharType *cstr = p_name.c_str();
|
const CharType *cstr = p_name.c_str();
|
||||||
#else
|
|
||||||
const char32_t *cstr = p_name.get_data();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (int i = 0; cstr[i]; i++)
|
for (int i = 0; cstr[i]; i++)
|
||||||
if (cstr[i] == '/' || cstr[i] == ':' || cstr[i] == '"' ||
|
if (cstr[i] == '/' || cstr[i] == ':' || cstr[i] == '"' ||
|
||||||
@ -202,13 +179,8 @@ void InputMapEditor::_device_input_add() {
|
|||||||
switch (add_type) {
|
switch (add_type) {
|
||||||
case INPUT_MOUSE_BUTTON: {
|
case INPUT_MOUSE_BUTTON: {
|
||||||
Ref<InputEventMouseButton> mb;
|
Ref<InputEventMouseButton> mb;
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
mb.instance();
|
mb.instance();
|
||||||
mb->set_button_index(device_index->get_selected() + 1);
|
mb->set_button_index(device_index->get_selected() + 1);
|
||||||
#else
|
|
||||||
mb.instantiate();
|
|
||||||
mb->set_button_index(static_cast<MouseButton>(device_index->get_selected() + 1));
|
|
||||||
#endif
|
|
||||||
mb->set_device(_get_current_device());
|
mb->set_device(_get_current_device());
|
||||||
|
|
||||||
for (int i = 0; i < events.size(); i++) {
|
for (int i = 0; i < events.size(); i++) {
|
||||||
@ -225,13 +197,8 @@ void InputMapEditor::_device_input_add() {
|
|||||||
} break;
|
} break;
|
||||||
case INPUT_JOY_MOTION: {
|
case INPUT_JOY_MOTION: {
|
||||||
Ref<InputEventJoypadMotion> jm;
|
Ref<InputEventJoypadMotion> jm;
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
jm.instance();
|
jm.instance();
|
||||||
jm->set_axis(device_index->get_selected() >> 1);
|
jm->set_axis(device_index->get_selected() >> 1);
|
||||||
#else
|
|
||||||
jm.instantiate();
|
|
||||||
jm->set_axis(static_cast<JoyAxis>(device_index->get_selected() >> 1));
|
|
||||||
#endif
|
|
||||||
jm->set_axis_value((device_index->get_selected() & 1) ? 1 : -1);
|
jm->set_axis_value((device_index->get_selected() & 1) ? 1 : -1);
|
||||||
jm->set_device(_get_current_device());
|
jm->set_device(_get_current_device());
|
||||||
|
|
||||||
@ -250,13 +217,8 @@ void InputMapEditor::_device_input_add() {
|
|||||||
} break;
|
} break;
|
||||||
case INPUT_JOY_BUTTON: {
|
case INPUT_JOY_BUTTON: {
|
||||||
Ref<InputEventJoypadButton> jb;
|
Ref<InputEventJoypadButton> jb;
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
jb.instance();
|
jb.instance();
|
||||||
jb->set_button_index(device_index->get_selected());
|
jb->set_button_index(device_index->get_selected());
|
||||||
#else
|
|
||||||
jb.instantiate();
|
|
||||||
jb->set_button_index(static_cast<JoyButton>(device_index->get_selected()));
|
|
||||||
#endif
|
|
||||||
jb->set_device(_get_current_device());
|
jb->set_device(_get_current_device());
|
||||||
|
|
||||||
for (int i = 0; i < events.size(); i++) {
|
for (int i = 0; i < events.size(); i++) {
|
||||||
@ -309,21 +271,12 @@ void InputMapEditor::_press_a_key_confirm() {
|
|||||||
|
|
||||||
Ref<BSInputEventKey> ie;
|
Ref<BSInputEventKey> ie;
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
ie.instance();
|
ie.instance();
|
||||||
ie->set_scancode(last_wait_for_key->get_scancode());
|
ie->set_scancode(last_wait_for_key->get_scancode());
|
||||||
ie->set_shift(last_wait_for_key->get_shift());
|
ie->set_shift(last_wait_for_key->get_shift());
|
||||||
ie->set_alt(last_wait_for_key->get_alt());
|
ie->set_alt(last_wait_for_key->get_alt());
|
||||||
ie->set_control(last_wait_for_key->get_control());
|
ie->set_control(last_wait_for_key->get_control());
|
||||||
ie->set_metakey(last_wait_for_key->get_metakey());
|
ie->set_metakey(last_wait_for_key->get_metakey());
|
||||||
#else
|
|
||||||
ie.instantiate();
|
|
||||||
ie->set_keycode(last_wait_for_key->get_keycode());
|
|
||||||
ie->set_shift_pressed(last_wait_for_key->is_shift_pressed());
|
|
||||||
ie->set_alt_pressed(last_wait_for_key->is_alt_pressed());
|
|
||||||
ie->set_ctrl_pressed(last_wait_for_key->is_ctrl_pressed());
|
|
||||||
ie->set_meta_pressed(last_wait_for_key->is_meta_pressed());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
String name = add_at;
|
String name = add_at;
|
||||||
int idx = edit_idx;
|
int idx = edit_idx;
|
||||||
@ -337,15 +290,9 @@ void InputMapEditor::_press_a_key_confirm() {
|
|||||||
if (aie.is_null())
|
if (aie.is_null())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
if (aie->get_scancode_with_modifiers() == ie->get_scancode_with_modifiers()) {
|
if (aie->get_scancode_with_modifiers() == ie->get_scancode_with_modifiers()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (aie->get_keycode_with_modifiers() == ie->get_keycode_with_modifiers()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (idx < 0 || idx >= events.size()) {
|
if (idx < 0 || idx >= events.size()) {
|
||||||
@ -370,11 +317,7 @@ void InputMapEditor::_show_last_added(const Ref<InputEvent> &p_event, const Stri
|
|||||||
if (!r)
|
if (!r)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
r = r->get_children();
|
r = r->get_children();
|
||||||
#else
|
|
||||||
r = r->get_first_child();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!r)
|
if (!r)
|
||||||
return;
|
return;
|
||||||
@ -385,11 +328,7 @@ void InputMapEditor::_show_last_added(const Ref<InputEvent> &p_event, const Stri
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
TreeItem *child = r->get_children();
|
TreeItem *child = r->get_children();
|
||||||
#else
|
|
||||||
TreeItem *child = r->get_first_child();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while (child) {
|
while (child) {
|
||||||
Variant input = child->get_meta("__input");
|
Variant input = child->get_meta("__input");
|
||||||
@ -413,33 +352,14 @@ void InputMapEditor::_show_last_added(const Ref<InputEvent> &p_event, const Stri
|
|||||||
void InputMapEditor::_wait_for_key(const Ref<InputEvent> &p_event) {
|
void InputMapEditor::_wait_for_key(const Ref<InputEvent> &p_event) {
|
||||||
Ref<InputEventKey> k = p_event;
|
Ref<InputEventKey> k = p_event;
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
if (k.is_valid() && k->is_pressed() && k->get_scancode() != 0) {
|
if (k.is_valid() && k->is_pressed() && k->get_scancode() != 0) {
|
||||||
#else
|
|
||||||
if (k.is_valid() && k->is_pressed() && k->get_keycode() != Key::NONE) {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
last_wait_for_key = p_event;
|
last_wait_for_key = p_event;
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
const String str = keycode_get_string(k->get_scancode_with_modifiers());
|
const String str = keycode_get_string(k->get_scancode_with_modifiers());
|
||||||
#else
|
|
||||||
const String str = keycode_get_string(k->get_keycode_with_modifiers());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
press_a_key_label->set_text(str);
|
press_a_key_label->set_text(str);
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
press_a_key->get_ok()->set_disabled(false);
|
press_a_key->get_ok()->set_disabled(false);
|
||||||
#else
|
|
||||||
press_a_key->get_ok_button()->set_disabled(false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
press_a_key->accept_event();
|
press_a_key->accept_event();
|
||||||
#else
|
|
||||||
press_a_key->set_input_as_handled();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,11 +370,7 @@ void InputMapEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_event) {
|
|||||||
case INPUT_KEY: {
|
case INPUT_KEY: {
|
||||||
press_a_key_label->set_text(("Press a Key..."));
|
press_a_key_label->set_text(("Press a Key..."));
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
press_a_key->get_ok()->set_disabled(true);
|
press_a_key->get_ok()->set_disabled(true);
|
||||||
#else
|
|
||||||
press_a_key->get_ok_button()->set_disabled(true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
last_wait_for_key = Ref<InputEvent>();
|
last_wait_for_key = Ref<InputEvent>();
|
||||||
press_a_key->popup_centered(Size2(250, 80));
|
press_a_key->popup_centered(Size2(250, 80));
|
||||||
@ -474,36 +390,18 @@ void InputMapEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_event) {
|
|||||||
device_index->add_item(("X Button 1"));
|
device_index->add_item(("X Button 1"));
|
||||||
device_index->add_item(("X Button 2"));
|
device_index->add_item(("X Button 2"));
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
device_input->popup_centered_minsize(Size2(350, 95));
|
device_input->popup_centered_minsize(Size2(350, 95));
|
||||||
#else
|
|
||||||
device_input->popup_centered(Size2(350, 95));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Ref<InputEventMouseButton> mb = p_exiting_event;
|
Ref<InputEventMouseButton> mb = p_exiting_event;
|
||||||
if (mb.is_valid()) {
|
if (mb.is_valid()) {
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
device_index->select(mb->get_button_index() - 1);
|
device_index->select(mb->get_button_index() - 1);
|
||||||
#else
|
|
||||||
device_index->select(static_cast<int>(mb->get_button_index()) - 1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_set_current_device(mb->get_device());
|
_set_current_device(mb->get_device());
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
device_input->get_ok()->set_text("Change");
|
device_input->get_ok()->set_text("Change");
|
||||||
#else
|
|
||||||
device_input->get_ok_button()->set_text("Change");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_set_current_device(0);
|
_set_current_device(0);
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
device_input->get_ok()->set_text("Add");
|
device_input->get_ok()->set_text("Add");
|
||||||
#else
|
|
||||||
device_input->get_ok_button()->set_text("Add");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
@ -511,45 +409,24 @@ void InputMapEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_event) {
|
|||||||
device_index_label->set_text("Joypad Axis Index:");
|
device_index_label->set_text("Joypad Axis Index:");
|
||||||
device_index->clear();
|
device_index->clear();
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
for (int i = 0; i < JOY_AXIS_MAX * 2; i++) {
|
for (int i = 0; i < JOY_AXIS_MAX * 2; i++) {
|
||||||
#else
|
|
||||||
for (int i = 0; i < static_cast<int>(JoyAxis::MAX) * 2; i++) {
|
|
||||||
#endif
|
|
||||||
String desc = _axis_names[i];
|
String desc = _axis_names[i];
|
||||||
device_index->add_item("Axis " + itos(i / 2) + " " + ((i & 1) ? "+" : "-") + desc);
|
device_index->add_item("Axis " + itos(i / 2) + " " + ((i & 1) ? "+" : "-") + desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
device_input->popup_centered_minsize(Size2(350, 95));
|
device_input->popup_centered_minsize(Size2(350, 95));
|
||||||
#else
|
|
||||||
device_input->popup_centered(Size2(350, 95));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Ref<InputEventJoypadMotion> jm = p_exiting_event;
|
Ref<InputEventJoypadMotion> jm = p_exiting_event;
|
||||||
if (jm.is_valid()) {
|
if (jm.is_valid()) {
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
device_index->select(jm->get_axis() * 2 + (jm->get_axis_value() > 0 ? 1 : 0));
|
device_index->select(jm->get_axis() * 2 + (jm->get_axis_value() > 0 ? 1 : 0));
|
||||||
#else
|
|
||||||
device_index->select(static_cast<int>(jm->get_axis()) * 2 + (jm->get_axis_value() > 0 ? 1 : 0));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_set_current_device(jm->get_device());
|
_set_current_device(jm->get_device());
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
device_input->get_ok()->set_text("Change");
|
device_input->get_ok()->set_text("Change");
|
||||||
#else
|
|
||||||
device_input->get_ok_button()->set_text("Change");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_set_current_device(0);
|
_set_current_device(0);
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
device_input->get_ok()->set_text("Add");
|
device_input->get_ok()->set_text("Add");
|
||||||
#else
|
|
||||||
device_input->get_ok_button()->set_text("Add");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
@ -557,42 +434,22 @@ void InputMapEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_event) {
|
|||||||
device_index_label->set_text("Joypad Button Index:");
|
device_index_label->set_text("Joypad Button Index:");
|
||||||
device_index->clear();
|
device_index->clear();
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
for (int i = 0; i < JOY_BUTTON_MAX; i++) {
|
for (int i = 0; i < JOY_BUTTON_MAX; i++) {
|
||||||
#else
|
|
||||||
for (int i = 0; i < static_cast<int>(JoyButton::MAX); i++) {
|
|
||||||
#endif
|
|
||||||
device_index->add_item(itos(i) + ": " + String(_button_names[i]));
|
device_index->add_item(itos(i) + ": " + String(_button_names[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
device_input->popup_centered_minsize(Size2(350, 95));
|
device_input->popup_centered_minsize(Size2(350, 95));
|
||||||
#else
|
|
||||||
device_input->popup_centered(Size2(350, 95));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Ref<InputEventJoypadButton> jb = p_exiting_event;
|
Ref<InputEventJoypadButton> jb = p_exiting_event;
|
||||||
if (jb.is_valid()) {
|
if (jb.is_valid()) {
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
device_index->select(jb->get_button_index());
|
device_index->select(jb->get_button_index());
|
||||||
#else
|
|
||||||
device_index->select(static_cast<int>(jb->get_button_index()));
|
|
||||||
#endif
|
|
||||||
_set_current_device(jb->get_device());
|
_set_current_device(jb->get_device());
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
device_input->get_ok()->set_text("Change");
|
device_input->get_ok()->set_text("Change");
|
||||||
#else
|
|
||||||
device_input->get_ok_button()->set_text("Change");
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
_set_current_device(0);
|
_set_current_device(0);
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
device_input->get_ok()->set_text("Add");
|
device_input->get_ok()->set_text("Add");
|
||||||
#else
|
|
||||||
device_input->get_ok_button()->set_text("Add");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
@ -682,11 +539,7 @@ void InputMapEditor::_action_button_pressed(Object *p_obj, int p_column, int p_i
|
|||||||
|
|
||||||
Array events = action["events"];
|
Array events = action["events"];
|
||||||
ERR_FAIL_INDEX(idx, events.size());
|
ERR_FAIL_INDEX(idx, events.size());
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
events.remove(idx);
|
events.remove(idx);
|
||||||
#else
|
|
||||||
events.remove_at(idx);
|
|
||||||
#endif
|
|
||||||
action["events"] = events;
|
action["events"] = events;
|
||||||
|
|
||||||
ProjectSettings::get_singleton()->set(name, action);
|
ProjectSettings::get_singleton()->set(name, action);
|
||||||
@ -729,13 +582,8 @@ void InputMapEditor::_update_actions() {
|
|||||||
|
|
||||||
Map<String, bool> collapsed;
|
Map<String, bool> collapsed;
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
if (input_editor->get_root() && input_editor->get_root()->get_children()) {
|
if (input_editor->get_root() && input_editor->get_root()->get_children()) {
|
||||||
for (TreeItem *item = input_editor->get_root()->get_children(); item; item = item->get_next()) {
|
for (TreeItem *item = input_editor->get_root()->get_children(); item; item = item->get_next()) {
|
||||||
#else
|
|
||||||
if (input_editor->get_root() && input_editor->get_root()->get_first_child()) {
|
|
||||||
for (TreeItem *item = input_editor->get_root()->get_first_child(); item; item = item->get_next()) {
|
|
||||||
#endif
|
|
||||||
collapsed[item->get_text(0)] = item->is_collapsed();
|
collapsed[item->get_text(0)] = item->is_collapsed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -762,11 +610,7 @@ void InputMapEditor::_update_actions() {
|
|||||||
TreeItem *item = input_editor->create_item(root);
|
TreeItem *item = input_editor->create_item(root);
|
||||||
item->set_text(0, name);
|
item->set_text(0, name);
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
item->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
|
item->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
|
||||||
#else
|
|
||||||
item->set_custom_bg_color(0, input_editor->get_theme_color("prop_subsection", "Editor"));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (collapsed.has(name))
|
if (collapsed.has(name))
|
||||||
item->set_collapsed(collapsed[name]);
|
item->set_collapsed(collapsed[name]);
|
||||||
@ -776,11 +620,7 @@ void InputMapEditor::_update_actions() {
|
|||||||
item->set_range_config(1, 0.0, 1.0, 0.01);
|
item->set_range_config(1, 0.0, 1.0, 0.01);
|
||||||
item->set_range(1, action["deadzone"]);
|
item->set_range(1, action["deadzone"]);
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
item->set_custom_bg_color(1, get_color("prop_subsection", "Editor"));
|
item->set_custom_bg_color(1, get_color("prop_subsection", "Editor"));
|
||||||
#else
|
|
||||||
item->set_custom_bg_color(1, input_editor->get_theme_color("prop_subsection", "Editor"));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
item->add_button(2, _add_texture, 1, false, "Add Event");
|
item->add_button(2, _add_texture, 1, false, "Add Event");
|
||||||
|
|
||||||
@ -793,11 +633,7 @@ void InputMapEditor::_update_actions() {
|
|||||||
|
|
||||||
Ref<InputEventKey> k = event;
|
Ref<InputEventKey> k = event;
|
||||||
if (k.is_valid()) {
|
if (k.is_valid()) {
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
const String str = keycode_get_string(k->get_scancode_with_modifiers());
|
const String str = keycode_get_string(k->get_scancode_with_modifiers());
|
||||||
#else
|
|
||||||
const String str = keycode_get_string(k->get_keycode_with_modifiers());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
action2->set_text(0, str);
|
action2->set_text(0, str);
|
||||||
action2->set_icon(0, _keyboard_texture);
|
action2->set_icon(0, _keyboard_texture);
|
||||||
@ -807,11 +643,7 @@ void InputMapEditor::_update_actions() {
|
|||||||
|
|
||||||
if (jb.is_valid()) {
|
if (jb.is_valid()) {
|
||||||
String str = _get_device_string(jb->get_device()) + ", Button " + itos(static_cast<int>(jb->get_button_index()));
|
String str = _get_device_string(jb->get_device()) + ", Button " + itos(static_cast<int>(jb->get_button_index()));
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
if (jb->get_button_index() >= 0 && jb->get_button_index() < JOY_BUTTON_MAX)
|
if (jb->get_button_index() >= 0 && jb->get_button_index() < JOY_BUTTON_MAX)
|
||||||
#else
|
|
||||||
if (static_cast<int>(jb->get_button_index()) >= 0 && static_cast<int>(jb->get_button_index()) < static_cast<int>(JoyButton::MAX))
|
|
||||||
#endif
|
|
||||||
str += String() + " (" + _button_names[static_cast<int>(jb->get_button_index())] + ").";
|
str += String() + " (" + _button_names[static_cast<int>(jb->get_button_index())] + ").";
|
||||||
else
|
else
|
||||||
str += ".";
|
str += ".";
|
||||||
@ -822,7 +654,6 @@ void InputMapEditor::_update_actions() {
|
|||||||
|
|
||||||
Ref<InputEventMouseButton> mb = event;
|
Ref<InputEventMouseButton> mb = event;
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
if (mb.is_valid()) {
|
if (mb.is_valid()) {
|
||||||
String str = _get_device_string(mb->get_device()) + ", ";
|
String str = _get_device_string(mb->get_device()) + ", ";
|
||||||
switch (mb->get_button_index()) {
|
switch (mb->get_button_index()) {
|
||||||
@ -844,29 +675,6 @@ void InputMapEditor::_update_actions() {
|
|||||||
default:
|
default:
|
||||||
str += "Button " + itos(mb->get_button_index()) + ".";
|
str += "Button " + itos(mb->get_button_index()) + ".";
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (mb.is_valid()) {
|
|
||||||
String str = _get_device_string(mb->get_device()) + ", ";
|
|
||||||
switch (mb->get_button_index()) {
|
|
||||||
case MouseButton::LEFT:
|
|
||||||
str += "Left Button.";
|
|
||||||
break;
|
|
||||||
case MouseButton::RIGHT:
|
|
||||||
str += "Right Button.";
|
|
||||||
break;
|
|
||||||
case MouseButton::MIDDLE:
|
|
||||||
str += "Middle Button.";
|
|
||||||
break;
|
|
||||||
case MouseButton::WHEEL_UP:
|
|
||||||
str += "Wheel Up.";
|
|
||||||
break;
|
|
||||||
case MouseButton::WHEEL_DOWN:
|
|
||||||
str += "Wheel Down.";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
str += "Button " + itos(static_cast<int>(mb->get_button_index())) + ".";
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
action2->set_text(0, str);
|
action2->set_text(0, str);
|
||||||
action2->set_icon(0, _mouse_texture);
|
action2->set_icon(0, _mouse_texture);
|
||||||
@ -1103,18 +911,11 @@ InputMapEditor::InputMapEditor() {
|
|||||||
input_editor->set_column_title(0, "Action");
|
input_editor->set_column_title(0, "Action");
|
||||||
input_editor->set_column_title(1, "Deadzone");
|
input_editor->set_column_title(1, "Deadzone");
|
||||||
input_editor->set_column_expand(1, false);
|
input_editor->set_column_expand(1, false);
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
input_editor->set_column_min_width(1, 80);
|
input_editor->set_column_min_width(1, 80);
|
||||||
#else
|
|
||||||
input_editor->set_column_custom_minimum_width(1, 80);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
input_editor->set_column_expand(2, false);
|
input_editor->set_column_expand(2, false);
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
input_editor->set_column_min_width(2, 50);
|
input_editor->set_column_min_width(2, 50);
|
||||||
#else
|
|
||||||
input_editor->set_column_custom_minimum_width(2, 50);
|
|
||||||
#endif
|
|
||||||
input_editor->CONNECT("item_edited", this, InputMapEditor, _action_edited);
|
input_editor->CONNECT("item_edited", this, InputMapEditor, _action_edited);
|
||||||
input_editor->CONNECT("item_activated", this, InputMapEditor, _action_activated);
|
input_editor->CONNECT("item_activated", this, InputMapEditor, _action_activated);
|
||||||
input_editor->CONNECT("cell_selected", this, InputMapEditor, _action_selected);
|
input_editor->CONNECT("cell_selected", this, InputMapEditor, _action_selected);
|
||||||
@ -1126,28 +927,19 @@ InputMapEditor::InputMapEditor() {
|
|||||||
popup_add->CONNECT("id_pressed", this, InputMapEditor, _add_item);
|
popup_add->CONNECT("id_pressed", this, InputMapEditor, _add_item);
|
||||||
|
|
||||||
press_a_key = memnew(ConfirmationDialog);
|
press_a_key = memnew(ConfirmationDialog);
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
press_a_key->set_focus_mode(FOCUS_ALL);
|
press_a_key->set_focus_mode(FOCUS_ALL);
|
||||||
#endif
|
|
||||||
add_child(press_a_key);
|
add_child(press_a_key);
|
||||||
|
|
||||||
Label *l = memnew(Label);
|
Label *l = memnew(Label);
|
||||||
l->set_text("Press a Key...");
|
l->set_text("Press a Key...");
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
l->set_align(Label::ALIGN_CENTER);
|
l->set_align(Label::ALIGN_CENTER);
|
||||||
#else
|
|
||||||
l->set_vertical_alignment(VerticalAlignment::VERTICAL_ALIGNMENT_CENTER);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
l->set_anchors_and_margins_preset(Control::PRESET_WIDE);
|
l->set_anchors_and_margins_preset(Control::PRESET_WIDE);
|
||||||
l->set_margin(MARGIN_TOP, 20);
|
l->set_margin(MARGIN_TOP, 20);
|
||||||
l->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_BEGIN, 30);
|
l->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_BEGIN, 30);
|
||||||
press_a_key->get_ok()->set_disabled(true);
|
press_a_key->get_ok()->set_disabled(true);
|
||||||
#else
|
|
||||||
press_a_key->get_ok_button()->set_disabled(true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
press_a_key_label = l;
|
press_a_key_label = l;
|
||||||
press_a_key->add_child(l);
|
press_a_key->add_child(l);
|
||||||
@ -1157,11 +949,7 @@ InputMapEditor::InputMapEditor() {
|
|||||||
device_input = memnew(ConfirmationDialog);
|
device_input = memnew(ConfirmationDialog);
|
||||||
add_child(device_input);
|
add_child(device_input);
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
device_input->get_ok()->set_text("Add");
|
device_input->get_ok()->set_text("Add");
|
||||||
#else
|
|
||||||
device_input->get_ok_button()->set_text("Add");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
device_input->CONNECT("confirmed", this, InputMapEditor, _device_input_add);
|
device_input->CONNECT("confirmed", this, InputMapEditor, _device_input_add);
|
||||||
|
|
||||||
|
@ -64,24 +64,14 @@ void TouchButton::_input(Ref<InputEvent> p_event) {
|
|||||||
get_viewport()->set_input_as_handled();
|
get_viewport()->set_input_as_handled();
|
||||||
|
|
||||||
Ref<InputEventMouseButton> ev;
|
Ref<InputEventMouseButton> ev;
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
ev.instance();
|
ev.instance();
|
||||||
#else
|
|
||||||
ev.instantiate();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
ev->set_button_index(BUTTON_LEFT);
|
ev->set_button_index(BUTTON_LEFT);
|
||||||
#else
|
|
||||||
ev->set_button_index(MouseButton::LEFT);
|
|
||||||
#endif
|
|
||||||
ev->set_pressed(b->is_pressed());
|
ev->set_pressed(b->is_pressed());
|
||||||
ev->set_position(b->get_position());
|
ev->set_position(b->get_position());
|
||||||
ev->set_global_position(b->get_position());
|
ev->set_global_position(b->get_position());
|
||||||
|
|
||||||
#if VERSION_MAJOR <= 3
|
|
||||||
BaseButton::_gui_input(ev);
|
BaseButton::_gui_input(ev);
|
||||||
#endif
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -107,9 +97,7 @@ void TouchButton::_gui_input(Ref<InputEvent> p_event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VERSION_MAJOR <= 3
|
|
||||||
BaseButton::_gui_input(p_event);
|
BaseButton::_gui_input(p_event);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TouchButton::_unhandled_input(Ref<InputEvent> p_event) {
|
void TouchButton::_unhandled_input(Ref<InputEvent> p_event) {
|
||||||
@ -118,9 +106,7 @@ void TouchButton::_unhandled_input(Ref<InputEvent> p_event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VERSION_MAJOR <= 3
|
|
||||||
Button::_unhandled_input(p_event);
|
Button::_unhandled_input(p_event);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TouchButton::_bind_methods() {
|
void TouchButton::_bind_methods() {
|
||||||
|
@ -22,16 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "core/version.h"
|
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
#include "core/config/engine.h"
|
|
||||||
#else
|
|
||||||
#include "core/engine.h"
|
#include "core/engine.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "scene/gui/button.h"
|
#include "scene/gui/button.h"
|
||||||
|
@ -77,11 +77,7 @@ void VoxelLibrarySimple::voxel_surface_set(const int index, Ref<VoxelSurface> va
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VoxelLibrarySimple::voxel_surface_remove(const int index) {
|
void VoxelLibrarySimple::voxel_surface_remove(const int index) {
|
||||||
#if VERSION_MAJOR <= 3
|
|
||||||
_voxel_surfaces.remove(index);
|
_voxel_surfaces.remove(index);
|
||||||
#else
|
|
||||||
_voxel_surfaces.remove_at(index);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int VoxelLibrarySimple::voxel_surface_get_num() const {
|
int VoxelLibrarySimple::voxel_surface_get_num() const {
|
||||||
|
@ -32,8 +32,8 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "../../library/voxel_material_cache.h"
|
#include "../../library/voxel_material_cache.h"
|
||||||
#include "../default/voxel_chunk_default.h"
|
#include "../default/voxel_chunk_default.h"
|
||||||
#include "servers/physics_server.h"
|
|
||||||
#include "scene/resources/world.h"
|
#include "scene/resources/world.h"
|
||||||
|
#include "servers/physics_server.h"
|
||||||
|
|
||||||
#ifdef MESH_DATA_RESOURCE_PRESENT
|
#ifdef MESH_DATA_RESOURCE_PRESENT
|
||||||
#include "../../../mesh_data_resource/mesh_data_resource.h"
|
#include "../../../mesh_data_resource/mesh_data_resource.h"
|
||||||
@ -96,12 +96,7 @@ void VoxelPropJob::phase_physics_process() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
RID body = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC);
|
RID body = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC);
|
||||||
#else
|
|
||||||
RID body = PhysicsServer::get_singleton()->body_create();
|
|
||||||
PhysicsServer::get_singleton()->body_set_mode(body, PhysicsServer::BODY_MODE_STATIC);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Transform transform = chunk->mesh_data_resource_get_transform(i);
|
Transform transform = chunk->mesh_data_resource_get_transform(i);
|
||||||
transform *= offset;
|
transform *= offset;
|
||||||
|
Loading…
Reference in New Issue
Block a user