当前位置: 首页>>代码示例>>C++>>正文


C++ QVector::Magnitude方法代码示例

本文整理汇总了C++中QVector::Magnitude方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector::Magnitude方法的具体用法?C++ QVector::Magnitude怎么用?C++ QVector::Magnitude使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QVector的用法示例。


在下文中一共展示了QVector::Magnitude方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ProcessPendingJumps

void StarSystem::ProcessPendingJumps()
{
    for (unsigned int kk = 0; kk < pendingjump.size(); ++kk) {
        Unit *un = pendingjump[kk]->un.GetUnit();
        if (pendingjump[kk]->delay >= 0) {
            Unit *jp = pendingjump[kk]->jumppoint.GetUnit();
            if (un && jp) {
                QVector delta = ( jp->LocalPosition()-un->LocalPosition() );
                float   dist  = delta.Magnitude();
                if (pendingjump[kk]->delay > 0) {
                    float speed  = dist/pendingjump[kk]->delay;
                    bool  player = (_Universe->isPlayerStarship( un ) != NULL);
                    if (dist > 10 && player) {
                        if (un->activeStarSystem == pendingjump[kk]->orig)
                            un->SetCurPosition( un->LocalPosition()+SIMULATION_ATOM*delta*(speed/dist) );
                    } else if (!player) {
                        un->SetVelocity( Vector( 0, 0, 0 ) );
                    }
                    static bool setshieldzero =
                        XMLSupport::parse_bool( vs_config->getVariable( "physics", "jump_disables_shields", "true" ) );
                    if (setshieldzero)
                        SetShieldZero( un );
                }
            }
            double time = GetElapsedTime();
            if (time > 1)
                time = 1;
            pendingjump[kk]->delay -= time;
            continue;
        } else {
#ifdef JUMP_DEBUG
            VSFileSystem::vs_fprintf( stderr, "Volitalizing pending jump animation.\n" );
#endif
            _Universe->activeStarSystem()->VolitalizeJumpAnimation( pendingjump[kk]->animation );
        }
        int playernum = _Universe->whichPlayerStarship( un );
        //In non-networking mode or in networking mode or a netplayer wants to jump and is ready or a non-player jump
        if ( Network == NULL || playernum < 0 || ( Network != NULL && playernum >= 0 && Network[playernum].readyToJump() ) ) {
            Unit *un = pendingjump[kk]->un.GetUnit();
            StarSystem *savedStarSystem = _Universe->activeStarSystem();
            //Download client descriptions of the new zone (has to be blocking)
            if (Network != NULL)
                Network[playernum].downloadZoneInfo();
            if ( un == NULL || !_Universe->StillExists( pendingjump[kk]->dest )
                || !_Universe->StillExists( pendingjump[kk]->orig ) ) {
#ifdef JUMP_DEBUG
                VSFileSystem::vs_fprintf( stderr, "Adez Mon! Unit destroyed during jump!\n" );
#endif
                delete pendingjump[kk];
                pendingjump.erase( pendingjump.begin()+kk );
                --kk;
                continue;
            }
            bool dosightandsound = ( (pendingjump[kk]->dest == savedStarSystem) || _Universe->isPlayerStarship( un ) );
            _Universe->setActiveStarSystem( pendingjump[kk]->orig );
            if ( un->TransferUnitToSystem( kk, savedStarSystem, dosightandsound ) )
                un->DecreaseWarpEnergy( false, 1.0f );
            if (dosightandsound)
                _Universe->activeStarSystem()->DoJumpingComeSightAndSound( un );
	    _Universe->AccessCockpit()->OnJumpEnd(un);
            delete pendingjump[kk];
            pendingjump.erase( pendingjump.begin()+kk );
            --kk;
            _Universe->setActiveStarSystem( savedStarSystem );
            //In networking mode we tell the server we want to go back in game
            if (Network != NULL) {
                //Find the corresponding networked player
                if (playernum >= 0) {
                    Network[playernum].inGame();
                    Network[playernum].unreadyToJump();
                }
            }
        }
    }
}
开发者ID:Ezeer,项目名称:VegaStrike_win32FR,代码行数:75,代码来源:star_system_generic.cpp


注:本文中的QVector::Magnitude方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。