2017-01-02 02:15:57 +01:00
|
|
|
#include "voxel_provider.h"
|
|
|
|
#include "voxel_map.h"
|
|
|
|
|
2017-08-28 15:42:54 +02:00
|
|
|
void VoxelProvider::emerge_block(Ref<VoxelBuffer> out_buffer, Vector3i origin_in_voxels) {
|
2017-01-02 02:15:57 +01:00
|
|
|
ERR_FAIL_COND(out_buffer.is_null());
|
2017-08-13 01:19:39 +02:00
|
|
|
ScriptInstance *script = get_script_instance();
|
|
|
|
if (script) {
|
2017-01-02 02:15:57 +01:00
|
|
|
// Call script to generate buffer
|
|
|
|
Variant arg1 = out_buffer;
|
2017-08-28 15:42:54 +02:00
|
|
|
Variant arg2 = origin_in_voxels.to_vec3();
|
2017-08-13 01:19:39 +02:00
|
|
|
const Variant *args[2] = { &arg1, &arg2 };
|
2017-01-02 02:15:57 +01:00
|
|
|
//Variant::CallError err; // wut
|
|
|
|
script->call_multilevel("emerge_block", args, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-28 15:42:54 +02:00
|
|
|
void VoxelProvider::immerge_block(Ref<VoxelBuffer> buffer, Vector3i origin_in_voxels) {
|
2017-01-02 02:15:57 +01:00
|
|
|
ERR_FAIL_COND(buffer.is_null());
|
2017-08-13 01:19:39 +02:00
|
|
|
ScriptInstance *script = get_script_instance();
|
|
|
|
if (script) {
|
2017-01-02 02:15:57 +01:00
|
|
|
// Call script to save buffer
|
|
|
|
Variant arg1 = buffer;
|
2017-08-28 15:42:54 +02:00
|
|
|
Variant arg2 = origin_in_voxels.to_vec3();
|
2017-08-13 01:19:39 +02:00
|
|
|
const Variant *args[2] = { &arg1, &arg2 };
|
2017-01-02 02:15:57 +01:00
|
|
|
//Variant::CallError err; // wut
|
|
|
|
script->call_multilevel("immerge_block", args, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-28 15:42:54 +02:00
|
|
|
void VoxelProvider::_emerge_block(Ref<VoxelBuffer> out_buffer, Vector3 origin_in_voxels) {
|
|
|
|
emerge_block(out_buffer, Vector3i(origin_in_voxels));
|
2017-01-02 02:15:57 +01:00
|
|
|
}
|
|
|
|
|
2017-08-28 15:42:54 +02:00
|
|
|
void VoxelProvider::_immerge_block(Ref<VoxelBuffer> buffer, Vector3 origin_in_voxels) {
|
|
|
|
immerge_block(buffer, Vector3i(origin_in_voxels));
|
2017-01-02 02:15:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void VoxelProvider::_bind_methods() {
|
2018-09-28 02:11:28 +02:00
|
|
|
// Note: C++ inheriting classes don't need to re-bind these, because they are bindings that call the actual virtual methods
|
2017-01-02 02:15:57 +01:00
|
|
|
|
2018-09-28 02:11:28 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("emerge_block", "out_buffer", "origin_in_voxels"), &VoxelProvider::_emerge_block);
|
|
|
|
ClassDB::bind_method(D_METHOD("immerge_block", "buffer", "origin_in_voxels"), &VoxelProvider::_immerge_block);
|
2017-01-02 02:15:57 +01:00
|
|
|
}
|