Cleaned up Terraman2d from version checks.

This commit is contained in:
Relintai 2022-03-18 02:20:01 +01:00
parent ef952b88b7
commit 0e78fdbf03
50 changed files with 25 additions and 874 deletions

View File

@ -22,21 +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/object/ref_counted.h"
#ifndef Reference
#define Reference RefCounted
#endif
#include "core/string/ustring.h"
#else
#include "core/reference.h"
#include "core/ustring.h"
#endif
#include "core/math/aabb.h"

View File

@ -22,24 +22,9 @@ 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/object/ref_counted.h"
#ifndef Reference
#define Reference RefCounted
#endif
#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
class Terrain2DLight : public Reference {
GDCLASS(Terrain2DLight, Reference);

View File

@ -2,32 +2,6 @@
#ifndef TERRAIN_2D_DEFINES_H
#define TERRAIN_2D_DEFINES_H
#include "core/version.h"
#if VERSION_MAJOR >= 4
#define GODOT4 true
#endif
//includes
#if GODOT4
#define core_input_h "core/input/input_event.h"
#define spatial_editor_plugin_h "editor/plugins/node_3d_editor_plugin.h"
#define camera_h "scene/3d/camera_3d.h"
#define spatial_h "scene/3d/node_3d.h"
#define navigation_h "scene/3d/node_3d.h"
#define Navigation3D Node3D
#define light_h "scene/3d/light_3d.h"
#define visual_server_h "servers/rendering_server.h"
#define mesh_instance_h "scene/3d/mesh_instance_3d.h"
#define pool_vector_h "core/templates/vector.h"
#define physics_server_h "servers/physics_server_3d.h"
#define immediate_geometry_h "scene/3d/immediate_geometry_3d.h"
#define include_pool_vector \
template <class N> \
class Vector; \
template <class N> \
using PoolVector = Vector<N>;
#else
#define core_input_h "core/os/input.h"
#define spatial_editor_plugin_h "editor/plugins/spatial_editor_plugin.h"
#define camera_h "scene/3d/camera.h"
@ -40,57 +14,6 @@
#define physics_server_h "servers/physics_server.h"
#define immediate_geometry_h "scene/3d/immediate_geometry.h"
#define include_pool_vector
#endif
//Type Defines
#if GODOT4
#define PhysicsDirectSpaceState PhysicsDirectSpaceState3D
#define SpatialEditor Node3DEditor
#define SpatialEditorPlugin Node3DEditorPlugin
#define SpatialEditorViewport Node3DEditorViewport
#define PoolStringArray PackedStringArray
#define REAL FLOAT
#define POOL_STRING_ARRAY PACKED_STRING_ARRAY
#define POOL_BYTE_ARRAY PACKED_BYTE_ARRAY
#define Spatial Node3D
#define SpatialMaterial StandardMaterial3D
#define PoolVector3Array PackedVector3Array
#define PoolVector2Array PackedVector2Array
#define PoolColorArray PackedColorArray
#define PoolIntArray PackedInt64Array
#define PoolRealArray PackedFloat32Array
#define PoolByteArray PackedByteArray
#define MeshInstance MeshInstance3D
#define Camera Camera3D
#define ToolButton Button
#define Shape Shape3D
#define Reference RefCounted
typedef class World3D World;
#define DirectionalLight DirectionalLight3D
typedef class ImmediateGeometry3D ImmediateGeometry;
typedef class Navigation3D Navigation;
typedef class PhysicsServer3D PhysicsServer;
typedef class RenderingServer VisualServer;
typedef class RenderingServer VS;
//typedef class StandardMaterial3D SpatialMaterial;
//toodo figure out a way to have this
//#define Variant::CallError Callable::CallError
#endif
#if GODOT4
#define VARIANT_ARRAY_GET(arr) \
Vector<Variant> r; \
for (int i = 0; i < arr.size(); i++) { \
r.push_back(arr[i]); \
} \
return r;
#else
#define VARIANT_ARRAY_GET(arr) \
Vector<Variant> r; \
@ -99,8 +22,6 @@ typedef class RenderingServer VS;
} \
return r;
#endif
#define VARIANT_ARRAY_SET(arr, arr_into, type) \
arr_into.clear(); \
for (int i = 0; i < arr.size(); i++) { \
@ -108,58 +29,6 @@ typedef class RenderingServer VS;
arr_into.push_back(e); \
}
#if GODOT4
//TODO do this properly
#define INSTANCE_VALIDATE(var) var
#define CONNECT(sig, obj, target_method_class, method) connect(sig, callable_mp(obj, &target_method_class::method))
#define DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, callable_mp(obj, &target_method_class::method))
#define INSTANCE instantiate
#define VREMOVE remove_at
#define CALL(func, ...) \
_gdvirtual_##func##_call(__VA_ARGS__)
#define RETURN_CALL(ret_type, func) \
ret_type _return_call_ret_var; \
_gdvirtual_##func##_call(_return_call_ret_var); \
return _return_call_ret_var;
#define RETURN_CALLP(ret_type, func, ...) \
ret_type _return_call_ret_var; \
_gdvirtual_##func##_call(__VA_ARGS__, _return_call_ret_var); \
return _return_call_ret_var;
#define GET_CALL(ret_type, ret_var, func) \
_gdvirtual_##func##_call(ret_var);
#define GET_CALLP(ret_type, ret_var, func, ...) \
_gdvirtual_##func##_call(__VA_ARGS__, ret_var);
#define RETURN_CALLD(ret_type, def_val, func) \
ret_type _return_call_ret_var = def_val; \
if (_gdvirtual_##func##_call(_return_call_ret_var)) { \
return _return_call_ret_var; \
} \
return def_val;
#define RETURN_CALLPD(ret_type, def_val, func, ...) \
ret_type _return_call_ret_var = def_val; \
if (_gdvirtual_##func##_call(__VA_ARGS__, _return_call_ret_var)) { \
return _return_call_ret_var; \
} \
return def_val;
#define GET_CALLD(ret_type, def_val, ret_var, func) \
if (!_gdvirtual_##func##_call(ret_var)) { \
ret_var = def_val; \
}
#define GET_CALLPD(ret_type, def_val, ret_var, func, ...) \
if (!_gdvirtual_##func##_call(__VA_ARGS__, ret_var)) { \
ret_var = def_val; \
}
#else
#define INSTANCE_VALIDATE(var) ObjectDB::instance_validate(var)
#define CONNECT(sig, obj, target_method_class, method) connect(sig, obj, #method)
#define DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, obj, #method)
@ -194,5 +63,3 @@ typedef class RenderingServer VS;
return call(#func, ##__VA_ARGS__);
#endif
#endif

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/io/resource.h"
#else
#include "core/resource.h"
#endif
class Terrain2DChunk;

View File

@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "terrain_2d_level_generator.h"
class Terrain2DChunk;

View File

@ -34,117 +34,6 @@ SOFTWARE.
#include "../defines.h"
#if VERSION_MAJOR > 3
#define TMCGDVIRTUAL1(m_class, m_name, m_type1) \
bool m_class::_gdvirtual_##m_name##_call(m_type1 arg1) { \
ScriptInstance *script_instance = ((Object *)(this))->get_script_instance(); \
if (script_instance) { \
Callable::CallError ce; \
Variant vargs[1] = { Variant(arg1) }; \
const Variant *vargptrs[1] = { &vargs[0] }; \
\
script_instance->call(_gdvirtual_##m_name##_sn, (const Variant **)vargptrs, 1, ce); \
if (ce.error == Callable::CallError::CALL_OK) { \
return true; \
} \
} \
if (unlikely(_get_extension() && !_gdvirtual_##m_name##_initialized)) { \
_gdvirtual_##m_name = (_get_extension() && _get_extension()->get_virtual) ? _get_extension()->get_virtual(_get_extension()->class_userdata, #m_name) : (GDNativeExtensionClassCallVirtual) nullptr; \
_gdvirtual_##m_name##_initialized = true; \
} \
if (_gdvirtual_##m_name) { \
PtrToArg<m_type1>::EncodeT argval1 = arg1; \
const GDNativeTypePtr argptrs[1] = { &argval1 }; \
\
_gdvirtual_##m_name(_get_extension_instance(), (const GDNativeTypePtr *)argptrs, nullptr); \
\
return true; \
} \
\
return false; \
} \
bool m_class::_gdvirtual_##m_name##_overridden() const { \
ScriptInstance *script_instance = ((Object *)(this))->get_script_instance(); \
if (script_instance) { \
return script_instance->has_method(_gdvirtual_##m_name##_sn); \
} \
if (unlikely(_get_extension() && !_gdvirtual_##m_name##_initialized)) { \
_gdvirtual_##m_name = (_get_extension() && _get_extension()->get_virtual) ? _get_extension()->get_virtual(_get_extension()->class_userdata, #m_name) : (GDNativeExtensionClassCallVirtual) nullptr; \
_gdvirtual_##m_name##_initialized = true; \
} \
if (_gdvirtual_##m_name) { \
return true; \
} \
return false; \
} \
\
MethodInfo m_class::_gdvirtual_##m_name##_get_method_info() { \
MethodInfo method_info; \
method_info.name = #m_name; \
method_info.flags = METHOD_FLAG_VIRTUAL; \
method_info.arguments.push_back(GetTypeInfo<m_type1>::get_class_info()); \
\
return method_info; \
}
#define TMCGDVIRTUAL1R(m_class, m_ret, m_name, m_type1) \
bool m_class::_gdvirtual_##m_name##_call(m_type1 arg1, m_ret &r_ret) { \
ScriptInstance *script_instance = ((Object *)(this))->get_script_instance(); \
if (script_instance) { \
Callable::CallError ce; \
Variant vargs[1] = { Variant(arg1) }; \
const Variant *vargptrs[1] = { &vargs[0] }; \
\
Variant ret = script_instance->call(_gdvirtual_##m_name##_sn, (const Variant **)vargptrs, 1, ce); \
if (ce.error == Callable::CallError::CALL_OK) { \
r_ret = VariantCaster<m_ret>::cast(ret); \
return true; \
} \
} \
if (unlikely(_get_extension() && !_gdvirtual_##m_name##_initialized)) { \
_gdvirtual_##m_name = (_get_extension() && _get_extension()->get_virtual) ? _get_extension()->get_virtual(_get_extension()->class_userdata, #m_name) : (GDNativeExtensionClassCallVirtual) nullptr; \
_gdvirtual_##m_name##_initialized = true; \
} \
if (_gdvirtual_##m_name) { \
PtrToArg<m_type1>::EncodeT argval1 = arg1; \
const GDNativeTypePtr argptrs[1] = { &argval1 }; \
\
PtrToArg<m_ret>::EncodeT ret; \
_gdvirtual_##m_name(_get_extension_instance(), (const GDNativeTypePtr *)argptrs, &ret); \
r_ret = (m_ret)ret; \
return true; \
} \
\
return false; \
} \
bool m_class::_gdvirtual_##m_name##_overridden() const { \
ScriptInstance *script_instance = ((Object *)(this))->get_script_instance(); \
if (script_instance) { \
return script_instance->has_method(_gdvirtual_##m_name##_sn); \
} \
if (unlikely(_get_extension() && !_gdvirtual_##m_name##_initialized)) { \
_gdvirtual_##m_name = (_get_extension() && _get_extension()->get_virtual) ? _get_extension()->get_virtual(_get_extension()->class_userdata, #m_name) : (GDNativeExtensionClassCallVirtual) nullptr; \
_gdvirtual_##m_name##_initialized = true; \
} \
if (_gdvirtual_##m_name) { \
return true; \
} \
return false; \
} \
\
MethodInfo m_class::_gdvirtual_##m_name##_get_method_info() { \
MethodInfo method_info; \
method_info.name = #m_name; \
method_info.flags = METHOD_FLAG_VIRTUAL; \
method_info.return_val = GetTypeInfo<m_ret>::get_class_info(); \
method_info.arguments.push_back(GetTypeInfo<m_type1>::get_class_info()); \
\
return method_info; \
}
#endif
bool Terrain2DLibrary::get_initialized() const {
return _initialized;
}
@ -350,30 +239,12 @@ Terrain2DLibrary::~Terrain2DLibrary() {
_prop_material.unref();
}
#if VERSION_MAJOR >= 4
TMCGDVIRTUAL1(Terrain2DLibrary, _material_cache_get_key, Ref<Terrain2DChunk>);
TMCGDVIRTUAL1R(Terrain2DLibrary, Ref<Terrain2DMaterialCache>, _material_cache_get, int);
TMCGDVIRTUAL1(Terrain2DLibrary, _material_cache_unref, int);
TMCGDVIRTUAL1(Terrain2DLibrary, _liquid_material_cache_get_key, Ref<Terrain2DChunk>);
TMCGDVIRTUAL1R(Terrain2DLibrary, Ref<Terrain2DMaterialCache>, _liquid_material_cache_get, int);
TMCGDVIRTUAL1(Terrain2DLibrary, _liquid_material_cache_unref, int);
TMCGDVIRTUAL1(Terrain2DLibrary, _prop_material_cache_get_key, Ref<Terrain2DChunk>);
TMCGDVIRTUAL1R(Terrain2DLibrary, Ref<Terrain2DMaterialCache>, _prop_material_cache_get, int);
TMCGDVIRTUAL1(Terrain2DLibrary, _prop_material_cache_unref, int);
#endif
void Terrain2DLibrary::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_initialized"), &Terrain2DLibrary::get_initialized);
ClassDB::bind_method(D_METHOD("set_initialized", "value"), &Terrain2DLibrary::set_initialized);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "initialized", PROPERTY_HINT_NONE, "", 0), "set_initialized", "get_initialized");
#if VERSION_MAJOR < 4
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "ret"), "_supports_caching"));
#else
GDVIRTUAL_BIND(_supports_caching);
#endif
ClassDB::bind_method(D_METHOD("_supports_caching"), &Terrain2DLibrary::_supports_caching);
ClassDB::bind_method(D_METHOD("supports_caching"), &Terrain2DLibrary::supports_caching);
@ -390,21 +261,11 @@ void Terrain2DLibrary::_bind_methods() {
ClassDB::bind_method(D_METHOD("prop_texture_set", "value"), &Terrain2DLibrary::prop_texture_set);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "prop_texture_set", "prop_texture_get");
#if VERSION_MAJOR < 4
BIND_VMETHOD(MethodInfo("_setup_material_albedo", PropertyInfo(Variant::INT, "material_index"), PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture")));
#else
GDVIRTUAL_BIND(_setup_material_albedo, "material_index", "texture");
#endif
#if VERSION_MAJOR < 4
BIND_VMETHOD(MethodInfo("_material_cache_get_key", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "Terrain2DChunk")));
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "ret", PROPERTY_HINT_RESOURCE_TYPE, "Terrain2DMaterialCache"), "_material_cache_get", PropertyInfo(Variant::INT, "key")));
BIND_VMETHOD(MethodInfo("_material_cache_unref", PropertyInfo(Variant::INT, "key")));
#else
GDVIRTUAL_BIND(_material_cache_get_key, "chunk", "texture");
GDVIRTUAL_BIND(_material_cache_get, "key");
GDVIRTUAL_BIND(_material_cache_unref, "key");
#endif
ClassDB::bind_method(D_METHOD("material_cache_get_key", "chunk"), &Terrain2DLibrary::material_cache_get_key);
ClassDB::bind_method(D_METHOD("_material_cache_get_key", "chunk"), &Terrain2DLibrary::_material_cache_get_key);
@ -417,15 +278,9 @@ void Terrain2DLibrary::_bind_methods() {
ClassDB::bind_method(D_METHOD("material_set", "value"), &Terrain2DLibrary::material_set);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "material_set", "material_get");
#if VERSION_MAJOR < 4
BIND_VMETHOD(MethodInfo("_liquid_material_cache_get_key", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "Terrain2DChunk")));
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "ret", PROPERTY_HINT_RESOURCE_TYPE, "Terrain2DMaterialCache"), "_liquid_material_cache_get", PropertyInfo(Variant::INT, "key")));
BIND_VMETHOD(MethodInfo("_liquid_material_cache_unref", PropertyInfo(Variant::INT, "key")));
#else
GDVIRTUAL_BIND(_liquid_material_cache_get_key, "chunk", "texture");
GDVIRTUAL_BIND(_liquid_material_cache_get, "key");
GDVIRTUAL_BIND(_liquid_material_cache_unref, "key");
#endif
ClassDB::bind_method(D_METHOD("liquid_material_cache_get_key", "chunk"), &Terrain2DLibrary::liquid_material_cache_get_key);
ClassDB::bind_method(D_METHOD("_liquid_material_cache_get_key", "chunk"), &Terrain2DLibrary::_liquid_material_cache_get_key);
@ -438,15 +293,9 @@ void Terrain2DLibrary::_bind_methods() {
ClassDB::bind_method(D_METHOD("liquid_material_set", "value"), &Terrain2DLibrary::liquid_material_set);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "liquid_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "liquid_material_set", "liquid_material_get");
#if VERSION_MAJOR < 4
BIND_VMETHOD(MethodInfo("_prop_material_cache_get_key", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "Terrain2DChunk")));
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "ret", PROPERTY_HINT_RESOURCE_TYPE, "Terrain2DMaterialCache"), "_prop_material_cache_get", PropertyInfo(Variant::INT, "key")));
BIND_VMETHOD(MethodInfo("_prop_material_cache_unref", PropertyInfo(Variant::INT, "key")));
#else
GDVIRTUAL_BIND(_prop_material_cache_get_key, "chunk", "texture");
GDVIRTUAL_BIND(_prop_material_cache_get, "key");
GDVIRTUAL_BIND(_prop_material_cache_unref, "key");
#endif
ClassDB::bind_method(D_METHOD("prop_material_cache_get_key", "chunk"), &Terrain2DLibrary::prop_material_cache_get_key);
ClassDB::bind_method(D_METHOD("_prop_material_cache_get_key", "chunk"), &Terrain2DLibrary::_prop_material_cache_get_key);

