mirror of
https://github.com/Relintai/props.git
synced 2024-11-14 10:17:30 +01:00
Removed the texture packer from PropInstancePropJob. The code now uses the material cache instead.
This commit is contained in:
parent
35cf1962d0
commit
64e6447d9c
@ -417,8 +417,8 @@ void PropInstanceMerger::_build() {
|
|||||||
//job -> if !has cache query -> buildings can use this to only have one material per building
|
//job -> if !has cache query -> buildings can use this to only have one material per building
|
||||||
|
|
||||||
//move this to job
|
//move this to job
|
||||||
#if TEXTURE_PACKER_PRESENT
|
//#if TEXTURE_PACKER_PRESENT
|
||||||
Ref<TexturePacker> packer; // = PropCache::get_singleton()->get_or_create_texture_threaded(_prop_data);
|
//Ref<TexturePacker> packer; // = PropCache::get_singleton()->get_or_create_texture_threaded(_prop_data);
|
||||||
/*
|
/*
|
||||||
if (packer->get_generated_texture_count() == 0) {
|
if (packer->get_generated_texture_count() == 0) {
|
||||||
_building = false;
|
_building = false;
|
||||||
@ -426,8 +426,8 @@ void PropInstanceMerger::_build() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
_job->set_texture_packer(packer);
|
// _job->set_texture_packer(packer);
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
for (int i = 0; i < get_child_count(); ++i) {
|
for (int i = 0; i < get_child_count(); ++i) {
|
||||||
Node *n = get_child(i);
|
Node *n = get_child(i);
|
||||||
|
@ -31,10 +31,11 @@ SOFTWARE.
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "jobs/prop_mesher_job_step.h"
|
#include "jobs/prop_mesher_job_step.h"
|
||||||
|
#include "material_cache/prop_material_cache.h"
|
||||||
#include "prop_instance.h"
|
#include "prop_instance.h"
|
||||||
#include "prop_instance_merger.h"
|
#include "prop_instance_merger.h"
|
||||||
#include "prop_mesher.h"
|
#include "prop_mesher.h"
|
||||||
#include "material_cache/prop_material_cache.h"
|
#include "singleton/prop_cache.h"
|
||||||
|
|
||||||
#ifdef MESH_DATA_RESOURCE_PRESENT
|
#ifdef MESH_DATA_RESOURCE_PRESENT
|
||||||
#include "../mesh_data_resource/mesh_data_resource.h"
|
#include "../mesh_data_resource/mesh_data_resource.h"
|
||||||
@ -56,15 +57,6 @@ SOFTWARE.
|
|||||||
#undef PROPS_PRESENT
|
#undef PROPS_PRESENT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TEXTURE_PACKER_PRESENT
|
|
||||||
Ref<TexturePacker> PropInstancePropJob::get_texture_packer() {
|
|
||||||
return _texture_packer;
|
|
||||||
}
|
|
||||||
void PropInstancePropJob::set_texture_packer(const Ref<TexturePacker> &packer) {
|
|
||||||
_texture_packer = packer;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Ref<PropMaterialCache> PropInstancePropJob::get_material_cache() {
|
Ref<PropMaterialCache> PropInstancePropJob::get_material_cache() {
|
||||||
return _material_cache;
|
return _material_cache;
|
||||||
}
|
}
|
||||||
@ -216,15 +208,7 @@ void PropInstancePropJob::phase_prop() {
|
|||||||
Transform t = pmd->get_transform();
|
Transform t = pmd->get_transform();
|
||||||
t *= e.base_transform;
|
t *= e.base_transform;
|
||||||
|
|
||||||
Rect2 uvr = Rect2(0, 0, 1, 1);
|
Rect2 uvr = _material_cache->texture_get_uv_rect(tex);
|
||||||
|
|
||||||
if (_texture_packer.is_valid() && tex.is_valid()) {
|
|
||||||
Ref<AtlasTexture> at = _texture_packer->get_texture(tex);
|
|
||||||
|
|
||||||
if (at.is_valid()) {
|
|
||||||
uvr = at->get_region();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get_prop_mesher()->add_mesh_data_resource_transform(mesh, t, uvr);
|
get_prop_mesher()->add_mesh_data_resource_transform(mesh, t, uvr);
|
||||||
}
|
}
|
||||||
@ -449,35 +433,30 @@ void PropInstancePropJob::_physics_process(float delta) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PropInstancePropJob::_execute_phase() {
|
void PropInstancePropJob::_execute_phase() {
|
||||||
/*
|
if (!_material_cache.is_valid()) {
|
||||||
ERR_FAIL_COND(!_chunk.is_valid());
|
ERR_PRINT("!PropInstancePropJob::_execute_phase(): _material_cache.is_valid()");
|
||||||
|
set_complete(true); //So threadpool knows it's done
|
||||||
|
finished();
|
||||||
|
}
|
||||||
|
|
||||||
Ref<TerramanLibrary> library = _chunk->get_library();
|
|
||||||
|
|
||||||
ERR_FAIL_COND(!library.is_valid());
|
|
||||||
|
|
||||||
Ref<TerraChunkDefault> chunk = _chunk;
|
|
||||||
|
|
||||||
if (!chunk.is_valid()
|
|
||||||
#ifdef MESH_DATA_RESOURCE_PRESENT
|
#ifdef MESH_DATA_RESOURCE_PRESENT
|
||||||
|| chunk->mesh_data_resource_get_count() == 0
|
if (_prop_mesh_datas.size() == 0) {
|
||||||
#endif
|
|
||||||
) {
|
|
||||||
set_complete(true);
|
set_complete(true);
|
||||||
finished();
|
finished();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*/
|
#endif
|
||||||
|
|
||||||
if (_phase == 1) {
|
if (_phase == 1) {
|
||||||
//phase_prop();
|
phase_prop();
|
||||||
} else if (_phase > 1) {
|
} else if (_phase > 1) {
|
||||||
set_complete(true); //So threadpool knows it's done
|
set_complete(true); //So threadpool knows it's done
|
||||||
finished();
|
finished();
|
||||||
ERR_FAIL_MSG("PropInstancePropJob: _phase is too high!");
|
ERR_FAIL_MSG("PropInstancePropJob: _phase is too high!");
|
||||||
}
|
}
|
||||||
|
|
||||||
set_complete(true); //So threadpool knows it's done
|
//set_complete(true); //So threadpool knows it's done
|
||||||
finished();
|
//finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropInstancePropJob::_reset() {
|
void PropInstancePropJob::_reset() {
|
||||||
@ -880,12 +859,6 @@ PropInstancePropJob::~PropInstancePropJob() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PropInstancePropJob::_bind_methods() {
|
void PropInstancePropJob::_bind_methods() {
|
||||||
#if TEXTURE_PACKER_PRESENT
|
|
||||||
ClassDB::bind_method(D_METHOD("get_texture_packer"), &PropInstancePropJob::get_texture_packer);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_texture_packer", "packer"), &PropInstancePropJob::set_texture_packer);
|
|
||||||
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_material_cache"), &PropInstancePropJob::get_material_cache);
|
ClassDB::bind_method(D_METHOD("get_material_cache"), &PropInstancePropJob::get_material_cache);
|
||||||
ClassDB::bind_method(D_METHOD("set_material_cache", "packer"), &PropInstancePropJob::set_material_cache);
|
ClassDB::bind_method(D_METHOD("set_material_cache", "packer"), &PropInstancePropJob::set_material_cache);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material_cache", PROPERTY_HINT_RESOURCE_TYPE, "PropMaterialCache", 0), "set_material_cache", "get_material_cache");
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material_cache", PROPERTY_HINT_RESOURCE_TYPE, "PropMaterialCache", 0), "set_material_cache", "get_material_cache");
|
||||||
|
@ -25,10 +25,6 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "prop_instance_job.h"
|
#include "prop_instance_job.h"
|
||||||
|
|
||||||
#if TEXTURE_PACKER_PRESENT
|
|
||||||
class TexturePacker;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class PropMesher;
|
class PropMesher;
|
||||||
class PropInstance;
|
class PropInstance;
|
||||||
class PropInstanceMerger;
|
class PropInstanceMerger;
|
||||||
@ -43,11 +39,6 @@ class PropInstancePropJob : public PropInstanceJob {
|
|||||||
GDCLASS(PropInstancePropJob, PropInstanceJob);
|
GDCLASS(PropInstancePropJob, PropInstanceJob);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#if TEXTURE_PACKER_PRESENT
|
|
||||||
Ref<TexturePacker> get_texture_packer();
|
|
||||||
void set_texture_packer(const Ref<TexturePacker> &packer);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Ref<PropMaterialCache> get_material_cache();
|
Ref<PropMaterialCache> get_material_cache();
|
||||||
void set_material_cache(const Ref<PropMaterialCache> &cache);
|
void set_material_cache(const Ref<PropMaterialCache> &cache);
|
||||||
|
|
||||||
@ -102,10 +93,6 @@ protected:
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TEXTURE_PACKER_PRESENT
|
|
||||||
Ref<TexturePacker> _texture_packer;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Ref<PropMaterialCache> _material_cache;
|
Ref<PropMaterialCache> _material_cache;
|
||||||
|
|
||||||
Vector<Ref<PropMesherJobStep>> _job_steps;
|
Vector<Ref<PropMesherJobStep>> _job_steps;
|
||||||
|
Loading…
Reference in New Issue
Block a user