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


C++ DynamicArray::Clear方法代码示例

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


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

示例1:

void TradeRouteData::ReturnPath
(
    const PLAYER_INDEX          owner,
    DynamicArray<MapPoint> &    waypoints,
    DynamicArray<MapPoint> &    fullpath,
	double &                    cost
)
{
	fullpath.Clear();
	Path partialAstarPath;
	float partialcost = 0;
	cost = 0.0;

	m_astarPath->Clear();

	int     nwp = waypoints.Num();
	sint32  r;

	for (int wp = 0; wp < nwp - 1; wp++)
    {
		if (wp == 0)
        {
			r = g_theTradeAstar.FindPath(owner, waypoints[wp], waypoints[wp + 1],
			                             *m_astarPath, partialcost, FALSE);
			Assert(r);
		} else {
			r = g_theTradeAstar.FindPath(owner, waypoints[wp], waypoints[wp + 1],
								  partialAstarPath, partialcost, FALSE);
			Assert(r);
			m_astarPath->Concat(partialAstarPath);
		}
		cost += partialcost;
	}

	fullpath.Insert(waypoints[0]);
	MapPoint pnt;
	m_crossesWater = FALSE;
	for (int p = 1; p < m_astarPath->Num(); p++) {
		WORLD_DIRECTION d;
		m_astarPath->GetCurrentDir(d);
		sint32 r = fullpath[p-1].GetNeighborPosition(d, pnt);
		Assert(r);
		if(r) {
			fullpath.Insert(pnt);
			if(g_theWorld->IsWater(pnt)) {
				m_crossesWater = TRUE;
			}
		}

		m_astarPath->IncDir();
	}
}
开发者ID:jleclanche,项目名称:darkdust-ctp2,代码行数:52,代码来源:TradeRouteData.cpp

示例2: Initialize

/// @copydoc CommandLineInitializer::Initialize()
bool CommandLineInitializationWin::Initialize( String& rModuleName, DynamicArray< String >& rArguments )
{
    rModuleName.Clear();
    rArguments.Clear();

    // Get the module file name and full command-line string (must use the wide-character versions, as there is only
    // a CommandLineToArgvW() and not a CommandLineToArgvA() to parse the command-line string).
    LPWSTR pCommandLine = GetCommandLineW();
    HELIUM_ASSERT( pCommandLine );
    if( !pCommandLine )
    {
        HELIUM_TRACE(
            TraceLevels::Error,
            TXT( "CommandLineInitializationWin::Initialize(): Failed to retrieve command-line string.\n" ) );

        return false;
    }

    WCHAR moduleFileName[ MAX_PATH ];
    DWORD moduleFileNameLength = GetModuleFileNameW( NULL, moduleFileName, MAX_PATH );
    if( moduleFileNameLength == 0 )
    {
        HELIUM_TRACE(
            TraceLevels::Error,
            TXT( "CommandLineInitializationWin::Initialize(): Failed to retrieve module file name string.\n" ) );

        return false;
    }

    moduleFileName[ MAX_PATH - 1 ] = L'\0';
    moduleFileNameLength = Min< DWORD >( moduleFileNameLength, MAX_PATH - 1 );

    // If the command line contains just the module file name, don't parse it and simply store the module name
    // (if no command-line arguments are specified, GetCommandLine() may return a string containing just the module
    // name without quoting it, which would in turn cause CommandLineToArgvW() to split the module path if it
    // contains any spaces).
    if( CompareString( pCommandLine, moduleFileName ) == 0 )
    {
        StringConverter< wchar_t, tchar_t >::Convert( rModuleName, moduleFileName );

        return true;
    }

    // Parse the command-line string.
    int argumentCount = 0;
    LPWSTR* ppArguments = CommandLineToArgvW( pCommandLine, &argumentCount );
    HELIUM_ASSERT( ppArguments );
    if( !ppArguments )
    {
        HELIUM_TRACE(
            TraceLevels::Error,
            TXT( "CommandLineInitializationWin::Initialize(): Failed to parse command-line arguments.\n" ) );

        return false;
    }

    StringConverter< wchar_t, tchar_t >::Convert( rModuleName, moduleFileName );

    if( argumentCount > 1 )
    {
        rArguments.Reserve( argumentCount - 1 );

        for( int argumentIndex = 1; argumentIndex < argumentCount; ++argumentIndex )
        {
            LPWSTR pArgument = ppArguments[ argumentIndex ];
            HELIUM_ASSERT( pArgument );
            String* pConvertedArgument = rArguments.New();
            HELIUM_ASSERT( pConvertedArgument );
            StringConverter< wchar_t, tchar_t >::Convert( *pConvertedArgument, pArgument );
        }
    }

    LocalFree( ppArguments );

    return true;
}
开发者ID:foolhuang,项目名称:Helium,代码行数:77,代码来源:CommandLineInitializerWin.cpp

