mirror of
https://github.com/Relintai/voxelman.git
synced 2024-11-12 10:15:12 +01:00
Same treatment to jobs in VoxelChunk.
This commit is contained in:
parent
851b4efb52
commit
1d1fdf5c56
@ -132,14 +132,14 @@ This is done by `setup_chunk(shunk)` in `VoxelWorld`.
|
||||
chunk = MyChunk.new()
|
||||
|
||||
# We need to check whether or not we need to initialize jobs
|
||||
if chunk.get_job_count() == 0:
|
||||
if chunk.job_get_count() == 0:
|
||||
# Setup a blocky (minecratf like) mesher job
|
||||
var tj : VoxelTerrarinJob = VoxelTerrarinJob.new()
|
||||
|
||||
tj.add_mesher(VoxelMesherBlocky.new());
|
||||
tj.add_liquid_mesher(VoxelMesherLiquidBlocky.new());
|
||||
|
||||
chunk.add_job(tj);
|
||||
chunk.job_add(tj);
|
||||
|
||||
#setup your chunk here
|
||||
|
||||
|
@ -182,7 +182,7 @@ void VoxelMesherMarchingCubes::_add_chunk(Ref<VoxelChunk> p_chunk) {
|
||||
|
||||
ERR_FAIL_COND(!chunk.is_valid());
|
||||
|
||||
Ref<VoxelJob> job = chunk->get_current_job();
|
||||
Ref<VoxelJob> job = chunk->job_get_current();
|
||||
|
||||
//if (!job->has_meta("ao_done")) {
|
||||
// job->set_meta("ao_done", true);
|
||||
|
@ -36,7 +36,7 @@ Ref<VoxelChunk> VoxelWorldBlocky::_create_chunk(int x, int y, int z, Ref<VoxelCh
|
||||
chunk = Ref<VoxelChunk>(memnew(VoxelChunkBlocky));
|
||||
}
|
||||
|
||||
if (chunk->get_job_count() == 0) {
|
||||
if (chunk->job_get_count() == 0) {
|
||||
Ref<VoxelTerrarinJob> tj;
|
||||
tj.instance();
|
||||
|
||||
@ -50,9 +50,9 @@ Ref<VoxelChunk> VoxelWorldBlocky::_create_chunk(int x, int y, int z, Ref<VoxelCh
|
||||
tj->add_mesher(Ref<VoxelMesher>(memnew(VoxelMesherBlocky())));
|
||||
tj->add_liquid_mesher(Ref<VoxelMesher>(memnew(VoxelMesherLiquidBlocky())));
|
||||
|
||||
chunk->add_job(lj);
|
||||
chunk->add_job(tj);
|
||||
chunk->add_job(pj);
|
||||
chunk->job_add(lj);
|
||||
chunk->job_add(tj);
|
||||
chunk->job_add(pj);
|
||||
}
|
||||
|
||||
return VoxelWorld::_create_chunk(x, y, z, chunk);
|
||||
|
@ -35,7 +35,7 @@ Ref<VoxelChunk> VoxelWorldCubic::_create_chunk(int x, int y, int z, Ref<VoxelChu
|
||||
chunk = Ref<VoxelChunk>(memnew(VoxelChunkCubic));
|
||||
}
|
||||
|
||||
if (chunk->get_job_count() == 0) {
|
||||
if (chunk->job_get_count() == 0) {
|
||||
Ref<VoxelTerrarinJob> tj;
|
||||
tj.instance();
|
||||
|
||||
@ -53,9 +53,9 @@ Ref<VoxelChunk> VoxelWorldCubic::_create_chunk(int x, int y, int z, Ref<VoxelChu
|
||||
tj->add_mesher(m);
|
||||
//add_liquid_mesher(Ref<VoxelMesher>(memnew(VoxelMesherLiquidMarchingCubes())));
|
||||
|
||||
chunk->add_job(lj);
|
||||
chunk->add_job(tj);
|
||||
chunk->add_job(pj);
|
||||
chunk->job_add(lj);
|
||||
chunk->job_add(tj);
|
||||
chunk->job_add(pj);
|
||||
}
|
||||
|
||||
return VoxelWorld::_create_chunk(x, y, z, chunk);
|
||||
|
@ -177,7 +177,7 @@ Ref<VoxelChunk> VoxelWorldDefault::_create_chunk(int x, int y, int z, Ref<VoxelC
|
||||
chunk = Ref<VoxelChunk>(memnew(VoxelChunkDefault));
|
||||
}
|
||||
|
||||
if (chunk->get_job_count() == 0) {
|
||||
if (chunk->job_get_count() == 0) {
|
||||
Ref<VoxelTerrarinJob> tj;
|
||||
tj.instance();
|
||||
|
||||
@ -188,9 +188,9 @@ Ref<VoxelChunk> VoxelWorldDefault::_create_chunk(int x, int y, int z, Ref<VoxelC
|
||||
pj.instance();
|
||||
pj->set_prop_mesher(Ref<VoxelMesher>(memnew(VoxelMesherDefault)));
|
||||
|
||||
chunk->add_job(lj);
|
||||
chunk->add_job(tj);
|
||||
chunk->add_job(pj);
|
||||
chunk->job_add(lj);
|
||||
chunk->job_add(tj);
|
||||
chunk->job_add(pj);
|
||||
}
|
||||
|
||||
Ref<VoxelChunkDefault> vcd = chunk;
|
||||
|
@ -59,7 +59,7 @@ void VoxelJob::set_build_done(const bool val) {
|
||||
}
|
||||
|
||||
void VoxelJob::next_job() {
|
||||
_chunk->next_job();
|
||||
_chunk->job_next();
|
||||
set_build_done(true);
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ Ref<VoxelChunk> VoxelWorldMarchingCubes::_create_chunk(int x, int y, int z, Ref<
|
||||
chunk = Ref<VoxelChunk>(memnew(VoxelChunkMarchingCubes));
|
||||
}
|
||||
|
||||
if (chunk->get_job_count() == 0) {
|
||||
if (chunk->job_get_count() == 0) {
|
||||
Ref<VoxelTerrarinJob> tj;
|
||||
tj.instance();
|
||||
|
||||
@ -52,9 +52,9 @@ Ref<VoxelChunk> VoxelWorldMarchingCubes::_create_chunk(int x, int y, int z, Ref<
|
||||
tj->add_mesher(m);
|
||||
//add_liquid_mesher(Ref<VoxelMesher>(memnew(VoxelMesherLiquidMarchingCubes())));
|
||||
|
||||
chunk->add_job(lj);
|
||||
chunk->add_job(tj);
|
||||
chunk->add_job(pj);
|
||||
chunk->job_add(lj);
|
||||
chunk->job_add(tj);
|
||||
chunk->job_add(pj);
|
||||
}
|
||||
|
||||
return VoxelWorld::_create_chunk(x, y, z, chunk);
|
||||
|
@ -217,32 +217,32 @@ void VoxelChunk::set_voxel_world_bind(Node *world) {
|
||||
_voxel_world = Object::cast_to<VoxelWorld>(world);
|
||||
}
|
||||
|
||||
Ref<VoxelJob> VoxelChunk::get_job(int index) const {
|
||||
Ref<VoxelJob> VoxelChunk::job_get(int index) const {
|
||||
ERR_FAIL_INDEX_V(index, _jobs.size(), Ref<VoxelJob>());
|
||||
|
||||
return _jobs.get(index);
|
||||
}
|
||||
void VoxelChunk::set_job(int index, const Ref<VoxelJob> &job) {
|
||||
void VoxelChunk::job_set(int index, const Ref<VoxelJob> &job) {
|
||||
ERR_FAIL_INDEX(index, _jobs.size());
|
||||
|
||||
_jobs.set(index, job);
|
||||
}
|
||||
void VoxelChunk::remove_job(const int index) {
|
||||
void VoxelChunk::job_remove(const int index) {
|
||||
ERR_FAIL_INDEX(index, _jobs.size());
|
||||
|
||||
_jobs.remove(index);
|
||||
}
|
||||
void VoxelChunk::add_job(const Ref<VoxelJob> &job) {
|
||||
void VoxelChunk::job_add(const Ref<VoxelJob> &job) {
|
||||
_jobs.push_back(job);
|
||||
}
|
||||
int VoxelChunk::get_job_count() const {
|
||||
int VoxelChunk::job_get_count() const {
|
||||
return _jobs.size();
|
||||
}
|
||||
|
||||
int VoxelChunk::get_current_job_index() {
|
||||
int VoxelChunk::job_get_current_index() {
|
||||
return _current_job;
|
||||
}
|
||||
void VoxelChunk::next_job() {
|
||||
void VoxelChunk::job_next() {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
++_current_job;
|
||||
@ -258,7 +258,7 @@ void VoxelChunk::next_job() {
|
||||
|
||||
if (!j.is_valid()) {
|
||||
//skip if invalid
|
||||
next_job();
|
||||
job_next();
|
||||
}
|
||||
|
||||
j->reset();
|
||||
@ -272,7 +272,7 @@ void VoxelChunk::next_job() {
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Ref<VoxelJob> VoxelChunk::get_current_job() {
|
||||
Ref<VoxelJob> VoxelChunk::job_get_current() {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
if (_current_job < 0 || _current_job >= _jobs.size()) {
|
||||
@ -636,7 +636,7 @@ void VoxelChunk::_build() {
|
||||
|
||||
_is_generating = true;
|
||||
|
||||
next_job();
|
||||
job_next();
|
||||
}
|
||||
|
||||
void VoxelChunk::clear() {
|
||||
@ -1318,15 +1318,15 @@ void VoxelChunk::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_voxel_scale", "value"), &VoxelChunk::set_voxel_scale);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "voxel_scale"), "set_voxel_scale", "get_voxel_scale");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_job", "index"), &VoxelChunk::get_job);
|
||||
ClassDB::bind_method(D_METHOD("set_job", "index", "job"), &VoxelChunk::set_job);
|
||||
ClassDB::bind_method(D_METHOD("remove_job", "index"), &VoxelChunk::remove_job);
|
||||
ClassDB::bind_method(D_METHOD("add_job", "job"), &VoxelChunk::add_job);
|
||||
ClassDB::bind_method(D_METHOD("get_job_count"), &VoxelChunk::get_job_count);
|
||||
ClassDB::bind_method(D_METHOD("job_get", "index"), &VoxelChunk::job_get);
|
||||
ClassDB::bind_method(D_METHOD("job_set", "index", "job"), &VoxelChunk::job_set);
|
||||
ClassDB::bind_method(D_METHOD("job_remove", "index"), &VoxelChunk::job_remove);
|
||||
ClassDB::bind_method(D_METHOD("job_add", "job"), &VoxelChunk::job_add);
|
||||
ClassDB::bind_method(D_METHOD("job_get_count"), &VoxelChunk::job_get_count);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_current_job_index"), &VoxelChunk::get_current_job_index);
|
||||
ClassDB::bind_method(D_METHOD("next_job"), &VoxelChunk::next_job);
|
||||
ClassDB::bind_method(D_METHOD("get_current_job"), &VoxelChunk::get_current_job);
|
||||
ClassDB::bind_method(D_METHOD("job_get_current_index"), &VoxelChunk::job_get_current_index);
|
||||
ClassDB::bind_method(D_METHOD("job_next"), &VoxelChunk::job_next);
|
||||
ClassDB::bind_method(D_METHOD("job_get_current"), &VoxelChunk::job_get_current);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_voxel_world"), &VoxelChunk::get_voxel_world);
|
||||
ClassDB::bind_method(D_METHOD("set_voxel_world", "world"), &VoxelChunk::set_voxel_world_bind);
|
||||
|
@ -144,15 +144,15 @@ public:
|
||||
void set_voxel_world_bind(Node *world);
|
||||
|
||||
//Jobs
|
||||
Ref<VoxelJob> get_job(const int index) const;
|
||||
void set_job(const int index, const Ref<VoxelJob> &job);
|
||||
void remove_job(const int index);
|
||||
void add_job(const Ref<VoxelJob> &job);
|
||||
int get_job_count() const;
|
||||
Ref<VoxelJob> job_get(const int index) const;
|
||||
void job_set(const int index, const Ref<VoxelJob> &job);
|
||||
void job_remove(const int index);
|
||||
void job_add(const Ref<VoxelJob> &job);
|
||||
int job_get_count() const;
|
||||
|
||||
int get_current_job_index();
|
||||
void next_job();
|
||||
Ref<VoxelJob> get_current_job();
|
||||
int job_get_current_index();
|
||||
void job_next();
|
||||
Ref<VoxelJob> job_get_current();
|
||||
|
||||
//Channels
|
||||
void setup_channels();
|
||||
|
Loading…
Reference in New Issue
Block a user