public override void Execute(ISceneQueryListener listener) { var list = new List <PCZSceneNode>(); var checkedNodes = new List <PCZSceneNode>(); foreach (PlaneBoundedVolume volume in volumes) { //find the nodes that intersect the AAB ((PCZSceneManager)creator).FindNodesIn(volume, ref list, this.startZone, (PCZSceneNode)this.excludeNode); //grab all moveables from the node that intersect... foreach (PCZSceneNode node in list) { // avoid double-check same scene node if (!checkedNodes.Contains(node)) { continue; } checkedNodes.Add(node); foreach (MovableObject m in node.Objects) { if ((m.QueryFlags & queryMask) != 0 && (m.TypeFlags & this.queryTypeMask) != 0 && m.IsAttached && volume.Intersects(m.GetWorldBoundingBox())) { listener.OnQueryResult(m); // deal with attached objects, since they are not directly attached to nodes if (m.MovableType == "Entity") { //Check: not sure here... var e = (Entity)m; foreach (MovableObject c in e.SubEntities) { if ((c.QueryFlags & queryMask) > 0 && volume.Intersects(c.GetWorldBoundingBox())) { listener.OnQueryResult(c); } } } } } } } // reset startzone and exclude node this.startZone = null; this.excludeNode = null; }
/// <summary> /// Finds any entities that intersect the AAB for the query. /// </summary> /// <param name="listener"> /// The listener to call when we find the results. /// </param> public override void Execute( ISceneQueryListener listener ) { List<PCZSceneNode> list = new List<PCZSceneNode>(); //find the nodes that intersect the AAB ( (PCZSceneManager)creator ).FindNodesIn( box, ref list, startZone, (PCZSceneNode)excludeNode ); //grab all moveables from the node that intersect... foreach ( PCZSceneNode node in list ) { foreach ( MovableObject m in node.Objects ) { if ( ( m.QueryFlags & queryMask ) != 0 && ( m.TypeFlags & queryTypeMask ) != 0 && m.IsAttached && box.Intersects( m.GetWorldBoundingBox() ) ) { listener.OnQueryResult( m ); // deal with attached objects, since they are not directly attached to nodes if ( m.MovableType == "Entity" ) { //Check: not sure here... Entity e = (Entity)m; foreach ( MovableObject c in e.SubEntities ) { if ( ( c.QueryFlags & queryMask ) > 0 ) { listener.OnQueryResult( c ); } } } } } } // reset startzone and exclude node startZone = null; excludeNode = null; }
public override void Execute( ISceneQueryListener listener ) { MovableObjectFactoryMap factories = Root.Instance.MovableObjectFactories; foreach ( KeyValuePair<string, MovableObjectFactory> map in factories ) { MovableObjectCollection movableObjects = this.creator.GetMovableObjectCollection( map.Value.Type ); foreach ( MovableObject movableObject in movableObjects.Values ) { // skip group if query type doesn't match if ( ( this.QueryTypeMask & movableObject.TypeFlags ) == 0 ) { break; } // skip if unattached or filtered out by query flags if ( !movableObject.IsAttached || ( movableObject.QueryFlags & this.queryMask ) == 0 ) { continue; } for ( int v = 0; v < this.volumes.Count; v++ ) { PlaneBoundedVolume volume = (PlaneBoundedVolume)this.volumes[ v ]; // Do AABB / plane volume test if ( ( movableObject.QueryFlags & this.queryMask ) != 0 && volume.Intersects( movableObject.GetWorldBoundingBox() ) ) { listener.OnQueryResult( movableObject ); break; } } } } }
public override void Execute( ISceneQueryListener listener ) { Sphere testSphere = new Sphere(); MovableObjectFactoryMap factories = Root.Instance.MovableObjectFactories; foreach ( KeyValuePair<string, MovableObjectFactory> map in factories ) { MovableObjectCollection movableObjects = this.creator.GetMovableObjectCollection( map.Value.Type ); foreach ( MovableObject movableObject in movableObjects.Values ) { // skip group if query type doesn't match if ( ( this.QueryTypeMask & movableObject.TypeFlags ) == 0 ) { break; } // skip if unattached or filtered out by query flags if ( !movableObject.IsAttached || ( movableObject.QueryFlags & this.queryMask ) == 0 ) { continue; } testSphere.Center = movableObject.ParentNode.DerivedPosition; testSphere.Radius = movableObject.BoundingRadius; // if the results came back positive, fire the event handler if ( this.sphere.Intersects( testSphere ) ) { listener.OnQueryResult( movableObject ); } } } }
public override void Execute( ISceneQueryListener listener ) { MovableObjectFactoryMap factories = Root.Instance.MovableObjectFactories; foreach ( KeyValuePair<string, MovableObjectFactory> map in factories ) { MovableObjectCollection movableObjects = this.creator.GetMovableObjectCollection( map.Value.Type ); foreach ( MovableObject movableObject in movableObjects.Values ) { // skip group if query type doesn't match if ( ( this.QueryTypeMask & movableObject.TypeFlags ) == 0 ) { break; } // skip if unattached or filtered out by query flags if ( !movableObject.IsAttached || ( movableObject.QueryFlags & this.queryMask ) == 0 ) { continue; } if ( this.box.Intersects( movableObject.GetWorldBoundingBox() ) ) { listener.OnQueryResult( movableObject ); } } } }
public override void Execute( ISceneQueryListener listener ) { this.listener = listener; this.foundIntersections.Clear(); ProcessNode( ( (BspSceneManager)creator ).Level.RootNode ); }
public override void Execute( ISceneQueryListener listener ) { var list = new List<PCZSceneNode>(); var checkedNodes = new List<PCZSceneNode>(); foreach ( PlaneBoundedVolume volume in volumes ) { //find the nodes that intersect the AAB ( (PCZSceneManager)creator ).FindNodesIn( volume, ref list, this.startZone, (PCZSceneNode)this.excludeNode ); //grab all moveables from the node that intersect... foreach ( PCZSceneNode node in list ) { // avoid double-check same scene node if ( !checkedNodes.Contains( node ) ) { continue; } checkedNodes.Add( node ); foreach ( MovableObject m in node.Objects ) { if ( ( m.QueryFlags & queryMask ) != 0 && ( m.TypeFlags & this.queryTypeMask ) != 0 && m.IsAttached && volume.Intersects( m.GetWorldBoundingBox() ) ) { listener.OnQueryResult( m ); // deal with attached objects, since they are not directly attached to nodes if ( m.MovableType == "Entity" ) { //Check: not sure here... var e = (Entity)m; foreach ( MovableObject c in e.SubEntities ) { if ( ( c.QueryFlags & queryMask ) > 0 && volume.Intersects( c.GetWorldBoundingBox() ) ) { listener.OnQueryResult( c ); } } } } } } } // reset startzone and exclude node this.startZone = null; this.excludeNode = null; }
/// <summary> /// Executes the query and returns each match through a listener interface. /// </summary> /// <remarks> /// Note that this method does not store the results of the query internally /// so does not update the 'last result' value. This means that this version of /// execute is more lightweight and therefore more efficient than the version /// which returns the results as a collection. /// </remarks> /// <param name="listener"></param> public abstract void Execute( ISceneQueryListener listener );
public override void Execute(ISceneQueryListener listener) { // TODO: BillboardSets? Will need per-billboard collision most likely // Entities only for now foreach (Dictionary<string, MovableObject> objectMap in creator.MovableObjectMaps) { foreach (MovableObject obj in objectMap.Values) { // skip if unattached or filtered out by query flags if (!obj.IsAttached || (obj.QueryFlags & queryMask) == 0) { continue; } if (box.Intersects(obj.GetWorldBoundingBox())) { listener.OnQueryResult(obj); } } } }
public override void Execute(ISceneQueryListener listener) { // TODO: BillboardSets? Will need per-billboard collision most likely // Entities only for now Sphere testSphere = new Sphere(); foreach (Dictionary<string, MovableObject> objectMap in creator.MovableObjectMaps) { foreach (MovableObject obj in objectMap.Values) { // skip if unattached or filtered out by query flags if (!obj.IsAttached || (obj.QueryFlags & queryMask) == 0) { continue; } testSphere.Center = obj.ParentNode.DerivedPosition; testSphere.Radius = obj.BoundingRadius; // if the results came back positive, fire the event handler if (sphere.Intersects(testSphere)) { listener.OnQueryResult(obj); } } } }
public override void Execute(ISceneQueryListener listener) { foreach (Dictionary<string, MovableObject> objectMap in creator.MovableObjectMaps) { foreach (MovableObject obj in objectMap.Values) { // skip if unattached or filtered out by query flags if (!obj.IsAttached || (obj.QueryFlags & queryMask) == 0) { continue; } for (int v = 0; v < volumes.Count; v++) { PlaneBoundedVolume volume = (PlaneBoundedVolume)volumes[v]; // Do AABB / plane volume test if ((obj.QueryFlags & queryMask) != 0 && volume.Intersects(obj.GetWorldBoundingBox())) { listener.OnQueryResult(obj); break; } } } } }
/// <summary> /// Executes the query and returns each match through a listener interface. /// </summary> /// <remarks> /// Note that this method does not store the results of the query internally /// so does not update the 'last result' value. This means that this version of /// execute is more lightweight and therefore more efficient than the version /// which returns the results as a collection. /// </remarks> /// <param name="listener"></param> public abstract void Execute(ISceneQueryListener listener);