mirror of
https://github.com/Relintai/voxelman.git
synced 2024-11-14 10:17:20 +01:00
Removed separate liquid surfaces. They will be contained inside the normal voxel arrays.
This commit is contained in:
parent
bb7daf8f6b
commit
21ad01ca80
@ -155,22 +155,6 @@ int VoxelmanLibrary::get_num_surfaces() const {
|
||||
void VoxelmanLibrary::clear_surfaces() {
|
||||
}
|
||||
|
||||
//Liquids
|
||||
Ref<VoxelSurface> VoxelmanLibrary::get_liquid_surface(const int index) {
|
||||
return Ref<VoxelSurface>();
|
||||
}
|
||||
void VoxelmanLibrary::add_liquid_surface(Ref<VoxelSurface> value) {
|
||||
}
|
||||
void VoxelmanLibrary::set_liquid_surface(int index, Ref<VoxelSurface> value) {
|
||||
}
|
||||
void VoxelmanLibrary::remove_liquid_surface(const int index) {
|
||||
}
|
||||
int VoxelmanLibrary::get_num_liquid_surfaces() const {
|
||||
return 0;
|
||||
}
|
||||
void VoxelmanLibrary::clear_liquid_surfaces() {
|
||||
}
|
||||
|
||||
Ref<PackedScene> VoxelmanLibrary::get_prop(const int id) {
|
||||
return Ref<PackedScene>();
|
||||
}
|
||||
@ -242,13 +226,6 @@ void VoxelmanLibrary::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_num_surfaces"), &VoxelmanLibrary::get_num_surfaces);
|
||||
ClassDB::bind_method(D_METHOD("clear_surfaces"), &VoxelmanLibrary::clear_surfaces);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_liquid_surface", "index"), &VoxelmanLibrary::get_liquid_surface);
|
||||
ClassDB::bind_method(D_METHOD("add_liquid_surface", "value"), &VoxelmanLibrary::add_liquid_surface);
|
||||
ClassDB::bind_method(D_METHOD("set_liquid_surface", "index", "surface"), &VoxelmanLibrary::set_liquid_surface);
|
||||
ClassDB::bind_method(D_METHOD("remove_liquid_surface", "index"), &VoxelmanLibrary::remove_liquid_surface);
|
||||
ClassDB::bind_method(D_METHOD("get_num_liquid_surfaces"), &VoxelmanLibrary::get_num_liquid_surfaces);
|
||||
ClassDB::bind_method(D_METHOD("clear_liquid_surfaces"), &VoxelmanLibrary::clear_liquid_surfaces);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_prop", "id"), &VoxelmanLibrary::get_prop);
|
||||
ClassDB::bind_method(D_METHOD("add_prop", "value"), &VoxelmanLibrary::add_prop);
|
||||
ClassDB::bind_method(D_METHOD("set_prop", "id", "surface"), &VoxelmanLibrary::set_prop);
|
||||
|
@ -73,13 +73,6 @@ public:
|
||||
virtual int get_num_surfaces() const;
|
||||
virtual void clear_surfaces();
|
||||
|
||||
virtual Ref<VoxelSurface> get_liquid_surface(const int index);
|
||||
virtual void add_liquid_surface(Ref<VoxelSurface> value);
|
||||
virtual void set_liquid_surface(const int index, Ref<VoxelSurface> value);
|
||||
virtual void remove_liquid_surface(const int index);
|
||||
virtual int get_num_liquid_surfaces() const;
|
||||
virtual void clear_liquid_surfaces();
|
||||
|
||||
virtual Ref<PackedScene> get_prop(const int id);
|
||||
virtual void add_prop(Ref<PackedScene> value);
|
||||
virtual void set_prop(const int id, Ref<PackedScene> value);
|
||||
|
@ -120,16 +120,6 @@ void VoxelmanLibraryMerger::clear_surfaces() {
|
||||
}
|
||||
|
||||
_voxel_surfaces.clear();
|
||||
|
||||
for (int i = 0; i < _liquid_surfaces.size(); i++) {
|
||||
Ref<VoxelSurfaceMerger> surface = _liquid_surfaces[i];
|
||||
|
||||
if (surface.is_valid()) {
|
||||
surface->set_library(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
_liquid_surfaces.clear();
|
||||
}
|
||||
|
||||
Vector<Variant> VoxelmanLibraryMerger::get_voxel_surfaces() {
|
||||
@ -158,88 +148,6 @@ void VoxelmanLibraryMerger::set_voxel_surfaces(const Vector<Variant> &surfaces)
|
||||
}
|
||||
}
|
||||
|
||||
//Liquids
|
||||
Ref<VoxelSurface> VoxelmanLibraryMerger::get_liquid_surface(const int index) {
|
||||
ERR_FAIL_INDEX_V(index, _liquid_surfaces.size(), Ref<VoxelSurface>(NULL));
|
||||
|
||||
return _liquid_surfaces[index];
|
||||
}
|
||||
|
||||
void VoxelmanLibraryMerger::add_liquid_surface(Ref<VoxelSurface> value) {
|
||||
ERR_FAIL_COND(!value.is_valid());
|
||||
|
||||
value->set_library(Ref<VoxelmanLibraryMerger>(this));
|
||||
value->set_id(_liquid_surfaces.size());
|
||||
|
||||
_liquid_surfaces.push_back(value);
|
||||
}
|
||||
|
||||
void VoxelmanLibraryMerger::set_liquid_voxel_surface(const int index, Ref<VoxelSurface> value) {
|
||||
ERR_FAIL_COND(index < 0);
|
||||
|
||||
if (_liquid_surfaces.size() < index) {
|
||||
_liquid_surfaces.resize(index + 1);
|
||||
}
|
||||
|
||||
if (_liquid_surfaces[index].is_valid()) {
|
||||
_liquid_surfaces.get(index)->set_library(Ref<VoxelmanLibraryMerger>(NULL));
|
||||
}
|
||||
|
||||
if (value.is_valid()) {
|
||||
value->set_library(Ref<VoxelmanLibraryMerger>(this));
|
||||
|
||||
_liquid_surfaces.set(index, value);
|
||||
}
|
||||
}
|
||||
|
||||
void VoxelmanLibraryMerger::remove_liquid_surface(const int index) {
|
||||
_liquid_surfaces.remove(index);
|
||||
}
|
||||
|
||||
int VoxelmanLibraryMerger::get_num_liquid_surfaces() const {
|
||||
return _liquid_surfaces.size();
|
||||
}
|
||||
|
||||
void VoxelmanLibraryMerger::clear_liquid_surfaces() {
|
||||
_packer->clear();
|
||||
|
||||
for (int i = 0; i < _liquid_surfaces.size(); i++) {
|
||||
Ref<VoxelSurfaceMerger> surface = _liquid_surfaces[i];
|
||||
|
||||
if (surface.is_valid()) {
|
||||
surface->set_library(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
_liquid_surfaces.clear();
|
||||
}
|
||||
|
||||
Vector<Variant> VoxelmanLibraryMerger::get_liquid_voxel_surfaces() {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _liquid_surfaces.size(); i++) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r.push_back(_liquid_surfaces[i].get_ref_ptr());
|
||||
#else
|
||||
r.push_back(_liquid_surfaces[i]);
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
void VoxelmanLibraryMerger::set_liquid_voxel_surfaces(const Vector<Variant> &surfaces) {
|
||||
_liquid_surfaces.clear();
|
||||
|
||||
for (int i = 0; i < surfaces.size(); i++) {
|
||||
Ref<VoxelSurfaceMerger> surface = Ref<VoxelSurfaceMerger>(surfaces[i]);
|
||||
|
||||
if (surface.is_valid()) {
|
||||
surface->set_library(this);
|
||||
}
|
||||
|
||||
_liquid_surfaces.push_back(surface);
|
||||
}
|
||||
}
|
||||
|
||||
Ref<PackedScene> VoxelmanLibraryMerger::get_prop(const int id) {
|
||||
//if (_props.has(id))
|
||||
// return _props[id];
|
||||
@ -288,26 +196,6 @@ void VoxelmanLibraryMerger::refresh_rects() {
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < _liquid_surfaces.size(); i++) {
|
||||
Ref<VoxelSurfaceMerger> surface = Ref<VoxelSurfaceMerger>(_liquid_surfaces[i]);
|
||||
|
||||
if (surface.is_valid()) {
|
||||
for (int j = 0; j < VoxelSurface::VOXEL_SIDES_COUNT; ++j) {
|
||||
Ref<Texture> tex = surface->get_texture(static_cast<VoxelSurface::VoxelSurfaceSides>(j));
|
||||
|
||||
if (!tex.is_valid())
|
||||
continue;
|
||||
|
||||
if (!_packer->contains_texture(tex)) {
|
||||
texture_added = true;
|
||||
surface->set_region(static_cast<VoxelSurface::VoxelSurfaceSides>(j), _packer->add_texture(tex));
|
||||
} else {
|
||||
surface->set_region(static_cast<VoxelSurface::VoxelSurfaceSides>(j), _packer->get_texture(tex));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (texture_added) {
|
||||
_packer->merge();
|
||||
|
||||
@ -316,6 +204,7 @@ void VoxelmanLibraryMerger::refresh_rects() {
|
||||
Ref<Texture> tex = _packer->get_generated_texture(0);
|
||||
|
||||
setup_material_albedo(MATERIAL_INDEX_VOXELS, tex);
|
||||
setup_material_albedo(MATERIAL_INDEX_LIQUID, tex);
|
||||
}
|
||||
|
||||
for (int i = 0; i < _voxel_surfaces.size(); i++) {
|
||||
@ -326,14 +215,6 @@ void VoxelmanLibraryMerger::refresh_rects() {
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < _liquid_surfaces.size(); i++) {
|
||||
Ref<VoxelSurfaceMerger> surface = _liquid_surfaces[i];
|
||||
|
||||
if (surface.is_valid()) {
|
||||
surface->refresh_rects();
|
||||
}
|
||||
}
|
||||
|
||||
set_initialized(true);
|
||||
}
|
||||
|
||||
@ -411,16 +292,6 @@ VoxelmanLibraryMerger::~VoxelmanLibraryMerger() {
|
||||
|
||||
_voxel_surfaces.clear();
|
||||
|
||||
for (int i = 0; i < _liquid_surfaces.size(); ++i) {
|
||||
Ref<VoxelSurface> surface = _liquid_surfaces[i];
|
||||
|
||||
if (surface.is_valid()) {
|
||||
surface->set_library(Ref<VoxelmanLibraryMerger>());
|
||||
}
|
||||
}
|
||||
|
||||
_liquid_surfaces.clear();
|
||||
|
||||
_packer->clear();
|
||||
_packer.unref();
|
||||
}
|
||||
@ -450,13 +321,5 @@ void VoxelmanLibraryMerger::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_voxel_surfaces"), &VoxelmanLibraryMerger::set_voxel_surfaces);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_surfaces", PROPERTY_HINT_NONE, "17/17:VoxelSurfaceMerger", PROPERTY_USAGE_DEFAULT, "VoxelSurfaceMerger"), "set_voxel_surfaces", "get_voxel_surfaces");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_liquid_voxel_surfaces"), &VoxelmanLibraryMerger::get_liquid_voxel_surfaces);
|
||||
ClassDB::bind_method(D_METHOD("set_liquid_voxel_surfaces"), &VoxelmanLibraryMerger::set_liquid_voxel_surfaces);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "liquid_voxel_surfaces", PROPERTY_HINT_NONE, "17/17:VoxelSurfaceMerger", PROPERTY_USAGE_DEFAULT, "VoxelSurfaceMerger"), "set_liquid_voxel_surfaces", "get_liquid_voxel_surfaces");
|
||||
|
||||
//ClassDB::bind_method(D_METHOD("get_props"), &VoxelmanLibraryMerger::get_props);
|
||||
//ClassDB::bind_method(D_METHOD("set_props"), &VoxelmanLibraryMerger::set_props);
|
||||
//ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "props", PROPERTY_HINT_NONE, "17/17:PackedScene", PROPERTY_USAGE_DEFAULT, "PackedScene"), "set_props", "get_props");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_setup_material_albedo", "material_index", "texture"), &VoxelmanLibraryMerger::_setup_material_albedo);
|
||||
}
|
||||
|
@ -65,16 +65,6 @@ public:
|
||||
Vector<Variant> get_voxel_surfaces();
|
||||
void set_voxel_surfaces(const Vector<Variant> &surfaces);
|
||||
|
||||
Ref<VoxelSurface> get_liquid_surface(const int index);
|
||||
void add_liquid_surface(Ref<VoxelSurface> value);
|
||||
void set_liquid_voxel_surface(const int index, Ref<VoxelSurface> value);
|
||||
void remove_liquid_surface(const int index);
|
||||
int get_num_liquid_surfaces() const;
|
||||
void clear_liquid_surfaces();
|
||||
|
||||
Vector<Variant> get_liquid_voxel_surfaces();
|
||||
void set_liquid_voxel_surfaces(const Vector<Variant> &surfaces);
|
||||
|
||||
Ref<PackedScene> get_prop(const int id);
|
||||
void add_prop(Ref<PackedScene> value);
|
||||
void set_prop(const int id, const Ref<PackedScene> &value);
|
||||
@ -97,7 +87,6 @@ protected:
|
||||
|
||||
private:
|
||||
Vector<Ref<VoxelSurfaceMerger> > _voxel_surfaces;
|
||||
Vector<Ref<VoxelSurfaceMerger> > _liquid_surfaces;
|
||||
Map<int, Ref<PackedScene> > _props;
|
||||
|
||||
Ref<TexturePacker> _packer;
|
||||
|
@ -117,79 +117,6 @@ void VoxelmanLibrarySimple::set_voxel_surfaces(const Vector<Variant> &surfaces)
|
||||
set_initialized(true);
|
||||
}
|
||||
|
||||
//Liquids
|
||||
Ref<VoxelSurface> VoxelmanLibrarySimple::get_liquid_surface(const int index) {
|
||||
ERR_FAIL_INDEX_V(index, _liquid_surfaces.size(), Ref<VoxelSurface>(NULL));
|
||||
|
||||
return _liquid_surfaces[index];
|
||||
}
|
||||
|
||||
void VoxelmanLibrarySimple::add_liquid_surface(Ref<VoxelSurface> value) {
|
||||
ERR_FAIL_COND(!value.is_valid());
|
||||
|
||||
value->set_library(Ref<VoxelmanLibrarySimple>(this));
|
||||
value->set_id(_liquid_surfaces.size());
|
||||
|
||||
_liquid_surfaces.push_back(value);
|
||||
}
|
||||
|
||||
void VoxelmanLibrarySimple::set_liquid_surface(const int index, Ref<VoxelSurface> value) {
|
||||
ERR_FAIL_COND(index < 0);
|
||||
|
||||
if (_liquid_surfaces.size() < index) {
|
||||
_liquid_surfaces.resize(index + 1);
|
||||
}
|
||||
|
||||
if (_liquid_surfaces[index].is_valid()) {
|
||||
_liquid_surfaces.get(index)->set_library(Ref<VoxelmanLibrarySimple>(NULL));
|
||||
}
|
||||
|
||||
if (value.is_valid()) {
|
||||
value->set_library(Ref<VoxelmanLibrarySimple>(this));
|
||||
|
||||
_liquid_surfaces.set(index, value);
|
||||
}
|
||||
}
|
||||
|
||||
void VoxelmanLibrarySimple::remove_liquid_surface(const int index) {
|
||||
_liquid_surfaces.remove(index);
|
||||
}
|
||||
|
||||
int VoxelmanLibrarySimple::get_num_liquid_surfaces() const {
|
||||
return _liquid_surfaces.size();
|
||||
}
|
||||
|
||||
void VoxelmanLibrarySimple::clear_liquid_surfaces() {
|
||||
_liquid_surfaces.clear();
|
||||
}
|
||||
|
||||
Vector<Variant> VoxelmanLibrarySimple::get_liquid_voxel_surfaces() {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _liquid_surfaces.size(); i++) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r.push_back(_liquid_surfaces[i].get_ref_ptr());
|
||||
#else
|
||||
r.push_back(_liquid_surfaces[i]);
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
void VoxelmanLibrarySimple::set_liquid_voxel_surfaces(const Vector<Variant> &surfaces) {
|
||||
_liquid_surfaces.clear();
|
||||
|
||||
for (int i = 0; i < surfaces.size(); i++) {
|
||||
Ref<VoxelSurfaceSimple> surface = Ref<VoxelSurfaceSimple>(surfaces[i]);
|
||||
|
||||
if (surface.is_valid()) {
|
||||
surface->set_library(this);
|
||||
surface->refresh_rects();
|
||||
}
|
||||
|
||||
_liquid_surfaces.push_back(surface);
|
||||
}
|
||||
}
|
||||
|
||||
void VoxelmanLibrarySimple::refresh_rects() {
|
||||
for (int i = 0; i < _voxel_surfaces.size(); i++) {
|
||||
Ref<VoxelSurfaceSimple> surface = Ref<VoxelSurfaceSimple>(_voxel_surfaces[i]);
|
||||
@ -198,14 +125,6 @@ void VoxelmanLibrarySimple::refresh_rects() {
|
||||
surface->refresh_rects();
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < _liquid_surfaces.size(); i++) {
|
||||
Ref<VoxelSurfaceSimple> surface = Ref<VoxelSurfaceSimple>(_liquid_surfaces[i]);
|
||||
|
||||
if (surface.is_valid()) {
|
||||
surface->refresh_rects();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VoxelmanLibrarySimple::VoxelmanLibrarySimple() {
|
||||
@ -223,16 +142,6 @@ VoxelmanLibrarySimple::~VoxelmanLibrarySimple() {
|
||||
}
|
||||
|
||||
_voxel_surfaces.clear();
|
||||
|
||||
for (int i = 0; i < _liquid_surfaces.size(); ++i) {
|
||||
Ref<VoxelSurface> surface = _liquid_surfaces[i];
|
||||
|
||||
if (surface.is_valid()) {
|
||||
surface->set_library(Ref<VoxelmanLibrarySimple>());
|
||||
}
|
||||
}
|
||||
|
||||
_liquid_surfaces.clear();
|
||||
}
|
||||
|
||||
void VoxelmanLibrarySimple::_bind_methods() {
|
||||
@ -246,10 +155,5 @@ void VoxelmanLibrarySimple::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_voxel_surfaces"), &VoxelmanLibrarySimple::get_voxel_surfaces);
|
||||
ClassDB::bind_method(D_METHOD("set_voxel_surfaces"), &VoxelmanLibrarySimple::set_voxel_surfaces);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_surfaces", PROPERTY_HINT_NONE, "17/17:VoxelSurfaceSimple", PROPERTY_USAGE_DEFAULT, "VoxelSurfaceSimple"), "set_voxel_surfaces", "get_voxel_surfaces");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_liquid_voxel_surfaces"), &VoxelmanLibrarySimple::get_liquid_voxel_surfaces);
|
||||
ClassDB::bind_method(D_METHOD("set_liquid_voxel_surfaces"), &VoxelmanLibrarySimple::set_liquid_voxel_surfaces);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "liquid_voxel_surfaces", PROPERTY_HINT_NONE, "17/17:VoxelSurfaceMerger", PROPERTY_USAGE_DEFAULT, "VoxelSurfaceMerger"), "set_liquid_voxel_surfaces", "get_liquid_voxel_surfaces");
|
||||
}
|
||||
|
@ -54,16 +54,6 @@ public:
|
||||
Vector<Variant> get_voxel_surfaces();
|
||||
void set_voxel_surfaces(const Vector<Variant> &surfaces);
|
||||
|
||||
Ref<VoxelSurface> get_liquid_surface(const int index);
|
||||
void add_liquid_surface(Ref<VoxelSurface> value);
|
||||
void set_liquid_surface(const int index, Ref<VoxelSurface> value);
|
||||
void remove_liquid_surface(const int index);
|
||||
int get_num_liquid_surfaces() const;
|
||||
void clear_liquid_surfaces();
|
||||
|
||||
Vector<Variant> get_liquid_voxel_surfaces();
|
||||
void set_liquid_voxel_surfaces(const Vector<Variant> &surfaces);
|
||||
|
||||
void refresh_rects();
|
||||
|
||||
VoxelmanLibrarySimple();
|
||||
@ -74,7 +64,6 @@ protected:
|
||||
|
||||
private:
|
||||
Vector<Ref<VoxelSurfaceSimple> > _voxel_surfaces;
|
||||
Vector<Ref<VoxelSurfaceSimple> > _liquid_surfaces;
|
||||
|
||||
//atlas
|
||||
int _atlas_columns;
|
||||
|
@ -39,9 +39,8 @@ void VoxelMesherLiquidBlocky::_add_chunk(Ref<VoxelChunk> p_chunk) {
|
||||
float voxel_scale = get_voxel_scale();
|
||||
|
||||
uint8_t *channel_type = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
uint8_t *channel_liquid_type = chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_LIQUID_TYPES);
|
||||
|
||||
if (!channel_type || !channel_liquid_type)
|
||||
if (!channel_type)
|
||||
return;
|
||||
|
||||
uint8_t *channel_color_r = NULL;
|
||||
|
@ -1498,8 +1498,6 @@ void VoxelChunkDefault::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_LIGHT_COLOR_B);
|
||||
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_AO);
|
||||
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_RANDOM_AO);
|
||||
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_LIQUID_TYPES);
|
||||
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_LIQUID_FILL);
|
||||
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_LIQUID_FLOW);
|
||||
BIND_ENUM_CONSTANT(MAX_DEFAULT_CHANNELS);
|
||||
|
||||
|
@ -83,7 +83,6 @@ public:
|
||||
BUILD_PHASE_TERRARIN_MESH_COLLIDER,
|
||||
BUILD_PHASE_LIGHTS,
|
||||
BUILD_PHASE_TERRARIN_MESH,
|
||||
//BUILD_PHASE_LIQUID,
|
||||
BUILD_PHASE_FINALIZE,
|
||||
BUILD_PHASE_MAX
|
||||
};
|
||||
@ -96,8 +95,6 @@ public:
|
||||
DEFAULT_CHANNEL_LIGHT_COLOR_B,
|
||||
DEFAULT_CHANNEL_AO,
|
||||
DEFAULT_CHANNEL_RANDOM_AO,
|
||||
DEFAULT_CHANNEL_LIQUID_TYPES,
|
||||
DEFAULT_CHANNEL_LIQUID_FILL,
|
||||
DEFAULT_CHANNEL_LIQUID_FLOW,
|
||||
MAX_DEFAULT_CHANNELS
|
||||
};
|
||||
|
@ -114,10 +114,8 @@ int VoxelWorldDefault::_get_channel_index_info(const VoxelWorld::ChannelTypeInfo
|
||||
return VoxelChunkDefault::DEFAULT_CHANNEL_TYPE;
|
||||
case CHANNEL_TYPE_INFO_ISOLEVEL:
|
||||
return VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL;
|
||||
case CHANNEL_TYPE_INFO_LIQUID:
|
||||
return VoxelChunkDefault::DEFAULT_CHANNEL_LIQUID_TYPES;
|
||||
case CHANNEL_TYPE_INFO_LIQUID_LEVEL:
|
||||
return VoxelChunkDefault::DEFAULT_CHANNEL_LIQUID_FILL;
|
||||
case CHANNEL_TYPE_INFO_LIQUID_FLOW:
|
||||
return VoxelChunkDefault::DEFAULT_CHANNEL_LIQUID_FLOW;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
@ -1046,6 +1046,5 @@ void VoxelWorld::_bind_methods() {
|
||||
|
||||
BIND_ENUM_CONSTANT(CHANNEL_TYPE_INFO_TYPE);
|
||||
BIND_ENUM_CONSTANT(CHANNEL_TYPE_INFO_ISOLEVEL);
|
||||
BIND_ENUM_CONSTANT(CHANNEL_TYPE_INFO_LIQUID);
|
||||
BIND_ENUM_CONSTANT(CHANNEL_TYPE_INFO_LIQUID_LEVEL);
|
||||
BIND_ENUM_CONSTANT(CHANNEL_TYPE_INFO_LIQUID_FLOW);
|
||||
}
|
||||
|
@ -56,8 +56,7 @@ public:
|
||||
enum ChannelTypeInfo {
|
||||
CHANNEL_TYPE_INFO_TYPE = 0,
|
||||
CHANNEL_TYPE_INFO_ISOLEVEL,
|
||||
CHANNEL_TYPE_INFO_LIQUID,
|
||||
CHANNEL_TYPE_INFO_LIQUID_LEVEL,
|
||||
CHANNEL_TYPE_INFO_LIQUID_FLOW,
|
||||
};
|
||||
|
||||
static const String BINDING_STRING_CHANNEL_TYPE_INFO;
|
||||
|
@ -106,11 +106,7 @@ bool VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point,
|
||||
int selected_voxel = 0;
|
||||
int channel = 0;
|
||||
|
||||
if (_current_tab == 0) {
|
||||
channel = _channel_type;
|
||||
} else {
|
||||
channel = _channel_liquid_type;
|
||||
}
|
||||
channel = _channel_type;
|
||||
|
||||
if (channel == -1)
|
||||
return false;
|
||||
@ -138,7 +134,6 @@ void VoxelWorldEditor::edit(VoxelWorld *p_world) {
|
||||
return;
|
||||
|
||||
_channel_type = _world->get_channel_index_info(VoxelWorld::CHANNEL_TYPE_INFO_TYPE);
|
||||
_channel_liquid_type = _world->get_channel_index_info(VoxelWorld::CHANNEL_TYPE_INFO_LIQUID);
|
||||
|
||||
spatial_editor = Object::cast_to<SpatialEditorPlugin>(_editor->get_editor_plugin_screen());
|
||||
|
||||
@ -150,14 +145,6 @@ void VoxelWorldEditor::edit(VoxelWorld *p_world) {
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < _liquid_surfaces_vbox_container->get_child_count(); ++i) {
|
||||
Node *child = _liquid_surfaces_vbox_container->get_child(i);
|
||||
|
||||
if (!child->is_queued_for_deletion()) {
|
||||
child->queue_delete();
|
||||
}
|
||||
}
|
||||
|
||||
Ref<VoxelmanLibrary> library = _world->get_library();
|
||||
|
||||
if (!library.is_valid())
|
||||
@ -190,52 +177,21 @@ void VoxelWorldEditor::edit(VoxelWorld *p_world) {
|
||||
f = true;
|
||||
}
|
||||
}
|
||||
|
||||
f = false;
|
||||
for (int i = 0; i < library->get_num_liquid_surfaces(); ++i) {
|
||||
Ref<VoxelSurface> surface = library->get_liquid_surface(i);
|
||||
|
||||
if (!surface.is_valid())
|
||||
continue;
|
||||
|
||||
String text = String::num(i) + " - " + surface->get_name();
|
||||
|
||||
Button *button = memnew(Button);
|
||||
button->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
button->set_text(text);
|
||||
button->set_text_align(Button::ALIGN_LEFT);
|
||||
button->set_meta("index", i);
|
||||
button->set_toggle_mode(true);
|
||||
button->set_button_group(_liquid_surfaces_button_group);
|
||||
button->connect("button_up", this, "_on_surface_button_pressed");
|
||||
_liquid_surfaces_vbox_container->add_child(button);
|
||||
|
||||
if (!f) {
|
||||
button->set_pressed(true);
|
||||
f = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VoxelWorldEditor::VoxelWorldEditor() {
|
||||
_world = NULL;
|
||||
_selected_type = 0;
|
||||
_selected_liquid_type = 0;
|
||||
_channel_type = -1;
|
||||
_channel_liquid_type = -1;
|
||||
_editor = NULL;
|
||||
_tool_mode = TOOL_MODE_ADD;
|
||||
_current_tab = 0;
|
||||
}
|
||||
VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) {
|
||||
_world = NULL;
|
||||
_selected_type = 0;
|
||||
_selected_liquid_type = 0;
|
||||
_channel_type = -1;
|
||||
_channel_liquid_type = -1;
|
||||
_editor = p_editor;
|
||||
_tool_mode = TOOL_MODE_ADD;
|
||||
_current_tab = 0;
|
||||
|
||||
spatial_editor_hb = memnew(HBoxContainer);
|
||||
spatial_editor_hb->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
@ -271,40 +227,22 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) {
|
||||
|
||||
set_custom_minimum_size(Size2(200 * EDSCALE, 0));
|
||||
|
||||
TabContainer *tab_container = memnew(TabContainer);
|
||||
tab_container->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
tab_container->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
tab_container->connect("tab_selected", this, "_tab_selected");
|
||||
add_child(tab_container);
|
||||
|
||||
ScrollContainer *scs = memnew(ScrollContainer);
|
||||
scs->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
scs->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
scs->set_name("Surfaces");
|
||||
tab_container->add_child(scs);
|
||||
add_child(scs);
|
||||
|
||||
_surfaces_vbox_container = memnew(VBoxContainer);
|
||||
scs->add_child(_surfaces_vbox_container);
|
||||
_surfaces_vbox_container->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
|
||||
ScrollContainer *scsl = memnew(ScrollContainer);
|
||||
scsl->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
scsl->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
scsl->set_name("Liquids");
|
||||
tab_container->add_child(scsl);
|
||||
|
||||
_liquid_surfaces_vbox_container = memnew(VBoxContainer);
|
||||
scsl->add_child(_liquid_surfaces_vbox_container);
|
||||
_liquid_surfaces_vbox_container->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
|
||||
_surfaces_button_group.instance();
|
||||
_liquid_surfaces_button_group.instance();
|
||||
}
|
||||
VoxelWorldEditor::~VoxelWorldEditor() {
|
||||
_world = NULL;
|
||||
|
||||
_surfaces_button_group.unref();
|
||||
_liquid_surfaces_button_group.unref();
|
||||
}
|
||||
|
||||
void VoxelWorldEditor::_node_removed(Node *p_node) {
|
||||
@ -320,12 +258,6 @@ void VoxelWorldEditor::_on_surface_button_pressed() {
|
||||
if (button) {
|
||||
_selected_type = button->get_meta("index");
|
||||
}
|
||||
|
||||
button = _liquid_surfaces_button_group->get_pressed_button();
|
||||
|
||||
if (button) {
|
||||
_selected_liquid_type = button->get_meta("index");
|
||||
}
|
||||
}
|
||||
|
||||
void VoxelWorldEditor::_on_tool_button_pressed() {
|
||||
@ -340,11 +272,7 @@ void VoxelWorldEditor::_on_insert_block_at_camera_button_pressed() {
|
||||
int selected_voxel = 0;
|
||||
int channel = 0;
|
||||
|
||||
if (_current_tab == 0) {
|
||||
channel = _channel_type;
|
||||
} else {
|
||||
channel = _channel_liquid_type;
|
||||
}
|
||||
channel = _channel_type;
|
||||
|
||||
if (channel == -1)
|
||||
return;
|
||||
@ -365,15 +293,10 @@ void VoxelWorldEditor::_on_insert_block_at_camera_button_pressed() {
|
||||
_world->set_voxel_at_world_position(pos, selected_voxel, channel);
|
||||
}
|
||||
|
||||
void VoxelWorldEditor::_tab_selected(int tab) {
|
||||
_current_tab = tab;
|
||||
}
|
||||
|
||||
void VoxelWorldEditor::_bind_methods() {
|
||||
ClassDB::bind_method("_node_removed", &VoxelWorldEditor::_node_removed);
|
||||
ClassDB::bind_method("_on_surface_button_pressed", &VoxelWorldEditor::_on_surface_button_pressed);
|
||||
ClassDB::bind_method("_on_tool_button_pressed", &VoxelWorldEditor::_on_tool_button_pressed);
|
||||
ClassDB::bind_method("_tab_selected", &VoxelWorldEditor::_tab_selected);
|
||||
ClassDB::bind_method("_on_insert_block_at_camera_button_pressed", &VoxelWorldEditor::_on_insert_block_at_camera_button_pressed);
|
||||
}
|
||||
|
||||
|
@ -65,13 +65,10 @@ protected:
|
||||
void _on_surface_button_pressed();
|
||||
void _on_tool_button_pressed();
|
||||
void _on_insert_block_at_camera_button_pressed();
|
||||
void _tab_selected(int tab);
|
||||
|
||||
private:
|
||||
VBoxContainer *_surfaces_vbox_container;
|
||||
VBoxContainer *_liquid_surfaces_vbox_container;
|
||||
Ref<ButtonGroup> _surfaces_button_group;
|
||||
Ref<ButtonGroup> _liquid_surfaces_button_group;
|
||||
|
||||
Ref<ButtonGroup> _tool_button_group;
|
||||
|
||||
@ -79,15 +76,11 @@ private:
|
||||
VoxelWorld *_world;
|
||||
|
||||
int _selected_type;
|
||||
int _selected_liquid_type;
|
||||
|
||||
SpatialEditorPlugin *spatial_editor;
|
||||
EditorNode *_editor;
|
||||
|
||||
int _channel_type;
|
||||
int _channel_liquid_type;
|
||||
|
||||
int _current_tab;
|
||||
};
|
||||
|
||||
class VoxelWorldEditorPlugin : public EditorPlugin {
|
||||
|
Loading…
Reference in New Issue
Block a user