Merge pull request #98788 from Bonkahe/master

Add `multimesh_get_buffer_rd_rid` method to `RenderingServer`.
This commit is contained in:
Thaddeus Crews 2024-11-18 09:23:46 -06:00
commit 0a50cef751
No known key found for this signature in database
GPG Key ID: 62181B86FE9E5D84
11 changed files with 29 additions and 0 deletions

View File

@ -2545,6 +2545,13 @@
[b]Note:[/b] If the buffer is in the engine's internal cache, it will have to be fetched from GPU memory and possibly decompressed. This means [method multimesh_get_buffer] is potentially a slow operation and should be avoided whenever possible. [b]Note:[/b] If the buffer is in the engine's internal cache, it will have to be fetched from GPU memory and possibly decompressed. This means [method multimesh_get_buffer] is potentially a slow operation and should be avoided whenever possible.
</description> </description>
</method> </method>
<method name="multimesh_get_buffer_rd_rid" qualifiers="const">
<return type="RID" />
<param index="0" name="multimesh" type="RID" />
<description>
Returns the [RenderingDevice] [RID] handle of the [MultiMesh], which can be used as any other buffer on the Rendering Device.
</description>
</method>
<method name="multimesh_get_custom_aabb" qualifiers="const"> <method name="multimesh_get_custom_aabb" qualifiers="const">
<return type="AABB" /> <return type="AABB" />
<param index="0" name="multimesh" type="RID" /> <param index="0" name="multimesh" type="RID" />

View File

@ -1974,6 +1974,10 @@ void MeshStorage::_multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_
} }
} }
RID MeshStorage::_multimesh_get_buffer_rd_rid(RID p_multimesh) const {
ERR_FAIL_V_MSG(RID(), "GLES3 does not contain a Rid for the multimesh buffer.");
}
Vector<float> MeshStorage::_multimesh_get_buffer(RID p_multimesh) const { Vector<float> MeshStorage::_multimesh_get_buffer(RID p_multimesh) const {
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh); MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_NULL_V(multimesh, Vector<float>()); ERR_FAIL_NULL_V(multimesh, Vector<float>());

View File

@ -517,6 +517,7 @@ public:
virtual Color _multimesh_instance_get_color(RID p_multimesh, int p_index) const override; virtual Color _multimesh_instance_get_color(RID p_multimesh, int p_index) const override;
virtual Color _multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const override; virtual Color _multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const override;
virtual void _multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) override; virtual void _multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) override;
virtual RID _multimesh_get_buffer_rd_rid(RID p_multimesh) const override;
virtual Vector<float> _multimesh_get_buffer(RID p_multimesh) const override; virtual Vector<float> _multimesh_get_buffer(RID p_multimesh) const override;
virtual void _multimesh_set_visible_instances(RID p_multimesh, int p_visible) override; virtual void _multimesh_set_visible_instances(RID p_multimesh, int p_visible) override;

View File

@ -170,6 +170,7 @@ public:
virtual Color _multimesh_instance_get_color(RID p_multimesh, int p_index) const override { return Color(); } virtual Color _multimesh_instance_get_color(RID p_multimesh, int p_index) const override { return Color(); }
virtual Color _multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const override { return Color(); } virtual Color _multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const override { return Color(); }
virtual void _multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) override; virtual void _multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) override;
virtual RID _multimesh_get_buffer_rd_rid(RID p_multimesh) const override { return RID(); }
virtual Vector<float> _multimesh_get_buffer(RID p_multimesh) const override; virtual Vector<float> _multimesh_get_buffer(RID p_multimesh) const override;
virtual void _multimesh_set_visible_instances(RID p_multimesh, int p_visible) override {} virtual void _multimesh_set_visible_instances(RID p_multimesh, int p_visible) override {}

View File

@ -1997,6 +1997,12 @@ void MeshStorage::_multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_
} }
} }
RID MeshStorage::_multimesh_get_buffer_rd_rid(RID p_multimesh) const {
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_NULL_V(multimesh, RID());
return multimesh->buffer;
}
Vector<float> MeshStorage::_multimesh_get_buffer(RID p_multimesh) const { Vector<float> MeshStorage::_multimesh_get_buffer(RID p_multimesh) const {
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh); MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_NULL_V(multimesh, Vector<float>()); ERR_FAIL_NULL_V(multimesh, Vector<float>());

View File

@ -651,6 +651,7 @@ public:
virtual Color _multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const override; virtual Color _multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const override;
virtual void _multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) override; virtual void _multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) override;
virtual RID _multimesh_get_buffer_rd_rid(RID p_multimesh) const override;
virtual Vector<float> _multimesh_get_buffer(RID p_multimesh) const override; virtual Vector<float> _multimesh_get_buffer(RID p_multimesh) const override;
virtual void _multimesh_set_visible_instances(RID p_multimesh, int p_visible) override; virtual void _multimesh_set_visible_instances(RID p_multimesh, int p_visible) override;

View File