View File

@ -22,35 +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/io/resource.h"
// These are needed here to use incomplete classes as vmethod arguments (godot4)
#define TMHGDVIRTUAL1(m_name, m_type1) \
StringName _gdvirtual_##m_name##_sn = #m_name; \
mutable bool _gdvirtual_##m_name##_initialized = false; \
mutable GDNativeExtensionClassCallVirtual _gdvirtual_##m_name = nullptr; \
bool _gdvirtual_##m_name##_call(m_type1 arg1); \
bool _gdvirtual_##m_name##_overridden() const; \
static MethodInfo _gdvirtual_##m_name##_get_method_info();
#define TMHGDVIRTUAL1R(m_ret, m_name, m_type1) \
StringName _gdvirtual_##m_name##_sn = #m_name; \
mutable bool _gdvirtual_##m_name##_initialized = false; \
mutable GDNativeExtensionClassCallVirtual _gdvirtual_##m_name = nullptr; \
bool _gdvirtual_##m_name##_call(m_type1 arg1, m_ret &r_ret); \
bool _gdvirtual_##m_name##_overridden() const; \
static MethodInfo _gdvirtual_##m_name##_get_method_info();
#else
#include "core/resource.h"
#endif
#include "core/math/rect2.h"
#include "scene/resources/material.h"
@ -60,10 +32,6 @@ SOFTWARE.
#include "../defines.h"
#if GODOT4
#define Texture Texture2D
#endif
class Terrain2DMaterialCache;
class Terrain2DSurface;
class Terrain2DMesher;
@ -159,24 +127,6 @@ public:
void setup_material_albedo(int material_index, Ref<Texture> texture);
#if VERSION_MAJOR >= 4
GDVIRTUAL0R(bool, _supports_caching);
GDVIRTUAL2(_setup_material_albedo, int, Ref<Texture>);
TMHGDVIRTUAL1(_material_cache_get_key, Ref<Terrain2DChunk>);
TMHGDVIRTUAL1R(Ref<Terrain2DMaterialCache>, _material_cache_get, int);
TMHGDVIRTUAL1(_material_cache_unref, int);
TMHGDVIRTUAL1(_liquid_material_cache_get_key, Ref<Terrain2DChunk>);
TMHGDVIRTUAL1R(Ref<Terrain2DMaterialCache>, _liquid_material_cache_get, int);
TMHGDVIRTUAL1(_liquid_material_cache_unref, int);
TMHGDVIRTUAL1(_prop_material_cache_get_key, Ref<Terrain2DChunk>);
TMHGDVIRTUAL1R(Ref<Terrain2DMaterialCache>, _prop_material_cache_get, int);
TMHGDVIRTUAL1(_prop_material_cache_unref, int);
#endif
Terrain2DLibrary();
~Terrain2DLibrary();

