Removed job steps, as 2d will not need lods.

This commit is contained in:
Relintai 2022-02-22 14:19:31 +01:00
parent e74b23b8de
commit 3a8ca20448
10 changed files with 13 additions and 836 deletions

1
SCsub
View File

@ -64,7 +64,6 @@ sources = [
"world/jobs/terrain_2d_job.cpp", "world/jobs/terrain_2d_job.cpp",
"world/jobs/terrain_2d_terrain_job.cpp", "world/jobs/terrain_2d_terrain_job.cpp",
"world/jobs/terrain_2d_mesher_job_step.cpp",
"world/jobs/terrain_2d_light_job.cpp", "world/jobs/terrain_2d_light_job.cpp",
"world/jobs/terrain_2d_prop_job.cpp", "world/jobs/terrain_2d_prop_job.cpp",
] ]

View File

@ -64,7 +64,6 @@ SOFTWARE.
#include "world/jobs/terrain_2d_job.h" #include "world/jobs/terrain_2d_job.h"
#include "world/jobs/terrain_2d_light_job.h" #include "world/jobs/terrain_2d_light_job.h"
#include "world/jobs/terrain_2d_mesher_job_step.h"
#include "world/jobs/terrain_2d_prop_job.h" #include "world/jobs/terrain_2d_prop_job.h"
#include "world/jobs/terrain_2d_terrain_job.h" #include "world/jobs/terrain_2d_terrain_job.h"
@ -110,7 +109,6 @@ void register_terraman_2d_types() {
ClassDB::register_class<Terrain2DJob>(); ClassDB::register_class<Terrain2DJob>();
ClassDB::register_class<Terrain2DTerrain2DJob>(); ClassDB::register_class<Terrain2DTerrain2DJob>();
ClassDB::register_class<Terrain2DMesherJobStep>();
ClassDB::register_class<Terrain2DLightJob>(); ClassDB::register_class<Terrain2DLightJob>();
ClassDB::register_class<Terrain2DProp2DJob>(); ClassDB::register_class<Terrain2DProp2DJob>();

View File

@ -41,29 +41,6 @@ Ref<Terrain2DChunk> Terrain2DWorldBlocky::_create_chunk(int x, int z, Ref<Terrai
Ref<Terrain2DLightJob> lj; Ref<Terrain2DLightJob> lj;
lj.instance(); lj.instance();
Ref<Terrain2DMesherJobStep> s;
s.instance();
s->set_job_type(Terrain2DMesherJobStep::TYPE_NORMAL);
tj->add_jobs_step(s);
s.instance();
s->set_job_type(Terrain2DMesherJobStep::TYPE_NORMAL_LOD);
s->set_lod_index(1);
tj->add_jobs_step(s);
s.instance();
s->set_job_type(Terrain2DMesherJobStep::TYPE_NORMAL_LOD);
s->set_lod_index(2);
tj->add_jobs_step(s);
s.instance();
s->set_job_type(Terrain2DMesherJobStep::TYPE_MERGE_VERTS);
tj->add_jobs_step(s);
s.instance();
s->set_job_type(Terrain2DMesherJobStep::TYPE_BAKE_TEXTURE);
tj->add_jobs_step(s);
tj->set_mesher(Ref<Terrain2DMesher>(memnew(Terrain2DMesherBlocky()))); tj->set_mesher(Ref<Terrain2DMesher>(memnew(Terrain2DMesherBlocky())));
Ref<Terrain2DMesherBlocky> liquid_mesher; Ref<Terrain2DMesherBlocky> liquid_mesher;
@ -76,28 +53,6 @@ Ref<Terrain2DChunk> Terrain2DWorldBlocky::_create_chunk(int x, int z, Ref<Terrai
pj.instance(); pj.instance();
pj->set_prop_mesher(Ref<Terrain2DMesher>(memnew(Terrain2DMesherBlocky))); pj->set_prop_mesher(Ref<Terrain2DMesher>(memnew(Terrain2DMesherBlocky)));
s.instance();
s->set_job_type(Terrain2DMesherJobStep::TYPE_NORMAL);
pj->add_jobs_step(s);
s.instance();
s->set_job_type(Terrain2DMesherJobStep::TYPE_MERGE_VERTS);
pj->add_jobs_step(s);
s.instance();
s->set_job_type(Terrain2DMesherJobStep::TYPE_BAKE_TEXTURE);
pj->add_jobs_step(s);
s.instance();
s->set_job_type(Terrain2DMesherJobStep::TYPE_SIMPLIFY_MESH);
#ifdef MESH_UTILS_PRESENT
Ref<FastQuadraticMeshSimplifier> fqms;
fqms.instance();
s->set_fqms(fqms);
s->set_simplification_steps(2);
#endif
pj->add_jobs_step(s);
chunk->job_add(lj); chunk->job_add(lj);
chunk->job_add(tj); chunk->job_add(tj);
chunk->job_add(pj); chunk->job_add(pj);

View File

@ -191,29 +191,6 @@ Ref<Terrain2DChunk> Terrain2DWorldDefault::_create_chunk(int x, int z, Ref<Terra
pj.instance(); pj.instance();
pj->set_prop_mesher(Ref<Terrain2DMesher>(memnew(Terrain2DMesherDefault))); pj->set_prop_mesher(Ref<Terrain2DMesher>(memnew(Terrain2DMesherDefault)));
Ref<Terrain2DMesherJobStep> s;
s.instance();
s->set_job_type(Terrain2DMesherJobStep::TYPE_NORMAL);
tj->add_jobs_step(s);
s.instance();
s->set_job_type(Terrain2DMesherJobStep::TYPE_NORMAL_LOD);
s->set_lod_index(1);
tj->add_jobs_step(s);
s.instance();
s->set_job_type(Terrain2DMesherJobStep::TYPE_NORMAL_LOD);
s->set_lod_index(2);
tj->add_jobs_step(s);
s.instance();
s->set_job_type(Terrain2DMesherJobStep::TYPE_MERGE_VERTS);
tj->add_jobs_step(s);
s.instance();
s->set_job_type(Terrain2DMesherJobStep::TYPE_BAKE_TEXTURE);
tj->add_jobs_step(s);
chunk->job_add(lj); chunk->job_add(lj);
chunk->job_add(tj); chunk->job_add(tj);
chunk->job_add(pj); chunk->job_add(pj);

View File

@ -1,123 +0,0 @@
/*
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "terrain_2d_mesher_job_step.h"
const String Terrain2DMesherJobStep::BINDING_STRING_TERRAIN_2D_TERRAIN_2D_JOB_STEP_TYPE = "Normal,Normal LOD,Drop UV2,Merge Verts,Bake Texture,Simplify Mesh";
Terrain2DMesherJobStep::Terrain2DMesherJobStepType Terrain2DMesherJobStep::get_job_type() const {
return _job_type;
}
void Terrain2DMesherJobStep::set_job_type(const Terrain2DMesherJobStep::Terrain2DMesherJobStepType value) {
_job_type = value;
}
int Terrain2DMesherJobStep::get_lod_index() const {
return _lod_index;
}
void Terrain2DMesherJobStep::set_lod_index(const int value) {
_lod_index = value;
}
#ifdef MESH_UTILS_PRESENT
Ref<FastQuadraticMeshSimplifier> Terrain2DMesherJobStep::get_fqms() {
return _fqms;
}
void Terrain2DMesherJobStep::set_fqms(const Ref<FastQuadraticMeshSimplifier> &val) {
_fqms = val;
}
float Terrain2DMesherJobStep::get_simplification_step_ratio() const {
return _simplification_step_ratio;
}
void Terrain2DMesherJobStep::set_simplification_step_ratio(const float value) {
_simplification_step_ratio = value;
}
int Terrain2DMesherJobStep::get_simplification_steps() const {
return _simplification_steps;
}
void Terrain2DMesherJobStep::set_simplification_steps(const int value) {
_simplification_steps = value;
}
float Terrain2DMesherJobStep::get_simplification_agressiveness() const {
return _simplification_agressiveness;
}
void Terrain2DMesherJobStep::set_simplification_agressiveness(const float value) {
_simplification_agressiveness = value;
}
#endif
Terrain2DMesherJobStep::Terrain2DMesherJobStep() {
_job_type = TYPE_NORMAL;
_lod_index = 0;
#ifdef MESH_UTILS_PRESENT
_simplification_step_ratio = 0.8;
_simplification_steps = 2;
_simplification_agressiveness = 7;
#endif
}
Terrain2DMesherJobStep::~Terrain2DMesherJobStep() {
#ifdef MESH_UTILS_PRESENT
_fqms.unref();
#endif
}
void Terrain2DMesherJobStep::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_job_type"), &Terrain2DMesherJobStep::get_job_type);
ClassDB::bind_method(D_METHOD("set_job_type", "value"), &Terrain2DMesherJobStep::set_job_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "job_type", PROPERTY_HINT_ENUM, Terrain2DMesherJobStep::BINDING_STRING_TERRAIN_2D_TERRAIN_2D_JOB_STEP_TYPE), "set_job_type", "get_job_type");
ClassDB::bind_method(D_METHOD("get_lod_index"), &Terrain2DMesherJobStep::get_lod_index);
ClassDB::bind_method(D_METHOD("set_lod_index", "value"), &Terrain2DMesherJobStep::set_lod_index);
ADD_PROPERTY(PropertyInfo(Variant::INT, "lod_index"), "set_lod_index", "get_lod_index");
#ifdef MESH_UTILS_PRESENT
ClassDB::bind_method(D_METHOD("get_fqms"), &Terrain2DMesherJobStep::get_fqms);
ClassDB::bind_method(D_METHOD("set_fqms", "value"), &Terrain2DMesherJobStep::set_fqms);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "fqms", PROPERTY_HINT_RESOURCE_TYPE, "FastQuadraticMeshSimplifier"), "set_fqms", "get_fqms");
ClassDB::bind_method(D_METHOD("get_simplification_step_ratio"), &Terrain2DMesherJobStep::get_simplification_step_ratio);
ClassDB::bind_method(D_METHOD("set_simplification_step_ratio", "value"), &Terrain2DMesherJobStep::set_simplification_step_ratio);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "simplification_step_ratio"), "set_simplification_step_ratio", "get_simplification_step_ratio");
ClassDB::bind_method(D_METHOD("get_simplification_steps"), &Terrain2DMesherJobStep::get_simplification_steps);
ClassDB::bind_method(D_METHOD("set_simplification_steps", "value"), &Terrain2DMesherJobStep::set_simplification_steps);
ADD_PROPERTY(PropertyInfo(Variant::INT, "simplification_steps"), "set_simplification_steps", "get_simplification_steps");
ClassDB::bind_method(D_METHOD("get_simplification_agressiveness"), &Terrain2DMesherJobStep::get_simplification_agressiveness);
ClassDB::bind_method(D_METHOD("set_simplification_agressiveness", "value"), &Terrain2DMesherJobStep::set_simplification_agressiveness);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "simplification_agressiveness"), "set_simplification_agressiveness", "get_simplification_agressiveness");
#endif
BIND_ENUM_CONSTANT(TYPE_NORMAL);
BIND_ENUM_CONSTANT(TYPE_NORMAL_LOD);
BIND_ENUM_CONSTANT(TYPE_DROP_UV2);
BIND_ENUM_CONSTANT(TYPE_MERGE_VERTS);
BIND_ENUM_CONSTANT(TYPE_BAKE_TEXTURE);
BIND_ENUM_CONSTANT(TYPE_SIMPLIFY_MESH);
BIND_ENUM_CONSTANT(TYPE_OTHER);
}

View File

@ -1,100 +0,0 @@
/*
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef TERRAIN_2D_TERRAIN_2D_JOB_STEP_H
#define TERRAIN_2D_TERRAIN_2D_JOB_STEP_H
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/object/ref_counted.h"
#ifndef Reference
#define Reference RefCounted
#endif
#else
#include "core/reference.h"
#endif
#ifdef MESH_UTILS_PRESENT
#include "../../../mesh_utils/fast_quadratic_mesh_simplifier.h"
#endif
class Terrain2DMesherJobStep : public Reference {
GDCLASS(Terrain2DMesherJobStep, Reference);
public:
//todo add:
//type generate lighting,
//type skip (this would leave the mesh empty)
//type previous mesh (this would set the previous mesh's rid to the current lod level)
enum Terrain2DMesherJobStepType {
TYPE_NORMAL = 0,
TYPE_NORMAL_LOD,
TYPE_DROP_UV2,
TYPE_MERGE_VERTS,
TYPE_BAKE_TEXTURE,
TYPE_SIMPLIFY_MESH,
TYPE_OTHER,
};
static const String BINDING_STRING_TERRAIN_2D_TERRAIN_2D_JOB_STEP_TYPE;
Terrain2DMesherJobStepType get_job_type() const;
void set_job_type(const Terrain2DMesherJobStepType value);
int get_lod_index() const;
void set_lod_index(const int value);
#ifdef MESH_UTILS_PRESENT
Ref<FastQuadraticMeshSimplifier> get_fqms();
void set_fqms(const Ref<FastQuadraticMeshSimplifier> &val);
float get_simplification_step_ratio() const;
void set_simplification_step_ratio(const float value);
int get_simplification_steps() const;
void set_simplification_steps(const int value);
float get_simplification_agressiveness() const;
void set_simplification_agressiveness(const float value);
#endif
Terrain2DMesherJobStep();
~Terrain2DMesherJobStep();
protected:
static void _bind_methods();
Terrain2DMesherJobStepType _job_type;
int _lod_index;
#ifdef MESH_UTILS_PRESENT
Ref<FastQuadraticMeshSimplifier> _fqms;
float _simplification_step_ratio;
int _simplification_steps;
float _simplification_agressiveness;
#endif
};
VARIANT_ENUM_CAST(Terrain2DMesherJobStep::Terrain2DMesherJobStepType);
#endif

View File

@ -24,9 +24,9 @@ SOFTWARE.
#include "../../defines.h" #include "../../defines.h"
#include "../../library/terrain_2d_library.h"
#include "../../library/terrain_2d_material_cache.h" #include "../../library/terrain_2d_material_cache.h"
#include "../../library/terrain_2d_surface.h" #include "../../library/terrain_2d_surface.h"
#include "../../library/terrain_2d_library.h"
#include "../../meshers/default/terrain_2d_mesher_default.h" #include "../../meshers/default/terrain_2d_mesher_default.h"
#include "../../meshers/terrain_2d_mesher.h" #include "../../meshers/terrain_2d_mesher.h"
@ -49,28 +49,6 @@ void Terrain2DProp2DJob::set_prop_mesher(const Ref<Terrain2DMesher> &mesher) {
_prop_mesher = mesher; _prop_mesher = mesher;
} }
Ref<Terrain2DMesherJobStep> Terrain2DProp2DJob::get_jobs_step(int index) const {
ERR_FAIL_INDEX_V(index, _job_steps.size(), Ref<Terrain2DMesherJobStep>());
return _job_steps.get(index);
}
void Terrain2DProp2DJob::set_jobs_step(int index, const Ref<Terrain2DMesherJobStep> &step) {
ERR_FAIL_INDEX(index, _job_steps.size());
_job_steps.set(index, step);
}
void Terrain2DProp2DJob::remove_jobs_step(const int index) {
ERR_FAIL_INDEX(index, _job_steps.size());
_job_steps.remove(index);
}
void Terrain2DProp2DJob::add_jobs_step(const Ref<Terrain2DMesherJobStep> &step) {
_job_steps.push_back(step);
}
int Terrain2DProp2DJob::get_jobs_step_count() const {
return _job_steps.size();
}
void Terrain2DProp2DJob::phase_physics_process() { void Terrain2DProp2DJob::phase_physics_process() {
Ref<Terrain2DChunkDefault> chunk = _chunk; Ref<Terrain2DChunkDefault> chunk = _chunk;
@ -259,9 +237,6 @@ void Terrain2DProp2DJob::_reset() {
_build_done = false; _build_done = false;
_phase = 0; _phase = 0;
_current_job_step = 0;
_current_mesh = 0;
if (get_prop_mesher().is_valid()) { if (get_prop_mesher().is_valid()) {
get_prop_mesher()->reset(); get_prop_mesher()->reset();
get_prop_mesher()->set_library(_chunk->get_library()); get_prop_mesher()->set_library(_chunk->get_library());
@ -300,7 +275,7 @@ void Terrain2DProp2DJob::phase_setup() {
#if MESH_DATA_RESOURCE_PRESENT #if MESH_DATA_RESOURCE_PRESENT
for (int i = 0; i < _chunk->mesh_data_resource_get_count(); ++i) { for (int i = 0; i < _chunk->mesh_data_resource_get_count(); ++i) {
Ref<Texture> tex = _chunk->mesh_data_resource_get_texture(i); Ref<Texture> tex = _chunk->mesh_data_resource_get_texture(i);
if (!tex.is_valid()) if (!tex.is_valid())
continue; continue;
@ -344,42 +319,8 @@ void Terrain2DProp2DJob::phase_steps() {
if (mesh_rid == RID()) { if (mesh_rid == RID()) {
//need to allocate the meshes //need to allocate the meshes
//first count how many we need
int count = 0;
for (int i = 0; i < _job_steps.size(); ++i) {
Ref<Terrain2DMesherJobStep> step = _job_steps[i];
ERR_FAIL_COND(!step.is_valid());
switch (step->get_job_type()) {
case Terrain2DMesherJobStep::TYPE_NORMAL:
++count;
break;
case Terrain2DMesherJobStep::TYPE_NORMAL_LOD:
++count;
break;
case Terrain2DMesherJobStep::TYPE_DROP_UV2:
++count;
break;
case Terrain2DMesherJobStep::TYPE_MERGE_VERTS:
++count;
break;
case Terrain2DMesherJobStep::TYPE_BAKE_TEXTURE:
++count;
break;
case Terrain2DMesherJobStep::TYPE_SIMPLIFY_MESH:
#ifdef MESH_UTILS_PRESENT
count += step->get_simplification_steps();
#endif
break;
default:
break;
}
}
//allocate //allocate
if (count > 0) chunk->meshes_create(Terrain2DChunkDefault::MESH_INDEX_PROP, 1);
chunk->meshes_create(Terrain2DChunkDefault::MESH_INDEX_PROP, count);
} else { } else {
//we have the meshes, just clear //we have the meshes, just clear
@ -398,41 +339,7 @@ void Terrain2DProp2DJob::phase_steps() {
} }
} }
for (; _current_job_step < _job_steps.size();) { step_type_normal();
Ref<Terrain2DMesherJobStep> step = _job_steps[_current_job_step];
ERR_FAIL_COND(!step.is_valid());
switch (step->get_job_type()) {
case Terrain2DMesherJobStep::TYPE_NORMAL:
step_type_normal();
break;
case Terrain2DMesherJobStep::TYPE_NORMAL_LOD:
step_type_normal_lod();
break;
case Terrain2DMesherJobStep::TYPE_DROP_UV2:
step_type_drop_uv2();
break;
case Terrain2DMesherJobStep::TYPE_MERGE_VERTS:
step_type_merge_verts();
break;
case Terrain2DMesherJobStep::TYPE_BAKE_TEXTURE:
step_type_bake_texture();
break;
case Terrain2DMesherJobStep::TYPE_SIMPLIFY_MESH:
step_type_simplify_mesh();
break;
case Terrain2DMesherJobStep::TYPE_OTHER:
//do nothing
break;
}
++_current_job_step;
if (should_return()) {
return;
}
}
reset_stages(); reset_stages();
//next_phase(); //next_phase();
@ -448,158 +355,25 @@ void Terrain2DProp2DJob::step_type_normal() {
temp_mesh_arr = _prop_mesher->build_mesh(); temp_mesh_arr = _prop_mesher->build_mesh();
RID mesh_rid = chunk->mesh_rid_get_index(Terrain2DChunkDefault::MESH_INDEX_PROP, Terrain2DChunkDefault::MESH_TYPE_INDEX_MESH, _current_mesh); RID mesh_rid = chunk->mesh_rid_get_index(Terrain2DChunkDefault::MESH_INDEX_PROP, Terrain2DChunkDefault::MESH_TYPE_INDEX_MESH, 0);
VS::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr); VS::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
Ref<Material> lmat; Ref<Material> lmat;
if (chunk->prop_material_cache_key_has()) { if (chunk->prop_material_cache_key_has()) {
lmat = chunk->get_library()->prop_material_cache_get(_chunk->prop_material_cache_key_get())->material_lod_get(_current_mesh); lmat = chunk->get_library()->prop_material_cache_get(_chunk->prop_material_cache_key_get())->material_lod_get(0);
} else { } else {
lmat = chunk->get_library()->prop_material_lod_get(_current_mesh); lmat = chunk->get_library()->prop_material_lod_get(0);
} }
if (lmat.is_valid()) { if (lmat.is_valid()) {
VisualServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid()); VisualServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
} }
++_current_mesh;
}
void Terrain2DProp2DJob::step_type_normal_lod() {
print_error("Error: step_type_normal_lod doesn't work for Terrain2DProp2DJobs!");
++_current_mesh;
}
void Terrain2DProp2DJob::step_type_drop_uv2() {
Ref<Terrain2DChunkDefault> chunk = _chunk;
RID mesh_rid = chunk->mesh_rid_get_index(Terrain2DChunkDefault::MESH_INDEX_PROP, Terrain2DChunkDefault::MESH_TYPE_INDEX_MESH, _current_mesh);
temp_mesh_arr[VisualServer::ARRAY_TEX_UV2] = Variant();
VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
Ref<Material> lmat;
if (chunk->prop_material_cache_key_has()) {
lmat = chunk->get_library()->prop_material_cache_get(_chunk->prop_material_cache_key_get())->material_lod_get(_current_mesh);
} else {
lmat = chunk->get_library()->prop_material_lod_get(_current_mesh);
}
if (lmat.is_valid()) {
VisualServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
}
++_current_mesh;
}
void Terrain2DProp2DJob::step_type_merge_verts() {
Array temp_mesh_arr2 = merge_mesh_array(temp_mesh_arr);
temp_mesh_arr = temp_mesh_arr2;
Ref<Terrain2DChunkDefault> chunk = _chunk;
RID mesh_rid = chunk->mesh_rid_get_index(Terrain2DChunkDefault::MESH_INDEX_PROP, Terrain2DChunkDefault::MESH_TYPE_INDEX_MESH, _current_mesh);
VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
Ref<Material> lmat;
if (chunk->prop_material_cache_key_has()) {
lmat = chunk->get_library()->prop_material_cache_get(_chunk->prop_material_cache_key_get())->material_lod_get(_current_mesh);
} else {
lmat = chunk->get_library()->prop_material_lod_get(_current_mesh);
}
if (lmat.is_valid()) {
VisualServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
}
++_current_mesh;
}
void Terrain2DProp2DJob::step_type_bake_texture() {
Ref<Terrain2DChunkDefault> chunk = _chunk;
Ref<ShaderMaterial> mat = chunk->get_library()->material_lod_get(0);
Ref<SpatialMaterial> spmat = chunk->get_library()->material_lod_get(0);
Ref<Texture> tex;
if (mat.is_valid()) {
tex = mat->get_shader_param("texture_albedo");
} else if (spmat.is_valid()) {
tex = spmat->get_texture(SpatialMaterial::TEXTURE_ALBEDO);
}
if (tex.is_valid()) {
temp_mesh_arr = bake_mesh_array_uv(temp_mesh_arr, tex);
temp_mesh_arr[VisualServer::ARRAY_TEX_UV] = Variant();
RID mesh_rid = chunk->mesh_rid_get_index(Terrain2DChunkDefault::MESH_INDEX_PROP, Terrain2DChunkDefault::MESH_TYPE_INDEX_MESH, _current_mesh);
VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
Ref<Material> lmat;
if (chunk->prop_material_cache_key_has()) {
lmat = chunk->get_library()->prop_material_cache_get(_chunk->prop_material_cache_key_get())->material_lod_get(_current_mesh);
} else {
lmat = chunk->get_library()->prop_material_lod_get(_current_mesh);
}
if (lmat.is_valid()) {
VisualServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
}
}
++_current_mesh;
}
void Terrain2DProp2DJob::step_type_simplify_mesh() {
#ifdef MESH_UTILS_PRESENT
Ref<Terrain2DChunkDefault> chunk = _chunk;
Ref<Terrain2DMesherJobStep> step = _job_steps[_current_job_step];
ERR_FAIL_COND(!step.is_valid());
Ref<FastQuadraticMeshSimplifier> fqms = step->get_fqms();
ERR_FAIL_COND(!fqms.is_valid());
fqms->initialize(temp_mesh_arr);
for (int i = 0; i < step->get_simplification_steps(); ++i) {
fqms->simplify_mesh(temp_mesh_arr.size() * step->get_simplification_step_ratio(), step->get_simplification_agressiveness());
temp_mesh_arr = fqms->get_arrays();
RID mesh_rid = chunk->mesh_rid_get_index(Terrain2DChunkDefault::MESH_INDEX_PROP, Terrain2DChunkDefault::MESH_TYPE_INDEX_MESH, _current_mesh);
VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
Ref<Material> lmat;
if (chunk->prop_material_cache_key_has()) {
lmat = chunk->get_library()->prop_material_cache_get(_chunk->prop_material_cache_key_get())->material_lod_get(_current_mesh);
} else {
lmat = chunk->get_library()->prop_material_lod_get(_current_mesh);
}
if (lmat.is_valid()) {
VisualServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
}
++_current_mesh;
}
#endif
} }
Terrain2DProp2DJob::Terrain2DProp2DJob() { Terrain2DProp2DJob::Terrain2DProp2DJob() {
set_build_phase_type(BUILD_PHASE_TYPE_PHYSICS_PROCESS); set_build_phase_type(BUILD_PHASE_TYPE_PHYSICS_PROCESS);
_current_job_step = 0;
_current_mesh = 0;
} }
Terrain2DProp2DJob::~Terrain2DProp2DJob() { Terrain2DProp2DJob::~Terrain2DProp2DJob() {
@ -610,11 +384,5 @@ void Terrain2DProp2DJob::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_prop_mesher", "mesher"), &Terrain2DProp2DJob::set_prop_mesher); ClassDB::bind_method(D_METHOD("set_prop_mesher", "mesher"), &Terrain2DProp2DJob::set_prop_mesher);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_mesher", PROPERTY_HINT_RESOURCE_TYPE, "Terrain2DMesher", 0), "set_prop_mesher", "get_prop_mesher"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_mesher", PROPERTY_HINT_RESOURCE_TYPE, "Terrain2DMesher", 0), "set_prop_mesher", "get_prop_mesher");
ClassDB::bind_method(D_METHOD("get_jobs_step", "index"), &Terrain2DProp2DJob::get_jobs_step);
ClassDB::bind_method(D_METHOD("set_jobs_step", "index", "mesher"), &Terrain2DProp2DJob::set_jobs_step);
ClassDB::bind_method(D_METHOD("remove_jobs_step", "index"), &Terrain2DProp2DJob::remove_jobs_step);
ClassDB::bind_method(D_METHOD("add_jobs_step", "mesher"), &Terrain2DProp2DJob::add_jobs_step);
ClassDB::bind_method(D_METHOD("get_jobs_step_count"), &Terrain2DProp2DJob::get_jobs_step_count);
ClassDB::bind_method(D_METHOD("_physics_process", "delta"), &Terrain2DProp2DJob::_physics_process); ClassDB::bind_method(D_METHOD("_physics_process", "delta"), &Terrain2DProp2DJob::_physics_process);
} }

View File

@ -25,8 +25,6 @@ SOFTWARE.
#include "terrain_2d_job.h" #include "terrain_2d_job.h"
#include "terrain_2d_mesher_job_step.h"
class Terrain2DMesher; class Terrain2DMesher;
class Terrain2DProp2DJob : public Terrain2DJob { class Terrain2DProp2DJob : public Terrain2DJob {
@ -36,12 +34,6 @@ public:
Ref<Terrain2DMesher> get_prop_mesher() const; Ref<Terrain2DMesher> get_prop_mesher() const;
void set_prop_mesher(const Ref<Terrain2DMesher> &mesher); void set_prop_mesher(const Ref<Terrain2DMesher> &mesher);
Ref<Terrain2DMesherJobStep> get_jobs_step(const int index) const;
void set_jobs_step(const int index, const Ref<Terrain2DMesherJobStep> &step);
void remove_jobs_step(const int index);
void add_jobs_step(const Ref<Terrain2DMesherJobStep> &step);
int get_jobs_step_count() const;
void phase_physics_process(); void phase_physics_process();
void phase_prop(); void phase_prop();
@ -54,11 +46,6 @@ public:
void phase_steps(); void phase_steps();
void step_type_normal(); void step_type_normal();
void step_type_normal_lod();
void step_type_drop_uv2();
void step_type_merge_verts();
void step_type_bake_texture();
void step_type_simplify_mesh();
Terrain2DProp2DJob(); Terrain2DProp2DJob();
~Terrain2DProp2DJob(); ~Terrain2DProp2DJob();
@ -68,10 +55,6 @@ protected:
Ref<Terrain2DMesher> _prop_mesher; Ref<Terrain2DMesher> _prop_mesher;
Vector<Ref<Terrain2DMesherJobStep>> _job_steps;
int _current_job_step;
int _current_mesh;
PoolVector<Vector3> temp_arr_collider; PoolVector<Vector3> temp_arr_collider;
Array temp_mesh_arr; Array temp_mesh_arr;
}; };

View File

@ -22,9 +22,9 @@ SOFTWARE.
#include "terrain_2d_terrain_job.h" #include "terrain_2d_terrain_job.h"
#include "../../library/terrain_2d_library.h"
#include "../../library/terrain_2d_material_cache.h" #include "../../library/terrain_2d_material_cache.h"
#include "../../library/terrain_2d_surface.h" #include "../../library/terrain_2d_surface.h"
#include "../../library/terrain_2d_library.h"
#include "../../meshers/default/terrain_2d_mesher_default.h" #include "../../meshers/default/terrain_2d_mesher_default.h"
#include "../../meshers/terrain_2d_mesher.h" #include "../../meshers/terrain_2d_mesher.h"
@ -49,28 +49,6 @@ void Terrain2DTerrain2DJob::set_liquid_mesher(const Ref<Terrain2DMesher> &mesher
_liquid_mesher = mesher; _liquid_mesher = mesher;
} }
Ref<Terrain2DMesherJobStep> Terrain2DTerrain2DJob::get_jobs_step(int index) const {
ERR_FAIL_INDEX_V(index, _job_steps.size(), Ref<Terrain2DMesherJobStep>());
return _job_steps.get(index);
}
void Terrain2DTerrain2DJob::set_jobs_step(int index, const Ref<Terrain2DMesherJobStep> &step) {
ERR_FAIL_INDEX(index, _job_steps.size());
_job_steps.set(index, step);
}
void Terrain2DTerrain2DJob::remove_jobs_step(const int index) {
ERR_FAIL_INDEX(index, _job_steps.size());
_job_steps.remove(index);
}
void Terrain2DTerrain2DJob::add_jobs_step(const Ref<Terrain2DMesherJobStep> &step) {
_job_steps.push_back(step);
}
int Terrain2DTerrain2DJob::get_jobs_step_count() const {
return _job_steps.size();
}
void Terrain2DTerrain2DJob::phase_setup() { void Terrain2DTerrain2DJob::phase_setup() {
if (_mesher.is_valid()) { if (_mesher.is_valid()) {
_mesher->set_library(_chunk->get_library()); _mesher->set_library(_chunk->get_library());
@ -265,43 +243,8 @@ void Terrain2DTerrain2DJob::phase_terrain_mesh() {
if (mesh_rid == RID()) { if (mesh_rid == RID()) {
//need to allocate the meshes //need to allocate the meshes
//first count how many we need
int count = 0;
for (int i = 0; i < _job_steps.size(); ++i) {
Ref<Terrain2DMesherJobStep> step = _job_steps[i];
ERR_FAIL_COND(!step.is_valid());
switch (step->get_job_type()) {
case Terrain2DMesherJobStep::TYPE_NORMAL:
++count;
break;
case Terrain2DMesherJobStep::TYPE_NORMAL_LOD:
++count;
break;
case Terrain2DMesherJobStep::TYPE_DROP_UV2:
++count;
break;
case Terrain2DMesherJobStep::TYPE_MERGE_VERTS:
++count;
break;
case Terrain2DMesherJobStep::TYPE_BAKE_TEXTURE:
++count;
break;
case Terrain2DMesherJobStep::TYPE_SIMPLIFY_MESH:
#ifdef MESH_UTILS_PRESENT
count += step->get_simplification_steps();
#endif
break;
default:
break;
}
}
//allocate //allocate
if (count > 0) chunk->meshes_create(Terrain2DChunkDefault::MESH_INDEX_TERRAIN, 1);
chunk->meshes_create(Terrain2DChunkDefault::MESH_INDEX_TERRAIN, count);
} else { } else {
//we have the meshes, just clear //we have the meshes, just clear
@ -320,41 +263,7 @@ void Terrain2DTerrain2DJob::phase_terrain_mesh() {
} }
} }
for (; _current_job_step < _job_steps.size();) { step_type_normal();
Ref<Terrain2DMesherJobStep> step = _job_steps[_current_job_step];
ERR_FAIL_COND(!step.is_valid());
switch (step->get_job_type()) {
case Terrain2DMesherJobStep::TYPE_NORMAL:
step_type_normal();
break;
case Terrain2DMesherJobStep::TYPE_NORMAL_LOD:
step_type_normal_lod();
break;
case Terrain2DMesherJobStep::TYPE_DROP_UV2:
step_type_drop_uv2();
break;
case Terrain2DMesherJobStep::TYPE_MERGE_VERTS:
step_type_merge_verts();
break;
case Terrain2DMesherJobStep::TYPE_BAKE_TEXTURE:
step_type_bake_texture();
break;
case Terrain2DMesherJobStep::TYPE_SIMPLIFY_MESH:
step_type_simplify_mesh();
break;
case Terrain2DMesherJobStep::TYPE_OTHER:
//do nothing
break;
}
++_current_job_step;
if (should_return()) {
return;
}
}
if (_liquid_mesher.is_valid() && _liquid_mesher->get_vertex_count() != 0) { if (_liquid_mesher.is_valid() && _liquid_mesher->get_vertex_count() != 0) {
if (should_do()) { if (should_do()) {
@ -440,9 +349,6 @@ void Terrain2DTerrain2DJob::_reset() {
_build_done = false; _build_done = false;
_phase = 0; _phase = 0;
_current_job_step = 0;
_current_mesh = 0;
ERR_FAIL_COND(!_mesher.is_valid()); ERR_FAIL_COND(!_mesher.is_valid());
_mesher->set_voxel_scale(_chunk->get_voxel_scale()); _mesher->set_voxel_scale(_chunk->get_voxel_scale());
@ -480,187 +386,24 @@ void Terrain2DTerrain2DJob::step_type_normal() {
temp_mesh_arr = _mesher->build_mesh(); temp_mesh_arr = _mesher->build_mesh();
RID mesh_rid = chunk->mesh_rid_get_index(Terrain2DChunkDefault::MESH_INDEX_TERRAIN, Terrain2DChunkDefault::MESH_TYPE_INDEX_MESH, _current_mesh); RID mesh_rid = chunk->mesh_rid_get_index(Terrain2DChunkDefault::MESH_INDEX_TERRAIN, Terrain2DChunkDefault::MESH_TYPE_INDEX_MESH, 0);
VS::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr); VS::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
Ref<Material> lmat; Ref<Material> lmat;
if (chunk->material_cache_key_has()) { if (chunk->material_cache_key_has()) {
lmat = chunk->get_library()->material_cache_get(_chunk->material_cache_key_get())->material_lod_get(_current_mesh); lmat = chunk->get_library()->material_cache_get(_chunk->material_cache_key_get())->material_lod_get(0);
} else { } else {
lmat = chunk->get_library()->material_lod_get(_current_mesh); lmat = chunk->get_library()->material_lod_get(0);
} }
if (lmat.is_valid()) { if (lmat.is_valid()) {
VisualServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid()); VisualServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
} }
++_current_mesh;
}
void Terrain2DTerrain2DJob::step_type_normal_lod() {
Ref<Terrain2DMesherJobStep> step = _job_steps[_current_job_step];
ERR_FAIL_COND(!step.is_valid());
Ref<Terrain2DChunkDefault> chunk = _chunk;
_mesher->set_lod_index(step->get_lod_index());
_mesher->reset();
_mesher->add_chunk(_chunk);
//TODO make this automatic in build_mesh
if ((chunk->get_build_flags() & Terrain2DChunkDefault::BUILD_FLAG_USE_LIGHTING) != 0) {
_mesher->bake_colors(_chunk);
}
temp_mesh_arr = _mesher->build_mesh();
RID mesh_rid = chunk->mesh_rid_get_index(Terrain2DChunkDefault::MESH_INDEX_TERRAIN, Terrain2DChunkDefault::MESH_TYPE_INDEX_MESH, _current_mesh);
VS::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
Ref<Material> lmat;
if (chunk->material_cache_key_has()) {
lmat = chunk->get_library()->material_cache_get(_chunk->material_cache_key_get())->material_lod_get(_current_mesh);
} else {
lmat = chunk->get_library()->material_lod_get(_current_mesh);
}
if (lmat.is_valid()) {
VisualServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
}
++_current_mesh;
}
void Terrain2DTerrain2DJob::step_type_drop_uv2() {
Ref<Terrain2DChunkDefault> chunk = _chunk;
RID mesh_rid = chunk->mesh_rid_get_index(Terrain2DChunkDefault::MESH_INDEX_TERRAIN, Terrain2DChunkDefault::MESH_TYPE_INDEX_MESH, _current_mesh);
temp_mesh_arr[VisualServer::ARRAY_TEX_UV2] = Variant();
VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
Ref<Material> lmat;
if (chunk->material_cache_key_has()) {
lmat = chunk->get_library()->material_cache_get(_chunk->material_cache_key_get())->material_lod_get(_current_mesh);
} else {
lmat = chunk->get_library()->material_lod_get(_current_mesh);
}
if (lmat.is_valid()) {
VisualServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
}
++_current_mesh;
}
void Terrain2DTerrain2DJob::step_type_merge_verts() {
Array temp_mesh_arr2 = merge_mesh_array(temp_mesh_arr);
temp_mesh_arr = temp_mesh_arr2;
Ref<Terrain2DChunkDefault> chunk = _chunk;
RID mesh_rid = chunk->mesh_rid_get_index(Terrain2DChunkDefault::MESH_INDEX_TERRAIN, Terrain2DChunkDefault::MESH_TYPE_INDEX_MESH, _current_mesh);
VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
Ref<Material> lmat;
if (chunk->material_cache_key_has()) {
lmat = chunk->get_library()->material_cache_get(_chunk->material_cache_key_get())->material_lod_get(_current_mesh);
} else {
lmat = chunk->get_library()->material_lod_get(_current_mesh);
}
if (lmat.is_valid()) {
VisualServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
}
++_current_mesh;
}
void Terrain2DTerrain2DJob::step_type_bake_texture() {
Ref<Terrain2DChunkDefault> chunk = _chunk;
Ref<ShaderMaterial> mat = chunk->get_library()->material_lod_get(0);
Ref<SpatialMaterial> spmat = chunk->get_library()->material_lod_get(0);
Ref<Texture> tex;
if (mat.is_valid()) {
tex = mat->get_shader_param("texture_albedo");
} else if (spmat.is_valid()) {
tex = spmat->get_texture(SpatialMaterial::TEXTURE_ALBEDO);
}
if (tex.is_valid()) {
temp_mesh_arr = bake_mesh_array_uv(temp_mesh_arr, tex);
temp_mesh_arr[VisualServer::ARRAY_TEX_UV] = Variant();
RID mesh_rid = chunk->mesh_rid_get_index(Terrain2DChunkDefault::MESH_INDEX_TERRAIN, Terrain2DChunkDefault::MESH_TYPE_INDEX_MESH, _current_mesh);
VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
Ref<Material> lmat;
if (chunk->material_cache_key_has()) {
lmat = chunk->get_library()->material_cache_get(_chunk->material_cache_key_get())->material_lod_get(_current_mesh);
} else {
lmat = chunk->get_library()->material_lod_get(_current_mesh);
}
if (lmat.is_valid()) {
VisualServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
}
}
++_current_mesh;
}
void Terrain2DTerrain2DJob::step_type_simplify_mesh() {
#ifdef MESH_UTILS_PRESENT
Ref<Terrain2DChunkDefault> chunk = _chunk;
Ref<Terrain2DMesherJobStep> step = _job_steps[_current_job_step];
ERR_FAIL_COND(!step.is_valid());
Ref<FastQuadraticMeshSimplifier> fqms = step->get_fqms();
ERR_FAIL_COND(!fqms.is_valid());
fqms->initialize(temp_mesh_arr);
for (int i = 0; i < step->get_simplification_steps(); ++i) {
fqms->simplify_mesh(temp_mesh_arr.size() * step->get_simplification_step_ratio(), step->get_simplification_agressiveness());
temp_mesh_arr = fqms->get_arrays();
RID mesh_rid = chunk->mesh_rid_get_index(Terrain2DChunkDefault::MESH_INDEX_TERRAIN, Terrain2DChunkDefault::MESH_TYPE_INDEX_MESH, _current_mesh);
VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
Ref<Material> lmat;
if (chunk->material_cache_key_has()) {
lmat = chunk->get_library()->material_cache_get(_chunk->material_cache_key_get())->material_lod_get(_current_mesh);
} else {
lmat = chunk->get_library()->material_lod_get(_current_mesh);
}
if (lmat.is_valid()) {
VisualServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
}
++_current_mesh;
}
#endif
} }
Terrain2DTerrain2DJob::Terrain2DTerrain2DJob() { Terrain2DTerrain2DJob::Terrain2DTerrain2DJob() {
_current_job_step = 0;
_current_mesh = 0;
} }
Terrain2DTerrain2DJob::~Terrain2DTerrain2DJob() { Terrain2DTerrain2DJob::~Terrain2DTerrain2DJob() {
@ -675,11 +418,5 @@ void Terrain2DTerrain2DJob::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_liquid_mesher"), &Terrain2DTerrain2DJob::get_liquid_mesher); ClassDB::bind_method(D_METHOD("get_liquid_mesher"), &Terrain2DTerrain2DJob::get_liquid_mesher);
ClassDB::bind_method(D_METHOD("set_liquid_mesher", "mesher"), &Terrain2DTerrain2DJob::set_liquid_mesher); ClassDB::bind_method(D_METHOD("set_liquid_mesher", "mesher"), &Terrain2DTerrain2DJob::set_liquid_mesher);
ClassDB::bind_method(D_METHOD("get_jobs_step", "index"), &Terrain2DTerrain2DJob::get_jobs_step);
ClassDB::bind_method(D_METHOD("set_jobs_step", "index", "mesher"), &Terrain2DTerrain2DJob::set_jobs_step);
ClassDB::bind_method(D_METHOD("remove_jobs_step", "index"), &Terrain2DTerrain2DJob::remove_jobs_step);
ClassDB::bind_method(D_METHOD("add_jobs_step", "mesher"), &Terrain2DTerrain2DJob::add_jobs_step);
ClassDB::bind_method(D_METHOD("get_jobs_step_count"), &Terrain2DTerrain2DJob::get_jobs_step_count);
ClassDB::bind_method(D_METHOD("_physics_process", "delta"), &Terrain2DTerrain2DJob::_physics_process); ClassDB::bind_method(D_METHOD("_physics_process", "delta"), &Terrain2DTerrain2DJob::_physics_process);
} }

View File

@ -25,8 +25,6 @@ SOFTWARE.
#include "terrain_2d_job.h" #include "terrain_2d_job.h"
#include "terrain_2d_mesher_job_step.h"
#include "../../defines.h" #include "../../defines.h"
#include pool_vector_h #include pool_vector_h
@ -45,12 +43,6 @@ public:
Ref<Terrain2DMesher> get_liquid_mesher() const; Ref<Terrain2DMesher> get_liquid_mesher() const;
void set_liquid_mesher(const Ref<Terrain2DMesher> &mesher); void set_liquid_mesher(const Ref<Terrain2DMesher> &mesher);
Ref<Terrain2DMesherJobStep> get_jobs_step(const int index) const;
void set_jobs_step(const int index, const Ref<Terrain2DMesherJobStep> &step);
void remove_jobs_step(const int index);
void add_jobs_step(const Ref<Terrain2DMesherJobStep> &step);
int get_jobs_step_count() const;
void phase_setup(); void phase_setup();
void phase_library_setup(); void phase_library_setup();
void phase_terrain_mesh_setup(); void phase_terrain_mesh_setup();
@ -65,11 +57,6 @@ public:
void _physics_process(float delta); void _physics_process(float delta);
void step_type_normal(); void step_type_normal();
void step_type_normal_lod();
void step_type_drop_uv2();
void step_type_merge_verts();
void step_type_bake_texture();
void step_type_simplify_mesh();
Terrain2DTerrain2DJob(); Terrain2DTerrain2DJob();
~Terrain2DTerrain2DJob(); ~Terrain2DTerrain2DJob();
@ -80,10 +67,6 @@ protected:
Ref<Terrain2DMesher> _mesher; Ref<Terrain2DMesher> _mesher;
Ref<Terrain2DMesher> _liquid_mesher; Ref<Terrain2DMesher> _liquid_mesher;
Vector<Ref<Terrain2DMesherJobStep> > _job_steps;
int _current_job_step;
int _current_mesh;
PoolVector<Vector3> temp_arr_collider; PoolVector<Vector3> temp_arr_collider;
PoolVector<Vector3> temp_arr_collider_liquid; PoolVector<Vector3> temp_arr_collider_liquid;
Array temp_mesh_arr; Array temp_mesh_arr;