/// <summary> /// Adds an entry to the broad phase. /// </summary> /// <param name="entry">Entry to add.</param> public virtual void Add(BroadPhaseEntry entry) { if (entry.BroadPhase == null) entry.BroadPhase = this; else throw new ArgumentException("Cannot add entry; it already belongs to a broad phase."); }
///<summary> /// Initializes the pair handler. ///</summary> ///<param name="entryA">First entry in the pair.</param> ///<param name="entryB">Second entry in the pair.</param> public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { mobileMesh = entryA as MobileMeshCollidable; convex = entryB as ConvexCollidable; if (mobileMesh == null || convex == null) { mobileMesh = entryB as MobileMeshCollidable; convex = entryA as ConvexCollidable; if (mobileMesh == null || convex == null) throw new Exception("Inappropriate types used to initialize pair."); } //Contact normal goes from A to B. broadPhaseOverlap.entryA = convex; broadPhaseOverlap.entryB = mobileMesh; //It's possible that the convex does not have an entity if it is a proxy for a non-entity collidable. //Similarly, the mesh could be a query object. UpdateMaterialProperties(convex.entity != null ? convex.entity.material : null, mobileMesh.entity != null ? mobileMesh.entity.material : null); base.Initialize(entryA, entryB); }
///<summary> /// Initializes the pair handler. ///</summary> ///<param name="entryA">First entry in the pair.</param> ///<param name="entryB">Second entry in the pair.</param> public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { box = entryA as ConvexCollidable<BoxShape>; sphere = entryB as ConvexCollidable<SphereShape>; if (box == null || sphere == null) { box = entryB as ConvexCollidable<BoxShape>; sphere = entryA as ConvexCollidable<SphereShape>; if (box == null || sphere == null) { throw new Exception("Inappropriate types used to initialize pair."); } } //Reorder the entries so that the guarantee that the normal points from A to B is satisfied. broadPhaseOverlap.entryA = box; broadPhaseOverlap.entryB = sphere; base.Initialize(entryA, entryB); }
/// <summary> /// Removes an entry from the broad phase. /// </summary> /// <param name="entry">Entry to remove.</param> public virtual void Remove(BroadPhaseEntry entry) { if (entry.BroadPhase == this) entry.BroadPhase = null; else throw new ArgumentException("Cannot remove entry; it does not belong to this broad phase."); }
///<summary> /// Initializes the pair handler. ///</summary> ///<param name="entryA">First entry in the pair.</param> ///<param name="entryB">Second entry in the pair.</param> public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { instancedMesh = entryA as InstancedMesh; convex = entryB as ConvexCollidable; if (instancedMesh == null || convex == null) { instancedMesh = entryB as InstancedMesh; convex = entryA as ConvexCollidable; if (instancedMesh == null || convex == null) throw new Exception("Inappropriate types used to initialize pair."); } //Contact normal goes from A to B. broadPhaseOverlap.entryA = convex; broadPhaseOverlap.entryB = instancedMesh; UpdateMaterialProperties(convex.entity != null ? convex.entity.material : null, instancedMesh.material); base.Initialize(entryA, entryB); }
/// <summary> /// Adds a broad phase overlap if the collision rules permit it. /// </summary> /// <param name="entryA">First entry of the overlap.</param> /// <param name="entryB">Second entry of the overlap.</param> protected internal void TryToAddOverlap(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { CollisionRule rule; if ((rule = GetCollisionRule(entryA, entryB)) < CollisionRule.NoBroadPhase) { overlapAddLock.Enter(); overlaps.Add(new BroadPhaseOverlap(entryA, entryB, rule)); overlapAddLock.Exit(); } }
///<summary> /// Initializes the pair handler. ///</summary> ///<param name="entryA">First entry in the pair.</param> ///<param name="entryB">Second entry in the pair.</param> public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { compoundInfoB = entryB as CompoundCollidable; if (compoundInfoB == null) { throw new Exception("Inappropriate types used to initialize pair."); } base.Initialize(entryA, entryB); }
///<summary> /// Initializes the pair handler. ///</summary> ///<param name="entryA">First entry in the pair.</param> ///<param name="entryB">Second entry in the pair.</param> public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { convexA = entryA as ConvexCollidable; convexB = entryB as ConvexCollidable; if (convexA == null || convexB == null) { throw new ArgumentException("Inappropriate types used to initialize pair."); } base.Initialize(entryA, entryB); }
///<summary> /// Initializes the pair handler. ///</summary> ///<param name="entryA">First entry in the pair.</param> ///<param name="entryB">Second entry in the pair.</param> public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { //Child initialization is responsible for setting up the entries. ContactManifold.Initialize(CollidableA, CollidableB); ContactConstraint.Initialize(EntityA, EntityB, this); base.Initialize(entryA, entryB); }
///<summary> /// Initializes the pair handler. ///</summary> ///<param name="entryA">First entry in the pair.</param> ///<param name="entryB">Second entry in the pair.</param> public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { boxA = entryA as ConvexCollidable<BoxShape>; boxB = entryB as ConvexCollidable<BoxShape>; if (boxA == null || boxB == null) { throw new Exception("Inappropriate types used to initialize pair."); } base.Initialize(entryA, entryB); }
///<summary> /// Initializes the pair handler. ///</summary> ///<param name="entryA">First entry in the pair.</param> ///<param name="entryB">Second entry in the pair.</param> public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { //Child initialization is responsible for setting up the collidable. DetectorVolume = entryA as DetectorVolume; if (DetectorVolume == null) { DetectorVolume = entryB as DetectorVolume; if (DetectorVolume == null) throw new Exception("Incorrect types used to initialize detector volume pair."); } }
///<summary> /// Initializes the pair handler. ///</summary> ///<param name="entryA">First entry in the pair.</param> ///<param name="entryB">Second entry in the pair.</param> public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { mesh = entryA as InstancedMesh; if (mesh == null) { mesh = entryB as InstancedMesh; if (mesh == null) { throw new Exception("Inappropriate types used to initialize pair."); } } base.Initialize(entryA, entryB); }
public override void Add(BroadPhaseEntry entry) { //binary search for the approximately correct location. This helps prevent large first-frame sort times. //X Axis: int minIndex = 0; //inclusive int maxIndex = entriesX.count; //exclusive int index = 0; while (maxIndex - minIndex > 0) { index = (maxIndex + minIndex) / 2; if (entriesX.Elements[index].boundingBox.Min.X > entry.boundingBox.Min.X) maxIndex = index; else if (entriesX.Elements[index].boundingBox.Min.X < entry.boundingBox.Min.X) minIndex = ++index; else break; //Found an equal value! } entriesX.Insert(index, entry); //Y Axis: minIndex = 0; //inclusive maxIndex = entriesY.count; //exclusive while (maxIndex - minIndex > 0) { index = (maxIndex + minIndex) / 2; if (entriesY.Elements[index].boundingBox.Min.Y > entry.boundingBox.Min.Y) maxIndex = index; else if (entriesY.Elements[index].boundingBox.Min.Y < entry.boundingBox.Min.Y) minIndex = ++index; else break; //Found an equal value! } entriesY.Insert(index, entry); //Z Axis: minIndex = 0; //inclusive maxIndex = entriesZ.count; //exclusive while (maxIndex - minIndex > 0) { index = (maxIndex + minIndex) / 2; if (entriesZ.Elements[index].boundingBox.Min.Z > entry.boundingBox.Min.Z) maxIndex = index; else if (entriesZ.Elements[index].boundingBox.Min.Z < entry.boundingBox.Min.Z) minIndex = ++index; else break; //Found an equal value! } entriesZ.Insert(index, entry); }
///<summary> /// Initializes the pair handler. ///</summary> ///<param name="entryA">First entry in the pair.</param> ///<param name="entryB">Second entry in the pair.</param> public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { terrain = entryA as Terrain; if (terrain == null) { terrain = entryB as Terrain; if (terrain == null) { throw new Exception("Inappropriate types used to initialize pair."); } } base.Initialize(entryA, entryB); }
///<summary> /// Initializes the pair handler. ///</summary> ///<param name="entryA">First entry in the pair.</param> ///<param name="entryB">Second entry in the pair.</param> public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { sphereA = entryA as ConvexCollidable<SphereShape>; sphereB = entryB as ConvexCollidable<SphereShape>; if (sphereA == null || sphereB == null) { throw new ArgumentException("Inappropriate types used to initialize pair."); } base.Initialize(entryA, entryB); }
///<summary> /// Initializes the pair handler. ///</summary> ///<param name="entryA">First entry in the pair.</param> ///<param name="entryB">Second entry in the pair.</param> public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { //Other member of the pair is initialized by the child. compoundInfo = entryA as CompoundCollidable; if (compoundInfo == null) { compoundInfo = entryB as CompoundCollidable; if (compoundInfo == null) { throw new Exception("Inappropriate types used to initialize pair."); } } base.Initialize(entryA, entryB); }
///<summary> /// Initializes the pair handler. ///</summary> ///<param name="entryA">First entry in the pair.</param> ///<param name="entryB">Second entry in the pair.</param> public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { triangle = entryA as ConvexCollidable<TriangleShape>; convex = entryB as ConvexCollidable; if (triangle == null || convex == null) { triangle = entryB as ConvexCollidable<TriangleShape>; convex = entryA as ConvexCollidable; if (triangle == null || convex == null) throw new ArgumentException("Inappropriate types used to initialize pair."); } //Contact normal goes from A to B. broadPhaseOverlap.entryA = convex; broadPhaseOverlap.entryB = triangle; base.Initialize(entryA, entryB); }
/// <summary> /// Adds an entry to the broad phase. /// </summary> /// <param name="entry">Entry to add.</param> public override void Add(BroadPhaseEntry entry) { //Entities do not set up their own bounding box before getting stuck in here. If they're all zeroed out, the tree will be horrible. Vector3 offset; Vector3.Subtract(ref entry.boundingBox.Max, ref entry.boundingBox.Min, out offset); if (offset.X * offset.Y * offset.Z == 0) entry.UpdateBoundingBox(); var newEntry = entryPool.Take(); newEntry.Initialize(entry); entries.Add(newEntry); //Add the object to the grid. for (int i = newEntry.previousMin.Y; i <= newEntry.previousMax.Y; i++) { for (int j = newEntry.previousMin.Z; j <= newEntry.previousMax.Z; j++) { var index = new Int2(); index.Y = i; index.Z = j; cellSet.Add(ref index, newEntry); } } }
/// <summary> /// Adds an entry to the broad phase. /// </summary> /// <param name="entry">Entry to add.</param> public override void Add(BroadPhaseEntry entry) { //Entities do not set up their own bounding box before getting stuck in here. If they're all zeroed out, the tree will be horrible. Vector3 offset; Vector3.Subtract(ref entry.boundingBox.Max, ref entry.boundingBox.Min, out offset); if (offset.X * offset.Y * offset.Z == 0) entry.UpdateBoundingBox(); //binary search for the approximately correct location. This helps prevent large first-frame sort times. int minIndex = 0; //inclusive int maxIndex = entries.count; //exclusive int index = 0; while (maxIndex - minIndex > 0) { index = (maxIndex + minIndex) / 2; if (entries.Elements[index].boundingBox.Min.X > entry.boundingBox.Min.X) maxIndex = index; else if (entries.Elements[index].boundingBox.Min.X < entry.boundingBox.Min.X) minIndex = ++index; else break; //Found an equal value! } entries.Insert(index, entry); }
///<summary> /// Initializes the pair handler. ///</summary> ///<param name="entryA">First entry in the pair.</param> ///<param name="entryB">Second entry in the pair.</param> public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { mesh = (MobileMeshCollidable)entryB; base.Initialize(entryA, entryB); }
bool RayCastFilter(BroadPhaseEntry entry) { return(entry != character.CharacterController.Body.CollisionInformation && entry.CollisionRules.Personal <= CollisionRule.Normal); }
/// <summary> /// Constructs an overlap. /// </summary> /// <param name="entryA">First entry in the pair.</param> /// <param name="entryB">Second entry in the pair.</param> public BroadPhaseOverlap(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { this.entryA = entryA; this.entryB = entryB; collisionRule = CollisionRules.DefaultCollisionRule; }
public override void Remove(BroadPhaseEntry entry) { entries.Remove(entry); }
void RemoveFriction(EntityCollidable sender, BroadPhaseEntry other, NarrowPhasePair pair) { var collidablePair = pair as CollidablePairHandler; if (collidablePair != null) { //The default values for InteractionProperties is all zeroes- zero friction, zero bounciness. //That's exactly how we want the character to behave when hitting objects. collidablePair.UpdateMaterialProperties(new InteractionProperties()); } }
///<summary> /// Gets a narrow phase pair for a given pair of entries. ///</summary> ///<param name="entryA">First entry in the pair.</param> /// <param name="entryB">Second entry in the pair.</param> ///<returns>AINarrowPhasePair for the overlap.</returns> public static NarrowPhasePair GetPairHandler(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { var overlap = new BroadPhaseOverlap(entryA, entryB); return(GetPairHandler(ref overlap)); }
public bool IgnorePlayers(BroadPhaseEntry entry) { if (entry.CollisionRules.Group == CollisionUtil.Player) { return false; } return TheRegion.Collision.ShouldCollide(entry); }
internal abstract bool RemoveFast(BroadPhaseEntry entry, out LeafNode leafNode, out Node replacementNode);
///<summary> /// Initializes the pair. ///</summary> ///<param name="entryA">First entry in the pair.</param> ///<param name="entryB">Second entry in the pair.</param> public abstract void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB);
internal void Initialize(BroadPhaseEntry element) { this.element = element; BoundingBox = element.BoundingBox; }
///<summary> /// Removes a space object from the simulation. ///</summary> ///<param name="spaceObject">Space object to remove.</param> public void Remove(ISpaceObject spaceObject) { if (spaceObject.Space != this) { Console.WriteLine("The object does not belong to this space; cannot remove it."); } //throw new ArgumentException("The object does not belong to this space; cannot remove it."); else { SimulationIslandMember simulationIslandMember = spaceObject as SimulationIslandMember; if (simulationIslandMember != null) { DeactivationManager.Remove(simulationIslandMember); } ISimulationIslandMemberOwner simulationIslandMemberOwner = spaceObject as ISimulationIslandMemberOwner; if (simulationIslandMemberOwner != null) { DeactivationManager.Remove(simulationIslandMemberOwner.ActivityInformation); } //Go through each stage, removing the space object from it if necessary. IForceUpdateable velocityUpdateable = spaceObject as IForceUpdateable; if (velocityUpdateable != null) { ForceUpdater.Remove(velocityUpdateable); } MobileCollidable boundingBoxUpdateable = spaceObject as MobileCollidable; if (boundingBoxUpdateable != null) { BoundingBoxUpdater.Remove(boundingBoxUpdateable); } BroadPhaseEntry broadPhaseEntry = spaceObject as BroadPhaseEntry; if (broadPhaseEntry != null) { BroadPhase.Remove(broadPhaseEntry); } //Entites own collision proxies, but are not entries themselves. IBroadPhaseEntryOwner broadPhaseEntryOwner = spaceObject as IBroadPhaseEntryOwner; if (broadPhaseEntryOwner != null) { BroadPhase.Remove(broadPhaseEntryOwner.Entry); boundingBoxUpdateable = broadPhaseEntryOwner.Entry as MobileCollidable; if (boundingBoxUpdateable != null) { BoundingBoxUpdater.Remove(boundingBoxUpdateable); } } SolverUpdateable solverUpdateable = spaceObject as SolverUpdateable; if (solverUpdateable != null) { Solver.Remove(solverUpdateable); } IPositionUpdateable integrable = spaceObject as IPositionUpdateable; if (integrable != null) { PositionUpdater.Remove(integrable); } Entity entity = spaceObject as Entity; if (entity != null) { BufferedStates.Remove(entity); } IDeferredEventCreator deferredEventCreator = spaceObject as IDeferredEventCreator; if (deferredEventCreator != null) { DeferredEventDispatcher.RemoveEventCreator(deferredEventCreator); } IDeferredEventCreatorOwner deferredEventCreatorOwner = spaceObject as IDeferredEventCreatorOwner; if (deferredEventCreatorOwner != null) { DeferredEventDispatcher.RemoveEventCreator(deferredEventCreatorOwner.EventCreator); } //Updateable stages. IDuringForcesUpdateable duringForcesUpdateable = spaceObject as IDuringForcesUpdateable; if (duringForcesUpdateable != null) { DuringForcesUpdateables.Remove(duringForcesUpdateable); } IBeforeNarrowPhaseUpdateable beforeNarrowPhaseUpdateable = spaceObject as IBeforeNarrowPhaseUpdateable; if (beforeNarrowPhaseUpdateable != null) { BeforeNarrowPhaseUpdateables.Remove(beforeNarrowPhaseUpdateable); } IBeforeSolverUpdateable beforeSolverUpdateable = spaceObject as IBeforeSolverUpdateable; if (beforeSolverUpdateable != null) { BeforeSolverUpdateables.Remove(beforeSolverUpdateable); } IBeforePositionUpdateUpdateable beforePositionUpdateUpdateable = spaceObject as IBeforePositionUpdateUpdateable; if (beforePositionUpdateUpdateable != null) { BeforePositionUpdateUpdateables.Remove(beforePositionUpdateUpdateable); } IEndOfTimeStepUpdateable endOfStepUpdateable = spaceObject as IEndOfTimeStepUpdateable; if (endOfStepUpdateable != null) { EndOfTimeStepUpdateables.Remove(endOfStepUpdateable); } IEndOfFrameUpdateable endOfFrameUpdateable = spaceObject as IEndOfFrameUpdateable; if (endOfFrameUpdateable != null) { EndOfFrameUpdateables.Remove(endOfFrameUpdateable); } spaceObject.Space = null; spaceObject.OnRemovalFromSpace(this); } }
internal EventStoragePairRemoved(BroadPhaseEntry other) { this.other = other; }
///<summary> /// Adds a space object to the simulation. ///</summary> ///<param name="spaceObject">Space object to add.</param> public void Add(ISpaceObject spaceObject) { if (spaceObject.Space != null) { throw new ArgumentException("The object belongs to some Space already; cannot add it again."); } spaceObject.Space = this; SimulationIslandMember simulationIslandMember = spaceObject as SimulationIslandMember; if (simulationIslandMember != null) { DeactivationManager.Add(simulationIslandMember); } ISimulationIslandMemberOwner simulationIslandMemberOwner = spaceObject as ISimulationIslandMemberOwner; if (simulationIslandMemberOwner != null) { DeactivationManager.Add(simulationIslandMemberOwner.ActivityInformation); } //Go through each stage, adding the space object to it if necessary. IForceUpdateable velocityUpdateable = spaceObject as IForceUpdateable; if (velocityUpdateable != null) { ForceUpdater.Add(velocityUpdateable); } MobileCollidable boundingBoxUpdateable = spaceObject as MobileCollidable; if (boundingBoxUpdateable != null) { BoundingBoxUpdater.Add(boundingBoxUpdateable); } BroadPhaseEntry broadPhaseEntry = spaceObject as BroadPhaseEntry; if (broadPhaseEntry != null) { BroadPhase.Add(broadPhaseEntry); } //Entites own collision proxies, but are not entries themselves. IBroadPhaseEntryOwner broadPhaseEntryOwner = spaceObject as IBroadPhaseEntryOwner; if (broadPhaseEntryOwner != null) { BroadPhase.Add(broadPhaseEntryOwner.Entry); boundingBoxUpdateable = broadPhaseEntryOwner.Entry as MobileCollidable; if (boundingBoxUpdateable != null) { BoundingBoxUpdater.Add(boundingBoxUpdateable); } } SolverUpdateable solverUpdateable = spaceObject as SolverUpdateable; if (solverUpdateable != null) { Solver.Add(solverUpdateable); } IPositionUpdateable integrable = spaceObject as IPositionUpdateable; if (integrable != null) { PositionUpdater.Add(integrable); } Entity entity = spaceObject as Entity; if (entity != null) { BufferedStates.Add(entity); } IDeferredEventCreator deferredEventCreator = spaceObject as IDeferredEventCreator; if (deferredEventCreator != null) { DeferredEventDispatcher.AddEventCreator(deferredEventCreator); } IDeferredEventCreatorOwner deferredEventCreatorOwner = spaceObject as IDeferredEventCreatorOwner; if (deferredEventCreatorOwner != null) { DeferredEventDispatcher.AddEventCreator(deferredEventCreatorOwner.EventCreator); } //Updateable stages. IDuringForcesUpdateable duringForcesUpdateable = spaceObject as IDuringForcesUpdateable; if (duringForcesUpdateable != null) { DuringForcesUpdateables.Add(duringForcesUpdateable); } IBeforeNarrowPhaseUpdateable beforeNarrowPhaseUpdateable = spaceObject as IBeforeNarrowPhaseUpdateable; if (beforeNarrowPhaseUpdateable != null) { BeforeNarrowPhaseUpdateables.Add(beforeNarrowPhaseUpdateable); } IBeforeSolverUpdateable beforeSolverUpdateable = spaceObject as IBeforeSolverUpdateable; if (beforeSolverUpdateable != null) { BeforeSolverUpdateables.Add(beforeSolverUpdateable); } IBeforePositionUpdateUpdateable beforePositionUpdateUpdateable = spaceObject as IBeforePositionUpdateUpdateable; if (beforePositionUpdateUpdateable != null) { BeforePositionUpdateUpdateables.Add(beforePositionUpdateUpdateable); } IEndOfTimeStepUpdateable endOfStepUpdateable = spaceObject as IEndOfTimeStepUpdateable; if (endOfStepUpdateable != null) { EndOfTimeStepUpdateables.Add(endOfStepUpdateable); } IEndOfFrameUpdateable endOfFrameUpdateable = spaceObject as IEndOfFrameUpdateable; if (endOfFrameUpdateable != null) { EndOfFrameUpdateables.Add(endOfFrameUpdateable); } spaceObject.OnAdditionToSpace(this); }
/// <summary> /// Constructs an overlap. /// </summary> /// <param name="entryA">First entry in the pair.</param> /// <param name="entryB">Second entry in the pair.</param> /// <param name="collisionRule">Collision rule calculated for the pair.</param> public BroadPhaseOverlap(BroadPhaseEntry entryA, BroadPhaseEntry entryB, CollisionRule collisionRule) { this.entryA = entryA; this.entryB = entryB; this.collisionRule = collisionRule; }
protected internal CollisionRule GetCollisionRule(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { if (entryA.IsActive || entryB.IsActive) return CollisionRules.collisionRuleCalculator(entryA, entryB); return CollisionRule.NoBroadPhase; }
public override void Remove(BroadPhaseEntry entry) { entries.Remove(entry); }
bool SupportRayFilterFunction(BroadPhaseEntry entry) { //Only permit an object to be used as a support if it fully collides with the character. return(CollisionRules.CollisionRuleCalculator(entry, character.Body.CollisionInformation) == CollisionRule.Normal); }
public override void Add(BroadPhaseEntry entry) { entries.Add(entry); }
public override void Initialize( BroadPhaseEntry entryA, BroadPhaseEntry entryB ) { voxelBlob = entryA as VoxelBlob; convex = entryB as ConvexCollidable; if( voxelBlob == null || convex == null ) { voxelBlob = entryB as VoxelBlob; convex = entryA as ConvexCollidable; if( voxelBlob == null || convex == null ) throw new ArgumentException( "Inappropriate types used to initialize pair." ); } //Contact normal goes from A to B. broadPhaseOverlap = new BroadPhaseOverlap( convex, voxelBlob, broadPhaseOverlap.CollisionRule ); Debugger.Break(); //UpdateMaterialProperties( convex.Entity != null ? convex.Entity.Material : null, voxelBlob.Material ); base.Initialize( entryA, entryB ); }
internal void CleanUp() { element = null; }
public override void Add(BroadPhaseEntry entry) { entries.Add(entry); }
bool RayCastFilter(BroadPhaseEntry entry) { return(entry != entityToChase.CollisionInformation && (entry.CollisionRules.Personal <= CollisionRule.Normal)); }
///<summary> /// Constructs a new ray cast result. ///</summary> ///<param name="hitData">Ray cast hit data.</param> ///<param name="hitObject">Object hit by the ray.</param> public RayCastResult(RayHit hitData, BroadPhaseEntry hitObject) { HitData = hitData; HitObject = hitObject; }
public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { UpdateMaterialProperties(); base.Initialize(entryA, entryB); }
bool SupportRayFilterFunction(BroadPhaseEntry entry) { //Only permit an object to be used as a support if it fully collides with the character. return CollisionRules.CollisionRuleCalculator(entry, character.Body.CollisionInformation) == CollisionRule.Normal; }
///<summary> /// Constructs a new ray cast result. ///</summary> ///<param name="hitData">Ray cast hit data.</param> ///<param name="hitObject">Object hit by the ray.</param> public RayCastResult(RayHit hitData, BroadPhaseEntry hitObject) { HitData = hitData; HitObject = hitObject; }
///<summary> /// Gets a narrow phase pair for a given pair of entries. ///</summary> ///<param name="entryA">First entry in the pair.</param> /// <param name="entryB">Second entry in the pair.</param> ///<returns>AINarrowPhasePair for the overlap.</returns> public static NarrowPhasePair GetPairHandler(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { var overlap = new BroadPhaseOverlap(entryA, entryB); return GetPairHandler(ref overlap); }
internal EventStoragePairUpdated(BroadPhaseEntry other, NarrowPhasePair pair) { this.other = other; this.pair = pair; }
public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { if (noRecurse) { return; } noRecurse = true; mesh = entryA as FullChunkObject; convex = entryB as ConvexCollidable; if (mesh == null || convex == null) { mesh = entryB as FullChunkObject; convex = entryA as ConvexCollidable; if (mesh == null || convex == null) { throw new ArgumentException("Inappropriate types used to initialize pair."); } } broadPhaseOverlap = new BroadPhaseOverlap(convex, mesh, broadPhaseOverlap.CollisionRule); UpdateMaterialProperties(convex.Entity != null ? convex.Entity.Material : null, mesh.Material); base.Initialize(entryA, entryB); noRecurse = false; }
public override void Add(BroadPhaseEntry entry) { base.Add(entry); //binary search for the approximately correct location. This helps prevent large first-frame sort times. //X Axis: int minIndex = 0; //inclusive int maxIndex = entriesX.count; //exclusive int index = 0; while (maxIndex - minIndex > 0) { index = (maxIndex + minIndex) / 2; if (entriesX.Elements[index].boundingBox.Min.X > entry.boundingBox.Min.X) { maxIndex = index; } else if (entriesX.Elements[index].boundingBox.Min.X < entry.boundingBox.Min.X) { minIndex = ++index; } else { break; //Found an equal value! } } entriesX.Insert(index, entry); //Y Axis: minIndex = 0; //inclusive maxIndex = entriesY.count; //exclusive while (maxIndex - minIndex > 0) { index = (maxIndex + minIndex) / 2; if (entriesY.Elements[index].boundingBox.Min.Y > entry.boundingBox.Min.Y) { maxIndex = index; } else if (entriesY.Elements[index].boundingBox.Min.Y < entry.boundingBox.Min.Y) { minIndex = ++index; } else { break; //Found an equal value! } } entriesY.Insert(index, entry); //Z Axis: minIndex = 0; //inclusive maxIndex = entriesZ.count; //exclusive while (maxIndex - minIndex > 0) { index = (maxIndex + minIndex) / 2; if (entriesZ.Elements[index].boundingBox.Min.Z > entry.boundingBox.Min.Z) { maxIndex = index; } else if (entriesZ.Elements[index].boundingBox.Min.Z < entry.boundingBox.Min.Z) { minIndex = ++index; } else { break; //Found an equal value! } } entriesZ.Insert(index, entry); }
public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB) { UpdateMaterialProperties(); base.Initialize(entryA, entryB); }
bool RayCastFilter(BroadPhaseEntry entry) { return(entry.CollisionRules.Personal <= CollisionRule.Normal); }