Merge pull request #94893 from rune-scape/no-const-cast-mesh-storage

Avoid `const_cast` in `mesh_storage.h`
This commit is contained in:
Rémi Verschelde 2024-09-10 09:51:22 +02:00
commit bc4c60c933
No known key found for this signature in database
GPG Key ID: C3336907360768E1
7 changed files with 10 additions and 10 deletions

View File

@ -1769,14 +1769,14 @@ AABB MeshStorage::_multimesh_get_custom_aabb(RID p_multimesh) const {
return multimesh->custom_aabb;
}
AABB MeshStorage::_multimesh_get_aabb(RID p_multimesh) const {
AABB MeshStorage::_multimesh_get_aabb(RID p_multimesh) {
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_NULL_V(multimesh, AABB());
if (multimesh->custom_aabb != AABB()) {
return multimesh->custom_aabb;
}
if (multimesh->aabb_dirty) {
const_cast<MeshStorage *>(this)->_update_dirty_multimeshes();
_update_dirty_multimeshes();
}
return multimesh->aabb;
}

View File

@ -510,7 +510,7 @@ public:
virtual RID _multimesh_get_mesh(RID p_multimesh) const override;
virtual void _multimesh_set_custom_aabb(RID p_multimesh, const AABB &p_aabb) override;
virtual AABB _multimesh_get_custom_aabb(RID p_multimesh) const override;
virtual AABB _multimesh_get_aabb(RID p_multimesh) const override;
virtual AABB _multimesh_get_aabb(RID p_multimesh) override;
virtual Transform3D _multimesh_instance_get_transform(RID p_multimesh, int p_index) const override;
virtual Transform2D _multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const override;

View File

@ -163,7 +163,7 @@ public:
virtual AABB _multimesh_get_custom_aabb(RID p_multimesh) const override { return AABB(); }
virtual RID _multimesh_get_mesh(RID p_multimesh) const override { return RID(); }
virtual AABB _multimesh_get_aabb(RID p_multimesh) const override { return AABB(); }
virtual AABB _multimesh_get_aabb(RID p_multimesh) override { return AABB(); }
virtual Transform3D _multimesh_instance_get_transform(RID p_multimesh, int p_index) const override { return Transform3D(); }
virtual Transform2D _multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const override { return Transform2D(); }

View File

@ -2041,7 +2041,7 @@ AABB MeshStorage::_multimesh_get_custom_aabb(RID p_multimesh) const {
return multimesh->custom_aabb;
}
AABB MeshStorage::_multimesh_get_aabb(RID p_multimesh) const {
AABB MeshStorage::_multimesh_get_aabb(RID p_multimesh) {
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_NULL_V(multimesh, AABB());
if (multimesh->custom_aabb != AABB()) {
@ -2049,7 +2049,7 @@ AABB MeshStorage::_multimesh_get_aabb(RID p_multimesh) const {
}
if (multimesh->aabb_dirty) {
const_cast<MeshStorage *>(this)->_update_dirty_multimeshes();
_update_dirty_multimeshes();
}
return multimesh->aabb;
}

View File

@ -652,7 +652,7 @@ public:
virtual void _multimesh_set_custom_aabb(RID p_multimesh, const AABB &p_aabb) override;
virtual AABB _multimesh_get_custom_aabb(RID p_multimesh) const override;
virtual AABB _multimesh_get_aabb(RID p_multimesh) const override;
virtual AABB _multimesh_get_aabb(RID p_multimesh) override;
virtual MultiMeshInterpolator *_multimesh_get_interpolator(RID p_multimesh) const override;

View File

@ -285,7 +285,7 @@ int RendererMeshStorage::multimesh_get_visible_instances(RID p_multimesh) const
return _multimesh_get_visible_instances(p_multimesh);
}
AABB RendererMeshStorage::multimesh_get_aabb(RID p_multimesh) const {
AABB RendererMeshStorage::multimesh_get_aabb(RID p_multimesh) {
return _multimesh_get_aabb(p_multimesh);
}

View File

@ -151,7 +151,7 @@ public:
virtual void multimesh_set_visible_instances(RID p_multimesh, int p_visible);
virtual int multimesh_get_visible_instances(RID p_multimesh) const;
virtual AABB multimesh_get_aabb(RID p_multimesh) const;
virtual AABB multimesh_get_aabb(RID p_multimesh);
virtual RID _multimesh_allocate() = 0;
virtual void _multimesh_initialize(RID p_rid) = 0;
@ -183,7 +183,7 @@ public:
virtual void _multimesh_set_visible_instances(RID p_multimesh, int p_visible) = 0;
virtual int _multimesh_get_visible_instances(RID p_multimesh) const = 0;
virtual AABB _multimesh_get_aabb(RID p_multimesh) const = 0;
virtual AABB _multimesh_get_aabb(RID p_multimesh) = 0;
// Multimesh is responsible for allocating / destroying a MultiMeshInterpolator object.
// This allows shared functionality for interpolation across backends.