mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-15 23:21:14 +01:00
Cleanups to voxelman.
This commit is contained in:
parent
03596bcbd3
commit
d95760ac9e
@ -2,32 +2,6 @@
|
|||||||
#ifndef VOXEL_DEFINES_H
|
#ifndef VOXEL_DEFINES_H
|
||||||
#define VOXEL_DEFINES_H
|
#define VOXEL_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 core_input_h "core/os/input.h"
|
||||||
#define spatial_editor_plugin_h "editor/plugins/spatial_editor_plugin.h"
|
#define spatial_editor_plugin_h "editor/plugins/spatial_editor_plugin.h"
|
||||||
#define camera_h "scene/3d/camera.h"
|
#define camera_h "scene/3d/camera.h"
|
||||||
@ -40,57 +14,6 @@
|
|||||||
#define physics_server_h "servers/physics_server.h"
|
#define physics_server_h "servers/physics_server.h"
|
||||||
#define immediate_geometry_h "scene/3d/immediate_geometry.h"
|
#define immediate_geometry_h "scene/3d/immediate_geometry.h"
|
||||||
#define include_pool_vector
|
#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) \
|
#define VARIANT_ARRAY_GET(arr) \
|
||||||
Vector<Variant> r; \
|
Vector<Variant> r; \
|
||||||
@ -99,8 +22,6 @@ typedef class RenderingServer VS;
|
|||||||
} \
|
} \
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define VARIANT_ARRAY_SET(arr, arr_into, type) \
|
#define VARIANT_ARRAY_SET(arr, arr_into, type) \
|
||||||
arr_into.clear(); \
|
arr_into.clear(); \
|
||||||
for (int i = 0; i < arr.size(); i++) { \
|
for (int i = 0; i < arr.size(); i++) { \
|
||||||
@ -108,21 +29,11 @@ typedef class RenderingServer VS;
|
|||||||
arr_into.push_back(e); \
|
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
|
|
||||||
#else
|
|
||||||
#define INSTANCE_VALIDATE(var) ObjectDB::instance_validate(var)
|
#define INSTANCE_VALIDATE(var) ObjectDB::instance_validate(var)
|
||||||
#define CONNECT(sig, obj, target_method_class, method) connect(sig, obj, #method)
|
#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 DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, obj, #method)
|
||||||
#define GET_WORLD get_world
|
#define GET_WORLD get_world
|
||||||
#define INSTANCE instance
|
#define INSTANCE instance
|
||||||
#define VREMOVE remove
|
#define VREMOVE remove
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -77,9 +77,9 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "world/jobs/voxel_job.h"
|
#include "world/jobs/voxel_job.h"
|
||||||
#include "world/jobs/voxel_light_job.h"
|
#include "world/jobs/voxel_light_job.h"
|
||||||
|
#include "world/jobs/voxel_mesher_job_step.h"
|
||||||
#include "world/jobs/voxel_prop_job.h"
|
#include "world/jobs/voxel_prop_job.h"
|
||||||
#include "world/jobs/voxel_terrain_job.h"
|
#include "world/jobs/voxel_terrain_job.h"
|
||||||
#include "world/jobs/voxel_mesher_job_step.h"
|
|
||||||
|
|
||||||
void register_voxelman_types() {
|
void register_voxelman_types() {
|
||||||
ClassDB::register_class<VoxelMesher>();
|
ClassDB::register_class<VoxelMesher>();
|
||||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void register_voxelman_types();
|
void register_voxelman_types();
|
||||||
void unregister_voxelman_types();
|
void unregister_voxelman_types();
|
||||||
|
|
||||||
|
@ -66,13 +66,9 @@ void VoxelStructure::set_position(const int x, const int y, const int z) {
|
|||||||
void VoxelStructure::write_to_chunk(Ref<VoxelChunk> chunk) {
|
void VoxelStructure::write_to_chunk(Ref<VoxelChunk> chunk) {
|
||||||
ERR_FAIL_COND(!chunk.is_valid());
|
ERR_FAIL_COND(!chunk.is_valid());
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
if (has_method("_write_to_chunk")) {
|
if (has_method("_write_to_chunk")) {
|
||||||
call("_write_to_chunk", chunk);
|
call("_write_to_chunk", chunk);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
GDVIRTUAL_CALL(_write_to_chunk, chunk);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VoxelStructure::VoxelStructure() {
|
VoxelStructure::VoxelStructure() {
|
||||||
@ -86,11 +82,7 @@ VoxelStructure::~VoxelStructure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VoxelStructure::_bind_methods() {
|
void VoxelStructure::_bind_methods() {
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
BIND_VMETHOD(MethodInfo("_write_to_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk")));
|
BIND_VMETHOD(MethodInfo("_write_to_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk")));
|
||||||
#else
|
|
||||||
GDVIRTUAL_BIND(_write_to_chunk, "chunk");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_use_aabb"), &VoxelStructure::get_use_aabb);
|
ClassDB::bind_method(D_METHOD("get_use_aabb"), &VoxelStructure::get_use_aabb);
|
||||||
ClassDB::bind_method(D_METHOD("set_use_aabb", "value"), &VoxelStructure::set_use_aabb);
|
ClassDB::bind_method(D_METHOD("set_use_aabb", "value"), &VoxelStructure::set_use_aabb);
|
||||||
|
@ -23,17 +23,8 @@ 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/hash_map.h"
|
||||||
#include "core/resource.h"
|
#include "core/resource.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../defines.h"
|
#include "../defines.h"
|
||||||
|
|
||||||
@ -65,10 +56,6 @@ public:
|
|||||||
|
|
||||||
void write_to_chunk(Ref<VoxelChunk> chunk);
|
void write_to_chunk(Ref<VoxelChunk> chunk);
|
||||||
|
|
||||||
#if VERSION_MAJOR >= 4
|
|
||||||
GDVIRTUAL1(_write_to_chunk, Ref<VoxelChunk>);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
VoxelStructure();
|
VoxelStructure();
|
||||||
~VoxelStructure();
|
~VoxelStructure();
|
||||||
|
|
||||||
|
@ -22,8 +22,6 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "voxel_world.h"
|
#include "voxel_world.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
|
||||||
|
|
||||||
#include "voxel_chunk.h"
|
#include "voxel_chunk.h"
|
||||||
#include "voxel_structure.h"
|
#include "voxel_structure.h"
|
||||||
|
|
||||||
@ -197,11 +195,7 @@ void VoxelWorld::world_area_add(const Ref<WorldArea> &area) {
|
|||||||
void VoxelWorld::world_area_remove(const int index) {
|
void VoxelWorld::world_area_remove(const int index) {
|
||||||
ERR_FAIL_INDEX(index, _world_areas.size());
|
ERR_FAIL_INDEX(index, _world_areas.size());
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
_world_areas.remove(index);
|
_world_areas.remove(index);
|
||||||
#else
|
|
||||||
_world_areas.remove_at(index);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
void VoxelWorld::world_areas_clear() {
|
void VoxelWorld::world_areas_clear() {
|
||||||
_world_areas.clear();
|
_world_areas.clear();
|
||||||
@ -227,21 +221,13 @@ void VoxelWorld::voxel_structure_remove(const Ref<VoxelStructure> &structure) {
|
|||||||
int index = _voxel_structures.find(structure);
|
int index = _voxel_structures.find(structure);
|
||||||
|
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
_voxel_structures.remove(index);
|
_voxel_structures.remove(index);
|
||||||
#else
|
|
||||||
_voxel_structures.remove_at(index);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void VoxelWorld::voxel_structure_remove_index(const int index) {
|
void VoxelWorld::voxel_structure_remove_index(const int index) {
|
||||||
ERR_FAIL_INDEX(index, _voxel_structures.size());
|
ERR_FAIL_INDEX(index, _voxel_structures.size());
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
_voxel_structures.remove(index);
|
_voxel_structures.remove(index);
|
||||||
#else
|
|
||||||
_voxel_structures.remove_at(index);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
void VoxelWorld::voxel_structures_clear() {
|
void VoxelWorld::voxel_structures_clear() {
|
||||||
_voxel_structures.clear();
|
_voxel_structures.clear();
|
||||||
@ -294,11 +280,7 @@ void VoxelWorld::chunk_add(Ref<VoxelChunk> chunk, const int x, const int y, cons
|
|||||||
chunk->enter_tree();
|
chunk->enter_tree();
|
||||||
|
|
||||||
if (has_method("_chunk_added")) {
|
if (has_method("_chunk_added")) {
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
call("_chunk_added", chunk);
|
call("_chunk_added", chunk);
|
||||||
#else
|
|
||||||
GDVIRTUAL_CALL(_chunk_added, chunk);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool VoxelWorld::chunk_has(const int x, const int y, const int z) const {
|
bool VoxelWorld::chunk_has(const int x, const int y, const int z) const {
|
||||||
@ -322,11 +304,7 @@ Ref<VoxelChunk> VoxelWorld::chunk_remove(const int x, const int y, const int z)
|
|||||||
|
|
||||||
for (int i = 0; i < _chunks_vector.size(); ++i) {
|
for (int i = 0; i < _chunks_vector.size(); ++i) {
|
||||||
if (_chunks_vector.get(i) == chunk) {
|
if (_chunks_vector.get(i) == chunk) {
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
_chunks_vector.remove(i);
|
_chunks_vector.remove(i);
|
||||||
#else
|
|
||||||
_chunks_vector.remove_at(i);
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -343,11 +321,7 @@ Ref<VoxelChunk> VoxelWorld::chunk_remove_index(const int index) {
|
|||||||
ERR_FAIL_INDEX_V(index, _chunks_vector.size(), NULL);
|
ERR_FAIL_INDEX_V(index, _chunks_vector.size(), NULL);
|
||||||
|
|
||||||
Ref<VoxelChunk> chunk = _chunks_vector.get(index);
|
Ref<VoxelChunk> chunk = _chunks_vector.get(index);
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
_chunks_vector.remove(index);
|
_chunks_vector.remove(index);
|
||||||
#else
|
|
||||||
_chunks_vector.remove_at(index);
|
|
||||||
#endif
|
|
||||||
_chunks.erase(IntPos(chunk->get_position_x(), chunk->get_position_y(), chunk->get_position_z()));
|
_chunks.erase(IntPos(chunk->get_position_x(), chunk->get_position_y(), chunk->get_position_z()));
|
||||||
chunk->exit_tree();
|
chunk->exit_tree();
|
||||||
|
|
||||||
@ -387,12 +361,7 @@ Ref<VoxelChunk> VoxelWorld::chunk_get_or_create(int x, int y, int z) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ref<VoxelChunk> VoxelWorld::chunk_create(const int x, const int y, const int z) {
|
Ref<VoxelChunk> VoxelWorld::chunk_create(const int x, const int y, const int z) {
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
Ref<VoxelChunk> c = call("_create_chunk", x, y, z, Ref<VoxelChunk>());
|
Ref<VoxelChunk> c = call("_create_chunk", x, y, z, Ref<VoxelChunk>());
|
||||||
#else
|
|
||||||
Ref<VoxelChunk> c;
|
|
||||||
GDVIRTUAL_CALL(_create_chunk, x, y, z, Ref<VoxelChunk>(), c);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
generation_queue_add_to(c);
|
generation_queue_add_to(c);
|
||||||
|
|
||||||
@ -402,21 +371,12 @@ Ref<VoxelChunk> VoxelWorld::chunk_create(const int x, const int y, const int z)
|
|||||||
void VoxelWorld::chunk_setup(Ref<VoxelChunk> chunk) {
|
void VoxelWorld::chunk_setup(Ref<VoxelChunk> chunk) {
|
||||||
ERR_FAIL_COND(!chunk.is_valid());
|
ERR_FAIL_COND(!chunk.is_valid());
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
call("_create_chunk", chunk->get_position_x(), chunk->get_position_y(), chunk->get_position_z(), chunk);
|
call("_create_chunk", chunk->get_position_x(), chunk->get_position_y(), chunk->get_position_z(), chunk);
|
||||||
#else
|
|
||||||
Ref<VoxelChunk> c;
|
|
||||||
GDVIRTUAL_CALL(_create_chunk, chunk->get_position_x(), chunk->get_position_y(), chunk->get_position_z(), chunk, c);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<VoxelChunk> VoxelWorld::_create_chunk(const int x, const int y, const int z, Ref<VoxelChunk> chunk) {
|
Ref<VoxelChunk> VoxelWorld::_create_chunk(const int x, const int y, const int z, Ref<VoxelChunk> chunk) {
|
||||||
if (!chunk.is_valid()) {
|
if (!chunk.is_valid()) {
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
chunk.instance();
|
chunk.instance();
|
||||||
#else
|
|
||||||
chunk.instantiate();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//no meshers here
|
//no meshers here
|
||||||
@ -446,18 +406,10 @@ void VoxelWorld::chunk_generate(Ref<VoxelChunk> chunk) {
|
|||||||
ERR_FAIL_COND(!chunk.is_valid());
|
ERR_FAIL_COND(!chunk.is_valid());
|
||||||
|
|
||||||
if (has_method("_prepare_chunk_for_generation")) {
|
if (has_method("_prepare_chunk_for_generation")) {
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
call("_prepare_chunk_for_generation", chunk);
|
call("_prepare_chunk_for_generation", chunk);
|
||||||
#else
|
|
||||||
GDVIRTUAL_CALL(_prepare_chunk_for_generation, chunk);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
call("_generate_chunk", chunk);
|
call("_generate_chunk", chunk);
|
||||||
#else
|
|
||||||
GDVIRTUAL_CALL(_generate_chunk, chunk);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
chunk->build();
|
chunk->build();
|
||||||
}
|
}
|
||||||
@ -566,11 +518,7 @@ Ref<VoxelChunk> VoxelWorld::generation_queue_get_index(int index) {
|
|||||||
void VoxelWorld::generation_queue_remove_index(int index) {
|
void VoxelWorld::generation_queue_remove_index(int index) {
|
||||||
ERR_FAIL_INDEX(index, _generation_queue.size());
|
ERR_FAIL_INDEX(index, _generation_queue.size());
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
_generation_queue.remove(index);
|
_generation_queue.remove(index);
|
||||||
#else
|
|
||||||
_generation_queue.remove_at(index);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
int VoxelWorld::generation_queue_get_size() const {
|
int VoxelWorld::generation_queue_get_size() const {
|
||||||
return _generation_queue.size();
|
return _generation_queue.size();
|
||||||
@ -589,11 +537,7 @@ Ref<VoxelChunk> VoxelWorld::generation_get_index(const int index) {
|
|||||||
void VoxelWorld::generation_remove_index(const int index) {
|
void VoxelWorld::generation_remove_index(const int index) {
|
||||||
ERR_FAIL_INDEX(index, _generating.size());
|
ERR_FAIL_INDEX(index, _generating.size());
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
_generating.remove(index);
|
_generating.remove(index);
|
||||||
#else
|
|
||||||
_generating.remove_at(index);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
int VoxelWorld::generation_get_size() const {
|
int VoxelWorld::generation_get_size() const {
|
||||||
return _generating.size();
|
return _generating.size();
|
||||||
@ -646,11 +590,7 @@ void VoxelWorld::prop_add(Transform tarnsform, const Ref<PropData> &prop, const
|
|||||||
if (!sc.is_valid())
|
if (!sc.is_valid())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
Node *n = sc->instance();
|
Node *n = sc->instance();
|
||||||
#else
|
|
||||||
Node *n = sc->instantiate();
|
|
||||||
#endif
|
|
||||||
add_child(n);
|
add_child(n);
|
||||||
n->set_owner(this);
|
n->set_owner(this);
|
||||||
|
|
||||||
@ -667,11 +607,7 @@ void VoxelWorld::prop_add(Transform tarnsform, const Ref<PropData> &prop, const
|
|||||||
|
|
||||||
if (light_data.is_valid()) {
|
if (light_data.is_valid()) {
|
||||||
Ref<VoxelLight> light;
|
Ref<VoxelLight> light;
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
light.instance();
|
light.instance();
|
||||||
#else
|
|
||||||
light.instantiate();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
light->set_world_position(wp.x / get_voxel_scale(), wp.y / get_voxel_scale(), wp.z / get_voxel_scale());
|
light->set_world_position(wp.x / get_voxel_scale(), wp.y / get_voxel_scale(), wp.z / get_voxel_scale());
|
||||||
light->set_color(light_data->get_light_color());
|
light->set_color(light_data->get_light_color());
|
||||||
@ -903,24 +839,11 @@ Ref<VoxelChunk> VoxelWorld::get_or_create_chunk_at_world_position(const Vector3
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VoxelWorld::set_voxel_with_tool(const bool mode_add, const Vector3 hit_position, const Vector3 hit_normal, const int selected_voxel, const int isolevel) {
|
void VoxelWorld::set_voxel_with_tool(const bool mode_add, const Vector3 hit_position, const Vector3 hit_normal, const int selected_voxel, const int isolevel) {
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
call("_set_voxel_with_tool", mode_add, hit_position, hit_normal, selected_voxel, isolevel);
|
call("_set_voxel_with_tool", mode_add, hit_position, hit_normal, selected_voxel, isolevel);
|
||||||
#else
|
|
||||||
GDVIRTUAL_CALL(_set_voxel_with_tool, mode_add, hit_position, hit_normal, selected_voxel, isolevel);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int VoxelWorld::get_channel_index_info(const VoxelWorld::ChannelTypeInfo channel_type) {
|
int VoxelWorld::get_channel_index_info(const VoxelWorld::ChannelTypeInfo channel_type) {
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
return call("_get_channel_index_info", channel_type);
|
return call("_get_channel_index_info", channel_type);
|
||||||
#else
|
|
||||||
int ret;
|
|
||||||
if (GDVIRTUAL_CALL(_get_channel_index_info, channel_type, ret)) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VoxelWorld::VoxelWorld() {
|
VoxelWorld::VoxelWorld() {
|
||||||
@ -1023,18 +946,10 @@ void VoxelWorld::_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()) {
|
if (_is_priority_generation && _generation_queue.empty() && _generating.empty()) {
|
||||||
#endif
|
|
||||||
_is_priority_generation = false;
|
_is_priority_generation = false;
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
call("_generation_finished");
|
call("_generation_finished");
|
||||||
#else
|
|
||||||
GDVIRTUAL_CALL(_generation_finished);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
emit_signal("generation_finished");
|
emit_signal("generation_finished");
|
||||||
|
|
||||||
@ -1045,11 +960,7 @@ void VoxelWorld::_notification(int p_what) {
|
|||||||
Ref<VoxelChunk> chunk = _generating.get(i);
|
Ref<VoxelChunk> chunk = _generating.get(i);
|
||||||
|
|
||||||
if (!chunk.is_valid() || !chunk->get_is_generating()) {
|
if (!chunk.is_valid() || !chunk->get_is_generating()) {
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
_generating.remove(i);
|
_generating.remove(i);
|
||||||
#else
|
|
||||||
_generating.remove_at(i);
|
|
||||||
#endif
|
|
||||||
--i;
|
--i;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1064,11 +975,7 @@ void VoxelWorld::_notification(int p_what) {
|
|||||||
while (_generating.size() < _max_concurrent_generations && _generation_queue.size() != 0) {
|
while (_generating.size() < _max_concurrent_generations && _generation_queue.size() != 0) {
|
||||||
Ref<VoxelChunk> chunk = _generation_queue.get(0);
|
Ref<VoxelChunk> chunk = _generation_queue.get(0);
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
_generation_queue.remove(0);
|
_generation_queue.remove(0);
|
||||||
#else
|
|
||||||
_generation_queue.remove_at(0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ERR_FAIL_COND(!chunk.is_valid());
|
ERR_FAIL_COND(!chunk.is_valid());
|
||||||
|
|
||||||
@ -1204,11 +1111,7 @@ void VoxelWorld::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("voxel_structures_set"), &VoxelWorld::voxel_structures_set);
|
ClassDB::bind_method(D_METHOD("voxel_structures_set"), &VoxelWorld::voxel_structures_set);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_structures", PROPERTY_HINT_NONE, "17/17:VoxelStructure", PROPERTY_USAGE_DEFAULT, "VoxelStructure"), "voxel_structures_set", "voxel_structures_get");
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_structures", PROPERTY_HINT_NONE, "17/17:VoxelStructure", PROPERTY_USAGE_DEFAULT, "VoxelStructure"), "voxel_structures_set", "voxel_structures_get");
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
BIND_VMETHOD(MethodInfo("_chunk_added", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk")));
|
BIND_VMETHOD(MethodInfo("_chunk_added", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk")));
|
||||||
#else
|
|
||||||
GDVIRTUAL_BIND(_chunk_added, "chunk");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("chunk_add", "chunk", "x", "y", "z"), &VoxelWorld::chunk_add);
|
ClassDB::bind_method(D_METHOD("chunk_add", "chunk", "x", "y", "z"), &VoxelWorld::chunk_add);
|
||||||
ClassDB::bind_method(D_METHOD("chunk_has", "x", "y", "z"), &VoxelWorld::chunk_has);
|
ClassDB::bind_method(D_METHOD("chunk_has", "x", "y", "z"), &VoxelWorld::chunk_has);
|
||||||
@ -1237,18 +1140,11 @@ void VoxelWorld::_bind_methods() {
|
|||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("generation_finished"));
|
ADD_SIGNAL(MethodInfo("generation_finished"));
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
BIND_VMETHOD(MethodInfo("_generation_finished"));
|
BIND_VMETHOD(MethodInfo("_generation_finished"));
|
||||||
|
|
||||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "ret", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), "_create_chunk", PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z"), PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk")));
|
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "ret", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), "_create_chunk", PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z"), PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk")));
|
||||||
BIND_VMETHOD(MethodInfo("_prepare_chunk_for_generation", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk")));
|
BIND_VMETHOD(MethodInfo("_prepare_chunk_for_generation", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk")));
|
||||||
BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk")));
|
BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk")));
|
||||||
#else
|
|
||||||
GDVIRTUAL_BIND(_generation_finished);
|
|
||||||
GDVIRTUAL_BIND(_create_chunk, "chunk", "x", "y", "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", "y", "z"), &VoxelWorld::chunk_get_or_create);
|
ClassDB::bind_method(D_METHOD("chunk_get_or_create", "x", "y", "z"), &VoxelWorld::chunk_get_or_create);
|
||||||
ClassDB::bind_method(D_METHOD("chunk_create", "x", "y", "z"), &VoxelWorld::chunk_create);
|
ClassDB::bind_method(D_METHOD("chunk_create", "x", "y", "z"), &VoxelWorld::chunk_create);
|
||||||
@ -1280,25 +1176,17 @@ void VoxelWorld::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("get_chunk_at_world_position", "world_position"), &VoxelWorld::get_chunk_at_world_position);
|
ClassDB::bind_method(D_METHOD("get_chunk_at_world_position", "world_position"), &VoxelWorld::get_chunk_at_world_position);
|
||||||
ClassDB::bind_method(D_METHOD("get_or_create_chunk_at_world_position", "world_position"), &VoxelWorld::get_or_create_chunk_at_world_position);
|
ClassDB::bind_method(D_METHOD("get_or_create_chunk_at_world_position", "world_position"), &VoxelWorld::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)));
|
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"), &VoxelWorld::get_channel_index_info);
|
ClassDB::bind_method(D_METHOD("get_channel_index_info", "channel_type"), &VoxelWorld::get_channel_index_info);
|
||||||
ClassDB::bind_method(D_METHOD("_get_channel_index_info", "channel_type"), &VoxelWorld::_get_channel_index_info);
|
ClassDB::bind_method(D_METHOD("_get_channel_index_info", "channel_type"), &VoxelWorld::_get_channel_index_info);
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
BIND_VMETHOD(MethodInfo("_set_voxel_with_tool",
|
BIND_VMETHOD(MethodInfo("_set_voxel_with_tool",
|
||||||
PropertyInfo(Variant::BOOL, "mode_add"),
|
PropertyInfo(Variant::BOOL, "mode_add"),
|
||||||
PropertyInfo(Variant::VECTOR3, "hit_position"),
|
PropertyInfo(Variant::VECTOR3, "hit_position"),
|
||||||
PropertyInfo(Variant::VECTOR3, "hit_normal"),
|
PropertyInfo(Variant::VECTOR3, "hit_normal"),
|
||||||
PropertyInfo(Variant::INT, "selected_voxel"),
|
PropertyInfo(Variant::INT, "selected_voxel"),
|
||||||
PropertyInfo(Variant::INT, "isolevel")));
|
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"), &VoxelWorld::set_voxel_with_tool);
|
ClassDB::bind_method(D_METHOD("set_voxel_with_tool", "mode_add", "hit_position", "hit_normal", "selected_voxel", "isolevel"), &VoxelWorld::set_voxel_with_tool);
|
||||||
ClassDB::bind_method(D_METHOD("_set_voxel_with_tool", "mode_add", "hit_position", "hit_normal", "selected_voxel", "isolevel"), &VoxelWorld::_set_voxel_with_tool);
|
ClassDB::bind_method(D_METHOD("_set_voxel_with_tool", "mode_add", "hit_position", "hit_normal", "selected_voxel", "isolevel"), &VoxelWorld::_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.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "core/version.h"
|
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
#include "core/templates/hash_map.h"
|
|
||||||
#include "core/config/engine.h"
|
|
||||||
#else
|
|
||||||
#include "core/hash_map.h"
|
|
||||||
#include "core/engine.h"
|
#include "core/engine.h"
|
||||||
#endif
|
#include "core/hash_map.h"
|
||||||
|
|
||||||
#include "../defines.h"
|
#include "../defines.h"
|
||||||
|
|
||||||
@ -193,20 +183,6 @@ public:
|
|||||||
|
|
||||||
int get_channel_index_info(const ChannelTypeInfo channel_type);
|
int get_channel_index_info(const ChannelTypeInfo channel_type);
|
||||||
|
|
||||||
#if VERSION_MAJOR >= 4
|
|
||||||
GDVIRTUAL1(_chunk_added, Ref<VoxelChunk>);
|
|
||||||
|
|
||||||
GDVIRTUAL0(_generation_finished);
|
|
||||||
|
|
||||||
GDVIRTUAL4R(Ref<VoxelChunk>, _create_chunk, int, int, int, Ref<VoxelChunk>);
|
|
||||||
GDVIRTUAL1(_prepare_chunk_for_generation, Ref<VoxelChunk>);
|
|
||||||
GDVIRTUAL1(_generate_chunk, Ref<VoxelChunk>);
|
|
||||||
|
|
||||||
GDVIRTUAL1R(int, _get_channel_index_info, int);
|
|
||||||
|
|
||||||
GDVIRTUAL5(_set_voxel_with_tool, bool, Vector3, Vector3, int, int);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
VoxelWorld();
|
VoxelWorld();
|
||||||
~VoxelWorld();
|
~VoxelWorld();
|
||||||
|
|
||||||
@ -270,23 +246,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) {
|
||||||
|
@ -22,8 +22,6 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "voxel_world_editor.h"
|
#include "voxel_world_editor.h"
|
||||||
|
|
||||||
#include "core/version.h"
|
|
||||||
|
|
||||||
#include "editor/editor_scale.h"
|
#include "editor/editor_scale.h"
|
||||||
#include "editor/editor_settings.h"
|
#include "editor/editor_settings.h"
|
||||||
|
|
||||||
@ -33,10 +31,10 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "voxel_chunk.h"
|
#include "voxel_chunk.h"
|
||||||
|
|
||||||
#include "../library/voxel_surface.h"
|
|
||||||
#include "../library/voxel_library.h"
|
#include "../library/voxel_library.h"
|
||||||
#include "servers/physics_server.h"
|
#include "../library/voxel_surface.h"
|
||||||
#include "scene/resources/world.h"
|
#include "scene/resources/world.h"
|
||||||
|
#include "servers/physics_server.h"
|
||||||
|
|
||||||
#include "../defines.h"
|
#include "../defines.h"
|
||||||
|
|
||||||
@ -44,7 +42,6 @@ SOFTWARE.
|
|||||||
#include spatial_editor_plugin_h
|
#include spatial_editor_plugin_h
|
||||||
#include camera_h
|
#include camera_h
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
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()) {
|
||||||
return false;
|
return false;
|
||||||
@ -71,39 +68,6 @@ bool VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<I
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
EditorPlugin::AfterGUIInput VoxelWorldEditor::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<VoxelLibrary> 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 VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) {
|
bool VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) {
|
||||||
if (!spatial_editor || !_world || !_world->is_inside_world())
|
if (!spatial_editor || !_world || !_world->is_inside_world())
|
||||||
@ -121,18 +85,7 @@ bool VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point,
|
|||||||
|
|
||||||
PhysicsDirectSpaceState::RayResult res;
|
PhysicsDirectSpaceState::RayResult res;
|
||||||
|
|
||||||
#if VERSION_MAJOR >= 4
|
|
||||||
PhysicsDirectSpaceState::RayParameters keyparams;
|
|
||||||
keyparams.from = from;
|
|
||||||
keyparams.to = to;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
if (ss->intersect_ray(from, to, res)) {
|
if (ss->intersect_ray(from, to, res)) {
|
||||||
#else
|
|
||||||
if (ss->intersect_ray(keyparams, res)) {
|
|
||||||
#endif
|
|
||||||
int selected_voxel = 0;
|
int selected_voxel = 0;
|
||||||
int channel = 0;
|
int channel = 0;
|
||||||
|
|
||||||
@ -205,11 +158,7 @@ void VoxelWorldEditor::edit(VoxelWorld *p_world) {
|
|||||||
|
|
||||||
Button *button = memnew(Button);
|
Button *button = memnew(Button);
|
||||||
button->set_text(text);
|
button->set_text(text);
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
button->set_text_align(Button::ALIGN_LEFT);
|
button->set_text_align(Button::ALIGN_LEFT);
|
||||||
#else
|
|
||||||
button->set_text_alignment(HorizontalAlignment::HORIZONTAL_ALIGNMENT_LEFT);
|
|
||||||
#endif
|
|
||||||
button->set_meta("index", i);
|
button->set_meta("index", i);
|
||||||
button->set_toggle_mode(true);
|
button->set_toggle_mode(true);
|
||||||
button->set_button_group(_surfaces_button_group);
|
button->set_button_group(_surfaces_button_group);
|
||||||
@ -247,18 +196,10 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) {
|
|||||||
|
|
||||||
spatial_editor_hb = memnew(HBoxContainer);
|
spatial_editor_hb = memnew(HBoxContainer);
|
||||||
spatial_editor_hb->set_h_size_flags(SIZE_EXPAND_FILL);
|
spatial_editor_hb->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
spatial_editor_hb->set_alignment(BoxContainer::ALIGN_BEGIN);
|
spatial_editor_hb->set_alignment(BoxContainer::ALIGN_BEGIN);
|
||||||
#else
|
|
||||||
spatial_editor_hb->set_alignment(BoxContainer::ALIGNMENT_BEGIN);
|
|
||||||
#endif
|
|
||||||
SpatialEditor::get_singleton()->add_control_to_menu_panel(spatial_editor_hb);
|
SpatialEditor::get_singleton()->add_control_to_menu_panel(spatial_editor_hb);
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
_tool_button_group.instance();
|
_tool_button_group.instance();
|
||||||
#else
|
|
||||||
_tool_button_group.instantiate();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ToolButton *add_button = memnew(ToolButton);
|
ToolButton *add_button = memnew(ToolButton);
|
||||||
add_button->set_text("Add");
|
add_button->set_text("Add");
|
||||||
@ -269,11 +210,7 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) {
|
|||||||
|
|
||||||
add_button->CONNECT("button_up", this, VoxelWorldEditor, _on_tool_button_pressed);
|
add_button->CONNECT("button_up", this, VoxelWorldEditor, _on_tool_button_pressed);
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
add_button->set_shortcut(ED_SHORTCUT("voxel_world_editor/add_mode", "Add Mode", KEY_A));
|
add_button->set_shortcut(ED_SHORTCUT("voxel_world_editor/add_mode", "Add Mode", KEY_A));
|
||||||
#else
|
|
||||||
add_button->set_shortcut(ED_SHORTCUT("voxel_world_editor/add_mode", "Add Mode", Key::A));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
spatial_editor_hb->add_child(add_button);
|
spatial_editor_hb->add_child(add_button);
|
||||||
|
|
||||||
@ -285,11 +222,7 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) {
|
|||||||
|
|
||||||
remove_button->CONNECT("button_up", this, VoxelWorldEditor, _on_tool_button_pressed);
|
remove_button->CONNECT("button_up", this, VoxelWorldEditor, _on_tool_button_pressed);
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
remove_button->set_shortcut(ED_SHORTCUT("voxel_world_editor/remove_mode", "Remove Mode", KEY_S));
|
remove_button->set_shortcut(ED_SHORTCUT("voxel_world_editor/remove_mode", "Remove Mode", KEY_S));
|
||||||
#else
|
|
||||||
remove_button->set_shortcut(ED_SHORTCUT("voxel_world_editor/remove_mode", "Remove Mode", Key::S));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
spatial_editor_hb->add_child(remove_button);
|
spatial_editor_hb->add_child(remove_button);
|
||||||
|
|
||||||
@ -298,11 +231,7 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) {
|
|||||||
|
|
||||||
insert_buton->CONNECT("button_up", this, VoxelWorldEditor, _on_insert_block_at_camera_button_pressed);
|
insert_buton->CONNECT("button_up", this, VoxelWorldEditor, _on_insert_block_at_camera_button_pressed);
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
insert_buton->set_shortcut(ED_SHORTCUT("voxel_world_editor/instert_block_at_camera", "Insert at camera", KEY_B));
|
insert_buton->set_shortcut(ED_SHORTCUT("voxel_world_editor/instert_block_at_camera", "Insert at camera", KEY_B));
|
||||||
#else
|
|
||||||
insert_buton->set_shortcut(ED_SHORTCUT("voxel_world_editor/instert_block_at_camera", "Insert at camera", Key::B));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
spatial_editor_hb->add_child(insert_buton);
|
spatial_editor_hb->add_child(insert_buton);
|
||||||
|
|
||||||
@ -330,11 +259,7 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) {
|
|||||||
scs->add_child(_surfaces_vbox_container);
|
scs->add_child(_surfaces_vbox_container);
|
||||||
_surfaces_vbox_container->set_h_size_flags(SIZE_EXPAND_FILL);
|
_surfaces_vbox_container->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
_surfaces_button_group.instance();
|
_surfaces_button_group.instance();
|
||||||
#else
|
|
||||||
_surfaces_button_group.instantiate();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
VoxelWorldEditor::~VoxelWorldEditor() {
|
VoxelWorldEditor::~VoxelWorldEditor() {
|
||||||
_world = NULL;
|
_world = NULL;
|
||||||
@ -377,12 +302,7 @@ void VoxelWorldEditor::_on_insert_block_at_camera_button_pressed() {
|
|||||||
if (!vp)
|
if (!vp)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
Camera *cam = vp->get_camera();
|
Camera *cam = vp->get_camera();
|
||||||
#else
|
|
||||||
Camera *cam = vp->get_camera_3d();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!cam)
|
if (!cam)
|
||||||
return;
|
return;
|
||||||
@ -413,21 +333,12 @@ void VoxelWorldEditor::_bind_methods() {
|
|||||||
void VoxelWorldEditorPlugin::_notification(int p_what) {
|
void VoxelWorldEditorPlugin::_notification(int p_what) {
|
||||||
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
|
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
|
||||||
switch ((int)EditorSettings::get_singleton()->get("editors/voxel/editor_side")) {
|
switch ((int)EditorSettings::get_singleton()->get("editors/voxel/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.
|
case 0: { // Left.
|
||||||
SpatialEditor::get_singleton()->move_control_to_left_panel(voxel_world_editor);
|
SpatialEditor::get_singleton()->move_control_to_left_panel(voxel_world_editor);
|
||||||
} break;
|
} break;
|
||||||
case 1: { // Right.
|
case 1: { // Right.
|
||||||
SpatialEditor::get_singleton()->move_control_to_right_panel(voxel_world_editor);
|
SpatialEditor::get_singleton()->move_control_to_right_panel(voxel_world_editor);
|
||||||
} break;
|
} break;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,19 +22,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "editor/editor_node.h"
|
#include "editor/editor_node.h"
|
||||||
#include "editor/editor_plugin.h"
|
#include "editor/editor_plugin.h"
|
||||||
|
|
||||||
#include "../defines.h"
|
#include "../defines.h"
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
|
||||||
#include "core/math/transform_3d.h"
|
|
||||||
typedef class Transform3D Transform;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class VoxelWorld;
|
class VoxelWorld;
|
||||||
class SpatialEditorPlugin;
|
class SpatialEditorPlugin;
|
||||||
|
|
||||||
@ -48,11 +40,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#if VERSION_MAJOR < 4
|
|
||||||
bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event);
|
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(VoxelWorld *p_world);
|
void edit(VoxelWorld *p_world);
|
||||||
bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
|
bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
|
||||||
@ -102,13 +90,8 @@ protected:
|
|||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
|
||||||
public:
|
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); }
|
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); }
|
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 "VoxelWorldEditor"; }
|
virtual String get_name() const { return "VoxelWorldEditor"; }
|
||||||
bool has_main_screen() const { return false; }
|
bool has_main_screen() const { return false; }
|
||||||
virtual void edit(Object *p_object);
|
virtual void edit(Object *p_object);
|
||||||
|
Loading…
Reference in New Issue
Block a user