mirror of
https://github.com/Relintai/voxelman.git
synced 2024-11-12 10:15:12 +01:00
Added binds for liquids.
This commit is contained in:
parent
fd48f195c6
commit
3b722e24f9
@ -8,22 +8,36 @@ VoxelmanLibrary::~VoxelmanLibrary() {
|
|||||||
_prop_material.unref();
|
_prop_material.unref();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Surfaces
|
||||||
Ref<VoxelSurface> VoxelmanLibrary::get_voxel_surface(int index) const {
|
Ref<VoxelSurface> VoxelmanLibrary::get_voxel_surface(int index) const {
|
||||||
return Ref<VoxelSurface>();
|
return Ref<VoxelSurface>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelmanLibrary::set_voxel_surface(int index, Ref<VoxelSurface> value) {
|
void VoxelmanLibrary::set_voxel_surface(int index, Ref<VoxelSurface> value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelmanLibrary::remove_surface(int index) {
|
void VoxelmanLibrary::remove_surface(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int VoxelmanLibrary::get_num_surfaces() {
|
int VoxelmanLibrary::get_num_surfaces() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
void VoxelmanLibrary::clear_surfaces() {
|
||||||
|
}
|
||||||
|
|
||||||
|
//Liquids
|
||||||
|
Ref<VoxelSurface> VoxelmanLibrary::get_liquid_voxel_surface(int index) const {
|
||||||
|
return Ref<VoxelSurface>();
|
||||||
|
}
|
||||||
|
void VoxelmanLibrary::set_liquid_voxel_surface(int index, Ref<VoxelSurface> value) {
|
||||||
|
}
|
||||||
|
void VoxelmanLibrary::remove_liquid_surface(int index) {
|
||||||
|
}
|
||||||
|
int VoxelmanLibrary::get_liquid_num_surfaces() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
void VoxelmanLibrary::clear_liquid_surfaces() {
|
||||||
|
}
|
||||||
|
|
||||||
|
//Rects
|
||||||
void VoxelmanLibrary::refresh_rects() {
|
void VoxelmanLibrary::refresh_rects() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelmanLibrary::_bind_methods() {
|
void VoxelmanLibrary::_bind_methods() {
|
||||||
@ -39,6 +53,13 @@ void VoxelmanLibrary::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_voxel_surface", "index", "surface"), &VoxelmanLibrary::set_voxel_surface);
|
ClassDB::bind_method(D_METHOD("set_voxel_surface", "index", "surface"), &VoxelmanLibrary::set_voxel_surface);
|
||||||
ClassDB::bind_method(D_METHOD("remove_surface", "index"), &VoxelmanLibrary::remove_surface);
|
ClassDB::bind_method(D_METHOD("remove_surface", "index"), &VoxelmanLibrary::remove_surface);
|
||||||
ClassDB::bind_method(D_METHOD("get_num_surfaces"), &VoxelmanLibrary::get_num_surfaces);
|
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_voxel_surface", "index"), &VoxelmanLibrary::get_liquid_voxel_surface);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_liquid_voxel_surface", "index", "surface"), &VoxelmanLibrary::set_liquid_voxel_surface);
|
||||||
|
ClassDB::bind_method(D_METHOD("remove_liquid_surface", "index"), &VoxelmanLibrary::remove_liquid_surface);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_liquid_num_surfaces"), &VoxelmanLibrary::get_liquid_num_surfaces);
|
||||||
|
ClassDB::bind_method(D_METHOD("clear_liquid_surfaces"), &VoxelmanLibrary::clear_liquid_surfaces);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("refresh_rects"), &VoxelmanLibrary::refresh_rects);
|
ClassDB::bind_method(D_METHOD("refresh_rects"), &VoxelmanLibrary::refresh_rects);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,13 @@ public:
|
|||||||
virtual void set_voxel_surface(int index, Ref<VoxelSurface> value);
|
virtual void set_voxel_surface(int index, Ref<VoxelSurface> value);
|
||||||
virtual void remove_surface(int index);
|
virtual void remove_surface(int index);
|
||||||
virtual int get_num_surfaces();
|
virtual int get_num_surfaces();
|
||||||
|
virtual void clear_surfaces();
|
||||||
|
|
||||||
|
virtual Ref<VoxelSurface> get_liquid_voxel_surface(int index) const;
|
||||||
|
virtual void set_liquid_voxel_surface(int index, Ref<VoxelSurface> value);
|
||||||
|
virtual void remove_liquid_surface(int index);
|
||||||
|
virtual int get_liquid_num_surfaces();
|
||||||
|
virtual void clear_liquid_surfaces();
|
||||||
|
|
||||||
virtual void refresh_rects();
|
virtual void refresh_rects();
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ void VoxelmanLibraryMerger::set_margin(const int margin) {
|
|||||||
_packer->set_margin(margin);
|
_packer->set_margin(margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Surfaces
|
||||||
Ref<VoxelSurface> VoxelmanLibraryMerger::get_voxel_surface(int index) const {
|
Ref<VoxelSurface> VoxelmanLibraryMerger::get_voxel_surface(int index) const {
|
||||||
ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref<VoxelSurface>(NULL));
|
ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref<VoxelSurface>(NULL));
|
||||||
|
|
||||||
@ -67,6 +68,30 @@ int VoxelmanLibraryMerger::get_num_surfaces() {
|
|||||||
return _voxel_surfaces.size();
|
return _voxel_surfaces.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibraryMerger::clear_surfaces() {
|
||||||
|
_packer->clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < _voxel_surfaces.size(); i++) {
|
||||||
|
Ref<VoxelSurfaceMerger> surface = _voxel_surfaces[i];
|
||||||
|
|
||||||
|
if (surface.is_valid()) {
|
||||||
|
surface->set_library(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_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() {
|
Vector<Variant> VoxelmanLibraryMerger::get_voxel_surfaces() {
|
||||||
Vector<Variant> r;
|
Vector<Variant> r;
|
||||||
for (int i = 0; i < _voxel_surfaces.size(); i++) {
|
for (int i = 0; i < _voxel_surfaces.size(); i++) {
|
||||||
@ -89,6 +114,76 @@ void VoxelmanLibraryMerger::set_voxel_surfaces(const Vector<Variant> &surfaces)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Liquids
|
||||||
|
Ref<VoxelSurface> VoxelmanLibraryMerger::get_liquid_voxel_surface(int index) const {
|
||||||
|
ERR_FAIL_INDEX_V(index, _liquid_surfaces.size(), Ref<VoxelSurface>(NULL));
|
||||||
|
|
||||||
|
return _liquid_surfaces[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibraryMerger::set_liquid_voxel_surface(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(int index) {
|
||||||
|
_liquid_surfaces.remove(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
int VoxelmanLibraryMerger::get_liquid_num_surfaces() {
|
||||||
|
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++) {
|
||||||
|
r.push_back(_liquid_surfaces[i].get_ref_ptr());
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void VoxelmanLibraryMerger::refresh_rects() {
|
void VoxelmanLibraryMerger::refresh_rects() {
|
||||||
bool texture_added = false;
|
bool texture_added = false;
|
||||||
for (int i = 0; i < _voxel_surfaces.size(); i++) {
|
for (int i = 0; i < _voxel_surfaces.size(); i++) {
|
||||||
@ -111,6 +206,26 @@ 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) {
|
if (texture_added) {
|
||||||
_packer->merge();
|
_packer->merge();
|
||||||
|
|
||||||
@ -132,6 +247,14 @@ void VoxelmanLibraryMerger::refresh_rects() {
|
|||||||
surface->refresh_rects();
|
surface->refresh_rects();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < _liquid_surfaces.size(); i++) {
|
||||||
|
Ref<VoxelSurfaceMerger> surface = _liquid_surfaces[i];
|
||||||
|
|
||||||
|
if (surface.is_valid()) {
|
||||||
|
surface->refresh_rects();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VoxelmanLibraryMerger::VoxelmanLibraryMerger() {
|
VoxelmanLibraryMerger::VoxelmanLibraryMerger() {
|
||||||
@ -148,12 +271,21 @@ VoxelmanLibraryMerger::~VoxelmanLibraryMerger() {
|
|||||||
|
|
||||||
if (surface.is_valid()) {
|
if (surface.is_valid()) {
|
||||||
surface->set_library(Ref<VoxelmanLibraryMerger>());
|
surface->set_library(Ref<VoxelmanLibraryMerger>());
|
||||||
surface.unref();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_voxel_surfaces.clear();
|
_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.unref();
|
_packer.unref();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,6 +312,9 @@ void VoxelmanLibraryMerger::_bind_methods() {
|
|||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_voxel_surfaces"), &VoxelmanLibraryMerger::get_voxel_surfaces);
|
ClassDB::bind_method(D_METHOD("get_voxel_surfaces"), &VoxelmanLibraryMerger::get_voxel_surfaces);
|
||||||
ClassDB::bind_method(D_METHOD("set_voxel_surfaces"), &VoxelmanLibraryMerger::set_voxel_surfaces);
|
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");
|
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");
|
||||||
}
|
}
|
||||||
|
@ -35,10 +35,20 @@ public:
|
|||||||
void set_voxel_surface(int index, Ref<VoxelSurface> value);
|
void set_voxel_surface(int index, Ref<VoxelSurface> value);
|
||||||
void remove_surface(int index);
|
void remove_surface(int index);
|
||||||
int get_num_surfaces();
|
int get_num_surfaces();
|
||||||
|
void clear_surfaces();
|
||||||
|
|
||||||
Vector<Variant> get_voxel_surfaces();
|
Vector<Variant> get_voxel_surfaces();
|
||||||
void set_voxel_surfaces(const Vector<Variant> &surfaces);
|
void set_voxel_surfaces(const Vector<Variant> &surfaces);
|
||||||
|
|
||||||
|
Ref<VoxelSurface> get_liquid_voxel_surface(int index) const;
|
||||||
|
void set_liquid_voxel_surface(int index, Ref<VoxelSurface> value);
|
||||||
|
void remove_liquid_surface(int index);
|
||||||
|
int get_liquid_num_surfaces();
|
||||||
|
void clear_liquid_surfaces();
|
||||||
|
|
||||||
|
Vector<Variant> get_liquid_voxel_surfaces();
|
||||||
|
void set_liquid_voxel_surfaces(const Vector<Variant> &surfaces);
|
||||||
|
|
||||||
void refresh_rects();
|
void refresh_rects();
|
||||||
|
|
||||||
VoxelmanLibraryMerger();
|
VoxelmanLibraryMerger();
|
||||||
@ -49,6 +59,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<Ref<VoxelSurfaceMerger> > _voxel_surfaces;
|
Vector<Ref<VoxelSurfaceMerger> > _voxel_surfaces;
|
||||||
|
Vector<Ref<VoxelSurfaceMerger> > _liquid_surfaces;
|
||||||
|
|
||||||
Ref<TexturePacker> _packer;
|
Ref<TexturePacker> _packer;
|
||||||
};
|
};
|
||||||
|
@ -18,6 +18,7 @@ void VoxelmanLibrarySimple::set_atlas_rows(int s) {
|
|||||||
_atlas_rows = s;
|
_atlas_rows = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Surfaces
|
||||||
Ref<VoxelSurface> VoxelmanLibrarySimple::get_voxel_surface(int index) const {
|
Ref<VoxelSurface> VoxelmanLibrarySimple::get_voxel_surface(int index) const {
|
||||||
ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref<VoxelSurface>(NULL));
|
ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref<VoxelSurface>(NULL));
|
||||||
|
|
||||||
@ -50,6 +51,10 @@ int VoxelmanLibrarySimple::get_num_surfaces() {
|
|||||||
return _voxel_surfaces.size();
|
return _voxel_surfaces.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibrarySimple::clear_surfaces() {
|
||||||
|
_voxel_surfaces.clear();
|
||||||
|
}
|
||||||
|
|
||||||
Vector<Variant> VoxelmanLibrarySimple::get_voxel_surfaces() {
|
Vector<Variant> VoxelmanLibrarySimple::get_voxel_surfaces() {
|
||||||
Vector<Variant> r;
|
Vector<Variant> r;
|
||||||
for (int i = 0; i < _voxel_surfaces.size(); i++) {
|
for (int i = 0; i < _voxel_surfaces.size(); i++) {
|
||||||
@ -73,6 +78,66 @@ void VoxelmanLibrarySimple::set_voxel_surfaces(const Vector<Variant> &surfaces)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Liquids
|
||||||
|
Ref<VoxelSurface> VoxelmanLibrarySimple::get_liquid_voxel_surface(int index) const {
|
||||||
|
ERR_FAIL_INDEX_V(index, _liquid_surfaces.size(), Ref<VoxelSurface>(NULL));
|
||||||
|
|
||||||
|
return _liquid_surfaces[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelmanLibrarySimple::set_liquid_voxel_surface(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(int index) {
|
||||||
|
_liquid_surfaces.remove(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
int VoxelmanLibrarySimple::get_liquid_num_surfaces() {
|
||||||
|
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++) {
|
||||||
|
r.push_back(_liquid_surfaces[i].get_ref_ptr());
|
||||||
|
}
|
||||||
|
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() {
|
void VoxelmanLibrarySimple::refresh_rects() {
|
||||||
for (int i = 0; i < _voxel_surfaces.size(); i++) {
|
for (int i = 0; i < _voxel_surfaces.size(); i++) {
|
||||||
Ref<VoxelSurfaceSimple> surface = Ref<VoxelSurfaceSimple>(_voxel_surfaces[i]);
|
Ref<VoxelSurfaceSimple> surface = Ref<VoxelSurfaceSimple>(_voxel_surfaces[i]);
|
||||||
@ -81,6 +146,14 @@ void VoxelmanLibrarySimple::refresh_rects() {
|
|||||||
surface->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() {
|
VoxelmanLibrarySimple::VoxelmanLibrarySimple() {
|
||||||
@ -94,11 +167,20 @@ VoxelmanLibrarySimple::~VoxelmanLibrarySimple() {
|
|||||||
|
|
||||||
if (surface.is_valid()) {
|
if (surface.is_valid()) {
|
||||||
surface->set_library(Ref<VoxelmanLibrarySimple>());
|
surface->set_library(Ref<VoxelmanLibrarySimple>());
|
||||||
surface.unref();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_voxel_surfaces.clear();
|
_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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -115,4 +197,8 @@ void VoxelmanLibrarySimple::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_voxel_surfaces"), &VoxelmanLibrarySimple::set_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");
|
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");
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,20 @@ public:
|
|||||||
void set_voxel_surface(int index, Ref<VoxelSurface> value);
|
void set_voxel_surface(int index, Ref<VoxelSurface> value);
|
||||||
void remove_surface(int index);
|
void remove_surface(int index);
|
||||||
int get_num_surfaces();
|
int get_num_surfaces();
|
||||||
|
void clear_surfaces();
|
||||||
|
|
||||||
Vector<Variant> get_voxel_surfaces();
|
Vector<Variant> get_voxel_surfaces();
|
||||||
void set_voxel_surfaces(const Vector<Variant> &surfaces);
|
void set_voxel_surfaces(const Vector<Variant> &surfaces);
|
||||||
|
|
||||||
|
Ref<VoxelSurface> get_liquid_voxel_surface(int index) const;
|
||||||
|
void set_liquid_voxel_surface(int index, Ref<VoxelSurface> value);
|
||||||
|
void remove_liquid_surface(int index);
|
||||||
|
int get_liquid_num_surfaces();
|
||||||
|
void clear_liquid_surfaces();
|
||||||
|
|
||||||
|
Vector<Variant> get_liquid_voxel_surfaces();
|
||||||
|
void set_liquid_voxel_surfaces(const Vector<Variant> &surfaces);
|
||||||
|
|
||||||
void refresh_rects();
|
void refresh_rects();
|
||||||
|
|
||||||
VoxelmanLibrarySimple();
|
VoxelmanLibrarySimple();
|
||||||
@ -40,6 +50,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<Ref<VoxelSurfaceSimple> > _voxel_surfaces;
|
Vector<Ref<VoxelSurfaceSimple> > _voxel_surfaces;
|
||||||
|
Vector<Ref<VoxelSurfaceSimple> > _liquid_surfaces;
|
||||||
|
|
||||||
//atlas
|
//atlas
|
||||||
int _atlas_columns;
|
int _atlas_columns;
|
||||||
|
@ -434,8 +434,9 @@ void VoxelBuffer::_bind_methods() {
|
|||||||
BIND_ENUM_CONSTANT(CHANNEL_LIGHT_COLOR_B);
|
BIND_ENUM_CONSTANT(CHANNEL_LIGHT_COLOR_B);
|
||||||
BIND_ENUM_CONSTANT(CHANNEL_AO);
|
BIND_ENUM_CONSTANT(CHANNEL_AO);
|
||||||
BIND_ENUM_CONSTANT(CHANNEL_RANDOM_AO);
|
BIND_ENUM_CONSTANT(CHANNEL_RANDOM_AO);
|
||||||
BIND_ENUM_CONSTANT(CHANNEL_DATA1);
|
BIND_ENUM_CONSTANT(CHANNEL_LIQUID_TYPES);
|
||||||
BIND_ENUM_CONSTANT(CHANNEL_DATA2);
|
BIND_ENUM_CONSTANT(CHANNEL_LIQUID_FILL);
|
||||||
|
BIND_ENUM_CONSTANT(CHANNEL_LIQUID_FLOW);
|
||||||
BIND_ENUM_CONSTANT(MAX_CHANNELS);
|
BIND_ENUM_CONSTANT(MAX_CHANNELS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,8 +40,9 @@ public:
|
|||||||
CHANNEL_LIGHT_COLOR_B,
|
CHANNEL_LIGHT_COLOR_B,
|
||||||
CHANNEL_AO,
|
CHANNEL_AO,
|
||||||
CHANNEL_RANDOM_AO,
|
CHANNEL_RANDOM_AO,
|
||||||
CHANNEL_DATA1,
|
CHANNEL_LIQUID_TYPES,
|
||||||
CHANNEL_DATA2,
|
CHANNEL_LIQUID_FILL,
|
||||||
|
CHANNEL_LIQUID_FLOW,
|
||||||
// Arbitrary value, 8 should be enough. Tweak for your needs.
|
// Arbitrary value, 8 should be enough. Tweak for your needs.
|
||||||
MAX_CHANNELS
|
MAX_CHANNELS
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user