[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [BUG] Xscortch Bug Padded physics


>Please CC as I'm not subscribed.
Unfortunately I can't do that as the web archive of the mailing list
doesn't show email domain names.  But in case anyone else needs to
know...

I found a the same problem a while ago and put together a quick fix. 
When a roller-class object drops onto a bouncing floor type (elastic,
etc), the calculations do go into an infinite loop.  It comes down to
a simple patch of the boundary conditon checking code.  This is a
reconstruction, I don't have my code onhand, but I believe it's
accurate:

in sphysics.c:
in function _sc_traj_pass_wall_elastic(const sc_config *c,
sc_trajectory *tr,                                             
sc_trajectory_data *t, double elasticity) :
{
...
/* Check if we hit ground or ceiling. */
   if(rint(tr->cury) < 0) {

/*Begin Roller Glitch Workaround*/
      if( tr->type == SC_TRAJ_ROLLER )
            return(SC_TRAJ_IMPACT_GROUND);
/*End Roller Glitch Workaround*/

      tr->cury =  0;
      tr->ctry =  tr->cury;
      tr->ctrx =  tr->curx;
      tr->vely = -sc_traj_get_velocity_y(tr) * elasticity;
      tr->velx =  sc_traj_get_velocity_x(tr);
      tr->stopstep -= tr->timestep;
      tr->timestep  = 0;
      tr->finalstep = 0;
      t->stepy  =  fabs(t->stepy) * elasticity;
      t->stepx *=  elasticity;
   }
...
}

Hope this is helpful to someone.  At least, unlike my ugly magnetized
weapons hack, it's practical.


Notices