2020-01-31 19:52:37 +01:00
|
|
|
/*
|
|
|
|
Copyright (c) 2019-2020 Péter Magyar
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2019-11-09 18:36:17 +01:00
|
|
|
#include "voxelman_library_merger.h"
|
|
|
|
|
2020-04-04 17:22:07 +02:00
|
|
|
#include "scene/resources/packed_scene.h"
|
|
|
|
#include "scene/resources/texture.h"
|
2020-02-16 02:54:17 +01:00
|
|
|
|
2020-06-27 18:25:23 +02:00
|
|
|
#ifdef PROPS_PRESENT
|
2020-06-27 17:04:40 +02:00
|
|
|
#include "../../props/props/prop_data.h"
|
2020-07-05 14:54:37 +02:00
|
|
|
|
2020-06-27 17:04:40 +02:00
|
|
|
#include "../../props/props/prop_data_prop.h"
|
2020-06-27 18:25:23 +02:00
|
|
|
#endif
|
2020-06-22 21:49:58 +02:00
|
|
|
|
2020-07-05 14:54:37 +02:00
|
|
|
#if MESH_DATA_RESOURCE_PRESENT
|
2020-07-05 18:49:00 +02:00
|
|
|
#include "../../mesh_data_resource/props/prop_data_mesh_data.h"
|
2020-07-05 14:54:37 +02:00
|
|
|
#endif
|
|
|
|
|
2020-05-23 10:34:47 +02:00
|
|
|
#include "../defines.h"
|
2020-04-09 12:34:39 +02:00
|
|
|
|
2019-11-09 21:51:40 +01:00
|
|
|
int VoxelmanLibraryMerger::get_texture_flags() const {
|
|
|
|
return _packer->get_texture_flags();
|
|
|
|
}
|
|
|
|
void VoxelmanLibraryMerger::set_texture_flags(const int flags) {
|
|
|
|
_packer->set_texture_flags(flags);
|
2020-06-22 21:49:58 +02:00
|
|
|
_prop_packer->set_texture_flags(flags);
|
2019-11-09 18:36:17 +01:00
|
|
|
}
|
|
|
|
|
2019-11-09 21:51:40 +01:00
|
|
|
int VoxelmanLibraryMerger::get_max_atlas_size() const {
|
|
|
|
return _packer->get_max_atlas_size();
|
|
|
|
}
|
|
|
|
void VoxelmanLibraryMerger::set_max_atlas_size(const int size) {
|
|
|
|
_packer->set_max_atlas_size(size);
|
2020-06-22 21:49:58 +02:00
|
|
|
_prop_packer->set_max_atlas_size(size);
|
2019-11-09 18:36:17 +01:00
|
|
|
}
|
|
|
|
|
2019-11-09 21:51:40 +01:00
|
|
|
bool VoxelmanLibraryMerger::get_keep_original_atlases() const {
|
|
|
|
return _packer->get_keep_original_atlases();
|
|
|
|
}
|
|
|
|
void VoxelmanLibraryMerger::set_keep_original_atlases(const bool value) {
|
|
|
|
_packer->set_keep_original_atlases(value);
|
2020-06-22 21:49:58 +02:00
|
|
|
_prop_packer->set_keep_original_atlases(value);
|
2019-11-09 18:36:17 +01:00
|
|
|
}
|
|
|
|
|
2019-11-09 21:51:40 +01:00
|
|
|
Color VoxelmanLibraryMerger::get_background_color() const {
|
|
|
|
return _packer->get_background_color();
|
|
|
|
}
|
2020-04-16 17:54:32 +02:00
|
|
|
void VoxelmanLibraryMerger::set_background_color(const Color &color) {
|
2019-11-09 21:51:40 +01:00
|
|
|
_packer->set_background_color(color);
|
2020-06-22 21:49:58 +02:00
|
|
|
_prop_packer->set_background_color(color);
|
2019-11-09 21:51:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int VoxelmanLibraryMerger::get_margin() const {
|
|
|
|
return _packer->get_margin();
|
|
|
|
}
|
|
|
|
void VoxelmanLibraryMerger::set_margin(const int margin) {
|
|
|
|
_packer->set_margin(margin);
|
2020-06-22 21:49:58 +02:00
|
|
|
_prop_packer->set_margin(margin);
|
2019-11-09 18:36:17 +01:00
|
|
|
}
|
|
|
|
|
2019-11-09 23:39:19 +01:00
|
|
|
//Surfaces
|
2020-02-16 02:54:17 +01:00
|
|
|
Ref<VoxelSurface> VoxelmanLibraryMerger::get_voxel_surface(const int index) {
|
2019-11-09 18:36:17 +01:00
|
|
|
ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref<VoxelSurface>(NULL));
|
|
|
|
|
|
|
|
return _voxel_surfaces[index];
|
|
|
|
}
|
|
|
|
|
2019-11-10 22:18:31 +01:00
|
|
|
void VoxelmanLibraryMerger::add_voxel_surface(Ref<VoxelSurface> value) {
|
|
|
|
ERR_FAIL_COND(!value.is_valid());
|
|
|
|
|
|
|
|
value->set_library(Ref<VoxelmanLibraryMerger>(this));
|
|
|
|
value->set_id(_voxel_surfaces.size());
|
|
|
|
|
|
|
|
_voxel_surfaces.push_back(value);
|
|
|
|
}
|
|
|
|
|
2020-02-16 02:54:17 +01:00
|
|
|
void VoxelmanLibraryMerger::set_voxel_surface(const int index, Ref<VoxelSurface> value) {
|
2019-11-09 18:36:17 +01:00
|
|
|
ERR_FAIL_COND(index < 0);
|
|
|
|
|
|
|
|
if (_voxel_surfaces.size() < index) {
|
|
|
|
_voxel_surfaces.resize(index + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_voxel_surfaces[index].is_valid()) {
|
|
|
|
_voxel_surfaces.get(index)->set_library(Ref<VoxelmanLibraryMerger>(NULL));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value.is_valid()) {
|
|
|
|
value->set_library(Ref<VoxelmanLibraryMerger>(this));
|
|
|
|
|
|
|
|
_voxel_surfaces.set(index, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-16 02:54:17 +01:00
|
|
|
void VoxelmanLibraryMerger::remove_surface(const int index) {
|
2019-11-09 18:36:17 +01:00
|
|
|
_voxel_surfaces.remove(index);
|
|
|
|
}
|
|
|
|
|
2020-02-16 02:54:17 +01:00
|
|
|
int VoxelmanLibraryMerger::get_num_surfaces() const {
|
2019-11-09 18:36:17 +01:00
|
|
|
return _voxel_surfaces.size();
|
|
|
|
}
|
|
|
|
|
2019-11-09 23:39:19 +01:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2019-11-09 18:36:17 +01:00
|
|
|
Vector<Variant> VoxelmanLibraryMerger::get_voxel_surfaces() {
|
2020-05-23 10:34:47 +02:00
|
|
|
VARIANT_ARRAY_GET(_voxel_surfaces);
|
2019-11-09 18:36:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void VoxelmanLibraryMerger::set_voxel_surfaces(const Vector<Variant> &surfaces) {
|
|
|
|
_voxel_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);
|
|
|
|
}
|
|
|
|
|
|
|
|
_voxel_surfaces.push_back(surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-27 18:25:23 +02:00
|
|
|
#ifdef PROPS_PRESENT
|
2020-06-23 01:15:11 +02:00
|
|
|
Ref<PropData> VoxelmanLibraryMerger::get_prop(const int index) {
|
|
|
|
ERR_FAIL_INDEX_V(index, _props.size(), Ref<PropData>());
|
2020-02-16 02:54:17 +01:00
|
|
|
|
2020-06-23 01:15:11 +02:00
|
|
|
return _props[index];
|
2020-02-16 02:54:17 +01:00
|
|
|
}
|
2020-06-22 21:49:58 +02:00
|
|
|
void VoxelmanLibraryMerger::add_prop(Ref<PropData> value) {
|
2020-06-23 01:15:11 +02:00
|
|
|
_props.push_back(value);
|
2020-02-16 02:54:17 +01:00
|
|
|
}
|
2020-06-23 01:15:11 +02:00
|
|
|
void VoxelmanLibraryMerger::set_prop(const int index, const Ref<PropData> &value) {
|
|
|
|
ERR_FAIL_INDEX(index, _props.size());
|
|
|
|
|
|
|
|
_props.write[index] = value;
|
2020-02-16 02:54:17 +01:00
|
|
|
}
|
2020-06-23 01:15:11 +02:00
|
|
|
void VoxelmanLibraryMerger::remove_prop(const int index) {
|
|
|
|
ERR_FAIL_INDEX(index, _props.size());
|
|
|
|
|
|
|
|
_props.remove(index);
|
2020-02-16 02:54:17 +01:00
|
|
|
}
|
|
|
|
int VoxelmanLibraryMerger::get_num_props() const {
|
|
|
|
return _props.size();
|
|
|
|
}
|
|
|
|
void VoxelmanLibraryMerger::clear_props() {
|
2020-06-22 21:49:58 +02:00
|
|
|
_props.clear();
|
|
|
|
}
|
|
|
|
|
2020-06-23 01:15:11 +02:00
|
|
|
Vector<Variant> VoxelmanLibraryMerger::get_props() {
|
|
|
|
VARIANT_ARRAY_GET(_props);
|
2020-02-16 02:54:17 +01:00
|
|
|
}
|
|
|
|
|
2020-06-22 21:49:58 +02:00
|
|
|
void VoxelmanLibraryMerger::set_props(const Vector<Variant> &props) {
|
2020-06-23 01:15:11 +02:00
|
|
|
VARIANT_ARRAY_SET(props, _props, PropData);
|
|
|
|
}
|
2020-06-28 21:31:26 +02:00
|
|
|
|
|
|
|
Rect2 VoxelmanLibraryMerger::get_prop_uv_rect(const Ref<Texture> &texture) {
|
|
|
|
if (!texture.is_valid())
|
|
|
|
return Rect2(0, 0, 1, 1);
|
|
|
|
|
|
|
|
Ref<AtlasTexture> at = _prop_packer->get_texture(texture);
|
|
|
|
|
|
|
|
if (!at.is_valid())
|
|
|
|
return Rect2(0, 0, 1, 1);
|
|
|
|
|
|
|
|
return at->get_region();
|
|
|
|
}
|
2020-06-27 18:25:23 +02:00
|
|
|
#endif
|
2020-06-22 21:49:58 +02:00
|
|
|
|
2019-11-09 18:36:17 +01:00
|
|
|
void VoxelmanLibraryMerger::refresh_rects() {
|
2019-11-09 21:51:40 +01:00
|
|
|
bool texture_added = false;
|
2019-11-09 18:36:17 +01:00
|
|
|
for (int i = 0; i < _voxel_surfaces.size(); i++) {
|
|
|
|
Ref<VoxelSurfaceMerger> surface = Ref<VoxelSurfaceMerger>(_voxel_surfaces[i]);
|
|
|
|
|
2019-11-09 21:51:40 +01:00
|
|
|
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();
|
|
|
|
|
|
|
|
ERR_FAIL_COND(_packer->get_texture_count() == 0);
|
|
|
|
|
|
|
|
Ref<Texture> tex = _packer->get_generated_texture(0);
|
|
|
|
|
2019-11-25 12:03:45 +01:00
|
|
|
setup_material_albedo(MATERIAL_INDEX_VOXELS, tex);
|
2020-04-19 23:35:47 +02:00
|
|
|
setup_material_albedo(MATERIAL_INDEX_LIQUID, tex);
|
2019-11-09 21:51:40 +01:00
|
|
|
}
|
|
|
|
|
2020-06-27 18:25:23 +02:00
|
|
|
#ifdef PROPS_PRESENT
|
2020-06-22 21:49:58 +02:00
|
|
|
texture_added = false;
|
2020-06-23 01:15:11 +02:00
|
|
|
for (int i = 0; i < _props.size(); i++) {
|
|
|
|
Ref<PropData> prop = _props.get(i);
|
2020-06-22 21:49:58 +02:00
|
|
|
|
|
|
|
if (prop.is_valid()) {
|
|
|
|
if (process_prop_textures(prop))
|
|
|
|
texture_added = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (texture_added) {
|
|
|
|
_prop_packer->merge();
|
|
|
|
|
|
|
|
ERR_FAIL_COND(_prop_packer->get_texture_count() == 0);
|
|
|
|
|
|
|
|
Ref<Texture> tex = _prop_packer->get_generated_texture(0);
|
|
|
|
|
|
|
|
setup_material_albedo(MATERIAL_INDEX_PROP, tex);
|
|
|
|
}
|
2020-06-27 18:25:23 +02:00
|
|
|
#endif
|
2020-06-22 21:49:58 +02:00
|
|
|
|
2019-11-09 21:51:40 +01:00
|
|
|
for (int i = 0; i < _voxel_surfaces.size(); i++) {
|
|
|
|
Ref<VoxelSurfaceMerger> surface = _voxel_surfaces[i];
|
|
|
|
|
2019-11-09 18:36:17 +01:00
|
|
|
if (surface.is_valid()) {
|
|
|
|
surface->refresh_rects();
|
|
|
|
}
|
|
|
|
}
|
2019-11-09 23:39:19 +01:00
|
|
|
|
2020-04-17 19:21:46 +02:00
|
|
|
set_initialized(true);
|
2019-11-09 18:36:17 +01:00
|
|
|
}
|
|
|
|
|
2020-04-16 17:54:32 +02:00
|
|
|
void VoxelmanLibraryMerger::_setup_material_albedo(const int material_index, const Ref<Texture> &texture) {
|
2019-11-25 12:03:45 +01:00
|
|
|
Ref<SpatialMaterial> mat;
|
|
|
|
|
2020-03-29 20:19:38 +02:00
|
|
|
int count = 0;
|
|
|
|
|
2019-11-25 12:03:45 +01:00
|
|
|
switch (material_index) {
|
|
|
|
case MATERIAL_INDEX_VOXELS:
|
2020-03-29 20:19:38 +02:00
|
|
|
count = get_num_materials();
|
2019-11-25 12:03:45 +01:00
|
|
|
break;
|
|
|
|
case MATERIAL_INDEX_LIQUID:
|
2020-03-29 20:19:38 +02:00
|
|
|
count = get_num_liquid_materials();
|
2019-11-25 12:03:45 +01:00
|
|
|
break;
|
2020-06-22 21:49:58 +02:00
|
|
|
case MATERIAL_INDEX_PROP:
|
|
|
|
count = get_num_prop_materials();
|
|
|
|
break;
|
2019-11-25 12:03:45 +01:00
|
|
|
}
|
|
|
|
|
2020-03-29 20:19:38 +02:00
|
|
|
for (int i = 0; i < count; ++i) {
|
|
|
|
|
|
|
|
switch (material_index) {
|
|
|
|
case MATERIAL_INDEX_VOXELS:
|
|
|
|
mat = get_material(i);
|
|
|
|
break;
|
|
|
|
case MATERIAL_INDEX_LIQUID:
|
|
|
|
mat = get_liquid_material(i);
|
|
|
|
break;
|
2020-06-22 21:49:58 +02:00
|
|
|
case MATERIAL_INDEX_PROP:
|
|
|
|
mat = get_prop_material(i);
|
|
|
|
break;
|
2020-03-29 20:19:38 +02:00
|
|
|
}
|
2019-11-25 12:03:45 +01:00
|
|
|
|
2020-03-29 20:19:38 +02:00
|
|
|
Ref<SpatialMaterial> spmat;
|
2019-11-25 12:03:45 +01:00
|
|
|
|
2020-03-29 20:19:38 +02:00
|
|
|
if (spmat.is_valid()) {
|
|
|
|
spmat->set_texture(SpatialMaterial::TEXTURE_ALBEDO, texture);
|
|
|
|
return;
|
|
|
|
}
|
2020-02-16 02:54:17 +01:00
|
|
|
|
2020-03-29 20:19:38 +02:00
|
|
|
Ref<ShaderMaterial> shmat;
|
|
|
|
|
|
|
|
switch (material_index) {
|
|
|
|
case MATERIAL_INDEX_VOXELS:
|
|
|
|
shmat = get_material(i);
|
|
|
|
break;
|
|
|
|
case MATERIAL_INDEX_LIQUID:
|
|
|
|
shmat = get_liquid_material(i);
|
|
|
|
break;
|
|
|
|
}
|
2019-11-25 12:03:45 +01:00
|
|
|
|
2020-03-29 20:19:38 +02:00
|
|
|
if (shmat.is_valid()) {
|
|
|
|
shmat->set_shader_param("texture_albedo", texture);
|
|
|
|
}
|
2019-11-25 12:03:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-09 18:36:17 +01:00
|
|
|
VoxelmanLibraryMerger::VoxelmanLibraryMerger() {
|
2019-11-09 21:51:40 +01:00
|
|
|
_packer.instance();
|
2020-04-09 12:34:39 +02:00
|
|
|
|
2020-05-23 10:34:47 +02:00
|
|
|
#if GODOT4
|
2020-06-22 21:49:58 +02:00
|
|
|
#warning implement
|
2020-04-10 13:55:27 +02:00
|
|
|
#else
|
2020-05-23 10:34:47 +02:00
|
|
|
_packer->set_texture_flags(Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER);
|
2020-04-10 13:55:27 +02:00
|
|
|
#endif
|
2020-04-09 12:34:39 +02:00
|
|
|
|
2019-11-09 21:51:40 +01:00
|
|
|
_packer->set_max_atlas_size(1024);
|
|
|
|
_packer->set_keep_original_atlases(false);
|
|
|
|
_packer->set_margin(0);
|
2020-06-22 21:49:58 +02:00
|
|
|
|
|
|
|
_prop_packer.instance();
|
|
|
|
|
|
|
|
#if GODOT4
|
|
|
|
#warning implement
|
|
|
|
#else
|
|
|
|
_prop_packer->set_texture_flags(Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
_prop_packer->set_max_atlas_size(1024);
|
|
|
|
_prop_packer->set_keep_original_atlases(false);
|
|
|
|
_prop_packer->set_margin(0);
|
2019-11-09 18:36:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VoxelmanLibraryMerger::~VoxelmanLibraryMerger() {
|
|
|
|
for (int i = 0; i < _voxel_surfaces.size(); ++i) {
|
|
|
|
Ref<VoxelSurface> surface = _voxel_surfaces[i];
|
|
|
|
|
|
|
|
if (surface.is_valid()) {
|
|
|
|
surface->set_library(Ref<VoxelmanLibraryMerger>());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_voxel_surfaces.clear();
|
|
|
|
|
2019-11-10 13:42:59 +01:00
|
|
|
_packer->clear();
|
2019-11-09 21:51:40 +01:00
|
|
|
_packer.unref();
|
2020-06-22 21:49:58 +02:00
|
|
|
|
|
|
|
_prop_packer->clear();
|
|
|
|
_prop_packer.unref();
|
|
|
|
}
|
|
|
|
|
2020-06-27 18:25:23 +02:00
|
|
|
#ifdef PROPS_PRESENT
|
2020-06-22 21:49:58 +02:00
|
|
|
bool VoxelmanLibraryMerger::process_prop_textures(Ref<PropData> prop) {
|
|
|
|
if (!prop.is_valid()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool texture_added = false;
|
|
|
|
|
|
|
|
for (int i = 0; i < prop->get_prop_count(); ++i) {
|
2020-07-05 18:49:00 +02:00
|
|
|
Ref<PropDataMeshData> pdm = prop->get_prop(i);
|
2020-06-22 21:49:58 +02:00
|
|
|
|
|
|
|
if (pdm.is_valid()) {
|
|
|
|
Ref<Texture> tex = pdm->get_texture();
|
|
|
|
|
|
|
|
if (!tex.is_valid())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!_prop_packer->contains_texture(tex)) {
|
|
|
|
_prop_packer->add_texture(tex);
|
|
|
|
texture_added = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Ref<PropDataProp> pdp = prop->get_prop(i);
|
|
|
|
|
|
|
|
if (pdp.is_valid()) {
|
|
|
|
if (process_prop_textures(pdp))
|
|
|
|
texture_added = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return texture_added;
|
2019-11-09 21:51:40 +01:00
|
|
|
}
|
2020-06-27 18:25:23 +02:00
|
|
|
#endif
|
2019-11-09 18:36:17 +01:00
|
|
|
|
|
|
|
void VoxelmanLibraryMerger::_bind_methods() {
|
2019-11-09 21:51:40 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("get_texture_flags"), &VoxelmanLibraryMerger::get_texture_flags);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_texture_flags", "flags"), &VoxelmanLibraryMerger::set_texture_flags);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter,Anisotropic Linear,Convert to Linear,Mirrored Repeat,Video Surface"), "set_texture_flags", "get_texture_flags");
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_max_atlas_size"), &VoxelmanLibraryMerger::get_max_atlas_size);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_max_atlas_size", "size"), &VoxelmanLibraryMerger::set_max_atlas_size);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_atlas_size"), "set_max_atlas_size", "get_max_atlas_size");
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_keep_original_atlases"), &VoxelmanLibraryMerger::get_keep_original_atlases);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_keep_original_atlases", "value"), &VoxelmanLibraryMerger::set_keep_original_atlases);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keep_original_atlases"), "set_keep_original_atlases", "get_keep_original_atlases");
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_background_color"), &VoxelmanLibraryMerger::get_background_color);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_background_color", "color"), &VoxelmanLibraryMerger::set_background_color);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "background_color"), "set_background_color", "get_background_color");
|
2019-11-09 18:36:17 +01:00
|
|
|
|
2019-11-09 21:51:40 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("get_margin"), &VoxelmanLibraryMerger::get_margin);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_margin", "size"), &VoxelmanLibraryMerger::set_margin);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "margin"), "set_margin", "get_margin");
|
2019-11-09 18:36:17 +01:00
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_voxel_surfaces"), &VoxelmanLibraryMerger::get_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");
|
2019-11-09 23:39:19 +01:00
|
|
|
|
2020-06-27 18:25:23 +02:00
|
|
|
#ifdef PROPS_PRESENT
|
2020-06-23 01:15:11 +02:00
|
|
|
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:PropData", PROPERTY_USAGE_DEFAULT, "PropData"), "set_props", "get_props");
|
2020-06-27 18:25:23 +02:00
|
|
|
#endif
|
2020-06-22 21:49:58 +02:00
|
|
|
|
2019-11-25 12:03:45 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("_setup_material_albedo", "material_index", "texture"), &VoxelmanLibraryMerger::_setup_material_albedo);
|
2019-11-09 18:36:17 +01:00
|
|
|
}
|