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; }
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)); }
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)); }