mirror of
https://github.com/Relintai/voxelman.git
synced 2025-02-20 17:04:23 +01:00
Moved 4.0 compatibility code into a new defines.h (like in ESS).
This commit is contained in:
parent
703acd1b56
commit
1d51be2f0b
120
defines.h
Normal file
120
defines.h
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
|
||||||
|
#ifndef VOXELMAN_DEFINES_H
|
||||||
|
#define VOXELMAN_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/navigation_3d.h"
|
||||||
|
#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/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"
|
||||||
|
#define spatial_h "scene/3d/spatial.h"
|
||||||
|
#define navigation_h "scene/3d/navigation.h"
|
||||||
|
#define light_h "scene/3d/light.h"
|
||||||
|
#define visual_server_h "servers/visual_server.h"
|
||||||
|
#define mesh_instance_h "scene/3d/mesh_instance.h"
|
||||||
|
#define pool_vector_h "core/pool_vector.h"
|
||||||
|
#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
|
||||||
|
|
||||||
|
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; \
|
||||||
|
for (int i = 0; i < arr.size(); i++) { \
|
||||||
|
r.push_back(arr[i].get_ref_ptr()); \
|
||||||
|
} \
|
||||||
|
return r;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define VARIANT_ARRAY_SET(arr, arr_into, type) \
|
||||||
|
arr_into.clear(); \
|
||||||
|
for (int i = 0; i < arr.size(); i++) { \
|
||||||
|
Ref<type> e = Ref<type>(arr[i]); \
|
||||||
|
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
|
||||||
|
#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)
|
||||||
|
#define GET_WORLD get_world
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -24,12 +24,10 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "voxelman_library_merger.h"
|
#include "voxelman_library_merger.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "../defines.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR >= 4
|
#if GODOT4
|
||||||
#define Texture Texture2D
|
#define Texture Texture2D
|
||||||
|
|
||||||
typedef class StandardMaterial3D SpatialMaterial;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Ref<AtlasTexture> VoxelSurfaceMerger::get_region(const VoxelSurfaceSides side) {
|
Ref<AtlasTexture> VoxelSurfaceMerger::get_region(const VoxelSurfaceSides side) {
|
||||||
|
@ -29,9 +29,9 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "../../texture_packer/texture_packer.h"
|
#include "../../texture_packer/texture_packer.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "../defines.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR >= 4
|
#if GODOT4
|
||||||
#define Texture Texture2D
|
#define Texture Texture2D
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "scene/resources/packed_scene.h"
|
#include "scene/resources/packed_scene.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "../defines.h"
|
||||||
|
|
||||||
bool VoxelmanLibrary::get_initialized() const {
|
bool VoxelmanLibrary::get_initialized() const {
|
||||||
return _initialized;
|
return _initialized;
|
||||||
@ -65,15 +65,7 @@ void VoxelmanLibrary::clear_materials() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector<Variant> VoxelmanLibrary::get_materials() {
|
Vector<Variant> VoxelmanLibrary::get_materials() {
|
||||||
Vector<Variant> r;
|
VARIANT_ARRAY_GET(_materials);
|
||||||
for (int i = 0; i < _materials.size(); i++) {
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
r.push_back(_materials[i].get_ref_ptr());
|
|
||||||
#else
|
|
||||||
r.push_back(_materials[i]);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelmanLibrary::set_materials(const Vector<Variant> &materials) {
|
void VoxelmanLibrary::set_materials(const Vector<Variant> &materials) {
|
||||||
@ -118,15 +110,7 @@ void VoxelmanLibrary::clear_liquid_materials() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector<Variant> VoxelmanLibrary::get_liquid_materials() {
|
Vector<Variant> VoxelmanLibrary::get_liquid_materials() {
|
||||||
Vector<Variant> r;
|
VARIANT_ARRAY_GET(_liquid_materials);
|
||||||
for (int i = 0; i < _liquid_materials.size(); i++) {
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
r.push_back(_liquid_materials[i].get_ref_ptr());
|
|
||||||
#else
|
|
||||||
r.push_back(_liquid_materials[i]);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelmanLibrary::set_liquid_materials(const Vector<Variant> &materials) {
|
void VoxelmanLibrary::set_liquid_materials(const Vector<Variant> &materials) {
|
||||||
|
@ -25,11 +25,7 @@ SOFTWARE.
|
|||||||
#include "scene/resources/packed_scene.h"
|
#include "scene/resources/packed_scene.h"
|
||||||
#include "scene/resources/texture.h"
|
#include "scene/resources/texture.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "../defines.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR >= 4
|
|
||||||
#define SpatialMaterial StandardMaterial3D
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int VoxelmanLibraryMerger::get_texture_flags() const {
|
int VoxelmanLibraryMerger::get_texture_flags() const {
|
||||||
return _packer->get_texture_flags();
|
return _packer->get_texture_flags();
|
||||||
@ -123,15 +119,7 @@ void VoxelmanLibraryMerger::clear_surfaces() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector<Variant> VoxelmanLibraryMerger::get_voxel_surfaces() {
|
Vector<Variant> VoxelmanLibraryMerger::get_voxel_surfaces() {
|
||||||
Vector<Variant> r;
|
VARIANT_ARRAY_GET(_voxel_surfaces);
|
||||||
for (int i = 0; i < _voxel_surfaces.size(); i++) {
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
r.push_back(_voxel_surfaces[i].get_ref_ptr());
|
|
||||||
#else
|
|
||||||
r.push_back(_voxel_surfaces[i]);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelmanLibraryMerger::set_voxel_surfaces(const Vector<Variant> &surfaces) {
|
void VoxelmanLibraryMerger::set_voxel_surfaces(const Vector<Variant> &surfaces) {
|
||||||
@ -270,10 +258,10 @@ void VoxelmanLibraryMerger::_setup_material_albedo(const int material_index, con
|
|||||||
VoxelmanLibraryMerger::VoxelmanLibraryMerger() {
|
VoxelmanLibraryMerger::VoxelmanLibraryMerger() {
|
||||||
_packer.instance();
|
_packer.instance();
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#if GODOT4
|
||||||
_packer->set_texture_flags(Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER);
|
#warning implement
|
||||||
#else
|
#else
|
||||||
//nyi
|
_packer->set_texture_flags(Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_packer->set_max_atlas_size(1024);
|
_packer->set_max_atlas_size(1024);
|
||||||
|
@ -22,7 +22,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "voxelman_library_simple.h"
|
#include "voxelman_library_simple.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "../defines.h"
|
||||||
|
|
||||||
int VoxelmanLibrarySimple::get_atlas_columns() const {
|
int VoxelmanLibrarySimple::get_atlas_columns() const {
|
||||||
return _atlas_columns;
|
return _atlas_columns;
|
||||||
@ -89,15 +89,7 @@ void VoxelmanLibrarySimple::clear_surfaces() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector<Variant> VoxelmanLibrarySimple::get_voxel_surfaces() {
|
Vector<Variant> VoxelmanLibrarySimple::get_voxel_surfaces() {
|
||||||
Vector<Variant> r;
|
VARIANT_ARRAY_GET(_voxel_surfaces);
|
||||||
for (int i = 0; i < _voxel_surfaces.size(); i++) {
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
r.push_back(_voxel_surfaces[i].get_ref_ptr());
|
|
||||||
#else
|
|
||||||
r.push_back(_voxel_surfaces[i]);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelmanLibrarySimple::set_voxel_surfaces(const Vector<Variant> &surfaces) {
|
void VoxelmanLibrarySimple::set_voxel_surfaces(const Vector<Variant> &surfaces) {
|
||||||
|
@ -24,14 +24,9 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "../../world/default/voxel_chunk_default.h"
|
#include "../../world/default/voxel_chunk_default.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#include "../../defines.h"
|
||||||
#include "servers/visual_server.h"
|
|
||||||
#else
|
|
||||||
#include "servers/rendering_server.h"
|
|
||||||
|
|
||||||
typedef class RenderingServer VisualServer;
|
#include visual_server_h
|
||||||
typedef class RenderingServer VS;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void VoxelMesherCubic::_add_chunk(Ref<VoxelChunk> p_chunk) {
|
void VoxelMesherCubic::_add_chunk(Ref<VoxelChunk> p_chunk) {
|
||||||
Ref<VoxelChunkDefault> chunk = p_chunk;
|
Ref<VoxelChunkDefault> chunk = p_chunk;
|
||||||
|
@ -24,18 +24,10 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "../../world/default/voxel_chunk_default.h"
|
#include "../../world/default/voxel_chunk_default.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#include "../../defines.h"
|
||||||
#include "servers/visual_server.h"
|
|
||||||
|
|
||||||
#include "scene/3d/mesh_instance.h"
|
#include visual_server_h
|
||||||
#else
|
#include mesh_instance_h
|
||||||
#include "servers/rendering_server.h"
|
|
||||||
|
|
||||||
typedef class RenderingServer VisualServer;
|
|
||||||
typedef class RenderingServer VS;
|
|
||||||
|
|
||||||
#include "scene/3d/mesh_instance_3d.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_FORCE_INLINE_ int VoxelMesherDefault::get_build_flags() const {
|
_FORCE_INLINE_ int VoxelMesherDefault::get_build_flags() const {
|
||||||
return _build_flags;
|
return _build_flags;
|
||||||
|
@ -22,22 +22,9 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "voxel_mesher.h"
|
#include "voxel_mesher.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "../defines.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#include mesh_instance_h
|
||||||
#include "servers/visual_server.h"
|
|
||||||
|
|
||||||
#include "scene/3d/mesh_instance.h"
|
|
||||||
#else
|
|
||||||
#include "servers/rendering_server.h"
|
|
||||||
|
|
||||||
typedef class RenderingServer VisualServer;
|
|
||||||
typedef class RenderingServer VS;
|
|
||||||
|
|
||||||
#include "scene/3d/mesh_instance_3d.h"
|
|
||||||
|
|
||||||
#define REAL FLOAT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../world/default/voxel_chunk_default.h"
|
#include "../world/default/voxel_chunk_default.h"
|
||||||
#include "../world/voxel_chunk.h"
|
#include "../world/voxel_chunk.h"
|
||||||
@ -167,7 +154,7 @@ Array VoxelMesher::build_mesh() {
|
|||||||
{
|
{
|
||||||
PoolVector<Vector3> array;
|
PoolVector<Vector3> array;
|
||||||
array.resize(_vertices.size());
|
array.resize(_vertices.size());
|
||||||
#if VERSION_MAJOR < 4
|
#if !GODOT4
|
||||||
PoolVector<Vector3>::Write w = array.write();
|
PoolVector<Vector3>::Write w = array.write();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -175,7 +162,7 @@ Array VoxelMesher::build_mesh() {
|
|||||||
array.set(i, _vertices[i].vertex);
|
array.set(i, _vertices[i].vertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#if !GODOT4
|
||||||
w.release();
|
w.release();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -189,7 +176,7 @@ Array VoxelMesher::build_mesh() {
|
|||||||
{
|
{
|
||||||
PoolVector<Vector3> array;
|
PoolVector<Vector3> array;
|
||||||
array.resize(_vertices.size());
|
array.resize(_vertices.size());
|
||||||
#if VERSION_MAJOR < 4
|
#if !GODOT4
|
||||||
PoolVector<Vector3>::Write w = array.write();
|
PoolVector<Vector3>::Write w = array.write();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -197,7 +184,7 @@ Array VoxelMesher::build_mesh() {
|
|||||||
array.set(i, _vertices[i].normal);
|
array.set(i, _vertices[i].normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#if !GODOT4
|
||||||
w.release();
|
w.release();
|
||||||
#endif
|
#endif
|
||||||
a[VisualServer::ARRAY_NORMAL] = array;
|
a[VisualServer::ARRAY_NORMAL] = array;
|
||||||
@ -206,7 +193,7 @@ Array VoxelMesher::build_mesh() {
|
|||||||
if ((_format & VisualServer::ARRAY_FORMAT_COLOR) != 0) {
|
if ((_format & VisualServer::ARRAY_FORMAT_COLOR) != 0) {
|
||||||
PoolVector<Color> array;
|
PoolVector<Color> array;
|
||||||
array.resize(_vertices.size());
|
array.resize(_vertices.size());
|
||||||
#if VERSION_MAJOR < 4
|
#if !GODOT4
|
||||||
PoolVector<Color>::Write w = array.write();
|
PoolVector<Color>::Write w = array.write();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -214,7 +201,7 @@ Array VoxelMesher::build_mesh() {
|
|||||||
array.set(i, _vertices[i].color);
|
array.set(i, _vertices[i].color);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#if !GODOT4
|
||||||
w.release();
|
w.release();
|
||||||
#endif
|
#endif
|
||||||
a[VisualServer::ARRAY_COLOR] = array;
|
a[VisualServer::ARRAY_COLOR] = array;
|
||||||
@ -223,7 +210,7 @@ Array VoxelMesher::build_mesh() {
|
|||||||
if ((_format & VisualServer::ARRAY_FORMAT_TEX_UV) != 0) {
|
if ((_format & VisualServer::ARRAY_FORMAT_TEX_UV) != 0) {
|
||||||
PoolVector<Vector2> array;
|
PoolVector<Vector2> array;
|
||||||
array.resize(_vertices.size());
|
array.resize(_vertices.size());
|
||||||
#if VERSION_MAJOR < 4
|
#if !GODOT4
|
||||||
PoolVector<Vector2>::Write w = array.write();
|
PoolVector<Vector2>::Write w = array.write();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -231,7 +218,7 @@ Array VoxelMesher::build_mesh() {
|
|||||||
array.set(i, _vertices[i].uv);
|
array.set(i, _vertices[i].uv);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#if !GODOT4
|
||||||
w.release();
|
w.release();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -241,7 +228,7 @@ Array VoxelMesher::build_mesh() {
|
|||||||
if ((_format & VisualServer::ARRAY_FORMAT_TEX_UV2) != 0) {
|
if ((_format & VisualServer::ARRAY_FORMAT_TEX_UV2) != 0) {
|
||||||
PoolVector<Vector2> array;
|
PoolVector<Vector2> array;
|
||||||
array.resize(_vertices.size());
|
array.resize(_vertices.size());
|
||||||
#if VERSION_MAJOR < 4
|
#if !GODOT4
|
||||||
PoolVector<Vector2>::Write w = array.write();
|
PoolVector<Vector2>::Write w = array.write();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -249,7 +236,7 @@ Array VoxelMesher::build_mesh() {
|
|||||||
array.set(i, _vertices[i].uv2);
|
array.set(i, _vertices[i].uv2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#if !GODOT4
|
||||||
w.release();
|
w.release();
|
||||||
#endif
|
#endif
|
||||||
a[VisualServer::ARRAY_TEX_UV2] = array;
|
a[VisualServer::ARRAY_TEX_UV2] = array;
|
||||||
@ -258,7 +245,7 @@ Array VoxelMesher::build_mesh() {
|
|||||||
if (_indices.size() > 0) {
|
if (_indices.size() > 0) {
|
||||||
PoolVector<int> array;
|
PoolVector<int> array;
|
||||||
array.resize(_indices.size());
|
array.resize(_indices.size());
|
||||||
#if VERSION_MAJOR < 4
|
#if !GODOT4
|
||||||
PoolVector<int>::Write w = array.write();
|
PoolVector<int>::Write w = array.write();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -266,7 +253,7 @@ Array VoxelMesher::build_mesh() {
|
|||||||
array.set(i, _indices[i]);
|
array.set(i, _indices[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#if !GODOT4
|
||||||
w.release();
|
w.release();
|
||||||
#endif
|
#endif
|
||||||
a[VisualServer::ARRAY_INDEX] = array;
|
a[VisualServer::ARRAY_INDEX] = array;
|
||||||
|
@ -25,22 +25,12 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "core/reference.h"
|
#include "core/reference.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "../defines.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#include pool_vector_h
|
||||||
#include "core/pool_vector.h"
|
include_pool_vector
|
||||||
#include "scene/3d/mesh_instance.h"
|
|
||||||
#else
|
|
||||||
#include "core/vector.h"
|
|
||||||
|
|
||||||
template <class N>
|
#include mesh_instance_h
|
||||||
using PoolVector = Vector<N>;
|
|
||||||
|
|
||||||
typedef PackedByteArray PoolByteArray;
|
|
||||||
|
|
||||||
class MeshInstance3D;
|
|
||||||
typedef MeshInstance3D MeshInstance;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "core/color.h"
|
#include "core/color.h"
|
||||||
#include "core/math/rect2.h"
|
#include "core/math/rect2.h"
|
||||||
|
@ -25,20 +25,14 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "voxel_structure.h"
|
#include "voxel_structure.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "../defines.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
#include "core/pool_vector.h"
|
|
||||||
#else
|
|
||||||
#include "core/vector.h"
|
|
||||||
|
|
||||||
typedef PackedByteArray PoolByteArray;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#include pool_vector_h
|
||||||
|
include_pool_vector
|
||||||
#include "core/hash_map.h"
|
#include "core/hash_map.h"
|
||||||
#include "voxel_chunk.h"
|
#include "voxel_chunk.h"
|
||||||
|
|
||||||
class BlockVoxelStructure : public VoxelStructure {
|
class BlockVoxelStructure : public VoxelStructure {
|
||||||
GDCLASS(BlockVoxelStructure, VoxelStructure);
|
GDCLASS(BlockVoxelStructure, VoxelStructure);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -25,11 +25,7 @@ SOFTWARE.
|
|||||||
#include "../../meshers/blocky/voxel_mesher_blocky.h"
|
#include "../../meshers/blocky/voxel_mesher_blocky.h"
|
||||||
#include "../../meshers/blocky/voxel_mesher_liquid_blocky.h"
|
#include "../../meshers/blocky/voxel_mesher_liquid_blocky.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "../../defines.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR >= 4
|
|
||||||
#define POOL_BYTE_ARRAY PACKED_BYTE_ARRAY
|
|
||||||
#endif
|
|
||||||
|
|
||||||
VoxelChunkBlocky::VoxelChunkBlocky() {
|
VoxelChunkBlocky::VoxelChunkBlocky() {
|
||||||
}
|
}
|
||||||
|
@ -22,24 +22,10 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "voxel_chunk_default.h"
|
#include "voxel_chunk_default.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "../../defines.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#include visual_server_h
|
||||||
#include "servers/visual_server.h"
|
#include physics_server_h
|
||||||
#else
|
|
||||||
#include "servers/rendering_server.h"
|
|
||||||
|
|
||||||
typedef class RenderingServer VisualServer;
|
|
||||||
typedef class RenderingServer VS;
|
|
||||||
|
|
||||||
#include "servers/physics_server_3d.h"
|
|
||||||
|
|
||||||
typedef class PhysicsServer3D PhysicsServer;
|
|
||||||
|
|
||||||
typedef class StandardMaterial3D SpatialMaterial;
|
|
||||||
|
|
||||||
typedef class World3D World;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../../../opensimplex/open_simplex_noise.h"
|
#include "../../../opensimplex/open_simplex_noise.h"
|
||||||
#include "../../meshers/default/voxel_mesher_default.h"
|
#include "../../meshers/default/voxel_mesher_default.h"
|
||||||
@ -526,13 +512,8 @@ void VoxelChunkDefault::create_meshes(const int mesh_index, const int mesh_count
|
|||||||
for (int i = 0; i < mesh_count; ++i) {
|
for (int i = 0; i < mesh_count; ++i) {
|
||||||
RID mesh_instance_rid = VS::get_singleton()->instance_create();
|
RID mesh_instance_rid = VS::get_singleton()->instance_create();
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
if (get_voxel_world()->GET_WORLD().is_valid())
|
||||||
if (get_voxel_world()->get_world().is_valid())
|
VS::get_singleton()->instance_set_scenario(mesh_instance_rid, get_voxel_world()->GET_WORLD()->get_scenario());
|
||||||
VS::get_singleton()->instance_set_scenario(mesh_instance_rid, get_voxel_world()->get_world()->get_scenario());
|
|
||||||
#else
|
|
||||||
if (get_voxel_world()->get_world_3d().is_valid())
|
|
||||||
VS::get_singleton()->instance_set_scenario(mesh_instance_rid, get_voxel_world()->get_world_3d()->get_scenario());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
RID mesh_rid = VS::get_singleton()->mesh_create();
|
RID mesh_rid = VS::get_singleton()->mesh_create();
|
||||||
|
|
||||||
@ -611,11 +592,7 @@ void VoxelChunkDefault::create_colliders(const int mesh_index, const int layer_m
|
|||||||
PhysicsServer::get_singleton()->body_set_state(body_rid, PhysicsServer::BODY_STATE_TRANSFORM, get_transform());
|
PhysicsServer::get_singleton()->body_set_state(body_rid, PhysicsServer::BODY_STATE_TRANSFORM, get_transform());
|
||||||
|
|
||||||
if (get_voxel_world()->is_inside_tree() && get_voxel_world()->is_inside_world()) {
|
if (get_voxel_world()->is_inside_tree() && get_voxel_world()->is_inside_world()) {
|
||||||
#if VERSION_MAJOR < 4
|
Ref<World> world = get_voxel_world()->GET_WORLD();
|
||||||
Ref<World> world = get_voxel_world()->get_world();
|
|
||||||
#else
|
|
||||||
Ref<World> world = get_voxel_world()->get_world_3d();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (world.is_valid() && world->get_space() != RID())
|
if (world.is_valid() && world->get_space() != RID())
|
||||||
PhysicsServer::get_singleton()->body_set_space(body_rid, world->get_space());
|
PhysicsServer::get_singleton()->body_set_space(body_rid, world->get_space());
|
||||||
@ -653,11 +630,7 @@ void VoxelChunkDefault::create_colliders_area(const int mesh_index, const int la
|
|||||||
PhysicsServer::get_singleton()->area_set_collision_mask(area_rid, layer_mask);
|
PhysicsServer::get_singleton()->area_set_collision_mask(area_rid, layer_mask);
|
||||||
|
|
||||||
if (get_voxel_world()->is_inside_tree() && get_voxel_world()->is_inside_world()) {
|
if (get_voxel_world()->is_inside_tree() && get_voxel_world()->is_inside_world()) {
|
||||||
#if VERSION_MAJOR < 4
|
Ref<World> world = get_voxel_world()->GET_WORLD();
|
||||||
Ref<World> world = get_voxel_world()->get_world();
|
|
||||||
#else
|
|
||||||
Ref<World> world = get_voxel_world()->get_world_3d();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (world.is_valid() && world->get_space() != RID())
|
if (world.is_valid() && world->get_space() != RID())
|
||||||
PhysicsServer::get_singleton()->area_set_space(area_rid, world->get_space());
|
PhysicsServer::get_singleton()->area_set_space(area_rid, world->get_space());
|
||||||
@ -1335,7 +1308,7 @@ void VoxelChunkDefault::_build_phase(int phase) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
|
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
|
||||||
#if VERSION_MAJOR < 4
|
#if !GODOT4
|
||||||
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
|
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
|
||||||
#else
|
#else
|
||||||
VS::get_singleton()->mesh_clear(mesh_rid);
|
VS::get_singleton()->mesh_clear(mesh_rid);
|
||||||
@ -1425,7 +1398,7 @@ void VoxelChunkDefault::_build_phase(int phase) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
|
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
|
||||||
#if VERSION_MAJOR < 4
|
#if !GODOT4
|
||||||
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
|
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
|
||||||
#else
|
#else
|
||||||
VS::get_singleton()->mesh_clear(mesh_rid);
|
VS::get_singleton()->mesh_clear(mesh_rid);
|
||||||
|
@ -25,15 +25,9 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "../voxel_chunk.h"
|
#include "../voxel_chunk.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "../../defines.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#include immediate_geometry_h
|
||||||
#include "scene/3d/immediate_geometry.h"
|
|
||||||
#else
|
|
||||||
#include "scene/3d/immediate_geometry_3d.h"
|
|
||||||
|
|
||||||
typedef class ImmediateGeometry3D ImmediateGeometry;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "core/engine.h"
|
#include "core/engine.h"
|
||||||
#include "core/os/mutex.h"
|
#include "core/os/mutex.h"
|
||||||
|
@ -24,11 +24,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "voxel_chunk_default.h"
|
#include "voxel_chunk_default.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "../../defines.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR >= 4
|
|
||||||
#define REAL FLOAT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_FORCE_INLINE_ int VoxelWorldDefault::get_build_flags() const {
|
_FORCE_INLINE_ int VoxelWorldDefault::get_build_flags() const {
|
||||||
return _build_flags;
|
return _build_flags;
|
||||||
@ -58,11 +54,7 @@ void VoxelWorldDefault::update_lods() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VoxelWorldDefault::_update_lods() {
|
void VoxelWorldDefault::_update_lods() {
|
||||||
#if VERSION_MAJOR < 4
|
if (!get_player() || !INSTANCE_VALIDATE(get_player())) {
|
||||||
if (!get_player() || !ObjectDB::instance_validate(get_player())) {
|
|
||||||
#else
|
|
||||||
if (!get_player() || !get_player()) {
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,11 +146,7 @@ void VoxelWorldDefault::_notification(int p_what) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
if (!INSTANCE_VALIDATE(get_player())) {
|
||||||
if (!ObjectDB::instance_validate(get_player())) {
|
|
||||||
#else
|
|
||||||
if (!get_player()) {
|
|
||||||
#endif
|
|
||||||
set_player(NULL);
|
set_player(NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,6 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "environment_data.h"
|
#include "environment_data.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
|
||||||
|
|
||||||
#if VERSION_MAJOR >= 4
|
|
||||||
#define REAL FLOAT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Ref<Environment> EnvironmentData::get_environment() {
|
Ref<Environment> EnvironmentData::get_environment() {
|
||||||
return _environment;
|
return _environment;
|
||||||
}
|
}
|
||||||
|
@ -23,15 +23,9 @@ SOFTWARE.
|
|||||||
#ifndef ENVIRONMENT_DATA_H
|
#ifndef ENVIRONMENT_DATA_H
|
||||||
#define ENVIRONMENT_DATA_H
|
#define ENVIRONMENT_DATA_H
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "../defines.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#include light_h
|
||||||
#include "scene/3d/light.h"
|
|
||||||
#else
|
|
||||||
#include "scene/3d/light_3d.h"
|
|
||||||
|
|
||||||
typedef class DirectionalLight3D DirectionalLight;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "core/color.h"
|
#include "core/color.h"
|
||||||
#include "core/resource.h"
|
#include "core/resource.h"
|
||||||
|
@ -26,21 +26,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "../thirdparty/lz4/lz4.h"
|
#include "../thirdparty/lz4/lz4.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#include "../defines.h"
|
||||||
#include "servers/visual_server.h"
|
|
||||||
#else
|
|
||||||
#include "servers/rendering_server.h"
|
|
||||||
|
|
||||||
typedef class RenderingServer VisualServer;
|
|
||||||
typedef class RenderingServer VS;
|
|
||||||
|
|
||||||
#define REAL FLOAT
|
|
||||||
|
|
||||||
typedef PackedVector3Array PoolVector3Array;
|
|
||||||
typedef PackedVector2Array PoolVector2Array;
|
|
||||||
typedef PackedColorArray PoolColorArray;
|
|
||||||
typedef PackedInt32Array PoolIntArray;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_FORCE_INLINE_ bool VoxelChunk::get_is_build_threaded() const {
|
_FORCE_INLINE_ bool VoxelChunk::get_is_build_threaded() const {
|
||||||
return _is_build_threaded;
|
return _is_build_threaded;
|
||||||
@ -478,7 +464,7 @@ PoolByteArray VoxelChunk::get_channel_compressed(const int channel_index) const
|
|||||||
int bound = LZ4_compressBound(size);
|
int bound = LZ4_compressBound(size);
|
||||||
arr.resize(bound);
|
arr.resize(bound);
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#if !GODOT4
|
||||||
PoolByteArray::Write w = arr.write();
|
PoolByteArray::Write w = arr.write();
|
||||||
|
|
||||||
int ns = LZ4_compress_default(reinterpret_cast<char *>(ch), reinterpret_cast<char *>(w.ptr()), size, bound);
|
int ns = LZ4_compress_default(reinterpret_cast<char *>(ch), reinterpret_cast<char *>(w.ptr()), size, bound);
|
||||||
@ -512,7 +498,7 @@ void VoxelChunk::set_channel_compressed(const int channel_index, const PoolByteA
|
|||||||
|
|
||||||
int ds = data.size();
|
int ds = data.size();
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#if !GODOT4
|
||||||
PoolByteArray::Read r = data.read();
|
PoolByteArray::Read r = data.read();
|
||||||
|
|
||||||
//We are not going to write to it
|
//We are not going to write to it
|
||||||
@ -546,11 +532,7 @@ void VoxelChunk::create_meshers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VoxelChunk::build(const bool immediate) {
|
void VoxelChunk::build(const bool immediate) {
|
||||||
#if VERSION_MAJOR < 4
|
ERR_FAIL_COND(!INSTANCE_VALIDATE(get_voxel_world()));
|
||||||
ERR_FAIL_COND(!ObjectDB::instance_validate(get_voxel_world()));
|
|
||||||
#else
|
|
||||||
ERR_FAIL_COND(!get_voxel_world());
|
|
||||||
#endif
|
|
||||||
ERR_FAIL_COND(!get_voxel_world()->is_inside_tree());
|
ERR_FAIL_COND(!get_voxel_world()->is_inside_tree());
|
||||||
ERR_FAIL_COND(!is_in_tree());
|
ERR_FAIL_COND(!is_in_tree());
|
||||||
ERR_FAIL_COND_MSG(!has_method("_build"), "VoxelChunk: _build(immediate : bool) is missing! Please implement it!");
|
ERR_FAIL_COND_MSG(!has_method("_build"), "VoxelChunk: _build(immediate : bool) is missing! Please implement it!");
|
||||||
@ -644,7 +626,7 @@ Array VoxelChunk::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const float mu
|
|||||||
if (colors.size() < uvs.size())
|
if (colors.size() < uvs.size())
|
||||||
colors.resize(uvs.size());
|
colors.resize(uvs.size());
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#if !GODOT4
|
||||||
img->lock();
|
img->lock();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -657,7 +639,7 @@ Array VoxelChunk::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const float mu
|
|||||||
colors.set(i, colors[i] * c * mul_color);
|
colors.set(i, colors[i] * c * mul_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#if !GODOT4
|
||||||
img->unlock();
|
img->unlock();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -25,13 +25,10 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "core/resource.h"
|
#include "core/resource.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "../defines.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#include pool_vector_h
|
||||||
#include "core/pool_vector.h"
|
include_pool_vector
|
||||||
#else
|
|
||||||
#include "core/vector.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "core/engine.h"
|
#include "core/engine.h"
|
||||||
#include "core/os/mutex.h"
|
#include "core/os/mutex.h"
|
||||||
@ -61,7 +58,7 @@ SOFTWARE.
|
|||||||
#define Texture Texture2D
|
#define Texture Texture2D
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class VoxelWorld;
|
class VoxelWorld;
|
||||||
|
|
||||||
class VoxelChunk : public Resource {
|
class VoxelChunk : public Resource {
|
||||||
GDCLASS(VoxelChunk, Resource);
|
GDCLASS(VoxelChunk, Resource);
|
||||||
@ -260,11 +257,11 @@ protected:
|
|||||||
float _voxel_scale;
|
float _voxel_scale;
|
||||||
|
|
||||||
Ref<VoxelmanLibrary> _library;
|
Ref<VoxelmanLibrary> _library;
|
||||||
Vector<Ref<VoxelMesher> > _meshers;
|
Vector<Ref<VoxelMesher>> _meshers;
|
||||||
Vector<Ref<VoxelMesher> > _liquid_meshers;
|
Vector<Ref<VoxelMesher>> _liquid_meshers;
|
||||||
|
|
||||||
//mergeable props
|
//mergeable props
|
||||||
Vector<Ref<VoxelChunkPropData> > _props;
|
Vector<Ref<VoxelChunkPropData>> _props;
|
||||||
|
|
||||||
Transform _transform;
|
Transform _transform;
|
||||||
};
|
};
|
||||||
|
@ -25,16 +25,10 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "core/resource.h"
|
#include "core/resource.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "../defines.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#include pool_vector_h
|
||||||
#include "core/pool_vector.h"
|
include_pool_vector
|
||||||
#else
|
|
||||||
#include "core/vector.h"
|
|
||||||
|
|
||||||
template <class N>
|
|
||||||
using PoolVector = Vector<N>;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "core/hash_map.h"
|
#include "core/hash_map.h"
|
||||||
#include "core/math/aabb.h"
|
#include "core/math/aabb.h"
|
||||||
|
@ -26,11 +26,7 @@ SOFTWARE.
|
|||||||
#include "voxel_chunk_prop_data.h"
|
#include "voxel_chunk_prop_data.h"
|
||||||
#include "voxel_structure.h"
|
#include "voxel_structure.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "../defines.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR >= 4
|
|
||||||
#define REAL FLOAT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const String VoxelWorld::BINDING_STRING_CHANNEL_TYPE_INFO = "Type,Isolevel,Liquid,Liquid Level";
|
const String VoxelWorld::BINDING_STRING_CHANNEL_TYPE_INFO = "Type,Isolevel,Liquid,Liquid Level";
|
||||||
|
|
||||||
@ -238,15 +234,7 @@ void VoxelWorld::add_voxel_structure_at_position(Ref<VoxelStructure> structure,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector<Variant> VoxelWorld::get_voxel_structures() {
|
Vector<Variant> VoxelWorld::get_voxel_structures() {
|
||||||
Vector<Variant> r;
|
VARIANT_ARRAY_GET(_voxel_structures);
|
||||||
for (int i = 0; i < _voxel_structures.size(); i++) {
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
r.push_back(_voxel_structures[i].get_ref_ptr());
|
|
||||||
#else
|
|
||||||
r.push_back(_voxel_structures[i]);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
void VoxelWorld::set_voxel_structures(const Vector<Variant> &structures) {
|
void VoxelWorld::set_voxel_structures(const Vector<Variant> &structures) {
|
||||||
clear_voxel_structures();
|
clear_voxel_structures();
|
||||||
@ -454,7 +442,6 @@ bool VoxelWorld::can_chunk_do_build_step() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool VoxelWorld::is_position_walkable(const Vector3 &p_pos) {
|
bool VoxelWorld::is_position_walkable(const Vector3 &p_pos) {
|
||||||
|
|
||||||
int x = static_cast<int>(Math::floor(p_pos.x / (_chunk_size_x * _voxel_scale)));
|
int x = static_cast<int>(Math::floor(p_pos.x / (_chunk_size_x * _voxel_scale)));
|
||||||
int y = static_cast<int>(Math::floor(p_pos.y / (_chunk_size_y * _voxel_scale)));
|
int y = static_cast<int>(Math::floor(p_pos.y / (_chunk_size_y * _voxel_scale)));
|
||||||
int z = static_cast<int>(Math::floor(p_pos.z / (_chunk_size_z * _voxel_scale)));
|
int z = static_cast<int>(Math::floor(p_pos.z / (_chunk_size_z * _voxel_scale)));
|
||||||
@ -472,19 +459,10 @@ void VoxelWorld::on_chunk_mesh_generation_finished(Ref<VoxelChunk> p_chunk) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector<Variant> VoxelWorld::get_chunks() {
|
Vector<Variant> VoxelWorld::get_chunks() {
|
||||||
Vector<Variant> r;
|
VARIANT_ARRAY_GET(_chunks_vector);
|
||||||
for (int i = 0; i < _chunks_vector.size(); i++) {
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
r.push_back(_chunks_vector[i].get_ref_ptr());
|
|
||||||
#else
|
|
||||||
r.push_back(_chunks_vector[i]);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelWorld::set_chunks(const Vector<Variant> &chunks) {
|
void VoxelWorld::set_chunks(const Vector<Variant> &chunks) {
|
||||||
|
|
||||||
if (is_inside_tree()) {
|
if (is_inside_tree()) {
|
||||||
for (int i = 0; i < _chunks_vector.size(); ++i) {
|
for (int i = 0; i < _chunks_vector.size(); ++i) {
|
||||||
Ref<VoxelChunk> chunk = Ref<VoxelChunk>(_chunks_vector[i]);
|
Ref<VoxelChunk> chunk = Ref<VoxelChunk>(_chunks_vector[i]);
|
||||||
@ -562,7 +540,6 @@ int VoxelWorld::get_light_count() const {
|
|||||||
}
|
}
|
||||||
void VoxelWorld::clear_lights() {
|
void VoxelWorld::clear_lights() {
|
||||||
for (int i = 0; i < _lights.size(); ++i) {
|
for (int i = 0; i < _lights.size(); ++i) {
|
||||||
|
|
||||||
Ref<VoxelLight> light = _lights[i];
|
Ref<VoxelLight> light = _lights[i];
|
||||||
|
|
||||||
if (!light.is_valid())
|
if (!light.is_valid())
|
||||||
@ -581,15 +558,7 @@ void VoxelWorld::clear_lights() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector<Variant> VoxelWorld::get_lights() {
|
Vector<Variant> VoxelWorld::get_lights() {
|
||||||
Vector<Variant> r;
|
VARIANT_ARRAY_GET(_lights);
|
||||||
for (int i = 0; i < _lights.size(); i++) {
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
r.push_back(_lights[i].get_ref_ptr());
|
|
||||||
#else
|
|
||||||
r.push_back(_lights[i]);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
void VoxelWorld::set_lights(const Vector<Variant> &chunks) {
|
void VoxelWorld::set_lights(const Vector<Variant> &chunks) {
|
||||||
clear_lights();
|
clear_lights();
|
||||||
|
@ -23,18 +23,9 @@ SOFTWARE.
|
|||||||
#ifndef VOXEL_WORLD_H
|
#ifndef VOXEL_WORLD_H
|
||||||
#define VOXEL_WORLD_H
|
#define VOXEL_WORLD_H
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "../defines.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#include navigation_h
|
||||||
#include "scene/3d/navigation.h"
|
|
||||||
#include "scene/3d/spatial.h"
|
|
||||||
#else
|
|
||||||
#include "scene/3d/navigation_3d.h"
|
|
||||||
#include "scene/3d/node_3d.h"
|
|
||||||
|
|
||||||
typedef class Navigation3D Navigation;
|
|
||||||
typedef class Node3D Spatial;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "core/engine.h"
|
#include "core/engine.h"
|
||||||
#include "core/hash_map.h"
|
#include "core/hash_map.h"
|
||||||
@ -248,23 +239,23 @@ private:
|
|||||||
int _chunk_spawn_range;
|
int _chunk_spawn_range;
|
||||||
|
|
||||||
HashMap<IntPos, Ref<VoxelChunk>, IntPosHasher> _chunks;
|
HashMap<IntPos, Ref<VoxelChunk>, IntPosHasher> _chunks;
|
||||||
Vector<Ref<VoxelChunk> > _chunks_vector;
|
Vector<Ref<VoxelChunk>> _chunks_vector;
|
||||||
|
|
||||||
Vector<Ref<WorldArea> > _world_areas;
|
Vector<Ref<WorldArea>> _world_areas;
|
||||||
|
|
||||||
Vector<Ref<VoxelStructure> > _voxel_structures;
|
Vector<Ref<VoxelStructure>> _voxel_structures;
|
||||||
|
|
||||||
NodePath _player_path;
|
NodePath _player_path;
|
||||||
Spatial *_player;
|
Spatial *_player;
|
||||||
|
|
||||||
bool _use_threads;
|
bool _use_threads;
|
||||||
int _max_concurrent_generations;
|
int _max_concurrent_generations;
|
||||||
Vector<Ref<VoxelChunk> > _generation_queue;
|
Vector<Ref<VoxelChunk>> _generation_queue;
|
||||||
Vector<Ref<VoxelChunk> > _generating;
|
Vector<Ref<VoxelChunk>> _generating;
|
||||||
int _max_frame_chunk_build_steps;
|
int _max_frame_chunk_build_steps;
|
||||||
int _num_frame_chunk_build_steps;
|
int _num_frame_chunk_build_steps;
|
||||||
|
|
||||||
Vector<Ref<VoxelLight> > _lights;
|
Vector<Ref<VoxelLight>> _lights;
|
||||||
};
|
};
|
||||||
|
|
||||||
_FORCE_INLINE_ bool operator==(const VoxelWorld::IntPos &a, const VoxelWorld::IntPos &b) {
|
_FORCE_INLINE_ bool operator==(const VoxelWorld::IntPos &a, const VoxelWorld::IntPos &b) {
|
||||||
|
@ -37,26 +37,11 @@ SOFTWARE.
|
|||||||
#include "../library/voxel_surface.h"
|
#include "../library/voxel_surface.h"
|
||||||
#include "../library/voxelman_library.h"
|
#include "../library/voxelman_library.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "../defines.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#include core_input_h
|
||||||
|
#include spatial_editor_plugin_h
|
||||||
#include "core/os/input.h"
|
#include camera_h
|
||||||
#include "editor/plugins/spatial_editor_plugin.h"
|
|
||||||
#include "scene/3d/camera.h"
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include "core/input/input_event.h"
|
|
||||||
#include "editor/plugins/node_3d_editor_plugin.h"
|
|
||||||
#include "scene/3d/camera_3d.h"
|
|
||||||
|
|
||||||
#define PhysicsDirectSpaceState PhysicsDirectSpaceState3D
|
|
||||||
#define SpatialEditor Node3DEditor
|
|
||||||
#define SpatialEditorPlugin Node3DEditorPlugin
|
|
||||||
#define SpatialEditorViewport Node3DEditorViewport
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) {
|
bool VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) {
|
||||||
if (!_world || !_world->get_editable()) {
|
if (!_world || !_world->get_editable()) {
|
||||||
@ -97,11 +82,7 @@ bool VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point,
|
|||||||
from = local_xform.xform(from);
|
from = local_xform.xform(from);
|
||||||
to = local_xform.xform(to);
|
to = local_xform.xform(to);
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
PhysicsDirectSpaceState *ss = _world->GET_WORLD()->get_direct_space_state();
|
||||||
PhysicsDirectSpaceState *ss = _world->get_world()->get_direct_space_state();
|
|
||||||
#else
|
|
||||||
PhysicsDirectSpaceState *ss = _world->get_world_3d()->get_direct_space_state();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
PhysicsDirectSpaceState::RayResult res;
|
PhysicsDirectSpaceState::RayResult res;
|
||||||
|
|
||||||
@ -174,11 +155,8 @@ void VoxelWorldEditor::edit(VoxelWorld *p_world) {
|
|||||||
button->set_button_group(_surfaces_button_group);
|
button->set_button_group(_surfaces_button_group);
|
||||||
button->set_h_size_flags(SIZE_EXPAND_FILL);
|
button->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
button->CONNECT("button_up", this, VoxelWorldEditor, _on_surface_button_pressed);
|
||||||
button->connect("button_up", this, "_on_surface_button_pressed");
|
|
||||||
#else
|
|
||||||
button->connect("button_up", callable_mp(this, &VoxelWorldEditor::_on_surface_button_pressed));
|
|
||||||
#endif
|
|
||||||
_surfaces_vbox_container->add_child(button);
|
_surfaces_vbox_container->add_child(button);
|
||||||
|
|
||||||
if (!f) {
|
if (!f) {
|
||||||
@ -216,11 +194,7 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) {
|
|||||||
add_button->set_button_group(_tool_button_group);
|
add_button->set_button_group(_tool_button_group);
|
||||||
add_button->set_meta("tool_mode", TOOL_MODE_ADD);
|
add_button->set_meta("tool_mode", TOOL_MODE_ADD);
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
add_button->CONNECT("button_up", this, VoxelWorldEditor, _on_tool_button_pressed);
|
||||||
add_button->connect("button_up", this, "_on_tool_button_pressed");
|
|
||||||
#else
|
|
||||||
add_button->connect("button_up", callable_mp(this, &VoxelWorldEditor::_on_tool_button_pressed));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
add_button->set_shortcut(ED_SHORTCUT("voxelman_world_editor/add_mode", "Add Mode", KEY_A));
|
add_button->set_shortcut(ED_SHORTCUT("voxelman_world_editor/add_mode", "Add Mode", KEY_A));
|
||||||
spatial_editor_hb->add_child(add_button);
|
spatial_editor_hb->add_child(add_button);
|
||||||
@ -231,11 +205,7 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) {
|
|||||||
remove_button->set_button_group(_tool_button_group);
|
remove_button->set_button_group(_tool_button_group);
|
||||||
remove_button->set_meta("tool_mode", TOOL_MODE_REMOVE);
|
remove_button->set_meta("tool_mode", TOOL_MODE_REMOVE);
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
remove_button->CONNECT("button_up", this, VoxelWorldEditor, _on_tool_button_pressed);
|
||||||
remove_button->connect("button_up", this, "_on_tool_button_pressed");
|
|
||||||
#else
|
|
||||||
remove_button->connect("button_up", callable_mp(this, &VoxelWorldEditor::_on_tool_button_pressed));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
remove_button->set_shortcut(ED_SHORTCUT("voxelman_world_editor/remove_mode", "Remove Mode", KEY_S));
|
remove_button->set_shortcut(ED_SHORTCUT("voxelman_world_editor/remove_mode", "Remove Mode", KEY_S));
|
||||||
spatial_editor_hb->add_child(remove_button);
|
spatial_editor_hb->add_child(remove_button);
|
||||||
@ -243,11 +213,7 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) {
|
|||||||
ToolButton *insert_buton = memnew(ToolButton);
|
ToolButton *insert_buton = memnew(ToolButton);
|
||||||
insert_buton->set_text("Insert");
|
insert_buton->set_text("Insert");
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
insert_buton->CONNECT("button_up", this, VoxelWorldEditor, _on_insert_block_at_camera_button_pressed);
|
||||||
insert_buton->connect("button_up", this, "_on_insert_block_at_camera_button_pressed");
|
|
||||||
#else
|
|
||||||
insert_buton->connect("button_up", callable_mp(this, &VoxelWorldEditor::_on_insert_block_at_camera_button_pressed));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
insert_buton->set_shortcut(ED_SHORTCUT("voxelman_world_editor/instert_block_at_camera", "Insert at camera", KEY_B));
|
insert_buton->set_shortcut(ED_SHORTCUT("voxelman_world_editor/instert_block_at_camera", "Insert at camera", KEY_B));
|
||||||
spatial_editor_hb->add_child(insert_buton);
|
spatial_editor_hb->add_child(insert_buton);
|
||||||
|
@ -26,14 +26,7 @@ SOFTWARE.
|
|||||||
#include "editor/editor_node.h"
|
#include "editor/editor_node.h"
|
||||||
#include "editor/editor_plugin.h"
|
#include "editor/editor_plugin.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
#include "../defines.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR >= 4
|
|
||||||
#define Camera Camera3D
|
|
||||||
#define PhysicsDirectSpaceState PhysicsDirectSpaceState3D
|
|
||||||
#define SpatialEditor Node3DEditor
|
|
||||||
#define SpatialEditorPlugin Node3DEditorPlugin
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class VoxelWorld;
|
class VoxelWorld;
|
||||||
class SpatialEditorPlugin;
|
class SpatialEditorPlugin;
|
||||||
@ -84,7 +77,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class VoxelWorldEditorPlugin : public EditorPlugin {
|
class VoxelWorldEditorPlugin : public EditorPlugin {
|
||||||
|
|
||||||
GDCLASS(VoxelWorldEditorPlugin, EditorPlugin);
|
GDCLASS(VoxelWorldEditorPlugin, EditorPlugin);
|
||||||
|
|
||||||
VoxelWorldEditor *voxel_world_editor;
|
VoxelWorldEditor *voxel_world_editor;
|
||||||
|
Loading…
Reference in New Issue
Block a user