-//
-// if original velocity is against the original velocity, stop dead
-// to avoid tiny occilations in sloping corners
-//
- if (DotProduct (ent->v.velocity, primal_velocity) <= 0)
- {
- VectorClear(ent->v.velocity);
- return blocked;
+ // run the impact function
+ if (impact)
+ {
+ SV_Impact (ent, trace.ent);
+
+ // break if removed by the impact function
+ if (ent->e->free)
+ break;
+ }
+
+
+ time_left -= time_left * trace.fraction;
+
+ // clipped to another plane
+ if (numplanes >= MAX_CLIP_PLANES)
+ {
+ // this shouldn't really happen
+ VectorClear(ent->v->velocity);
+ return 3;
+ }
+
+ VectorCopy (trace.plane.normal, planes[numplanes]);
+ numplanes++;
+
+ // modify original_velocity so it parallels all of the clip planes
+ for (i=0 ; i<numplanes ; i++)
+ {
+ ClipVelocity (original_velocity, planes[i], new_velocity, 1);
+ for (j=0 ; j<numplanes ; j++)
+ if (j != i)
+ {
+ // not ok
+ if (DotProduct (new_velocity, planes[j]) < 0)
+ break;
+ }
+ if (j == numplanes)
+ break;
+ }
+
+ if (i != numplanes)
+ {
+ // go along this plane
+ VectorCopy (new_velocity, ent->v->velocity);
+ }
+ else
+ {
+ // go along the crease
+ if (numplanes != 2)
+ {
+ VectorClear(ent->v->velocity);
+ return 7;
+ }
+ CrossProduct (planes[0], planes[1], dir);
+ // LordHavoc: thanks to taniwha of QuakeForge for pointing out this fix for slowed falling in corners
+ VectorNormalize(dir);
+ d = DotProduct (dir, ent->v->velocity);
+ VectorScale (dir, d, ent->v->velocity);
+ }
+
+ // if original velocity is against the original velocity,
+ // stop dead to avoid tiny occilations in sloping corners
+ if (DotProduct (ent->v->velocity, primal_velocity) <= 0)
+ {
+ VectorClear(ent->v->velocity);
+ return blocked;
+ }