Guest User

Untitled

a guest
Feb 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. if (!ground && !onladder) {
  2.             double dis = vel.speed()*double(delta)/1000;
  3.             //Iterate through all footholds
  4.             for (auto i = footholds.begin(); i != footholds.end(); i++) {
  5.                 auto other = *i;
  6.                 if (!other->walk && group!=other->group) {continue;}
  7.                 double a1 = angdif(vel.direction(), other->dir);
  8.                 if (a1 <= 0) {continue;}
  9.                 double a2 = angdif(vel.direction(), pdir(x, y, other->x1, other->y1));
  10.                 if (a2 >= 0) {continue;}
  11.                 double a3 = angdif(vel.direction(), pdir(x, y, other->x2, other->y2));
  12.                 if (a3 <= 0) {continue;}
  13.                 double d1 = pdis(xprev, yprev, other->x1, other->y1);
  14.                 double a4 = angdif(other->dir+90, pdir(xprev, yprev, other->x1, other->y1));
  15.                 double d2 = ldx(d1, a4);
  16.                 if (d2<0) {continue;}
  17.                 if (d2 <= dis) {
  18.                     if (downjump && downjump->group == other->group) {
  19.                         downjump = 0;
  20.                         continue;
  21.                     }
  22.                     ground = other;
  23.                     dis = d2;
  24.                 }
  25.             }
  26.             //Deal with the foothold of interest
  27.             if (ground) {
  28.                 //double a5 = angdif(ground->dir+90, vel.direction());
  29.                 //double d3 = dis/ldx(1, a5);
  30.                 x = xprev+ldx(dis, vel.direction());
  31.                 y = yprev+ldy(dis, vel.direction());
  32.                 vel.limit(ground->dir);
  33.                 if (ground->walk) {
  34.                     x = max(min(x, ground->x2-0.1), ground->x1+0.1);
  35.                 }
  36.                 group = ground->group;
  37.                 if (z[1] != ground->layer) {
  38.                     z[1] = ground->layer;
  39.                     resort = true;
  40.                 }
  41.             }
  42.         }
Add Comment
Please, Sign In to add comment