Odd stuff happening at second 1.0

View: New views
1 Messages — Rating Filter:   Alert me  

Odd stuff happening at second 1.0

by Enrico Mattea :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,
I've found that when s->currentTime reaches 1.0, human driver (whichever
its car is) sets accel to 0.0, just to gradually reapply it in the
following 5 timesteps. This happens in all gears, with all tracks. And I
think it's not very realistic... I've found in human.cpp the following
lines:

    if (s->currentTime > 1.0) {
        // thanks Christos for the following: gradual accel/brake
changes for on/off controls.
        const tdble inc_rate = 0.2f;

        if (cmd[CMD_BRAKE].type == GFCTRL_TYPE_JOY_BUT ||
            cmd[CMD_BRAKE].type == GFCTRL_TYPE_MOUSE_BUT ||
            cmd[CMD_BRAKE].type == GFCTRL_TYPE_KEYBOARD ||
            cmd[CMD_BRAKE].type == GFCTRL_TYPE_SKEYBOARD)
        {
            tdble d_brake = car->_brakeCmd - HCtx[idx]->pbrake;
            if (fabs(d_brake) > inc_rate && car->_brakeCmd >
HCtx[idx]->pbrake) {
                car->_brakeCmd = MIN(car->_brakeCmd, HCtx[idx]->pbrake +
inc_rate*d_brake/fabs(d_brake));
            }
            HCtx[idx]->pbrake = car->_brakeCmd;
        }

        if (cmd[CMD_THROTTLE].type == GFCTRL_TYPE_JOY_BUT ||
            cmd[CMD_THROTTLE].type == GFCTRL_TYPE_MOUSE_BUT ||
            cmd[CMD_THROTTLE].type == GFCTRL_TYPE_KEYBOARD ||
            cmd[CMD_THROTTLE].type == GFCTRL_TYPE_SKEYBOARD)
        {
            tdble d_accel = car->_accelCmd - HCtx[idx]->paccel;
            if (fabs(d_accel) > inc_rate && car->_accelCmd >
HCtx[idx]->paccel) {
                car->_accelCmd = MIN(car->_accelCmd, HCtx[idx]->paccel +
inc_rate*d_accel/fabs(d_accel));
            }
            HCtx[idx]->paccel = car->_accelCmd;
        }
    }


and, setting inc_rate at line 3 to 1.0f, the bug doesn't seem to happen
anymore. The problem is that I suppose line 3 is important for other
things, so my remedy must be changed into something else.

The problem disappears also commenting lines 17 to 27, but, as for the
previous stuff, I think those lines are useful for something.

So, what would it possible to do?

Cheers,
Ocirne.

P.S.: I'm not sure whether it has been made intentionally or not. If
that's the case, and it's useful for something, sorry for all the spam
above.


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Torcs-devel mailing list
Torcs-devel@...
https://lists.sourceforge.net/lists/listinfo/torcs-devel