mirror of
https://github.com/Relintai/voxelman.git
synced 2025-01-25 15:09:18 +01:00
Same treatment to light related methods in VoxelWorld.
This commit is contained in:
parent
7e647cf8ba
commit
0f69a9dce3
@ -28,6 +28,7 @@ SOFTWARE.
|
|||||||
#include "../defines.h"
|
#include "../defines.h"
|
||||||
|
|
||||||
#if PROPS_PRESENT
|
#if PROPS_PRESENT
|
||||||
|
#include "../../props/props/prop_data.h"
|
||||||
#include "../../props/props/prop_data_entry.h"
|
#include "../../props/props/prop_data_entry.h"
|
||||||
#include "../../props/props/prop_data_light.h"
|
#include "../../props/props/prop_data_light.h"
|
||||||
#include "../../props/props/prop_data_prop.h"
|
#include "../../props/props/prop_data_prop.h"
|
||||||
@ -608,7 +609,7 @@ void VoxelWorld::add_prop(Transform tarnsform, const Ref<PropData> &prop, const
|
|||||||
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_size(light_data->get_light_size());
|
||||||
|
|
||||||
add_light(light);
|
light_add(light);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -632,7 +633,7 @@ void VoxelWorld::add_prop(Transform tarnsform, const Ref<PropData> &prop, const
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Lights
|
//Lights
|
||||||
void VoxelWorld::add_light(const Ref<VoxelLight> &light) {
|
void VoxelWorld::light_add(const Ref<VoxelLight> &light) {
|
||||||
_lights.push_back(light);
|
_lights.push_back(light);
|
||||||
|
|
||||||
for (int i = 0; i < _chunks_vector.size(); ++i) {
|
for (int i = 0; i < _chunks_vector.size(); ++i) {
|
||||||
@ -643,12 +644,12 @@ void VoxelWorld::add_light(const Ref<VoxelLight> &light) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ref<VoxelLight> VoxelWorld::get_light(const int index) {
|
Ref<VoxelLight> VoxelWorld::light_get(const int index) {
|
||||||
ERR_FAIL_INDEX_V(index, _lights.size(), Ref<VoxelLight>());
|
ERR_FAIL_INDEX_V(index, _lights.size(), Ref<VoxelLight>());
|
||||||
|
|
||||||
return _lights.get(index);
|
return _lights.get(index);
|
||||||
}
|
}
|
||||||
void VoxelWorld::remove_light(const int index) {
|
void VoxelWorld::light_remove(const int index) {
|
||||||
ERR_FAIL_INDEX(index, _lights.size());
|
ERR_FAIL_INDEX(index, _lights.size());
|
||||||
|
|
||||||
Ref<VoxelLight> light = _lights[index];
|
Ref<VoxelLight> light = _lights[index];
|
||||||
@ -661,10 +662,10 @@ void VoxelWorld::remove_light(const int index) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int VoxelWorld::get_light_count() const {
|
int VoxelWorld::light_get_count() const {
|
||||||
return _lights.size();
|
return _lights.size();
|
||||||
}
|
}
|
||||||
void VoxelWorld::clear_lights() {
|
void VoxelWorld::lights_clear() {
|
||||||
for (int i = 0; i < _lights.size(); ++i) {
|
for (int i = 0; i < _lights.size(); ++i) {
|
||||||
Ref<VoxelLight> light = _lights[i];
|
Ref<VoxelLight> light = _lights[i];
|
||||||
|
|
||||||
@ -683,16 +684,16 @@ void VoxelWorld::clear_lights() {
|
|||||||
_lights.clear();
|
_lights.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<Variant> VoxelWorld::get_lights() {
|
Vector<Variant> VoxelWorld::lights_get() {
|
||||||
VARIANT_ARRAY_GET(_lights);
|
VARIANT_ARRAY_GET(_lights);
|
||||||
}
|
}
|
||||||
void VoxelWorld::set_lights(const Vector<Variant> &chunks) {
|
void VoxelWorld::lights_set(const Vector<Variant> &chunks) {
|
||||||
clear_lights();
|
lights_clear();
|
||||||
|
|
||||||
for (int i = 0; i < chunks.size(); ++i) {
|
for (int i = 0; i < chunks.size(); ++i) {
|
||||||
Ref<VoxelLight> light = Ref<VoxelLight>(chunks[i]);
|
Ref<VoxelLight> light = Ref<VoxelLight>(chunks[i]);
|
||||||
|
|
||||||
add_light(light);
|
light_add(light);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1154,14 +1155,14 @@ void VoxelWorld::_bind_methods() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Lights
|
//Lights
|
||||||
ClassDB::bind_method(D_METHOD("add_light", "light"), &VoxelWorld::add_light);
|
ClassDB::bind_method(D_METHOD("light_add", "light"), &VoxelWorld::light_add);
|
||||||
ClassDB::bind_method(D_METHOD("get_light", "index"), &VoxelWorld::get_light);
|
ClassDB::bind_method(D_METHOD("light_get", "index"), &VoxelWorld::light_get);
|
||||||
ClassDB::bind_method(D_METHOD("remove_light", "index"), &VoxelWorld::remove_light);
|
ClassDB::bind_method(D_METHOD("light_remove", "index"), &VoxelWorld::light_remove);
|
||||||
ClassDB::bind_method(D_METHOD("get_light_count"), &VoxelWorld::get_light_count);
|
ClassDB::bind_method(D_METHOD("light_get_count"), &VoxelWorld::light_get_count);
|
||||||
ClassDB::bind_method(D_METHOD("clear_lights"), &VoxelWorld::clear_lights);
|
ClassDB::bind_method(D_METHOD("lights_clear"), &VoxelWorld::lights_clear);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_lights"), &VoxelWorld::get_lights);
|
ClassDB::bind_method(D_METHOD("lights_get"), &VoxelWorld::lights_get);
|
||||||
ClassDB::bind_method(D_METHOD("set_lights", "chunks"), &VoxelWorld::set_lights);
|
ClassDB::bind_method(D_METHOD("lights_set", "chunks"), &VoxelWorld::lights_set);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_voxel_at_world_position", "world_position", "channel_index"), &VoxelWorld::get_voxel_at_world_position);
|
ClassDB::bind_method(D_METHOD("get_voxel_at_world_position", "world_position", "channel_index"), &VoxelWorld::get_voxel_at_world_position);
|
||||||
ClassDB::bind_method(D_METHOD("set_voxel_at_world_position", "world_position", "data", "channel_index", "rebuild"), &VoxelWorld::set_voxel_at_world_position, DEFVAL(true));
|
ClassDB::bind_method(D_METHOD("set_voxel_at_world_position", "world_position", "data", "channel_index", "rebuild"), &VoxelWorld::set_voxel_at_world_position, DEFVAL(true));
|
||||||
|
@ -166,14 +166,14 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Lights
|
//Lights
|
||||||
void add_light(const Ref<VoxelLight> &light);
|
void light_add(const Ref<VoxelLight> &light);
|
||||||
Ref<VoxelLight> get_light(const int index);
|
Ref<VoxelLight> light_get(const int index);
|
||||||
void remove_light(const int index);
|
void light_remove(const int index);
|
||||||
int get_light_count() const;
|
int light_get_count() const;
|
||||||
void clear_lights();
|
void lights_clear();
|
||||||
|
|
||||||
Vector<Variant> get_lights();
|
Vector<Variant> lights_get();
|
||||||
void set_lights(const Vector<Variant> &chunks);
|
void lights_set(const Vector<Variant> &chunks);
|
||||||
|
|
||||||
//Helpers
|
//Helpers
|
||||||
uint8_t get_voxel_at_world_position(const Vector3 &world_position, const int channel_index);
|
uint8_t get_voxel_at_world_position(const Vector3 &world_position, const int channel_index);
|
||||||
|
Loading…
Reference in New Issue
Block a user