示例3: SynchronizeShaderParameters

/// Synchronize the shader parameter list with those provided by the selected shader variant.
///
/// @see SynchronizeFloatVectorParameters(), SynchronizeTextureParameters()
void Material::SynchronizeShaderParameters()
{
    Shader* pShader = m_spShader;
    if( !pShader )
    {
        m_float1Parameters.Clear();
        m_float2Parameters.Clear();
        m_float3Parameters.Clear();
        m_float4Parameters.Clear();
        m_textureParameters.Clear();
    }

    // Synchronize floating-point constant parameters.
    Name parameterConstantBufferName = GetParameterConstantBufferName();

    size_t existingFloat1Count = m_float1Parameters.GetSize();
    size_t existingFloat2Count = m_float2Parameters.GetSize();
    size_t existingFloat3Count = m_float3Parameters.GetSize();
    size_t existingFloat4Count = m_float4Parameters.GetSize();

    DynamicArray< Float1Parameter > newFloat1Parameters;
    DynamicArray< Float2Parameter > newFloat2Parameters;
    DynamicArray< Float3Parameter > newFloat3Parameters;
    DynamicArray< Float4Parameter > newFloat4Parameters;
    for( size_t shaderTypeIndex = 0; shaderTypeIndex < HELIUM_ARRAY_COUNT( m_shaderVariants ); ++shaderTypeIndex )
    {
        ShaderVariant* pShaderVariant = m_shaderVariants[ shaderTypeIndex ];
        if( !pShaderVariant )
        {
            continue;
        }

        const ShaderConstantBufferInfoSet* pBufferSet = pShaderVariant->GetConstantBufferInfoSet( 0 );
        if( !pBufferSet )
        {
            continue;
        }

        bool bCheckDuplicates =
            ( !newFloat1Parameters.IsEmpty() || !newFloat2Parameters.IsEmpty() || !newFloat3Parameters.IsEmpty() ||
            !newFloat4Parameters.IsEmpty() );

        const DynamicArray< ShaderConstantBufferInfo >& rBuffers = pBufferSet->buffers;
        size_t bufferCount = rBuffers.GetSize();
        for( size_t bufferIndex = 0; bufferIndex < bufferCount; ++bufferIndex )
        {
            const ShaderConstantBufferInfo& rBufferInfo = rBuffers[ bufferIndex ];
            if( rBufferInfo.name != parameterConstantBufferName )
            {
                continue;
            }

            const DynamicArray< ShaderConstantInfo >& rConstants = rBufferInfo.constants;
            size_t constantCount = rConstants.GetSize();
            for( size_t constantIndex = 0; constantIndex < constantCount; ++constantIndex )
            {
                const ShaderConstantInfo& rConstantInfo = rConstants[ constantIndex ];

                // Constants must be between 1 and 4 floating-point values.
                uint16_t constantSize = rConstantInfo.usedSize;
                if( constantSize < sizeof( float32_t ) || constantSize > sizeof( float32_t ) * 4 )
                {
                    continue;
                }

                Name constantName = rConstantInfo.name;

                size_t parameterIndex;
                if( bCheckDuplicates )
                {
                    size_t parameterCount = newFloat1Parameters.GetSize();
                    for( parameterIndex = 0; parameterIndex < parameterCount; ++parameterIndex )
                    {
                        if( newFloat1Parameters[ parameterIndex ].name == constantName )
                        {
                            break;
                        }
                    }

                    if( parameterIndex < parameterCount )
                    {
                        continue;
                    }

                    parameterCount = newFloat2Parameters.GetSize();
                    for( parameterIndex = 0; parameterIndex < parameterCount; ++parameterIndex )
                    {
                        if( newFloat2Parameters[ parameterIndex ].name == constantName )
                        {
                            break;
                        }
                    }

                    if( parameterIndex < parameterCount )
                    {
                        continue;
                    }
//.........这里部分代码省略.........
开发者ID:foolhuang,项目名称:Helium,代码行数:101,代码来源:Material.cpp


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