コード例 #1
0
ファイル: MoveSpline.cpp プロジェクト: Exodius/ArkCORE-NG
MoveSpline::UpdateResult MoveSpline::_updateState(int32& ms_time_diff)
{
    if (Finalized())
    {
        ms_time_diff = 0;
        return Result_Arrived;
    }

    UpdateResult result = Result_None;

    int32 minimal_diff = std::min(ms_time_diff, segment_time_elapsed());
    
    //sometimes we receive here values < 0 //then the core crash on ASSERT //this is only a first workaround.. // i need help here
    if (minimal_diff < 0)
    {
        TC_LOG_ERROR("misc", "MoveSpline::_updateState (Prevent Core Crash: minimal_diff is < 0) ms_time_diff:%u \n", ms_time_diff);
        _Finalize();
        ms_time_diff = 0;
        return Result_Arrived;
    }
    
    ASSERT(minimal_diff >= 0);
    time_passed += minimal_diff;
    ms_time_diff -= minimal_diff;

    if (time_passed >= next_timestamp())
    {
        ++point_Idx;
        if (point_Idx < spline.last())
        {
            result = Result_NextSegment;
        }
        else
        {
            if (spline.isCyclic())
            {
                point_Idx = spline.first();
                time_passed = time_passed % Duration();
                result = Result_NextCycle;
            }
            else
            {
                _Finalize();
                ms_time_diff = 0;
                result = Result_Arrived;
            }
        }
    }

    return result;
}
コード例 #2
0
ファイル: MoveSpline.cpp プロジェクト: Expecto/FCore
MoveSpline::UpdateResult MoveSpline::_updateState(int32& ms_time_diff)
{
	if (ms_time_diff < 0)
	{
		ms_time_diff = 0;
		return Result_Arrived;
	}

    if (Finalized())
    {
        ms_time_diff = 0;
        return Result_Arrived;
    }

    UpdateResult result = Result_None;

    int32 minimal_diff = std::min(ms_time_diff, segment_time_elapsed());
    ASSERT(minimal_diff >= 0);
    time_passed += minimal_diff;
    ms_time_diff -= minimal_diff;

    if (time_passed >= next_timestamp())
    {
        ++point_Idx;
        if (point_Idx < spline.last())
        {
            result = Result_NextSegment;
        }
        else
        {
            if (spline.isCyclic())
            {
                point_Idx = spline.first();
                time_passed = time_passed % Duration();
                result = Result_NextSegment;
            }
            else
            {
                _Finalize();
                ms_time_diff = 0;
                result = Result_Arrived;
            }
        }
    }

    return result;
}