Exemplo n.º 1
0
/*
============
idCVarSystemLocal::SetInternal
============
*/
void idCVarSystemLocal::SetInternal( const char *name, const char *value, int flags ) {
	int hash;
	idInternalCVar *internal;

	internal = FindInternal( name );

	if ( internal ) {
		internal->InternalSetString( value );
		internal->flags |= flags & ~CVAR_STATIC;
		internal->UpdateCheat();
	} else {
		internal = new idInternalCVar( name, value, flags );
		hash = cvarHash.GenerateKey( internal->nameString.c_str(), false );
		cvarHash.Add( hash, cvars.Append( internal ) );
	}
}
Exemplo n.º 2
0
/*
===============
idClipModel::RestoreTraceModels
===============
*/
void idClipModel::RestoreTraceModels( idRestoreGame *savefile ) {
	int i, num;
	ClearTraceModelCache();
	savefile->ReadInt( num );
	traceModelCache.SetNum( num );
	for( i = 0; i < num; i++ ) {
		trmCache_t *entry = new trmCache_t;
		savefile->ReadTraceModel( entry->trm );
		savefile->ReadFloat( entry->volume );
		savefile->ReadVec3( entry->centerOfMass );
		savefile->ReadMat3( entry->inertiaTensor );
		entry->refCount = 0;
		traceModelCache[i] = entry;
		traceModelHash.Add( GetTraceModelHashKey( entry->trm ), i );
	}
}
Exemplo n.º 3
0
/*
============
idCVarSystemLocal::Register
============
*/
void idCVarSystemLocal::Register( idCVar *cvar ) {
	int hash;
	idInternalCVar *internal;

	cvar->SetInternalVar( cvar );

	internal = FindInternal( cvar->GetName() );

	if ( internal ) {
		internal->Update( cvar );
	} else {
		internal = new idInternalCVar( cvar );
		hash = cvarHash.GenerateKey( internal->nameString.c_str(), false );
		cvarHash.Add( hash, cvars.Append( internal ) );
	}

	cvar->SetInternalVar( internal );
}
Exemplo n.º 4
0
/*
===============
idClipModel::AllocTraceModel
===============
*/
int idClipModel::AllocTraceModel( const idTraceModel &trm ) {
	int i, hashKey, traceModelIndex;
	trmCache_t *entry;
	hashKey = GetTraceModelHashKey( trm );
	for( i = traceModelHash.First( hashKey ); i >= 0; i = traceModelHash.Next( i ) ) {
		if( traceModelCache[i]->trm == trm ) {
			traceModelCache[i]->refCount++;
			return i;
		}
	}
	entry = new trmCache_t;
	entry->trm = trm;
	entry->trm.GetMassProperties( 1.0f, entry->volume, entry->centerOfMass, entry->inertiaTensor );
	entry->refCount = 1;
	traceModelIndex = traceModelCache.Append( entry );
	traceModelHash.Add( hashKey, traceModelIndex );
	return traceModelIndex;
}
Exemplo n.º 5
0
/*
=================
idRenderModelManagerLocal::AddModel
=================
*/
void idRenderModelManagerLocal::AddModel( idRenderModel *model ) {
	hash.Add( hash.GenerateKey( model->Name(), false ), models.Append( model ) );
}
Exemplo n.º 6
0
/*
===============
idClipModel::AllocTraceModel
===============
*/
int idClipModel::AllocTraceModel( const idTraceModel& trm, bool persistantThroughSaves )
{
	int i, hashKey, traceModelIndex;
	trmCache_t* entry;
	
	hashKey = GetTraceModelHashKey( trm );
	
	if( persistantThroughSaves )
	{
		// Look Inside the saved list.
		for( i = traceModelHash.First( hashKey ); i >= 0; i = traceModelHash.Next( i ) )
		{
			if( traceModelCache[i]->trm == trm )
			{
				traceModelCache[i]->refCount++;
				int flagged_index = i | TRACE_MODEL_SAVED;
				return flagged_index;
			}
		}
	}
	else
	{
	
		// Look inside the unsaved list.
		for( i = traceModelHash_Unsaved.First( hashKey ); i >= 0; i = traceModelHash_Unsaved.Next( i ) )
		{
			if( traceModelCache_Unsaved[i]->trm == trm )
			{
				traceModelCache_Unsaved[i]->refCount++;
				return i;
			}
		}
	}
	
	
	entry = new( TAG_PHYSICS_CLIP ) trmCache_t;
	entry->trm = trm;
	entry->trm.GetMassProperties( 1.0f, entry->volume, entry->centerOfMass, entry->inertiaTensor );
	entry->refCount = 1;
	
	if( persistantThroughSaves )
	{
		traceModelIndex = traceModelCache.Append( entry );
		traceModelHash.Add( hashKey, traceModelIndex );
		
		// Set the saved bit.
		traceModelIndex |= TRACE_MODEL_SAVED;
		
	}
	else
	{
		traceModelIndex = traceModelCache_Unsaved.Append( entry );
		traceModelHash_Unsaved.Add( hashKey, traceModelIndex );
		
		// remove the saved bit
		traceModelIndex &= ~TRACE_MODEL_SAVED;
		
	}
	
	return traceModelIndex;
}