mirror of
https://github.com/Relintai/props.git
synced 2024-11-14 10:17:30 +01:00
Added PropMesherJobStep. It's the TerraMesherJobStep class from Terraman renamed.
This commit is contained in:
parent
8c088048d1
commit
58b59557af
6
SCsub
6
SCsub
@ -13,7 +13,9 @@ if os.path.isdir('../texture_packer'):
|
|||||||
if os.path.isdir('../terraman'):
|
if os.path.isdir('../terraman'):
|
||||||
module_env.Append(CPPDEFINES=['TERRAMAN_PRESENT'])
|
module_env.Append(CPPDEFINES=['TERRAMAN_PRESENT'])
|
||||||
|
|
||||||
#ifdef
|
if os.path.isdir('../mesh_utils'):
|
||||||
|
module_env.Append(CPPDEFINES=['MESH_UTILS_PRESENT'])
|
||||||
|
|
||||||
sources = [
|
sources = [
|
||||||
|
|
||||||
"register_types.cpp",
|
"register_types.cpp",
|
||||||
@ -38,6 +40,8 @@ sources = [
|
|||||||
"editor/prop_editor_plugin.cpp",
|
"editor/prop_editor_plugin.cpp",
|
||||||
|
|
||||||
"prop_mesher.cpp",
|
"prop_mesher.cpp",
|
||||||
|
|
||||||
|
"prop_mesher_job_step.cpp",
|
||||||
]
|
]
|
||||||
|
|
||||||
if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes':
|
if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes':
|
||||||
|
123
prop_mesher_job_step.cpp
Normal file
123
prop_mesher_job_step.cpp
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2021 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_mesher_job_step.h"
|
||||||
|
|
||||||
|
const String PropMesherJobStep::BINDING_STRING_TERRA_TERRARIN_JOB_STEP_TYPE = "Normal,Normal LOD,Drop UV2,Merge Verts,Bake Texture,Simplify Mesh";
|
||||||
|
|
||||||
|
PropMesherJobStep::PropMesherJobStepType PropMesherJobStep::get_job_type() const {
|
||||||
|
return _job_type;
|
||||||
|
}
|
||||||
|
void PropMesherJobStep::set_job_type(const PropMesherJobStep::PropMesherJobStepType value) {
|
||||||
|
_job_type = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PropMesherJobStep::get_lod_index() const {
|
||||||
|
return _lod_index;
|
||||||
|
}
|
||||||
|
void PropMesherJobStep::set_lod_index(const int value) {
|
||||||
|
_lod_index = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef MESH_UTILS_PRESENT
|
||||||
|
Ref<FastQuadraticMeshSimplifier> PropMesherJobStep::get_fqms() {
|
||||||
|
return _fqms;
|
||||||
|
}
|
||||||
|
void PropMesherJobStep::set_fqms(const Ref<FastQuadraticMeshSimplifier> &val) {
|
||||||
|
_fqms = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
float PropMesherJobStep::get_simplification_step_ratio() const {
|
||||||
|
return _simplification_step_ratio;
|
||||||
|
}
|
||||||
|
void PropMesherJobStep::set_simplification_step_ratio(const float value) {
|
||||||
|
_simplification_step_ratio = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PropMesherJobStep::get_simplification_steps() const {
|
||||||
|
return _simplification_steps;
|
||||||
|
}
|
||||||
|
void PropMesherJobStep::set_simplification_steps(const int value) {
|
||||||
|
_simplification_steps = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
float PropMesherJobStep::get_simplification_agressiveness() const {
|
||||||
|
return _simplification_agressiveness;
|
||||||
|
}
|
||||||
|
void PropMesherJobStep::set_simplification_agressiveness(const float value) {
|
||||||
|
_simplification_agressiveness = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PropMesherJobStep::PropMesherJobStep() {
|
||||||
|
_job_type = TYPE_NORMAL;
|
||||||
|
_lod_index = 0;
|
||||||
|
|
||||||
|
#ifdef MESH_UTILS_PRESENT
|
||||||
|
_simplification_step_ratio = 0.8;
|
||||||
|
_simplification_steps = 2;
|
||||||
|
_simplification_agressiveness = 7;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
PropMesherJobStep::~PropMesherJobStep() {
|
||||||
|
#ifdef MESH_UTILS_PRESENT
|
||||||
|
_fqms.unref();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropMesherJobStep::_bind_methods() {
|
||||||
|
ClassDB::bind_method(D_METHOD("get_job_type"), &PropMesherJobStep::get_job_type);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_job_type", "value"), &PropMesherJobStep::set_job_type);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "job_type", PROPERTY_HINT_ENUM, PropMesherJobStep::BINDING_STRING_TERRA_TERRARIN_JOB_STEP_TYPE), "set_job_type", "get_job_type");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_lod_index"), &PropMesherJobStep::get_lod_index);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_lod_index", "value"), &PropMesherJobStep::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"), &PropMesherJobStep::get_fqms);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_fqms", "value"), &PropMesherJobStep::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"), &PropMesherJobStep::get_simplification_step_ratio);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_simplification_step_ratio", "value"), &PropMesherJobStep::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"), &PropMesherJobStep::get_simplification_steps);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_simplification_steps", "value"), &PropMesherJobStep::set_simplification_steps);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "simplification_steps"), "set_simplification_steps", "get_simplification_steps");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_simplification_agressiveness"), &PropMesherJobStep::get_simplification_agressiveness);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_simplification_agressiveness", "value"), &PropMesherJobStep::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);
|
||||||
|
}
|
93
prop_mesher_job_step.h
Normal file
93
prop_mesher_job_step.h
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2021 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_MESHER_JOB_STEP_H
|
||||||
|
#define PROP_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 PropMesherJobStep : public Reference {
|
||||||
|
GDCLASS(PropMesherJobStep, Reference);
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum PropMesherJobStepType {
|
||||||
|
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_TERRA_TERRARIN_JOB_STEP_TYPE;
|
||||||
|
|
||||||
|
PropMesherJobStepType get_job_type() const;
|
||||||
|
void set_job_type(const PropMesherJobStepType 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
|
||||||
|
|
||||||
|
PropMesherJobStep();
|
||||||
|
~PropMesherJobStep();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static void _bind_methods();
|
||||||
|
|
||||||
|
PropMesherJobStepType _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(PropMesherJobStep::PropMesherJobStepType);
|
||||||
|
|
||||||
|
#endif
|
@ -46,6 +46,8 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "prop_scene_instance.h"
|
#include "prop_scene_instance.h"
|
||||||
|
|
||||||
|
#include "prop_mesher_job_step.h"
|
||||||
|
|
||||||
#include "singleton/prop_utils.h"
|
#include "singleton/prop_utils.h"
|
||||||
|
|
||||||
#include "./editor/prop_editor_plugin.h"
|
#include "./editor/prop_editor_plugin.h"
|
||||||
@ -65,6 +67,7 @@ void register_props_types() {
|
|||||||
ClassDB::register_class<GroundClutterFoliage>();
|
ClassDB::register_class<GroundClutterFoliage>();
|
||||||
|
|
||||||
ClassDB::register_class<PropMesher>();
|
ClassDB::register_class<PropMesher>();
|
||||||
|
ClassDB::register_class<PropMesherJobStep>();
|
||||||
|
|
||||||
ClassDB::register_class<PropInstance>();
|
ClassDB::register_class<PropInstance>();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user