diff --git a/drivers/gles3/storage/mesh_storage.cpp b/drivers/gles3/storage/mesh_storage.cpp index b45b7f7d5b..6f58fc21c5 100644 --- a/drivers/gles3/storage/mesh_storage.cpp +++ b/drivers/gles3/storage/mesh_storage.cpp @@ -105,7 +105,7 @@ bool MeshStorage::mesh_needs_instance(RID p_mesh, bool p_has_skeleton) { return mesh->blend_shape_count > 0 || (mesh->has_bone_weights && p_has_skeleton); } -void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) { +void MeshStorage::mesh_add_surface(RID p_mesh, const RenderingServerTypes::SurfaceData &p_surface) { Mesh *mesh = mesh_owner.get_or_null(p_mesh); ERR_FAIL_NULL(mesh); @@ -194,7 +194,7 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) #endif uint64_t surface_version = p_surface.format & (uint64_t(RSE::ARRAY_FLAG_FORMAT_VERSION_MASK) << RSE::ARRAY_FLAG_FORMAT_VERSION_SHIFT); - RS::SurfaceData new_surface = p_surface; + RenderingServerTypes::SurfaceData new_surface = p_surface; #ifdef DISABLE_DEPRECATED ERR_FAIL_COND_MSG(surface_version != RSE::ARRAY_FLAG_FORMAT_CURRENT_VERSION, "Surface version provided (" + itos(int(surface_version >> RSE::ARRAY_FLAG_FORMAT_VERSION_SHIFT)) + ") does not match current version (" + itos(RSE::ARRAY_FLAG_FORMAT_CURRENT_VERSION >> RSE::ARRAY_FLAG_FORMAT_VERSION_SHIFT) + ")"); @@ -612,14 +612,14 @@ RID MeshStorage::mesh_surface_get_material(RID p_mesh, int p_surface) const { return mesh->surfaces[p_surface]->material; } -RS::SurfaceData MeshStorage::mesh_get_surface(RID p_mesh, int p_surface) const { +RenderingServerTypes::SurfaceData MeshStorage::mesh_get_surface(RID p_mesh, int p_surface) const { Mesh *mesh = mesh_owner.get_or_null(p_mesh); - ERR_FAIL_NULL_V(mesh, RS::SurfaceData()); - ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_surface, mesh->surface_count, RS::SurfaceData()); + ERR_FAIL_NULL_V(mesh, RenderingServerTypes::SurfaceData()); + ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_surface, mesh->surface_count, RenderingServerTypes::SurfaceData()); Mesh::Surface &s = *mesh->surfaces[p_surface]; - RS::SurfaceData sd; + RenderingServerTypes::SurfaceData sd; sd.format = s.format; if (s.vertex_buffer != 0) { sd.vertex_data = Utilities::buffer_get_data(GL_ARRAY_BUFFER, s.vertex_buffer, s.vertex_buffer_size); @@ -648,7 +648,7 @@ RS::SurfaceData MeshStorage::mesh_get_surface(RID p_mesh, int p_surface) const { sd.aabb = s.aabb; for (uint32_t i = 0; i < s.lod_count; i++) { - RS::SurfaceData::LOD lod; + RenderingServerTypes::SurfaceData::LOD lod; lod.edge_length = s.lods[i].edge_length; lod.index_data = Utilities::buffer_get_data(GL_ELEMENT_ARRAY_BUFFER, s.lods[i].index_buffer, s.lods[i].index_buffer_size); sd.lods.push_back(lod); diff --git a/drivers/gles3/storage/mesh_storage.h b/drivers/gles3/storage/mesh_storage.h index 60d0ba1050..d19ee9bf08 100644 --- a/drivers/gles3/storage/mesh_storage.h +++ b/drivers/gles3/storage/mesh_storage.h @@ -36,7 +36,6 @@ #include "core/templates/rid_owner.h" #include "core/templates/self_list.h" #include "drivers/gles3/shaders/skeleton.glsl.gen.h" -#include "servers/rendering/rendering_server.h" #include "servers/rendering/rendering_server_enums.h" #include "servers/rendering/rendering_server_globals.h" #include "servers/rendering/storage/mesh_storage.h" @@ -305,7 +304,7 @@ public: virtual void mesh_set_blend_shape_count(RID p_mesh, int p_blend_shape_count) override; virtual bool mesh_needs_instance(RID p_mesh, bool p_has_skeleton) override; - virtual void mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) override; + virtual void mesh_add_surface(RID p_mesh, const RenderingServerTypes::SurfaceData &p_surface) override; virtual int mesh_get_blend_shape_count(RID p_mesh) const override; @@ -320,7 +319,7 @@ public: virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) override; virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const override; - virtual RS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const override; + virtual RenderingServerTypes::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const override; virtual int mesh_get_surface_count(RID p_mesh) const override; virtual void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) override; @@ -334,7 +333,7 @@ public: virtual void mesh_clear(RID p_mesh) override; virtual void mesh_surface_remove(RID p_mesh, int p_surface) override; - virtual void mesh_debug_usage(List *r_info) override {} + virtual void mesh_debug_usage(List *r_info) override {} _FORCE_INLINE_ const RID *mesh_get_surface_count_and_materials(RID p_mesh, uint32_t &r_surface_count) { Mesh *mesh = mesh_owner.get_or_null(p_mesh); diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index 5cb857671d..97d548f0fd 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -31,13 +31,13 @@ #include "polygon_2d.h" #include "core/math/geometry_2d.h" -#include "skeleton_2d.h" +#include "scene/2d/skeleton_2d.h" +#include "servers/rendering/rendering_server.h" #ifndef NAVIGATION_2D_DISABLED #include "scene/resources/2d/navigation_mesh_source_geometry_data_2d.h" #include "scene/resources/2d/navigation_polygon.h" #include "servers/navigation_2d/navigation_server_2d.h" -#include "servers/rendering/rendering_server.h" Callable Polygon2D::_navmesh_source_geometry_parsing_callback; RID Polygon2D::_navmesh_source_geometry_parser; @@ -375,7 +375,7 @@ void Polygon2D::_notification(int p_what) { arr[RSE::ARRAY_INDEX] = index_array; - RS::SurfaceData sd; + RenderingServerTypes::SurfaceData sd; if (skeleton_node) { // Compute transform between mesh and skeleton for runtime AABB compute. diff --git a/scene/3d/label_3d.cpp b/scene/3d/label_3d.cpp index 89c1669005..2c2d8c97fc 100644 --- a/scene/3d/label_3d.cpp +++ b/scene/3d/label_3d.cpp @@ -649,7 +649,7 @@ void Label3D::_shape() { mesh_array[RSE::ARRAY_TEX_UV] = E.value.mesh_uvs; mesh_array[RSE::ARRAY_INDEX] = E.value.indices; - RS::SurfaceData sd; + RenderingServerTypes::SurfaceData sd; RS::get_singleton()->mesh_create_surface_data_from_arrays(&sd, RSE::PRIMITIVE_TRIANGLES, mesh_array); sd.material = E.value.material; diff --git a/scene/3d/physics/soft_body_3d.cpp b/scene/3d/physics/soft_body_3d.cpp index 15dd17f894..e95fdd7341 100644 --- a/scene/3d/physics/soft_body_3d.cpp +++ b/scene/3d/physics/soft_body_3d.cpp @@ -44,7 +44,7 @@ void SoftBodyRenderingServerHandler::prepare(RID p_mesh, int p_surface) { mesh = p_mesh; surface = p_surface; - RS::SurfaceData surface_data = RS::get_singleton()->mesh_get_surface(mesh, surface); + RenderingServerTypes::SurfaceData surface_data = RS::get_singleton()->mesh_get_surface(mesh, surface); uint32_t surface_offsets[RSE::ARRAY_MAX]; uint32_t vertex_stride; diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index f80f55aa40..737b683b13 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -770,7 +770,7 @@ SpriteBase3D::SpriteBase3D() { mesh_array[RSE::ARRAY_TEX_UV] = mesh_uvs; mesh_array[RSE::ARRAY_INDEX] = indices; - RS::SurfaceData sd; + RenderingServerTypes::SurfaceData sd; RS::get_singleton()->mesh_create_surface_data_from_arrays(&sd, RSE::PRIMITIVE_TRIANGLES, mesh_array); mesh_surface_format = sd.format; diff --git a/scene/3d/voxelizer.cpp b/scene/3d/voxelizer.cpp index 155c406642..c3742b2757 100644 --- a/scene/3d/voxelizer.cpp +++ b/scene/3d/voxelizer.cpp @@ -31,6 +31,7 @@ #include "voxelizer.h" #include "core/config/project_settings.h" +#include "core/io/image.h" #include "core/math/geometry_3d.h" #include "scene/resources/curve.h" #include "scene/resources/texture.h" diff --git a/scene/3d/voxelizer.h b/scene/3d/voxelizer.h index 13e808cd21..55f870dfe6 100644 --- a/scene/3d/voxelizer.h +++ b/scene/3d/voxelizer.h @@ -32,6 +32,8 @@ #include "scene/resources/multimesh.h" +class Image; + class Voxelizer { public: enum BakeResult { diff --git a/scene/debugger/runtime_node_select.cpp b/scene/debugger/runtime_node_select.cpp index 11ca1e209d..c16cfe2536 100644 --- a/scene/debugger/runtime_node_select.cpp +++ b/scene/debugger/runtime_node_select.cpp @@ -42,6 +42,7 @@ #include "scene/debugger/scene_debugger_object.h" #include "scene/gui/popup_menu.h" #include "scene/main/canvas_layer.h" +#include "scene/resources/mesh.h" #include "scene/theme/theme_db.h" #include "servers/rendering/rendering_server.h" @@ -1155,6 +1156,7 @@ void RuntimeNodeSelect::_update_view_2d() { } #ifndef _3D_DISABLED + void RuntimeNodeSelect::_find_3d_items_at_pos(const Point2 &p_pos, Vector &r_items) { Window *root = SceneTree::get_singleton()->get_root(); @@ -1631,6 +1633,16 @@ void RuntimeNodeSelect::_reset_camera_3d() { override_camera->set_perspective(camera_fov * cursor.fov_scale, camera_znear, camera_zfar); } } + +RuntimeNodeSelect::SelectionBox3D::~SelectionBox3D() { + if (instance.is_valid()) { + RS::get_singleton()->free_rid(instance); + RS::get_singleton()->free_rid(instance_ofs); + RS::get_singleton()->free_rid(instance_xray); + RS::get_singleton()->free_rid(instance_xray_ofs); + } +} + #endif // _3D_DISABLED #endif // DEBUG_ENABLED diff --git a/scene/debugger/runtime_node_select.h b/scene/debugger/runtime_node_select.h index 724d821509..db97f24c90 100644 --- a/scene/debugger/runtime_node_select.h +++ b/scene/debugger/runtime_node_select.h @@ -35,16 +35,16 @@ #include "core/object/object.h" #include "scene/gui/view_panner.h" -#ifndef _3D_DISABLED -#include "scene/resources/mesh.h" -#endif // _3D_DISABLED - class InputEvent; class InputEventMouseMotion; class InputEventWithModifiers; class Node; class PopupMenu; +#ifndef _3D_DISABLED +class ArrayMesh; +#endif + class RuntimeNodeSelect : public Object { GDCLASS(RuntimeNodeSelect, Object); @@ -171,14 +171,7 @@ private: Transform3D transform; AABB bounds; - ~SelectionBox3D() { - if (instance.is_valid()) { - RS::get_singleton()->free_rid(instance); - RS::get_singleton()->free_rid(instance_ofs); - RS::get_singleton()->free_rid(instance_xray); - RS::get_singleton()->free_rid(instance_xray_ofs); - } - } + ~SelectionBox3D(); }; HashMap> selected_3d_nodes; diff --git a/scene/resources/3d/mesh_library.cpp b/scene/resources/3d/mesh_library.cpp index 2073b634d4..8a1b66ea38 100644 --- a/scene/resources/3d/mesh_library.cpp +++ b/scene/resources/3d/mesh_library.cpp @@ -31,6 +31,7 @@ #include "mesh_library.h" #include "scene/resources/texture.h" +#include "servers/rendering/rendering_server.h" // IWYU pragma: Needed to bind RSE enums. #ifndef PHYSICS_3D_DISABLED #include "box_shape_3d.h" diff --git a/scene/resources/immediate_mesh.cpp b/scene/resources/immediate_mesh.cpp index 76532d0d88..71cfacd6b2 100644 --- a/scene/resources/immediate_mesh.cpp +++ b/scene/resources/immediate_mesh.cpp @@ -277,7 +277,7 @@ void ImmediateMesh::surface_end() { } } - RS::SurfaceData sd; + RenderingServerTypes::SurfaceData sd; sd.primitive = RSE::PrimitiveType(active_surface_data.primitive); sd.format = format; diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index 8f8e0d3036..bdb0148fda 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -33,6 +33,7 @@ #include "core/math/convex_hull.h" #include "core/templates/pair.h" #include "scene/resources/surface_tool.h" +#include "servers/rendering/rendering_server.h" #ifndef PHYSICS_3D_DISABLED #include "scene/resources/3d/concave_polygon_shape_3d.h" @@ -1514,7 +1515,7 @@ Array ArrayMesh::_get_surfaces() const { Array ret; for (int i = 0; i < surfaces.size(); i++) { - RenderingServer::SurfaceData surface = RS::get_singleton()->mesh_get_surface(mesh, i); + RenderingServerTypes::SurfaceData surface = RS::get_singleton()->mesh_get_surface(mesh, i); Dictionary data; data["format"] = surface.format; data["primitive"] = surface.primitive; @@ -1583,13 +1584,13 @@ void ArrayMesh::_create_if_empty() const { } void ArrayMesh::_set_surfaces(const Array &p_surfaces) { - Vector surface_data; + Vector surface_data; Vector> surface_materials; Vector surface_names; Vector surface_2d; for (int i = 0; i < p_surfaces.size(); i++) { - RS::SurfaceData surface; + RenderingServerTypes::SurfaceData surface; Dictionary d = p_surfaces[i]; ERR_FAIL_COND(!d.has("format")); ERR_FAIL_COND(!d.has("primitive")); @@ -1622,7 +1623,7 @@ void ArrayMesh::_set_surfaces(const Array &p_surfaces) { Array lods = d["lods"]; ERR_FAIL_COND(lods.size() & 1); //must be even for (int j = 0; j < lods.size(); j += 2) { - RS::SurfaceData::LOD lod; + RenderingServerTypes::SurfaceData::LOD lod; lod.edge_length = lods[j + 0]; lod.index_data = lods[j + 1]; surface.lods.push_back(lod); @@ -1778,7 +1779,7 @@ void ArrayMesh::_recompute_aabb() { } // TODO: Need to add binding to add_surface using future MeshSurfaceData object. -void ArrayMesh::add_surface(BitField p_format, PrimitiveType p_primitive, const Vector &p_array, const Vector &p_attribute_array, const Vector &p_skin_array, int p_vertex_count, const Vector &p_index_array, int p_index_count, const AABB &p_aabb, const Vector &p_blend_shape_data, const Vector &p_bone_aabbs, const Vector &p_lods, const Vector4 p_uv_scale) { +void ArrayMesh::add_surface(BitField p_format, PrimitiveType p_primitive, const Vector &p_array, const Vector &p_attribute_array, const Vector &p_skin_array, int p_vertex_count, const Vector &p_index_array, int p_index_count, const AABB &p_aabb, const Vector &p_blend_shape_data, const Vector &p_bone_aabbs, const Vector &p_lods, const Vector4 p_uv_scale) { ERR_FAIL_COND(surfaces.size() == RSE::MAX_MESH_SURFACES); _create_if_empty(); @@ -1793,7 +1794,7 @@ void ArrayMesh::add_surface(BitField p_format, PrimitiveType p_prim surfaces.push_back(s); _recompute_aabb(); - RS::SurfaceData sd; + RenderingServerTypes::SurfaceData sd; sd.format = p_format; sd.primitive = RSE::PrimitiveType(p_primitive); sd.aabb = p_aabb; @@ -1819,7 +1820,7 @@ void ArrayMesh::add_surface_from_arrays(PrimitiveType p_primitive, const Array & ERR_FAIL_COND(p_blend_shapes.size() != blend_shapes.size()); ERR_FAIL_COND(p_arrays.size() != ARRAY_MAX); - RS::SurfaceData surface; + RenderingServerTypes::SurfaceData surface; Error err = RS::get_singleton()->mesh_create_surface_data_from_arrays(&surface, (RSE::PrimitiveType)p_primitive, p_arrays, p_blend_shapes, p_lods, p_flags); ERR_FAIL_COND(err != OK); diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h index 9aba2e622c..4c28e5cf7b 100644 --- a/scene/resources/mesh.h +++ b/scene/resources/mesh.h @@ -35,8 +35,8 @@ #include "core/math/triangle_mesh.h" #include "core/variant/typed_array.h" #include "scene/resources/material.h" -#include "servers/rendering/rendering_server.h" // Needed for SurfaceData::LOD. #include "servers/rendering/rendering_server_enums.h" +#include "servers/rendering/rendering_server_types.h" #ifndef PHYSICS_3D_DISABLED #include "scene/resources/3d/shape_3d.h" @@ -345,7 +345,7 @@ protected: public: void add_surface_from_arrays(PrimitiveType p_primitive, const Array &p_arrays, const TypedArray &p_blend_shapes = TypedArray(), const Dictionary &p_lods = Dictionary(), BitField p_flags = 0); - void add_surface(BitField p_format, PrimitiveType p_primitive, const Vector &p_array, const Vector &p_attribute_array, const Vector &p_skin_array, int p_vertex_count, const Vector &p_index_array, int p_index_count, const AABB &p_aabb, const Vector &p_blend_shape_data = Vector(), const Vector &p_bone_aabbs = Vector(), const Vector &p_lods = Vector(), const Vector4 p_uv_scale = Vector4()); + void add_surface(BitField p_format, PrimitiveType p_primitive, const Vector &p_array, const Vector &p_attribute_array, const Vector &p_skin_array, int p_vertex_count, const Vector &p_index_array, int p_index_count, const AABB &p_aabb, const Vector &p_blend_shape_data = Vector(), const Vector &p_bone_aabbs = Vector(), const Vector &p_lods = Vector(), const Vector4 p_uv_scale = Vector4()); Array surface_get_arrays(int p_surface) const override; TypedArray surface_get_blend_shape_arrays(int p_surface) const override; diff --git a/servers/debugger/servers_debugger.cpp b/servers/debugger/servers_debugger.cpp index 0b550913ef..77d31538cb 100644 --- a/servers/debugger/servers_debugger.cpp +++ b/servers/debugger/servers_debugger.cpp @@ -462,10 +462,10 @@ void ServersDebugger::_send_resource_usage() { usage.infos.push_back(info); } - List mesh_info; + List mesh_info; RS::get_singleton()->mesh_debug_usage(&mesh_info); - for (const RS::MeshInfo &E : mesh_info) { + for (const RenderingServerTypes::MeshInfo &E : mesh_info) { ServersDebugger::ResourceInfo info; info.path = E.path; // We use 64-bit integers to avoid overflow, if for whatever reason, the sum is bigger than 4GB. diff --git a/servers/rendering/dummy/storage/mesh_storage.h b/servers/rendering/dummy/storage/mesh_storage.h index 2e86112c05..09bbd1f11c 100644 --- a/servers/rendering/dummy/storage/mesh_storage.h +++ b/servers/rendering/dummy/storage/mesh_storage.h @@ -36,7 +36,7 @@ namespace RendererDummy { struct DummyMesh { - Vector surfaces; + Vector surfaces; int blend_shape_count; RSE::BlendShapeMode blend_shape_mode; PackedFloat32Array blend_shape_values; @@ -76,11 +76,11 @@ public: } virtual bool mesh_needs_instance(RID p_mesh, bool p_has_skeleton) override { return false; } - virtual void mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) override { + virtual void mesh_add_surface(RID p_mesh, const RenderingServerTypes::SurfaceData &p_surface) override { DummyMesh *m = mesh_owner.get_or_null(p_mesh); ERR_FAIL_NULL(m); - m->surfaces.push_back(RS::SurfaceData()); - RS::SurfaceData *s = &m->surfaces.write[m->surfaces.size() - 1]; + m->surfaces.push_back(RenderingServerTypes::SurfaceData()); + RenderingServerTypes::SurfaceData *s = &m->surfaces.write[m->surfaces.size() - 1]; s->format = p_surface.format; s->primitive = p_surface.primitive; s->vertex_data = p_surface.vertex_data; @@ -125,11 +125,11 @@ public: virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) override {} virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const override { return RID(); } - virtual RS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const override { + virtual RenderingServerTypes::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const override { DummyMesh *m = mesh_owner.get_or_null(p_mesh); - ERR_FAIL_NULL_V(m, RS::SurfaceData()); - ERR_FAIL_INDEX_V(p_surface, m->surfaces.size(), RS::SurfaceData()); - RS::SurfaceData s = m->surfaces[p_surface]; + ERR_FAIL_NULL_V(m, RenderingServerTypes::SurfaceData()); + ERR_FAIL_INDEX_V(p_surface, m->surfaces.size(), RenderingServerTypes::SurfaceData()); + RenderingServerTypes::SurfaceData s = m->surfaces[p_surface]; return s; } @@ -150,7 +150,7 @@ public: virtual void mesh_surface_remove(RID p_mesh, int p_surface) override; virtual void mesh_clear(RID p_mesh) override; - virtual void mesh_debug_usage(List *r_info) override {} + virtual void mesh_debug_usage(List *r_info) override {} /* MESH INSTANCE */ diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp index 2ea8eafbef..81b6a3d473 100644 --- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp @@ -31,6 +31,7 @@ #include "mesh_storage.h" #include "servers/rendering/rendering_server.h" +#include "servers/rendering/rendering_server_types.h" using namespace RendererRD; @@ -258,7 +259,7 @@ void MeshStorage::mesh_set_blend_shape_count(RID p_mesh, int p_blend_shape_count } /// Returns stride -void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) { +void MeshStorage::mesh_add_surface(RID p_mesh, const RenderingServerTypes::SurfaceData &p_surface) { Mesh *mesh = mesh_owner.get_or_null(p_mesh); ERR_FAIL_NULL(mesh); @@ -350,7 +351,7 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) #endif uint64_t surface_version = p_surface.format & (uint64_t(RSE::ARRAY_FLAG_FORMAT_VERSION_MASK) << RSE::ARRAY_FLAG_FORMAT_VERSION_SHIFT); - RS::SurfaceData new_surface = p_surface; + RenderingServerTypes::SurfaceData new_surface = p_surface; #ifdef DISABLE_DEPRECATED ERR_FAIL_COND_MSG(surface_version != RSE::ARRAY_FLAG_FORMAT_CURRENT_VERSION, "Surface version provided (" + itos(int(surface_version >> RSE::ARRAY_FLAG_FORMAT_VERSION_SHIFT)) + ") does not match current version (" + itos(RSE::ARRAY_FLAG_FORMAT_CURRENT_VERSION >> RSE::ARRAY_FLAG_FORMAT_VERSION_SHIFT) + ")"); @@ -636,14 +637,14 @@ RID MeshStorage::mesh_surface_get_material(RID p_mesh, int p_surface) const { return mesh->surfaces[p_surface]->material; } -RS::SurfaceData MeshStorage::mesh_get_surface(RID p_mesh, int p_surface) const { +RenderingServerTypes::SurfaceData MeshStorage::mesh_get_surface(RID p_mesh, int p_surface) const { Mesh *mesh = mesh_owner.get_or_null(p_mesh); - ERR_FAIL_NULL_V(mesh, RS::SurfaceData()); - ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_surface, mesh->surface_count, RS::SurfaceData()); + ERR_FAIL_NULL_V(mesh, RenderingServerTypes::SurfaceData()); + ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_surface, mesh->surface_count, RenderingServerTypes::SurfaceData()); Mesh::Surface &s = *mesh->surfaces[p_surface]; - RS::SurfaceData sd; + RenderingServerTypes::SurfaceData sd; sd.format = s.format; if (s.vertex_buffer.is_valid()) { sd.vertex_data = RD::get_singleton()->buffer_get_data(s.vertex_buffer); @@ -668,7 +669,7 @@ RS::SurfaceData MeshStorage::mesh_get_surface(RID p_mesh, int p_surface) const { sd.aabb = s.aabb; sd.uv_scale = s.uv_scale; for (uint32_t i = 0; i < s.lod_count; i++) { - RS::SurfaceData::LOD lod; + RenderingServerTypes::SurfaceData::LOD lod; lod.edge_length = s.lods[i].edge_length; lod.index_data = RD::get_singleton()->buffer_get_data(s.lods[i].index_buffer); sd.lods.push_back(lod); @@ -939,13 +940,13 @@ void MeshStorage::mesh_surface_remove(RID p_mesh, int p_surface) { } } -void MeshStorage::mesh_debug_usage(List *r_info) { +void MeshStorage::mesh_debug_usage(List *r_info) { for (const RID &mesh_rid : mesh_owner.get_owned_list()) { Mesh *mesh = mesh_owner.get_or_null(mesh_rid); if (!mesh) { continue; } - RS::MeshInfo mesh_info; + RenderingServerTypes::MeshInfo mesh_info; mesh_info.mesh = mesh_rid; mesh_info.path = mesh->path; diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.h b/servers/rendering/renderer_rd/storage_rd/mesh_storage.h index c3d5e70d39..953124ccbc 100644 --- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.h @@ -30,11 +30,11 @@ #pragma once -#include "../../rendering_server_globals.h" #include "core/templates/local_vector.h" #include "core/templates/rid_owner.h" #include "core/templates/self_list.h" #include "servers/rendering/renderer_rd/shaders/skeleton.glsl.gen.h" +#include "servers/rendering/rendering_server_globals.h" #include "servers/rendering/storage/mesh_storage.h" #include "servers/rendering/storage/utilities.h" @@ -374,7 +374,7 @@ public: virtual void mesh_set_blend_shape_count(RID p_mesh, int p_blend_shape_count) override; /// Return stride - virtual void mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) override; + virtual void mesh_add_surface(RID p_mesh, const RenderingServerTypes::SurfaceData &p_surface) override; virtual int mesh_get_blend_shape_count(RID p_mesh) const override; @@ -389,7 +389,7 @@ public: virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) override; virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const override; - virtual RS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const override; + virtual RenderingServerTypes::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const override; virtual int mesh_get_surface_count(RID p_mesh) const override; @@ -405,7 +405,7 @@ public: virtual void mesh_clear(RID p_mesh) override; virtual void mesh_surface_remove(RID p_mesh, int p_surface) override; - virtual void mesh_debug_usage(List *r_info) override; + virtual void mesh_debug_usage(List *r_info) override; virtual bool mesh_needs_instance(RID p_mesh, bool p_has_skeleton) override; diff --git a/servers/rendering/rendering_server.cpp b/servers/rendering/rendering_server.cpp index 3df3a56fe2..175213a0db 100644 --- a/servers/rendering/rendering_server.cpp +++ b/servers/rendering/rendering_server.cpp @@ -35,6 +35,7 @@ #include "core/math/geometry_3d.h" #include "core/variant/typed_array.h" #include "servers/rendering/rendering_device.h" +#include "servers/rendering/rendering_server_types.h" #include "servers/rendering/shader_language.h" #include "servers/rendering/shader_warnings.h" @@ -1173,7 +1174,7 @@ void RenderingServer::mesh_surface_make_offsets_from_format(uint64_t p_format, i } } -Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_data, RSE::PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, const Dictionary &p_lods, uint64_t p_compress_format) { +Error RenderingServer::mesh_create_surface_data_from_arrays(RenderingServerTypes::SurfaceData *r_surface_data, RSE::PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, const Dictionary &p_lods, uint64_t p_compress_format) { ERR_FAIL_INDEX_V(p_primitive, RSE::PRIMITIVE_MAX, ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(p_arrays.size() != RSE::ARRAY_MAX, ERR_INVALID_PARAMETER); @@ -1331,7 +1332,7 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa blend_shape_data.append_array(vertex_array_shape); } } - Vector lods; + Vector lods; if (index_array_len) { LocalVector keys = p_lods.get_key_list(); keys.sort(); // otherwise lod levels may get skipped @@ -1364,14 +1365,14 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa } } - SurfaceData::LOD lod; + RenderingServerTypes::SurfaceData::LOD lod; lod.edge_length = distance; lod.index_data = data; lods.push_back(lod); } } - SurfaceData &surface_data = *r_surface_data; + RenderingServerTypes::SurfaceData &surface_data = *r_surface_data; surface_data.format = format; surface_data.primitive = p_primitive; surface_data.aabb = aabb; @@ -1390,7 +1391,7 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa } void RenderingServer::mesh_add_surface_from_arrays(RID p_mesh, RSE::PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, const Dictionary &p_lods, BitField p_compress_format) { - SurfaceData sd; + RenderingServerTypes::SurfaceData sd; Error err = mesh_create_surface_data_from_arrays(&sd, p_primitive, p_arrays, p_blend_shapes, p_lods, p_compress_format); if (err != OK) { return; @@ -1714,12 +1715,12 @@ Array RenderingServer::_get_array_from_surface(uint64_t p_format, Vector RenderingServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const { - SurfaceData sd = mesh_get_surface(p_mesh, p_surface); + RenderingServerTypes::SurfaceData sd = mesh_get_surface(p_mesh, p_surface); ERR_FAIL_COND_V(sd.vertex_count == 0, Array()); Vector blend_shape_data = sd.blend_shape_data; @@ -1789,7 +1790,7 @@ TypedArray RenderingServer::mesh_surface_get_blend_shape_arrays(RID p_mes } } -Array RenderingServer::mesh_create_arrays_from_surface_data(const SurfaceData &p_data) const { +Array RenderingServer::mesh_create_arrays_from_surface_data(const RenderingServerTypes::SurfaceData &p_data) const { Vector vertex_data = p_data.vertex_data; Vector attrib_data = p_data.attribute_data; Vector skin_data = p_data.skin_data; @@ -1804,16 +1805,6 @@ Array RenderingServer::mesh_create_arrays_from_surface_data(const SurfaceData &p return _get_array_from_surface(format, vertex_data, attrib_data, skin_data, vertex_len, index_data, index_len, p_data.aabb, p_data.uv_scale); } -#if 0 -Array RenderingServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surface) const { - Vector vec = RS::get_singleton()->mesh_surface_get_skeleton_aabb(p_mesh, p_surface); - Array arr; - for (int i = 0; i < vec.size(); i++) { - arr[i] = vec[i]; - } - return arr; -} -#endif Rect2 RenderingServer::debug_canvas_item_get_rect(RID p_item) { #ifdef TOOLS_ENABLED @@ -1937,14 +1928,14 @@ TypedArray RenderingServer::_shader_get_shader_parameter_list(RID p_ return convert_property_list(&l); } -static RS::SurfaceData _dict_to_surf(const Dictionary &p_dictionary) { - ERR_FAIL_COND_V(!p_dictionary.has("primitive"), RS::SurfaceData()); - ERR_FAIL_COND_V(!p_dictionary.has("format"), RS::SurfaceData()); - ERR_FAIL_COND_V(!p_dictionary.has("vertex_data"), RS::SurfaceData()); - ERR_FAIL_COND_V(!p_dictionary.has("vertex_count"), RS::SurfaceData()); - ERR_FAIL_COND_V(!p_dictionary.has("aabb"), RS::SurfaceData()); +static RenderingServerTypes::SurfaceData _dict_to_surf(const Dictionary &p_dictionary) { + ERR_FAIL_COND_V(!p_dictionary.has("primitive"), RenderingServerTypes::SurfaceData()); + ERR_FAIL_COND_V(!p_dictionary.has("format"), RenderingServerTypes::SurfaceData()); + ERR_FAIL_COND_V(!p_dictionary.has("vertex_data"), RenderingServerTypes::SurfaceData()); + ERR_FAIL_COND_V(!p_dictionary.has("vertex_count"), RenderingServerTypes::SurfaceData()); + ERR_FAIL_COND_V(!p_dictionary.has("aabb"), RenderingServerTypes::SurfaceData()); - RS::SurfaceData sd; + RenderingServerTypes::SurfaceData sd; sd.primitive = RSE::PrimitiveType(int(p_dictionary["primitive"])); sd.format = p_dictionary["format"]; @@ -1960,7 +1951,7 @@ static RS::SurfaceData _dict_to_surf(const Dictionary &p_dictionary) { if (p_dictionary.has("index_data")) { sd.index_data = p_dictionary["index_data"]; - ERR_FAIL_COND_V(!p_dictionary.has("index_count"), RS::SurfaceData()); + ERR_FAIL_COND_V(!p_dictionary.has("index_count"), RenderingServerTypes::SurfaceData()); sd.index_count = p_dictionary["index_count"]; } @@ -1975,7 +1966,7 @@ static RS::SurfaceData _dict_to_surf(const Dictionary &p_dictionary) { Dictionary lod = lods[i]; ERR_CONTINUE(!lod.has("edge_length")); ERR_CONTINUE(!lod.has("index_data")); - RS::SurfaceData::LOD l; + RenderingServerTypes::SurfaceData::LOD l; l.edge_length = lod["edge_length"]; l.index_data = lod["index_data"]; sd.lods.push_back(l); @@ -2001,7 +1992,7 @@ static RS::SurfaceData _dict_to_surf(const Dictionary &p_dictionary) { return sd; } RID RenderingServer::_mesh_create_from_surfaces(const TypedArray &p_surfaces, int p_blend_shape_count) { - Vector surfaces; + Vector surfaces; for (int i = 0; i < p_surfaces.size(); i++) { surfaces.push_back(_dict_to_surf(p_surfaces[i])); } @@ -2011,7 +2002,7 @@ void RenderingServer::_mesh_add_surface(RID p_mesh, const Dictionary &p_surface) mesh_add_surface(p_mesh, _dict_to_surf(p_surface)); } Dictionary RenderingServer::_mesh_get_surface(RID p_mesh, int p_idx) { - RS::SurfaceData sd = mesh_get_surface(p_mesh, p_idx); + RenderingServerTypes::SurfaceData sd = mesh_get_surface(p_mesh, p_idx); Dictionary d; d["primitive"] = sd.primitive; @@ -2165,7 +2156,7 @@ void RenderingServer::set_warn_on_surface_upgrade(bool p_warn) { #endif #ifndef DISABLE_DEPRECATED -void RenderingServer::fix_surface_compatibility(SurfaceData &p_surface, const String &p_path) { +void RenderingServer::fix_surface_compatibility(RenderingServerTypes::SurfaceData &p_surface, const String &p_path) { uint64_t surface_version = p_surface.format & (RSE::ARRAY_FLAG_FORMAT_VERSION_MASK << RSE::ARRAY_FLAG_FORMAT_VERSION_SHIFT); ERR_FAIL_COND_MSG(surface_version > RSE::ARRAY_FLAG_FORMAT_CURRENT_VERSION, "Cannot convert surface with version provided (" + itos((surface_version >> RSE::ARRAY_FLAG_FORMAT_VERSION_SHIFT) & RSE::ARRAY_FLAG_FORMAT_VERSION_MASK) + ") to current version (" + itos((RSE::ARRAY_FLAG_FORMAT_CURRENT_VERSION >> RSE::ARRAY_FLAG_FORMAT_VERSION_SHIFT) & RSE::ARRAY_FLAG_FORMAT_VERSION_MASK) + ")"); diff --git a/servers/rendering/rendering_server.h b/servers/rendering/rendering_server.h index 6de785dfa8..be376a79d7 100644 --- a/servers/rendering/rendering_server.h +++ b/servers/rendering/rendering_server.h @@ -203,37 +203,7 @@ public: /* MESH API */ - struct SurfaceData { - RSE::PrimitiveType primitive = RSE::PRIMITIVE_MAX; - - uint64_t format = RSE::ARRAY_FLAG_FORMAT_CURRENT_VERSION; - Vector vertex_data; // Vertex, Normal, Tangent (change with skinning, blendshape). - Vector attribute_data; // Color, UV, UV2, Custom0-3. - Vector skin_data; // Bone index, Bone weight. - uint32_t vertex_count = 0; - Vector index_data; - uint32_t index_count = 0; - - AABB aabb; - struct LOD { - float edge_length = 0.0f; - Vector index_data; - }; - Vector lods; - Vector bone_aabbs; - - // Transforms used in runtime bone AABBs compute. - // Since bone AABBs is saved in Mesh space, but bones is in Skeleton space. - Transform3D mesh_to_skeleton_xform; - - Vector blend_shape_data; - - Vector4 uv_scale; - - RID material; - }; - - virtual RID mesh_create_from_surfaces(const Vector &p_surfaces, int p_blend_shape_count = 0) = 0; + virtual RID mesh_create_from_surfaces(const Vector &p_surfaces, int p_blend_shape_count = 0) = 0; virtual RID mesh_create() = 0; virtual void mesh_set_blend_shape_count(RID p_mesh, int p_blend_shape_count) = 0; @@ -247,14 +217,14 @@ public: /// Returns stride virtual void mesh_surface_make_offsets_from_format(uint64_t p_format, int p_vertex_len, int p_index_len, uint32_t *r_offsets, uint32_t &r_vertex_element_size, uint32_t &r_normal_element_size, uint32_t &r_attrib_element_size, uint32_t &r_skin_element_size) const; - virtual Error mesh_create_surface_data_from_arrays(SurfaceData *r_surface_data, RSE::PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), const Dictionary &p_lods = Dictionary(), uint64_t p_compress_format = 0); - Array mesh_create_arrays_from_surface_data(const SurfaceData &p_data) const; + virtual Error mesh_create_surface_data_from_arrays(RenderingServerTypes::SurfaceData *r_surface_data, RSE::PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), const Dictionary &p_lods = Dictionary(), uint64_t p_compress_format = 0); + Array mesh_create_arrays_from_surface_data(const RenderingServerTypes::SurfaceData &p_data) const; Array mesh_surface_get_arrays(RID p_mesh, int p_surface) const; TypedArray mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const; Dictionary mesh_surface_get_lods(RID p_mesh, int p_surface) const; virtual void mesh_add_surface_from_arrays(RID p_mesh, RSE::PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), const Dictionary &p_lods = Dictionary(), BitField p_compress_format = 0); - virtual void mesh_add_surface(RID p_mesh, const SurfaceData &p_surface) = 0; + virtual void mesh_add_surface(RID p_mesh, const RenderingServerTypes::SurfaceData &p_surface) = 0; virtual int mesh_get_blend_shape_count(RID p_mesh) const = 0; @@ -269,7 +239,7 @@ public: virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) = 0; virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const = 0; - virtual SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const = 0; + virtual RenderingServerTypes::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const = 0; virtual int mesh_get_surface_count(RID p_mesh) const = 0; @@ -284,19 +254,7 @@ public: virtual void mesh_surface_remove(RID p_mesh, int p_surface) = 0; virtual void mesh_clear(RID p_mesh) = 0; - struct MeshInfo { - RID mesh; - String path; - uint32_t vertex_buffer_size = 0; - uint32_t attribute_buffer_size = 0; - uint32_t skin_buffer_size = 0; - uint32_t index_buffer_size = 0; - uint32_t blend_shape_buffer_size = 0; - uint32_t lod_index_buffers_size = 0; - uint64_t vertex_count = 0; - }; - - virtual void mesh_debug_usage(List *r_info) = 0; + virtual void mesh_debug_usage(List *r_info) = 0; /* MULTIMESH API */ @@ -1111,7 +1069,7 @@ public: #endif #ifndef DISABLE_DEPRECATED - void fix_surface_compatibility(SurfaceData &p_surface, const String &p_path = ""); + void fix_surface_compatibility(RenderingServerTypes::SurfaceData &p_surface, const String &p_path = ""); #endif private: diff --git a/servers/rendering/rendering_server_default.h b/servers/rendering/rendering_server_default.h index 9677ec375d..b88d8ec06a 100644 --- a/servers/rendering/rendering_server_default.h +++ b/servers/rendering/rendering_server_default.h @@ -34,12 +34,12 @@ #include "core/os/thread.h" #include "core/templates/command_queue_mt.h" #include "core/templates/hash_map.h" -#include "renderer_canvas_cull.h" -#include "renderer_viewport.h" -#include "rendering_server_globals.h" +#include "servers/rendering/renderer_canvas_cull.h" #include "servers/rendering/renderer_compositor.h" +#include "servers/rendering/renderer_viewport.h" #include "servers/rendering/rendering_server.h" #include "servers/rendering/rendering_server_enums.h" +#include "servers/rendering/rendering_server_globals.h" #include "servers/rendering/rendering_server_types.h" #include "servers/server_wrap_mt_common.h" @@ -359,7 +359,7 @@ public: #define ServerName RendererMeshStorage #define server_name RSG::mesh_storage - virtual RID mesh_create_from_surfaces(const Vector &p_surfaces, int p_blend_shape_count = 0) override { + virtual RID mesh_create_from_surfaces(const Vector &p_surfaces, int p_blend_shape_count = 0) override { RID mesh = RSG::mesh_storage->mesh_allocate(); bool using_server_thread = Thread::get_caller_id() == server_thread; @@ -389,7 +389,7 @@ public: FUNCRIDSPLIT(mesh) - FUNC2(mesh_add_surface, RID, const SurfaceData &) + FUNC2(mesh_add_surface, RID, const RenderingServerTypes::SurfaceData &) FUNC1RC(int, mesh_get_blend_shape_count, RID) @@ -404,7 +404,7 @@ public: FUNC3(mesh_surface_set_material, RID, int, RID) FUNC2RC(RID, mesh_surface_get_material, RID, int) - FUNC2RC(SurfaceData, mesh_get_surface, RID, int) + FUNC2RC(RenderingServerTypes::SurfaceData, mesh_get_surface, RID, int) FUNC1RC(int, mesh_get_surface_count, RID) @@ -419,7 +419,7 @@ public: FUNC2(mesh_surface_remove, RID, int) FUNC1(mesh_clear, RID) - FUNC1(mesh_debug_usage, List *) + FUNC1(mesh_debug_usage, List *) /* MULTIMESH API */ diff --git a/servers/rendering/rendering_server_types.h b/servers/rendering/rendering_server_types.h index c75e286b72..863553834f 100644 --- a/servers/rendering/rendering_server_types.h +++ b/servers/rendering/rendering_server_types.h @@ -30,9 +30,12 @@ #pragma once +#include "core/math/aabb.h" #include "core/math/rect2.h" #include "core/math/rect2i.h" +#include "core/math/transform_3d.h" #include "core/math/vector2.h" +#include "core/math/vector4.h" #include "core/string/ustring.h" #include "core/templates/rid.h" #include "core/templates/vector.h" @@ -40,6 +43,9 @@ #include +template +class Vector; + namespace RenderingServerTypes { /* SHADER API */ @@ -55,6 +61,50 @@ struct ShaderNativeSourceCode { Vector versions; }; +/* MESH API */ + +struct SurfaceData { + RSE::PrimitiveType primitive = RSE::PRIMITIVE_MAX; + + uint64_t format = RSE::ARRAY_FLAG_FORMAT_CURRENT_VERSION; + Vector vertex_data; // Vertex, Normal, Tangent (change with skinning, blendshape). + Vector attribute_data; // Color, UV, UV2, Custom0-3. + Vector skin_data; // Bone index, Bone weight. + uint32_t vertex_count = 0; + Vector index_data; + uint32_t index_count = 0; + + AABB aabb; + struct LOD { + float edge_length = 0.0f; + Vector index_data; + }; + Vector lods; + Vector bone_aabbs; + + // Transforms used in runtime bone AABBs compute. + // Since bone AABBs is saved in Mesh space, but bones is in Skeleton space. + Transform3D mesh_to_skeleton_xform; + + Vector blend_shape_data; + + Vector4 uv_scale; + + RID material; +}; + +struct MeshInfo { + RID mesh; + String path; + uint32_t vertex_buffer_size = 0; + uint32_t attribute_buffer_size = 0; + uint32_t skin_buffer_size = 0; + uint32_t index_buffer_size = 0; + uint32_t blend_shape_buffer_size = 0; + uint32_t lod_index_buffers_size = 0; + uint64_t vertex_count = 0; +}; + /* STATUS INFORMATION */ struct FrameProfileArea { diff --git a/servers/rendering/storage/mesh_storage.cpp b/servers/rendering/storage/mesh_storage.cpp index 44f288e130..a2ab8d531a 100644 --- a/servers/rendering/storage/mesh_storage.cpp +++ b/servers/rendering/storage/mesh_storage.cpp @@ -234,7 +234,7 @@ Color RendererMeshStorage::multimesh_instance_get_custom_data(RID p_multimesh, i void RendererMeshStorage::multimesh_set_buffer(RID p_multimesh, const Vector &p_buffer) { MultiMeshInterpolator *mmi = _multimesh_get_interpolator(p_multimesh); if (mmi && mmi->interpolated) { - ERR_FAIL_COND_MSG(p_buffer.size() != mmi->_data_curr.size(), vformat("Buffer should have %d elements, got %d instead.", mmi->_data_curr.size(), p_buffer.size())); + ERR_FAIL_COND_MSG(p_buffer.size() != mmi->_data_curr.size(), "Buffer should have " + itos(mmi->_data_curr.size()) + " elements, got " + itos(p_buffer.size()) + " instead."); mmi->_data_curr = p_buffer; _multimesh_add_to_interpolation_lists(p_multimesh, *mmi); @@ -266,8 +266,8 @@ Vector RendererMeshStorage::multimesh_get_buffer(RID p_multimesh) const { void RendererMeshStorage::multimesh_set_buffer_interpolated(RID p_multimesh, const Vector &p_buffer, const Vector &p_buffer_prev) { MultiMeshInterpolator *mmi = _multimesh_get_interpolator(p_multimesh); if (mmi) { - ERR_FAIL_COND_MSG(p_buffer.size() != mmi->_data_curr.size(), vformat("Buffer for current frame should have %d elements, got %d instead.", mmi->_data_curr.size(), p_buffer.size())); - ERR_FAIL_COND_MSG(p_buffer_prev.size() != mmi->_data_prev.size(), vformat("Buffer for previous frame should have %d elements, got %d instead.", mmi->_data_prev.size(), p_buffer_prev.size())); + ERR_FAIL_COND_MSG(p_buffer.size() != mmi->_data_curr.size(), "Buffer for current frame should have " + itos(mmi->_data_curr.size()) + " elements, got " + itos(p_buffer.size()) + " instead."); + ERR_FAIL_COND_MSG(p_buffer_prev.size() != mmi->_data_prev.size(), "Buffer for previous frame should have " + itos(mmi->_data_prev.size()) + " elements, got " + itos(p_buffer_prev.size()) + " instead."); // We are assuming that mmi->interpolated is the case. (Can possibly assert this?) // Even if this flag hasn't been set - just calling this function suggests interpolation is desired. diff --git a/servers/rendering/storage/mesh_storage.h b/servers/rendering/storage/mesh_storage.h index 97a4806f85..bbbaebd6d6 100644 --- a/servers/rendering/storage/mesh_storage.h +++ b/servers/rendering/storage/mesh_storage.h @@ -30,9 +30,12 @@ #pragma once -#include "servers/rendering/rendering_server.h" +#include "core/math/color.h" +#include "core/math/transform_2d.h" +#include "core/templates/local_vector.h" #include "servers/rendering/rendering_server_enums.h" -#include "utilities.h" +#include "servers/rendering/rendering_server_types.h" +#include "servers/rendering/storage/utilities.h" class RendererMeshStorage { public: @@ -47,7 +50,7 @@ public: virtual void mesh_set_blend_shape_count(RID p_mesh, int p_blend_shape_count) = 0; /// Returns stride - virtual void mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) = 0; + virtual void mesh_add_surface(RID p_mesh, const RenderingServerTypes::SurfaceData &p_surface) = 0; virtual int mesh_get_blend_shape_count(RID p_mesh) const = 0; @@ -62,7 +65,7 @@ public: virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) = 0; virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const = 0; - virtual RS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const = 0; + virtual RenderingServerTypes::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const = 0; virtual int mesh_get_surface_count(RID p_mesh) const = 0; @@ -78,7 +81,7 @@ public: virtual void mesh_surface_remove(RID p_mesh, int p_surface) = 0; virtual void mesh_clear(RID p_mesh) = 0; - virtual void mesh_debug_usage(List *r_info) = 0; + virtual void mesh_debug_usage(List *r_info) = 0; virtual bool mesh_needs_instance(RID p_mesh, bool p_has_skeleton) = 0; diff --git a/tests/scene/test_arraymesh.cpp b/tests/scene/test_arraymesh.cpp index 05f505fdfd..a369ce13ce 100644 --- a/tests/scene/test_arraymesh.cpp +++ b/tests/scene/test_arraymesh.cpp @@ -36,6 +36,7 @@ TEST_FORCE_LINK(test_arraymesh) #include "scene/resources/3d/primitive_meshes.h" #include "scene/resources/mesh.h" +#include "servers/rendering/rendering_server.h" namespace TestArrayMesh { @@ -396,7 +397,7 @@ TEST_CASE("[SceneTree][ArrayMesh] Get/Set mesh metadata and actions") { SUBCASE("Create surface from raw SurfaceData data.") { RID mesh_rid = mesh->get_rid(); - RS::SurfaceData surface_data = RS::get_singleton()->mesh_get_surface(mesh_rid, 0); + RenderingServerTypes::SurfaceData surface_data = RS::get_singleton()->mesh_get_surface(mesh_rid, 0); Ref mesh2; mesh2.instantiate(); mesh2->add_surface(surface_data.format, Mesh::PRIMITIVE_TRIANGLES, surface_data.vertex_data, surface_data.attribute_data,