diff options
author | PouleyKetchoupp <pouleyketchoup@gmail.com> | 2021-10-01 08:42:47 -0700 |
---|---|---|
committer | PouleyKetchoupp <pouleyketchoup@gmail.com> | 2021-10-01 08:42:47 -0700 |
commit | b8eeb34b4e18304ce24bda6001c6f120b99ddeec (patch) | |
tree | db3af96a27ceb15562692de0777007fdc87da5a5 /servers | |
parent | 77721b35ba21f2e7e8bb42cf415fccb018517843 (diff) |
Remove scene code in physics servers
Replaced Mesh with mesh RID in Godot Physics 3D and Bullet.
Diffstat (limited to 'servers')
-rw-r--r-- | servers/physics_3d/physics_server_3d_sw.cpp | 2 | ||||
-rw-r--r-- | servers/physics_3d/physics_server_3d_sw.h | 2 | ||||
-rw-r--r-- | servers/physics_3d/physics_server_3d_wrap_mt.h | 2 | ||||
-rw-r--r-- | servers/physics_3d/soft_body_3d_sw.cpp | 14 | ||||
-rw-r--r-- | servers/physics_3d/soft_body_3d_sw.h | 5 | ||||
-rw-r--r-- | servers/physics_server_3d.h | 2 |
6 files changed, 15 insertions, 12 deletions
diff --git a/servers/physics_3d/physics_server_3d_sw.cpp b/servers/physics_3d/physics_server_3d_sw.cpp index ece1fe46e7..36f81e072d 100644 --- a/servers/physics_3d/physics_server_3d_sw.cpp +++ b/servers/physics_3d/physics_server_3d_sw.cpp @@ -1098,7 +1098,7 @@ real_t PhysicsServer3DSW::soft_body_get_drag_coefficient(RID p_body) const { return soft_body->get_drag_coefficient(); } -void PhysicsServer3DSW::soft_body_set_mesh(RID p_body, const REF &p_mesh) { +void PhysicsServer3DSW::soft_body_set_mesh(RID p_body, RID p_mesh) { SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body); ERR_FAIL_COND(!soft_body); diff --git a/servers/physics_3d/physics_server_3d_sw.h b/servers/physics_3d/physics_server_3d_sw.h index 357bfba1d7..106e260311 100644 --- a/servers/physics_3d/physics_server_3d_sw.h +++ b/servers/physics_3d/physics_server_3d_sw.h @@ -291,7 +291,7 @@ public: virtual void soft_body_set_drag_coefficient(RID p_body, real_t p_drag_coefficient) override; virtual real_t soft_body_get_drag_coefficient(RID p_body) const override; - virtual void soft_body_set_mesh(RID p_body, const REF &p_mesh) override; + virtual void soft_body_set_mesh(RID p_body, RID p_mesh) override; virtual AABB soft_body_get_bounds(RID p_body) const override; diff --git a/servers/physics_3d/physics_server_3d_wrap_mt.h b/servers/physics_3d/physics_server_3d_wrap_mt.h index 6869484f8c..a86fb5a3d3 100644 --- a/servers/physics_3d/physics_server_3d_wrap_mt.h +++ b/servers/physics_3d/physics_server_3d_wrap_mt.h @@ -308,7 +308,7 @@ public: FUNC2(soft_body_set_drag_coefficient, RID, real_t); FUNC1RC(real_t, soft_body_get_drag_coefficient, RID); - FUNC2(soft_body_set_mesh, RID, const REF &); + FUNC2(soft_body_set_mesh, RID, RID); FUNC1RC(AABB, soft_body_get_bounds, RID); diff --git a/servers/physics_3d/soft_body_3d_sw.cpp b/servers/physics_3d/soft_body_3d_sw.cpp index 752d5f3a91..5e8f8692ba 100644 --- a/servers/physics_3d/soft_body_3d_sw.cpp +++ b/servers/physics_3d/soft_body_3d_sw.cpp @@ -33,6 +33,7 @@ #include "core/math/geometry_3d.h" #include "core/templates/map.h" +#include "servers/rendering_server.h" // Based on Bullet soft body. @@ -127,7 +128,7 @@ void SoftBody3DSW::set_space(Space3DSW *p_space) { } } -void SoftBody3DSW::set_mesh(const Ref<Mesh> &p_mesh) { +void SoftBody3DSW::set_mesh(RID p_mesh) { destroy(); soft_mesh = p_mesh; @@ -136,13 +137,11 @@ void SoftBody3DSW::set_mesh(const Ref<Mesh> &p_mesh) { return; } - Array arrays = soft_mesh->surface_get_arrays(0); - ERR_FAIL_COND(!(soft_mesh->surface_get_format(0) & RS::ARRAY_FORMAT_INDEX)); + Array arrays = RenderingServer::get_singleton()->mesh_surface_get_arrays(soft_mesh, 0); - bool success = create_from_trimesh(arrays[RS::ARRAY_INDEX], arrays[RS::ARRAY_VERTEX]); + bool success = create_from_trimesh(arrays[RenderingServer::ARRAY_INDEX], arrays[RenderingServer::ARRAY_VERTEX]); if (!success) { destroy(); - soft_mesh = Ref<Mesh>(); } } @@ -467,6 +466,9 @@ Vector3 SoftBody3DSW::get_face_normal(uint32_t p_face_index) const { } bool SoftBody3DSW::create_from_trimesh(const Vector<int> &p_indices, const Vector<Vector3> &p_vertices) { + ERR_FAIL_COND_V(p_indices.is_empty(), false); + ERR_FAIL_COND_V(p_vertices.is_empty(), false); + uint32_t node_count = 0; LocalVector<Vector3> vertices; const int visual_vertex_count(p_vertices.size()); @@ -1227,6 +1229,8 @@ void SoftBody3DSW::deinitialize_shape() { } void SoftBody3DSW::destroy() { + soft_mesh = RID(); + map_visual_to_physics.clear(); node_tree.clear(); diff --git a/servers/physics_3d/soft_body_3d_sw.h b/servers/physics_3d/soft_body_3d_sw.h index 58fd234fde..7d4b83d0ee 100644 --- a/servers/physics_3d/soft_body_3d_sw.h +++ b/servers/physics_3d/soft_body_3d_sw.h @@ -40,12 +40,11 @@ #include "core/templates/local_vector.h" #include "core/templates/set.h" #include "core/templates/vset.h" -#include "scene/resources/mesh.h" class Constraint3DSW; class SoftBody3DSW : public CollisionObject3DSW { - Ref<Mesh> soft_mesh; + RID soft_mesh; struct Node { Vector3 s; // Source position @@ -159,7 +158,7 @@ public: virtual void set_space(Space3DSW *p_space); - void set_mesh(const Ref<Mesh> &p_mesh); + void set_mesh(RID p_mesh); void update_rendering_server(RenderingServerHandler *p_rendering_server_handler); diff --git a/servers/physics_server_3d.h b/servers/physics_server_3d.h index c2fdb0a19b..dbd734ba32 100644 --- a/servers/physics_server_3d.h +++ b/servers/physics_server_3d.h @@ -520,7 +520,7 @@ public: virtual void soft_body_set_space(RID p_body, RID p_space) = 0; virtual RID soft_body_get_space(RID p_body) const = 0; - virtual void soft_body_set_mesh(RID p_body, const REF &p_mesh) = 0; + virtual void soft_body_set_mesh(RID p_body, RID p_mesh) = 0; virtual AABB soft_body_get_bounds(RID p_body) const = 0; |