add 'mass' and 'elasticity' entity properties

This commit is contained in:
MihailRis 2026-03-14 18:47:10 +03:00
parent f945719d7a
commit ad32d7b6db
5 changed files with 20 additions and 0 deletions

View file

@ -26,6 +26,12 @@ static glm::vec3 calc_collsion_velocity_result(
) {
const auto& vA = a.velocity;
const auto& vB = b.velocity;
if (glm::isinf(a.mass)) {
return vA;
}
if (glm::isinf(b.mass)) {
return vA * -a.elasticity + vB;
}
const auto& mA = a.mass;
const auto& mB = b.mass;
return (mA * vA + mB * vB + a.elasticity * mB * (vB - vA)) / (mA + mB);