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

@@ -13,20 +13,22 @@ namespace omath::collision
{
public:
using VertexType = Vector3<float>;
MeshCollider(const std::vector<Vector3<float>>& vertexes, const Vector3<float> origin)
: m_vertexes(vertexes), m_origin(origin)
MeshCollider(const std::vector<VertexType>& vertexes, const VertexType& origin, const VertexType& scale = {1.f, 1.f, 1.f})
: m_vertexes(vertexes),m_scale(scale), m_origin(origin)
{
if (m_vertexes.empty())
throw std::runtime_error("Collider cannot have 0 vertexes");
}
std::vector<Vector3<float>> m_vertexes;
Vector3<float> m_scale;
Vector3<float> m_origin;
source_engine::ViewAngles m_rotation;
[[nodiscard]]
source_engine::Mat4X4 to_world() const
{
return mat_translation(m_origin) * source_engine::rotation_matrix(m_rotation);
return mat_scale(m_scale) * mat_translation(m_origin) * source_engine::rotation_matrix(m_rotation);
}
[[nodiscard]]