/// <summary> /// To shift the expiration of internal instruments <see cref="ContinuousSecurity.ExpirationJumps"/> to a size equas to <paramref name="offset" />. /// </summary> /// <param name="offset">The size of the expiration shift.</param> public void Offset(TimeSpan offset) { lock (_expirationJumps.SyncRoot) { var dict = new PairSet <Security, DateTimeOffset>(); foreach (var security in InnerSecurities) { if (security.ExpiryDate == null) { throw new InvalidOperationException(LocalizedStrings.Str698Params.Put(security.Id)); } var expiryDate = (DateTimeOffset)security.ExpiryDate + offset; if (expiryDate > security.ExpiryDate) { throw new ArgumentOutOfRangeException(nameof(offset), offset, LocalizedStrings.Str699Params.Put(security.Id, expiryDate, security.ExpiryDate)); } dict.Add(security, expiryDate); } _expirationJumps.Clear(); _expirationJumps.AddRange(dict); } }
public Task <INodeVisitor> ValidateAsync(ValidationContext context) { var comparedFragmentPairs = new PairSet(); var cachedFieldsAndFragmentNames = new Dictionary <SelectionSet, CachedField>(); return(new EnterLeaveListener(config => { config.Match <SelectionSet>(selectionSet => { List <Conflict> conflicts = FindConflictsWithinSelectionSet( context, cachedFieldsAndFragmentNames, comparedFragmentPairs, context.TypeInfo.GetParentType(), selectionSet); foreach (var conflict in conflicts) { context.ReportError(new ValidationError( context.OriginalQuery, "5.3.2", FieldsConflictMessage(conflict.Reason.Name, conflict.Reason), conflict.FieldsLeft.Concat(conflict.FieldsRight).ToArray() )); } }); }).ToTask()); }
internal static void BeginLoad() { const int DEFAULT_CAPACITY = 11; //37; BaseMorphoFormNative.BeginLoad(); MorphoTypeNative.BeginLoad(); tempBufferPairs = new PairSet(DEFAULT_CAPACITY); /*---tempBufferPairs = new Dictionary< pair_t, pair_t >( default(pair_t_IEqualityComparer) );*/ }
private List <Conflict> FindConflictsWithinSelectionSet( Dictionary <SelectionSet, CachedField> cachedFieldsAndFragmentNames, PairSet comparedFragmentPairs, INamedType parentType, SelectionSet selectionSet) { var conflicts = new List <Conflict>(); var cachedField = GetFieldsAndFragmentNames( cachedFieldsAndFragmentNames, parentType, selectionSet); var fieldMap = cachedField.NodeAndDef; var fragmentNames = cachedField.Names; CollectConflictsWithin( conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, fieldMap); if (fragmentNames.Count != 0) { // (B) Then collect conflicts between these fields and those represented by // each spread fragment name found. var comparedFragments = new ObjMap <bool>(); for (var i = 0; i < fragmentNames.Count; i++) { CollectConflictsBetweenFieldsAndFragment( conflicts, cachedFieldsAndFragmentNames, comparedFragments, comparedFragmentPairs, false, fieldMap, fragmentNames[i]); // (C) Then compare this fragment with all other fragments found in this // selection set to collect conflicts between fragments spread together. // This compares each item in the list of fragment names to every other // item in that same list (except for itself). for (var j = i + 1; j < fragmentNames.Count; j++) { CollectConflictsBetweenFragments( conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, false, fragmentNames[i], fragmentNames[j]); } } } return(conflicts); }
public async Task <ActionResult> DeleteConfirmed(int id) { PairSet pairSet = await db.PairSet.FindAsync(id); db.PairSet.Remove(pairSet); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
internal static void BeginLoad() { const int DEFAULT_CAPACITY = 11; BaseMorphoFormNative.BeginLoad(); MorphoTypeNative.BeginLoad(); tempBufferPairs = new PairSet(DEFAULT_CAPACITY); }
public async Task <ActionResult> Edit([Bind(Include = "PairId,PairNumber,PairStart,PairEnd")] PairSet pairSet) { if (ModelState.IsValid) { db.Entry(pairSet).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(pairSet)); }
//--- Constructors --- public MockResourceReader(PairSet set) { if (set == null) { return; } foreach (var pair in set) { _resources[pair.Key] = pair.Value; } }
public async Task <ActionResult> Create([Bind(Include = "PairId,PairNumber,PairStart,PairEnd")] PairSet pairSet) { if (ModelState.IsValid) { db.PairSet.Add(pairSet); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(pairSet)); }
public void ReadFrom(BinaryReader reader, ushort v1format, ushort v2format) { ushort rowCount = reader.ReadUInt16(); for (int i = 0; i < rowCount; ++i) { //GlyphID SecondGlyph GlyphID of second glyph in the pair-first glyph is listed in the Coverage table //ValueRecord Value1 Positioning data for the first glyph in the pair //ValueRecord Value2 Positioning data for the second glyph in the pair ushort secondGlyp = reader.ReadUInt16(); ValueRecord v1 = ValueRecord.CreateFrom(reader, v1format); ValueRecord v2 = ValueRecord.CreateFrom(reader, v2format); PairSet pset = new PairSet(secondGlyp, v1, v2); } }
public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PairSet pairSet = await db.PairSet.FindAsync(id); if (pairSet == null) { return(HttpNotFound()); } return(View(pairSet)); }
public void ReadFrom(BinaryReader reader, ushort v1format, ushort v2format) { ushort rowCount = reader.ReadUInt16(); for (int i = 0; i < rowCount; ++i) { //GlyphID SecondGlyph GlyphID of second glyph in the pair-first glyph is listed in the Coverage table //ValueRecord Value1 Positioning data for the first glyph in the pair //ValueRecord Value2 Positioning data for the second glyph in the pair ushort secondGlyph = reader.ReadUInt16(); ValueRecord v1 = ValueRecord.CreateFrom(reader, v1format); ValueRecord v2 = ValueRecord.CreateFrom(reader, v2format); PairSet pset = new PairSet(secondGlyph, v1, v2); } }
void IPersistable.Save(SettingsStorage settings) { var ps = new PairSet <Tuple <string, Type>, IContentWindow>(); foreach (var control in _controls) { ps.Add(Tuple.Create(control.Id, control.Control.GetType()), control); } settings.SaveUISettings(DockSite, ps); if (EmulationService != null) { settings.SetValue("EmulationService", EmulationService.Save()); } }
public bool FindPairSet(ushort secondGlyphIndex, out PairSet foundPairSet) { int j = pairSets.Length; for (int i = 0; i < j; ++i) { if (pairSets[i].secondGlyph == secondGlyphIndex) { //found foundPairSet = pairSets[i]; return(true); } } // foundPairSet = new PairSet();//empty return(false); }
private void CollectConflictsBetween( ValidationContext context, List <Conflict> conflicts, Dictionary <SelectionSet, CachedField> cachedFieldsAndFragmentNames, PairSet comparedFragmentPairs, bool parentFieldsAreMutuallyExclusive, Dictionary <string, List <FieldDefPair> > fieldMap1, Dictionary <string, List <FieldDefPair> > fieldMap2) { // A field map is a keyed collection, where each key represents a response // name and the value at that key is a list of all fields which provide that // response name. For any response name which appears in both provided field // maps, each field from the first field map must be compared to every field // in the second field map to find potential conflicts. foreach (var responseName in fieldMap1.Keys) { fieldMap2.TryGetValue(responseName, out List <FieldDefPair> fields2); if (fields2 != null && fields2.Count != 0) { var fields1 = fieldMap1[responseName]; for (var i = 0; i < fields1.Count; i++) { for (var j = 0; j < fields2.Count; j++) { Conflict conflict = FindConflict( context, cachedFieldsAndFragmentNames, comparedFragmentPairs, parentFieldsAreMutuallyExclusive, responseName, fields1[i], fields2[j]); if (conflict != null) { conflicts.Add(conflict); } } } } } }
private void CollectConflictsWithin( ValidationContext context, List <Conflict> conflicts, Dictionary <SelectionSet, CachedField> cachedFieldsAndFragmentNames, PairSet comparedFragmentPairs, Dictionary <string, List <FieldDefPair> > fieldMap) { // A field map is a keyed collection, where each key represents a response // name and the value at that key is a list of all fields which provide that // response name. For every response name, if there are multiple fields, they // must be compared to find a potential conflict. foreach (var entry in fieldMap) { string responseName = entry.Key; var fields = entry.Value; // This compares every field in the list to every other field in this list // (except to itself). If the list only has one item, nothing needs to // be compared. if (fields.Count > 1) { for (int i = 0; i < fields.Count; i++) { for (int j = i + 1; j < fields.Count; j++) { var conflict = FindConflict( context, cachedFieldsAndFragmentNames, comparedFragmentPairs, false, // within one collection is never mutually exclusive responseName, fields[i], fields[j]); if (conflict != null) { conflicts.Add(conflict); } } } } } }
public void Validate(SelectionSet selectionSet) { var comparedFragmentPairs = new PairSet(); var cachedFieldsAndFragmentNames = new Dictionary <SelectionSet, CachedField>(); var conflicts = FindConflictsWithinSelectionSet( cachedFieldsAndFragmentNames, comparedFragmentPairs, _context.Tracker.GetParentType(), selectionSet); foreach (var conflict in conflicts) { _context.Error( ValidationErrorCodes.R532FieldSelectionMerging, FieldsConflictMessage(conflict.Reason.Name, conflict.Reason), conflict.FieldsLeft.Concat(conflict.FieldsRight) ); } }
/// <inheritdoc/> /// <exception cref="OverlappingFieldsCanBeMergedError"/> public Task <INodeVisitor> ValidateAsync(ValidationContext context) { //TODO: make static instance when enabling this rule var comparedFragmentPairs = new PairSet(); var cachedFieldsAndFragmentNames = new Dictionary <SelectionSet, CachedField>(); return(new MatchingNodeVisitor <SelectionSet>((selectionSet, context) => { List <Conflict> conflicts = FindConflictsWithinSelectionSet( context, cachedFieldsAndFragmentNames, comparedFragmentPairs, context.TypeInfo.GetParentType(), selectionSet); foreach (var conflict in conflicts) { context.ReportError(new OverlappingFieldsCanBeMergedError(context, conflict)); } }).ToTask()); }
/// <inheritdoc/> /// <exception cref="OverlappingFieldsCanBeMergedError"/> public Task <INodeVisitor> ValidateAsync(ValidationContext context) { var comparedFragmentPairs = new PairSet(); var cachedFieldsAndFragmentNames = new Dictionary <SelectionSet, CachedField>(); return(new EnterLeaveListener(config => { config.Match <SelectionSet>(selectionSet => { List <Conflict> conflicts = FindConflictsWithinSelectionSet( context, cachedFieldsAndFragmentNames, comparedFragmentPairs, context.TypeInfo.GetParentType(), selectionSet); foreach (var conflict in conflicts) { context.ReportError(new OverlappingFieldsCanBeMergedError(context, conflict)); } }); }).ToTask()); }
public void Validate(SelectionSet selectionSet) { if (_context.Tracker.ParentType is null) { return; } var comparedFragmentPairs = new PairSet(); var cachedFieldsAndFragmentNames = new Dictionary <SelectionSet, CachedField>(); var conflicts = FindConflictsWithinSelectionSet( cachedFieldsAndFragmentNames, comparedFragmentPairs, _context.Tracker.ParentType ?? throw new InvalidOperationException("todo: ParentType is null"), selectionSet); foreach (var conflict in conflicts) { _context.Error( ValidationErrorCodes.R532FieldSelectionMerging, FieldsConflictMessage(conflict.Reason.Name, conflict.Reason), conflict.FieldsLeft.Concat(conflict.FieldsRight) ); } }
protected void GImpactVsGImpactFindPairs( ref IndexedMatrix trans0, ref IndexedMatrix trans1, GImpactShapeInterface shape0, GImpactShapeInterface shape1, PairSet pairset) { if (shape0.HasBoxSet() && shape1.HasBoxSet()) { GImpactQuantizedBvh.FindCollision(shape0.GetBoxSet(), ref trans0, shape1.GetBoxSet(), ref trans1, pairset); } else { AABB boxshape0 = new AABB(); AABB boxshape1 = new AABB(); int i = shape0.GetNumChildShapes(); while (i-- != 0) { shape0.GetChildAabb(i, ref trans0, out boxshape0.m_min, out boxshape0.m_max); int j = shape1.GetNumChildShapes(); while (j-- != 0) { shape1.GetChildAabb(i, ref trans1, out boxshape1.m_min, out boxshape1.m_max); if (boxshape1.HasCollision(ref boxshape0)) { pairset.PushPair(i, j); } } } } if (BulletGlobals.g_streamWriter != null && BulletGlobals.debugGimpactAlgo) { BulletGlobals.g_streamWriter.WriteLine("GImpactAglo::GImpactVsGImpactFindPairs [{0}]", pairset.Count); } }
protected void CollideSatTriangles(CollisionObject body0, CollisionObject body1, GImpactMeshShapePart shape0, GImpactMeshShapePart shape1, PairSet pairs, int pair_count) { IndexedMatrix orgtrans0 = body0.GetWorldTransform(); IndexedMatrix orgtrans1 = body1.GetWorldTransform(); PrimitiveTriangle ptri0 = new PrimitiveTriangle(); PrimitiveTriangle ptri1 = new PrimitiveTriangle(); if (BulletGlobals.g_streamWriter != null && BulletGlobals.debugGimpactAlgo) { BulletGlobals.g_streamWriter.WriteLine("GImpactAglo::CollideSatTriangles [{0}]", pair_count); } shape0.LockChildShapes(); shape1.LockChildShapes(); int pair_pointer = 0; while (pair_count-- != 0) { m_triface0 = pairs[pair_pointer].m_index1; m_triface1 = pairs[pair_pointer].m_index2; pair_pointer += 1; shape0.GetPrimitiveTriangle(m_triface0, ptri0); shape1.GetPrimitiveTriangle(m_triface1, ptri1); #if TRI_COLLISION_PROFILING BulletGlobal.StartProfile("gim02_tri_time"); #endif ptri0.ApplyTransform(ref orgtrans0); ptri1.ApplyTransform(ref orgtrans1); //build planes ptri0.BuildTriPlane(); ptri1.BuildTriPlane(); // test conservative if (ptri0.OverlapTestConservative(ptri1)) { if (ptri0.FindTriangleCollisionClipMethod(ptri1, m_contact_data)) { int j = m_contact_data.m_point_count; while (j-- != 0) { AddContactPoint(body0, body1, m_contact_data.m_points[j], MathUtil.Vector4ToVector3(ref m_contact_data.m_separating_normal), -m_contact_data.m_penetration_depth); } } } #if TRI_COLLISION_PROFILING BulletGlobals.StopProfile(); #endif } shape0.UnlockChildShapes(); shape1.UnlockChildShapes(); }
private void CollectConflictsBetweenFieldsAndFragment( ValidationContext context, List <Conflict> conflicts, Dictionary <SelectionSet, CachedField> cachedFieldsAndFragmentNames, ObjMap <bool> comparedFragments, PairSet comparedFragmentPairs, bool areMutuallyExclusive, Dictionary <string, List <FieldDefPair> > fieldMap, string fragmentName) { // Memoize so a fragment is not compared for conflicts more than once. if (comparedFragments.ContainsKey(fragmentName)) { return; } comparedFragments[fragmentName] = true; FragmentDefinition fragment = context.GetFragment(fragmentName); if (fragment == null) { return; } var cachedField = GetReferencedFieldsAndFragmentNames( context, cachedFieldsAndFragmentNames, fragment); var fieldMap2 = cachedField.NodeAndDef; var fragmentNames2 = cachedField.Names; // Do not compare a fragment's fieldMap to itself. if (fieldMap == fieldMap2) { return; } // (D) First collect any conflicts between the provided collection of fields // and the collection of fields represented by the given fragment. CollectConflictsBetween( context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fieldMap2); // (E) Then collect any conflicts between the provided collection of fields // and any fragment names found in the given fragment. for (var i = 0; i < fragmentNames2.Count; i++) { CollectConflictsBetweenFieldsAndFragment( context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fragmentNames2[i]); } }
private void CollectConflictsBetweenFragments( ValidationContext context, List <Conflict> conflicts, Dictionary <SelectionSet, CachedField> cachedFieldsAndFragmentNames, PairSet comparedFragmentPairs, bool areMutuallyExclusive, string fragmentName1, string fragmentName2) { // No need to compare a fragment to itself. if (fragmentName1 == fragmentName2) { return; } // Memoize so two fragments are not compared for conflicts more than once. if (comparedFragmentPairs.Has(fragmentName1, fragmentName2, areMutuallyExclusive)) { return; } comparedFragmentPairs.Add(fragmentName1, fragmentName2, areMutuallyExclusive); var fragment1 = context.GetFragment(fragmentName1); var fragment2 = context.GetFragment(fragmentName2); if (fragment1 == null || fragment2 == null) { return; } var cachedField1 = GetReferencedFieldsAndFragmentNames( context, cachedFieldsAndFragmentNames, fragment1); var fieldMap1 = cachedField1.NodeAndDef; var fragmentNames1 = cachedField1.Names; var cachedField2 = GetReferencedFieldsAndFragmentNames( context, cachedFieldsAndFragmentNames, fragment2); var fieldMap2 = cachedField2.NodeAndDef; var fragmentNames2 = cachedField2.Names; // (F) First, collect all conflicts between these two collections of fields // (not including any nested fragments). CollectConflictsBetween( context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, fieldMap2); // (G) Then collect conflicts between the first fragment and any nested // fragments spread in the second fragment. for (var j = 0; j < fragmentNames2.Count; j++) { CollectConflictsBetweenFragments( context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fragmentName1, fragmentNames2[j]); } // (G) Then collect conflicts between the second fragment and any nested // fragments spread in the first fragment. for (var i = 0; i < fragmentNames1.Count; i++) { CollectConflictsBetweenFragments( context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fragmentNames1[i], fragmentName2); } }
private List <Conflict> FindConflictsBetweenSubSelectionSets( ValidationContext context, Dictionary <SelectionSet, CachedField> cachedFieldsAndFragmentNames, PairSet comparedFragmentPairs, bool areMutuallyExclusive, IGraphType parentType1, SelectionSet selectionSet1, IGraphType parentType2, SelectionSet selectionSet2) { var conflicts = new List <Conflict>(); var cachedField1 = GetFieldsAndFragmentNames( context, cachedFieldsAndFragmentNames, parentType1, selectionSet1); var fieldMap1 = cachedField1.NodeAndDef; var fragmentNames1 = cachedField1.Names; var cachedField2 = GetFieldsAndFragmentNames( context, cachedFieldsAndFragmentNames, parentType2, selectionSet2); var fieldMap2 = cachedField2.NodeAndDef; var fragmentNames2 = cachedField2.Names; // (H) First, collect all conflicts between these two collections of field. CollectConflictsBetween( context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, fieldMap2); // (I) Then collect conflicts between the first collection of fields and // those referenced by each fragment name associated with the second. if (fragmentNames2.Count != 0) { var comparedFragments = new ObjMap <bool>(); for (var j = 0; j < fragmentNames2.Count; j++) { CollectConflictsBetweenFieldsAndFragment( context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, fragmentNames2[j]); } } // (I) Then collect conflicts between the second collection of fields and // those referenced by each fragment name associated with the first. if (fragmentNames1.Count != 0) { var comparedFragments = new ObjMap <bool>(); for (var i = 0; i < fragmentNames1.Count; i++) { CollectConflictsBetweenFieldsAndFragment( context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, comparedFragmentPairs, areMutuallyExclusive, fieldMap2, fragmentNames1[i]); } } // (J) Also collect conflicts between any fragment names by the first and // fragment names by the second. This compares each item in the first set of // names to each item in the second set of names. for (var i = 0; i < fragmentNames1.Count; i++) { for (var j = 0; j < fragmentNames2.Count; j++) { CollectConflictsBetweenFragments( context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fragmentNames1[i], fragmentNames2[j]); } } return(conflicts); }
private Conflict FindConflict( ValidationContext context, Dictionary <SelectionSet, CachedField> cachedFieldsAndFragmentNames, PairSet comparedFragmentPairs, bool parentFieldsAreMutuallyExclusive, string responseName, FieldDefPair fieldDefPair1, FieldDefPair fieldDefPair2) { var parentType1 = fieldDefPair1.ParentType; var node1 = fieldDefPair1.Field; var def1 = fieldDefPair1.FieldDef; var parentType2 = fieldDefPair2.ParentType; var node2 = fieldDefPair2.Field; var def2 = fieldDefPair2.FieldDef; // If it is known that two fields could not possibly apply at the same // time, due to the parent types, then it is safe to permit them to diverge // in aliased field or arguments used as they will not present any ambiguity // by differing. // It is known that two parent types could never overlap if they are // different Object types. Interface or Union types might overlap - if not // in the current state of the schema, then perhaps in some future version, // thus may not safely diverge. var areMutuallyExclusive = parentFieldsAreMutuallyExclusive || parentType1 != parentType2 && isObjectType(parentType1) && isObjectType(parentType2); // return type for each field. var type1 = def1?.ResolvedType; var type2 = def2?.ResolvedType; if (!areMutuallyExclusive) { // Two aliases must refer to the same field. var name1 = node1.GetName(); var name2 = node2.GetName(); if (name1 != name2) { return(new Conflict { Reason = new ConflictReason { Name = responseName, Message = new Message { Msg = $"{name1} and {name2} are different fields" } }, FieldsLeft = new List <ISelection> { node1 }, FieldsRight = new List <ISelection> { node2 } }); } // Two field calls must have the same arguments. if (!SameArguments(node1.GetArguments(), node2.GetArguments())) { return(new Conflict { Reason = new ConflictReason { Name = responseName, Message = new Message { Msg = "they have differing arguments" } }, FieldsLeft = new List <ISelection> { node1 }, FieldsRight = new List <ISelection> { node2 } }); } } if (type1 != null && type2 != null && DoTypesConflict(type1, type2)) { return(new Conflict { Reason = new ConflictReason { Name = responseName, Message = new Message { Msg = $"they return conflicting types {type1} and {type2}" } }, FieldsLeft = new List <ISelection> { node1 }, FieldsRight = new List <ISelection> { node2 } }); } // Collect and compare sub-fields. Use the same "visited fragment names" list // for both collections so fields in a fragment reference are never // compared to themselves. var selectionSet1 = node1.GetSelectionSet(); var selectionSet2 = node2.GetSelectionSet(); if (selectionSet1 != null && selectionSet2 != null) { var conflicts = FindConflictsBetweenSubSelectionSets( context, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, type1.GetNamedType(), selectionSet1, type2.GetNamedType(), selectionSet2); return(SubfieldConflicts(conflicts, responseName, node1, node2)); } return(null); }
internal static void EndLoad() { BaseMorphoFormNative.EndLoad(); MorphoTypeNative.EndLoad(); tempBufferPairs = null; }
//! Collides two gimpact shapes /*! \pre shape0 and shape1 couldn't be btGImpactMeshShape objects */ public void GImpactVsGImpact(CollisionObject body0, CollisionObject body1, GImpactShapeInterface shape0, GImpactShapeInterface shape1) { if (shape0.GetGImpactShapeType() == GIMPACT_SHAPE_TYPE.CONST_GIMPACT_TRIMESH_SHAPE) { GImpactMeshShape meshshape0 = shape0 as GImpactMeshShape; m_part0 = meshshape0.GetMeshPartCount(); while (m_part0-- != 0) { GImpactVsGImpact(body0, body1, meshshape0.GetMeshPart(m_part0), shape1); } return; } if (shape1.GetGImpactShapeType() == GIMPACT_SHAPE_TYPE.CONST_GIMPACT_TRIMESH_SHAPE) { GImpactMeshShape meshshape1 = shape1 as GImpactMeshShape; m_part1 = meshshape1.GetMeshPartCount(); while (m_part1-- != 0) { GImpactVsGImpact(body0, body1, shape0, meshshape1.GetMeshPart(m_part1)); } return; } IndexedMatrix orgtrans0 = body0.GetWorldTransform(); IndexedMatrix orgtrans1 = body1.GetWorldTransform(); PairSet pairset = new PairSet(); GImpactVsGImpactFindPairs(ref orgtrans0, ref orgtrans1, shape0, shape1, pairset); if (pairset.Count == 0) return; if (BulletGlobals.g_streamWriter != null && BulletGlobals.debugGimpactAlgo) { BulletGlobals.g_streamWriter.WriteLine("GImpactAglo::GImpactVsGImpact [{0}]",pairset.Count); } if (shape0.GetGImpactShapeType() == GIMPACT_SHAPE_TYPE.CONST_GIMPACT_TRIMESH_SHAPE_PART && shape1.GetGImpactShapeType() == GIMPACT_SHAPE_TYPE.CONST_GIMPACT_TRIMESH_SHAPE_PART) { GImpactMeshShapePart shapepart0 = shape0 as GImpactMeshShapePart; GImpactMeshShapePart shapepart1 = shape1 as GImpactMeshShapePart; //specialized function #if BULLET_TRIANGLE_COLLISION CollideGjkTriangles(body0,body1,shapepart0,shapepart1,&pairset[0].m_index1,pairset.size()); #else CollideSatTriangles(body0, body1, shapepart0, shapepart1, pairset, pairset.Count); #endif return; } //general function shape0.LockChildShapes(); shape1.LockChildShapes(); using(GIM_ShapeRetriever retriever0 = BulletGlobals.GIM_ShapeRetrieverPool.Get()) using (GIM_ShapeRetriever retriever1 = BulletGlobals.GIM_ShapeRetrieverPool.Get()) { retriever0.Initialize(shape0); retriever1.Initialize(shape1); bool child_has_transform0 = shape0.ChildrenHasTransform(); bool child_has_transform1 = shape1.ChildrenHasTransform(); int i = pairset.Count; while (i-- != 0) { GIM_PAIR pair = pairset[i]; m_triface0 = pair.m_index1; m_triface1 = pair.m_index2; CollisionShape colshape0 = retriever0.GetChildShape(m_triface0); CollisionShape colshape1 = retriever1.GetChildShape(m_triface1); if (child_has_transform0) { body0.SetWorldTransform(orgtrans0 * shape0.GetChildTransform(m_triface0)); } if (child_has_transform1) { body1.SetWorldTransform(orgtrans1 * shape1.GetChildTransform(m_triface1)); } //collide two convex shapes ConvexVsConvexCollision(body0, body1, colshape0, colshape1); if (child_has_transform0) { body0.SetWorldTransform(ref orgtrans0); } if (child_has_transform1) { body1.SetWorldTransform(ref orgtrans1); } } shape0.UnlockChildShapes(); shape1.UnlockChildShapes(); } }
internal Enumerator(PairSet set) { this._Set = set; this._Index = 0; this._Current = default(Pair); }
public static void LoadUISettings(this SettingsStorage storage, DockSite dockSite, PairSet <Tuple <string, Type>, IContentWindow> contents) { var controlsSettings = storage.GetValue <SettingsStorage[]>("Content"); foreach (var ctrlSettings in controlsSettings) { try { var id = ctrlSettings.GetValue <string>("Id"); var ctrlType = ctrlSettings.GetValue <string>("Type").To <Type>(); var isToolWindow = ctrlSettings.GetValue <bool>("IsToolWindow"); var dockingWindowName = ctrlSettings.GetValue <string>("DockingWindowName"); var controlSettings = ctrlSettings.GetValue <SettingsStorage>("Settings"); var tagType = ctrlSettings.GetValue <string>("TagType").To <Type>(); var canClose = true; object tag = null; if (tagType == typeof(StrategyInfo)) { tag = ConfigManager.GetService <IStudioEntityRegistry>().Strategies.ReadById(id.To <long>()); if (tag == null) { continue; } } else if (tagType != null && tagType.IsSubclassOf(typeof(Strategy))) { var sessionStrategy = ConfigManager.GetService <IStudioEntityRegistry>().ReadSessionStrategyById(id.To <Guid>()); if (sessionStrategy != null) { tag = sessionStrategy.Strategy; } if (tag == null) { continue; } } else if (tagType == typeof(CompositionDiagramElement)) { tag = ConfigManager.GetService <CompositionRegistry>().DiagramElements.FirstOrDefault(c => c.TypeId == id.To <Guid>()); if (tag == null) { continue; } } else if (tagType == typeof(ExpressionIndexSecurity) || tagType == typeof(ContinuousSecurity)) { tag = ConfigManager.GetService <IStudioEntityRegistry>().Securities.ReadById(id); if (tag == null) { continue; } } var control = ctrlType.CreateInstance <IStudioControl>(); var info = tag as StrategyInfo; if (info != null) { control.DoIf <IStudioControl, StrategyInfoCodeContent>(c => { canClose = false; c.StrategyInfo = info; }); control.DoIf <IStudioControl, DiagramPanel>(c => { canClose = false; c.StrategyInfo = info; }); control.DoIf <IStudioControl, StrategyInfoContent>(c => c.StrategyInfo = info); ConfigManager .GetService <IStudioCommandService>() .Bind(control.GetKey(), (IStudioCommandScope)control); } var strategy = tag as StrategyContainer; if (strategy != null) { control.DoIf <IStudioControl, StrategyContent>(c => c.SetStrategy(strategy)); control.DoIf <IStudioControl, DiagramDebuggerPanel>(c => c.Strategy = strategy); control.DoIf <IStudioControl, OptimizatorContent>(c => c.SetStrategy(strategy)); } var composition = tag as CompositionDiagramElement; if (composition != null) { ((DiagramPanel)control).Composition = composition; } var security = tag as Security; if (security != null) { ((CompositeSecurityPanel)control).Security = security; } var window = isToolWindow ? (IContentWindow) new ContentToolWindow { Id = id, Tag = tag, Control = control, Name = dockingWindowName, CanClose = canClose } : new ContentDocumentWindow { Id = id, Tag = tag, Control = control, Name = dockingWindowName, CanClose = canClose }; if (isToolWindow) { dockSite.ToolWindows.Add((ToolWindow)window); } else { dockSite.DocumentWindows.Add((DocumentWindow)window); } ((DockingWindow)window).Activate(); if (controlSettings != null) { control.Load(controlSettings); } contents.Add(Tuple.Create(id, ctrlType), window); } catch (Exception e) { e.LogError(); } } var layout = storage.GetValue <string>("Layout"); if (layout != null) { try { dockSite.LoadLayout(layout); } catch (Exception ex) { ex.LogError(); } } var activeWindow = storage.GetValue <string>("ActiveWindow"); if (activeWindow != null) { var id = activeWindow.To <Guid>(); var window = dockSite .ToolWindows .OfType <DockingWindow>() .Concat(dockSite.DocumentWindows) .FirstOrDefault(w => w.UniqueId == id); if (window != null) { window.Activate(); } } }
public static void SaveUISettings(this SettingsStorage storage, DockSite dockSite, PairSet <Tuple <string, Type>, IContentWindow> contents) { storage.SetValue("Content", contents.Select(p => { var ctrlStorage = new SettingsStorage(); ctrlStorage.SetValue("Id", p.Key.Item1); ctrlStorage.SetValue("Type", p.Value.Control.GetType().GetTypeName(false)); ctrlStorage.SetValue("IsToolWindow", p.Value is ContentToolWindow); ctrlStorage.SetValue("DockingWindowName", ((DockingWindow)p.Value).Name); ctrlStorage.SetValue("Settings", p.Value.Control.Save()); ctrlStorage.SetValue("TagType", p.Value.Tag == null ? null : p.Value.Tag.GetType().GetTypeName(false)); return(ctrlStorage); }).ToArray()); storage.SetValue("Layout", dockSite.SaveLayout()); var window = dockSite.ActiveWindow; if (window != null) { storage.SetValue("ActiveWindow", window.UniqueId.To <string>()); } }
internal Enumerator(PairSet set) { _set = set; _index = 0; _current = default; }