From 51ee053eed17de36a9884ae215da6af2d73a1cf9 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 11 Aug 2021 18:20:29 +0200 Subject: [PATCH] Now PropLights can be added into the mesher. --- prop_mesher.cpp | 17 ++++++++++++++--- prop_mesher.h | 10 +++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/prop_mesher.cpp b/prop_mesher.cpp index 295ddeb..1d3d0f7 100644 --- a/prop_mesher.cpp +++ b/prop_mesher.cpp @@ -22,6 +22,7 @@ SOFTWARE. #include "prop_mesher.h" +#include "lights/prop_light.h" #include "modules/opensimplex/open_simplex_noise.h" const String PropMesher::BINDING_STRING_BUILD_FLAGS = "Use Lighting,Use AO,Use RAO,Bake Lights"; @@ -632,6 +633,13 @@ void PropMesher::_add_mesher(const Ref &mesher) { } } +void PropMesher::add_light(const Ref &light) { + _lights.push_back(light); +} +void PropMesher::clear_lights() { + _lights.clear(); +} + PoolVector PropMesher::build_collider() const { PoolVector face_points; @@ -666,7 +674,7 @@ void PropMesher::bake_colors() { //if ((get_build_flags() & TerraChunkDefault::BUILD_FLAG_USE_LIGHTING) == 0) // return; -/* + /* if (_vertices.size() == 0) return; @@ -1090,12 +1098,15 @@ void PropMesher::_bind_methods() { #endif ClassDB::bind_method(D_METHOD("generate_ao"), &PropMesher::generate_ao); - ClassDB::bind_method(D_METHOD("get_random_ao", "position"),&PropMesher::get_random_ao); + ClassDB::bind_method(D_METHOD("get_random_ao", "position"), &PropMesher::get_random_ao); BIND_VMETHOD(MethodInfo("_add_mesher", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "PropMesher"))); ClassDB::bind_method(D_METHOD("add_mesher", "mesher"), &PropMesher::add_mesher); ClassDB::bind_method(D_METHOD("_add_mesher", "mesher"), &PropMesher::_add_mesher); + ClassDB::bind_method(D_METHOD("add_light", "light"), &PropMesher::add_light); + ClassDB::bind_method(D_METHOD("clear_lights"), &PropMesher::clear_lights); + ClassDB::bind_method(D_METHOD("get_vertices"), &PropMesher::get_vertices); ClassDB::bind_method(D_METHOD("set_vertices", "values"), &PropMesher::set_vertices); ClassDB::bind_method(D_METHOD("get_vertex_count"), &PropMesher::get_vertex_count); @@ -1139,7 +1150,7 @@ void PropMesher::_bind_methods() { ClassDB::bind_method(D_METHOD("build_collider"), &PropMesher::build_collider); ClassDB::bind_method(D_METHOD("bake_colors"), &PropMesher::bake_colors); - + ClassDB::bind_method(D_METHOD("generate_normals", "flip"), &PropMesher::generate_normals, DEFVAL(false)); ClassDB::bind_method(D_METHOD("remove_doubles"), &PropMesher::remove_doubles); diff --git a/prop_mesher.h b/prop_mesher.h index 1ffd783..4720995 100644 --- a/prop_mesher.h +++ b/prop_mesher.h @@ -39,9 +39,9 @@ using PoolVector = Vector; #else #include "core/color.h" +#include "core/pool_vector.h" #include "core/reference.h" #include "core/vector.h" -#include "core/pool_vector.h" #include "scene/3d/mesh_instance.h" #endif @@ -61,6 +61,7 @@ using PoolVector = Vector; #endif class OpenSimplexNoise; +class PropLight; class PropMesher : public Reference { GDCLASS(PropMesher, Reference); @@ -79,7 +80,6 @@ public: }; struct Vertex { - Vector3 vertex; Color color; Vector3 normal; // normal, binormal, tangent @@ -155,12 +155,15 @@ public: void add_mesher(const Ref &mesher); void _add_mesher(const Ref &mesher); + void add_light(const Ref &light); + void clear_lights(); + PoolVector build_collider() const; void bake_colors(); #ifdef TERRAMAN_PRESENT - void bake_lights(MeshInstance *node, Vector > &lights); + void bake_lights(MeshInstance *node, Vector> &lights); #endif Array build_mesh(); @@ -221,6 +224,7 @@ protected: PoolVector _vertices; PoolVector _indices; + Vector> _lights; Color _last_color; Vector3 _last_normal;