Adds mesh scaling to mesh collider

Updates the mesh collider to include a scale parameter, allowing for non-uniform scaling of the collision mesh.

This provides more flexibility in defining collision shapes and supports a wider range of scenarios.
This commit is contained in:
2025-11-09 17:02:07 +03:00
parent 7b0e2127dc
commit b2a512eafe
2 changed files with 9 additions and 26 deletions

View File

@@ -4,7 +4,7 @@
#include <gtest/gtest.h>
#include <omath/collision/gjk_algorithm.hpp>
TEST(UnitTestGjk, TestCollisionTrue)
namespace
{
const std::vector<omath::Vector3<float>> mesh = {
{-1.f, -1.f, -1.f},
@@ -16,6 +16,9 @@ TEST(UnitTestGjk, TestCollisionTrue)
{ 1.f, -1.f, 1.f},
{ 1.f, -1.f, -1.f}
};
}
TEST(UnitTestGjk, TestCollisionTrue)
{
const omath::collision::MeshCollider collider_a(mesh, {0.f, 0.f, 0.f});
const omath::collision::MeshCollider collider_b(mesh, {0.f, 0.5f, 0.f});
@@ -26,17 +29,6 @@ TEST(UnitTestGjk, TestCollisionTrue)
}
TEST(UnitTestGjk, TestCollisionFalse)
{
const std::vector<omath::Vector3<float>> mesh = {
{-1.f, -1.f, -1.f},
{-1.f, -1.f, 1.f},
{-1.f, 1.f, -1.f},
{-1.f, 1.f, 1.f},
{ 1.f, 1.f, 1.f}, // x = +1 vertices (put {1,1,1} first in case your support breaks ties by first-hit)
{ 1.f, 1.f, -1.f},
{ 1.f, -1.f, 1.f},
{ 1.f, -1.f, -1.f}
};
const omath::collision::MeshCollider collider_a(mesh, {0.f, 0.f, 0.f});
const omath::collision::MeshCollider collider_b(mesh, {0.f, 2.1f, 0.f});
@@ -47,17 +39,6 @@ TEST(UnitTestGjk, TestCollisionFalse)
TEST(UnitTestGjk, TestCollisionEqualOrigin)
{
const std::vector<omath::Vector3<float>> mesh = {
{-1.f, -1.f, -1.f},
{-1.f, -1.f, 1.f},
{-1.f, 1.f, -1.f},
{-1.f, 1.f, 1.f},
{ 1.f, 1.f, 1.f}, // x = +1 vertices (put {1,1,1} first in case your support breaks ties by first-hit)
{ 1.f, 1.f, -1.f},
{ 1.f, -1.f, 1.f},
{ 1.f, -1.f, -1.f}
};
const omath::collision::MeshCollider collider_a(mesh, {0.f, 0.f, 0.f});
const omath::collision::MeshCollider collider_b(mesh, {0.f, 0.f, 0.f});