components/prboom/p_map.c
/*
 * killough 9/12/98
 *
 * Applies "torque" to objects, based on all contacted linedefs
 */
killough 9/12/98
Applies "torque" to objects, based on all contacted linedefs
killough 9 / 12 / 98 Applies " torque " to objects based on all contacted linedefs
void P_ApplyTorque(mobj_t *mo)
{
  int xl = ((tmbbox[BOXLEFT] =
       mo->x - mo->radius) - bmaporgx) >> MAPBLOCKSHIFT;
  int xh = ((tmbbox[BOXRIGHT] =
       mo->x + mo->radius) - bmaporgx) >> MAPBLOCKSHIFT;
  int yl = ((tmbbox[BOXBOTTOM] =
       mo->y - mo->radius) - bmaporgy) >> MAPBLOCKSHIFT;
  int yh = ((tmbbox[BOXTOP] =
       mo->y + mo->radius) - bmaporgy) >> MAPBLOCKSHIFT;
  int bx,by,flags = mo->intflags; 
  tmthing = mo;
  validcount++; 
  for (bx = xl ; bx <= xh ; bx++)
    for (by = yl ; by <= yh ; by++)
      P_BlockLinesIterator(bx, by, PIT_ApplyTorque);
  if (mo->momx | mo->momy)
    mo->intflags |= MIF_FALLING;
  else  
    mo->intflags &= ~MIF_FALLING;
  if (!((mo->intflags | flags) & MIF_FALLING))   
    mo->gear = 0;                                
  else
    if (mo->gear < MAXGEAR)                      
      mo->gear++;                                
}
void P_ApplyTorque ( mobj_t * mo ) { int xl = ( ( tmbbox [ BOXLEFT ] = mo -> x - mo -> radius ) - bmaporgx ) >> MAPBLOCKSHIFT ; int xh = ( ( tmbbox [ BOXRIGHT ] = mo -> x + mo -> radius ) - bmaporgx ) >> MAPBLOCKSHIFT ; int yl = ( ( tmbbox [ BOXBOTTOM ] = mo -> y - mo -> radius ) - bmaporgy ) >> MAPBLOCKSHIFT ; int yh = ( ( tmbbox [ BOXTOP ] = mo -> y + mo -> radius ) - bmaporgy ) >> MAPBLOCKSHIFT ; int bx , by , flags = mo -> intflags ; tmthing = mo ; validcount ++ ; for ( bx = xl ; bx <= xh ; bx ++ ) for ( by = yl ; by <= yh ; by ++ ) P_BlockLinesIterator ( bx , by , PIT_ApplyTorque ) ; if ( mo -> momx | mo -> momy ) mo -> intflags |= MIF_FALLING ; else mo -> intflags &= ~ MIF_FALLING ; if ( ! ( ( mo -> intflags | flags ) & MIF_FALLING ) ) mo -> gear = 0 ; else if ( mo -> gear < MAXGEAR ) mo -> gear ++ ; }
killough 9/12/98
 Applies "torque" to objects, based on all contacted linedefs
killough 9 / 12 / 98 Applies " torque " to objects based on all contacted linedefs
//Remember the current state, for gear-change /* prevents checking same line twice */ /* If any momentum, mark object as 'falling' using engine-internal flags */ // Clear the engine-internal flag indicating falling object. /* If the object has been moving, step up the gear.
   * This helps reach equilibrium and avoid oscillations.
   *
   * Doom has no concept of potential energy, much less
   * of rotation, so we have to creatively simulate these
   * systems somehow :)
   */ // If not falling for a while, // Reset it to full strength // Else if not at max gear, // move up a gear