Work on the interface, and build.

This commit is contained in:
Relintai 2019-11-18 19:43:15 +01:00
parent 5b275155c5
commit decf9a4af2
2 changed files with 73 additions and 94 deletions

View File

@ -19,91 +19,50 @@ _FORCE_INLINE_ void VoxelChunk::set_state(int value) {
_FORCE_INLINE_ int VoxelChunk::get_chunk_position_x() {
return _chunk_position_x;
}
_FORCE_INLINE_ void VoxelChunk::set_chunk_position_x(int value) {
_chunk_position_x = value;
}
_FORCE_INLINE_ int VoxelChunk::get_chunk_position_y() {
return _chunk_position_y;
}
_FORCE_INLINE_ void VoxelChunk::set_chunk_position_y(int value) {
_chunk_position_y = value;
}
_FORCE_INLINE_ int VoxelChunk::get_chunk_position_z() {
return _chunk_position_z;
}
_FORCE_INLINE_ void VoxelChunk::set_chunk_position_z(int value) {
_chunk_position_z = value;
}
_FORCE_INLINE_ Vector3 VoxelChunk::get_chunk_position() const {
return Vector3(_chunk_position_x, _chunk_position_y, _chunk_position_z);
}
_FORCE_INLINE_ void VoxelChunk::set_chunk_position(int x, int y, int z) {
_chunk_position_x = x;
_chunk_position_y = y;
_chunk_position_z = z;
}
_FORCE_INLINE_ int VoxelChunk::get_chunk_size_x() {
return _chunk_size_x;
}
_FORCE_INLINE_ void VoxelChunk::set_chunk_size_x(int value) {
_chunk_size_x = value;
}
_FORCE_INLINE_ int VoxelChunk::get_chunk_size_y() {
return _chunk_size_y;
}
_FORCE_INLINE_ void VoxelChunk::set_chunk_size_y(int value) {
_chunk_size_y = value;
}
_FORCE_INLINE_ int VoxelChunk::get_chunk_size_z() {
return _chunk_size_z;
}
_FORCE_INLINE_ void VoxelChunk::set_chunk_size_z(int value) {
_chunk_size_z = value;
}
_FORCE_INLINE_ Vector3 VoxelChunk::get_chunk_size() const {
return Vector3(_chunk_size_x, _chunk_size_y, _chunk_size_z);
}
_FORCE_INLINE_ void VoxelChunk::set_chunk_size(int x, int y, int z) {
_chunk_size_x = x;
_chunk_size_y = y;
_chunk_size_z = z;
}
_FORCE_INLINE_ int VoxelChunk::get_chunk_data_size_x() {
return _chunk_data_size_x;
}
_FORCE_INLINE_ void VoxelChunk::set_chunk_data_size_x(int value) {
_chunk_data_size_x = value;
}
_FORCE_INLINE_ int VoxelChunk::get_chunk_data_size_y() {
return _chunk_data_size_y;
}
_FORCE_INLINE_ void VoxelChunk::set_chunk_data_size_y(int value) {
_chunk_data_size_y = value;
}
_FORCE_INLINE_ int VoxelChunk::get_chunk_data_size_z() {
return _chunk_data_size_z;
}
_FORCE_INLINE_ void VoxelChunk::set_chunk_data_size_z(int value) {
_chunk_data_size_z = value;
}
_FORCE_INLINE_ Vector3 VoxelChunk::get_chunk_data_size() const {
return Vector3(_chunk_data_size_x, _chunk_data_size_y, _chunk_data_size_z);
}
_FORCE_INLINE_ void VoxelChunk::set_chunk_data_size(int x, int y, int z) {
_chunk_data_size_x = x;
_chunk_data_size_y = y;
_chunk_data_size_z = z;
_FORCE_INLINE_ int VoxelChunk::get_margin_start() const {
return _margin_start;
}
_FORCE_INLINE_ int VoxelChunk::get_margin_end() const {
return _margin_end;
}
Ref<VoxelmanLibrary> VoxelChunk::get_library() {
@ -178,10 +137,6 @@ void VoxelChunk::set_bake_lights(bool value) {
_bake_lights = value;
}
Ref<VoxelBuffer> VoxelChunk::get_buffer() const {
return _buffer;
}
RID VoxelChunk::get_mesh_rid() {
return _mesh_rid;
}
@ -222,10 +177,49 @@ RID VoxelChunk::get_clutter_mesh_instance_rid() {
return _clutter_mesh_instance_rid;
}
//Voxel Data
void VoxelBuffer::set_size(int size_x, int size_y, int siye_z, int margin_start = 0, int margin_end = 0) {
}
void VoxelBuffer::set_channel_count(int value) {
}
void VoxelBuffer::validate_channel_index(int x, int y, int z, int channel_index) {
}
uint8_t VoxelBuffer::get_voxel(int x, int y, int z, int channel_index) {
}
void VoxelBuffer::set_voxel(uint8_t value, int x, int y, int z, int channel_index) {
}
void VoxelBuffer::set_channel_count(int count) {
}
void VoxelBuffer::allocate_channel(int channel_index, uint8_t value = 0) {
}
void VoxelBuffer::fill_channel(int channel_index) {
}
void VoxelBuffer::dealloc_channel(int channel_index) {
}
uint8_t *VoxelBuffer::get_channel(int channel_index) {
}
uint8_t *VoxelBuffer::get_valid_channel(int channel_index) {
}
//Data Management functions
void VoxelBuffer::generate_ao() {
unsigned int size_x = _actual_size.x;
unsigned int size_y = _actual_size.y;
unsigned int size_z = _actual_size.z;
unsigned int size_x = _actual_size_x;
unsigned int size_y = _actual_size_y;
unsigned int size_z = _actual_size_z;
ERR_FAIL_COND(size_x == 0 || size_y == 0 || size_z == 0);
@ -257,9 +251,9 @@ void VoxelBuffer::generate_ao() {
void VoxelBuffer::add_light(int local_x, int local_y, int local_z, int size, Color color) {
ERR_FAIL_COND(size < 0);
int size_x = _actual_size.x;
int size_y = _actual_size.y;
int size_z = _actual_size.z;
int size_x = _actual_size_actual_size_xx;
int size_y = _actual_size_actual_size_xy;
int size_z = _actual_size_actual_size_xz;
float sizef = static_cast<float>(size);
//float rf = (color.r / sizef);
@ -313,9 +307,9 @@ void VoxelBuffer::add_light(int local_x, int local_y, int local_z, int size, Col
}
}
void VoxelBuffer::clear_lights() {
fill(0, CHANNEL_LIGHT_COLOR_R);
fill(0, CHANNEL_LIGHT_COLOR_G);
fill(0, CHANNEL_LIGHT_COLOR_B);
fill_channel(0, CHANNEL_LIGHT_COLOR_R);
fill_channel(0, CHANNEL_LIGHT_COLOR_G);
fill_channel(0, CHANNEL_LIGHT_COLOR_B);
}
void VoxelChunk::create_mesher() {
@ -1037,8 +1031,6 @@ void VoxelChunk::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_current_build_phase", "value"), &VoxelChunk::set_current_build_phase);
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_build_phase"), "set_current_build_phase", "get_current_build_phase");
ClassDB::bind_method(D_METHOD("get_buffer"), &VoxelChunk::get_buffer);
ADD_GROUP("Meshing", "meshing");
ClassDB::bind_method(D_METHOD("meshing_get_create_collider"), &VoxelChunk::get_create_collider);

View File

@ -23,8 +23,6 @@
#include "../library/voxel_surface.h"
#include "../library/voxelman_library.h"
#include "voxel_buffer.h"
#include "../../entity_spell_system/meshes/mesh_data_resource.h"
#include "../props/prop_data.h"
#include "../props/prop_data_entry.h"
@ -83,39 +81,24 @@ public:
int get_state() const;
void set_state(int value);
//Properties
int get_chunk_position_x();
void set_chunk_position_x(int value);
int get_chunk_position_y();
void set_chunk_position_y(int value);
int get_chunk_position_z();
void set_chunk_position_z(int value);
Vector3 get_chunk_position() const;
void set_chunk_position(int x, int y, int z);
int get_chunk_size_x();
void set_chunk_size_x(int value);
int get_chunk_size_y();
void set_chunk_size_y(int value);
int get_chunk_size_z();
void set_chunk_size_z(int value);
Vector3 get_chunk_size() const;
void set_chunk_size(int x, int y, int z);
int get_chunk_data_size_x();
void set_chunk_data_size_x(int value);
int get_chunk_data_size_y();
void set_chunk_data_size_y(int value);
int get_chunk_data_size_z();
void set_chunk_data_size_z(int value);
Vector3 get_chunk_position() const;
Vector3 get_chunk_size() const;
Vector3 get_chunk_data_size() const;
void set_chunk_data_size(int x, int y, int z);
_FORCE_INLINE_ int get_margin_start() const { return _margin_start; }
_FORCE_INLINE_ int get_margin_end() const { return _margin_end; }
int get_margin_start() const;
int get_margin_end() const;
Ref<VoxelmanLibrary> get_library();
void set_library(Ref<VoxelmanLibrary> value);
@ -142,8 +125,6 @@ public:
bool get_bake_lights() const;
void set_bake_lights(bool value);
Ref<VoxelBuffer> get_buffer() const;
RID get_mesh_rid();
RID get_mesh_instance_rid();
RID get_shape_rid();
@ -161,17 +142,22 @@ public:
RID get_clutter_mesh_instance_rid();
//Voxel Data
void set_size(int size_x, int size_y, int siye_z, int margin_start = 0, int margin_end = 0);
void set_channel_count(int value);
//validate
//get voxel
//set voxel
//get channel
//alloc
//fill channel
//clear channel
void validate_channel_index(int x, int y, int z, int channel_index);
uint8_t get_voxel(int x, int y, int z, int channel_index);
void set_voxel(uint8_t value, int x, int y, int z, int channel_index);
void set_channel_count(int count);
void allocate_channel(int channel_index, uint8_t value = 0);
void fill_channel(int channel_index);
void dealloc_channel(int channel_index);
uint8_t *get_channel(int channel_index);
uint8_t *get_valid_channel(int channel_index);
//Data Management functions
void generate_ao();
void add_light(int local_x, int local_y, int local_z, int size, Color color);
@ -282,7 +268,8 @@ protected:
uint32_t _margin_start;
uint32_t _margin_end;
Ref<VoxelBuffer> _buffer;
Vector<uint8_t *> _channels;
Vector<Ref<VoxelLight> > _voxel_lights;
int _lod_size;