Addes api for lights to PropInstancePropJob. Also now PropInstanceMerger will process lights.

This commit is contained in:
Relintai 2021-08-11 18:29:52 +02:00
parent 51ee053eed
commit db6171c48f
3 changed files with 23 additions and 6 deletions

View File

@ -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<PropDat
continue;
}
/*
//Will create a Terralight node, and prop
//PropDataLight could use standard godot light nodes
Ref<PropDataLight> light_data = entry;
Ref<PropDataLight> light_data = e;
if (light_data.is_valid()) {
Ref<VoxelLight> light;
Ref<PropLight> 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<PropDataMeshData> mesh_data = e;

View File

@ -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<PropLight> &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);
}

View File

@ -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<PropLight> &light);
void clear_lights();
void phase_physics_process();
void phase_prop();