mirror of
https://github.com/Relintai/props.git
synced 2024-11-12 10:15:25 +01:00
Now PropLights can be added into the mesher.
This commit is contained in:
parent
00536c9596
commit
51ee053eed
@ -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<PropMesher> &mesher) {
|
||||
}
|
||||
}
|
||||
|
||||
void PropMesher::add_light(const Ref<PropLight> &light) {
|
||||
_lights.push_back(light);
|
||||
}
|
||||
void PropMesher::clear_lights() {
|
||||
_lights.clear();
|
||||
}
|
||||
|
||||
PoolVector<Vector3> PropMesher::build_collider() const {
|
||||
PoolVector<Vector3> 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);
|
||||
|
@ -39,9 +39,9 @@ using PoolVector = Vector<N>;
|
||||
|
||||
#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<N>;
|
||||
#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<PropMesher> &mesher);
|
||||
void _add_mesher(const Ref<PropMesher> &mesher);
|
||||
|
||||
void add_light(const Ref<PropLight> &light);
|
||||
void clear_lights();
|
||||
|
||||
PoolVector<Vector3> build_collider() const;
|
||||
|
||||
void bake_colors();
|
||||
|
||||
#ifdef TERRAMAN_PRESENT
|
||||
void bake_lights(MeshInstance *node, Vector<Ref<TerraLight> > &lights);
|
||||
void bake_lights(MeshInstance *node, Vector<Ref<TerraLight>> &lights);
|
||||
#endif
|
||||
|
||||
Array build_mesh();
|
||||
@ -221,6 +224,7 @@ protected:
|
||||
|
||||
PoolVector<Vertex> _vertices;
|
||||
PoolVector<int> _indices;
|
||||
Vector<Ref<PropLight>> _lights;
|
||||
|
||||
Color _last_color;
|
||||
Vector3 _last_normal;
|
||||
|
Loading…
Reference in New Issue
Block a user