gltf export: Remove snapping and fix validation

Round min/max correctly in accessors
Include correct target in vertex and indices bufferViews
Avoid use of Math::snapped
Normalize vertex weights.
This commit is contained in:
Lyuma
2024-03-09 23:51:52 -08:00
parent 0ace0a1292
commit fd2aa564ab
5 changed files with 109 additions and 55 deletions

View File

@@ -46,12 +46,15 @@ void GLTFBufferView::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_byte_stride", "byte_stride"), &GLTFBufferView::set_byte_stride);
ClassDB::bind_method(D_METHOD("get_indices"), &GLTFBufferView::get_indices);
ClassDB::bind_method(D_METHOD("set_indices", "indices"), &GLTFBufferView::set_indices);
ClassDB::bind_method(D_METHOD("get_vertex_attributes"), &GLTFBufferView::get_vertex_attributes);
ClassDB::bind_method(D_METHOD("set_vertex_attributes", "is_attributes"), &GLTFBufferView::set_vertex_attributes);
ADD_PROPERTY(PropertyInfo(Variant::INT, "buffer"), "set_buffer", "get_buffer"); // GLTFBufferIndex
ADD_PROPERTY(PropertyInfo(Variant::INT, "byte_offset"), "set_byte_offset", "get_byte_offset"); // int
ADD_PROPERTY(PropertyInfo(Variant::INT, "byte_length"), "set_byte_length", "get_byte_length"); // int
ADD_PROPERTY(PropertyInfo(Variant::INT, "byte_stride"), "set_byte_stride", "get_byte_stride"); // int
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "indices"), "set_indices", "get_indices"); // bool
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "vertex_attributes"), "set_vertex_attributes", "get_vertex_attributes"); // bool
}
GLTFBufferIndex GLTFBufferView::get_buffer() const {
@@ -94,6 +97,14 @@ void GLTFBufferView::set_indices(bool p_indices) {
indices = p_indices;
}
bool GLTFBufferView::get_vertex_attributes() const {
return vertex_attributes;
}
void GLTFBufferView::set_vertex_attributes(bool p_attributes) {
vertex_attributes = p_attributes;
}
Vector<uint8_t> GLTFBufferView::load_buffer_view_data(const Ref<GLTFState> p_state) const {
ERR_FAIL_COND_V(p_state.is_null(), Vector<uint8_t>());
ERR_FAIL_COND_V_MSG(byte_stride > 0, Vector<uint8_t>(), "Buffer views with byte stride are not yet supported by this method.");