Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] Make CollisionShape selection box use shape AABB #71320

Merged
merged 1 commit into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions scene/3d/collision_shape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ String CollisionShape::get_configuration_warning() const {
return warning;
}

#ifdef TOOLS_ENABLED
AABB CollisionShape::get_fallback_gizmo_aabb() const {
if (shape.is_null()) {
return Spatial::get_fallback_gizmo_aabb();
}

// get_debug_mesh() is not const because the mesh is lazy initialized and cached.
// It would be better if we can mark the cache mutable and make get_debug_mesh() const.
return const_cast<CollisionShape *>(this)->shape->get_debug_mesh()->get_aabb();
}
#endif

void CollisionShape::_bind_methods() {
//not sure if this should do anything
ClassDB::bind_method(D_METHOD("resource_changed", "resource"), &CollisionShape::resource_changed);
Expand Down
4 changes: 4 additions & 0 deletions scene/3d/collision_shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class CollisionShape : public Spatial {

String get_configuration_warning() const;

#ifdef TOOLS_ENABLED
virtual AABB get_fallback_gizmo_aabb() const;
#endif

CollisionShape();
~CollisionShape();
};
Expand Down