More version check cleanups.

This commit is contained in:
Relintai 2022-03-18 03:46:14 +01:00
parent 32acbf4252
commit 1f0652741c
53 changed files with 2530 additions and 1924 deletions

View File

@ -115,11 +115,7 @@ Dictionary SpeciesInstance::_to_dict() {
return dict;
}
void SpeciesInstance::_from_dict(const Dictionary &dict) {
#if VERSION_MAJOR > 3
ERR_FAIL_COND(dict.is_empty());
#else
ERR_FAIL_COND(dict.empty());
#endif
_id = dict.get("id", 0);
set_species_path(dict.get("species_path", ""));

View File

@ -124,7 +124,6 @@ void ESSResourceDBFolders::add_resource(const Ref<Resource> &resource) {
Ref<Resource> ESSResourceDBFolders::load_resource(const String &path, const String &type_hint) {
_ResourceLoader *rl = _ResourceLoader::get_singleton();
#if VERSION_MAJOR < 4
Ref<ResourceInteractiveLoader> resl = rl->load_interactive(path, type_hint);
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();
return resl->get_resource();
#else
return rl->load(path, type_hint);
#endif
}
ESSResourceDBFolders::ESSResourceDBFolders() {

View File

@ -30,11 +30,7 @@ void ESSEditorPlugin::fix_ids(Variant param) {
ESSEditorPlugin::ESSEditorPlugin(EditorNode *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");
#endif
}
ESSEditorPlugin::~ESSEditorPlugin() {

View File

@ -39,11 +39,7 @@ Dictionary EntityDataContainer::_to_dict() {
return dict;
}
void EntityDataContainer::_from_dict(const Dictionary &dict) {
#if VERSION_MAJOR > 3
ERR_FAIL_COND(dict.is_empty());
#else
ERR_FAIL_COND(dict.empty());
#endif
}
EntityDataContainer::EntityDataContainer() {

View File

@ -286,11 +286,7 @@ Dictionary EntityResource::_to_dict() {
return dict;
}
void EntityResource::_from_dict(const Dictionary &dict) {
#if VERSION_MAJOR > 3
ERR_FAIL_COND(dict.is_empty());
#else
ERR_FAIL_COND(dict.empty());
#endif
_dirty = dict.get("dirty", false);
_should_process = dict.get("should_process", false);

View File

@ -205,11 +205,7 @@ Dictionary SpellCastInfo::to_dict() {
return dict;
}
void SpellCastInfo::from_dict(const Dictionary &dict) {
#if VERSION_MAJOR > 3
ERR_FAIL_COND(dict.is_empty());
#else
ERR_FAIL_COND(dict.empty());
#endif
_has_cast_time = dict.get("has_cast_time", true);
_cast_time = dict.get("cast_time", 0);

View File

@ -201,11 +201,7 @@ Dictionary SpellDamageInfo::to_dict() {
return dict;
}
void SpellDamageInfo::from_dict(const Dictionary &dict) {
#if VERSION_MAJOR > 3
ERR_FAIL_COND(dict.is_empty());
#else
ERR_FAIL_COND(dict.empty());
#endif
_immune = dict.get("immune", true);
_damage = dict.get("damage", 0);

View File

@ -202,11 +202,7 @@ Dictionary SpellHealInfo::to_dict() {
return dict;
}
void SpellHealInfo::from_dict(const Dictionary &dict) {
#if VERSION_MAJOR > 3
ERR_FAIL_COND(dict.is_empty());
#else
ERR_FAIL_COND(dict.empty());
#endif
_immune = dict.get("immune", true);
_heal = dict.get("heal", 0);
@ -237,7 +233,6 @@ SpellHealInfo::~SpellHealInfo() {
}
void SpellHealInfo::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_immune"), &SpellHealInfo::get_immune);
ClassDB::bind_method(D_METHOD("set_immune", "value"), &SpellHealInfo::set_immune);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "immune"), "set_immune", "get_immune");

View File

@ -93,11 +93,7 @@ Dictionary ActionBarButtonEntry::to_dict() const {
return dict;
}
void ActionBarButtonEntry::from_dict(const Dictionary &dict) {
#if VERSION_MAJOR > 3
ERR_FAIL_COND(dict.is_empty());
#else
ERR_FAIL_COND(dict.empty());
#endif
_action_bar_id = dict.get("action_bar_id", 0);
_slot_id = dict.get("slot_id", 0);

View File

@ -117,11 +117,7 @@ Dictionary ActionBarEntry::to_dict() const {
return dict;
}
void ActionBarEntry::from_dict(const Dictionary &dict) {
#if VERSION_MAJOR > 3
ERR_FAIL_COND(dict.is_empty());
#else
ERR_FAIL_COND(dict.empty());
#endif
for (int i = 0; i < _button_entries.size(); ++i) {
_button_entries.get(i)->set_owner(NULL);

View File

@ -134,13 +134,8 @@ Dictionary ActionBarProfile::to_dict() const {
return dict;
}
void ActionBarProfile::from_dict(const Dictionary &dict) {
#if VERSION_MAJOR > 3
if (dict.is_empty())
return;
#else
if (dict.empty())
return;
#endif
for (int i = 0; i < _action_bars.size(); ++i) {
_action_bars.get(i)->set_owner(NULL);

View File

@ -127,11 +127,7 @@ Dictionary ClassProfile::to_dict() const {
return dict;
}
void ClassProfile::from_dict(const Dictionary &dict) {
#if VERSION_MAJOR > 3
ERR_FAIL_COND(dict.is_empty());
#else
ERR_FAIL_COND(dict.empty());
#endif
_character_class_name = dict.get("character_class_name", "");
_class_path = dict.get("class_path", "");

View File

@ -146,11 +146,7 @@ Dictionary PlayerProfile::to_dict() const {
return dict;
}
void PlayerProfile::from_dict(const Dictionary &dict) {
#if VERSION_MAJOR > 3
ERR_FAIL_COND(dict.is_empty());
#else
ERR_FAIL_COND(dict.empty());
#endif
clear_class_profiles();

View File

@ -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) {
_ResourceLoader *rl = _ResourceLoader::get_singleton();
#if VERSION_MAJOR < 4
Ref<ResourceInteractiveLoader> resl = rl->load_interactive(path, type_hint);
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();
return resl->get_resource();
#else
return rl->load(path, type_hint);
#endif
}
void ESS::_bind_methods() {
@ -910,11 +906,7 @@ ESS::ESS() {
#endif
#ifdef TEXTURE_PACKER_PRESENT
#if VERSION_MAJOR < 4
_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);
_keep_original_atlases = GLOBAL_DEF("ess/material_cache/keep_original_atlases", false);

View File

@ -165,11 +165,7 @@ Dictionary ProfileManager::to_dict() const {
return dict;
}
void ProfileManager::from_dict(const Dictionary &dict) {
#if VERSION_MAJOR > 3
ERR_FAIL_COND(dict.is_empty());
#else
ERR_FAIL_COND(dict.empty());
#endif
clears_player_profiles();

View File

@ -190,11 +190,7 @@ Dictionary EntityCreateInfo::_to_dict() {
return dict;
}
void EntityCreateInfo::_from_dict(const Dictionary &dict) {
#if VERSION_MAJOR > 3
ERR_FAIL_COND(dict.is_empty());
#else
ERR_FAIL_COND(dict.empty());
#endif
_guid = dict.get("guid", 0);
_networked = dict.get("networked", false);

View File

@ -1,11 +1,5 @@
#include "fastnoise_noise_params.h"
#include "core/version.h"
#if VERSION_MAJOR >= 4
#define REAL FLOAT
#endif
void FastnoiseNoiseParams::setup_noise(Ref<FastNoise> noise) {
noise->set_seed(_seed);
noise->set_noise_type(_noise_type);

View File

@ -1,13 +1,7 @@
#ifndef 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"
#endif
#include "noise.h"

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +1,12 @@
#ifndef 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/ustring.h"
#endif
#include "lib/FastNoise.h"
#include "core/version.h"
#if VERSION_MAJOR < 4
#include "core/pool_vector.h"
#else
typedef PackedInt64Array PoolIntArray;
#endif
typedef fastnoise::FastNoise _FastNoise;
@ -33,9 +20,9 @@ public:
static const String BINDING_STRING_CELLULAR_DISTANCE_FUNCTION;
static const String BINDING_STRING_CELLULAR_RETURN_TYPE;
// Enums Godot-style (same values)
// Enums Godot-style (same values)
enum Type {
enum Type {
TYPE_VALUE = _FastNoise::Value,
TYPE_VALUE_FRACTAL = _FastNoise::ValueFractal,
TYPE_PERLIN = _FastNoise::Perlin,
@ -46,45 +33,45 @@ public:
TYPE_WHITE_NOISE = _FastNoise::WhiteNoise,
TYPE_CUBIC = _FastNoise::Cubic,
TYPE_CUBIC_FRACTAL = _FastNoise::CubicFractal
};
};
enum Interpolation {
enum Interpolation {
INTERP_LINEAR = _FastNoise::Linear,
INTERP_QUINTIC = _FastNoise::Quintic,
INTERP_HERMITE = _FastNoise::Hermite
};
};
enum FractalType {
FRACTAL_FBM = _FastNoise::FBM,
FRACTAL_BILLOW = _FastNoise::Billow,
FRACTAL_RIGID_MULTI = _FastNoise::RigidMulti
};
enum FractalType {
FRACTAL_FBM = _FastNoise::FBM,
FRACTAL_BILLOW = _FastNoise::Billow,
FRACTAL_RIGID_MULTI = _FastNoise::RigidMulti
};
enum CellularDistanceFunction {
DISTANCE_EUCLIDEAN = _FastNoise::Euclidean,
DISTANCE_MANHATTAN = _FastNoise::Manhattan,
DISTANCE_NATURAL = _FastNoise::Natural
};
enum CellularDistanceFunction {
DISTANCE_EUCLIDEAN = _FastNoise::Euclidean,
DISTANCE_MANHATTAN = _FastNoise::Manhattan,
DISTANCE_NATURAL = _FastNoise::Natural
};
enum CellularReturnType {
RETURN_CELL_VALUE = _FastNoise::CellValue,
RETURN_NOISE_LOOKUP = _FastNoise::NoiseLookup,
enum CellularReturnType {
RETURN_CELL_VALUE = _FastNoise::CellValue,
RETURN_NOISE_LOOKUP = _FastNoise::NoiseLookup,
RETURN_DISTANCE = _FastNoise::Distance,
RETURN_DISTANCE_2 = _FastNoise::Distance2,
RETURN_DISTANCE_2_ADD = _FastNoise::Distance2Add,
RETURN_DISTANCE_2_SUB = _FastNoise::Distance2Sub,
RETURN_DISTANCE_2_MUL = _FastNoise::Distance2Mul,
RETURN_DISTANCE_2_DIV = _FastNoise::Distance2Div
};
};
FastNoise();
FastNoise();
// Methods (Godot-style mappings to FastNoise)
// Methods (Godot-style mappings to FastNoise)
int get_seed() const { return _noise.GetSeed(); }
void set_seed(int seed) { _noise.SetSeed(seed); }
void set_seed(int seed) { _noise.SetSeed(seed); }
void set_noise_type(Type noise_type) { _noise.SetNoiseType((_FastNoise::NoiseType)noise_type); }
void set_noise_type(Type noise_type) { _noise.SetNoiseType((_FastNoise::NoiseType)noise_type); }
Type get_noise_type() const { return (Type)_noise.GetNoiseType(); }
void set_interpolation(Interpolation interp) { _noise.SetInterp((_FastNoise::Interp)interp); }
@ -111,7 +98,7 @@ public:
void set_cellular_return_type(CellularReturnType ret) { _noise.SetCellularReturnType((_FastNoise::CellularReturnType)ret); }
CellularReturnType get_cellular_return_type() const { return (CellularReturnType)_noise.GetCellularReturnType(); }
void set_cellular_noise_lookup(Ref<FastNoise> other_noise);
void set_cellular_noise_lookup(Ref<FastNoise> other_noise);
Ref<FastNoise> get_cellular_noise_lookup() const { return _cellular_lookup_ref; }
void set_cellular_distance_2_indices(int index0, int index1);
@ -123,46 +110,44 @@ public:
void set_gradient_perturbation_amplitude(real_t amp) { _noise.SetGradientPerturbAmp(amp); }
real_t get_gradient_perturbation_amplitude() const { return _noise.GetGradientPerturbAmp(); }
// 2D
// 2D
float get_noise_2d(float x, float y) { return _noise.GetNoise(x, y); }
float get_noise_2d(float x, float y) { return _noise.GetNoise(x, y); }
//float get_gradient_2d(float x, float y) { return _noise.GetGradient(x, y); }
//float get_simplex_2d(float x, float y) { return _noise.GetSimplex(x, y); }
//float get_cellular_2d(float x, float y) { return _noise.GetCellular(x, y); }
//float get_cellular_hq_2d(float x, float y) { return _noise.GetCellularHQ(x, y); }
//float get_white_noise_2d(float x, float y) { return _noise.GetWhiteNoise(x, y); }
//float get_value_2d(float x, float y) { return _noise.GetValue(x, y); }
//float get_gradient_2d(float x, float y) { return _noise.GetGradient(x, y); }
//float get_simplex_2d(float x, float y) { return _noise.GetSimplex(x, y); }
//float get_cellular_2d(float x, float y) { return _noise.GetCellular(x, y); }
//float get_cellular_hq_2d(float x, float y) { return _noise.GetCellularHQ(x, y); }
//float get_white_noise_2d(float x, float y) { return _noise.GetWhiteNoise(x, y); }
//float get_value_2d(float x, float y) { return _noise.GetValue(x, y); }
// 3D
// 3D
float get_noise_3d(float x, float y, float z) { return _noise.GetNoise(x, y, z); }
float get_noise_3d(float x, float y, float z) { return _noise.GetNoise(x, y, z); }
//float get_gradient_3d(float x, float y, float z) { return _noise.GetGradient(x, y, z); }
//float get_simplex_3d(float x, float y, float z) { return _noise.GetSimplex(x, y, z); }
//float get_cellular_3d(float x, float y, float z) { return _noise.GetCellular(x, y, z); }
//float get_cellular_hq_3d(float x, float y, float z) { return _noise.GetCellularHQ(x, y, z); }
//float get_white_noise_3d(float x, float y, float z) { return _noise.GetWhiteNoise(x, y, z); }
//float get_value_2d(float x, float y, float z) { return _noise.GetValue(x, y, z); }
//float get_gradient_3d(float x, float y, float z) { return _noise.GetGradient(x, y, z); }
//float get_simplex_3d(float x, float y, float z) { return _noise.GetSimplex(x, y, z); }
//float get_cellular_3d(float x, float y, float z) { return _noise.GetCellular(x, y, z); }
//float get_cellular_hq_3d(float x, float y, float z) { return _noise.GetCellularHQ(x, y, z); }
//float get_white_noise_3d(float x, float y, float z) { return _noise.GetWhiteNoise(x, y, z); }
//float get_value_2d(float x, float y, float z) { return _noise.GetValue(x, y, z); }
// 4D
// 4D
float get_simplex_4d(float x, float y, float z, float w) { return _noise.GetSimplex(x, y, z, w); }
float get_white_noise_4d(float x, float y, float z, float w) { return _noise.GetWhiteNoise(x, y, z, w); }
float get_simplex_4d(float x, float y, float z, float w) { return _noise.GetSimplex(x, y, z, w); }
float get_white_noise_4d(float x, float y, float z, float w) { return _noise.GetWhiteNoise(x, y, z, w); }
// Convenience
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); }
// Convenience
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); }
protected:
static void _bind_methods();
static void _bind_methods();
private:
_FastNoise _noise;
Ref<FastNoise> _cellular_lookup_ref;
_FastNoise _noise;
Ref<FastNoise> _cellular_lookup_ref;
};
// Make Variant happy with custom enums
@ -172,6 +157,4 @@ VARIANT_ENUM_CAST(FastNoise::Interpolation)
VARIANT_ENUM_CAST(FastNoise::CellularDistanceFunction)
VARIANT_ENUM_CAST(FastNoise::CellularReturnType)
#endif // FASTNOISE_NOISE_H

View File

@ -2,25 +2,15 @@
#include "core/version.h"
#if VERSION_MAJOR < 4
#include "core/class_db.h"
#else
#include "core/object/class_db.h"
#endif
#include "noise.h"
#include "fastnoise_noise_params.h"
#include "noise.h"
void register_fastnoise_types() {
ClassDB::register_class<FastNoise>();
ClassDB::register_class<FastnoiseNoiseParams>();
}
void unregister_fastnoise_types() {
}

View File

@ -22,16 +22,7 @@ SOFTWARE.
#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"
#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";
@ -85,13 +76,8 @@ int MeshDataResource::get_collision_shape_count() const {
Vector<Variant> MeshDataResource::get_collision_shapes() {
Vector<Variant> r;
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].shape.get_ref_ptr());
#else
r.push_back(_collision_shapes[i].transform);
r.push_back(_collision_shapes[i].shape);
#endif
}
return r;
}
@ -296,12 +282,9 @@ void MeshDataResource::recompute_aabb() {
if (vertices_2d.size() > 0) {
AABB aabb;
#if VERSION_MAJOR < 4
PoolVector<Vector2>::Read r = vertices_2d.read();
const Vector2 *vtx = r.ptr();
#else
const Vector2 *vtx = vertices.ptr();
#endif
int len = vertices_2d.size();
aabb.position = Vector3(vtx[0].x, vtx[0].y, 0);
@ -320,12 +303,8 @@ void MeshDataResource::recompute_aabb() {
return;
}
#if VERSION_MAJOR < 4
PoolVector<Vector3>::Read r = vertices.read();
const Vector3 *vtx = r.ptr();
#else
const Vector3 *vtx = vertices.ptr();
#endif
AABB aabb;
for (int i = 0; i < len; i++) {

View File

@ -22,39 +22,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
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/variant.h"
#include "core/pool_vector.h"
#endif
#include "core/resource.h"
#include "core/variant.h"
#include "core/version.h"
#include "scene/resources/mesh.h"
#if VERSION_MAJOR < 4
#include "scene/resources/shape.h"
#else
#include "scene/resources/shape_3d.h"
#define Shape Shape3D
#endif
class MeshDataResource : public Resource {
GDCLASS(MeshDataResource, Resource);

View File

@ -31,11 +31,7 @@ void MeshDataResourceCollection::add_mdr(Ref<MeshDataResource> mdr) {
Vector<Variant> MeshDataResourceCollection::get_mdrs() {
Vector<Variant> r;
for (int i = 0; i < _mdrs.size(); i++) {
#if VERSION_MAJOR < 4
r.push_back(_mdrs[i].get_ref_ptr());
#else
r.push_back(_mdrs[i]);
#endif
}
return r;
}

View File

@ -22,18 +22,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#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/vector.h"
#endif
#include "mesh_data_resource.h"
@ -53,7 +45,7 @@ protected:
static void _bind_methods();
private:
Vector<Ref<MeshDataResource> > _mdrs;
Vector<Ref<MeshDataResource>> _mdrs;
};
#endif

View File

@ -5,15 +5,9 @@
#include "core/version.h"
#include "scene/resources/texture.h"
#if VERSION_MAJOR < 4
#include "core/image.h"
#define GET_WORLD get_world
#else
#include "core/io/image.h"
#define GET_WORLD get_world_3d
#endif
#if TEXTURE_PACKER_PRESENT
#include "../../texture_packer/texture_resource/packer_image_resource.h"
@ -184,11 +178,7 @@ void MeshDataInstance::setup_material_texture() {
Ref<ImageTexture> tex;
tex.instance();
#if VERSION_MAJOR < 4
tex->create_from_image(i, 0);
#else
tex->create_from_image(i);
#endif
if (sm.is_valid()) {
sm->set_texture(SpatialMaterial::TEXTURE_ALBEDO, tex);
@ -214,9 +204,7 @@ MeshDataInstance::MeshDataInstance() {
_snap_to_mesh = false;
_snap_axis = Vector3(0, -1, 0);
#if VERSION_MINOR >= 4
set_portal_mode(PORTAL_MODE_GLOBAL);
#endif
//set_notify_transform(true);
}

View File

@ -22,21 +22,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "core/version.h"
#include "scene/resources/texture.h"
#if VERSION_MAJOR < 4
#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"

View File

@ -5,11 +5,7 @@
#include "core/version.h"
#include "scene/resources/texture.h"
#if VERSION_MAJOR < 4
#include "core/image.h"
#else
#include "core/io/image.h"
#endif
#if TEXTURE_PACKER_PRESENT
#include "../../texture_packer/texture_resource/packer_image_resource.h"

View File

@ -22,10 +22,6 @@ SOFTWARE.
#include "mdr_import_plugin_base.h"
#include "core/version.h"
#if VERSION_MAJOR < 4
#include "scene/resources/box_shape.h"
#include "scene/resources/capsule_shape.h"
#include "scene/resources/concave_polygon_shape.h"
@ -34,41 +30,6 @@ SOFTWARE.
#include "scene/resources/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
#include "../../mesh_utils/mesh_utils.h"
#endif
@ -517,11 +478,7 @@ void MDRImportPluginBase::add_colliders(Ref<MeshDataResource> mdr, Ref<ArrayMesh
AABB aabb = m->get_aabb();
Vector3 size = aabb.get_size();
#if VERSION_MAJOR > 3
shape->set_size(size * 0.5);
#else
shape->set_extents(size * 0.5);
#endif
Vector3 pos = aabb.position;
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)) {
Ref<BoxShape> bs = shape;
#if VERSION_MAJOR > 3
bs->set_size(bs->get_size() * scale);
#else
bs->set_extents(bs->get_extents() * scale);
#endif
}
if (Object::cast_to<CapsuleShape>(*shape)) {

View File

@ -27,13 +27,8 @@ SOFTWARE.
#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/ustring.h"
#endif
#include "../mesh_data_resource_collection.h"
#include "core/io/resource_saver.h"
@ -49,21 +44,9 @@ SOFTWARE.
#include "core/version.h"
#if VERSION_MAJOR < 4
#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"
#endif
#else
#include "../../gltf/editor_scene_importer_gltf.h"
#include "scene/3d/mesh_instance_3d.h"
#define MeshInstance MeshInstance3D
#endif
class MDRImportPluginBase : public EditorImportPlugin {
GDCLASS(MDRImportPluginBase, EditorImportPlugin);

View File

@ -60,11 +60,7 @@ Error EditorImportGLTFMdr::import(const String &p_source_file, const String &p_s
Error erri;
#if VERSION_MAJOR == 3 && VERSION_MINOR > 4
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);

View File

@ -22,18 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
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"
#endif
#include "core/ustring.h"
#include "../plugin/mdr_import_plugin_base.h"
@ -47,26 +37,10 @@ SOFTWARE.
#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"
#endif
#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 {
GDCLASS(EditorImportGLTFMdr, MDRImportPluginBase);
public:

View File

@ -22,23 +22,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/string/ustring.h"
#else
#include "core/ustring.h"
#endif
#include "editor/editor_plugin.h"
#include "editor_import_gltf_mdr.h"
class EditorPluginGLTFMdr : public EditorPlugin {
GDCLASS(EditorPluginGLTFMdr, EditorPlugin);
public:

View File

@ -27,16 +27,8 @@ SOFTWARE.
#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"
#endif
#include "core/reference.h"
#include "simplify.h"

View File

@ -24,26 +24,14 @@ SOFTWARE.
*/
#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/color.h"
#include "core/reference.h"
#include "core/vector.h"
#include "core/color.h"
#endif
#include "defines.h"
#include pool_vector_h
include_pool_vector
#include mesh_instance_h
#include "core/math/rect2.h"
@ -62,7 +50,6 @@ include_pool_vector
public:
struct Vertex {
Vector3 vertex;
Color color;
Vector3 normal; // normal, binormal, tangent

View File

@ -22,17 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "core/variant.h"
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/object/object.h"
#else
#include "core/object.h"
#endif
#include "scene/resources/texture.h"

View File

@ -26,11 +26,7 @@ SOFTWARE.
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/config/engine.h"
#else
#include "core/engine.h"
#endif
#include "fast_quadratic_mesh_simplifier.h"
#include "mesh_merger.h"

View File

@ -16,13 +16,8 @@
#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"
#endif
#include "core/ustring.h"
#include "core/math/vector2.h"
#include "core/math/vector3.h"
@ -34,18 +29,7 @@
#include <map>
#include <vector>
#include "core/version.h"
#if VERSION_MAJOR < 4
#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 {
@ -116,10 +100,13 @@ struct vec3f {
vec3f a = v, b = *this;
double dot = v.x * x + v.y * y + v.z * z;
double len = a.length() * b.length();
if (len == 0) len = 0.00001f;
if (len == 0)
len = 0.00001f;
double input = dot / len;
if (input < -1) input = -1;
if (input > 1) input = 1;
if (input < -1)
input = -1;
if (input > 1)
input = 1;
return (double)acos(input);
}
@ -127,7 +114,8 @@ struct vec3f {
vec3f a = v, b = *this;
double dot = a.x * b.x + a.y * b.y + a.z * b.z;
double len = a.length() * b.length();
if (len == 0) len = 1;
if (len == 0)
len = 1;
vec3f plane;
plane.cross(b, w);
@ -153,12 +141,18 @@ struct vec3f {
return *this;
}
inline void clamp(double min, double max) {
if (x < min) x = min;
if (y < min) y = min;
if (z < min) z = min;
if (x > max) x = max;
if (y > max) y = max;
if (z > max) z = max;
if (x < min)
x = min;
if (y < min)
y = min;
if (z < min)
z = min;
if (x > max)
x = max;
if (y > max)
y = max;
if (z > max)
z = max;
}
inline vec3f rot_z(double a) {
double yy = cos(a) * y + sin(a) * x;
@ -258,7 +252,6 @@ static double min(double v1, double v2) {
}
class SymetricMatrix {
public:
// Constructor
@ -344,7 +337,6 @@ static bool compare_border_vertex(const BorderVertex &i1, const BorderVertex &i2
}
class FQMS {
public:
struct Triangle {
int v[3];
@ -408,7 +400,8 @@ public:
int triangle_count = triangles.size();
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
if (iteration % 5 == 0) {
@ -448,7 +441,6 @@ public:
for (int j = 0; j < 3; ++j) {
if (t.err[j] < threshold) {
int i0 = t.v[j];
Vertex &v0 = vertices[i0];
int i1 = t.v[(j + 1) % 3];
@ -496,7 +488,8 @@ public:
if (tcount <= v0.tcount) {
// 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 {
// append
v0.tstart = tstart;
@ -508,7 +501,8 @@ public:
}
// done?
if (triangle_count - deleted_triangles <= target_count) break;
if (triangle_count - deleted_triangles <= target_count)
break;
}
}
// clean up mesh
@ -604,7 +598,8 @@ public:
if (tcount <= v0.tcount) {
// 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 {
// append
v0.tstart = tstart;
@ -628,7 +623,6 @@ public:
// 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) {
for (int k = 0; k < v0.tcount; ++k) {
Triangle &t = triangles[refs[v0.tstart + k].tid];
@ -648,12 +642,14 @@ public:
d1.normalize();
vec3f d2 = vertices[id2].p - p;
d2.normalize();
if (fabs(d1.dot(d2)) > 0.999) return true;
if (fabs(d1.dot(d2)) > 0.999)
return true;
vec3f n;
n.cross(d1, d2);
n.normalize();
deleted[k] = 0;
if (n.dot(t.n) < 0.2) return true;
if (n.dot(t.n) < 0.2)
return true;
}
return false;
}
@ -1018,7 +1014,6 @@ public:
double error = 0;
double det = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
if (det != 0 && !border) {
// 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.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 error3 = vertex_error(q, p3.x, p3.y, p3.z);
error = min(error1, min(error2, error3));
if (error1 == error) p_result = p1;
if (error2 == error) p_result = p2;
if (error3 == error) p_result = p3;
if (error1 == error)
p_result = p1;
if (error2 == error)
p_result = p2;
if (error3 == error)
p_result = p3;
}
return error;
}

View File

@ -72,7 +72,6 @@ void PropEditorPlugin::convert_scene(Node *root, const String &path) {
}
void PropEditorPlugin::find_room_points(Variant param) {
#if VERSION_MINOR >= 4
SceneTree *st = SceneTree::get_singleton();
if (st) {
@ -82,7 +81,6 @@ void PropEditorPlugin::find_room_points(Variant param) {
PropUtils::get_singleton()->generate_room_points_node(scene);
}
}
#endif
}
void PropEditorPlugin::_quick_convert_button_pressed() {

View File

@ -95,7 +95,6 @@ void PropUtils::_convert_tree(Ref<PropData> prop_data, Node *node, const Transfo
}
}
} else {
#if VERSION_MINOR >= 4
//only handle the first encountered room per prop
if (!prop_data->get_is_room()) {
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);
}
}
#endif
for (int i = 0; i < node->get_child_count(); ++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) {
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) {
ERR_FAIL_COND_V(!processor.is_valid(), 0);

View File

@ -279,10 +279,8 @@ TiledWall::TiledWall() {
_physics_body_rid = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC);
#if VERSION_MINOR >= 4
//temporary
set_portal_mode(PORTAL_MODE_GLOBAL);
#endif
_mesher.instance();
}

View File

@ -72,7 +72,6 @@ void Prop2DEditorPlugin::convert_scene(Node *root, const String &path) {
}
void Prop2DEditorPlugin::find_room_points(Variant param) {
#if VERSION_MINOR >= 4
SceneTree *st = SceneTree::get_singleton();
if (st) {
@ -82,7 +81,6 @@ void Prop2DEditorPlugin::find_room_points(Variant param) {
//Prop2DUtils::get_singleton()->generate_room_points_node(scene);
}
}
#endif
}
void Prop2DEditorPlugin::_quick_convert_button_pressed() {

View File

@ -35,12 +35,10 @@
#include "core/os/os.h"
#include "scene/2d/area_2d.h"
#include "scene/2d/collision_object_2d.h"
#include "servers/physics_2d_server.h"
#include "scene/resources/world_2d.h"
#include "servers/physics_2d_server.h"
#if VERSION_MINOR >= 5
#include "servers/navigation_2d_server.h"
#endif
int RTileMap::_get_quadrant_size() const {
if (y_sort_mode) {
@ -84,11 +82,7 @@ void RTileMap::_notification(int p_what) {
Quadrant &q = E->get();
if (navigation) {
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());
#endif
}
q.navpoly_ids.clear();
}
@ -172,11 +166,7 @@ void RTileMap::_update_quadrant_transform() {
if (navigation) {
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);
#endif
}
}
@ -403,11 +393,7 @@ void RTileMap::update_dirty_quadrants() {
if (navigation) {
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());
#endif
}
q.navpoly_ids.clear();
}
@ -654,20 +640,12 @@ void RTileMap::update_dirty_quadrants() {
xform.set_origin(offset.floor() + q.pos);
_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();
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_navpoly(region, navpoly);
#endif
Quadrant::NavPoly np;
#if VERSION_MINOR < 5
np.id = pid;
#else
np.region = region;
#endif
np.xform = xform;
q.navpoly_ids[E->key()] = np;
@ -861,11 +839,7 @@ void RTileMap::_erase_quadrant(Map<PosKey, Quadrant>::Element *Q) {
if (navigation) {
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());
#endif
}
q.navpoly_ids.clear();
}

View File

@ -30,15 +30,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "core/self_list.h"
#include "core/version.h"
#include "core/vset.h"
#include "scene/2d/navigation_2d.h"
#include "scene/2d/node_2d.h"
#include "tile_set.h"
#include "core/version.h"
#include "../fastnoise/noise.h"
@ -149,11 +146,7 @@ private:
SelfList<Quadrant> dirty_list;
struct NavPoly {
#if VERSION_MINOR < 5
int id;
#else
RID region;
#endif
Transform2D xform;
};

View File

@ -2133,18 +2133,10 @@ void RTileMapEditorPlugin::_notification(int p_what) {
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
switch ((int)EditorSettings::get_singleton()->get("editors/tile_map/editor_side")) {
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);
#endif
} break;
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);
#endif
} break;
}
}

View File

@ -26,11 +26,7 @@ SOFTWARE.
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/config/engine.h"
#else
#include "core/engine.h"
#endif
#include "thread_pool.h"
#include "thread_pool_execute_job.h"
@ -39,7 +35,6 @@ SOFTWARE.
static ThreadPool *thread_pool = NULL;
void register_thread_pool_types() {
ClassDB::register_class<ThreadPoolJob>();
ClassDB::register_class<ThreadPoolExecuteJob>();

View File

@ -27,27 +27,15 @@ SOFTWARE.
void BSInputEventKey::from_input_event_key(const Ref<InputEventKey> event) {
set_device(event->get_device());
#if VERSION_MAJOR < 4
set_shift(event->get_shift());
set_alt(event->get_alt());
set_control(event->get_control());
set_metakey(event->get_metakey());
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());
#if VERSION_MAJOR < 4
set_scancode(event->get_scancode());
#else
set_keycode(event->get_keycode());
#endif
set_unicode(event->get_unicode());
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())
return false;
#if VERSION_MAJOR < 4
uint32_t code = 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);
if (match) {

View File

@ -27,11 +27,7 @@ SOFTWARE.
#include "core/version.h"
#if VERSION_MAJOR < 4
#include "core/os/input_event.h"
#else
#include "core/input/input_event.h"
#endif
class BSInputEventKey : public InputEventKey {
GDCLASS(BSInputEventKey, InputEventKey);

View File

@ -30,16 +30,10 @@
#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/project_settings.h"
#include "core/translation.h"
#include "core/ustring.h"
#endif
#include "core/os/keyboard.h"
#include "editor/editor_export.h"
@ -49,19 +43,10 @@
#include "core/version.h"
#if VERSION_MAJOR < 4
#include "core/input_map.h"
#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] = {
#else
static const char *_button_names[static_cast<int>(JoyButton::MAX)] = {
#endif
"DualShock Cross, Xbox A, Nintendo B",
"DualShock Circle, Xbox B, Nintendo A",
"DualShock Square, Xbox X, Nintendo Y",
@ -80,11 +65,7 @@ static const char *_button_names[static_cast<int>(JoyButton::MAX)] = {
"D-Pad Right"
};
#if VERSION_MAJOR < 4
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 Right)",
" (Left Stick Up)",
@ -112,11 +93,7 @@ void InputMapEditor::_notification(int p_what) {
}
static bool _validate_action_name(const String &p_name) {
#if VERSION_MAJOR < 4
const CharType *cstr = p_name.c_str();
#else
const char32_t *cstr = p_name.get_data();
#endif
for (int i = 0; cstr[i]; i++)
if (cstr[i] == '/' || cstr[i] == ':' || cstr[i] == '"' ||
@ -202,13 +179,8 @@ void InputMapEditor::_device_input_add() {
switch (add_type) {
case INPUT_MOUSE_BUTTON: {
Ref<InputEventMouseButton> mb;
#if VERSION_MAJOR < 4
mb.instance();
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());
for (int i = 0; i < events.size(); i++) {
@ -225,13 +197,8 @@ void InputMapEditor::_device_input_add() {
} break;
case INPUT_JOY_MOTION: {
Ref<InputEventJoypadMotion> jm;
#if VERSION_MAJOR < 4
jm.instance();
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_device(_get_current_device());
@ -250,13 +217,8 @@ void InputMapEditor::_device_input_add() {
} break;
case INPUT_JOY_BUTTON: {
Ref<InputEventJoypadButton> jb;
#if VERSION_MAJOR < 4
jb.instance();
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());
for (int i = 0; i < events.size(); i++) {
@ -309,21 +271,12 @@ void InputMapEditor::_press_a_key_confirm() {
Ref<BSInputEventKey> ie;
#if VERSION_MAJOR < 4
ie.instance();
ie->set_scancode(last_wait_for_key->get_scancode());
ie->set_shift(last_wait_for_key->get_shift());
ie->set_alt(last_wait_for_key->get_alt());
ie->set_control(last_wait_for_key->get_control());
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;
int idx = edit_idx;
@ -337,15 +290,9 @@ void InputMapEditor::_press_a_key_confirm() {
if (aie.is_null())
continue;
#if VERSION_MAJOR < 4
if (aie->get_scancode_with_modifiers() == ie->get_scancode_with_modifiers()) {
return;
}
#else
if (aie->get_keycode_with_modifiers() == ie->get_keycode_with_modifiers()) {
return;
}
#endif
}
if (idx < 0 || idx >= events.size()) {
@ -370,11 +317,7 @@ void InputMapEditor::_show_last_added(const Ref<InputEvent> &p_event, const Stri
if (!r)
return;
#if VERSION_MAJOR < 4
r = r->get_children();
#else
r = r->get_first_child();
#endif
if (!r)
return;
@ -385,11 +328,7 @@ void InputMapEditor::_show_last_added(const Ref<InputEvent> &p_event, const Stri
continue;
}
#if VERSION_MAJOR < 4
TreeItem *child = r->get_children();
#else
TreeItem *child = r->get_first_child();
#endif
while (child) {
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) {
Ref<InputEventKey> k = p_event;
#if VERSION_MAJOR < 4
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;
#if VERSION_MAJOR < 4
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);
#if VERSION_MAJOR < 4
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();
#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: {
press_a_key_label->set_text(("Press a Key..."));
#if VERSION_MAJOR < 4
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>();
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 2"));
#if VERSION_MAJOR < 4
device_input->popup_centered_minsize(Size2(350, 95));
#else
device_input->popup_centered(Size2(350, 95));
#endif
Ref<InputEventMouseButton> mb = p_exiting_event;
if (mb.is_valid()) {
#if VERSION_MAJOR < 4
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());
#if VERSION_MAJOR < 4
device_input->get_ok()->set_text("Change");
#else
device_input->get_ok_button()->set_text("Change");
#endif
} else {
_set_current_device(0);
#if VERSION_MAJOR < 4
device_input->get_ok()->set_text("Add");
#else
device_input->get_ok_button()->set_text("Add");
#endif
}
} 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->clear();
#if VERSION_MAJOR < 4
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];
device_index->add_item("Axis " + itos(i / 2) + " " + ((i & 1) ? "+" : "-") + desc);
}
#if VERSION_MAJOR < 4
device_input->popup_centered_minsize(Size2(350, 95));
#else
device_input->popup_centered(Size2(350, 95));
#endif
Ref<InputEventJoypadMotion> jm = p_exiting_event;
if (jm.is_valid()) {
#if VERSION_MAJOR < 4
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());
#if VERSION_MAJOR < 4
device_input->get_ok()->set_text("Change");
#else
device_input->get_ok_button()->set_text("Change");
#endif
} else {
_set_current_device(0);
#if VERSION_MAJOR < 4
device_input->get_ok()->set_text("Add");
#else
device_input->get_ok_button()->set_text("Add");
#endif
}
} 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->clear();
#if VERSION_MAJOR < 4
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]));
}
#if VERSION_MAJOR < 4
device_input->popup_centered_minsize(Size2(350, 95));
#else
device_input->popup_centered(Size2(350, 95));
#endif
Ref<InputEventJoypadButton> jb = p_exiting_event;
if (jb.is_valid()) {
#if VERSION_MAJOR < 4
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());
#if VERSION_MAJOR < 4
device_input->get_ok()->set_text("Change");
#else
device_input->get_ok_button()->set_text("Change");
#endif
} else {
_set_current_device(0);
#if VERSION_MAJOR < 4
device_input->get_ok()->set_text("Add");
#else
device_input->get_ok_button()->set_text("Add");
#endif
}
} break;
@ -682,11 +539,7 @@ void InputMapEditor::_action_button_pressed(Object *p_obj, int p_column, int p_i
Array events = action["events"];
ERR_FAIL_INDEX(idx, events.size());
#if VERSION_MAJOR < 4
events.remove(idx);
#else
events.remove_at(idx);
#endif
action["events"] = events;
ProjectSettings::get_singleton()->set(name, action);
@ -729,13 +582,8 @@ void InputMapEditor::_update_actions() {
Map<String, bool> collapsed;
#if VERSION_MAJOR < 4
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()) {
#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();
}
}
@ -762,11 +610,7 @@ void InputMapEditor::_update_actions() {
TreeItem *item = input_editor->create_item(root);
item->set_text(0, name);
#if VERSION_MAJOR < 4
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))
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(1, action["deadzone"]);
#if VERSION_MAJOR < 4
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");
@ -793,11 +633,7 @@ void InputMapEditor::_update_actions() {
Ref<InputEventKey> k = event;
if (k.is_valid()) {
#if VERSION_MAJOR < 4
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_icon(0, _keyboard_texture);
@ -807,11 +643,7 @@ void InputMapEditor::_update_actions() {
if (jb.is_valid()) {
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)
#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())] + ").";
else
str += ".";
@ -822,7 +654,6 @@ void InputMapEditor::_update_actions() {
Ref<InputEventMouseButton> mb = event;
#if VERSION_MAJOR < 4
if (mb.is_valid()) {
String str = _get_device_string(mb->get_device()) + ", ";
switch (mb->get_button_index()) {
@ -844,29 +675,6 @@ void InputMapEditor::_update_actions() {
default:
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_icon(0, _mouse_texture);
@ -1103,18 +911,11 @@ InputMapEditor::InputMapEditor() {
input_editor->set_column_title(0, "Action");
input_editor->set_column_title(1, "Deadzone");
input_editor->set_column_expand(1, false);
#if VERSION_MAJOR < 4
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);
#if VERSION_MAJOR < 4
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_activated", this, InputMapEditor, _action_activated);
input_editor->CONNECT("cell_selected", this, InputMapEditor, _action_selected);
@ -1126,28 +927,19 @@ InputMapEditor::InputMapEditor() {
popup_add->CONNECT("id_pressed", this, InputMapEditor, _add_item);
press_a_key = memnew(ConfirmationDialog);
#if VERSION_MAJOR < 4
press_a_key->set_focus_mode(FOCUS_ALL);
#endif
add_child(press_a_key);
Label *l = memnew(Label);
l->set_text("Press a Key...");
#if VERSION_MAJOR < 4
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_margin(MARGIN_TOP, 20);
l->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_BEGIN, 30);
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->add_child(l);
@ -1157,11 +949,7 @@ InputMapEditor::InputMapEditor() {
device_input = memnew(ConfirmationDialog);
add_child(device_input);
#if VERSION_MAJOR < 4
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);

View File

@ -64,24 +64,14 @@ void TouchButton::_input(Ref<InputEvent> p_event) {
get_viewport()->set_input_as_handled();
Ref<InputEventMouseButton> ev;
#if VERSION_MAJOR < 4
ev.instance();
#else
ev.instantiate();
#endif
#if VERSION_MAJOR < 4
ev->set_button_index(BUTTON_LEFT);
#else
ev->set_button_index(MouseButton::LEFT);
#endif
ev->set_pressed(b->is_pressed());
ev->set_position(b->get_position());
ev->set_global_position(b->get_position());
#if VERSION_MAJOR <= 3
BaseButton::_gui_input(ev);
#endif
update();
}
/*
@ -107,9 +97,7 @@ void TouchButton::_gui_input(Ref<InputEvent> p_event) {
return;
}
#if VERSION_MAJOR <= 3
BaseButton::_gui_input(p_event);
#endif
}
void TouchButton::_unhandled_input(Ref<InputEvent> p_event) {
@ -118,9 +106,7 @@ void TouchButton::_unhandled_input(Ref<InputEvent> p_event) {
return;
}
#if VERSION_MAJOR <= 3
Button::_unhandled_input(p_event);
#endif
}
void TouchButton::_bind_methods() {

View File

@ -22,16 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/config/engine.h"
#else
#include "core/engine.h"
#endif
#include "core/os/os.h"
#include "scene/gui/button.h"

View File

@ -77,11 +77,7 @@ void VoxelLibrarySimple::voxel_surface_set(const int index, Ref<VoxelSurface> va
}
void VoxelLibrarySimple::voxel_surface_remove(const int index) {
#if VERSION_MAJOR <= 3
_voxel_surfaces.remove(index);
#else
_voxel_surfaces.remove_at(index);
#endif
}
int VoxelLibrarySimple::voxel_surface_get_num() const {

View File

@ -32,8 +32,8 @@ SOFTWARE.
#include "../../library/voxel_material_cache.h"
#include "../default/voxel_chunk_default.h"
#include "servers/physics_server.h"
#include "scene/resources/world.h"
#include "servers/physics_server.h"
#ifdef MESH_DATA_RESOURCE_PRESENT
#include "../../../mesh_data_resource/mesh_data_resource.h"
@ -96,12 +96,7 @@ void VoxelPropJob::phase_physics_process() {
continue;
}
#if VERSION_MAJOR < 4
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 *= offset;