mirror of
https://github.com/Relintai/voxelman.git
synced 2024-11-20 10:47:19 +01:00
Ported TerrainMesherJobStep from Terraman
This commit is contained in:
parent
3410575387
commit
c694c04768
1
SCsub
1
SCsub
@ -78,6 +78,7 @@ sources = [
|
|||||||
|
|
||||||
"world/jobs/voxel_job.cpp",
|
"world/jobs/voxel_job.cpp",
|
||||||
"world/jobs/voxel_terrain_job.cpp",
|
"world/jobs/voxel_terrain_job.cpp",
|
||||||
|
"world/jobs/voxel_mesher_job_step.cpp",
|
||||||
"world/jobs/voxel_light_job.cpp",
|
"world/jobs/voxel_light_job.cpp",
|
||||||
"world/jobs/voxel_prop_job.cpp",
|
"world/jobs/voxel_prop_job.cpp",
|
||||||
]
|
]
|
||||||
|
@ -64,6 +64,7 @@ def get_doc_classes():
|
|||||||
"VoxelTerrainJob",
|
"VoxelTerrainJob",
|
||||||
"VoxelLightJob",
|
"VoxelLightJob",
|
||||||
"VoxelPropJob",
|
"VoxelPropJob",
|
||||||
|
"VoxelMesherJobStep",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
41
doc_classes/VoxelMesherJobStep.xml
Normal file
41
doc_classes/VoxelMesherJobStep.xml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<class name="VoxelMesherJobStep" inherits="Reference" version="3.5">
|
||||||
|
<brief_description>
|
||||||
|
</brief_description>
|
||||||
|
<description>
|
||||||
|
</description>
|
||||||
|
<tutorials>
|
||||||
|
</tutorials>
|
||||||
|
<methods>
|
||||||
|
</methods>
|
||||||
|
<members>
|
||||||
|
<member name="fqms" type="FastQuadraticMeshSimplifier" setter="set_fqms" getter="get_fqms">
|
||||||
|
</member>
|
||||||
|
<member name="job_type" type="int" setter="set_job_type" getter="get_job_type" enum="VoxelMesherJobStep.VoxelMesherJobStepType" default="0">
|
||||||
|
</member>
|
||||||
|
<member name="lod_index" type="int" setter="set_lod_index" getter="get_lod_index" default="0">
|
||||||
|
</member>
|
||||||
|
<member name="simplification_agressiveness" type="float" setter="set_simplification_agressiveness" getter="get_simplification_agressiveness" default="7.0">
|
||||||
|
</member>
|
||||||
|
<member name="simplification_step_ratio" type="float" setter="set_simplification_step_ratio" getter="get_simplification_step_ratio" default="0.8">
|
||||||
|
</member>
|
||||||
|
<member name="simplification_steps" type="int" setter="set_simplification_steps" getter="get_simplification_steps" default="2">
|
||||||
|
</member>
|
||||||
|
</members>
|
||||||
|
<constants>
|
||||||
|
<constant name="TYPE_NORMAL" value="0" enum="VoxelMesherJobStepType">
|
||||||
|
</constant>
|
||||||
|
<constant name="TYPE_NORMAL_LOD" value="1" enum="VoxelMesherJobStepType">
|
||||||
|
</constant>
|
||||||
|
<constant name="TYPE_DROP_UV2" value="2" enum="VoxelMesherJobStepType">
|
||||||
|
</constant>
|
||||||
|
<constant name="TYPE_MERGE_VERTS" value="3" enum="VoxelMesherJobStepType">
|
||||||
|
</constant>
|
||||||
|
<constant name="TYPE_BAKE_TEXTURE" value="4" enum="VoxelMesherJobStepType">
|
||||||
|
</constant>
|
||||||
|
<constant name="TYPE_SIMPLIFY_MESH" value="5" enum="VoxelMesherJobStepType">
|
||||||
|
</constant>
|
||||||
|
<constant name="TYPE_OTHER" value="6" enum="VoxelMesherJobStepType">
|
||||||
|
</constant>
|
||||||
|
</constants>
|
||||||
|
</class>
|
@ -79,6 +79,7 @@ SOFTWARE.
|
|||||||
#include "world/jobs/voxel_light_job.h"
|
#include "world/jobs/voxel_light_job.h"
|
||||||
#include "world/jobs/voxel_prop_job.h"
|
#include "world/jobs/voxel_prop_job.h"
|
||||||
#include "world/jobs/voxel_terrain_job.h"
|
#include "world/jobs/voxel_terrain_job.h"
|
||||||
|
#include "world/jobs/voxel_mesher_job_step.h"
|
||||||
|
|
||||||
void register_voxelman_types() {
|
void register_voxelman_types() {
|
||||||
ClassDB::register_class<VoxelMesher>();
|
ClassDB::register_class<VoxelMesher>();
|
||||||
@ -135,6 +136,7 @@ void register_voxelman_types() {
|
|||||||
|
|
||||||
ClassDB::register_class<VoxelJob>();
|
ClassDB::register_class<VoxelJob>();
|
||||||
ClassDB::register_class<VoxelTerrainJob>();
|
ClassDB::register_class<VoxelTerrainJob>();
|
||||||
|
ClassDB::register_class<VoxelMesherJobStep>();
|
||||||
ClassDB::register_class<VoxelLightJob>();
|
ClassDB::register_class<VoxelLightJob>();
|
||||||
ClassDB::register_class<VoxelPropJob>();
|
ClassDB::register_class<VoxelPropJob>();
|
||||||
|
|
||||||
|
123
world/jobs/voxel_mesher_job_step.cpp
Normal file
123
world/jobs/voxel_mesher_job_step.cpp
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
/*
|
||||||
|
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 "voxel_mesher_job_step.h"
|
||||||
|
|
||||||
|
const String VoxelMesherJobStep::BINDING_STRING_TERRAIN_TERRAIN_JOB_STEP_TYPE = "Normal,Normal LOD,Drop UV2,Merge Verts,Bake Texture,Simplify Mesh";
|
||||||
|
|
||||||
|
VoxelMesherJobStep::VoxelMesherJobStepType VoxelMesherJobStep::get_job_type() const {
|
||||||
|
return _job_type;
|
||||||
|
}
|
||||||
|
void VoxelMesherJobStep::set_job_type(const VoxelMesherJobStep::VoxelMesherJobStepType value) {
|
||||||
|
_job_type = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int VoxelMesherJobStep::get_lod_index() const {
|
||||||
|
return _lod_index;
|
||||||
|
}
|
||||||
|
void VoxelMesherJobStep::set_lod_index(const int value) {
|
||||||
|
_lod_index = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef MESH_UTILS_PRESENT
|
||||||
|
Ref<FastQuadraticMeshSimplifier> VoxelMesherJobStep::get_fqms() {
|
||||||
|
return _fqms;
|
||||||
|
}
|
||||||
|
void VoxelMesherJobStep::set_fqms(const Ref<FastQuadraticMeshSimplifier> &val) {
|
||||||
|
_fqms = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
float VoxelMesherJobStep::get_simplification_step_ratio() const {
|
||||||
|
return _simplification_step_ratio;
|
||||||
|
}
|
||||||
|
void VoxelMesherJobStep::set_simplification_step_ratio(const float value) {
|
||||||
|
_simplification_step_ratio = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int VoxelMesherJobStep::get_simplification_steps() const {
|
||||||
|
return _simplification_steps;
|
||||||
|
}
|
||||||
|
void VoxelMesherJobStep::set_simplification_steps(const int value) {
|
||||||
|
_simplification_steps = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
float VoxelMesherJobStep::get_simplification_agressiveness() const {
|
||||||
|
return _simplification_agressiveness;
|
||||||
|
}
|
||||||
|
void VoxelMesherJobStep::set_simplification_agressiveness(const float value) {
|
||||||
|
_simplification_agressiveness = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
VoxelMesherJobStep::VoxelMesherJobStep() {
|
||||||
|
_job_type = TYPE_NORMAL;
|
||||||
|
_lod_index = 0;
|
||||||
|
|
||||||
|
#ifdef MESH_UTILS_PRESENT
|
||||||
|
_simplification_step_ratio = 0.8;
|
||||||
|
_simplification_steps = 2;
|
||||||
|
_simplification_agressiveness = 7;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
VoxelMesherJobStep::~VoxelMesherJobStep() {
|
||||||
|
#ifdef MESH_UTILS_PRESENT
|
||||||
|
_fqms.unref();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelMesherJobStep::_bind_methods() {
|
||||||
|
ClassDB::bind_method(D_METHOD("get_job_type"), &VoxelMesherJobStep::get_job_type);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_job_type", "value"), &VoxelMesherJobStep::set_job_type);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "job_type", PROPERTY_HINT_ENUM, VoxelMesherJobStep::BINDING_STRING_TERRAIN_TERRAIN_JOB_STEP_TYPE), "set_job_type", "get_job_type");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_lod_index"), &VoxelMesherJobStep::get_lod_index);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_lod_index", "value"), &VoxelMesherJobStep::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"), &VoxelMesherJobStep::get_fqms);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_fqms", "value"), &VoxelMesherJobStep::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"), &VoxelMesherJobStep::get_simplification_step_ratio);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_simplification_step_ratio", "value"), &VoxelMesherJobStep::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"), &VoxelMesherJobStep::get_simplification_steps);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_simplification_steps", "value"), &VoxelMesherJobStep::set_simplification_steps);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "simplification_steps"), "set_simplification_steps", "get_simplification_steps");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_simplification_agressiveness"), &VoxelMesherJobStep::get_simplification_agressiveness);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_simplification_agressiveness", "value"), &VoxelMesherJobStep::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);
|
||||||
|
}
|
100
world/jobs/voxel_mesher_job_step.h
Normal file
100
world/jobs/voxel_mesher_job_step.h
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
/*
|
||||||
|
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 VOXEL_MESHER_JOB_STEP_H
|
||||||
|
#define VOXEL_MESHER_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 VoxelMesherJobStep : public Reference {
|
||||||
|
GDCLASS(VoxelMesherJobStep, 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 VoxelMesherJobStepType {
|
||||||
|
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_TERRAIN_JOB_STEP_TYPE;
|
||||||
|
|
||||||
|
VoxelMesherJobStepType get_job_type() const;
|
||||||
|
void set_job_type(const VoxelMesherJobStepType 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
|
||||||
|
|
||||||
|
VoxelMesherJobStep();
|
||||||
|
~VoxelMesherJobStep();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static void _bind_methods();
|
||||||
|
|
||||||
|
VoxelMesherJobStepType _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(VoxelMesherJobStep::VoxelMesherJobStepType);
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user