mirror of
https://github.com/Relintai/props_2d.git
synced 2025-02-10 16:40:11 +01:00
Removed job steps, as 2d will not need lods.
This commit is contained in:
parent
1b5d2102bc
commit
bb6f76dbf0
2
SCsub
2
SCsub
@ -61,8 +61,6 @@ sources = [
|
||||
|
||||
"jobs/prop_2d_texture_job.cpp",
|
||||
|
||||
"jobs/prop_2d_mesher_job_step.cpp",
|
||||
|
||||
"material_cache/prop_2d_material_cache.cpp"
|
||||
]
|
||||
|
||||
|
@ -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 "prop_2d_mesher_job_step.h"
|
||||
|
||||
const String Prop2DMesherJobStep::BINDING_STRING_PROP_2D_MESHER_JOB_STEP_TYPE = "Normal,Normal LOD,Drop UV2,Merge Verts,Bake Texture,Simplify Mesh";
|
||||
|
||||
Prop2DMesherJobStep::Prop2DMesherJobStepType Prop2DMesherJobStep::get_job_type() const {
|
||||
return _job_type;
|
||||
}
|
||||
void Prop2DMesherJobStep::set_job_type(const Prop2DMesherJobStep::Prop2DMesherJobStepType value) {
|
||||
_job_type = value;
|
||||
}
|
||||
|
||||
int Prop2DMesherJobStep::get_lod_index() const {
|
||||
return _lod_index;
|
||||
}
|
||||
void Prop2DMesherJobStep::set_lod_index(const int value) {
|
||||
_lod_index = value;
|
||||
}
|
||||
|
||||
#ifdef MESH_UTILS_PRESENT
|
||||
Ref<FastQuadraticMeshSimplifier> Prop2DMesherJobStep::get_fqms() {
|
||||
return _fqms;
|
||||
}
|
||||
void Prop2DMesherJobStep::set_fqms(const Ref<FastQuadraticMeshSimplifier> &val) {
|
||||
_fqms = val;
|
||||
}
|
||||
|
||||
float Prop2DMesherJobStep::get_simplification_step_ratio() const {
|
||||
return _simplification_step_ratio;
|
||||
}
|
||||
void Prop2DMesherJobStep::set_simplification_step_ratio(const float value) {
|
||||
_simplification_step_ratio = value;
|
||||
}
|
||||
|
||||
int Prop2DMesherJobStep::get_simplification_steps() const {
|
||||
return _simplification_steps;
|
||||
}
|
||||
void Prop2DMesherJobStep::set_simplification_steps(const int value) {
|
||||
_simplification_steps = value;
|
||||
}
|
||||
|
||||
float Prop2DMesherJobStep::get_simplification_agressiveness() const {
|
||||
return _simplification_agressiveness;
|
||||
}
|
||||
void Prop2DMesherJobStep::set_simplification_agressiveness(const float value) {
|
||||
_simplification_agressiveness = value;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Prop2DMesherJobStep::Prop2DMesherJobStep() {
|
||||
_job_type = TYPE_NORMAL;
|
||||
_lod_index = 0;
|
||||
|
||||
#ifdef MESH_UTILS_PRESENT
|
||||
_simplification_step_ratio = 0.8;
|
||||
_simplification_steps = 2;
|
||||
_simplification_agressiveness = 7;
|
||||
#endif
|
||||
}
|
||||
|
||||
Prop2DMesherJobStep::~Prop2DMesherJobStep() {
|
||||
#ifdef MESH_UTILS_PRESENT
|
||||
_fqms.unref();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Prop2DMesherJobStep::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_job_type"), &Prop2DMesherJobStep::get_job_type);
|
||||
ClassDB::bind_method(D_METHOD("set_job_type", "value"), &Prop2DMesherJobStep::set_job_type);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "job_type", PROPERTY_HINT_ENUM, Prop2DMesherJobStep::BINDING_STRING_PROP_2D_MESHER_JOB_STEP_TYPE), "set_job_type", "get_job_type");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_lod_index"), &Prop2DMesherJobStep::get_lod_index);
|
||||
ClassDB::bind_method(D_METHOD("set_lod_index", "value"), &Prop2DMesherJobStep::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"), &Prop2DMesherJobStep::get_fqms);
|
||||
ClassDB::bind_method(D_METHOD("set_fqms", "value"), &Prop2DMesherJobStep::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"), &Prop2DMesherJobStep::get_simplification_step_ratio);
|
||||
ClassDB::bind_method(D_METHOD("set_simplification_step_ratio", "value"), &Prop2DMesherJobStep::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"), &Prop2DMesherJobStep::get_simplification_steps);
|
||||
ClassDB::bind_method(D_METHOD("set_simplification_steps", "value"), &Prop2DMesherJobStep::set_simplification_steps);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "simplification_steps"), "set_simplification_steps", "get_simplification_steps");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_simplification_agressiveness"), &Prop2DMesherJobStep::get_simplification_agressiveness);
|
||||
ClassDB::bind_method(D_METHOD("set_simplification_agressiveness", "value"), &Prop2DMesherJobStep::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);
|
||||
}
|
@ -1,97 +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 PROP_2D_MESHER_JOB_STEP_H
|
||||
#define PROP_2D_MESHER_JOB_STEP_H
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/io/reference.h"
|
||||
#else
|
||||
#include "core/reference.h"
|
||||
#endif
|
||||
|
||||
#ifdef MESH_UTILS_PRESENT
|
||||
#include "../../mesh_utils/fast_quadratic_mesh_simplifier.h"
|
||||
#endif
|
||||
|
||||
class Prop2DMesherJobStep : public Reference {
|
||||
GDCLASS(Prop2DMesherJobStep, 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 Prop2DMesherJobStepType {
|
||||
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_PROP_2D_MESHER_JOB_STEP_TYPE;
|
||||
|
||||
Prop2DMesherJobStepType get_job_type() const;
|
||||
void set_job_type(const Prop2DMesherJobStepType 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
|
||||
|
||||
Prop2DMesherJobStep();
|
||||
~Prop2DMesherJobStep();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
Prop2DMesherJobStepType _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(Prop2DMesherJobStep::Prop2DMesherJobStepType);
|
||||
|
||||
#endif
|
@ -48,7 +48,6 @@ typedef class RenderingServer VS;
|
||||
#include "./props/prop_2d_data_light.h"
|
||||
#include "./props/prop_2d_data_prop.h"
|
||||
#include "./props/prop_2d_data_scene.h"
|
||||
#include "jobs/prop_2d_mesher_job_step.h"
|
||||
#include "lights/prop_2d_light.h"
|
||||
#include "material_cache/prop_2d_material_cache.h"
|
||||
#include "scene/3d/camera.h"
|
||||
@ -722,20 +721,6 @@ void Prop2DInstanceMerger::collision_mask_changed() {
|
||||
void Prop2DInstanceMerger::_create_job() {
|
||||
_job = Ref<Prop2DInstanceProp2DJob>(memnew(Prop2DInstanceProp2DJob()));
|
||||
_job->set_prop_instace(this);
|
||||
|
||||
Ref<Prop2DMesherJobStep> js;
|
||||
|
||||
js.instance();
|
||||
js->set_job_type(Prop2DMesherJobStep::TYPE_NORMAL);
|
||||
_job->add_jobs_step(js);
|
||||
|
||||
js.instance();
|
||||
js->set_job_type(Prop2DMesherJobStep::TYPE_MERGE_VERTS);
|
||||
_job->add_jobs_step(js);
|
||||
|
||||
js.instance();
|
||||
js->set_job_type(Prop2DMesherJobStep::TYPE_BAKE_TEXTURE);
|
||||
_job->add_jobs_step(js);
|
||||
}
|
||||
|
||||
Prop2DInstanceMerger::Prop2DInstanceMerger() {
|
||||
|
@ -30,7 +30,6 @@ SOFTWARE.
|
||||
#define GET_WORLD get_world
|
||||
#endif
|
||||
|
||||
#include "jobs/prop_2d_mesher_job_step.h"
|
||||
#include "lights/prop_2d_light.h"
|
||||
#include "material_cache/prop_2d_material_cache.h"
|
||||
#include "prop_2d_instance.h"
|
||||
@ -68,28 +67,6 @@ void Prop2DInstanceProp2DJob::set_material_cache(const Ref<Prop2DMaterialCache>
|
||||
_material_cache = cache;
|
||||
}
|
||||
|
||||
Ref<Prop2DMesherJobStep> Prop2DInstanceProp2DJob::get_jobs_step(int index) const {
|
||||
ERR_FAIL_INDEX_V(index, _job_steps.size(), Ref<Prop2DMesherJobStep>());
|
||||
|
||||
return _job_steps.get(index);
|
||||
}
|
||||
void Prop2DInstanceProp2DJob::set_jobs_step(int index, const Ref<Prop2DMesherJobStep> &step) {
|
||||
ERR_FAIL_INDEX(index, _job_steps.size());
|
||||
|
||||
_job_steps.set(index, step);
|
||||
}
|
||||
void Prop2DInstanceProp2DJob::remove_jobs_step(const int index) {
|
||||
ERR_FAIL_INDEX(index, _job_steps.size());
|
||||
|
||||
_job_steps.remove(index);
|
||||
}
|
||||
void Prop2DInstanceProp2DJob::add_jobs_step(const Ref<Prop2DMesherJobStep> &step) {
|
||||
_job_steps.push_back(step);
|
||||
}
|
||||
int Prop2DInstanceProp2DJob::get_jobs_step_count() const {
|
||||
return _job_steps.size();
|
||||
}
|
||||
|
||||
void Prop2DInstanceProp2DJob::add_collision_shape(const Ref<Shape> &shape, const Transform &transform, const bool owns_shape) {
|
||||
CollisionShapeEntry e;
|
||||
|
||||
@ -195,9 +172,6 @@ void Prop2DInstanceProp2DJob::_reset() {
|
||||
_build_done = false;
|
||||
_phase = 0;
|
||||
|
||||
_current_mesh = 0;
|
||||
_current_job_step = 0;
|
||||
|
||||
reset_stages();
|
||||
|
||||
if (_prop_mesher.is_valid()) {
|
||||
@ -375,45 +349,7 @@ void Prop2DInstanceProp2DJob::phase_steps() {
|
||||
if (should_do()) {
|
||||
if (_prop_instace->mesh_get_num() == 0) {
|
||||
//need to allocate the meshes
|
||||
|
||||
//first count how many we need
|
||||
int count = 0;
|
||||
for (int i = 0; i < _job_steps.size(); ++i) {
|
||||
Ref<Prop2DMesherJobStep> step = _job_steps[i];
|
||||
|
||||
ERR_FAIL_COND(!step.is_valid());
|
||||
|
||||
switch (step->get_job_type()) {
|
||||
case Prop2DMesherJobStep::TYPE_NORMAL:
|
||||
++count;
|
||||
break;
|
||||
case Prop2DMesherJobStep::TYPE_NORMAL_LOD:
|
||||
++count;
|
||||
break;
|
||||
case Prop2DMesherJobStep::TYPE_DROP_UV2:
|
||||
++count;
|
||||
break;
|
||||
case Prop2DMesherJobStep::TYPE_MERGE_VERTS:
|
||||
++count;
|
||||
break;
|
||||
case Prop2DMesherJobStep::TYPE_BAKE_TEXTURE:
|
||||
++count;
|
||||
break;
|
||||
case Prop2DMesherJobStep::TYPE_SIMPLIFY_MESH:
|
||||
#ifdef MESH_UTILS_PRESENT
|
||||
count += step->get_simplification_steps();
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//allocate
|
||||
if (count > 0) {
|
||||
_prop_instace->meshes_create(count);
|
||||
}
|
||||
|
||||
_prop_instace->meshes_create(1);
|
||||
} else {
|
||||
//we have the meshes, just clear
|
||||
int count = _prop_instace->mesh_get_num();
|
||||
@ -431,41 +367,7 @@ void Prop2DInstanceProp2DJob::phase_steps() {
|
||||
}
|
||||
}
|
||||
|
||||
for (; _current_job_step < _job_steps.size();) {
|
||||
Ref<Prop2DMesherJobStep> step = _job_steps[_current_job_step];
|
||||
|
||||
ERR_FAIL_COND(!step.is_valid());
|
||||
|
||||
switch (step->get_job_type()) {
|
||||
case Prop2DMesherJobStep::TYPE_NORMAL:
|
||||
step_type_normal();
|
||||
break;
|
||||
case Prop2DMesherJobStep::TYPE_NORMAL_LOD:
|
||||
step_type_normal_lod();
|
||||
break;
|
||||
case Prop2DMesherJobStep::TYPE_DROP_UV2:
|
||||
step_type_drop_uv2();
|
||||
break;
|
||||
case Prop2DMesherJobStep::TYPE_MERGE_VERTS:
|
||||
step_type_merge_verts();
|
||||
break;
|
||||
case Prop2DMesherJobStep::TYPE_BAKE_TEXTURE:
|
||||
step_type_bake_texture();
|
||||
break;
|
||||
case Prop2DMesherJobStep::TYPE_SIMPLIFY_MESH:
|
||||
step_type_simplify_mesh();
|
||||
break;
|
||||
case Prop2DMesherJobStep::TYPE_OTHER:
|
||||
//do nothing
|
||||
break;
|
||||
}
|
||||
|
||||
++_current_job_step;
|
||||
|
||||
if (should_return()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
step_type_normal();
|
||||
|
||||
reset_stages();
|
||||
//next_phase();
|
||||
@ -478,115 +380,15 @@ void Prop2DInstanceProp2DJob::step_type_normal() {
|
||||
|
||||
temp_mesh_arr = _prop_mesher->build_mesh();
|
||||
|
||||
RID mesh_rid = _prop_instace->mesh_get(_current_mesh);
|
||||
RID mesh_rid = _prop_instace->mesh_get(0);
|
||||
|
||||
VS::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
|
||||
Ref<Material> lmat = _material_cache->material_lod_get(_current_mesh);
|
||||
Ref<Material> lmat = _material_cache->material_lod_get(0);
|
||||
|
||||
if (lmat.is_valid()) {
|
||||
VisualServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
|
||||
}
|
||||
|
||||
++_current_mesh;
|
||||
}
|
||||
|
||||
void Prop2DInstanceProp2DJob::step_type_normal_lod() {
|
||||
print_error("Error: step_type_normal_lod doesn't work for TerraProp2DJobs!");
|
||||
|
||||
++_current_mesh;
|
||||
}
|
||||
|
||||
void Prop2DInstanceProp2DJob::step_type_drop_uv2() {
|
||||
RID mesh_rid = _prop_instace->mesh_get(_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 = _material_cache->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 Prop2DInstanceProp2DJob::step_type_merge_verts() {
|
||||
Array temp_mesh_arr2 = merge_mesh_array(temp_mesh_arr);
|
||||
temp_mesh_arr = temp_mesh_arr2;
|
||||
|
||||
RID mesh_rid = _prop_instace->mesh_get(_current_mesh);
|
||||
|
||||
VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
|
||||
Ref<Material> lmat = _material_cache->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 Prop2DInstanceProp2DJob::step_type_bake_texture() {
|
||||
Ref<ShaderMaterial> mat = _material_cache->material_lod_get(0);
|
||||
Ref<SpatialMaterial> spmat = _material_cache->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 = _prop_instace->mesh_get(_current_mesh);
|
||||
|
||||
VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
|
||||
Ref<Material> lmat = _material_cache->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 Prop2DInstanceProp2DJob::step_type_simplify_mesh() {
|
||||
#ifdef MESH_UTILS_PRESENT
|
||||
|
||||
Ref<Prop2DMesherJobStep> 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 = _prop_instace->mesh_get(_current_mesh);
|
||||
|
||||
VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
|
||||
Ref<Material> lmat = _material_cache->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
|
||||
}
|
||||
|
||||
Array Prop2DInstanceProp2DJob::merge_mesh_array(Array arr) const {
|
||||
@ -721,8 +523,6 @@ Prop2DInstanceProp2DJob::Prop2DInstanceProp2DJob() {
|
||||
|
||||
_prop_instace = NULL;
|
||||
|
||||
_current_job_step = 0;
|
||||
|
||||
//todo allocate this in a virtual method
|
||||
_prop_mesher.instance();
|
||||
_prop_mesher->set_build_flags(Prop2DMesher::BUILD_FLAG_USE_LIGHTING | Prop2DMesher::BUILD_FLAG_USE_AO | Prop2DMesher::BUILD_FLAG_USE_RAO | Prop2DMesher::BUILD_FLAG_BAKE_LIGHTS);
|
||||
@ -736,12 +536,6 @@ void Prop2DInstanceProp2DJob::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_material_cache", "packer"), &Prop2DInstanceProp2DJob::set_material_cache);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material_cache", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DMaterialCache", 0), "set_material_cache", "get_material_cache");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_jobs_step", "index"), &Prop2DInstanceProp2DJob::get_jobs_step);
|
||||
ClassDB::bind_method(D_METHOD("set_jobs_step", "index", "mesher"), &Prop2DInstanceProp2DJob::set_jobs_step);
|
||||
ClassDB::bind_method(D_METHOD("remove_jobs_step", "index"), &Prop2DInstanceProp2DJob::remove_jobs_step);
|
||||
ClassDB::bind_method(D_METHOD("add_jobs_step", "mesher"), &Prop2DInstanceProp2DJob::add_jobs_step);
|
||||
ClassDB::bind_method(D_METHOD("get_jobs_step_count"), &Prop2DInstanceProp2DJob::get_jobs_step_count);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_prop_mesher"), &Prop2DInstanceProp2DJob::get_prop_mesher);
|
||||
ClassDB::bind_method(D_METHOD("set_prop_mesher", "mesher"), &Prop2DInstanceProp2DJob::set_prop_mesher);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_mesher", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DMesher", 0), "set_prop_mesher", "get_prop_mesher");
|
||||
|
@ -45,12 +45,6 @@ public:
|
||||
Ref<Prop2DMaterialCache> get_material_cache();
|
||||
void set_material_cache(const Ref<Prop2DMaterialCache> &cache);
|
||||
|
||||
Ref<Prop2DMesherJobStep> get_jobs_step(const int index) const;
|
||||
void set_jobs_step(const int index, const Ref<Prop2DMesherJobStep> &step);
|
||||
void remove_jobs_step(const int index);
|
||||
void add_jobs_step(const Ref<Prop2DMesherJobStep> &step);
|
||||
int get_jobs_step_count() const;
|
||||
|
||||
void add_collision_shape(const Ref<Shape> &shape, const Transform &transform, const bool owns_shape = false);
|
||||
void clear_collision_shapes();
|
||||
|
||||
@ -82,11 +76,6 @@ public:
|
||||
void phase_steps();
|
||||
|
||||
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();
|
||||
|
||||
Array merge_mesh_array(Array arr) const;
|
||||
Array bake_mesh_array_uv(Array arr, Ref<Texture> tex, float mul_color = 0.7) const;
|
||||
@ -124,10 +113,6 @@ protected:
|
||||
|
||||
Ref<Prop2DMaterialCache> _material_cache;
|
||||
|
||||
Vector<Ref<Prop2DMesherJobStep>> _job_steps;
|
||||
int _current_job_step;
|
||||
int _current_mesh;
|
||||
|
||||
Ref<Prop2DMesher> _prop_mesher;
|
||||
Prop2DInstanceMerger *_prop_instace;
|
||||
|
||||
|
@ -54,7 +54,6 @@ SOFTWARE.
|
||||
#include "prop_2d_instance_job.h"
|
||||
#include "prop_2d_instance_prop_job.h"
|
||||
|
||||
#include "jobs/prop_2d_mesher_job_step.h"
|
||||
#include "jobs/prop_2d_texture_job.h"
|
||||
|
||||
#include "prop_2d_scene_instance.h"
|
||||
@ -98,7 +97,6 @@ void register_props_2d_types() {
|
||||
ClassDB::register_class<GroundClutter2DFoliage>();
|
||||
|
||||
ClassDB::register_class<Prop2DMesher>();
|
||||
ClassDB::register_class<Prop2DMesherJobStep>();
|
||||
|
||||
ClassDB::register_class<Prop2DInstance>();
|
||||
ClassDB::register_class<Prop2DInstanceMerger>();
|
||||
|
Loading…
Reference in New Issue
Block a user