Skip to content

Commit 6e9d31f

Browse files
committed
Implemented multimesh_get_buffer_rd_rid function into RenderingServer.
Fixed style error. Updated dummy mesh_storage to move from cpp to h the return of a blank Rid on _multimesh_get_buffer_rd_rid.
1 parent 673f396 commit 6e9d31f

File tree

11 files changed

+29
-0
lines changed

11 files changed

+29
-0
lines changed

doc/classes/RenderingServer.xml

+7
Original file line numberDiff line numberDiff line change
@@ -2545,6 +2545,13 @@
25452545
[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.
25462546
</description>
25472547
</method>
2548+
<method name="multimesh_get_buffer_rd_rid" qualifiers="const">
2549+
<return type="RID" />
2550+
<param index="0" name="multimesh" type="RID" />
2551+
<description>
2552+
Returns the [RenderingDevice] [RID] handle of the [MultiMesh], which can be used as any other buffer on the Rendering Device.
2553+
</description>
2554+
</method>
25482555
<method name="multimesh_get_custom_aabb" qualifiers="const">
25492556
<return type="AABB" />
25502557
<param index="0" name="multimesh" type="RID" />

drivers/gles3/storage/mesh_storage.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,10 @@ void MeshStorage::_multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_
19741974
}
19751975
}
19761976

1977+
RID MeshStorage::_multimesh_get_buffer_rd_rid(RID p_multimesh) const {
1978+
ERR_FAIL_V_MSG(RID(), "GLES3 does not contain a Rid for the multimesh buffer.");
1979+
}
1980+
19771981
Vector<float> MeshStorage::_multimesh_get_buffer(RID p_multimesh) const {
19781982
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
19791983
ERR_FAIL_NULL_V(multimesh, Vector<float>());

drivers/gles3/storage/mesh_storage.h

+1
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ class MeshStorage : public RendererMeshStorage {
517517
virtual Color _multimesh_instance_get_color(RID p_multimesh, int p_index) const override;
518518
virtual Color _multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const override;
519519
virtual void _multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) override;
520+
virtual RID _multimesh_get_buffer_rd_rid(RID p_multimesh) const override;
520521
virtual Vector<float> _multimesh_get_buffer(RID p_multimesh) const override;
521522

522523
virtual void _multimesh_set_visible_instances(RID p_multimesh, int p_visible) override;

servers/rendering/dummy/storage/mesh_storage.h

+1
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ class MeshStorage : public RendererMeshStorage {
170170
virtual Color _multimesh_instance_get_color(RID p_multimesh, int p_index) const override { return Color(); }
171171
virtual Color _multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const override { return Color(); }
172172
virtual void _multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) override;
173+
virtual RID _multimesh_get_buffer_rd_rid(RID p_multimesh) const override { return RID(); }
173174
virtual Vector<float> _multimesh_get_buffer(RID p_multimesh) const override;
174175

175176
virtual void _multimesh_set_visible_instances(RID p_multimesh, int p_visible) override {}

servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -1997,6 +1997,12 @@ void MeshStorage::_multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_
19971997
}
19981998
}
19991999

