Exemple #1
0
        private static int AllocateTraceModel(idTraceModel traceModel)
        {
            int traceModelIndex;
            int hashKey = GetTraceModelHashKey(traceModel);

            if (_traceModelHashCache.ContainsKey(hashKey) == true)
            {
                traceModelIndex = _traceModelHashCache[hashKey];
                _traceModelCache[traceModelIndex].ReferenceCount++;

                return(traceModelIndex);
            }

            TraceModelCache entry = new TraceModelCache();

            entry.TraceModel = traceModel;
            entry.TraceModel.GetMassProperties(1.0f, out entry.Volume, out entry.CenterOfMass, out entry.InertiaTensor);
            entry.ReferenceCount = 1;

            traceModelIndex = _traceModelCache.Count;

            _traceModelCache.Add(entry);
            _traceModelHashCache.Add(hashKey, traceModelIndex);

            return(traceModelIndex);
        }
		private static int AllocateTraceModel(idTraceModel traceModel)
		{
			int traceModelIndex;
			int hashKey = GetTraceModelHashKey(traceModel);

			if(_traceModelHashCache.ContainsKey(hashKey) == true)
			{
				traceModelIndex = _traceModelHashCache[hashKey];
				_traceModelCache[traceModelIndex].ReferenceCount++;

				return traceModelIndex;
			}

			TraceModelCache entry = new TraceModelCache();
			entry.TraceModel = traceModel;
			entry.TraceModel.GetMassProperties(1.0f, out entry.Volume, out entry.CenterOfMass, out entry.InertiaTensor);
			entry.ReferenceCount = 1;

			traceModelIndex = _traceModelCache.Count;

			_traceModelCache.Add(entry);
			_traceModelHashCache.Add(hashKey, traceModelIndex);

			return traceModelIndex;
		}