Added the job steps api to PropInstancePropJob.

This commit is contained in:
Relintai 2021-08-09 11:30:52 +02:00
parent 3c20bd4ec6
commit 33095a83a1
2 changed files with 42 additions and 0 deletions

View File

@ -33,6 +33,7 @@ SOFTWARE.
#include "prop_instance.h"
#include "prop_instance_merger.h"
#include "prop_mesher.h"
#include "jobs/prop_mesher_job_step.h"
#ifdef MESH_DATA_RESOURCE_PRESENT
#include "../mesh_data_resource/mesh_data_resource.h"
@ -62,6 +63,29 @@ void PropInstancePropJob::set_texture_packer(const Ref<TexturePacker> &packer) {
}
#endif
Ref<PropMesherJobStep> PropInstancePropJob::get_jobs_step(int index) const {
ERR_FAIL_INDEX_V(index, _job_steps.size(), Ref<PropMesherJobStep>());
return _job_steps.get(index);
}
void PropInstancePropJob::set_jobs_step(int index, const Ref<PropMesherJobStep> &step) {
ERR_FAIL_INDEX(index, _job_steps.size());
_job_steps.set(index, step);
}
void PropInstancePropJob::remove_jobs_step(const int index) {
ERR_FAIL_INDEX(index, _job_steps.size());
_job_steps.remove(index);
}
void PropInstancePropJob::add_jobs_step(const Ref<PropMesherJobStep> &step) {
_job_steps.push_back(step);
}
int PropInstancePropJob::get_jobs_step_count() const {
return _job_steps.size();
}
PropInstanceMerger *PropInstancePropJob::get_prop_instace() {
return _prop_instace;
}
@ -479,6 +503,12 @@ void PropInstancePropJob::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_packer", PROPERTY_HINT_RESOURCE_TYPE, "TexturePacker", 0), "set_texture_packer", "get_texture_packer");
#endif
ClassDB::bind_method(D_METHOD("get_jobs_step", "index"), &PropInstancePropJob::get_jobs_step);
ClassDB::bind_method(D_METHOD("set_jobs_step", "index", "mesher"), &PropInstancePropJob::set_jobs_step);
ClassDB::bind_method(D_METHOD("remove_jobs_step", "index"), &PropInstancePropJob::remove_jobs_step);
ClassDB::bind_method(D_METHOD("add_jobs_step", "mesher"), &PropInstancePropJob::add_jobs_step);
ClassDB::bind_method(D_METHOD("get_jobs_step_count"), &PropInstancePropJob::get_jobs_step_count);
ClassDB::bind_method(D_METHOD("get_prop_mesher"), &PropInstancePropJob::get_prop_mesher);
ClassDB::bind_method(D_METHOD("set_prop_mesher", "mesher"), &PropInstancePropJob::set_prop_mesher);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_mesher", PROPERTY_HINT_RESOURCE_TYPE, "PropMesher", 0), "set_prop_mesher", "get_prop_mesher");

View File

@ -32,6 +32,7 @@ class TexturePacker;
class PropMesher;
class PropInstance;
class PropInstanceMerger;
class PropMesherJobStep;
#if MESH_DATA_RESOURCE_PRESENT
class PropDataMeshData;
@ -46,6 +47,12 @@ public:
void set_texture_packer(const Ref<TexturePacker> &packer);
#endif
Ref<PropMesherJobStep> get_jobs_step(const int index) const;
void set_jobs_step(const int index, const Ref<PropMesherJobStep> &step);
void remove_jobs_step(const int index);
void add_jobs_step(const Ref<PropMesherJobStep> &step);
int get_jobs_step_count() const;
PropInstanceMerger *get_prop_instace();
void set_prop_instace(PropInstanceMerger *prop);
void set_prop_instace_bind(Node *prop);
@ -82,6 +89,11 @@ protected:
#if TEXTURE_PACKER_PRESENT
Ref<TexturePacker> _texture_packer;
#endif
Vector<Ref<PropMesherJobStep>> _job_steps;
int _current_job_step;
int _current_mesh;
Ref<PropMesher> _prop_mesher;
PropInstanceMerger *_prop_instace;