mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-06 08:05:54 +01:00
More cleanups to voxelman.
This commit is contained in:
parent
d95760ac9e
commit
77d4171dff
@ -22,21 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/object/ref_counted.h"
|
||||
#ifndef Reference
|
||||
#define Reference RefCounted
|
||||
#endif
|
||||
#include "core/string/ustring.h"
|
||||
#else
|
||||
#include "core/reference.h"
|
||||
#include "core/ustring.h"
|
||||
#endif
|
||||
|
||||
#include "core/math/aabb.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
@ -22,23 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/object/ref_counted.h"
|
||||
#ifndef Reference
|
||||
#define Reference RefCounted
|
||||
#endif
|
||||
#include "core/templates/vector.h"
|
||||
#include "core/math/color.h"
|
||||
#else
|
||||
#include "core/color.h"
|
||||
#include "core/reference.h"
|
||||
#include "core/vector.h"
|
||||
#include "core/color.h"
|
||||
#endif
|
||||
|
||||
class VoxelLight : public Reference {
|
||||
GDCLASS(VoxelLight, Reference);
|
||||
|
@ -27,13 +27,9 @@ SOFTWARE.
|
||||
#include "../world/voxel_chunk.h"
|
||||
|
||||
void VoxelLevelGenerator::generate_chunk(Ref<VoxelChunk> chunk) {
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_generate_chunk")) {
|
||||
call("_generate_chunk", chunk);
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_generate_chunk, chunk);
|
||||
#endif
|
||||
}
|
||||
|
||||
VoxelLevelGenerator::VoxelLevelGenerator() {
|
||||
@ -43,11 +39,7 @@ VoxelLevelGenerator::~VoxelLevelGenerator() {
|
||||
}
|
||||
|
||||
void VoxelLevelGenerator::_bind_methods() {
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk")));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_generate_chunk, "chunk");
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &VoxelLevelGenerator::generate_chunk);
|
||||
}
|
||||
|
@ -22,18 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/io/resource.h"
|
||||
#include "core/object/gdvirtual.gen.inc"
|
||||
#include "core/object/script_language.h"
|
||||
#else
|
||||
#include "core/resource.h"
|
||||
#endif
|
||||
|
||||
class VoxelChunk;
|
||||
|
||||
@ -43,10 +32,6 @@ class VoxelLevelGenerator : public Resource {
|
||||
public:
|
||||
void generate_chunk(Ref<VoxelChunk> chunk);
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
GDVIRTUAL1(_generate_chunk, Ref<VoxelChunk>);
|
||||
#endif
|
||||
|
||||
VoxelLevelGenerator();
|
||||
~VoxelLevelGenerator();
|
||||
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "voxel_level_generator.h"
|
||||
|
||||
class VoxelChunk;
|
||||
|
@ -47,7 +47,6 @@ bool VoxelLibrary::_supports_caching() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//Materials
|
||||
Ref<Material> VoxelLibrary::material_get(const int index) {
|
||||
ERR_FAIL_INDEX_V(index, _materials.size(), Ref<Material>());
|
||||
@ -103,11 +102,7 @@ void VoxelLibrary::material_set(const int index, const Ref<Material> &value) {
|
||||
}
|
||||
|
||||
void VoxelLibrary::material_remove(const int index) {
|
||||
#if VERSION_MAJOR <= 3
|
||||
_materials.remove(index);
|
||||
#else
|
||||
_materials.remove_at(index);
|
||||
#endif
|
||||
}
|
||||
|
||||
int VoxelLibrary::material_get_num() const {
|
||||
@ -174,7 +169,6 @@ void VoxelLibrary::liquid_material_cache_unref(const int key) {
|
||||
void VoxelLibrary::_liquid_material_cache_unref(const int key) {
|
||||
}
|
||||
|
||||
|
||||
void VoxelLibrary::liquid_material_add(const Ref<Material> &value) {
|
||||
ERR_FAIL_COND(!value.is_valid());
|
||||
|
||||
@ -188,11 +182,7 @@ void VoxelLibrary::liquid_material_set(const int index, const Ref<Material> &val
|
||||
}
|
||||
|
||||
void VoxelLibrary::liquid_material_remove(const int index) {
|
||||
#if VERSION_MAJOR <= 3
|
||||
_liquid_materials.remove(index);
|
||||
#else
|
||||
_liquid_materials.remove_at(index);
|
||||
#endif
|
||||
}
|
||||
|
||||
int VoxelLibrary::liquid_material_get_num() const {
|
||||
@ -259,7 +249,6 @@ void VoxelLibrary::prop_material_cache_unref(const int key) {
|
||||
void VoxelLibrary::_prop_material_cache_unref(const int key) {
|
||||
}
|
||||
|
||||
|
||||
void VoxelLibrary::prop_material_add(const Ref<Material> &value) {
|
||||
ERR_FAIL_COND(!value.is_valid());
|
||||
|
||||
@ -273,11 +262,7 @@ void VoxelLibrary::prop_material_set(const int index, const Ref<Material> &value
|
||||
}
|
||||
|
||||
void VoxelLibrary::prop_material_remove(const int index) {
|
||||
#if VERSION_MAJOR <= 3
|
||||
_prop_materials.remove(index);
|
||||
#else
|
||||
_prop_materials.remove_at(index);
|
||||
#endif
|
||||
}
|
||||
|
||||
int VoxelLibrary::prop_material_get_num() const {
|
||||
@ -357,13 +342,9 @@ void VoxelLibrary::refresh_rects() {
|
||||
}
|
||||
|
||||
void VoxelLibrary::setup_material_albedo(int material_index, Ref<Texture> texture) {
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_setup_material_albedo")) {
|
||||
call("_setup_material_albedo", material_index, texture);
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_setup_material_albedo, material_index, texture);
|
||||
#endif
|
||||
}
|
||||
|
||||
VoxelLibrary::VoxelLibrary() {
|
||||
@ -381,30 +362,16 @@ void VoxelLibrary::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_initialized", "value"), &VoxelLibrary::set_initialized);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "initialized", PROPERTY_HINT_NONE, "", 0), "set_initialized", "get_initialized");
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "ret"), "_supports_caching"));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_supports_caching);
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_supports_caching"), &VoxelLibrary::_supports_caching);
|
||||
ClassDB::bind_method(D_METHOD("supports_caching"), &VoxelLibrary::supports_caching);
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_setup_material_albedo", PropertyInfo(Variant::INT, "material_index"), PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture")));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_setup_material_albedo, "material_index", "texture");
|
||||
#endif
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_material_cache_get_key", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk")));
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "ret", PROPERTY_HINT_RESOURCE_TYPE, "TerrainMaterialCache"), "_material_cache_get", PropertyInfo(Variant::INT, "key")));
|
||||
BIND_VMETHOD(MethodInfo("_material_cache_unref", PropertyInfo(Variant::INT, "key")));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_material_cache_get_key, "chunk", "texture");
|
||||
GDVIRTUAL_BIND(_material_cache_get, "key");
|
||||
GDVIRTUAL_BIND(_material_cache_unref, "key");
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("material_get", "index"), &VoxelLibrary::material_get);
|
||||
ClassDB::bind_method(D_METHOD("material_lod_get", "index"), &VoxelLibrary::material_lod_get);
|
||||
@ -426,15 +393,9 @@ void VoxelLibrary::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("materials_set"), &VoxelLibrary::materials_set);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "materials_set", "materials_get");
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_liquid_material_cache_get_key", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk")));
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "ret", PROPERTY_HINT_RESOURCE_TYPE, "TerrainMaterialCache"), "_liquid_material_cache_get", PropertyInfo(Variant::INT, "key")));
|
||||
BIND_VMETHOD(MethodInfo("_liquid_material_cache_unref", PropertyInfo(Variant::INT, "key")));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_liquid_material_cache_get_key, "chunk", "texture");
|
||||
GDVIRTUAL_BIND(_liquid_material_cache_get, "key");
|
||||
GDVIRTUAL_BIND(_liquid_material_cache_unref, "key");
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("liquid_material_get", "index"), &VoxelLibrary::liquid_material_get);
|
||||
ClassDB::bind_method(D_METHOD("liquid_material_lod_get", "index"), &VoxelLibrary::liquid_material_lod_get);
|
||||
@ -456,15 +417,9 @@ void VoxelLibrary::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("liquid_materials_set"), &VoxelLibrary::liquid_materials_set);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "liquid_materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "liquid_materials_set", "liquid_materials_get");
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_prop_material_cache_get_key", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk")));
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "ret", PROPERTY_HINT_RESOURCE_TYPE, "TerrainMaterialCache"), "_prop_material_cache_get", PropertyInfo(Variant::INT, "key")));
|
||||
BIND_VMETHOD(MethodInfo("_prop_material_cache_unref", PropertyInfo(Variant::INT, "key")));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_prop_material_cache_get_key, "chunk", "texture");
|
||||
GDVIRTUAL_BIND(_prop_material_cache_get, "key");
|
||||
GDVIRTUAL_BIND(_prop_material_cache_unref, "key");
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("prop_material_get", "index"), &VoxelLibrary::prop_material_get);
|
||||
ClassDB::bind_method(D_METHOD("prop_material_lod_get", "index"), &VoxelLibrary::prop_material_lod_get);
|
||||
|
@ -22,16 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/io/resource.h"
|
||||
#else
|
||||
#include "core/resource.h"
|
||||
#endif
|
||||
|
||||
#include "core/math/rect2.h"
|
||||
#include "scene/resources/material.h"
|
||||
@ -41,10 +32,6 @@ SOFTWARE.
|
||||
|
||||
#include "../defines.h"
|
||||
|
||||
#if GODOT4
|
||||
#define Texture Texture2D
|
||||
#endif
|
||||
|
||||
class VoxelMaterialCache;
|
||||
class VoxelChunk;
|
||||
class VoxelSurface;
|
||||
@ -158,11 +145,6 @@ public:
|
||||
|
||||
void setup_material_albedo(int material_index, Ref<Texture> texture);
|
||||
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
GDVIRTUAL2(_setup_material_albedo, int, Ref<Texture>);
|
||||
#endif
|
||||
|
||||
VoxelLibrary();
|
||||
~VoxelLibrary();
|
||||
|
||||
@ -170,9 +152,9 @@ protected:
|
||||
static void _bind_methods();
|
||||
|
||||
bool _initialized;
|
||||
Vector<Ref<Material> > _materials;
|
||||
Vector<Ref<Material> > _liquid_materials;
|
||||
Vector<Ref<Material> > _prop_materials;
|
||||
Vector<Ref<Material>> _materials;
|
||||
Vector<Ref<Material>> _liquid_materials;
|
||||
Vector<Ref<Material>> _prop_materials;
|
||||
};
|
||||
|
||||
#endif // VOXEL_LIBRARY_H
|
||||
|
@ -207,11 +207,7 @@ Rect2 VoxelLibraryMerger::get_prop_uv_rect(const Ref<Texture> &texture) {
|
||||
return Rect2(0, 0, 1, 1);
|
||||
}
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
Ref<Image> image = tex->get_data();
|
||||
#else
|
||||
Ref<Image> image = tex->get_image();
|
||||
#endif
|
||||
|
||||
if (!image.is_valid()) {
|
||||
return Rect2(0, 0, 1, 1);
|
||||
@ -371,11 +367,7 @@ void VoxelLibraryMerger::_setup_material_albedo(const int material_index, const
|
||||
VoxelLibraryMerger::VoxelLibraryMerger() {
|
||||
_packer.INSTANCE();
|
||||
|
||||
#if GODOT4
|
||||
#warning implement
|
||||
#else
|
||||
_packer->set_texture_flags(Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER);
|
||||
#endif
|
||||
|
||||
_packer->set_max_atlas_size(1024);
|
||||
_packer->set_keep_original_atlases(false);
|
||||
@ -383,11 +375,7 @@ VoxelLibraryMerger::VoxelLibraryMerger() {
|
||||
|
||||
_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);
|
||||
|
@ -22,18 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/io/resource.h"
|
||||
#include "core/templates/map.h"
|
||||
#else
|
||||
#include "core/resource.h"
|
||||
#include "core/map.h"
|
||||
#endif
|
||||
|
||||
#include "voxel_library.h"
|
||||
|
||||
|
@ -710,11 +710,7 @@ void VoxelLibraryMergerPCM::_setup_material_albedo(const int material_index, con
|
||||
VoxelLibraryMergerPCM::VoxelLibraryMergerPCM() {
|
||||
_packer.instance();
|
||||
|
||||
#if GODOT4
|
||||
#warning implement
|
||||
#else
|
||||
_packer->set_texture_flags(Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER);
|
||||
#endif
|
||||
|
||||
_packer->set_max_atlas_size(1024);
|
||||
_packer->set_keep_original_atlases(false);
|
||||
@ -722,11 +718,7 @@ VoxelLibraryMergerPCM::VoxelLibraryMergerPCM() {
|
||||
|
||||
_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);
|
||||
|
@ -22,18 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/io/resource.h"
|
||||
#include "core/templates/map.h"
|
||||
#else
|
||||
#include "core/resource.h"
|
||||
#include "core/map.h"
|
||||
#endif
|
||||
#include "core/resource.h"
|
||||
|
||||
#include "voxel_library.h"
|
||||
|
||||
@ -123,12 +113,12 @@ protected:
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
Map<int, Ref<VoxelMaterialCachePCM> > _material_cache;
|
||||
Map<int, Ref<VoxelMaterialCachePCM> > _prop_material_cache;
|
||||
Map<int, Ref<VoxelMaterialCachePCM>> _material_cache;
|
||||
Map<int, Ref<VoxelMaterialCachePCM>> _prop_material_cache;
|
||||
|
||||
Vector<Ref<VoxelSurfaceMerger> > _voxel_surfaces;
|
||||
Vector<Ref<VoxelSurfaceMerger>> _voxel_surfaces;
|
||||
#ifdef PROPS_PRESENT
|
||||
Vector<Ref<PropData> > _props;
|
||||
Vector<Ref<PropData>> _props;
|
||||
#endif
|
||||
|
||||
//todo remove these
|
||||
|
@ -22,19 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/object/ref_counted.h"
|
||||
#ifndef Reference
|
||||
#define Reference RefCounted
|
||||
#endif
|
||||
#else
|
||||
#include "core/resource.h"
|
||||
#endif
|
||||
|
||||
#include "voxel_library.h"
|
||||
|
||||
@ -74,7 +62,7 @@ public:
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
Vector<Ref<VoxelSurfaceSimple> > _voxel_surfaces;
|
||||
Vector<Ref<VoxelSurfaceSimple>> _voxel_surfaces;
|
||||
|
||||
//atlas
|
||||
int _atlas_columns;
|
||||
|
@ -256,13 +256,9 @@ void VoxelMaterialCache::refresh_rects() {
|
||||
}
|
||||
|
||||
void VoxelMaterialCache::setup_material_albedo(Ref<Texture> texture) {
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_setup_material_albedo")) {
|
||||
call("_setup_material_albedo", texture);
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_setup_material_albedo, texture);
|
||||
#endif
|
||||
}
|
||||
|
||||
VoxelMaterialCache::VoxelMaterialCache() {
|
||||
@ -286,11 +282,7 @@ void VoxelMaterialCache::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("inc_ref_count"), &VoxelMaterialCache::inc_ref_count);
|
||||
ClassDB::bind_method(D_METHOD("dec_ref_count"), &VoxelMaterialCache::dec_ref_count);
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_setup_material_albedo", PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture")));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_setup_material_albedo, "texture");
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("material_get", "index"), &VoxelMaterialCache::material_get);
|
||||
ClassDB::bind_method(D_METHOD("material_lod_get", "index"), &VoxelMaterialCache::material_lod_get);
|
||||
|
@ -22,20 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/io/resource.h"
|
||||
#include "core/math/color.h"
|
||||
#include "core/templates/vector.h"
|
||||
#else
|
||||
#include "core/color.h"
|
||||
#include "core/resource.h"
|
||||
#include "core/vector.h"
|
||||
#endif
|
||||
|
||||
#include "core/math/rect2.h"
|
||||
#include "scene/resources/material.h"
|
||||
@ -96,10 +85,6 @@ public:
|
||||
|
||||
void setup_material_albedo(Ref<Texture> texture);
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
GDVIRTUAL1(_setup_material_albedo, Ref<Texture>);
|
||||
#endif
|
||||
|
||||
VoxelMaterialCache();
|
||||
~VoxelMaterialCache();
|
||||
|
||||
|
@ -22,22 +22,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "voxel_material_cache.h"
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/io/resource.h"
|
||||
#include "core/math/color.h"
|
||||
#include "core/templates/vector.h"
|
||||
#else
|
||||
#include "core/color.h"
|
||||
#include "core/resource.h"
|
||||
#include "core/vector.h"
|
||||
#endif
|
||||
|
||||
#include "core/math/rect2.h"
|
||||
#include "scene/resources/material.h"
|
||||
|
@ -22,21 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/io/resource.h"
|
||||
#include "core/templates/vector.h"
|
||||
#include "core/math/color.h"
|
||||
#else
|
||||
#include "core/color.h"
|
||||
#include "core/resource.h"
|
||||
#include "core/vector.h"
|
||||
#include "core/color.h"
|
||||
#endif
|
||||
|
||||
#include "core/math/rect2.h"
|
||||
#include "scene/resources/material.h"
|
||||
@ -57,9 +45,9 @@ public:
|
||||
I_____I/
|
||||
|
||||
|
||||
I y
|
||||
I I
|
||||
O----- x I B
|
||||
I y
|
||||
I I
|
||||
O----- x I B
|
||||
/ I F I /
|
||||
/ z+ I ---I/
|
||||
*/
|
||||
|
@ -24,12 +24,6 @@ SOFTWARE.
|
||||
|
||||
#include "voxel_library_merger.h"
|
||||
|
||||
#include "../defines.h"
|
||||
|
||||
#if GODOT4
|
||||
#define Texture Texture2D
|
||||
#endif
|
||||
|
||||
Ref<AtlasTexture> VoxelSurfaceMerger::get_region(const VoxelSurfaceSides side) {
|
||||
return _regions[side];
|
||||
}
|
||||
|
@ -22,21 +22,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "voxel_surface.h"
|
||||
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
#include "../../texture_packer/texture_packer.h"
|
||||
|
||||
#include "../defines.h"
|
||||
|
||||
#if GODOT4
|
||||
#define Texture Texture2D
|
||||
#endif
|
||||
|
||||
class VoxelSurfaceMerger : public VoxelSurface {
|
||||
GDCLASS(VoxelSurfaceMerger, VoxelSurface)
|
||||
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "voxel_surface.h"
|
||||
|
||||
class VoxelSurfaceSimple : public VoxelSurface {
|
||||
|
@ -22,16 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/math/color.h"
|
||||
#else
|
||||
#include "core/color.h"
|
||||
#endif
|
||||
|
||||
#include "core/math/vector2.h"
|
||||
#include "core/math/vector3.h"
|
||||
|
@ -22,16 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/math/color.h"
|
||||
#else
|
||||
#include "core/color.h"
|
||||
#endif
|
||||
|
||||
#include "core/math/vector2.h"
|
||||
#include "core/math/vector3.h"
|
||||
|
@ -815,7 +815,6 @@ VoxelCubePoints::~VoxelCubePoints() {
|
||||
}
|
||||
|
||||
void VoxelCubePoints::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_x"), &VoxelCubePoints::get_x);
|
||||
ClassDB::bind_method(D_METHOD("set_x", "value"), &VoxelCubePoints::set_x);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "x"), "set_x", "get_x");
|
||||
|
@ -22,21 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/object/ref_counted.h"
|
||||
#ifndef Reference
|
||||
#define Reference RefCounted
|
||||
#endif
|
||||
#include "core/templates/vector.h"
|
||||
#else
|
||||
#include "core/reference.h"
|
||||
#include "core/vector.h"
|
||||
#endif
|
||||
|
||||
class VoxelChunk;
|
||||
class SubVoxelFacePointsHelper;
|
||||
|
@ -22,16 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/math/color.h"
|
||||
#else
|
||||
#include "core/color.h"
|
||||
#endif
|
||||
|
||||
#include "core/math/vector2.h"
|
||||
#include "core/math/vector3.h"
|
||||
|
@ -22,16 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/math/color.h"
|
||||
#else
|
||||
#include "core/color.h"
|
||||
#endif
|
||||
|
||||
#include "core/math/vector2.h"
|
||||
#include "core/math/vector3.h"
|
||||
|
@ -22,20 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/object/ref_counted.h"
|
||||
#ifndef Reference
|
||||
#define Reference RefCounted
|
||||
#endif
|
||||
#else
|
||||
#include "core/reference.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include "marching_cubes_tables.h"
|
||||
|
||||
|
@ -34,9 +34,6 @@
|
||||
//
|
||||
//================================================================================
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/math/vector3.h"
|
||||
|
||||
namespace MarchingCubes {
|
||||
|
@ -20,15 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/variant/array.h"
|
||||
#include "core/variant/dictionary.h"
|
||||
#else
|
||||
#include "core/array.h"
|
||||
#include "core/dictionary.h"
|
||||
#endif
|
||||
|
||||
#include "voxel_mesher_marching_cubes.h"
|
||||
|
||||
@ -39,13 +32,7 @@ SOFTWARE.
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
#include "servers/visual_server.h"
|
||||
#else
|
||||
#include "servers/rendering_server.h"
|
||||
|
||||
typedef class RenderingServer VisualServer;
|
||||
#endif
|
||||
|
||||
void VoxelMesherMarchingCubes::get_voxel_type_array(int *arr, Ref<VoxelChunk> chunk, const int x, const int y, const int z, const int size) {
|
||||
uint8_t *channel_type = chunk->channel_get(_channel_index_type);
|
||||
|
@ -22,19 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/object/ref_counted.h"
|
||||
#ifndef Reference
|
||||
#define Reference RefCounted
|
||||
#endif
|
||||
#else
|
||||
#include "core/reference.h"
|
||||
#endif
|
||||
|
||||
#include "../default/voxel_mesher_default.h"
|
||||
#include "marching_cubes_cell_data.h"
|
||||
|
@ -350,11 +350,7 @@ void VoxelMesher::remove_doubles() {
|
||||
for (int j = 0; j < indices.size(); ++j) {
|
||||
int index = indices[j];
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
_vertices.remove(index);
|
||||
#else
|
||||
_vertices.remove_at(index);
|
||||
#endif
|
||||
|
||||
//make all indices that were bigger than the one we replaced one lower
|
||||
for (int k = 0; k < _indices.size(); ++k) {
|
||||
@ -406,13 +402,8 @@ void VoxelMesher::remove_doubles_hashed() {
|
||||
for (int j = 0; j < indices.size(); ++j) {
|
||||
int index = indices[j];
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
hashes.remove(index);
|
||||
_vertices.remove(index);
|
||||
#else
|
||||
hashes.remove_at(index);
|
||||
_vertices.remove_at(index);
|
||||
#endif
|
||||
|
||||
//make all indices that were bigger than the one we replaced one lower
|
||||
for (int k = 0; k < _indices.size(); ++k) {
|
||||
@ -753,11 +744,7 @@ Vector3 VoxelMesher::get_vertex(const int idx) const {
|
||||
}
|
||||
|
||||
void VoxelMesher::remove_vertex(const int idx) {
|
||||
#if VERSION_MAJOR < 4
|
||||
_vertices.remove(idx);
|
||||
#else
|
||||
_vertices.remove_at(idx);
|
||||
#endif
|
||||
}
|
||||
|
||||
PoolVector<Vector3> VoxelMesher::get_normals() const {
|
||||
@ -905,11 +892,7 @@ int VoxelMesher::get_index(const int idx) const {
|
||||
}
|
||||
|
||||
void VoxelMesher::remove_index(const int idx) {
|
||||
#if VERSION_MAJOR < 4
|
||||
_indices.remove(idx);
|
||||
#else
|
||||
_indices.remove_at(idx);
|
||||
#endif
|
||||
}
|
||||
|
||||
VoxelMesher::VoxelMesher(const Ref<VoxelLibrary> &library) {
|
||||
@ -948,15 +931,9 @@ VoxelMesher::~VoxelMesher() {
|
||||
}
|
||||
|
||||
void VoxelMesher::_bind_methods() {
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_add_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk")));
|
||||
BIND_VMETHOD(MethodInfo("_bake_colors", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk")));
|
||||
BIND_VMETHOD(MethodInfo("_bake_liquid_colors", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk")));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_add_chunk, "chunk");
|
||||
GDVIRTUAL_BIND(_bake_colors, "chunk");
|
||||
GDVIRTUAL_BIND(_bake_liquid_colors, "chunk");
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_channel_index_type"), &VoxelMesher::get_channel_index_type);
|
||||
ClassDB::bind_method(D_METHOD("set_channel_index_type", "value"), &VoxelMesher::set_channel_index_type);
|
||||
@ -1014,11 +991,7 @@ void VoxelMesher::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform_colored", "mesh", "transform", "colors", "uv_rect"), &VoxelMesher::add_mesh_data_resource_transform_colored, DEFVAL(Rect2(0, 0, 1, 1)));
|
||||
#endif
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_add_mesher", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "VoxelMesher")));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_add_mesher, "mesher");
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("add_mesher", "mesher"), &VoxelMesher::add_mesher);
|
||||
ClassDB::bind_method(D_METHOD("_add_mesher", "mesher"), &VoxelMesher::_add_mesher);
|
||||
|
@ -22,23 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/object/ref_counted.h"
|
||||
#ifndef Reference
|
||||
#define Reference RefCounted
|
||||
#endif
|
||||
#include "core/templates/vector.h"
|
||||
#include "core/math/color.h"
|
||||
#else
|
||||
#include "core/color.h"
|
||||
#include "core/reference.h"
|
||||
#include "core/vector.h"
|
||||
#include "core/color.h"
|
||||
#endif
|
||||
|
||||
#include "../defines.h"
|
||||
|
||||
@ -71,7 +57,6 @@ class VoxelMesher : public Reference {
|
||||
|
||||
public:
|
||||
struct Vertex {
|
||||
|
||||
Vector3 vertex;
|
||||
Color color;
|
||||
Vector3 normal; // normal, binormal, tangent
|
||||
@ -154,7 +139,7 @@ public:
|
||||
|
||||
PoolVector<Vector3> build_collider() const;
|
||||
|
||||
void bake_lights(MeshInstance *node, Vector<Ref<VoxelLight> > &lights);
|
||||
void bake_lights(MeshInstance *node, Vector<Ref<VoxelLight>> &lights);
|
||||
|
||||
Array build_mesh();
|
||||
void build_mesh_into(RID mesh);
|
||||
@ -197,13 +182,6 @@ public:
|
||||
void remove_index(const int idx);
|
||||
void add_indices(const int index);
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
GDVIRTUAL1(_add_chunk, Ref<VoxelChunk>);
|
||||
GDVIRTUAL1(_bake_colors, Ref<VoxelChunk>);
|
||||
GDVIRTUAL1(_bake_liquid_colors, Ref<VoxelChunk>);
|
||||
GDVIRTUAL1(_add_mesher, Ref<VoxelMesher>);
|
||||
#endif
|
||||
|
||||
VoxelMesher(const Ref<VoxelLibrary> &library);
|
||||
VoxelMesher();
|
||||
~VoxelMesher();
|
||||
|
@ -27,13 +27,7 @@ SOFTWARE.
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
#include "scene/3d/spatial.h"
|
||||
#else
|
||||
#include "scene/3d/node_3d.h"
|
||||
|
||||
#define Spatial Node3D
|
||||
#endif
|
||||
|
||||
#include "core/math/vector3.h"
|
||||
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "../default/voxel_chunk_default.h"
|
||||
|
||||
class VoxelChunkBlocky : public VoxelChunkDefault {
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "../default/voxel_world_default.h"
|
||||
|
||||
class VoxelWorldBlocky : public VoxelWorldDefault {
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "../default/voxel_chunk_default.h"
|
||||
|
||||
class VoxelChunkCubic : public VoxelChunkDefault {
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "../default/voxel_world_default.h"
|
||||
|
||||
class VoxelWorldCubic : public VoxelWorldDefault {
|
||||
|
@ -123,13 +123,8 @@ RID VoxelChunkDefault::mesh_rid_get(const int mesh_index, const int mesh_type_in
|
||||
|
||||
Variant v = m[mesh_type_index];
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
if (v.get_type() != Variant::RID)
|
||||
return RID();
|
||||
#else
|
||||
if (v.get_type() != Variant::_RID)
|
||||
return RID();
|
||||
#endif
|
||||
|
||||
return v;
|
||||
}
|
||||
@ -147,11 +142,7 @@ void VoxelChunkDefault::mesh_rid_set(const int mesh_index, const int mesh_type_i
|
||||
|
||||
Variant v = m[mesh_type_index];
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
ERR_FAIL_COND(v.get_type() != Variant::RID);
|
||||
#else
|
||||
ERR_FAIL_COND(v.get_type() != Variant::_RID);
|
||||
#endif
|
||||
|
||||
m[mesh_type_index] = value;
|
||||
_rids[mesh_index] = m;
|
||||
@ -379,12 +370,7 @@ void VoxelChunkDefault::colliders_create(const int mesh_index, const int layer_m
|
||||
ERR_FAIL_COND(m.has(MESH_TYPE_INDEX_SHAPE));
|
||||
|
||||
RID shape_rid = PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CONCAVE_POLYGON);
|
||||
#if VERSION_MAJOR < 4
|
||||
RID body_rid = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC);
|
||||
#else
|
||||
RID body_rid = PhysicsServer::get_singleton()->body_create();
|
||||
PhysicsServer::get_singleton()->body_set_mode(body_rid, PhysicsServer::BODY_MODE_STATIC);
|
||||
#endif
|
||||
|
||||
PhysicsServer::get_singleton()->body_set_collision_layer(body_rid, layer_mask);
|
||||
PhysicsServer::get_singleton()->body_set_collision_mask(body_rid, layer_mask);
|
||||
@ -839,11 +825,7 @@ void VoxelChunkDefault::_world_light_removed(const Ref<VoxelLight> &light) {
|
||||
int index = _lights.find(light);
|
||||
|
||||
if (index != -1) {
|
||||
#if VERSION_MAJOR < 4
|
||||
_lights.remove(index);
|
||||
#else
|
||||
_lights.remove_at(index);
|
||||
#endif
|
||||
|
||||
set_lights_dirty(true);
|
||||
}
|
||||
|
@ -22,21 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/string/ustring.h"
|
||||
#include "core/config/engine.h"
|
||||
#include "core/variant/array.h"
|
||||
#else
|
||||
#include "core/ustring.h"
|
||||
#include "core/engine.h"
|
||||
#include "core/array.h"
|
||||
#endif
|
||||
|
||||
#include "core/engine.h"
|
||||
#include "core/ustring.h"
|
||||
|
||||
#include "../voxel_chunk.h"
|
||||
|
||||
@ -46,12 +34,12 @@ SOFTWARE.
|
||||
#include "core/os/thread.h"
|
||||
#include "core/os/thread_safe.h"
|
||||
|
||||
#include "scene/resources/packed_scene.h"
|
||||
#include "../voxel_world.h"
|
||||
#include "../../data/voxel_light.h"
|
||||
#include "../../meshers/voxel_mesher.h"
|
||||
#include "../../library/voxel_surface.h"
|
||||
#include "../../library/voxel_library.h"
|
||||
#include "../../library/voxel_surface.h"
|
||||
#include "../../meshers/voxel_mesher.h"
|
||||
#include "../voxel_world.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
|
||||
class VoxelWorld;
|
||||
class VoxelJob;
|
||||
@ -224,7 +212,7 @@ protected:
|
||||
RID _debug_mesh_instance;
|
||||
PoolVector3Array _debug_mesh_array;
|
||||
|
||||
Vector<Ref<VoxelLight> > _lights;
|
||||
Vector<Ref<VoxelLight>> _lights;
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(VoxelChunkDefault::DefaultChannels);
|
||||
|
@ -75,11 +75,7 @@ void VoxelWorldDefault::set_num_lods(const int value) {
|
||||
}
|
||||
|
||||
void VoxelWorldDefault::update_lods() {
|
||||
#if VERSION_MAJOR < 4
|
||||
call("_update_lods");
|
||||
#else
|
||||
GDVIRTUAL_CALL(_update_lods);
|
||||
#endif
|
||||
}
|
||||
|
||||
int VoxelWorldDefault::get_chunk_lod_falloff() const {
|
||||
@ -362,11 +358,7 @@ void VoxelWorldDefault::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_num_lods", "value"), &VoxelWorldDefault::set_num_lods);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "num_lods"), "set_num_lods", "get_num_lods");
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_update_lods"));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_update_lods);
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("update_lods"), &VoxelWorldDefault::update_lods);
|
||||
ClassDB::bind_method(D_METHOD("_update_lods"), &VoxelWorldDefault::_update_lods);
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "../voxel_world.h"
|
||||
|
||||
class VoxelWorldDefault : public VoxelWorld {
|
||||
@ -50,10 +47,6 @@ public:
|
||||
|
||||
PoolColorArray get_vertex_colors(const Transform &transform, const PoolVector3Array &vertices, const float base_light_value = 0.45, const float ao_strength = 0.2);
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
GDVIRTUAL0(_update_lods);
|
||||
#endif
|
||||
|
||||
VoxelWorldDefault();
|
||||
~VoxelWorldDefault();
|
||||
|
||||
|
@ -64,11 +64,7 @@ void EnvironmentData::set_indirect_energy(const int index, const float value) {
|
||||
|
||||
void EnvironmentData::setup(WorldEnvironment *world_environment, DirectionalLight *primary_light, DirectionalLight *secondary_light) {
|
||||
if (has_method("_setup")) {
|
||||
#if VERSION_MAJOR < 4
|
||||
call("_setup", world_environment, primary_light, secondary_light);
|
||||
#else
|
||||
GDVIRTUAL_CALL(_setup, world_environment, primary_light, secondary_light);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
void EnvironmentData::setup_bind(Node *world_environment, Node *primary_light, Node *secondary_light) {
|
||||
@ -91,11 +87,7 @@ EnvironmentData::~EnvironmentData() {
|
||||
}
|
||||
|
||||
void EnvironmentData::_bind_methods() {
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_setup", PropertyInfo(Variant::OBJECT, "world_environment", PROPERTY_HINT_RESOURCE_TYPE, "WorldEnvironment"), PropertyInfo(Variant::OBJECT, "primary_light", PROPERTY_HINT_RESOURCE_TYPE, "DirectionalLight"), PropertyInfo(Variant::OBJECT, "secondary_light", PROPERTY_HINT_RESOURCE_TYPE, "DirectionalLight")));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_setup, "world_environment", "primary_light", "secondary_light");
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_environment"), &EnvironmentData::get_environment);
|
||||
ClassDB::bind_method(D_METHOD("set_environment", "value"), &EnvironmentData::set_environment);
|
||||
|
@ -22,18 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/io/resource.h"
|
||||
#include "core/math/color.h"
|
||||
#else
|
||||
#include "core/resource.h"
|
||||
#include "core/color.h"
|
||||
#endif
|
||||
|
||||
#include "../defines.h"
|
||||
|
||||
@ -63,10 +53,6 @@ public:
|
||||
void setup(WorldEnvironment *world_environment, DirectionalLight *primary_light, DirectionalLight *secondary_light);
|
||||
void setup_bind(Node *world_environment, Node *primary_light, Node *secondary_light);
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
GDVIRTUAL3(_setup, WorldEnvironment*, DirectionalLight*, DirectionalLight*);
|
||||
#endif
|
||||
|
||||
EnvironmentData();
|
||||
~EnvironmentData();
|
||||
|
||||
|
@ -64,11 +64,7 @@ void VoxelJob::next_job() {
|
||||
}
|
||||
|
||||
void VoxelJob::reset() {
|
||||
#if VERSION_MAJOR < 4
|
||||
call("_reset");
|
||||
#else
|
||||
GDVIRTUAL_CALL(_reset);
|
||||
#endif
|
||||
}
|
||||
void VoxelJob::_reset() {
|
||||
_build_done = false;
|
||||
@ -88,11 +84,7 @@ void VoxelJob::_execute() {
|
||||
}
|
||||
|
||||
void VoxelJob::execute_phase() {
|
||||
#if VERSION_MAJOR < 4
|
||||
call("_execute_phase");
|
||||
#else
|
||||
GDVIRTUAL_CALL(_execute_phase);
|
||||
#endif
|
||||
}
|
||||
|
||||
void VoxelJob::_execute_phase() {
|
||||
@ -100,22 +92,14 @@ void VoxelJob::_execute_phase() {
|
||||
}
|
||||
|
||||
void VoxelJob::process(const float delta) {
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_process")) {
|
||||
call("_process", delta);
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_process, delta);
|
||||
#endif
|
||||
}
|
||||
void VoxelJob::physics_process(const float delta) {
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_physics_process")) {
|
||||
call("_physics_process", delta);
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_physics_process, delta);
|
||||
#endif
|
||||
}
|
||||
|
||||
//Data Management functions
|
||||
@ -273,11 +257,7 @@ Array VoxelJob::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const float mul_
|
||||
ERR_FAIL_COND_V(arr.size() != VisualServer::ARRAY_MAX, arr);
|
||||
ERR_FAIL_COND_V(!tex.is_valid(), arr);
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
Ref<Image> img = tex->get_data();
|
||||
#else
|
||||
Ref<Image> img = tex->get_image();
|
||||
#endif
|
||||
|
||||
ERR_FAIL_COND_V(!img.is_valid(), arr);
|
||||
|
||||
@ -289,9 +269,7 @@ Array VoxelJob::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const float mul_
|
||||
if (colors.size() < uvs.size())
|
||||
colors.resize(uvs.size());
|
||||
|
||||
#if !GODOT4
|
||||
img->lock();
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < uvs.size(); ++i) {
|
||||
Vector2 uv = uvs[i];
|
||||
@ -305,9 +283,7 @@ Array VoxelJob::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const float mul_
|
||||
colors.set(i, colors[i] * c * mul_color);
|
||||
}
|
||||
|
||||
#if !GODOT4
|
||||
img->unlock();
|
||||
#endif
|
||||
|
||||
arr[VisualServer::ARRAY_COLOR] = colors;
|
||||
|
||||
@ -348,13 +324,8 @@ VoxelJob::~VoxelJob() {
|
||||
}
|
||||
|
||||
void VoxelJob::_bind_methods() {
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_process", PropertyInfo(Variant::REAL, "delta")));
|
||||
BIND_VMETHOD(MethodInfo("_physics_process", PropertyInfo(Variant::REAL, "delta")));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_process, "delta");
|
||||
GDVIRTUAL_BIND(_physics_process, "delta");
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_build_phase_type"), &VoxelJob::get_build_phase_type);
|
||||
ClassDB::bind_method(D_METHOD("set_build_phase_type", "value"), &VoxelJob::set_build_phase_type);
|
||||
@ -371,22 +342,14 @@ void VoxelJob::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("next_job"), &VoxelJob::next_job);
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_reset"));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_reset);
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("reset"), &VoxelJob::reset);
|
||||
ClassDB::bind_method(D_METHOD("_reset"), &VoxelJob::_reset);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_execute"), &VoxelJob::_execute);
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_execute_phase"));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_execute_phase);
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("execute_phase"), &VoxelJob::execute_phase);
|
||||
ClassDB::bind_method(D_METHOD("_execute_phase"), &VoxelJob::_execute_phase);
|
||||
@ -418,11 +381,7 @@ void VoxelJob::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("should_do", "just_check"), &VoxelJob::should_do, DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("should_return"), &VoxelJob::should_return);
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_execute"));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_execute);
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("execute"), &VoxelJob::execute);
|
||||
|
||||
@ -495,11 +454,7 @@ bool VoxelJob::should_return() {
|
||||
void VoxelJob::execute() {
|
||||
ERR_FAIL_COND(!has_method("_execute"));
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
call("_execute");
|
||||
#else
|
||||
GDVIRTUAL_CALL(_execute);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -22,34 +22,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
#if THREAD_POOL_PRESENT
|
||||
#include "../../../thread_pool/thread_pool_job.h"
|
||||
#else
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/object/ref_counted.h"
|
||||
#ifndef Reference
|
||||
#define Reference RefCounted
|
||||
#endif
|
||||
#else
|
||||
#include "core/reference.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include "../../defines.h"
|
||||
|
||||
#if GODOT4
|
||||
#define Texture Texture2D
|
||||
#endif
|
||||
|
||||
class VoxelChunk;
|
||||
|
||||
#if THREAD_POOL_PRESENT
|
||||
@ -102,14 +84,6 @@ public:
|
||||
|
||||
void chunk_exit_tree();
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
GDVIRTUAL1(_process, float);
|
||||
GDVIRTUAL1(_physics_process, float);
|
||||
|
||||
GDVIRTUAL0(_reset);
|
||||
GDVIRTUAL0(_execute_phase);
|
||||
#endif
|
||||
|
||||
VoxelJob();
|
||||
~VoxelJob();
|
||||
|
||||
@ -151,10 +125,6 @@ public:
|
||||
|
||||
void execute();
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
GDVIRTUAL0(_execute);
|
||||
#endif
|
||||
|
||||
private:
|
||||
bool _complete;
|
||||
bool _cancelled;
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "voxel_job.h"
|
||||
|
||||
class VoxelMesher;
|
||||
|
@ -22,19 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/object/ref_counted.h"
|
||||
#ifndef Reference
|
||||
#define Reference RefCounted
|
||||
#endif
|
||||
#else
|
||||
#include "core/reference.h"
|
||||
#endif
|
||||
|
||||
#ifdef MESH_UTILS_PRESENT
|
||||
#include "../../../mesh_utils/fast_quadratic_mesh_simplifier.h"
|
||||
@ -66,19 +56,19 @@ public:
|
||||
int get_lod_index() const;
|
||||
void set_lod_index(const int value);
|
||||
|
||||
#ifdef MESH_UTILS_PRESENT
|
||||
Ref<FastQuadraticMeshSimplifier> get_fqms();
|
||||
void set_fqms(const Ref<FastQuadraticMeshSimplifier> &val);
|
||||
#ifdef MESH_UTILS_PRESENT
|
||||
Ref<FastQuadraticMeshSimplifier> get_fqms();
|
||||
void set_fqms(const Ref<FastQuadraticMeshSimplifier> &val);
|
||||
|
||||
float get_simplification_step_ratio() const;
|
||||
void set_simplification_step_ratio(const float value);
|
||||
float get_simplification_step_ratio() const;
|
||||
void set_simplification_step_ratio(const float value);
|
||||
|
||||
int get_simplification_steps() const;
|
||||
void set_simplification_steps(const int value);
|
||||
int get_simplification_steps() const;
|
||||
void set_simplification_steps(const int value);
|
||||
|
||||
float get_simplification_agressiveness() const;
|
||||
void set_simplification_agressiveness(const float value);
|
||||
#endif
|
||||
float get_simplification_agressiveness() const;
|
||||
void set_simplification_agressiveness(const float value);
|
||||
#endif
|
||||
|
||||
VoxelMesherJobStep();
|
||||
~VoxelMesherJobStep();
|
||||
@ -89,12 +79,12 @@ protected:
|
||||
VoxelMesherJobStepType _job_type;
|
||||
int _lod_index;
|
||||
|
||||
#ifdef MESH_UTILS_PRESENT
|
||||
Ref<FastQuadraticMeshSimplifier> _fqms;
|
||||
float _simplification_step_ratio;
|
||||
int _simplification_steps;
|
||||
float _simplification_agressiveness;
|
||||
#endif
|
||||
#ifdef MESH_UTILS_PRESENT
|
||||
Ref<FastQuadraticMeshSimplifier> _fqms;
|
||||
float _simplification_step_ratio;
|
||||
int _simplification_steps;
|
||||
float _simplification_agressiveness;
|
||||
#endif
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(VoxelMesherJobStep::VoxelMesherJobStepType);
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "voxel_job.h"
|
||||
|
||||
#include "voxel_mesher_job_step.h"
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "voxel_job.h"
|
||||
|
||||
#include "../../defines.h"
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "../default/voxel_chunk_default.h"
|
||||
|
||||
class VoxelChunkMarchingCubes : public VoxelChunkDefault {
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "../default/voxel_world_default.h"
|
||||
|
||||
class VoxelWorldMarchingCubes : public VoxelWorldDefault {
|
||||
|
@ -273,11 +273,7 @@ void VoxelChunk::job_set(int index, const Ref<VoxelJob> &job) {
|
||||
void VoxelChunk::job_remove(const int index) {
|
||||
ERR_FAIL_INDEX(index, _jobs.size());
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
_jobs.remove(index);
|
||||
#else
|
||||
_jobs.remove_at(index);
|
||||
#endif
|
||||
}
|
||||
void VoxelChunk::job_add(const Ref<VoxelJob> &job) {
|
||||
_jobs.push_back(job);
|
||||
@ -331,13 +327,9 @@ Ref<VoxelJob> VoxelChunk::job_get_current() {
|
||||
|
||||
//Voxel Data
|
||||
void VoxelChunk::channel_setup() {
|
||||
#if VERSION_MAJOR < 4
|
||||
ERR_FAIL_COND_MSG(!has_method("_channel_setup"), "VoxelChunk: _setup_channels() is missing! Please implement it!");
|
||||
|
||||
call("_channel_setup");
|
||||
#else
|
||||
GDVIRTUAL_CALL(_channel_setup);
|
||||
#endif
|
||||
}
|
||||
|
||||
void VoxelChunk::set_size(const int size_x, const int size_y, const int size_z, const int margin_start, const int margin_end) {
|
||||
@ -635,21 +627,13 @@ void VoxelChunk::voxel_structure_remove(const Ref<VoxelStructure> &structure) {
|
||||
int index = _voxel_structures.find(structure);
|
||||
|
||||
if (index != -1) {
|
||||
#if VERSION_MAJOR < 4
|
||||
_voxel_structures.remove(index);
|
||||
#else
|
||||
_voxel_structures.remove_at(index);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
void VoxelChunk::voxel_structure_remove_index(const int index) {
|
||||
ERR_FAIL_INDEX(index, _voxel_structures.size());
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
_voxel_structures.remove(index);
|
||||
#else
|
||||
_voxel_structures.remove_at(index);
|
||||
#endif
|
||||
}
|
||||
void VoxelChunk::voxel_structure_clear() {
|
||||
_voxel_structures.clear();
|
||||
@ -685,11 +669,7 @@ void VoxelChunk::build() {
|
||||
ERR_FAIL_COND(!get_voxel_world()->is_inside_tree());
|
||||
ERR_FAIL_COND(!is_in_tree());
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
call("_build");
|
||||
#else
|
||||
GDVIRTUAL_CALL(_build);
|
||||
#endif
|
||||
}
|
||||
|
||||
void VoxelChunk::_build() {
|
||||
@ -710,44 +690,28 @@ void VoxelChunk::clear() {
|
||||
}
|
||||
|
||||
void VoxelChunk::finalize_build() {
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_finalize_build")) {
|
||||
call("_finalize_build");
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_finalize_build);
|
||||
#endif
|
||||
}
|
||||
|
||||
void VoxelChunk::bake_lights() {
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_bake_lights")) {
|
||||
call("_bake_lights");
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_bake_lights);
|
||||
#endif
|
||||
}
|
||||
void VoxelChunk::bake_light(Ref<VoxelLight> light) {
|
||||
if (!light.is_valid())
|
||||
return;
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_bake_light")) {
|
||||
call("_bake_light", light);
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_bake_light, light);
|
||||
#endif
|
||||
}
|
||||
void VoxelChunk::clear_baked_lights() {
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_clear_baked_lights")) {
|
||||
call("_clear_baked_lights");
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_clear_baked_lights);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if PROPS_PRESENT
|
||||
@ -776,11 +740,7 @@ int VoxelChunk::prop_get_count() const {
|
||||
void VoxelChunk::prop_remove(const int index) {
|
||||
ERR_FAIL_INDEX(index, _props.size());
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
_props.remove(index);
|
||||
#else
|
||||
_props.remove_at(index);
|
||||
#endif
|
||||
}
|
||||
void VoxelChunk::props_clear() {
|
||||
_props.clear();
|
||||
@ -822,13 +782,9 @@ int VoxelChunk::mesh_data_resource_addv(const Vector3 &local_data_pos, const Ref
|
||||
|
||||
_mesh_data_resources.push_back(e);
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_mesh_data_resource_added")) {
|
||||
call("_mesh_data_resource_added", index);
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_mesh_data_resource_added, index);
|
||||
#endif
|
||||
|
||||
return index;
|
||||
}
|
||||
@ -866,13 +822,9 @@ int VoxelChunk::mesh_data_resource_add(const Transform &local_transform, const R
|
||||
|
||||
_mesh_data_resources.push_back(e);
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_mesh_data_resource_added")) {
|
||||
call("_mesh_data_resource_added", index);
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_mesh_data_resource_added, index);
|
||||
#endif
|
||||
|
||||
return index;
|
||||
}
|
||||
@ -948,11 +900,7 @@ int VoxelChunk::mesh_data_resource_get_count() const {
|
||||
void VoxelChunk::mesh_data_resource_remove(const int index) {
|
||||
ERR_FAIL_INDEX(index, _mesh_data_resources.size());
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
_mesh_data_resources.remove(index);
|
||||
#else
|
||||
_mesh_data_resources.remove_at(index);
|
||||
#endif
|
||||
}
|
||||
void VoxelChunk::mesh_data_resource_clear() {
|
||||
_mesh_data_resources.clear();
|
||||
@ -1027,11 +975,7 @@ int VoxelChunk::collider_get_count() const {
|
||||
void VoxelChunk::collider_remove(const int index) {
|
||||
ERR_FAIL_INDEX(index, _colliders.size());
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
_colliders.remove(index);
|
||||
#else
|
||||
_colliders.remove_at(index);
|
||||
#endif
|
||||
}
|
||||
void VoxelChunk::colliders_clear() {
|
||||
_colliders.clear();
|
||||
@ -1040,92 +984,52 @@ void VoxelChunk::colliders_clear() {
|
||||
void VoxelChunk::enter_tree() {
|
||||
_is_in_tree = true;
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_enter_tree")) {
|
||||
call("_enter_tree");
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_enter_tree);
|
||||
#endif
|
||||
}
|
||||
void VoxelChunk::exit_tree() {
|
||||
_is_in_tree = false;
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_exit_tree")) {
|
||||
call("_exit_tree");
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_exit_tree);
|
||||
#endif
|
||||
}
|
||||
void VoxelChunk::process(const float delta) {
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_process")) {
|
||||
call("_process", delta);
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_process, delta);
|
||||
#endif
|
||||
}
|
||||
void VoxelChunk::physics_process(const float delta) {
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_physics_process")) {
|
||||
call("_physics_process", delta);
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_physics_process, delta);
|
||||
#endif
|
||||
}
|
||||
void VoxelChunk::world_transform_changed() {
|
||||
call("_world_transform_changed");
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
call("_world_transform_changed");
|
||||
#else
|
||||
GDVIRTUAL_CALL(_world_transform_changed);
|
||||
#endif
|
||||
}
|
||||
void VoxelChunk::visibility_changed(const bool visible) {
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_visibility_changed")) {
|
||||
call("_visibility_changed", _is_visible);
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_visibility_changed, _is_visible);
|
||||
#endif
|
||||
}
|
||||
void VoxelChunk::world_light_added(const Ref<VoxelLight> &light) {
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_world_light_added")) {
|
||||
call("_world_light_added", light);
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_world_light_added, light);
|
||||
#endif
|
||||
}
|
||||
void VoxelChunk::world_light_removed(const Ref<VoxelLight> &light) {
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_world_light_removed")) {
|
||||
call("_world_light_removed", light);
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_world_light_removed, light);
|
||||
#endif
|
||||
}
|
||||
void VoxelChunk::generation_process(const float delta) {
|
||||
#if VERSION_MAJOR < 4
|
||||
call("_generation_process", delta);
|
||||
#else
|
||||
GDVIRTUAL_CALL(_generation_process, delta);
|
||||
#endif
|
||||
}
|
||||
void VoxelChunk::generation_physics_process(const float delta) {
|
||||
#if VERSION_MAJOR < 4
|
||||
call("_generation_physics_process", delta);
|
||||
#else
|
||||
GDVIRTUAL_CALL(_generation_physics_process, delta);
|
||||
#endif
|
||||
}
|
||||
|
||||
Transform VoxelChunk::get_transform() const {
|
||||
@ -1355,7 +1259,6 @@ void VoxelChunk::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
void VoxelChunk::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("mesh_generation_finished", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk")));
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_mesh_data_resource_added", PropertyInfo(Variant::INT, "index")));
|
||||
|
||||
BIND_VMETHOD(MethodInfo("_channel_setup"));
|
||||
@ -1363,21 +1266,11 @@ void VoxelChunk::_bind_methods() {
|
||||
BIND_VMETHOD(MethodInfo("_bake_lights"));
|
||||
BIND_VMETHOD(MethodInfo("_bake_light", PropertyInfo(Variant::OBJECT, "light", PROPERTY_HINT_RESOURCE_TYPE, "VoxelLight")));
|
||||
BIND_VMETHOD(MethodInfo("_clear_baked_lights"));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_mesh_data_resource_added, "index");
|
||||
|
||||
GDVIRTUAL_BIND(_channel_setup);
|
||||
|
||||
GDVIRTUAL_BIND(_bake_lights);
|
||||
GDVIRTUAL_BIND(_bake_light, "light");
|
||||
GDVIRTUAL_BIND(_clear_baked_lights);
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("bake_lights"), &VoxelChunk::bake_lights);
|
||||
ClassDB::bind_method(D_METHOD("bake_light", "light"), &VoxelChunk::bake_light);
|
||||
ClassDB::bind_method(D_METHOD("clear_baked_lights"), &VoxelChunk::clear_baked_lights);
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_enter_tree"));
|
||||
BIND_VMETHOD(MethodInfo("_exit_tree"));
|
||||
BIND_VMETHOD(MethodInfo("_process", PropertyInfo(Variant::REAL, "delta")));
|
||||
@ -1391,21 +1284,6 @@ void VoxelChunk::_bind_methods() {
|
||||
BIND_VMETHOD(MethodInfo("_generation_physics_process", PropertyInfo(Variant::REAL, "delta")));
|
||||
|
||||
BIND_VMETHOD(MethodInfo("_finalize_build"));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_enter_tree);
|
||||
GDVIRTUAL_BIND(_exit_tree);
|
||||
GDVIRTUAL_BIND(_process, "delta");
|
||||
GDVIRTUAL_BIND(_physics_process, "delta");
|
||||
GDVIRTUAL_BIND(_world_transform_changed);
|
||||
GDVIRTUAL_BIND(_visibility_changed, "visible");
|
||||
GDVIRTUAL_BIND(_world_light_added, "light");
|
||||
GDVIRTUAL_BIND(_world_light_removed, "light");
|
||||
|
||||
GDVIRTUAL_BIND(_generation_process, "delta");
|
||||
GDVIRTUAL_BIND(_generation_physics_process, "delta");
|
||||
|
||||
GDVIRTUAL_BIND(_finalize_build);
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("enter_tree"), &VoxelChunk::enter_tree);
|
||||
ClassDB::bind_method(D_METHOD("exit_tree"), &VoxelChunk::exit_tree);
|
||||
@ -1435,11 +1313,7 @@ void VoxelChunk::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_transform"), &VoxelChunk::get_transform);
|
||||
ClassDB::bind_method(D_METHOD("set_transform", "value"), &VoxelChunk::set_transform);
|
||||
#if VERSION_MAJOR < 4
|
||||
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "transform"), "set_transform", "get_transform");
|
||||
#else
|
||||
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "transform"), "set_transform", "get_transform");
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_visible"), &VoxelChunk::get_visible);
|
||||
ClassDB::bind_method(D_METHOD("set_visible", "value"), &VoxelChunk::set_visible);
|
||||
@ -1651,11 +1525,7 @@ void VoxelChunk::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("collider_remove", "index"), &VoxelChunk::collider_remove);
|
||||
ClassDB::bind_method(D_METHOD("colliders_clear"), &VoxelChunk::colliders_clear);
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_build"));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_build);
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("build"), &VoxelChunk::build);
|
||||
ClassDB::bind_method(D_METHOD("_build"), &VoxelChunk::_build);
|
||||
|
@ -22,22 +22,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/config/engine.h"
|
||||
#include "core/io/resource.h"
|
||||
#include "core/string/ustring.h"
|
||||
#include "core/variant/array.h"
|
||||
#else
|
||||
#include "core/array.h"
|
||||
#include "core/engine.h"
|
||||
#include "core/resource.h"
|
||||
#include "core/ustring.h"
|
||||
#endif
|
||||
|
||||
#include "../defines.h"
|
||||
|
||||
@ -62,13 +50,6 @@ include_pool_vector
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
#define Texture Texture2D
|
||||
|
||||
#include "core/math/transform_3d.h"
|
||||
typedef class Transform3D Transform;
|
||||
#endif
|
||||
|
||||
#include "../library/voxel_library.h"
|
||||
#include "../library/voxel_surface.h"
|
||||
; //hackfix for a clang format issue
|
||||
@ -319,31 +300,6 @@ public:
|
||||
Vector3 to_local(Vector3 p_global) const;
|
||||
Vector3 to_global(Vector3 p_local) const;
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
GDVIRTUAL1(_mesh_data_resource_added, int);
|
||||
|
||||
GDVIRTUAL0(_channel_setup);
|
||||
|
||||
GDVIRTUAL0(_bake_lights);
|
||||
GDVIRTUAL1(_bake_light, Ref<VoxelLight>);
|
||||
GDVIRTUAL0(_clear_baked_lights);
|
||||
|
||||
GDVIRTUAL0(_enter_tree);
|
||||
GDVIRTUAL0(_exit_tree);
|
||||
GDVIRTUAL1(_process, float);
|
||||
GDVIRTUAL1(_physics_process, float);
|
||||
GDVIRTUAL0(_world_transform_changed);
|
||||
GDVIRTUAL1(_visibility_changed, bool);
|
||||
GDVIRTUAL1(_world_light_added, Ref<VoxelLight>);
|
||||
GDVIRTUAL1(_world_light_removed, Ref<VoxelLight>);
|
||||
|
||||
GDVIRTUAL1(_generation_process, float);
|
||||
GDVIRTUAL1(_generation_physics_process, float);
|
||||
|
||||
GDVIRTUAL0(_finalize_build);
|
||||
GDVIRTUAL0(_build);
|
||||
#endif
|
||||
|
||||
VoxelChunk();
|
||||
~VoxelChunk();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user