Game Development Community

[T3D 1.01] DeadZone on input system

by Nicolas Buquet · in Torque 3D Professional · 01/06/2010 (11:27 am) · 0 replies

Hi,

in actionMap.cpp, in method "ActionMap::processAction", I see :
if ( pNode->flags & Node::HasDeadZone )
         {
            if ( value >= pNode->deadZoneBegin &&
                 value <= pNode->deadZoneEnd )
               value = 0.0f;
            else
            {
               if( value > 0 )
                  value = ( value - pNode->deadZoneBegin ) * ( 1.f / ( 1.f - pNode->deadZoneBegin ) );
               else
                  value = ( value + pNode->deadZoneBegin ) * ( 1.f / ( 1.f - pNode->deadZoneBegin ) );
            }
         }

So if value is in deadZone range, it is nullified : OK.

But if the input value is not in the deadZone range, it is re-evaluated (and not passed as is).

These code seems to me to estimate that the deadZone is center around 0 (deadZoneEnd = -deadZoneBegin), and that the input value range is from -1 to 1.

It seems to me that the code (if the input range is from -1 to 1) should be :

if ( pNode->flags & Node::HasDeadZone )
         {
            if ( value >= pNode->deadZoneBegin &&
                 value <= pNode->deadZoneEnd )
               value = 0.0f;
            else
            {
               if( value > pNode->deadZoneEnd )
                  value = ( value - pNode->deadZoneEnd ) / ( 1.f - pNode->deadZoneEnd );
               else
                  value = ( value - pNode->deadZoneBegin ) / ( pNode->deadZoneBegin + 1.f );
            }
         }

So with this, the input scale is normalized from -1 to 0 before the deadZoneBegin value, 0 in between the deadZone, and from 0 to 1 after the deadZoneEnd.

But if the initial input value is not from -1 to 1, then I don't think the input should not be normalized at all.

Any enlightenment on this devs ?

Nicolas Buquet
www.buquet-net.com/cv/