mirror of
https://github.com/Relintai/voxelman.git
synced 2024-11-12 10:15:12 +01:00
Fix compile for 4.0.
This commit is contained in:
parent
c48dfde661
commit
edce32b190
@ -37,6 +37,8 @@ typedef class RenderingServer VS;
|
||||
typedef class PhysicsServer3D PhysicsServer;
|
||||
|
||||
typedef class StandardMaterial3D SpatialMaterial;
|
||||
|
||||
typedef class World3D World;
|
||||
#endif
|
||||
|
||||
#include "../../../opensimplex/open_simplex_noise.h"
|
||||
@ -225,7 +227,6 @@ void VoxelChunkDefault::_build_step_threaded(void *_userdata) {
|
||||
}
|
||||
|
||||
void VoxelChunkDefault::build_phase() {
|
||||
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
if (_abort_build)
|
||||
@ -298,7 +299,6 @@ void VoxelChunkDefault::emit_build_finished() {
|
||||
}
|
||||
|
||||
void VoxelChunkDefault::generate_random_ao(int seed, int octaves, int period, float persistence, float scale_factor) {
|
||||
|
||||
Ref<OpenSimplexNoise> noise;
|
||||
noise.instance();
|
||||
|
||||
@ -526,8 +526,13 @@ void VoxelChunkDefault::create_meshes(const int mesh_index, const int mesh_count
|
||||
for (int i = 0; i < mesh_count; ++i) {
|
||||
RID mesh_instance_rid = VS::get_singleton()->instance_create();
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
if (get_voxel_world()->get_world().is_valid())
|
||||
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();
|
||||
|
||||
@ -555,7 +560,6 @@ void VoxelChunkDefault::free_meshes(const int mesh_index) {
|
||||
RID rid;
|
||||
|
||||
if (m.has(MESH_TYPE_INDEX_MESH)) {
|
||||
|
||||
Array a = m[MESH_TYPE_INDEX_MESH];
|
||||
|
||||
for (int i = 0; i < a.size(); ++i) {
|
||||
@ -607,7 +611,11 @@ 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());
|
||||
|
||||
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();
|
||||
#else
|
||||
Ref<World> world = get_voxel_world()->get_world_3d();
|
||||
#endif
|
||||
|
||||
if (world.is_valid() && world->get_space() != RID())
|
||||
PhysicsServer::get_singleton()->body_set_space(body_rid, world->get_space());
|
||||
@ -645,7 +653,11 @@ void VoxelChunkDefault::create_colliders_area(const int mesh_index, const int la
|
||||
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 VERSION_MAJOR < 4
|
||||
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())
|
||||
PhysicsServer::get_singleton()->area_set_space(area_rid, world->get_space());
|
||||
@ -806,7 +818,6 @@ void VoxelChunkDefault::draw_debug_voxels(int max, Color color) {
|
||||
for (int y = 0; y < sy; ++y) {
|
||||
for (int z = 0; z < sz; ++z) {
|
||||
for (int x = 0; x < sx; ++x) {
|
||||
|
||||
int type = get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
|
||||
if (type == 0) {
|
||||
@ -928,7 +939,6 @@ void VoxelChunkDefault::_physics_process(float delta) {
|
||||
}
|
||||
|
||||
if (_active_build_phase_type == BUILD_PHASE_TYPE_PHYSICS_PROCESS) {
|
||||
|
||||
if (!_voxel_world->can_chunk_do_build_step())
|
||||
return;
|
||||
|
||||
@ -1325,7 +1335,11 @@ void VoxelChunkDefault::_build_phase(int phase) {
|
||||
}
|
||||
|
||||
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
|
||||
#if VERSION_MAJOR < 4
|
||||
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
|
||||
#else
|
||||
VS::get_singleton()->mesh_clear(mesh_rid);
|
||||
#endif
|
||||
|
||||
VS::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
|
||||
@ -1411,7 +1425,11 @@ void VoxelChunkDefault::_build_phase(int phase) {
|
||||
}
|
||||
|
||||
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
|
||||
#if VERSION_MAJOR < 4
|
||||
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
|
||||
#else
|
||||
VS::get_singleton()->mesh_clear(mesh_rid);
|
||||
#endif
|
||||
|
||||
VS::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
|
||||
|
@ -294,7 +294,7 @@ protected:
|
||||
|
||||
ActiveBuildPhaseType _active_build_phase_type;
|
||||
|
||||
Vector<Ref<VoxelLight> > _lights;
|
||||
Vector<Ref<VoxelLight>> _lights;
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(VoxelChunkDefault::DefaultChannels);
|
||||
|
@ -24,6 +24,12 @@ SOFTWARE.
|
||||
|
||||
#include "voxel_chunk_default.h"
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
#define REAL FLOAT
|
||||
#endif
|
||||
|
||||
_FORCE_INLINE_ int VoxelWorldDefault::get_build_flags() const {
|
||||
return _build_flags;
|
||||
}
|
||||
@ -52,7 +58,11 @@ void VoxelWorldDefault::update_lods() {
|
||||
}
|
||||
|
||||
void VoxelWorldDefault::_update_lods() {
|
||||
#if VERSION_MAJOR < 4
|
||||
if (!get_player() || !ObjectDB::instance_validate(get_player())) {
|
||||
#else
|
||||
if (!get_player() || !get_player()) {
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
@ -86,7 +96,6 @@ void VoxelWorldDefault::_update_lods() {
|
||||
}
|
||||
|
||||
Ref<VoxelChunk> VoxelWorldDefault::_create_chunk(int x, int y, int z, Ref<VoxelChunk> chunk) {
|
||||
|
||||
if (!chunk.is_valid()) {
|
||||
chunk = Ref<VoxelChunk>(memnew(VoxelChunkDefault));
|
||||
}
|
||||
@ -145,7 +154,11 @@ void VoxelWorldDefault::_notification(int p_what) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
if (!ObjectDB::instance_validate(get_player())) {
|
||||
#else
|
||||
if (!get_player()) {
|
||||
#endif
|
||||
set_player(NULL);
|
||||
return;
|
||||
}
|
||||
@ -157,7 +170,6 @@ void VoxelWorldDefault::_notification(int p_what) {
|
||||
|
||||
update_lods();
|
||||
}
|
||||
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
@ -546,7 +546,11 @@ void VoxelChunk::create_meshers() {
|
||||
}
|
||||
|
||||
void VoxelChunk::build(const bool immediate) {
|
||||
#if VERSION_MAJOR < 4
|
||||
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(!is_in_tree());
|
||||
ERR_FAIL_COND_MSG(!has_method("_build"), "VoxelChunk: _build(immediate : bool) is missing! Please implement it!");
|
||||
|
@ -54,6 +54,7 @@ SOFTWARE.
|
||||
#define PhysicsDirectSpaceState PhysicsDirectSpaceState3D
|
||||
#define SpatialEditor Node3DEditor
|
||||
#define SpatialEditorPlugin Node3DEditorPlugin
|
||||
#define SpatialEditorViewport Node3DEditorViewport
|
||||
|
||||
#endif
|
||||
|
||||
@ -65,7 +66,6 @@ bool VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<I
|
||||
Ref<InputEventMouseButton> mb = p_event;
|
||||
|
||||
if (mb.is_valid()) {
|
||||
|
||||
if (mb->is_pressed()) {
|
||||
Ref<VoxelmanLibrary> lib = _world->get_library();
|
||||
|
||||
@ -86,7 +86,6 @@ bool VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<I
|
||||
}
|
||||
|
||||
bool VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) {
|
||||
|
||||
if (!spatial_editor || !_world || !_world->is_inside_world())
|
||||
return false;
|
||||
|
||||
@ -98,7 +97,12 @@ bool VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point,
|
||||
from = local_xform.xform(from);
|
||||
to = local_xform.xform(to);
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
PhysicsDirectSpaceState *ss = _world->get_world()->get_direct_space_state();
|
||||
#else
|
||||
PhysicsDirectSpaceState *ss = _world->get_world_3d()->get_direct_space_state();
|
||||
#endif
|
||||
|
||||
PhysicsDirectSpaceState::RayResult res;
|
||||
|
||||
if (ss->intersect_ray(from, to, res)) {
|
||||
@ -169,7 +173,12 @@ void VoxelWorldEditor::edit(VoxelWorld *p_world) {
|
||||
button->set_toggle_mode(true);
|
||||
button->set_button_group(_surfaces_button_group);
|
||||
button->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
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);
|
||||
|
||||
if (!f) {
|
||||
@ -206,7 +215,13 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) {
|
||||
add_button->set_pressed(true);
|
||||
add_button->set_button_group(_tool_button_group);
|
||||
add_button->set_meta("tool_mode", TOOL_MODE_ADD);
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
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));
|
||||
spatial_editor_hb->add_child(add_button);
|
||||
|
||||
@ -215,13 +230,25 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) {
|
||||
remove_button->set_toggle_mode(true);
|
||||
remove_button->set_button_group(_tool_button_group);
|
||||
remove_button->set_meta("tool_mode", TOOL_MODE_REMOVE);
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
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));
|
||||
spatial_editor_hb->add_child(remove_button);
|
||||
|
||||
ToolButton *insert_buton = memnew(ToolButton);
|
||||
insert_buton->set_text("Insert");
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
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));
|
||||
spatial_editor_hb->add_child(insert_buton);
|
||||
|
||||
@ -246,13 +273,11 @@ VoxelWorldEditor::~VoxelWorldEditor() {
|
||||
}
|
||||
|
||||
void VoxelWorldEditor::_node_removed(Node *p_node) {
|
||||
|
||||
if (p_node == _world)
|
||||
_world = NULL;
|
||||
}
|
||||
|
||||
void VoxelWorldEditor::_on_surface_button_pressed() {
|
||||
|
||||
BaseButton *button = _surfaces_button_group->get_pressed_button();
|
||||
|
||||
if (button) {
|
||||
@ -301,9 +326,7 @@ void VoxelWorldEditor::_bind_methods() {
|
||||
}
|
||||
|
||||
void VoxelWorldEditorPlugin::_notification(int p_what) {
|
||||
|
||||
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
|
||||
|
||||
switch ((int)EditorSettings::get_singleton()->get("editors/voxelman/editor_side")) {
|
||||
case 0: { // Left.
|
||||
SpatialEditor::get_singleton()->get_palette_split()->move_child(voxel_world_editor, 0);
|
||||
@ -316,12 +339,10 @@ void VoxelWorldEditorPlugin::_notification(int p_what) {
|
||||
}
|
||||
|
||||
void VoxelWorldEditorPlugin::edit(Object *p_object) {
|
||||
|
||||
voxel_world_editor->edit(Object::cast_to<VoxelWorld>(p_object));
|
||||
}
|
||||
|
||||
bool VoxelWorldEditorPlugin::handles(Object *p_object) const {
|
||||
|
||||
if (!p_object->is_class("VoxelWorld"))
|
||||
return false;
|
||||
|
||||
@ -331,13 +352,11 @@ bool VoxelWorldEditorPlugin::handles(Object *p_object) const {
|
||||
}
|
||||
|
||||
void VoxelWorldEditorPlugin::make_visible(bool p_visible) {
|
||||
|
||||
if (p_visible) {
|
||||
voxel_world_editor->show();
|
||||
voxel_world_editor->spatial_editor_hb->show();
|
||||
voxel_world_editor->set_process(true);
|
||||
} else {
|
||||
|
||||
voxel_world_editor->spatial_editor_hb->hide();
|
||||
voxel_world_editor->hide();
|
||||
voxel_world_editor->edit(NULL);
|
||||
@ -346,7 +365,6 @@ void VoxelWorldEditorPlugin::make_visible(bool p_visible) {
|
||||
}
|
||||
|
||||
VoxelWorldEditorPlugin::VoxelWorldEditorPlugin(EditorNode *p_node) {
|
||||
|
||||
editor = p_node;
|
||||
|
||||
EDITOR_DEF("editors/voxelman/editor_side", 1);
|
||||
|
Loading…
Reference in New Issue
Block a user