diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index e67b0bea210..35e11bbdf2c 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -3229,6 +3229,24 @@ VS::BlendShapeMode RasterizerStorageGLES3::mesh_get_blend_shape_mode(RID p_mesh) return mesh->blend_shape_mode; } +uint32_t RasterizerStorageGLES3::mesh_surface_get_stride_in_array(RID p_mesh, int p_surface, int p_array_index) const { + Mesh *mesh = mesh_owner.getornull(p_mesh); + ERR_FAIL_COND_V(!mesh, 0); + ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), 0); + ERR_FAIL_INDEX_V(p_array_index, VS::ARRAY_MAX, 0); + + return mesh->surfaces[p_surface]->attribs[p_array_index].stride; +} + +uint32_t RasterizerStorageGLES3::mesh_surface_get_offset_in_array(RID p_mesh, int p_surface, int p_array_index) const { + Mesh *mesh = mesh_owner.getornull(p_mesh); + ERR_FAIL_COND_V(!mesh, 0); + ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), 0); + ERR_FAIL_INDEX_V(p_array_index, VS::ARRAY_MAX, 0); + + return mesh->surfaces[p_surface]->attribs[p_array_index].offset; +} + void RasterizerStorageGLES3::mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector &p_data) { Mesh *mesh = mesh_owner.getornull(p_mesh); @@ -3240,7 +3258,7 @@ void RasterizerStorageGLES3::mesh_surface_update_region(RID p_mesh, int p_surfac PoolVector::Read r = p_data.read(); - glBindBuffer(GL_ARRAY_BUFFER, mesh->surfaces[p_surface]->array_id); + glBindBuffer(GL_ARRAY_BUFFER, mesh->surfaces[p_surface]->vertex_id); glBufferSubData(GL_ARRAY_BUFFER, p_offset, total_size, r.ptr()); glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind } @@ -3404,6 +3422,7 @@ Vector > RasterizerStorageGLES3::mesh_surface_get_blend_shap return bsarr; } + Vector RasterizerStorageGLES3::mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const { const Mesh *mesh = mesh_owner.getornull(p_mesh); @@ -3455,6 +3474,7 @@ void RasterizerStorageGLES3::mesh_remove_surface(RID p_mesh, int p_surface) { mesh->instance_change_notify(); } + int RasterizerStorageGLES3::mesh_get_surface_count(RID p_mesh) const { const Mesh *mesh = mesh_owner.getornull(p_mesh); @@ -3468,6 +3488,7 @@ void RasterizerStorageGLES3::mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb ERR_FAIL_COND(!mesh); mesh->custom_aabb = p_aabb; + mesh->instance_change_notify(); } AABB RasterizerStorageGLES3::mesh_get_custom_aabb(RID p_mesh) const { diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index 80df21941b4..7b8a09af154 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -693,7 +693,6 @@ public: AABB custom_aabb; mutable uint64_t last_pass; SelfList::List multimeshes; - _FORCE_INLINE_ void update_multimeshes() { SelfList *mm = multimeshes.first(); @@ -723,6 +722,8 @@ public: virtual void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode); virtual VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const; + virtual uint32_t mesh_surface_get_stride_in_array(RID p_mesh, int p_surface, int p_array_index) const; + virtual uint32_t mesh_surface_get_offset_in_array(RID p_mesh, int p_surface, int p_array_index) const; virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector &p_data); virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material); diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 0b37d266e77..38849721f88 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -252,6 +252,8 @@ public: virtual void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode) = 0; virtual VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const = 0; + virtual uint32_t mesh_surface_get_stride_in_array(RID p_mesh, int p_surface, int p_array_index) const = 0; + virtual uint32_t mesh_surface_get_offset_in_array(RID p_mesh, int p_surface, int p_array_index) const = 0; virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector &p_data) = 0; virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) = 0; @@ -277,6 +279,7 @@ public: virtual AABB mesh_get_custom_aabb(RID p_mesh) const = 0; virtual AABB mesh_get_aabb(RID p_mesh, RID p_skeleton) const = 0; + virtual void mesh_clear(RID p_mesh) = 0; /* MULTIMESH API */ diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index ec0d02ed2ad..c2bf1110f06 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -97,6 +97,7 @@ public: #define DISPLAY_CHANGED \ changes++; #endif + // print_line(String("CHANGED: ") + __FUNCTION__); #define BIND0R(m_r, m_name) \ m_r m_name() { return BINDBASE->m_name(); } @@ -218,6 +219,8 @@ public: BIND2(mesh_set_blend_shape_mode, RID, BlendShapeMode) BIND1RC(BlendShapeMode, mesh_get_blend_shape_mode, RID) + BIND3RC(uint32_t, mesh_surface_get_stride_in_array, RID, int, int) + BIND3RC(uint32_t, mesh_surface_get_offset_in_array, RID, int, int) BIND4(mesh_surface_update_region, RID, int, int, const PoolVector &) BIND3(mesh_surface_set_material, RID, int, RID) diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 48f0ec46f3b..3ba761e4f3a 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -64,7 +64,7 @@ class VisualServerWrapMT : public VisualServer { int pool_max_size; - //#define DEBUG_SYNC +//#define DEBUG_SYNC static VisualServerWrapMT *singleton_mt; @@ -152,6 +152,8 @@ public: FUNC2(mesh_set_blend_shape_mode, RID, BlendShapeMode) FUNC1RC(BlendShapeMode, mesh_get_blend_shape_mode, RID) + FUNC3RC(uint32_t, mesh_surface_get_stride_in_array, RID, int, int) + FUNC3RC(uint32_t, mesh_surface_get_offset_in_array, RID, int, int) FUNC4(mesh_surface_update_region, RID, int, int, const PoolVector &) FUNC3(mesh_surface_set_material, RID, int, RID) diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index a48f1cccae2..200475742b3 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -1569,6 +1569,9 @@ void VisualServer::_bind_methods() { ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_count", "mesh"), &VisualServer::mesh_get_blend_shape_count); ClassDB::bind_method(D_METHOD("mesh_set_blend_shape_mode", "mesh", "mode"), &VisualServer::mesh_set_blend_shape_mode); ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_mode", "mesh"), &VisualServer::mesh_get_blend_shape_mode); + ClassDB::bind_method(D_METHOD("mesh_surface_get_stride_in_array", "mesh", "surface", "array_index"), &VisualServer::mesh_surface_get_stride_in_array); + ClassDB::bind_method(D_METHOD("mesh_surface_get_offset_in_array", "mesh", "surface", "array_index"), &VisualServer::mesh_surface_get_offset_in_array); + ClassDB::bind_method(D_METHOD("mesh_surface_update_region", "mesh", "surface", "offset", "data"), &VisualServer::mesh_surface_update_region); ClassDB::bind_method(D_METHOD("mesh_surface_set_material", "mesh", "surface", "material"), &VisualServer::mesh_surface_set_material); ClassDB::bind_method(D_METHOD("mesh_surface_get_material", "mesh", "surface"), &VisualServer::mesh_surface_get_material); ClassDB::bind_method(D_METHOD("mesh_surface_get_array_len", "mesh", "surface"), &VisualServer::mesh_surface_get_array_len); diff --git a/servers/visual_server.h b/servers/visual_server.h index 968cb852ed9..424de4ab631 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -265,6 +265,8 @@ public: virtual void mesh_set_blend_shape_mode(RID p_mesh, BlendShapeMode p_mode) = 0; virtual BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const = 0; + virtual uint32_t mesh_surface_get_stride_in_array(RID p_mesh, int p_surface, int p_array_index) const = 0; + virtual uint32_t mesh_surface_get_offset_in_array(RID p_mesh, int p_surface, int p_array_index) const = 0; virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector &p_data) = 0; virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) = 0;