View File

@ -321,11 +321,7 @@ void Terrain2DLibraryMerger::_setup_material_albedo(const int material_index, co
Terrain2DLibraryMerger::Terrain2DLibraryMerger() {
_packer.instance();
#if GODOT4
#warning implement
#else
_packer->set_texture_flags(Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER);
#endif
_packer->set_max_atlas_size(1024);
_packer->set_keep_original_atlases(false);
@ -333,11 +329,7 @@ Terrain2DLibraryMerger::Terrain2DLibraryMerger() {
_prop_packer.instance();
#if GODOT4
#warning implement
#else
_prop_packer->set_texture_flags(Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER);
#endif
_prop_packer->set_max_atlas_size(1024);
_prop_packer->set_keep_original_atlases(false);

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/io/resource.h"
#include "core/templates/map.h"
#else
#include "core/resource.h"
#include "core/map.h"
#endif
#include "core/resource.h"
#include "terrain_2d_library.h"
@ -106,9 +96,9 @@ protected:
static void _bind_methods();
Vector<Ref<Terrain2DSurfaceMerger> > _terra_surfaces;
Vector<Ref<Terrain2DSurfaceMerger>> _terra_surfaces;
#ifdef PROPS_2D_PRESENT
Vector<Ref<Prop2DData> > _props;
Vector<Ref<Prop2DData>> _props;
#endif
Ref<TexturePacker> _packer;

View File

@ -696,11 +696,7 @@ void Terrain2DLibraryMergerPCM::_setup_material_albedo(const int material_index,
Terrain2DLibraryMergerPCM::Terrain2DLibraryMergerPCM() {
_packer.instance();
#if GODOT4
#warning implement
#else
_packer->set_texture_flags(Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER);
#endif
_packer->set_max_atlas_size(1024);
_packer->set_keep_original_atlases(false);
@ -708,11 +704,7 @@ Terrain2DLibraryMergerPCM::Terrain2DLibraryMergerPCM() {
_prop_packer.instance();
#if GODOT4
#warning implement
#else
_prop_packer->set_texture_flags(Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER);
#endif
_prop_packer->set_max_atlas_size(1024);
_prop_packer->set_keep_original_atlases(false);

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/io/resource.h"
#include "core/templates/map.h"
#else
#include "core/resource.h"
#include "core/map.h"
#endif
#include "core/resource.h"
#include "terrain_2d_library.h"
@ -121,12 +111,12 @@ protected:
static void _bind_methods();
Map<int, Ref<Terrain2DMaterialCachePCM> > _material_cache;
Map<int, Ref<Terrain2DMaterialCachePCM> > _prop_material_cache;
Map<int, Ref<Terrain2DMaterialCachePCM>> _material_cache;
Map<int, Ref<Terrain2DMaterialCachePCM>> _prop_material_cache;
Vector<Ref<Terrain2DSurfaceMerger> > _terra_surfaces;
Vector<Ref<Terrain2DSurfaceMerger>> _terra_surfaces;
#ifdef PROPS_2D_PRESENT
Vector<Ref<Prop2DData> > _props;
Vector<Ref<Prop2DData>> _props;
#endif
//todo remove these

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/io/resource.h"
#else
#include "core/resource.h"
#endif
#include "terrain_2d_library.h"
@ -72,7 +63,7 @@ protected:
static void _bind_methods();
private:
Vector<Ref<Terrain2DSurfaceSimple> > _terra_surfaces;
Vector<Ref<Terrain2DSurfaceSimple>> _terra_surfaces;
//atlas
int _atlas_columns;

View File

@ -219,13 +219,9 @@ void Terrain2DMaterialCache::refresh_rects() {
}
void Terrain2DMaterialCache::setup_material_albedo(Ref<Texture> texture) {
#if VERSION_MAJOR < 4
if (has_method("_setup_material_albedo")) {
call("_setup_material_albedo", texture);
}
#else
GDVIRTUAL_CALL(_setup_material_albedo, texture);
#endif
}
Terrain2DMaterialCache::Terrain2DMaterialCache() {
@ -249,11 +245,7 @@ void Terrain2DMaterialCache::_bind_methods() {
ClassDB::bind_method(D_METHOD("inc_ref_count"), &Terrain2DMaterialCache::inc_ref_count);
ClassDB::bind_method(D_METHOD("dec_ref_count"), &Terrain2DMaterialCache::dec_ref_count);
#if VERSION_MAJOR < 4
BIND_VMETHOD(MethodInfo("_setup_material_albedo", PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture")));
#else
GDVIRTUAL_BIND(_setup_material_albedo, "texture");
#endif
ClassDB::bind_method(D_METHOD("material_get"), &Terrain2DMaterialCache::material_get);
ClassDB::bind_method(D_METHOD("material_set", "value"), &Terrain2DMaterialCache::material_set);

View File

@ -22,20 +22,9 @@ 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/math/color.h"
#include "core/templates/vector.h"
#else
#include "core/color.h"
#include "core/resource.h"
#include "core/vector.h"
#endif
#include "core/math/rect2.h"
#include "scene/resources/material.h"
@ -94,10 +83,6 @@ public:
void setup_material_albedo(Ref<Texture> texture);
#if VERSION_MAJOR >= 4
GDVIRTUAL1(_setup_material_albedo, Ref<Texture>);
#endif
Terrain2DMaterialCache();
~Terrain2DMaterialCache();

View File

@ -172,11 +172,7 @@ void Terrain2DMaterialCachePCM::_setup_material_albedo(Ref<Texture> texture) {
Terrain2DMaterialCachePCM::Terrain2DMaterialCachePCM() {
_packer.instance();
#if GODOT4
#warning implement
#else
_packer->set_texture_flags(Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER);
#endif
_packer->set_max_atlas_size(1024);
_packer->set_keep_original_atlases(false);

View File

@ -22,22 +22,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "terrain_2d_material_cache.h"
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/io/resource.h"
#include "core/math/color.h"
#include "core/templates/vector.h"
#else
#include "core/color.h"
#include "core/resource.h"
#include "core/vector.h"
#endif
#include "core/math/rect2.h"
#include "scene/resources/material.h"

View File

@ -22,21 +22,9 @@ 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"
#include "core/math/color.h"
#else
#include "core/color.h"
#include "core/resource.h"
#include "core/vector.h"
#include "core/color.h"
#endif
#include "core/math/rect2.h"
#include "scene/resources/material.h"

View File

@ -26,10 +26,6 @@ SOFTWARE.
#include "../defines.h"
#if GODOT4
#define Texture Texture2D
#endif
Ref<AtlasTexture> Terrain2DSurfaceMerger::get_region() {
return _region;
}

View File

@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "terrain_2d_surface.h"
#include "scene/resources/texture.h"
@ -33,9 +30,6 @@ SOFTWARE.
#include "../defines.h"
#if GODOT4
#define Texture Texture2D
#endif
class Terrain2DSurfaceMerger : public Terrain2DSurface {
GDCLASS(Terrain2DSurfaceMerger, Terrain2DSurface)

View File

@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "terrain_2d_surface.h"
class Terrain2DSurfaceSimple : public Terrain2DSurface {

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/math/color.h"
#else
#include "core/color.h"
#endif
#include "core/math/vector2.h"
#include "core/math/vector3.h"

View File

@ -22,22 +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/math/color.h"
#else
#include "core/color.h"
#endif
#include "core/math/vector2.h"
#include "core/math/vector3.h"
#include "../default/terrain_2d_mesher_default.h"
#include "../../world/default/terrain_2d_chunk_default.h"
#include "../default/terrain_2d_mesher_default.h"
class Terrain2DMesherIsometric : public Terrain2DMesherDefault {
GDCLASS(Terrain2DMesherIsometric, Terrain2DMesherDefault);

View File

@ -22,22 +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/math/color.h"
#else
#include "core/color.h"
#endif
#include "core/math/vector2.h"
#include "core/math/vector3.h"
#include "../default/terrain_2d_mesher_default.h"
#include "../../world/default/terrain_2d_chunk_default.h"
#include "../default/terrain_2d_mesher_default.h"
class Terrain2DMesherSimple : public Terrain2DMesherDefault {
GDCLASS(Terrain2DMesherSimple, Terrain2DMesherDefault);

View File

@ -155,21 +155,13 @@ Array Terrain2DMesher::build_mesh() {
{
PoolVector<Vector2> array;
array.resize(_vertices.size());
#if !GODOT4
PoolVector<Vector2>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) {
#if !GODOT4
w[i] = _vertices[i].vertex;
#else
array.set(i, _vertices[i].vertex);
#endif
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_VERTEX] = array;
}
@ -177,42 +169,27 @@ Array Terrain2DMesher::build_mesh() {
if ((_format & VisualServer::ARRAY_FORMAT_COLOR) != 0) {
PoolVector<Color> array;
array.resize(_vertices.size());
#if !GODOT4
PoolVector<Color>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) {
#if !GODOT4
w[i] = _vertices[i].color;
#else
array.set(i, _vertices[i].color);
#endif
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_COLOR] = array;
}
if ((_format & VisualServer::ARRAY_FORMAT_TEX_UV) != 0) {
PoolVector<Vector2> array;
array.resize(_vertices.size());
#if !GODOT4
PoolVector<Vector2>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) {
#if !GODOT4
w[i] = _vertices[i].uv;
#else
array.set(i, _vertices[i].uv);
#endif
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_TEX_UV] = array;
}
@ -220,21 +197,13 @@ Array Terrain2DMesher::build_mesh() {
if (_indices.size() > 0) {
PoolVector<int> array;
array.resize(_indices.size());
#if !GODOT4
PoolVector<int>::Write w = array.write();
#endif
for (int i = 0; i < _indices.size(); ++i) {
#if !GODOT4
w[i] = _indices[i];
#else
array.set(i, _indices[i]);
#endif
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_INDEX] = array;
}
@ -387,21 +356,14 @@ Array Terrain2DMesher::build_stored_mesh(const int index) {
{
PoolVector<Vector2> array;
array.resize(md.vertices.size());
#if !GODOT4
PoolVector<Vector2>::Write w = array.write();
#endif
for (int i = 0; i < md.vertices.size(); ++i) {
#if !GODOT4
w[i] = md.vertices[i].vertex;
#else
array.set(i, md.vertices[i].vertex);
#endif
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_VERTEX] = array;
}
@ -409,64 +371,40 @@ Array Terrain2DMesher::build_stored_mesh(const int index) {
if ((_format & VisualServer::ARRAY_FORMAT_COLOR) != 0) {
PoolVector<Color> array;
array.resize(md.vertices.size());
#if !GODOT4
PoolVector<Color>::Write w = array.write();
#endif
for (int i = 0; i < md.vertices.size(); ++i) {
#if !GODOT4
w[i] = md.vertices[i].color;
#else
array.set(i, md.vertices[i].color);
#endif
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_COLOR] = array;
}
if ((_format & VisualServer::ARRAY_FORMAT_TEX_UV) != 0) {
PoolVector<Vector2> array;
array.resize(md.vertices.size());
#if !GODOT4
PoolVector<Vector2>::Write w = array.write();
#endif
for (int i = 0; i < md.vertices.size(); ++i) {
#if !GODOT4
w[i] = md.vertices[i].uv;
#else
array.set(i, md.vertices[i].uv);
#endif
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_TEX_UV] = array;
}
if (md.indices.size() > 0) {
PoolVector<int> array;
array.resize(md.indices.size());
#if !GODOT4
PoolVector<int>::Write w = array.write();
#endif
for (int i = 0; i < md.indices.size(); ++i) {
#if !GODOT4
w[i] = md.indices[i];
#else
array.set(i, md.indices[i]);
#endif
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_INDEX] = array;
}
@ -935,15 +873,9 @@ Terrain2DMesher::~Terrain2DMesher() {
}
void Terrain2DMesher::_bind_methods() {
#if VERSION_MAJOR < 4
BIND_VMETHOD(MethodInfo("_add_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "Terrain2DChunk")));
BIND_VMETHOD(MethodInfo("_bake_colors", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "Terrain2DChunk")));
BIND_VMETHOD(MethodInfo("_bake_liquid_colors", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "Terrain2DChunk")));
#else
GDVIRTUAL_BIND(_add_chunk, "chunk");
GDVIRTUAL_BIND(_bake_colors, "chunk");
GDVIRTUAL_BIND(_bake_liquid_colors, "chunk");
#endif
ClassDB::bind_method(D_METHOD("get_channel_index_type"), &Terrain2DMesher::get_channel_index_type);
ClassDB::bind_method(D_METHOD("set_channel_index_type", "value"), &Terrain2DMesher::set_channel_index_type);
@ -997,11 +929,7 @@ void Terrain2DMesher::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform_colored", "mesh", "transform", "colors", "uv_rect"), &Terrain2DMesher::add_mesh_data_resource_transform_colored, DEFVAL(Rect2(0, 0, 1, 1)));
#endif
#if VERSION_MAJOR < 4
BIND_VMETHOD(MethodInfo("_add_mesher", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "Terrain2DMesher")));
#else
GDVIRTUAL_BIND(_add_mesher, "mesher");
#endif
ClassDB::bind_method(D_METHOD("add_mesher", "mesher"), &Terrain2DMesher::add_mesher);
ClassDB::bind_method(D_METHOD("_add_mesher", "mesher"), &Terrain2DMesher::_add_mesher);

View File

@ -22,23 +22,9 @@ 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/object/ref_counted.h"
#ifndef Reference
#define Reference RefCounted
#endif
#include "core/math/color.h"
#include "core/templates/vector.h"
#else
#include "core/color.h"
#include "core/reference.h"
#include "core/vector.h"
#endif
#include "../defines.h"
@ -190,13 +176,6 @@ public:
void remove_index(const int idx);
void add_indices(const int index);
#if VERSION_MAJOR >= 4
GDVIRTUAL1(_add_chunk, Ref<Terrain2DChunk>);
GDVIRTUAL1(_bake_colors, Ref<Terrain2DChunk>);
GDVIRTUAL1(_bake_liquid_colors, Ref<Terrain2DChunk>);
GDVIRTUAL1(_add_mesher, Ref<Terrain2DChunk>);
#endif
Terrain2DMesher(const Ref<Terrain2DLibrary> &library);
Terrain2DMesher();
~Terrain2DMesher();

View File

@ -22,18 +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 < 4
#include "scene/3d/spatial.h"
#else
#include "scene/3d/node_3d.h"
#define Spatial Node3D
#endif
#include "core/math/vector3.h"

View File

@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
void register_terraman_2d_types();
void unregister_terraman_2d_types();

View File

@ -43,7 +43,6 @@ int BlockTerrain2DStructure::get_voxel_type(int p_x, int p_y) const {
return 0;
}
void BlockTerrain2DStructure::set_voxel(int p_x, int p_y, int p_type, int p_isolevel) {
DataEntry p;
p.x = p_x;

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/templates/vector.h"
#else
#include "core/vector.h"
#endif
#include "terrain_2d_structure.h"

View File

@ -38,9 +38,9 @@ SOFTWARE.
#include "../jobs/terrain_2d_light_job.h"
#include "../jobs/terrain_2d_prop_job.h"
#include "../jobs/terrain_2d_terrain_job.h"
#include "servers/physics_2d_server.h"
#include "scene/resources/world.h"
#include "scene/resources/world_2d.h"
#include "servers/physics_2d_server.h"
const String Terrain2DChunkDefault::BINDING_STRING_BUILD_FLAGS = "Use Lighting,Use AO,Use RAO,Generate AO,Generate RAO,Bake Lights,Create Collider";
@ -85,13 +85,8 @@ RID Terrain2DChunkDefault::mesh_rid_get(const int mesh_index, const int mesh_typ
Variant v = m[mesh_type_index];
#if VERSION_MAJOR > 3
if (v.get_type() != Variant::RID)
return RID();
#else
if (v.get_type() != Variant::_RID)
return RID();
#endif
return v;
}
@ -109,11 +104,7 @@ void Terrain2DChunkDefault::mesh_rid_set(const int mesh_index, const int mesh_ty
Variant v = m[mesh_type_index];
#if VERSION_MAJOR > 3
ERR_FAIL_COND(v.get_type() != Variant::RID);
#else
ERR_FAIL_COND(v.get_type() != Variant::_RID);
#endif
m[mesh_type_index] = value;
_rids[mesh_index] = m;

View File

@ -22,20 +22,9 @@ 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"
#include "core/string/ustring.h"
#include "core/variant/array.h"
#else
#include "core/array.h"
#include "core/engine.h"
#include "core/ustring.h"
#endif
#include "../terrain_2d_chunk.h"

View File

@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "../terrain_2d_world.h"
class Terrain2DWorldDefault : public Terrain2DWorld {

View File

@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "../default/terrain_2d_chunk_default.h"
class Terrain2DChunkIsometric : public Terrain2DChunkDefault {

View File

@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "../default/terrain_2d_world_default.h"
class Terrain2DWorldIsometric : public Terrain2DWorldDefault {

View File

@ -72,7 +72,6 @@ void Terrain2DJob::_reset() {
}
void Terrain2DJob::_execute() {
ActiveBuildPhaseType origpt = _build_phase_type;
while (!get_cancelled() && _in_tree && !_build_done && origpt == _build_phase_type && !should_return()) {
@ -259,7 +258,6 @@ Array Terrain2DJob::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const float
}
void Terrain2DJob::chunk_exit_tree() {
_in_tree = false;
if (get_complete()) {

View File

@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "scene/resources/texture.h"
#if THREAD_POOL_PRESENT
@ -32,21 +29,12 @@ SOFTWARE.
#else
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/object/reference.h"
#else
#include "core/reference.h"
#endif
#endif
#include "../../defines.h"
#if GODOT4
#define Texture Texture2D
#endif
class Terrain2DChunk;
#if THREAD_POOL_PRESENT

View File

@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "terrain_2d_job.h"
class Terrain2DMesher;

View File

@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "terrain_2d_job.h"
class Terrain2DMesher;

View File

@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "terrain_2d_job.h"
#include "../../defines.h"

View File

@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "../default/terrain_2d_chunk_default.h"
class Terrain2DChunkSimple : public Terrain2DChunkDefault {

View File

@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "../default/terrain_2d_world_default.h"
class Terrain2DWorldSimple : public Terrain2DWorldDefault {

View File

@ -22,22 +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/config/engine.h"
#include "core/io/resource.h"
#include "core/string/ustring.h"
#include "core/variant/array.h"
#else
#include "core/array.h"
#include "core/engine.h"
#include "core/resource.h"
#include "core/ustring.h"
#endif
#include "../defines.h"
@ -60,12 +48,6 @@ include_pool_vector
#include "../../props_2d/props/prop_2d_data.h"
#endif
#include "core/version.h"
#if VERSION_MAJOR >= 4
#define Texture Texture2D
#endif
#include "scene/resources/shape_2d.h"
#include "../library/terrain_2d_library.h"

View File

@ -87,11 +87,7 @@ Terrain2DEnvironmentData::~Terrain2DEnvironmentData() {
}
void Terrain2DEnvironmentData::_bind_methods() {
#if VERSION_MAJOR < 4
BIND_VMETHOD(MethodInfo("_setup", PropertyInfo(Variant::OBJECT, "world_environment", PROPERTY_HINT_RESOURCE_TYPE, "WorldEnvironment"), PropertyInfo(Variant::OBJECT, "primary_light", PROPERTY_HINT_RESOURCE_TYPE, "DirectionalLight"), PropertyInfo(Variant::OBJECT, "secondary_light", PROPERTY_HINT_RESOURCE_TYPE, "DirectionalLight")));
#else
GDVIRTUAL_BIND(_setup, "world_environment", "primary_light", "secondary_light");
#endif
ClassDB::bind_method(D_METHOD("get_environment"), &Terrain2DEnvironmentData::get_environment);
ClassDB::bind_method(D_METHOD("set_environment", "value"), &Terrain2DEnvironmentData::set_environment);

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/io/resource.h"
#include "core/math/color.h"
#else
#include "core/color.h"
#include "core/resource.h"
#endif
#include "../defines.h"
@ -59,10 +49,6 @@ public:
void setup(WorldEnvironment *world_environment, DirectionalLight *primary_light, DirectionalLight *secondary_light);
void setup_bind(Node *world_environment, Node *primary_light, Node *secondary_light);
#if VERSION_MAJOR >= 4
GDVIRTUAL3(_setup, WorldEnvironment *, DirectionalLight *, DirectionalLight *);
#endif
Terrain2DEnvironmentData();
~Terrain2DEnvironmentData();

View File

@ -73,11 +73,7 @@ Terrain2DStructure::~Terrain2DStructure() {
}
void Terrain2DStructure::_bind_methods() {
#if VERSION_MAJOR < 4
BIND_VMETHOD(MethodInfo("_write_to_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "Terrain2DChunk")));
#else
GDVIRTUAL_BIND(_write_to_chunk, "chunk");
#endif
ClassDB::bind_method(D_METHOD("get_use_rect"), &Terrain2DStructure::get_use_rect);
ClassDB::bind_method(D_METHOD("set_use_rect", "value"), &Terrain2DStructure::set_use_rect);

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/io/resource.h"
#include "core/templates/hash_map.h"
#else
#include "core/hash_map.h"
#include "core/resource.h"
#endif
#include "../defines.h"
@ -62,10 +52,6 @@ public:
void write_to_chunk(Ref<Terrain2DChunk> chunk);
#if VERSION_MAJOR >= 4
GDVIRTUAL1(_write_to_chunk, Ref<Terrain2DChunk>);
#endif
Terrain2DStructure();
~Terrain2DStructure();

View File

@ -22,8 +22,6 @@ SOFTWARE.
#include "terrain_2d_world.h"
#include "core/version.h"
#include "core/message_queue.h"
#include "terrain_2d_chunk.h"
#include "terrain_2d_structure.h"
@ -449,12 +447,7 @@ Ref<Terrain2DChunk> Terrain2DWorld::chunk_create(const int x, const int z) {
void Terrain2DWorld::chunk_setup(Ref<Terrain2DChunk> chunk) {
ERR_FAIL_COND(!chunk.is_valid());
#if VERSION_MAJOR < 4
call("_create_chunk", chunk->get_position_x(), chunk->get_position_y(), chunk);
#else
Ref<Terrain2DChunk> c;
GDVIRTUAL_CALL(_create_chunk, chunk->get_position_x(), chunk->get_position_y(), chunk, c);
#endif
}
Ref<Terrain2DChunk> Terrain2DWorld::_create_chunk(const int x, const int y, Ref<Terrain2DChunk> chunk) {
@ -1039,11 +1032,7 @@ void Terrain2DWorld::_notification(int p_what) {
}
}
#if VERSION_MAJOR > 3
if (_is_priority_generation && _generation_queue.is_empty() && _generating.is_empty()) {
#else
if (_is_priority_generation && _generation_queue.empty() && _generating.empty()) {
#endif
_is_priority_generation = false;
CALL(_generation_finished);
@ -1249,11 +1238,7 @@ void Terrain2DWorld::_bind_methods() {
ClassDB::bind_method(D_METHOD("voxel_structures_set"), &Terrain2DWorld::voxel_structures_set);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_structures", PROPERTY_HINT_NONE, "17/17:Terrain2DStructure", PROPERTY_USAGE_DEFAULT, "Terrain2DStructure"), "voxel_structures_set", "voxel_structures_get");
#if VERSION_MAJOR < 4
BIND_VMETHOD(MethodInfo("_chunk_added", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "Terrain2DChunk")));
#else
GDVIRTUAL_BIND(_chunk_added, "chunk");
#endif
ClassDB::bind_method(D_METHOD("chunk_add", "chunk", "x", "y"), &Terrain2DWorld::chunk_add);
ClassDB::bind_method(D_METHOD("chunk_has", "x", "y"), &Terrain2DWorld::chunk_has);
@ -1282,18 +1267,11 @@ void Terrain2DWorld::_bind_methods() {
ADD_SIGNAL(MethodInfo("generation_finished"));
#if VERSION_MAJOR < 4
BIND_VMETHOD(MethodInfo("_generation_finished"));
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "ret", PROPERTY_HINT_RESOURCE_TYPE, "Terrain2DChunk"), "_create_chunk", PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "Terrain2DChunk")));
BIND_VMETHOD(MethodInfo("_prepare_chunk_for_generation", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "Terrain2DChunk")));
BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "Terrain2DChunk")));
#else
GDVIRTUAL_BIND(_generation_finished);
GDVIRTUAL_BIND(_create_chunk, "chunk", "x", "y", "chunk", "ret");
GDVIRTUAL_BIND(_prepare_chunk_for_generation, "chunk");
GDVIRTUAL_BIND(_generate_chunk, "chunk");
#endif
ClassDB::bind_method(D_METHOD("chunk_get_or_create", "x", "y"), &Terrain2DWorld::chunk_get_or_create);
ClassDB::bind_method(D_METHOD("chunk_create", "x", "y"), &Terrain2DWorld::chunk_create);
@ -1325,24 +1303,16 @@ void Terrain2DWorld::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_chunk_at_world_position", "world_position"), &Terrain2DWorld::get_chunk_at_world_position);
ClassDB::bind_method(D_METHOD("get_or_create_chunk_at_world_position", "world_position"), &Terrain2DWorld::get_or_create_chunk_at_world_position);
#if VERSION_MAJOR < 4
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::INT, "ret"), "_get_channel_index_info", PropertyInfo(Variant::INT, "channel_type", PROPERTY_HINT_ENUM, BINDING_STRING_CHANNEL_TYPE_INFO)));
#else
GDVIRTUAL_BIND(_get_channel_index_info, "channel_type", "ret");
#endif
ClassDB::bind_method(D_METHOD("get_channel_index_info", "channel_type"), &Terrain2DWorld::get_channel_index_info);
ClassDB::bind_method(D_METHOD("_get_channel_index_info", "channel_type"), &Terrain2DWorld::_get_channel_index_info);
#if VERSION_MAJOR < 4
BIND_VMETHOD(MethodInfo("_set_voxel_with_tool",
PropertyInfo(Variant::BOOL, "mode_add"),
PropertyInfo(Variant::VECTOR2, "hit_position"),
PropertyInfo(Variant::INT, "selected_voxel"),
PropertyInfo(Variant::INT, "isolevel")));
#else
GDVIRTUAL_BIND(_set_voxel_with_tool, "mode_add", "hit_position", "selected_voxel", "isolevel");
#endif
ClassDB::bind_method(D_METHOD("set_voxel_with_tool", "mode_add", "hit_position", "selected_voxel", "isolevel"), &Terrain2DWorld::set_voxel_with_tool);
ClassDB::bind_method(D_METHOD("_set_voxel_with_tool", "mode_add", "hit_position", "selected_voxel", "isolevel"), &Terrain2DWorld::_set_voxel_with_tool);

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/config/engine.h"
#include "core/templates/hash_map.h"
#else
#include "core/engine.h"
#include "core/hash_map.h"
#endif
#include "../defines.h"
@ -209,20 +199,6 @@ public:
int get_channel_index_info(const ChannelTypeInfo channel_type);
#if VERSION_MAJOR >= 4
GDVIRTUAL1(_chunk_added, Ref<Terrain2DChunk>);
GDVIRTUAL0(_generation_finished);
GDVIRTUAL3R(Ref<Terrain2DChunk>, _create_chunk, int, int, Ref<Terrain2DChunk>);
GDVIRTUAL1(_prepare_chunk_for_generation, Ref<Terrain2DChunk>);
GDVIRTUAL1(_generate_chunk, Ref<Terrain2DChunk>);
GDVIRTUAL1R(int, _get_channel_index_info, int);
GDVIRTUAL5(_set_voxel_with_tool, bool, Vector3, Vector3, int, int);
#endif
Terrain2DWorld();
~Terrain2DWorld();

View File

@ -33,8 +33,8 @@ SOFTWARE.
#include "terrain_2d_chunk.h"
#include "../library/terrain_2d_surface.h"
#include "../library/terrain_2d_library.h"
#include "../library/terrain_2d_surface.h"
#include "../defines.h"
@ -42,7 +42,6 @@ SOFTWARE.
#include spatial_editor_plugin_h
#include camera_h
#if VERSION_MAJOR < 4
bool Terrain2DWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) {
if (!_world || !_world->get_editable()) {
return false;
@ -69,39 +68,6 @@ bool Terrain2DWorldEditor::forward_spatial_input_event(Camera *p_camera, const R
return false;
}
#else
EditorPlugin::AfterGUIInput Terrain2DWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) {
if (!_world || !_world->get_editable()) {
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
if (mb->is_pressed()) {
Ref<Terrain2DLibrary> lib = _world->get_library();
if (!lib.is_valid())
return EditorPlugin::AFTER_GUI_INPUT_PASS;
if (mb->get_button_index() == MouseButton::LEFT) {
if (do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true)) {
return EditorPlugin::AFTER_GUI_INPUT_STOP;
} else {
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
} else {
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
//return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
}
}
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
#endif
bool Terrain2DWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) {
/*
@ -343,14 +309,14 @@ void Terrain2DWorldEditor::_on_insert_block_at_camera_button_pressed() {
Vector3 pos = cam->get_transform().origin;
selected_voxel = _selected_type + 1;
*/
/*
if (_channel_isolevel == -1) {
_world->set_voxel_at_world_position(pos, selected_voxel, channel);
} else {
_world->set_voxel_at_world_position(pos, selected_voxel, channel, false);
_world->set_voxel_at_world_position(pos, _current_isolevel, _channel_isolevel);
}
*/
/*
if (_channel_isolevel == -1) {
_world->set_voxel_at_world_position(pos, selected_voxel, channel);
} else {
_world->set_voxel_at_world_position(pos, selected_voxel, channel, false);
_world->set_voxel_at_world_position(pos, _current_isolevel, _channel_isolevel);
}
*/
}
void Terrain2DWorldEditor::_on_isolevel_slider_value_changed(float value) {
@ -368,21 +334,12 @@ void Terrain2DWorldEditor::_bind_methods() {
void Terrain2DWorldEditorPlugin::_notification(int p_what) {
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
switch ((int)EditorSettings::get_singleton()->get("editors/voxelman/editor_side")) {
#if VERSION_MAJOR <= 3 && VERSION_MINOR < 5
case 0: { // Left.
SpatialEditor::get_singleton()->get_palette_split()->move_child(voxel_world_editor, 0);
} break;
case 1: { // Right.
SpatialEditor::get_singleton()->get_palette_split()->move_child(voxel_world_editor, 1);
} break;
#else
case 0: { // Left.
SpatialEditor::get_singleton()->move_control_to_left_panel(voxel_world_editor);
} break;
case 1: { // Right.
SpatialEditor::get_singleton()->move_control_to_right_panel(voxel_world_editor);
} break;
#endif
}
}
}

View File

@ -30,11 +30,6 @@ SOFTWARE.
#include "../defines.h"
#if VERSION_MAJOR > 3
#include "core/math/transform_3d.h"
typedef class Transform3D Transform;
#endif
class Terrain2DWorld;
class SpatialEditorPlugin;
@ -48,11 +43,7 @@ public:
};
public:
#if VERSION_MAJOR < 4
bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event);
#else
EditorPlugin::AfterGUIInput forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event);
#endif
void edit(Terrain2DWorld *p_world);
bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
@ -102,13 +93,8 @@ protected:
void _notification(int p_what);
public:
#if VERSION_MAJOR < 4
bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); }
virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); }
#else
EditorPlugin::AfterGUIInput forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); }
virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); }
#endif
virtual String get_name() const { return "Terrain2DWorldEditor"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_object);