diff --git a/prop_instance_merger.cpp b/prop_instance_merger.cpp index e6bc68d..1c955e4 100644 --- a/prop_instance_merger.cpp +++ b/prop_instance_merger.cpp @@ -50,6 +50,7 @@ typedef class RenderingServer VS; #include "./props/prop_data_scene.h" #include "jobs/prop_mesher_job_step.h" #include "material_cache/prop_material_cache.h" +#include "lights/prop_light.h" #if TEXTURE_PACKER_PRESENT #include "./singleton/prop_cache.h" @@ -516,24 +517,24 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref light_data = entry; + Ref light_data = e; if (light_data.is_valid()) { - Ref light; + Ref light; light.instance(); - light->set_world_position(wp.x / get_voxel_scale(), wp.y / get_voxel_scale(), wp.z / get_voxel_scale()); + Vector3 v = t.xform(Vector3()); + + light->set_position(v); light->set_color(light_data->get_light_color()); light->set_size(light_data->get_light_size()); - light_add(light); + _job->add_light(light); continue; } - */ #if MESH_DATA_RESOURCE_PRESENT Ref mesh_data = e; diff --git a/prop_instance_prop_job.cpp b/prop_instance_prop_job.cpp index a0f7366..fec7aa2 100644 --- a/prop_instance_prop_job.cpp +++ b/prop_instance_prop_job.cpp @@ -37,6 +37,7 @@ SOFTWARE. #include "prop_mesher.h" #include "singleton/prop_cache.h" #include "scene/resources/shape.h" +#include "lights/prop_light.h" #ifdef MESH_DATA_RESOURCE_PRESENT #include "../mesh_data_resource/mesh_data_resource.h" @@ -131,6 +132,14 @@ void PropInstancePropJob::clear_meshes() { } #endif + +void PropInstancePropJob::add_light(const Ref &light) { + _prop_mesher->add_light(light); +} +void PropInstancePropJob::clear_lights() { + _prop_mesher->clear_lights(); +} + void PropInstancePropJob::phase_physics_process() { //TODO this should only update the differences for (int i = 0; i < _prop_instace->collider_get_num(); ++i) { @@ -726,5 +735,8 @@ void PropInstancePropJob::_bind_methods() { 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"); + ClassDB::bind_method(D_METHOD("add_light", "light"), &PropInstancePropJob::add_light); + ClassDB::bind_method(D_METHOD("clear_lights"), &PropInstancePropJob::clear_lights); + ClassDB::bind_method(D_METHOD("_physics_process", "delta"), &PropInstancePropJob::_physics_process); } diff --git a/prop_instance_prop_job.h b/prop_instance_prop_job.h index da56987..d0a8103 100644 --- a/prop_instance_prop_job.h +++ b/prop_instance_prop_job.h @@ -31,6 +31,7 @@ class PropInstanceMerger; class PropMesherJobStep; class PropMaterialCache; class Shape; +class PropLight; #if MESH_DATA_RESOURCE_PRESENT class PropDataMeshData; @@ -64,6 +65,9 @@ public: void clear_meshes(); #endif + void add_light(const Ref &light); + void clear_lights(); + void phase_physics_process(); void phase_prop();