-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DamageImpact and Impulse energy fix #602
Conversation
result.rotateWorld(glm::quat(m_angular * deltaSec)); | ||
|
||
return result; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Physics has a projectedTransformIn, seems duplicated. Probably this is the better place, so remove the other pls
My bad, no dup. projectedTransform should use this one though
|
||
if (voxelCollision.a().worldObject()->spawnState() != SpawnState::RemovalScheduled) { | ||
m_damageImpactAccumulator.parse(DamageImpact(voxelCollision.a().worldObject(), | ||
voxelCollision.a().voxel(), | ||
(speedB - speedA) * (massPerImpactB), | ||
glm::normalize(v2 - v1) * (freedEnergy/2), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain the *(freedEnergy/2) part? I assume you divide by 2 to distribute the freedEnergy evenly between the two colliders, but shouldn't this be relative to mass and speed of the colliding objects in respect to each other?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, yes/no. A collision frees energy (in Joule) which is applied to both collisionparties. The velocity-effect it has on them is determined by the mass, but this is not the job of the ImpactGenerator.
I find this distribution correct and remember putting a bit of thought into it when I originally implemented it, that's why I guess it has some logic to it ;)
… damage_and_impulse_energy_fix Conflicts: src/world/handler/damageimpactgenerator.cpp
…oxellancer into damage_and_impulse_energy_fix
Mastermerge and removal of unused method. This is a small one, lets ship it! |
|
||
glm::vec3 directional(((m1 - m2) * v1 + 2.0f * v2 * m2) / (m1 + m2)); | ||
glm::vec3 directional((m1*v1 + m2*v2 - m2 * (v1 - v2) * k) / (m1 + m2)); // See partly elastic impulse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these two are equal :D (except the k)
DamageImpact and Impulse energy fix
This moves to a more physically correct computation of damage and impulse created on collision of 2 objects, based on the formula of the partly elastic impulse.
Before this, bullets colliding with a heavy object got way too much damage, for example.