mirror of
https://github.com/Relintai/terraman_2d.git
synced 2024-11-12 10:15:18 +01:00
Removed the default isolevel channels.
This commit is contained in:
parent
3a8ca20448
commit
da473b0794
@ -46,7 +46,6 @@ Ref<Terrain2DChunk> Terrain2DWorldBlocky::_create_chunk(int x, int z, Ref<Terrai
|
||||
Ref<Terrain2DMesherBlocky> liquid_mesher;
|
||||
liquid_mesher.instance();
|
||||
liquid_mesher->set_channel_index_type(Terrain2DChunkDefault::DEFAULT_CHANNEL_LIQUID_TYPE);
|
||||
liquid_mesher->set_channel_index_isolevel(Terrain2DChunkDefault::DEFAULT_CHANNEL_LIQUID_ISOLEVEL);
|
||||
tj->set_liquid_mesher(liquid_mesher);
|
||||
|
||||
Ref<Terrain2DProp2DJob> pj;
|
||||
|
@ -652,7 +652,7 @@ void Terrain2DChunkDefault::draw_debug_voxels(int max, Color color) {
|
||||
continue;
|
||||
}
|
||||
|
||||
draw_cross_voxels_fill(Vector3(x, get_voxel(x, z, Terrain2DChunkDefault::DEFAULT_CHANNEL_ISOLEVEL), z), get_voxel(x, z, Terrain2DChunkDefault::DEFAULT_CHANNEL_ISOLEVEL) / 255.0 * get_voxel_scale() * 2.0);
|
||||
draw_cross_voxels_fill(Vector3(x, 0, z), 1);
|
||||
|
||||
++a;
|
||||
|
||||
@ -970,9 +970,7 @@ void Terrain2DChunkDefault::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_finalize_build"), &Terrain2DChunkDefault::_finalize_build);
|
||||
|
||||
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_TYPE);
|
||||
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_ISOLEVEL);
|
||||
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_LIQUID_TYPE);
|
||||
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_LIQUID_ISOLEVEL);
|
||||
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_LIGHT_COLOR_R);
|
||||
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_LIGHT_COLOR_G);
|
||||
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_LIGHT_COLOR_B);
|
||||
|
@ -64,9 +64,7 @@ public:
|
||||
|
||||
enum DefaultChannels {
|
||||
DEFAULT_CHANNEL_TYPE = 0,
|
||||
DEFAULT_CHANNEL_ISOLEVEL,
|
||||
DEFAULT_CHANNEL_LIQUID_TYPE,
|
||||
DEFAULT_CHANNEL_LIQUID_ISOLEVEL,
|
||||
DEFAULT_CHANNEL_LIGHT_COLOR_R,
|
||||
DEFAULT_CHANNEL_LIGHT_COLOR_G,
|
||||
DEFAULT_CHANNEL_LIGHT_COLOR_B,
|
||||
|
@ -219,7 +219,7 @@ int Terrain2DWorldDefault::_get_channel_index_info(const Terrain2DWorld::Channel
|
||||
case CHANNEL_TYPE_INFO_TYPE:
|
||||
return Terrain2DChunkDefault::DEFAULT_CHANNEL_TYPE;
|
||||
case CHANNEL_TYPE_INFO_ISOLEVEL:
|
||||
return Terrain2DChunkDefault::DEFAULT_CHANNEL_ISOLEVEL;
|
||||
return -1;
|
||||
case CHANNEL_TYPE_INFO_LIQUID_FLOW:
|
||||
return -1;
|
||||
default:
|
||||
|
@ -103,41 +103,6 @@ void Terrain2DJob::physics_process(const float delta) {
|
||||
|
||||
//Data Management functions
|
||||
void Terrain2DJob::generate_ao() {
|
||||
ERR_FAIL_COND(!_chunk.is_valid());
|
||||
|
||||
int data_size_x = _chunk->get_data_size_x();
|
||||
int data_size_z = _chunk->get_data_size_z();
|
||||
|
||||
ERR_FAIL_COND(data_size_x == 0 || data_size_z == 0);
|
||||
|
||||
int margin_start = _chunk->get_margin_start();
|
||||
int margin_end = _chunk->get_margin_end();
|
||||
|
||||
int ssize_x = _chunk->get_size_x();
|
||||
int ssize_z = _chunk->get_size_z();
|
||||
|
||||
int size_x = ssize_x + margin_end;
|
||||
int size_z = ssize_z + margin_end;
|
||||
|
||||
for (int z = margin_start - 1; z < size_z - 1; ++z) {
|
||||
for (int x = margin_start - 1; x < size_x - 1; ++x) {
|
||||
int current = _chunk->get_voxel(x, z, Terrain2DChunkDefault::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
|
||||
int sum = _chunk->get_voxel(x + 1, z, Terrain2DChunkDefault::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
sum += _chunk->get_voxel(x - 1, z, Terrain2DChunkDefault::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
sum += _chunk->get_voxel(x, z + 1, Terrain2DChunkDefault::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
sum += _chunk->get_voxel(x, z - 1, Terrain2DChunkDefault::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
|
||||
sum /= 6;
|
||||
|
||||
sum -= current;
|
||||
|
||||
if (sum < 0)
|
||||
sum = 0;
|
||||
|
||||
_chunk->set_voxel(sum, x, z, Terrain2DChunkDefault::DEFAULT_CHANNEL_AO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Terrain2DJob::generate_random_ao(int seed, int octaves, int period, float persistence, float scale_factor) {
|
||||
@ -163,7 +128,7 @@ void Terrain2DJob::generate_random_ao(int seed, int octaves, int period, float p
|
||||
for (int x = -margin_start; x < size_x + margin_end; ++x) {
|
||||
for (int z = -margin_start; z < size_z + margin_end; ++z) {
|
||||
|
||||
float val = noise->get_noise_3d(x + (position_x * size_x), 0, z + (position_z * size_z));
|
||||
float val = noise->get_noise_2d(x + (position_x * size_x), z + (position_z * size_z));
|
||||
|
||||
val *= scale_factor;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user