Light support for Propinstance.

This commit is contained in:
Relintai 2021-04-27 17:17:31 +02:00
parent 5b71d7a931
commit 446b526f57

View File

@ -4,6 +4,14 @@
#include "core/version.h" #include "core/version.h"
#if VERSION_MAJOR < 4
#include "scene/3d/light.h"
#else
#include "scene/3d/light_3d.h"
#define OmniLight OmniLight3D
#define Light Light3D
#endif
#if MESH_DATA_RESOURCE_PRESENT #if MESH_DATA_RESOURCE_PRESENT
//define PROPS_PRESENT, so things compile. That module's scsub will define this too while compiling, //define PROPS_PRESENT, so things compile. That module's scsub will define this too while compiling,
//but not when included from here. //but not when included from here.
@ -80,6 +88,8 @@ void PropInstance::prop_preprocess(Transform transform, const Ref<PropData> &pro
} }
void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &prop) { void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &prop) {
//don't set owners, to help working with the editor
ERR_FAIL_COND(!prop.is_valid()); ERR_FAIL_COND(!prop.is_valid());
int count = prop->get_prop_count(); int count = prop->get_prop_count();
@ -114,7 +124,6 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &pr
Node *n = sc->instance(); Node *n = sc->instance();
add_child(n); add_child(n);
//n->set_owner(this);
Spatial *sp = Object::cast_to<Spatial>(n); Spatial *sp = Object::cast_to<Spatial>(n);
@ -125,24 +134,17 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &pr
continue; continue;
} }
/* Ref<PropDataLight> light_data = e;
//Will create a Terralight node, and prop
//PropDataLight could use standard godot light nodes
Ref<PropDataLight> light_data = entry;
if (light_data.is_valid()) { if (light_data.is_valid()) {
Ref<VoxelLight> light; OmniLight *light = memnew(OmniLight);
light.instance(); add_child(light);
light->set_world_position(wp.x / get_voxel_scale(), wp.y / get_voxel_scale(), wp.z / get_voxel_scale());
light->set_color(light_data->get_light_color()); light->set_color(light_data->get_light_color());
light->set_size(light_data->get_light_size()); light->set_param(Light::PARAM_RANGE, light_data->get_light_size());
light->set_transform(t);
light_add(light);
continue; continue;
} }
*/
#if MESH_DATA_RESOURCE_PRESENT #if MESH_DATA_RESOURCE_PRESENT
Ref<PropDataMeshData> mesh_data = e; Ref<PropDataMeshData> mesh_data = e;
@ -155,10 +157,7 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &pr
MeshDataInstance *mdi = memnew(MeshDataInstance); MeshDataInstance *mdi = memnew(MeshDataInstance);
add_child(mdi); add_child(mdi);
//mdi->set_owner(this);
mdi->set_transform(t); mdi->set_transform(t);
//not yet sure how it would be best to do this
//Maybe giving this class a material, and setting it could work
//mdi->set_material(); //mdi->set_material();
mdi->set_mesh_data(mdr); mdi->set_mesh_data(mdr);