From de103a3fdf5adcc3ddb2279c7e6b96013b79d933 Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 18 Nov 2019 22:35:08 +0100 Subject: [PATCH] Fixed compile. --- meshers/cubic_mesher/voxel_cube_points.cpp | 13 ++++++++++--- meshers/cubic_mesher/voxel_cube_points.h | 5 +++-- meshers/cubic_mesher/voxel_mesher_cubic.cpp | 6 +++++- meshers/cubic_mesher/voxel_mesher_cubic.h | 2 +- props/prop_data.cpp | 7 ++----- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/meshers/cubic_mesher/voxel_cube_points.cpp b/meshers/cubic_mesher/voxel_cube_points.cpp index 7aaf784..cdac8b2 100644 --- a/meshers/cubic_mesher/voxel_cube_points.cpp +++ b/meshers/cubic_mesher/voxel_cube_points.cpp @@ -168,7 +168,9 @@ void VoxelCubePoints::recalculate_point(int point) { _points[point] = dynamic_offset; } -void VoxelCubePoints::refresh_neighbours(const VoxelChunk *chunk) { +void VoxelCubePoints::refresh_neighbours(VoxelChunk *chunk) { + ERR_FAIL_COND(!ObjectDB::instance_validate(chunk)); + int neighbours = 0; int x = _x; @@ -405,7 +407,12 @@ void VoxelCubePoints::refresh_neighbours(const VoxelChunk *chunk) { _point_neighbours[P111] = neighbours; } -void VoxelCubePoints::setup(const VoxelChunk *chunk, int x, int y, int z, int size) { +void VoxelCubePoints::setup_bind(Node *chunk, int x, int y, int z, int size) { + setup(Object::cast_to(chunk), x, y, z, size); +} + +void VoxelCubePoints::setup(VoxelChunk *chunk, int x, int y, int z, int size) { + ERR_FAIL_COND(!ObjectDB::instance_validate(chunk)); ERR_FAIL_COND(size <= 0); ERR_FAIL_COND(!chunk->validate_channel_position(x + size, y + size, z + size) || !chunk->validate_channel_position(x, y, z)); @@ -757,7 +764,7 @@ void VoxelCubePoints::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "size"), "set_size", "get_size"); ClassDB::bind_method(D_METHOD("refresh_points"), &VoxelCubePoints::refresh_points); - ClassDB::bind_method(D_METHOD("setup", "chunk", "x", "y", "z", "size"), &VoxelCubePoints::setup, DEFVAL(1)); + ClassDB::bind_method(D_METHOD("setup", "chunk", "x", "y", "z", "size"), &VoxelCubePoints::setup_bind, DEFVAL(1)); ClassDB::bind_method(D_METHOD("get_point_index", "face", "index"), &VoxelCubePoints::get_point_index); ClassDB::bind_method(D_METHOD("get_point_uv_direction", "face", "index"), &VoxelCubePoints::get_point_uv_direction); diff --git a/meshers/cubic_mesher/voxel_cube_points.h b/meshers/cubic_mesher/voxel_cube_points.h index f9a0fb4..f9e41f9 100644 --- a/meshers/cubic_mesher/voxel_cube_points.h +++ b/meshers/cubic_mesher/voxel_cube_points.h @@ -91,8 +91,9 @@ public: void refresh_points(); void recalculate_point(int point); - void refresh_neighbours(const VoxelChunk *buffer); - void setup(const VoxelChunk *buffer, int x, int y, int z, int size = 1); + void refresh_neighbours(VoxelChunk *chunk); + void setup_bind(Node *chunk, int x, int y, int z, int size = 1); + void setup(VoxelChunk *chunk, int x, int y, int z, int size = 1); void reset(); diff --git a/meshers/cubic_mesher/voxel_mesher_cubic.cpp b/meshers/cubic_mesher/voxel_mesher_cubic.cpp index 83f0c8d..8207b3e 100644 --- a/meshers/cubic_mesher/voxel_mesher_cubic.cpp +++ b/meshers/cubic_mesher/voxel_mesher_cubic.cpp @@ -1,7 +1,11 @@ #include "voxel_mesher_cubic.h" -void VoxelMesherCubic::_add_buffer(VoxelChunk *chunk) { +void VoxelMesherCubic::_add_buffer(Node *p_chunk) { + VoxelChunk *chunk = Object::cast_to(p_chunk); + + ERR_FAIL_COND(!ObjectDB::instance_validate(chunk)); + chunk->generate_ao(); int x_size = chunk->get_size_x() - 1; diff --git a/meshers/cubic_mesher/voxel_mesher_cubic.h b/meshers/cubic_mesher/voxel_mesher_cubic.h index b239490..8b31845 100644 --- a/meshers/cubic_mesher/voxel_mesher_cubic.h +++ b/meshers/cubic_mesher/voxel_mesher_cubic.h @@ -13,7 +13,7 @@ class VoxelMesherCubic : public VoxelMesher { GDCLASS(VoxelMesherCubic, VoxelMesher); public: - void _add_buffer(VoxelChunk *chunk); + void _add_buffer(Node *p_chunk); VoxelMesherCubic(); ~VoxelMesherCubic(); diff --git a/props/prop_data.cpp b/props/prop_data.cpp index b8b1bc1..c5d98f5 100644 --- a/props/prop_data.cpp +++ b/props/prop_data.cpp @@ -88,13 +88,10 @@ void PropData::add_prop_lights_into(VoxelChunk *chunk, Transform parent_transfor Transform t = parent_transform * pl->get_transform(); Vector3 px = t.origin / chunk->get_voxel_scale(); - - Vector3i cp = chunk->get_chunk_position(); - Vector3i cs = chunk->get_chunk_size(); - + Ref vl; vl.instance(); - vl->set_world_position(px.x + cp.x * cs.x, px.y + cp.y * cs.y, px.z + cp.z * cs.z); + vl->set_world_position(px.x + chunk->get_position_x() * chunk->get_size_x(), px.y + chunk->get_position_y() * chunk->get_size_y(), px.z + chunk->get_position_z() * chunk->get_size_z()); vl->set_color(pl->get_light_color()); vl->set_size(pl->get_light_size());