コード例 #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);
        }
コード例 #2
0
ファイル: idTraceModel.cs プロジェクト: iainmckay/idtech4.net
		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;
		}
コード例 #3
0
        private static int GetTraceModelHashKey(idTraceModel traceModel)
        {
            Vector3 v = traceModel.Bounds.Min;

            return(((int)traceModel._type << 8) ^ (traceModel._vertices.Length << 4) ^ (traceModel._edges.Length << 2) ^ (traceModel._polygons.Length << 0) ^ idMath.VectorHash(v));
        }
コード例 #4
0
ファイル: idTraceModel.cs プロジェクト: iainmckay/idtech4.net
		private static int GetTraceModelHashKey(idTraceModel traceModel)
		{
			Vector3 v = traceModel.Bounds.Min;

			return (((int) traceModel._type << 8) ^ (traceModel._vertices.Length << 4) ^ (traceModel._edges.Length << 2) ^ (traceModel._polygons.Length << 0) ^ idMath.VectorHash(v));
		}