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


C++ CUtlVector::SetSize方法代码示例

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


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

示例1: Format

void CMySQLQuery::Format( const char *pFormat, ... )
{
	#define QUERYTEXT_GROWSIZE	1024

	// This keeps growing the buffer and calling _vsnprintf until the buffer is 
	// large enough to hold all the data.
	m_QueryText.SetSize( QUERYTEXT_GROWSIZE );
	while ( 1 )
	{
		va_list marker;
		va_start( marker, pFormat );
		int ret = _vsnprintf( m_QueryText.Base(), m_QueryText.Count(), pFormat, marker );
		va_end( marker );

		if ( ret < 0 )
		{
			m_QueryText.SetSize( m_QueryText.Count() + QUERYTEXT_GROWSIZE );
		}
		else
		{
			m_QueryText[ m_QueryText.Count() - 1 ] = 0;
			break;
		}
	}
}
开发者ID:Adidasman1,项目名称:source-sdk-2013,代码行数:25,代码来源:mpi_stats.cpp

示例2: Graphical_Start

static void Graphical_Start()
{
	g_bUseGraphics = VMPI_IsParamUsed( mpi_Graphics );
	if ( !g_bUseGraphics )
		return;
	
	// Setup an event so we'll wait until the window is ready.
	if ( !g_hCreateEvent )
	{
		g_hCreateEvent = CreateEvent( 0, 0, 0, 0 );
		g_hDestroyWindowEvent = CreateEvent( 0, 0, 0, 0 );
		g_hDestroyWindowCompletedEvent = CreateEvent( 0, 0, 0, 0 );
		InitializeCriticalSection( &g_CS );
	}
	ResetEvent( g_hCreateEvent );
	ResetEvent( g_hDestroyWindowCompletedEvent );

	g_WUStatus.SetSize( g_WorkUnits.Count() );
	for ( int i=0; i < g_WUStatus.Count(); i++ )
		g_WUStatus[i].m_iState = 0;
	
	// Setup our thread.
	CreateThread( NULL, 0, ThreadProc, NULL, 0, NULL );
	
	// Wait until the event is signaled.
	WaitForSingleObject( g_hCreateEvent, INFINITE );
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:27,代码来源:vmpi_distribute_tracker.cpp

示例3: jInit_destination

void jInit_destination(j_compress_ptr cinfo)
{
	jOut.Purge();
	jOut.SetSize(BLOCK_SIZE);
	cinfo->dest->next_output_byte = &jOut[0];
	cinfo->dest->free_in_buffer = jOut.Count();
}
开发者ID:Biohazard90,项目名称:source-shader-editor,代码行数:7,代码来源:chlsl_image.cpp

示例4: SetupDispBoxes

void SetupDispBoxes( const CCoreDispInfo *pListBase, int listSize, CUtlVector<CDispBox> &out )
{
	out.SetSize( listSize );
	for ( int i=0; i < listSize; i++ )
	{
		const CCoreDispInfo *pDisp = &pListBase[i];

		// Calculate the bbox for this displacement.
		Vector vMin(  1e24,  1e24,  1e24 );
		Vector vMax( -1e24, -1e24, -1e24 );

		for ( int iVert=0; iVert < 4; iVert++ )
		{
			const Vector &vTest = pDisp->GetSurface()->GetPoint( iVert );
			VectorMin( vTest, vMin, vMin );
			VectorMax( vTest, vMax, vMax );
		}		

		// Puff the box out a little.
		static float flPuff = 0.1f;
		vMin -= Vector( flPuff, flPuff, flPuff );
		vMax += Vector( flPuff, flPuff, flPuff );

		out[i].m_Min = vMin;
		out[i].m_Max = vMax;
	}
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:27,代码来源:disp_vbsp.cpp

示例5: GetCurrentWorkerText

bool CJobWatchDlg::GetCurrentWorkerText( 
	CUtlVector<char> &text, 
	unsigned long &curMessageIndex )
{
	text.SetSize( 0 );

	unsigned long jobWorkerID;
	if ( !GetCurJobWorkerID( jobWorkerID ) )
		return false;

	// Now copy all the text out.
	CMySQLQuery query;
	if ( curMessageIndex == 0 )
		query.Format( "select * from text_messages where JobWorkerID=%lu", jobWorkerID );
	else
		query.Format( "select * from text_messages where JobWorkerID=%lu and MessageIndex >= %lu", jobWorkerID, curMessageIndex );
	
	GetMySQL()->Execute( query );

	while ( GetMySQL()->NextRow() )
	{
		const char *pTextStr = GetMySQL()->GetColumnValue( "text" ).String();
		int len = strlen( pTextStr );
		text.AddMultipleToTail( len, pTextStr );

		curMessageIndex = GetMySQL()->GetColumnValue( "MessageIndex" ).UInt32() + 1;
	}

	text.AddToTail( 0 );
	return true;
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:31,代码来源:JobWatchDlg.cpp

示例6: OnPacketReceived

	virtual void OnPacketReceived( CTCPPacket *pPacket )
	{
		if ( g_ClientPacket.Count() < pPacket->GetLen() )
			g_ClientPacket.SetSize( pPacket->GetLen() );
		
		memcpy( g_ClientPacket.Base(), pPacket->GetData(), pPacket->GetLen() );
		g_ClientPacketEvent.SetEvent();
		pPacket->Release();
	}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:9,代码来源:ThreadedTCPSocketTest.cpp

示例7: InitMacroTexture

void InitMacroTexture( const char *pBSPFilename )
{
	// Get the world bounds (same ones used by minimaps and level designers know how to use).
	int i = 0;
	for (i = 0; i < num_entities; ++i)
	{
		char* pEntity = ValueForKey(&entities[i], "classname");
		if( !strcmp(pEntity, "worldspawn") )
		{
			GetVectorForKey( &entities[i], "world_mins", g_MacroWorldMins );
			GetVectorForKey( &entities[i], "world_maxs", g_MacroWorldMaxs );
			break;
		}
	}

	if ( i == num_entities )
	{
		Warning( "MaskOnMacroTexture: can't find worldspawn" );
		return;
	}


	// Load the macro texture that is mapped onto everything.
	char mapName[512], vtfFilename[512];
	Q_FileBase( pBSPFilename, mapName, sizeof( mapName ) );
	Q_snprintf( vtfFilename, sizeof( vtfFilename ), "materials/macro/%s/base.vtf", mapName );
	g_pGlobalMacroTextureData = LoadMacroTextureFile( vtfFilename );

	
	// Now load the macro texture for each face.
	g_FaceMacroTextures.SetSize( numfaces );
	for ( int iFace=0; iFace < numfaces; iFace++ )
	{
		g_FaceMacroTextures[iFace] = NULL;

		if ( iFace < g_FaceMacroTextureInfos.Count() )
		{
			unsigned short stringID = g_FaceMacroTextureInfos[iFace].m_MacroTextureNameID;
			if ( stringID != 0xFFFF )
			{
				const char *pMacroTextureName = &g_TexDataStringData[ g_TexDataStringTable[stringID] ];
				Q_snprintf( vtfFilename, sizeof( vtfFilename ), "%smaterials/%s.vtf", gamedir, pMacroTextureName );
				
				g_FaceMacroTextures[iFace] = FindMacroTexture( vtfFilename );
				if ( !g_FaceMacroTextures[iFace] )
				{
					g_FaceMacroTextures[iFace] = LoadMacroTextureFile( vtfFilename );
					if ( g_FaceMacroTextures[iFace] )
					{
						g_MacroTextureLookup.Insert( vtfFilename, g_FaceMacroTextures[iFace] );
					}
				}
			}
		}
	}
}
开发者ID:chrizonix,项目名称:RCBot2,代码行数:56,代码来源:macro_texture.cpp

示例8: ScratchPad_DrawSphere

void ScratchPad_DrawSphere(
	IScratchPad3D *pPad,
	const Vector &vCenter,
	float flRadius,
	const Vector &vColor,
	int nSubDivs )
{
	CUtlVector<Vector> prevPoints;
	prevPoints.SetSize( nSubDivs );
	
	// For each vertical slice.. (the top and bottom ones are just a single point).
	for ( int iSlice=0; iSlice < nSubDivs; iSlice++ )
	{
		float flHalfSliceAngle = M_PI * (float)iSlice / (nSubDivs - 1);

		if ( iSlice == 0 )
		{
			prevPoints[0] = vCenter + Vector( 0, 0, flRadius );
			for ( int z=1; z < prevPoints.Count(); z++ )
				prevPoints[z] = prevPoints[0];
		}
		else
		{
			for ( int iSubPt=0; iSubPt < nSubDivs; iSubPt++ )
			{
				float flHalfAngle = M_PI * (float)iSubPt / (nSubDivs - 1);
				float flAngle = flHalfAngle * 2;
				
				Vector pt;
				if ( iSlice == (nSubDivs - 1) )
				{
					pt = vCenter - Vector( 0, 0, flRadius );
				}
				else
				{
					pt.x = cos( flAngle ) * sin( flHalfSliceAngle );
					pt.y = sin( flAngle ) * sin( flHalfSliceAngle );
					pt.z = cos( flHalfSliceAngle );
					
					pt *= flRadius;
					pt += vCenter;
				}
				
				pPad->DrawLine( CSPVert( pt, vColor ), CSPVert( prevPoints[iSubPt], vColor ) );
				prevPoints[iSubPt] = pt;
			}
			
			if ( iSlice != (nSubDivs - 1) )
			{
				for ( int i=0; i < nSubDivs; i++ )
					pPad->DrawLine( CSPVert( prevPoints[i], vColor ), CSPVert( prevPoints[(i+1)%nSubDivs], vColor ) );
			}
		}
	}
}
开发者ID:SizzlingStats,项目名称:hl2sdk-ob-valve,代码行数:55,代码来源:ScratchPadUtils.cpp

示例9: VMPITracker_Start

void VMPITracker_Start( int nWorkUnits )
{
	g_bTrackWorkUnitEvents = (VMPI_IsParamUsed( mpi_TrackEvents ) || VMPI_IsParamUsed( mpi_Graphics ));
	g_flJobStartTime = Plat_FloatTime();
	g_WorkUnits.Purge();

	if ( g_bTrackWorkUnitEvents )
	{
		g_WorkUnits.SetSize( nWorkUnits );
	}

	Graphical_Start();
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:13,代码来源:vmpi_distribute_tracker.cpp

示例10: ShowMPIStats

void ShowMPIStats(
    double flTimeSpent,
    unsigned long nBytesSent,
    unsigned long nBytesReceived,
    unsigned long nMessagesSent,
    unsigned long nMessagesReceived )
{
    double flKSent = (nBytesSent + 511) / 1024;
    double flKRecv = (nBytesReceived + 511) / 1024;

    bool bShowOutput = VMPI_IsParamUsed( mpi_ShowDistributeWorkStats );

    bool bOldSuppress = g_bSuppressPrintfOutput;
    g_bSuppressPrintfOutput = !bShowOutput;

    Msg( "\n\n--------------------------------------------------------------\n");
    Msg( "Total Time       : %.2f\n", flTimeSpent );
    Msg( "Total Bytes Sent : %dk (%.2fk/sec, %d messages)\n", (int)flKSent, flKSent / flTimeSpent, nMessagesSent );
    Msg( "Total Bytes Recv : %dk (%.2fk/sec, %d messages)\n", (int)flKRecv, flKRecv / flTimeSpent, nMessagesReceived );
    if ( g_bMPIMaster )
    {
        Msg( "Duplicated WUs   : %I64u (%.1f%%)\n", g_nDuplicatedWUs, (float)g_nDuplicatedWUs * 100.0f / g_nWUs );

        Msg( "\nWU count by proc:\n" );

        int nProcs = VMPI_GetCurrentNumberOfConnections();

        CUtlVector<int> sortedProcs;
        sortedProcs.SetSize( nProcs );
        for ( int i=0; i < nProcs; i++ )
            sortedProcs[i] = i;

        qsort( sortedProcs.Base(), nProcs, sizeof( int ), SortByWUCount );

        for ( int i=0; i < nProcs; i++ )
        {
            const char *pMachineName = VMPI_GetMachineName( sortedProcs[i] );
            Msg( "%s", pMachineName );

            char formatStr[512];
            Q_snprintf( formatStr, sizeof( formatStr ), "%%%ds %I64u\n", 30 - strlen( pMachineName ), g_wuCountByProcess[ sortedProcs[i] ] );
            Msg( formatStr, ":" );
        }
    }
    Msg( "--------------------------------------------------------------\n\n ");

    g_bSuppressPrintfOutput = bOldSuppress;
}
开发者ID:steadyfield,项目名称:SourceEngine2007,代码行数:48,代码来源:vmpi_distribute_work.cpp

示例11: Test_InitRandomEntitySpawner

void Test_InitRandomEntitySpawner( const CCommand &args )
{
	// Put the list of registered functions into array form for convenience.
	g_StressEntityRegs.Purge();
	for ( CStressEntityReg *pCur=CStressEntityReg::GetListHead(); pCur; pCur=pCur->GetNext() )
		g_StressEntityRegs.AddToTail( pCur );

	// Create slots for all the entities..
	int nSlots = 100;
	if ( args.ArgC() >= 2 )
		nSlots = atoi( args[ 1 ] );

	g_StressEntities.Purge();
	g_StressEntities.SetSize( nSlots );

	Msg( "Test_InitRandomEntitySpawner: created %d slots.\n", nSlots );
}
开发者ID:FooGames,项目名称:SecobMod,代码行数:17,代码来源:test_stressentities.cpp

示例12: PortalMCThreadFn

DWORD WINAPI PortalMCThreadFn( LPVOID p )
{
	CUtlVector<char> data;
	data.SetSize( portalbytes + 128 );

	DWORD waitTime = 0;
	while ( WaitForSingleObject( g_MCThreadExitEvent.GetEventHandle(), waitTime ) != WAIT_OBJECT_0 )
	{
		CIPAddr ipFrom;
		int len = g_pPortalMCSocket->RecvFrom( data.Base(), data.Count(), &ipFrom );
		if ( len == -1 )
		{
			waitTime = 20;
		}
		else
		{
			// These lengths must match exactly what is sent in ReceivePortalFlow.
			if ( len == 2 + sizeof( g_PortalMCThreadUniqueID ) + sizeof( int ) + portalbytes )
			{
				// Perform more validation...
				if ( data[0] == VMPI_VVIS_PACKET_ID && data[1] == VMPI_PORTALFLOW_RESULTS )
				{
					if ( *((unsigned long*)&data[2]) == g_PortalMCThreadUniqueID )
					{
						int iWorkUnit = *((int*)&data[6]);
						if ( iWorkUnit >= 0 && iWorkUnit < g_numportals*2 )
						{
							portal_t *p = sorted_portals[iWorkUnit];
							if ( p )
							{
								++g_nMulticastPortalsReceived;
								memcpy( p->portalvis, &data[10], portalbytes );
								p->status = stat_done;
								waitTime = 0;
							}
						}
					}
				}
			}
		}
	}
	
	return 0;
}
开发者ID:Adidasman1,项目名称:source-sdk-2013,代码行数:44,代码来源:mpivis.cpp

示例13: LoadMacroTextureFile

CMacroTextureData* LoadMacroTextureFile( const char *pFilename )
{
	FileHandle_t hFile = g_pFileSystem->Open( pFilename, "rb" );
	if ( hFile == FILESYSTEM_INVALID_HANDLE )
		return NULL;

	// Read the file in.
	CUtlVector<char> tempData;
	tempData.SetSize( g_pFileSystem->Size( hFile ) );
	g_pFileSystem->Read( tempData.Base(), tempData.Count(), hFile );
	g_pFileSystem->Close( hFile );
	
	
	// Now feed the data into a CUtlBuffer (great...)
	CUtlBuffer buf;
	buf.Put( tempData.Base(), tempData.Count() );

	
	// Now make a texture out of it.
	IVTFTexture *pTex = CreateVTFTexture();
	if ( !pTex->Unserialize( buf ) )
		Error( "IVTFTexture::Unserialize( %s ) failed.", pFilename );

	pTex->ConvertImageFormat( IMAGE_FORMAT_RGBA8888, false );	// Get it in a format we like.

	
	// Now convert to a CMacroTextureData.
	CMacroTextureData *pData = new CMacroTextureData;
	pData->m_Width = pTex->Width();
	pData->m_Height = pTex->Height();
	pData->m_ImageData.EnsureCapacity( pData->m_Width * pData->m_Height * 4 );
	memcpy( pData->m_ImageData.Base(), pTex->ImageData(), pData->m_Width * pData->m_Height * 4 );

	DestroyVTFTexture( pTex );

	Msg( "-- LoadMacroTextureFile: %s\n", pFilename );
	return pData;
}
开发者ID:chrizonix,项目名称:RCBot2,代码行数:38,代码来源:macro_texture.cpp

示例14: ReadKeyValuesFile

KeyValues* ReadKeyValuesFile( const char *pFilename )
{
	// Read in the gameinfo.txt file and null-terminate it.
	FILE *fp = fopen( pFilename, "rb" );
	if ( !fp )
		return NULL;
	CUtlVector<char> buf;
	fseek( fp, 0, SEEK_END );
	buf.SetSize( ftell( fp ) + 1 );
	fseek( fp, 0, SEEK_SET );
	fread( buf.Base(), 1, buf.Count()-1, fp );
	fclose( fp );
	buf[buf.Count()-1] = 0;

	KeyValues *kv = new KeyValues( "" );
	if ( !kv->LoadFromBuffer( pFilename, buf.Base() ) )
	{
		kv->deleteThis();
		return NULL;
	}
	
	return kv;
}
开发者ID:SizzlingStats,项目名称:hl2sdk-ob-valve,代码行数:23,代码来源:filesystem_init.cpp

示例15: SnapRemainingVertsToSurface

void SnapRemainingVertsToSurface( CCoreDispInfo *pCoreDisp, ddispinfo_t *pDispInfo )
{
	// First, tesselate the displacement.
	CUtlVector<unsigned short> indices;
	CVBSPTesselateHelper helper;
	helper.m_pIndices = &indices;
	helper.m_pActiveVerts = pCoreDisp->GetAllowedVerts().Base();
	helper.m_pPowerInfo = pCoreDisp->GetPowerInfo();
	::TesselateDisplacement( &helper );

	// Figure out which verts are actually referenced in the tesselation.
	CUtlVector<bool> vertsTouched;
	vertsTouched.SetSize( pCoreDisp->GetSize() );
	memset( vertsTouched.Base(), 0, sizeof( bool ) * vertsTouched.Count() );

	for ( int i=0; i < indices.Count(); i++ )
		vertsTouched[ indices[i] ] = true;

	// Generate 2D floating point coordinates for each vertex. We use these to generate
	// barycentric coordinates, and the scale doesn't matter.
	CUtlVector<Vector2D> vertCoords;
	vertCoords.SetSize( pCoreDisp->GetSize() );
	for ( int y=0; y < pCoreDisp->GetHeight(); y++ )
	{
		for ( int x=0; x < pCoreDisp->GetWidth(); x++ )
			vertCoords[y*pCoreDisp->GetWidth()+x].Init( x, y );
	}
	
	// Now, for each vert not touched, snap its position to the main surface.
	for ( int y=0; y < pCoreDisp->GetHeight(); y++ )
	{
		for ( int x=0; x < pCoreDisp->GetWidth(); x++ )
		{
			int index = y * pCoreDisp->GetWidth() + x;
			if ( !( vertsTouched[index] ) )
			{
				float bcCoords[3];
				int iStartVert = -1;
				if ( FindEnclosingTri( vertCoords[index], vertCoords, indices, &iStartVert, bcCoords ) )
				{
					const Vector &A = pCoreDisp->GetVert( indices[iStartVert+0] );
					const Vector &B = pCoreDisp->GetVert( indices[iStartVert+1] );
					const Vector &C = pCoreDisp->GetVert( indices[iStartVert+2] );
					Vector vNewPos = A*bcCoords[0] + B*bcCoords[1] + C*bcCoords[2];

					// This is kind of cheesy, but it gets the job done. Since the CDispVerts store the
					// verts relative to some other offset, we'll just offset their position instead
					// of setting it directly.
					Vector vOffset = vNewPos - pCoreDisp->GetVert( index );

					// Modify the mapfile vert.
					CDispVert *pVert = &g_DispVerts[pDispInfo->m_iDispVertStart + index];
					pVert->m_vVector = (pVert->m_vVector * pVert->m_flDist) + vOffset;
					pVert->m_flDist = 1;

					// Modify the CCoreDispInfo vert (although it probably won't be used later).
					pCoreDisp->SetVert( index, vNewPos );
				}
				else
				{
					// This shouldn't happen because it would mean that the triangulation that 
					// disp_tesselation.h produced was missing a chunk of the space that the
					// displacement covers. 
					// It also could indicate a floating-point epsilon error.. check to see if
					// FindEnclosingTri finds a triangle that -almost- encloses the vert.
					Assert( false );
				}
			}
		}
	} 
}
开发者ID:TotallyMehis,项目名称:ZM-Updated,代码行数:71,代码来源:disp_vbsp.cpp


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