# Smooth Collision Question

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

## Recommended Posts

Hello, I have finally gotten far enough in my game engine development process to deal with objects colliding against the world. My concern was smooth movement when an object collides with a world surface. Unsure of what to search for on the internet, and a review of my mathematic books revealing nothing, I ultimately decided upon referring to the Quake 3 source code and I found the following:
void PM_ClipVelocity( vec3_t in, vec3_t normal, vec3_t out, float overbounce ) {
float	backoff;
float	change;
int		i;

backoff = DotProduct (in, normal);

if ( backoff < 0 ) {
backoff *= overbounce;
} else {
backoff /= overbounce;
}

for ( i=0 ; i<3 ; i++ ) {
change = normal*backoff;
out = in - change;
}
}

"overbounce" was typically set to 1.001f when the function was called. "normal" is the the normal vector of the plane that the object is colliding with, "in" is the velocity of the the object, and "out" is the vector that should represent the adjusted velocity of the colliding object. By modifying this code to work with the design of my engine I have achieved the desired effect of smooth movement against surfaces. My question is this: What exactly is this code doing? Can anyone explain it to me or point me to a reference that explains why this solution does what it does. I mean I'm satisfied with the results, but I would like to know why it works. Peace Out.

##### Share on other sites
Alright I figured it out. I was reading about reflection vector calculation in the book "Mathematics for 3D Game Programming & Computer Graphics" by Eric Lengyel (p. 125) and in explaining how a reflected vector can be calculated he explains that the first part is to find the vector perpendicular to the surface with respect to the vector which is given by:

perp N L = L-(N*L)N which is the equation used in the function I mentioned in the previous post. Where N is the normal vector of the plane, and L is the vector representing the velocity of the object.

1. 1
Rutin
36
2. 2
3. 3
4. 4
5. 5

• 12
• 14
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633343
• Total Posts
3011431
• ### Who's Online (See full list)

There are no registered users currently online

×