Now the prop instance job now holds an array of PropDataMeshDatas with their base transforms. Also PropInstanceMerger will now add all mesh data resources to the job when processing the prop.

This commit is contained in:
Relintai 2021-05-20 19:09:00 +02:00
parent a0d9404201
commit 243ddc2faf
3 changed files with 43 additions and 3 deletions

View File

@ -299,9 +299,7 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref<PropDat
if (!mdr.is_valid())
continue;
//add to job
//job could merge textures if needed
//chunk->mesh_data_resource_add(t, mdr, mesh_data->get_texture());
_job->add_mesh(mesh_data, transform);
continue;
}

View File

@ -37,6 +37,13 @@ SOFTWARE.
#include "../texture_packer/texture_packer.h"
#endif
#if MESH_DATA_RESOURCE_PRESENT
//define PROPS_PRESENT, so things compile. That module's scsub will define this too while compiling,
//but not when included from here.
#define PROPS_PRESENT 1
#include "../mesh_data_resource/props/prop_data_mesh_data.h"
#endif
#if TEXTURE_PACKER_PRESENT
Ref<TexturePacker> PropInstancePropJob::get_texture_packer() {
return _texture_packer;
@ -63,6 +70,20 @@ void PropInstancePropJob::set_prop_mesher(const Ref<PropMesher> &mesher) {
_prop_mesher = mesher;
}
#if MESH_DATA_RESOURCE_PRESENT
void PropInstancePropJob::add_mesh(const Ref<PropDataMeshData> &mesh_data, const Transform &base_transform) {
PMDREntry e;
e.mesh_data = mesh_data;
e.base_transform = base_transform;
_prop_mesh_datas.push_back(e);
}
void PropInstancePropJob::clear_meshes() {
_prop_mesh_datas.clear();
}
#endif
void PropInstancePropJob::phase_physics_process() {
/*
Ref<TerraChunkDefault> chunk = _chunk;

View File

@ -32,6 +32,10 @@ class TexturePacker;
class PropMesher;
class PropInstance;
#if MESH_DATA_RESOURCE_PRESENT
class PropDataMeshData;
#endif
class PropInstancePropJob : public PropInstanceJob {
GDCLASS(PropInstancePropJob, PropInstanceJob);
@ -48,6 +52,11 @@ public:
Ref<PropMesher> get_prop_mesher() const;
void set_prop_mesher(const Ref<PropMesher> &mesher);
#if MESH_DATA_RESOURCE_PRESENT
void add_mesh(const Ref<PropDataMeshData> &mesh_data, const Transform &base_transform);
void clear_meshes();
#endif
void phase_physics_process();
void phase_prop();
@ -61,12 +70,24 @@ public:
protected:
static void _bind_methods();
protected:
#if MESH_DATA_RESOURCE_PRESENT
struct PMDREntry {
Ref<PropDataMeshData> mesh_data;
Transform base_transform;
};
#endif
#if TEXTURE_PACKER_PRESENT
Ref<TexturePacker> _texture_packer;
#endif
Ref<PropMesher> _prop_mesher;
PropInstance *_prop_instace;
#if MESH_DATA_RESOURCE_PRESENT
Vector<PMDREntry> _prop_mesh_datas;
#endif
Array temp_mesh_arr;
};