//--------------------------------------------------------------------- void PCZPlaneBoundedVolumeListSceneQuery::execute(SceneQueryListener* listener) { std::set<SceneNode*> checkedSceneNodes; PlaneBoundedVolumeList::iterator pi, piend; piend = mVolumes.end(); for (pi = mVolumes.begin(); pi != piend; ++pi) { PCZSceneNodeList list; //find the nodes that intersect the Plane bounded Volume static_cast<PCZSceneManager*>( mParentSceneMgr ) -> findNodesIn( *pi, list, mStartZone, (PCZSceneNode*)mExcludeNode ); //grab all moveables from the node that intersect... PCZSceneNodeList::iterator it, itend; itend = list.end(); for (it = list.begin(); it != itend; ++it) { // avoid double-check same scene node if (!checkedSceneNodes.insert(*it).second) continue; SceneNode::ObjectIterator oit = (*it) -> getAttachedObjectIterator(); while( oit.hasMoreElements() ) { MovableObject * m = oit.getNext(); if( (m->getQueryFlags() & mQueryMask) && (m->getTypeFlags() & mQueryTypeMask) && m->isInScene() && (*pi).intersects( m->getWorldBoundingBox() ) ) { listener -> queryResult( m ); // deal with attached objects, since they are not directly attached to nodes if (m->getMovableType() == "Entity") { Entity* e = static_cast<Entity*>(m); Entity::ChildObjectListIterator childIt = e->getAttachedObjectIterator(); while(childIt.hasMoreElements()) { MovableObject* c = childIt.getNext(); if (c->getQueryFlags() & mQueryMask && (*pi).intersects( c->getWorldBoundingBox())) { listener->queryResult(c); } } } } } } }//for // reset startzone and exclude node mStartZone = 0; mExcludeNode = 0; }
//--------------------------------------------------------------------- void PCZRaySceneQuery::execute(RaySceneQueryListener* listener) { PCZSceneNodeList list; //find the nodes that intersect the Ray static_cast<PCZSceneManager*>( mParentSceneMgr ) -> findNodesIn( mRay, list, mStartZone, (PCZSceneNode*)mExcludeNode ); //grab all moveables from the node that intersect... PCZSceneNodeList::iterator it = list.begin(); while( it != list.end() ) { SceneNode::ObjectIterator oit = (*it) -> getAttachedObjectIterator(); while( oit.hasMoreElements() ) { MovableObject * m = oit.getNext(); if( (m->getQueryFlags() & mQueryMask) && (m->getTypeFlags() & mQueryTypeMask) && m->isInScene() ) { std::pair<bool, Real> result = mRay.intersects(m->getWorldBoundingBox()); if( result.first ) { listener -> queryResult( m, result.second ); // deal with attached objects, since they are not directly attached to nodes if (m->getMovableType() == "Entity") { Entity* e = static_cast<Entity*>(m); Entity::ChildObjectListIterator childIt = e->getAttachedObjectIterator(); while(childIt.hasMoreElements()) { MovableObject* c = childIt.getNext(); if (c->getQueryFlags() & mQueryMask) { result = mRay.intersects(c->getWorldBoundingBox()); if (result.first) { listener->queryResult(c, result.second); } } } } } } } ++it; } // reset startzone and exclude node mStartZone = 0; mExcludeNode = 0; }
//--------------------------------------------------------------------- void PCZIntersectionSceneQuery::execute(IntersectionSceneQueryListener* listener) { typedef std::pair<MovableObject *, MovableObject *> MovablePair; typedef std::set < std::pair<MovableObject *, MovableObject *> > MovableSet; MovableSet set; // Iterate over all movable types Root::MovableObjectFactoryIterator factIt = Root::getSingleton().getMovableObjectFactoryIterator(); while(factIt.hasMoreElements()) { SceneManager::MovableObjectIterator it = mParentSceneMgr->getMovableObjectIterator( factIt.getNext()->getType()); while( it.hasMoreElements() ) { MovableObject * e = it.getNext(); PCZone * zone = ((PCZSceneNode*)(e->getParentSceneNode()))->getHomeZone(); PCZSceneNodeList list; //find the nodes that intersect the AAB static_cast<PCZSceneManager*>( mParentSceneMgr ) -> findNodesIn( e->getWorldBoundingBox(), list, zone, 0 ); //grab all moveables from the node that intersect... PCZSceneNodeList::iterator nit = list.begin(); while( nit != list.end() ) { SceneNode::ObjectIterator oit = (*nit) -> getAttachedObjectIterator(); while( oit.hasMoreElements() ) { MovableObject * m = oit.getNext(); if( m != e && set.find( MovablePair(e,m)) == set.end() && set.find( MovablePair(m,e)) == set.end() && (m->getQueryFlags() & mQueryMask) && (m->getTypeFlags() & mQueryTypeMask) && m->isInScene() && e->getWorldBoundingBox().intersects( m->getWorldBoundingBox() ) ) { listener -> queryResult( e, m ); // deal with attached objects, since they are not directly attached to nodes if (m->getMovableType() == "Entity") { Entity* e2 = static_cast<Entity*>(m); Entity::ChildObjectListIterator childIt = e2->getAttachedObjectIterator(); while(childIt.hasMoreElements()) { MovableObject* c = childIt.getNext(); if (c->getQueryFlags() & mQueryMask && e->getWorldBoundingBox().intersects( c->getWorldBoundingBox() )) { listener->queryResult(e, c); } } } } set.insert( MovablePair(e,m) ); } ++nit; } } } }