2000+
RID MeshStorage::_multimesh_get_buffer_rd_rid(RID p_multimesh) const {
2001+
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
2002+
ERR_FAIL_NULL_V(multimesh, RID());
2003+
return multimesh->buffer;
2004+
}
2005+
20002006
Vector<float> MeshStorage::_multimesh_get_buffer(RID p_multimesh) const {
20012007
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
20022008
ERR_FAIL_NULL_V(multimesh, Vector<float>());

servers/rendering/renderer_rd/storage_rd/mesh_storage.h

+1
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ class MeshStorage : public RendererMeshStorage {
651651
virtual Color _multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const override;
652652

653653
virtual void _multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) override;
654+
virtual RID _multimesh_get_buffer_rd_rid(RID p_multimesh) const override;
654655
virtual Vector<float> _multimesh_get_buffer(RID p_multimesh) const override;
655656

656657
virtual void _multimesh_set_visible_instances(RID p_multimesh, int p_visible) override;

servers/rendering/rendering_server_default.h

+1
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ class RenderingServerDefault : public RenderingServer {
403403
FUNC2RC(Color, multimesh_instance_get_custom_data, RID, int)
404404

405405
FUNC2(multimesh_set_buffer, RID, const Vector<float> &)
406+
FUNC1RC(RID, multimesh_get_buffer_rd_rid, RID)
406407
FUNC1RC(Vector<float>, multimesh_get_buffer, RID)
407408

408409
FUNC3(multimesh_set_buffer_interpolated, RID, const Vector<float> &, const Vector<float> &)

servers/rendering/storage/mesh_storage.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ void RendererMeshStorage::multimesh_set_buffer(RID p_multimesh, const Vector<flo
223223
_multimesh_set_buffer(p_multimesh, p_buffer);
224224
}
225225

226+
RID RendererMeshStorage::multimesh_get_buffer_rd_rid(RID p_multimesh) const {
227+
return _multimesh_get_buffer_rd_rid(p_multimesh);
228+
}
229+
226230
Vector<float> RendererMeshStorage::multimesh_get_buffer(RID p_multimesh) const {
227231
return _multimesh_get_buffer(p_multimesh);
228232
}

servers/rendering/storage/mesh_storage.h

+2
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ class RendererMeshStorage {
141141
virtual Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const;
142142

143143
virtual void multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer);
144+
virtual RID multimesh_get_buffer_rd_rid(RID p_multimesh) const;
144145
virtual Vector<float> multimesh_get_buffer(RID p_multimesh) const;
145146

146147
virtual void multimesh_set_buffer_interpolated(RID p_multimesh, const Vector<float> &p_buffer, const Vector<float> &p_buffer_prev);
@@ -178,6 +179,7 @@ class RendererMeshStorage {
178179
virtual Color _multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const = 0;
179180

180181
virtual void _multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) = 0;
182+
virtual RID _multimesh_get_buffer_rd_rid(RID p_multimesh) const = 0;
181183
virtual Vector<float> _multimesh_get_buffer(RID p_multimesh) const = 0;
182184

183185
virtual void _multimesh_set_visible_instances(RID p_multimesh, int p_visible) = 0;

servers/rendering_server.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -2452,6 +2452,7 @@ void RenderingServer::_bind_methods() {
24522452
ClassDB::bind_method(D_METHOD("multimesh_set_visible_instances", "multimesh", "visible"), &RenderingServer::multimesh_set_visible_instances);
24532453
ClassDB::bind_method(D_METHOD("multimesh_get_visible_instances", "multimesh"), &RenderingServer::multimesh_get_visible_instances);
24542454
ClassDB::bind_method(D_METHOD("multimesh_set_buffer", "multimesh", "buffer"), &RenderingServer::multimesh_set_buffer);
2455+
ClassDB::bind_method(D_METHOD("multimesh_get_buffer_rd_rid", "multimesh"), &RenderingServer::multimesh_get_buffer_rd_rid);
24552456
ClassDB::bind_method(D_METHOD("multimesh_get_buffer", "multimesh"), &RenderingServer::multimesh_get_buffer);
24562457

24572458
ClassDB::bind_method(D_METHOD("multimesh_set_buffer_interpolated", "multimesh", "buffer", "buffer_previous"), &RenderingServer::multimesh_set_buffer_interpolated);

servers/rendering_server.h

+1
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ class RenderingServer : public Object {
475475
virtual Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const = 0;
476476

477477
virtual void multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) = 0;
478+
virtual RID multimesh_get_buffer_rd_rid(RID p_multimesh) const = 0;
478479
virtual Vector<float> multimesh_get_buffer(RID p_multimesh) const = 0;
479480

480481
// Interpolation.

0 commit comments

Comments
 (0)