Jump to content
  • Advertisement
Sign in to follow this  
Meshboy

Quake PM_ClipVelocity

This topic is 3174 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi folks! I am doing a FPS game where i have sucessful collision detection and response. I do this by only doing this: Compute collision (distance to line (only x,z)-velocity length (speed) if collision then take vector from closestPointOnLine to Player and push the player out. but i am NEVER using dot product for this. i have seen many slide plane calculations and they all use dot produt. something like: sphere_velocity -= n * (sphere_velocity.dotProduct(n)); My formula is this one: min = minimum distance player can go to against wall Ni = normal from closest_point_to_plane vs = velocity speed d = Distance to wall i am using this and it works: sphere_velocity += Ni * (min -(d+vs); Quake II and III using this formula for modifying the velocity, but my question is: can anyone explain what the dot-product is suppose to do? (both in this formula and all other sliding plane calucaltions)???? void PM_ClipVelocity (vec3_t in, vec3_t normal, vec3_t out, float overbounce) { float backoff; float change; int i; backoff = DotProduct (in, normal) * overbounce; for (i=0 ; i<3 ; i++) { change = normal*backoff; out = in - change; if (out > -STOP_EPSILON && out < STOP_EPSILON) out = 0; } }

Share this post


Link to post
Share on other sites
Advertisement
it's the reflection algorithm. If you have done A level physics / optics, that should be trivial.

Doing a dot-product in that context, is basically calculating the length of the 'velocity' along the normal of collision, or the projection length, provided the normal is normalised. If you want, name it the impact speed (speed being a real number, the magnitude of a velocity vector), or how hard the object hits the collision surface.


sphere_velocity -= n * (sphere_velocity.dotProduct(n));

basically 'kills' the speed, by subtracting the impact speed from the velocity vector along the normal of collision, from itself. All components of the velocity along the normal direction will be zeroed. That's a pure sliding motion.

Share this post


Link to post
Share on other sites
but then i am missing something... now if the player if face up against the wall with full speed, i just push him out the distance+the current speed. The right thing would be to take away all speed if player facing dead-a-head and some if the angle is just slightly towards the wall...

hm... the normal in this formula, is it closestPoint to the player or is it the real "normal" of the plane?

now i calculate this seperatle, check if player has collided and with what angle, and then reduce the speed depending on the angle. But this is done seperatly...

thanks for your answer man, you are always helpful and knows things 100% correct! =)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!