summaryrefslogtreecommitdiffstats
path: root/modules/gltf/structures/gltf_buffer_view.cpp
diff options
context:
space:
mode:
authorAaron Franke <arnfranke@yahoo.com>2024-01-10 16:08:25 -0600
committerAaron Franke <arnfranke@yahoo.com>2024-01-11 20:33:51 -0600
commitd36a34edb77e93d501fd18fb7a255cc14e246dab (patch)
tree7a5e1605706528742e97ab1a35f98e04fcdb5e28 /modules/gltf/structures/gltf_buffer_view.cpp
parent26b1fd0d842fa3c2f090ead47e8ea7cd2d6515e1 (diff)
downloadredot-engine-d36a34edb77e93d501fd18fb7a255cc14e246dab.tar.gz
Misc changes to the GLTF module before audio PR
Diffstat (limited to 'modules/gltf/structures/gltf_buffer_view.cpp')
-rw-r--r--modules/gltf/structures/gltf_buffer_view.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/gltf/structures/gltf_buffer_view.cpp b/modules/gltf/structures/gltf_buffer_view.cpp
index 7678f23f57..d40ed69915 100644
--- a/modules/gltf/structures/gltf_buffer_view.cpp
+++ b/modules/gltf/structures/gltf_buffer_view.cpp
@@ -30,7 +30,11 @@
#include "gltf_buffer_view.h"
+#include "../gltf_state.h"
+
void GLTFBufferView::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("load_buffer_view_data", "state"), &GLTFBufferView::load_buffer_view_data);
+
ClassDB::bind_method(D_METHOD("get_buffer"), &GLTFBufferView::get_buffer);
ClassDB::bind_method(D_METHOD("set_buffer", "buffer"), &GLTFBufferView::set_buffer);
ClassDB::bind_method(D_METHOD("get_byte_offset"), &GLTFBufferView::get_byte_offset);
@@ -88,3 +92,12 @@ bool GLTFBufferView::get_indices() {
void GLTFBufferView::set_indices(bool p_indices) {
indices = p_indices;
}
+
+Vector<uint8_t> GLTFBufferView::load_buffer_view_data(const Ref<GLTFState> p_state) const {
+ ERR_FAIL_COND_V_MSG(byte_stride > 0, Vector<uint8_t>(), "Buffer views with byte stride are not yet supported by this method.");
+ const TypedArray<Vector<uint8_t>> &buffers = p_state->get_buffers();
+ ERR_FAIL_INDEX_V(buffer, buffers.size(), Vector<uint8_t>());
+ const PackedByteArray &buffer_data = buffers[buffer];
+ const int64_t byte_end = byte_offset + byte_length;
+ return buffer_data.slice(byte_offset, byte_end);
+}