Skip to content

Commit

Permalink
fix(geom): center capsule shape
Browse files Browse the repository at this point in the history
  • Loading branch information
luishfonseca committed Oct 6, 2023
1 parent 0019da7 commit 5d133d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/include/cubos/core/geom/capsule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ namespace cubos::core::geom
AABB aabb() const
{
AABB aabb;
aabb.min({-radius, -radius, -radius});
aabb.max({radius, radius + length, radius});
aabb.min({-radius, -radius - (length / 2.0F), -radius});
aabb.max({radius, radius + (length / 2.0F), radius});
return aabb;
}
};
Expand Down
4 changes: 3 additions & 1 deletion engine/samples/collisions/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ static void render(Query<Read<LocalToWorld>, Read<Collider>> query)
{
for (auto [entity, localToWorld, collider] : query)
{
cubos::core::gl::Debug::drawWireBox(collider->localAABB.box(), localToWorld->mat * collider->transform);
cubos::core::gl::Debug::drawWireBox(
collider->localAABB.box(),
glm::translate(localToWorld->mat * collider->transform, collider->localAABB.center()));
cubos::core::gl::Debug::drawWireBox(collider->worldAABB.box(),
glm::translate(glm::mat4{1.0}, collider->worldAABB.center()),
glm::vec3{1.0, 0.0, 0.0});
Expand Down

0 comments on commit 5d133d8

Please sign in to comment.