@ -403,6 +403,7 @@ public:
FUNC2RC(Color, multimesh_instance_get_custom_data, RID, int) FUNC2RC(Color, multimesh_instance_get_custom_data, RID, int)
FUNC2(multimesh_set_buffer, RID, const Vector<float> &) FUNC2(multimesh_set_buffer, RID, const Vector<float> &)
FUNC1RC(RID, multimesh_get_buffer_rd_rid, RID)
FUNC1RC(Vector<float>, multimesh_get_buffer, RID) FUNC1RC(Vector<float>, multimesh_get_buffer, RID)
FUNC3(multimesh_set_buffer_interpolated, RID, const Vector<float> &, const Vector<float> &) FUNC3(multimesh_set_buffer_interpolated, RID, const Vector<float> &, const Vector<float> &)

View File

@ -223,6 +223,10 @@ void RendererMeshStorage::multimesh_set_buffer(RID p_multimesh, const Vector<flo
_multimesh_set_buffer(p_multimesh, p_buffer); _multimesh_set_buffer(p_multimesh, p_buffer);
} }
RID RendererMeshStorage::multimesh_get_buffer_rd_rid(RID p_multimesh) const {
return _multimesh_get_buffer_rd_rid(p_multimesh);
}
Vector<float> RendererMeshStorage::multimesh_get_buffer(RID p_multimesh) const { Vector<float> RendererMeshStorage::multimesh_get_buffer(RID p_multimesh) const {
return _multimesh_get_buffer(p_multimesh); return _multimesh_get_buffer(p_multimesh);
} }

View File

@ -141,6 +141,7 @@ public:
virtual Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const; virtual Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const;
virtual void multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer); virtual void multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer);
virtual RID multimesh_get_buffer_rd_rid(RID p_multimesh) const;
virtual Vector<float> multimesh_get_buffer(RID p_multimesh) const; virtual Vector<float> multimesh_get_buffer(RID p_multimesh) const;
virtual void multimesh_set_buffer_interpolated(RID p_multimesh, const Vector<float> &p_buffer, const Vector<float> &p_buffer_prev); virtual void multimesh_set_buffer_interpolated(RID p_multimesh, const Vector<float> &p_buffer, const Vector<float> &p_buffer_prev);
@ -178,6 +179,7 @@ public:
virtual Color _multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const = 0; virtual Color _multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const = 0;
virtual void _multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) = 0; virtual void _multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) = 0;
virtual RID _multimesh_get_buffer_rd_rid(RID p_multimesh) const = 0;
virtual Vector<float> _multimesh_get_buffer(RID p_multimesh) const = 0; virtual Vector<float> _multimesh_get_buffer(RID p_multimesh) const = 0;
virtual void _multimesh_set_visible_instances(RID p_multimesh, int p_visible) = 0; virtual void _multimesh_set_visible_instances(RID p_multimesh, int p_visible) = 0;

View File

@ -2452,6 +2452,7 @@ void RenderingServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("multimesh_set_visible_instances", "multimesh", "visible"), &RenderingServer::multimesh_set_visible_instances); ClassDB::bind_method(D_METHOD("multimesh_set_visible_instances", "multimesh", "visible"), &RenderingServer::multimesh_set_visible_instances);
ClassDB::bind_method(D_METHOD("multimesh_get_visible_instances", "multimesh"), &RenderingServer::multimesh_get_visible_instances); ClassDB::bind_method(D_METHOD("multimesh_get_visible_instances", "multimesh"), &RenderingServer::multimesh_get_visible_instances);
ClassDB::bind_method(D_METHOD("multimesh_set_buffer", "multimesh", "buffer"), &RenderingServer::multimesh_set_buffer); ClassDB::bind_method(D_METHOD("multimesh_set_buffer", "multimesh", "buffer"), &RenderingServer::multimesh_set_buffer);
ClassDB::bind_method(D_METHOD("multimesh_get_buffer_rd_rid", "multimesh"), &RenderingServer::multimesh_get_buffer_rd_rid);
ClassDB::bind_method(D_METHOD("multimesh_get_buffer", "multimesh"), &RenderingServer::multimesh_get_buffer); ClassDB::bind_method(D_METHOD("multimesh_get_buffer", "multimesh"), &RenderingServer::multimesh_get_buffer);
ClassDB::bind_method(D_METHOD("multimesh_set_buffer_interpolated", "multimesh", "buffer", "buffer_previous"), &RenderingServer::multimesh_set_buffer_interpolated); ClassDB::bind_method(D_METHOD("multimesh_set_buffer_interpolated", "multimesh", "buffer", "buffer_previous"), &RenderingServer::multimesh_set_buffer_interpolated);

View File

@ -475,6 +475,7 @@ public:
virtual Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const = 0; virtual Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const = 0;
virtual void multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) = 0; virtual void multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) = 0;
virtual RID multimesh_get_buffer_rd_rid(RID p_multimesh) const = 0;
virtual Vector<float> multimesh_get_buffer(RID p_multimesh) const = 0; virtual Vector<float> multimesh_get_buffer(RID p_multimesh) const = 0;
// Interpolation. // Interpolation.