Skip to content

Commit

Permalink
Merge pull request godotengine#94893 from rune-scape/no-const-cast-me…
Browse files Browse the repository at this point in the history
…sh-storage

Avoid `const_cast` in `mesh_storage.h`
  • Loading branch information
akien-mga committed Sep 10, 2024
2 parents 91c66b5 + f04a9bb commit bc4c60c
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions drivers/gles3/storage/mesh_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/storage/mesh_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ class MeshStorage : public RendererMeshStorage {
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;
Expand Down
2 changes: 1 addition & 1 deletion servers/rendering/dummy/storage/mesh_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class MeshStorage : public RendererMeshStorage {
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(); }
Expand Down
4 changes: 2 additions & 2 deletions servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2041,15 +2041,15 @@ 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;
}
Expand Down
2 changes: 1 addition & 1 deletion servers/rendering/renderer_rd/storage_rd/mesh_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ class MeshStorage : public RendererMeshStorage {
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;

Expand Down
2 changes: 1 addition & 1 deletion servers/rendering/storage/mesh_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions servers/rendering/storage/mesh_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class RendererMeshStorage {
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;
Expand Down Expand Up @@ -183,7 +183,7 @@ class RendererMeshStorage {
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.
Expand Down

0 comments on commit bc4c60c

Please sign in to comment.