- // 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;
+ 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);
+ blocked = 7;
+ break;
+ }
+ 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);
+ break;
+ }