mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add 'mass' and 'elasticity' entity properties
This commit is contained in:
parent
f945719d7a
commit
ad32d7b6db
5 changed files with 20 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue