mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-03-03 03:44:19 +01:00
Cleaned up Terraman's version checks.
This commit is contained in:
parent
24c8c121a5
commit
3039645b4a
@ -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"
|
||||
|
||||
|
@ -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 TerrainLight : public Reference {
|
||||
GDCLASS(TerrainLight, Reference);
|
||||
|
@ -2,32 +2,6 @@
|
||||
#ifndef TERRAIN_DEFINES_H
|
||||
#define TERRAIN_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,59 +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 GET_WORLD get_world_3d
|
||||
#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)
|
||||
@ -196,5 +64,3 @@ typedef class RenderingServer VS;
|
||||
return call(#func, ##__VA_ARGS__);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -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 TerrainChunk;
|
||||
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "terrain_level_generator.h"
|
||||
|
||||
class TerrainChunk;
|
||||
|
@ -32,119 +32,6 @@ SOFTWARE.
|
||||
|
||||
#include "scene/resources/packed_scene.h"
|
||||
|
||||
#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 TerrainLibrary::get_initialized() const {
|
||||
return _initialized;
|
||||
}
|
||||
@ -469,49 +356,21 @@ TerrainLibrary::~TerrainLibrary() {
|
||||
_prop_materials.clear();
|
||||
}
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
TMCGDVIRTUAL1(TerrainLibrary, _material_cache_get_key, Ref<TerrainChunk>);
|
||||
TMCGDVIRTUAL1R(TerrainLibrary, Ref<TerrainMaterialCache>, _material_cache_get, int);
|
||||
TMCGDVIRTUAL1(TerrainLibrary, _material_cache_unref, int);
|
||||
|
||||
TMCGDVIRTUAL1(TerrainLibrary, _liquid_material_cache_get_key, Ref<TerrainChunk>);
|
||||
TMCGDVIRTUAL1R(TerrainLibrary, Ref<TerrainMaterialCache>, _liquid_material_cache_get, int);
|
||||
TMCGDVIRTUAL1(TerrainLibrary, _liquid_material_cache_unref, int);
|
||||
|
||||
TMCGDVIRTUAL1(TerrainLibrary, _prop_material_cache_get_key, Ref<TerrainChunk>);
|
||||
TMCGDVIRTUAL1R(TerrainLibrary, Ref<TerrainMaterialCache>, _prop_material_cache_get, int);
|
||||
TMCGDVIRTUAL1(TerrainLibrary, _prop_material_cache_unref, int);
|
||||
#endif
|
||||
|
||||
void TerrainLibrary::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_initialized"), &TerrainLibrary::get_initialized);
|
||||
ClassDB::bind_method(D_METHOD("set_initialized", "value"), &TerrainLibrary::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"), &TerrainLibrary::_supports_caching);
|
||||
ClassDB::bind_method(D_METHOD("supports_caching"), &TerrainLibrary::supports_caching);
|
||||
|
||||
#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, "TerrainChunk")));
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "ret", PROPERTY_HINT_RESOURCE_TYPE, "TerrainMaterialCache"), "_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_get", "index"), &TerrainLibrary::material_get);
|
||||
ClassDB::bind_method(D_METHOD("material_lod_get", "index"), &TerrainLibrary::material_lod_get);
|
||||
@ -533,15 +392,9 @@ void TerrainLibrary::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("materials_set"), &TerrainLibrary::materials_set);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "materials_set", "materials_get");
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_liquid_material_cache_get_key", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerrainChunk")));
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "ret", PROPERTY_HINT_RESOURCE_TYPE, "TerrainMaterialCache"), "_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_get", "index"), &TerrainLibrary::liquid_material_get);
|
||||
ClassDB::bind_method(D_METHOD("liquid_material_lod_get", "index"), &TerrainLibrary::liquid_material_lod_get);
|
||||
@ -563,15 +416,9 @@ void TerrainLibrary::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("liquid_materials_set"), &TerrainLibrary::liquid_materials_set);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "liquid_materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "liquid_materials_set", "liquid_materials_get");
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_prop_material_cache_get_key", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerrainChunk")));
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "ret", PROPERTY_HINT_RESOURCE_TYPE, "TerrainMaterialCache"), "_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_get", "index"), &TerrainLibrary::prop_material_get);
|
||||
ClassDB::bind_method(D_METHOD("prop_material_lod_get", "index"), &TerrainLibrary::prop_material_lod_get);
|
||||
|
@ -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"
|
||||
@ -58,12 +30,6 @@ SOFTWARE.
|
||||
#include "../data/terrain_light.h"
|
||||
#include "terrain_surface.h"
|
||||
|
||||
#include "../defines.h"
|
||||
|
||||
#if GODOT4
|
||||
#define Texture Texture2D
|
||||
#endif
|
||||
|
||||
class TerrainMaterialCache;
|
||||
class TerrainSurface;
|
||||
class TerrainMesher;
|
||||
@ -177,24 +143,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<TerrainChunk>);
|
||||
TMHGDVIRTUAL1R(Ref<TerrainMaterialCache>, _material_cache_get, int);
|
||||
TMHGDVIRTUAL1(_material_cache_unref, int);
|
||||
|
||||
TMHGDVIRTUAL1(_liquid_material_cache_get_key, Ref<TerrainChunk>);
|
||||
TMHGDVIRTUAL1R(Ref<TerrainMaterialCache>, _liquid_material_cache_get, int);
|
||||
TMHGDVIRTUAL1(_liquid_material_cache_unref, int);
|
||||
|
||||
TMHGDVIRTUAL1(_prop_material_cache_get_key, Ref<TerrainChunk>);
|
||||
TMHGDVIRTUAL1R(Ref<TerrainMaterialCache>, _prop_material_cache_get, int);
|
||||
TMHGDVIRTUAL1(_prop_material_cache_unref, int);
|
||||
#endif
|
||||
|
||||
TerrainLibrary();
|
||||
~TerrainLibrary();
|
||||
|
||||
|
@ -367,11 +367,7 @@ void TerrainLibraryMerger::_setup_material_albedo(const int material_index, cons
|
||||
TerrainLibraryMerger::TerrainLibraryMerger() {
|
||||
_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);
|
||||
@ -379,11 +375,7 @@ TerrainLibraryMerger::TerrainLibraryMerger() {
|
||||
|
||||
_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);
|
||||
|
@ -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_library.h"
|
||||
|
||||
@ -106,9 +96,9 @@ protected:
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
Vector<Ref<TerrainSurfaceMerger> > _terra_surfaces;
|
||||
Vector<Ref<TerrainSurfaceMerger>> _terra_surfaces;
|
||||
#ifdef PROPS_PRESENT
|
||||
Vector<Ref<PropData> > _props;
|
||||
Vector<Ref<PropData>> _props;
|
||||
#endif
|
||||
|
||||
Ref<TexturePacker> _packer;
|
||||
|
@ -905,11 +905,7 @@ void TerrainLibraryMergerPCM::_setup_material_albedo(const int material_index, c
|
||||
TerrainLibraryMergerPCM::TerrainLibraryMergerPCM() {
|
||||
_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);
|
||||
@ -917,11 +913,7 @@ TerrainLibraryMergerPCM::TerrainLibraryMergerPCM() {
|
||||
|
||||
_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);
|
||||
|
@ -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_library.h"
|
||||
|
||||
@ -125,13 +115,13 @@ protected:
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
Map<int, Ref<TerrainMaterialCachePCM> > _material_cache;
|
||||
Map<int, Ref<TerrainMaterialCachePCM> > _liquid_material_cache;
|
||||
Map<int, Ref<TerrainMaterialCachePCM> > _prop_material_cache;
|
||||
Map<int, Ref<TerrainMaterialCachePCM>> _material_cache;
|
||||
Map<int, Ref<TerrainMaterialCachePCM>> _liquid_material_cache;
|
||||
Map<int, Ref<TerrainMaterialCachePCM>> _prop_material_cache;
|
||||
|
||||
Vector<Ref<TerrainSurfaceMerger> > _terra_surfaces;
|
||||
Vector<Ref<TerrainSurfaceMerger>> _terra_surfaces;
|
||||
#ifdef PROPS_PRESENT
|
||||
Vector<Ref<PropData> > _props;
|
||||
Vector<Ref<PropData>> _props;
|
||||
#endif
|
||||
|
||||
//todo remove these
|
||||
|
@ -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_library.h"
|
||||
|
||||
@ -72,7 +63,7 @@ protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
Vector<Ref<TerrainSurfaceSimple> > _terra_surfaces;
|
||||
Vector<Ref<TerrainSurfaceSimple>> _terra_surfaces;
|
||||
|
||||
//atlas
|
||||
int _atlas_columns;
|
||||
|
@ -256,13 +256,9 @@ void TerrainMaterialCache::refresh_rects() {
|
||||
}
|
||||
|
||||
void TerrainMaterialCache::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
|
||||
}
|
||||
|
||||
TerrainMaterialCache::TerrainMaterialCache() {
|
||||
@ -286,11 +282,7 @@ void TerrainMaterialCache::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("inc_ref_count"), &TerrainMaterialCache::inc_ref_count);
|
||||
ClassDB::bind_method(D_METHOD("dec_ref_count"), &TerrainMaterialCache::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", "index"), &TerrainMaterialCache::material_get);
|
||||
ClassDB::bind_method(D_METHOD("material_lod_get", "index"), &TerrainMaterialCache::material_lod_get);
|
||||
|
@ -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"
|
||||
@ -96,10 +85,6 @@ public:
|
||||
|
||||
void setup_material_albedo(Ref<Texture> texture);
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
GDVIRTUAL1(_setup_material_albedo, Ref<Texture>);
|
||||
#endif
|
||||
|
||||
TerrainMaterialCache();
|
||||
~TerrainMaterialCache();
|
||||
|
||||
|
@ -181,11 +181,7 @@ void TerrainMaterialCachePCM::_setup_material_albedo(Ref<Texture> texture) {
|
||||
TerrainMaterialCachePCM::TerrainMaterialCachePCM() {
|
||||
_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);
|
||||
|
@ -22,22 +22,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "terrain_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"
|
||||
|
@ -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"
|
||||
@ -57,9 +45,9 @@ public:
|
||||
I_____I/
|
||||
|
||||
|
||||
I y
|
||||
I I
|
||||
O----- x I B
|
||||
I y
|
||||
I I
|
||||
O----- x I B
|
||||
/ I F I /
|
||||
/ z+ I ---I/
|
||||
*/
|
||||
|
@ -24,12 +24,6 @@ SOFTWARE.
|
||||
|
||||
#include "terrain_library_merger.h"
|
||||
|
||||
#include "../defines.h"
|
||||
|
||||
#if GODOT4
|
||||
#define Texture Texture2D
|
||||
#endif
|
||||
|
||||
Ref<AtlasTexture> TerrainSurfaceMerger::get_region(const TerrainSurfaceSides side) {
|
||||
return _regions[side];
|
||||
}
|
||||
|
@ -22,21 +22,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "terrain_surface.h"
|
||||
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
#include "../../texture_packer/texture_packer.h"
|
||||
|
||||
#include "../defines.h"
|
||||
|
||||
#if GODOT4
|
||||
#define Texture Texture2D
|
||||
#endif
|
||||
|
||||
class TerrainSurfaceMerger : public TerrainSurface {
|
||||
GDCLASS(TerrainSurfaceMerger, TerrainSurface)
|
||||
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "terrain_surface.h"
|
||||
|
||||
class TerrainSurfaceSimple : public TerrainSurface {
|
||||
|
@ -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_mesher_default.h"
|
||||
#include "../../world/default/terrain_chunk_default.h"
|
||||
#include "../default/terrain_mesher_default.h"
|
||||
|
||||
class TerrainMesherBlocky : public TerrainMesherDefault {
|
||||
GDCLASS(TerrainMesherBlocky, TerrainMesherDefault);
|
||||
|
@ -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"
|
||||
|
@ -180,21 +180,13 @@ Array TerrainMesher::build_mesh() {
|
||||
{
|
||||
PoolVector<Vector3> array;
|
||||
array.resize(_vertices.size());
|
||||
#if !GODOT4
|
||||
PoolVector<Vector3>::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;
|
||||
}
|
||||
@ -206,63 +198,39 @@ Array TerrainMesher::build_mesh() {
|
||||
{
|
||||
PoolVector<Vector3> array;
|
||||
array.resize(_vertices.size());
|
||||
#if !GODOT4
|
||||
PoolVector<Vector3>::Write w = array.write();
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < _vertices.size(); ++i) {
|
||||
#if !GODOT4
|
||||
w[i] = _vertices[i].normal;
|
||||
#else
|
||||
array.set(i, _vertices[i].normal);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GODOT4
|
||||
w.release();
|
||||
#endif
|
||||
a[VisualServer::ARRAY_NORMAL] = array;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@ -270,42 +238,27 @@ Array TerrainMesher::build_mesh() {
|
||||
if ((_format & VisualServer::ARRAY_FORMAT_TEX_UV2) != 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].uv2;
|
||||
#else
|
||||
array.set(i, _vertices[i].uv2);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GODOT4
|
||||
w.release();
|
||||
#endif
|
||||
a[VisualServer::ARRAY_TEX_UV2] = array;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -965,15 +918,9 @@ TerrainMesher::~TerrainMesher() {
|
||||
}
|
||||
|
||||
void TerrainMesher::_bind_methods() {
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_add_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerrainChunk")));
|
||||
BIND_VMETHOD(MethodInfo("_bake_colors", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerrainChunk")));
|
||||
BIND_VMETHOD(MethodInfo("_bake_liquid_colors", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerrainChunk")));
|
||||
#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"), &TerrainMesher::get_channel_index_type);
|
||||
ClassDB::bind_method(D_METHOD("set_channel_index_type", "value"), &TerrainMesher::set_channel_index_type);
|
||||
@ -1035,11 +982,7 @@ void TerrainMesher::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform_colored", "mesh", "transform", "colors", "uv_rect"), &TerrainMesher::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, "TerrainMesher")));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_add_mesher, "mesher");
|
||||
#endif
|
||||
ClassDB::bind_method(D_METHOD("add_mesher", "mesher"), &TerrainMesher::add_mesher);
|
||||
ClassDB::bind_method(D_METHOD("_add_mesher", "mesher"), &TerrainMesher::_add_mesher);
|
||||
|
||||
|
@ -22,28 +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/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
|
||||
|
||||
#include "../defines.h"
|
||||
|
||||
#include pool_vector_h
|
||||
include_pool_vector
|
||||
|
||||
#include mesh_instance_h
|
||||
|
||||
@ -60,7 +45,7 @@ include_pool_vector
|
||||
|
||||
#include "../library/terrain_library.h"
|
||||
|
||||
class TerrainLibrary;
|
||||
class TerrainLibrary;
|
||||
class TerrainChunk;
|
||||
|
||||
class TerrainMesher : public Reference {
|
||||
@ -199,13 +184,6 @@ public:
|
||||
void remove_index(const int idx);
|
||||
void add_indices(const int index);
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
GDVIRTUAL1(_add_chunk, Ref<TerrainChunk>);
|
||||
GDVIRTUAL1(_bake_colors, Ref<TerrainChunk>);
|
||||
GDVIRTUAL1(_bake_liquid_colors, Ref<TerrainChunk>);
|
||||
GDVIRTUAL1(_add_mesher, Ref<TerrainChunk>);
|
||||
#endif
|
||||
|
||||
TerrainMesher(const Ref<TerrainLibrary> &library);
|
||||
TerrainMesher();
|
||||
~TerrainMesher();
|
||||
|
@ -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"
|
||||
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
void register_terraman_types();
|
||||
void unregister_terraman_types();
|
||||
|
||||
|
@ -22,26 +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/templates/vector.h"
|
||||
#else
|
||||
#include "core/vector.h"
|
||||
#endif
|
||||
|
||||
#include "terrain_structure.h"
|
||||
|
||||
#include "../defines.h"
|
||||
|
||||
#include pool_vector_h
|
||||
include_pool_vector
|
||||
|
||||
#include "terrain_chunk.h"
|
||||
;
|
||||
|
||||
class BlockTerrainStructure : public TerrainStructure {
|
||||
GDCLASS(BlockTerrainStructure, TerrainStructure);
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "../default/terrain_chunk_default.h"
|
||||
|
||||
class TerrainChunkBlocky : public TerrainChunkDefault {
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "../default/terrain_world_default.h"
|
||||
|
||||
class TerrainWorldBlocky : public TerrainWorldDefault {
|
||||
|
@ -125,13 +125,8 @@ RID TerrainChunkDefault::mesh_rid_get(const int mesh_index, const int mesh_type_
|
||||
|
||||
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;
|
||||
}
|
||||
@ -149,11 +144,7 @@ void TerrainChunkDefault::mesh_rid_set(const int mesh_index, const int mesh_type
|
||||
|
||||
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;
|
||||
|
@ -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/string/ustring.h"
|
||||
#include "core/config/engine.h"
|
||||
#include "core/variant/array.h"
|
||||
#else
|
||||
#include "core/ustring.h"
|
||||
#include "core/engine.h"
|
||||
#include "core/array.h"
|
||||
#endif
|
||||
|
||||
#include "core/engine.h"
|
||||
#include "core/ustring.h"
|
||||
|
||||
#include "../terrain_chunk.h"
|
||||
|
||||
@ -46,12 +34,12 @@ SOFTWARE.
|
||||
#include "core/os/thread.h"
|
||||
#include "core/os/thread_safe.h"
|
||||
|
||||
#include "scene/resources/packed_scene.h"
|
||||
#include "../terrain_world.h"
|
||||
#include "../../data/terrain_light.h"
|
||||
#include "../../meshers/terrain_mesher.h"
|
||||
#include "../../library/terrain_surface.h"
|
||||
#include "../../library/terrain_library.h"
|
||||
#include "../../library/terrain_surface.h"
|
||||
#include "../../meshers/terrain_mesher.h"
|
||||
#include "../terrain_world.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
|
||||
class TerrainWorld;
|
||||
class TerrainJob;
|
||||
@ -224,7 +212,7 @@ protected:
|
||||
RID _debug_mesh_instance;
|
||||
PoolVector3Array _debug_mesh_array;
|
||||
|
||||
Vector<Ref<TerrainLight> > _lights;
|
||||
Vector<Ref<TerrainLight>> _lights;
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(TerrainChunkDefault::DefaultChannels);
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "../terrain_world.h"
|
||||
|
||||
class TerrainWorldDefault : public TerrainWorld {
|
||||
|
@ -72,7 +72,6 @@ void TerrainJob::_reset() {
|
||||
}
|
||||
|
||||
void TerrainJob::_execute() {
|
||||
|
||||
ActiveBuildPhaseType origpt = _build_phase_type;
|
||||
|
||||
while (!get_cancelled() && _in_tree && !_build_done && origpt == _build_phase_type && !should_return()) {
|
||||
@ -162,7 +161,6 @@ void TerrainJob::generate_random_ao(int seed, int octaves, int period, float per
|
||||
|
||||
for (int x = -margin_start; x < size_x + margin_end; ++x) {
|
||||
for (int z = -margin_start; z < size_z + margin_end; ++z) {
|
||||
|
||||
float val = noise->get_noise_3d(x + (position_x * size_x), 0, z + (position_z * size_z));
|
||||
|
||||
val *= scale_factor;
|
||||
@ -258,9 +256,7 @@ Array TerrainJob::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const float mu
|
||||
if (colors.size() < uvs.size())
|
||||
colors.resize(uvs.size());
|
||||
|
||||
#if !GODOT4
|
||||
img->lock();
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < uvs.size(); ++i) {
|
||||
Vector2 uv = uvs[i];
|
||||
@ -274,9 +270,7 @@ Array TerrainJob::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const float mu
|
||||
colors.set(i, colors[i] * c * mul_color);
|
||||
}
|
||||
|
||||
#if !GODOT4
|
||||
img->unlock();
|
||||
#endif
|
||||
|
||||
arr[VisualServer::ARRAY_COLOR] = colors;
|
||||
|
||||
@ -284,7 +278,6 @@ Array TerrainJob::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const float mu
|
||||
}
|
||||
|
||||
void TerrainJob::chunk_exit_tree() {
|
||||
|
||||
_in_tree = false;
|
||||
|
||||
if (get_complete()) {
|
||||
|
@ -22,31 +22,16 @@ 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
|
||||
#include "../../../thread_pool/thread_pool_job.h"
|
||||
#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 TerrainChunk;
|
||||
|
||||
#if THREAD_POOL_PRESENT
|
||||
|
@ -24,8 +24,8 @@ SOFTWARE.
|
||||
|
||||
#include "../../defines.h"
|
||||
|
||||
#include "../../library/terrain_surface.h"
|
||||
#include "../../library/terrain_library.h"
|
||||
#include "../../library/terrain_surface.h"
|
||||
|
||||
#include "../../meshers/terrain_mesher.h"
|
||||
#include "../default/terrain_chunk_default.h"
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "terrain_job.h"
|
||||
|
||||
class TerrainMesher;
|
||||
|
@ -22,19 +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/object/ref_counted.h"
|
||||
#ifndef Reference
|
||||
#define Reference RefCounted
|
||||
#endif
|
||||
#else
|
||||
#include "core/reference.h"
|
||||
#endif
|
||||
|
||||
#ifdef MESH_UTILS_PRESENT
|
||||
#include "../../../mesh_utils/fast_quadratic_mesh_simplifier.h"
|
||||
@ -66,19 +54,19 @@ public:
|
||||
int get_lod_index() const;
|
||||
void set_lod_index(const int value);
|
||||
|
||||
#ifdef MESH_UTILS_PRESENT
|
||||
Ref<FastQuadraticMeshSimplifier> get_fqms();
|
||||
void set_fqms(const Ref<FastQuadraticMeshSimplifier> &val);
|
||||
#ifdef MESH_UTILS_PRESENT
|
||||
Ref<FastQuadraticMeshSimplifier> get_fqms();
|
||||
void set_fqms(const Ref<FastQuadraticMeshSimplifier> &val);
|
||||
|
||||
float get_simplification_step_ratio() const;
|
||||
void set_simplification_step_ratio(const float value);
|
||||
float get_simplification_step_ratio() const;
|
||||
void set_simplification_step_ratio(const float value);
|
||||
|
||||
int get_simplification_steps() const;
|
||||
void set_simplification_steps(const int value);
|
||||
int get_simplification_steps() const;
|
||||
void set_simplification_steps(const int value);
|
||||
|
||||
float get_simplification_agressiveness() const;
|
||||
void set_simplification_agressiveness(const float value);
|
||||
#endif
|
||||
float get_simplification_agressiveness() const;
|
||||
void set_simplification_agressiveness(const float value);
|
||||
#endif
|
||||
|
||||
TerrainMesherJobStep();
|
||||
~TerrainMesherJobStep();
|
||||
@ -89,12 +77,12 @@ protected:
|
||||
TerrainMesherJobStepType _job_type;
|
||||
int _lod_index;
|
||||
|
||||
#ifdef MESH_UTILS_PRESENT
|
||||
Ref<FastQuadraticMeshSimplifier> _fqms;
|
||||
float _simplification_step_ratio;
|
||||
int _simplification_steps;
|
||||
float _simplification_agressiveness;
|
||||
#endif
|
||||
#ifdef MESH_UTILS_PRESENT
|
||||
Ref<FastQuadraticMeshSimplifier> _fqms;
|
||||
float _simplification_step_ratio;
|
||||
int _simplification_steps;
|
||||
float _simplification_agressiveness;
|
||||
#endif
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(TerrainMesherJobStep::TerrainMesherJobStepType);
|
||||
|
@ -24,15 +24,15 @@ SOFTWARE.
|
||||
|
||||
#include "../../defines.h"
|
||||
|
||||
#include "../../library/terrain_library.h"
|
||||
#include "../../library/terrain_material_cache.h"
|
||||
#include "../../library/terrain_surface.h"
|
||||
#include "../../library/terrain_library.h"
|
||||
|
||||
#include "../../meshers/default/terrain_mesher_default.h"
|
||||
#include "../../meshers/terrain_mesher.h"
|
||||
#include "../default/terrain_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"
|
||||
@ -302,7 +302,7 @@ void TerrainPropJob::phase_setup() {
|
||||
|
||||
#if MESH_DATA_RESOURCE_PRESENT
|
||||
for (int i = 0; i < _chunk->mesh_data_resource_get_count(); ++i) {
|
||||
Ref<Texture> tex = _chunk->mesh_data_resource_get_texture(i);
|
||||
Ref<Texture> tex = _chunk->mesh_data_resource_get_texture(i);
|
||||
|
||||
if (!tex.is_valid())
|
||||
continue;
|
||||
@ -391,11 +391,7 @@ void TerrainPropJob::phase_steps() {
|
||||
mesh_rid = chunk->mesh_rid_get_index(TerrainChunkDefault::MESH_INDEX_PROP, TerrainChunkDefault::MESH_TYPE_INDEX_MESH, i);
|
||||
|
||||
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
|
||||
#if !GODOT4
|
||||
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
|
||||
#else
|
||||
VS::get_singleton()->mesh_clear(mesh_rid);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "terrain_job.h"
|
||||
|
||||
#include "terrain_mesher_job_step.h"
|
||||
|
@ -325,11 +325,7 @@ void TerrainTerrainJob::phase_terrain_mesh() {
|
||||
mesh_rid = chunk->mesh_rid_get_index(TerrainChunkDefault::MESH_INDEX_TERRAIN, TerrainChunkDefault::MESH_TYPE_INDEX_MESH, i);
|
||||
|
||||
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
|
||||
#if !GODOT4
|
||||
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
|
||||
#else
|
||||
VS::get_singleton()->mesh_clear(mesh_rid);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,11 +385,7 @@ void TerrainTerrainJob::phase_terrain_mesh() {
|
||||
}
|
||||
|
||||
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
|
||||
#if !GODOT4
|
||||
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
|
||||
#else
|
||||
VS::get_singleton()->mesh_clear(mesh_rid);
|
||||
#endif
|
||||
|
||||
if (should_return()) {
|
||||
return;
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "terrain_job.h"
|
||||
|
||||
#include "terrain_mesher_job_step.h"
|
||||
@ -33,9 +30,7 @@ SOFTWARE.
|
||||
|
||||
#include pool_vector_h
|
||||
|
||||
include_pool_vector
|
||||
|
||||
class TerrainMesher;
|
||||
class TerrainMesher;
|
||||
|
||||
class TerrainTerrainJob : public TerrainJob {
|
||||
GDCLASS(TerrainTerrainJob, TerrainJob);
|
||||
@ -82,7 +77,7 @@ protected:
|
||||
Ref<TerrainMesher> _mesher;
|
||||
Ref<TerrainMesher> _liquid_mesher;
|
||||
|
||||
Vector<Ref<TerrainMesherJobStep> > _job_steps;
|
||||
Vector<Ref<TerrainMesherJobStep>> _job_steps;
|
||||
int _current_job_step;
|
||||
int _current_mesh;
|
||||
|
||||
|
@ -543,15 +543,11 @@ PoolByteArray TerrainChunk::channel_get_compressed(const int channel_index) cons
|
||||
int bound = LZ4_compressBound(size);
|
||||
arr.resize(bound);
|
||||
|
||||
#if !GODOT4
|
||||
PoolByteArray::Write w = arr.write();
|
||||
|
||||
int ns = LZ4_compress_default(reinterpret_cast<char *>(ch), reinterpret_cast<char *>(w.ptr()), size, bound);
|
||||
|
||||
w.release();
|
||||
#else
|
||||
int ns = LZ4_compress_default(reinterpret_cast<char *>(ch), reinterpret_cast<char *>(arr.ptrw()), size, bound);
|
||||
#endif
|
||||
arr.resize(ns);
|
||||
|
||||
return arr;
|
||||
@ -577,19 +573,12 @@ void TerrainChunk::channel_set_compressed(const int channel_index, const PoolByt
|
||||
|
||||
int ds = data.size();
|
||||
|
||||
#if !GODOT4
|
||||
PoolByteArray::Read r = data.read();
|
||||
|
||||
//We are not going to write to it
|
||||
uint8_t *data_arr = const_cast<uint8_t *>(r.ptr());
|
||||
|
||||
LZ4_decompress_safe(reinterpret_cast<char *>(data_arr), reinterpret_cast<char *>(ch), ds, size);
|
||||
#else
|
||||
//We are not going to write to it
|
||||
uint8_t *data_arr = const_cast<uint8_t *>(data.ptr());
|
||||
|
||||
LZ4_decompress_safe(reinterpret_cast<char *>(data_arr), reinterpret_cast<char *>(ch), ds, size);
|
||||
#endif
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ int TerrainChunk::get_index(const int x, const int z) const {
|
||||
|
@ -22,27 +22,14 @@ 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"
|
||||
|
||||
#include pool_vector_h
|
||||
include_pool_vector
|
||||
|
||||
#include "core/os/mutex.h"
|
||||
#include "core/os/thread.h"
|
||||
@ -62,13 +49,8 @@ include_pool_vector
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
#define Texture Texture2D
|
||||
#endif
|
||||
|
||||
#include "../library/terrain_surface.h"
|
||||
#include "../library/terrain_library.h"
|
||||
; //hackfix for a clang format issue
|
||||
#include "../library/terrain_surface.h"
|
||||
|
||||
class TerrainJob;
|
||||
class TerrainWorld;
|
||||
|
@ -87,11 +87,7 @@ TerrainEnvironmentData::~TerrainEnvironmentData() {
|
||||
}
|
||||
|
||||
void TerrainEnvironmentData::_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"), &TerrainEnvironmentData::get_environment);
|
||||
ClassDB::bind_method(D_METHOD("set_environment", "value"), &TerrainEnvironmentData::set_environment);
|
||||
|
@ -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
|
||||
|
||||
TerrainEnvironmentData();
|
||||
~TerrainEnvironmentData();
|
||||
|
||||
|
@ -82,11 +82,7 @@ TerrainStructure::~TerrainStructure() {
|
||||
}
|
||||
|
||||
void TerrainStructure::_bind_methods() {
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_write_to_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerrainChunk")));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_write_to_chunk, "chunk");
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_use_aabb"), &TerrainStructure::get_use_aabb);
|
||||
ClassDB::bind_method(D_METHOD("set_use_aabb", "value"), &TerrainStructure::set_use_aabb);
|
||||
|
@ -22,27 +22,17 @@ 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"
|
||||
|
||||
#include pool_vector_h
|
||||
include_pool_vector
|
||||
|
||||
#include "core/math/aabb.h"
|
||||
#include "terrain_chunk.h"
|
||||
|
||||
class TerrainStructure : public Resource {
|
||||
class TerrainStructure : public Resource {
|
||||
GDCLASS(TerrainStructure, Resource);
|
||||
|
||||
public:
|
||||
@ -65,10 +55,6 @@ public:
|
||||
|
||||
void write_to_chunk(Ref<TerrainChunk> chunk);
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
GDVIRTUAL1(_write_to_chunk, Ref<TerrainChunk>);
|
||||
#endif
|
||||
|
||||
TerrainStructure();
|
||||
~TerrainStructure();
|
||||
|
||||
|
@ -22,8 +22,6 @@ SOFTWARE.
|
||||
|
||||
#include "terrain_world.h"
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#include "core/message_queue.h"
|
||||
#include "terrain_chunk.h"
|
||||
#include "terrain_structure.h"
|
||||
@ -400,12 +398,7 @@ Ref<TerrainChunk> TerrainWorld::chunk_create(const int x, const int z) {
|
||||
void TerrainWorld::chunk_setup(Ref<TerrainChunk> chunk) {
|
||||
ERR_FAIL_COND(!chunk.is_valid());
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
call("_create_chunk", chunk->get_position_x(), chunk->get_position_z(), chunk);
|
||||
#else
|
||||
Ref<TerrainChunk> c;
|
||||
GDVIRTUAL_CALL(_create_chunk, chunk->get_position_x(), chunk->get_position_z(), chunk, c);
|
||||
#endif
|
||||
}
|
||||
|
||||
Ref<TerrainChunk> TerrainWorld::_create_chunk(const int x, const int z, Ref<TerrainChunk> chunk) {
|
||||
@ -983,11 +976,7 @@ void TerrainWorld::_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);
|
||||
@ -1162,11 +1151,7 @@ void TerrainWorld::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("voxel_structures_set"), &TerrainWorld::voxel_structures_set);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_structures", PROPERTY_HINT_NONE, "17/17:TerrainStructure", PROPERTY_USAGE_DEFAULT, "TerrainStructure"), "voxel_structures_set", "voxel_structures_get");
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_chunk_added", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerrainChunk")));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_chunk_added, "chunk");
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("chunk_add", "chunk", "x", "z"), &TerrainWorld::chunk_add);
|
||||
ClassDB::bind_method(D_METHOD("chunk_has", "x", "z"), &TerrainWorld::chunk_has);
|
||||
@ -1195,18 +1180,11 @@ void TerrainWorld::_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, "TerrainChunk"), "_create_chunk", PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "z"), PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerrainChunk")));
|
||||
BIND_VMETHOD(MethodInfo("_prepare_chunk_for_generation", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerrainChunk")));
|
||||
BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerrainChunk")));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_generation_finished);
|
||||
GDVIRTUAL_BIND(_create_chunk, "chunk", "x", "z", "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", "z"), &TerrainWorld::chunk_get_or_create);
|
||||
ClassDB::bind_method(D_METHOD("chunk_create", "x", "z"), &TerrainWorld::chunk_create);
|
||||
@ -1238,27 +1216,19 @@ void TerrainWorld::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_chunk_at_world_position", "world_position"), &TerrainWorld::get_chunk_at_world_position);
|
||||
ClassDB::bind_method(D_METHOD("get_or_create_chunk_at_world_position", "world_position"), &TerrainWorld::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"), &TerrainWorld::get_channel_index_info);
|
||||
ClassDB::bind_method(D_METHOD("_get_channel_index_info", "channel_type"), &TerrainWorld::_get_channel_index_info);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_editor_camera"), &TerrainWorld::get_editor_camera);
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_set_voxel_with_tool",
|
||||
PropertyInfo(Variant::BOOL, "mode_add"),
|
||||
PropertyInfo(Variant::VECTOR3, "hit_position"),
|
||||
PropertyInfo(Variant::VECTOR3, "hit_normal"),
|
||||
PropertyInfo(Variant::INT, "selected_voxel"),
|
||||
PropertyInfo(Variant::INT, "isolevel")));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_set_voxel_with_tool, "mode_add", "hit_position", "hit_normal", "selected_voxel", "isolevel");
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_voxel_with_tool", "mode_add", "hit_position", "hit_normal", "selected_voxel", "isolevel"), &TerrainWorld::set_voxel_with_tool);
|
||||
ClassDB::bind_method(D_METHOD("_set_voxel_with_tool", "mode_add", "hit_position", "hit_normal", "selected_voxel", "isolevel"), &TerrainWorld::_set_voxel_with_tool);
|
||||
|
@ -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"
|
||||
|
||||
@ -196,20 +186,6 @@ public:
|
||||
|
||||
Spatial *get_editor_camera();
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
GDVIRTUAL1(_chunk_added, Ref<TerrainChunk>);
|
||||
|
||||
GDVIRTUAL0(_generation_finished);
|
||||
|
||||
GDVIRTUAL3R(Ref<TerrainChunk>, _create_chunk, int, int, Ref<TerrainChunk>);
|
||||
GDVIRTUAL1(_prepare_chunk_for_generation, Ref<TerrainChunk>);
|
||||
GDVIRTUAL1(_generate_chunk, Ref<TerrainChunk>);
|
||||
|
||||
GDVIRTUAL1R(int, _get_channel_index_info, int);
|
||||
|
||||
GDVIRTUAL5(_set_voxel_with_tool, bool, Vector3, Vector3, int, int);
|
||||
#endif
|
||||
|
||||
TerrainWorld();
|
||||
~TerrainWorld();
|
||||
|
||||
|
@ -33,10 +33,10 @@ SOFTWARE.
|
||||
|
||||
#include "terrain_chunk.h"
|
||||
|
||||
#include "../library/terrain_surface.h"
|
||||
#include "../library/terrain_library.h"
|
||||
#include "servers/physics_server.h"
|
||||
#include "../library/terrain_surface.h"
|
||||
#include "scene/resources/world.h"
|
||||
#include "servers/physics_server.h"
|
||||
|
||||
#include "../defines.h"
|
||||
|
||||
@ -44,7 +44,6 @@ SOFTWARE.
|
||||
#include spatial_editor_plugin_h
|
||||
#include camera_h
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
bool TerrainWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) {
|
||||
if (!_world || !_world->get_editable()) {
|
||||
return false;
|
||||
@ -71,39 +70,6 @@ bool TerrainWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref
|
||||
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
EditorPlugin::AfterGUIInput TerrainWorldEditor::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<TerrainLibrary> 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 TerrainWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) {
|
||||
if (!spatial_editor || !_world || !_world->is_inside_world())
|
||||
@ -366,21 +332,12 @@ void TerrainWorldEditor::_bind_methods() {
|
||||
void TerrainWorldEditorPlugin::_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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,13 +28,6 @@ SOFTWARE.
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_plugin.h"
|
||||
|
||||
#include "../defines.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/math/transform_3d.h"
|
||||
typedef class Transform3D Transform;
|
||||
#endif
|
||||
|
||||
class TerrainWorld;
|
||||
class SpatialEditorPlugin;
|
||||
|
||||
@ -48,11 +41,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(TerrainWorld *p_world);
|
||||
bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
|
||||
@ -102,13 +91,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 "TerrainWorldEditor"; }
|
||||
bool has_main_screen() const { return false; }
|
||||
virtual void edit(Object *p_object);
|
||||
|
Loading…
Reference in New Issue
Block a user