Skip to content
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

Merged
merged 8 commits into from
Aug 19, 2014
Merged

Conversation

mrzzzrm
Copy link

@mrzzzrm mrzzzrm commented May 1, 2014

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.

This was referenced May 1, 2014
result.rotateWorld(glm::quat(m_angular * deltaSec));

return result;
}
Copy link
Contributor

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

@psieg
Copy link
Contributor

psieg commented May 4, 2014

Well, you certainly turned the tides at the battle 😀
hole

looking good :shipit:


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),
Copy link
Contributor

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?

Copy link
Author

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 ;)

@mrzzzrm
Copy link
Author

mrzzzrm commented Aug 18, 2014

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
Copy link
Member

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)

@xchrdw
Copy link
Member

xchrdw commented Aug 19, 2014

:shipit:

mrzzzrm pushed a commit that referenced this pull request Aug 19, 2014
@mrzzzrm mrzzzrm merged commit 1c112a5 into master Aug 19, 2014
@mrzzzrm mrzzzrm deleted the damage_and_impulse_energy_fix branch August 19, 2014 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants