mirror of
https://github.com/Relintai/voxelman.git
synced 2025-03-12 18:18:50 +01:00
Added an overrideable fonction to VoxelWorld, so the editor plugin will be able to query the correct channel ids, for any particular world. returning -1 will mean not supported.
This commit is contained in:
parent
b21030ae89
commit
76f9011c24
@ -54,6 +54,21 @@ void VoxelWorldDefault::_chunk_added(Ref<VoxelChunk> chunk) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int VoxelWorldDefault::_get_channel_index_info(const VoxelWorld::ChannelTypeInfo channel_type) {
|
||||||
|
switch (channel_type) {
|
||||||
|
case CHANNEL_TYPE_INFO_TYPE:
|
||||||
|
return VoxelChunkDefault::DEFAULT_CHANNEL_TYPE;
|
||||||
|
case CHANNEL_TYPE_INFO_ISOLEVEL:
|
||||||
|
return VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL;
|
||||||
|
case CHANNEL_TYPE_INFO_LIQUID:
|
||||||
|
return VoxelChunkDefault::DEFAULT_CHANNEL_LIQUID_TYPES;
|
||||||
|
case CHANNEL_TYPE_INFO_LIQUID_LEVEL:
|
||||||
|
return VoxelChunkDefault::DEFAULT_CHANNEL_LIQUID_FILL;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VoxelWorldDefault::VoxelWorldDefault() {
|
VoxelWorldDefault::VoxelWorldDefault() {
|
||||||
_build_flags = VoxelChunkDefault::BUILD_FLAG_CREATE_COLLIDER | VoxelChunkDefault::BUILD_FLAG_CREATE_LODS;
|
_build_flags = VoxelChunkDefault::BUILD_FLAG_CREATE_COLLIDER | VoxelChunkDefault::BUILD_FLAG_CREATE_LODS;
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
Ref<VoxelChunk> _create_chunk(int x, int y, int z, Ref<VoxelChunk> p_chunk);
|
Ref<VoxelChunk> _create_chunk(int x, int y, int z, Ref<VoxelChunk> p_chunk);
|
||||||
virtual void _chunk_added(Ref<VoxelChunk> chunk);
|
virtual void _chunk_added(Ref<VoxelChunk> chunk);
|
||||||
|
int _get_channel_index_info(const ChannelTypeInfo channel_type);
|
||||||
|
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@ SOFTWARE.
|
|||||||
#define REAL FLOAT
|
#define REAL FLOAT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const String VoxelWorld::BINDING_STRING_CHANNEL_TYPE_INFO = "Type,Isolevel,Liquid,Liquid Level";
|
||||||
|
|
||||||
bool VoxelWorld::get_editable() const {
|
bool VoxelWorld::get_editable() const {
|
||||||
return _editable;
|
return _editable;
|
||||||
}
|
}
|
||||||
@ -410,6 +412,9 @@ void VoxelWorld::generate_chunk(Ref<VoxelChunk> chunk) {
|
|||||||
|
|
||||||
chunk->build();
|
chunk->build();
|
||||||
}
|
}
|
||||||
|
int VoxelWorld::_get_channel_index_info(const VoxelWorld::ChannelTypeInfo channel_type) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
bool VoxelWorld::can_chunk_do_build_step() {
|
bool VoxelWorld::can_chunk_do_build_step() {
|
||||||
if (_max_frame_chunk_build_steps == 0) {
|
if (_max_frame_chunk_build_steps == 0) {
|
||||||
@ -626,6 +631,10 @@ void VoxelWorld::set_voxel_at_world_position(const Vector3 &world_position, cons
|
|||||||
chunk->build();
|
chunk->build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int VoxelWorld::get_channel_index_info(const VoxelWorld::ChannelTypeInfo channel_type) {
|
||||||
|
return call("_get_channel_index_info", channel_type);
|
||||||
|
}
|
||||||
|
|
||||||
VoxelWorld::VoxelWorld() {
|
VoxelWorld::VoxelWorld() {
|
||||||
_editable = false;
|
_editable = false;
|
||||||
|
|
||||||
@ -944,4 +953,14 @@ void VoxelWorld::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_lights", "chunks"), &VoxelWorld::set_lights);
|
ClassDB::bind_method(D_METHOD("set_lights", "chunks"), &VoxelWorld::set_lights);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_voxel_at_world_position", "world_position", "data", "channel_index"), &VoxelWorld::set_voxel_at_world_position);
|
ClassDB::bind_method(D_METHOD("set_voxel_at_world_position", "world_position", "data", "channel_index"), &VoxelWorld::set_voxel_at_world_position);
|
||||||
|
|
||||||
|
BIND_VMETHOD(MethodInfo("_get_channel_index_info", PropertyInfo(Variant::INT, "channel_type", PROPERTY_HINT_ENUM, BINDING_STRING_CHANNEL_TYPE_INFO)));
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_channel_index_info", "channel_type"), &VoxelWorld::get_channel_index_info);
|
||||||
|
ClassDB::bind_method(D_METHOD("_get_channel_index_info", "channel_type"), &VoxelWorld::_get_channel_index_info);
|
||||||
|
|
||||||
|
BIND_ENUM_CONSTANT(CHANNEL_TYPE_INFO_TYPE);
|
||||||
|
BIND_ENUM_CONSTANT(CHANNEL_TYPE_INFO_ISOLEVEL);
|
||||||
|
BIND_ENUM_CONSTANT(CHANNEL_TYPE_INFO_LIQUID);
|
||||||
|
BIND_ENUM_CONSTANT(CHANNEL_TYPE_INFO_LIQUID_LEVEL);
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,16 @@ class VoxelChunkPropData;
|
|||||||
class VoxelWorld : public Navigation {
|
class VoxelWorld : public Navigation {
|
||||||
GDCLASS(VoxelWorld, Navigation);
|
GDCLASS(VoxelWorld, Navigation);
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum ChannelTypeInfo {
|
||||||
|
CHANNEL_TYPE_INFO_TYPE = 0,
|
||||||
|
CHANNEL_TYPE_INFO_ISOLEVEL,
|
||||||
|
CHANNEL_TYPE_INFO_LIQUID,
|
||||||
|
CHANNEL_TYPE_INFO_LIQUID_LEVEL,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const String BINDING_STRING_CHANNEL_TYPE_INFO;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool get_editable() const;
|
bool get_editable() const;
|
||||||
void set_editable(const bool value);
|
void set_editable(const bool value);
|
||||||
@ -171,6 +181,7 @@ public:
|
|||||||
|
|
||||||
//Helpers
|
//Helpers
|
||||||
void set_voxel_at_world_position(const Vector3 &world_position, const uint8_t data, const int channel_index);
|
void set_voxel_at_world_position(const Vector3 &world_position, const uint8_t data, const int channel_index);
|
||||||
|
int get_channel_index_info(const ChannelTypeInfo channel_type);
|
||||||
|
|
||||||
VoxelWorld();
|
VoxelWorld();
|
||||||
~VoxelWorld();
|
~VoxelWorld();
|
||||||
@ -178,6 +189,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
virtual void _generate_chunk(Ref<VoxelChunk> chunk);
|
virtual void _generate_chunk(Ref<VoxelChunk> chunk);
|
||||||
virtual Ref<VoxelChunk> _create_chunk(int x, int y, int z, Ref<VoxelChunk> p_chunk);
|
virtual Ref<VoxelChunk> _create_chunk(int x, int y, int z, Ref<VoxelChunk> p_chunk);
|
||||||
|
virtual int _get_channel_index_info(const ChannelTypeInfo channel_type);
|
||||||
|
|
||||||
virtual void _notification(int p_what);
|
virtual void _notification(int p_what);
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
@ -256,4 +268,6 @@ _FORCE_INLINE_ bool operator==(const VoxelWorld::IntPos &a, const VoxelWorld::In
|
|||||||
return a.x == b.x && a.y == b.y && a.z == b.z;
|
return a.x == b.x && a.y == b.y && a.z == b.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VARIANT_ENUM_CAST(VoxelWorld::ChannelTypeInfo);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user