示例#1
0
void KateCTagsView::gotoTagForTypes(const QString &word, const QStringList &types)
{
    Tags::TagList list = Tags::getMatches(m_ctagsUi.tagsFile->text(), word, false, types);
    if (list.size() == 0) list = Tags::getMatches(m_commonDB, word, false, types);

    //kDebug() << "found" << list.count() << word << types;
    setNewLookupText(word);

    if ( list.count() < 1) {
        m_ctagsUi.tagTreeWidget->clear();
        new QTreeWidgetItem(m_ctagsUi.tagTreeWidget, QStringList(i18n("No hits found")));
        m_ctagsUi.tabWidget->setCurrentIndex(0);
        m_mWin->showToolView(m_toolView);
        return;
    }

    displayHits(list);

    if (list.count() == 1) {
        Tags::TagEntry tag = list.first();
        jumpToTag(tag.file, tag.pattern, word);
    }
    else {
        Tags::TagEntry tag = list.first();
        jumpToTag(tag.file, tag.pattern, word);
        m_ctagsUi.tabWidget->setCurrentIndex(0);
        m_mWin->showToolView(m_toolView);
    }
}
示例#2
0
void KateCTagsView::lookupTag( )
{
    QString currWord = currentWord();
    if (currWord.isEmpty()) {
        return;
    }

    setNewLookupText(currWord);
    Tags::TagList list = Tags::getExactMatches(m_ctagsUi.tagsFile->text(), currWord);
    if (list.size() == 0) list = Tags::getExactMatches(m_commonDB, currWord);
    displayHits(list);

    // activate the hits tab
    m_ctagsUi.tabWidget->setCurrentIndex(0);
    m_mWin->showToolView(m_toolView);
}
hkDemo::Result OptimizedWorldRaycastDemo::stepDemo()
{
	m_world->lock();

	m_time += m_timestep;

	//
	//	Create a number of ray directions
	//
	const int NUM_DIRECTIONS = 8; const hkReal increment = 2.0f;
	//const int NUM_DIRECTIONS = 125; const hkReal increment = 0.5f;

	hkVector4 rayDirections[NUM_DIRECTIONS];
	{
		int i = 0;
		for (hkReal x = -1.0f; x <= 1.0f; x += increment)
		{
			for (hkReal y = -1.0f; y <= 1.0f; y += increment)
			{
				for (hkReal z = -1.0f; z <= 1.0f; z+= increment)
				{
					rayDirections[i++].set(x,y,z);
				}
			}
		}
	}

	
	hkReal angle = 0.5f * m_time;
	
	// In these first chapter we simply call the hkpWorld castRay version with no further optimizations
	{
		angle += HK_REAL_PI * 0.3f;

		hkReal xPos = m_rayLength * 3.0f * hkMath::sin(angle);
		hkReal zPos = m_rayLength * 3.0f * hkMath::cos(angle);

		hkpWorldRayCastInput      inputs[NUM_DIRECTIONS];
		hkpClosestRayHitCollector collectors[NUM_DIRECTIONS];

		HK_TIMER_BEGIN("NotOptimized", HK_NULL);
		{
			for (int i = 0; i < NUM_DIRECTIONS; i++)
			{
				inputs[i].m_from.set( xPos, 0, zPos);
				inputs[i].m_to.setAddMul4(inputs[i].m_from, rayDirections[i], 1.f*m_rayLength);
				m_world->castRay(inputs[i], collectors[i]);
			}
		}
		HK_TIMER_END();
		displayHits( inputs, NUM_DIRECTIONS, collectors, hkColor::RED);
	}
	
	// This second set of raycasts (yellow) is using a the group functionality of the hkpWorldRayCaster.
	// Internally it builds an the aabb cache. This is an optimization for broadphase raycasts. 
	// Note that we need to pass in array of collectors to the hkpWorldRayCaster.
	// As the hkpWorldRayCaster has no clue about the size of each collector, we have to pass in the size.
	// Interesting if we use a size of 0, than all raycast will report to the same collector.
	{
		angle += HK_REAL_PI * 0.3f;

		hkReal xPos = m_rayLength * 3.0f * hkMath::sin(angle);
		hkReal zPos = m_rayLength * 3.0f * hkMath::cos(angle);

		hkpWorldRayCastInput inputs[NUM_DIRECTIONS];
		hkpClosestRayHitCollector collectors[NUM_DIRECTIONS];

		//
		//	Cast Rays
		//
		HK_TIMER_BEGIN("CastRayGroup", HK_NULL);
		{
			for (int i = 0; i < NUM_DIRECTIONS; i++)
			{
				inputs[i].m_from.set( xPos, 0, zPos);
				inputs[i].m_to.setAddMul4(inputs[i].m_from, rayDirections[i], 1.f*m_rayLength);

			}
			hkpWorldRayCaster rayCaster;
			rayCaster.castRayGroup( *m_world->getBroadPhase(), inputs, NUM_DIRECTIONS, m_world->getCollisionFilter(), collectors, sizeof(collectors[0]) ); 
		}
		HK_TIMER_END();
		displayHits( inputs, NUM_DIRECTIONS, collectors, hkColor::CYAN);
	}
	
	// This set of raycasts (yellow) is using a the hkpBroadPhaseAabbCache.
	// So by building the aabb cache. This is an optimization for broadphase raycasts. 
	// The idea is that the aabb cache is actually a reduced broadphase, just storing
	// objects inside the aabb. Therefore using this cache can speed up rayCasts significantly.
	// Unfortunately we cannot use our simple hkpWorld::castRay() function, but have to use
	// a small helper class hkpWorldRayCaster (which is actually used by the hkpWorld::castRay()).
	{
		angle += HK_REAL_PI * 0.3f;

		hkReal xPos = m_rayLength * 3.0f * hkMath::sin(angle);
		hkReal zPos = m_rayLength * 3.0f * hkMath::cos(angle);

		hkpWorldRayCastInput inputs[NUM_DIRECTIONS];
		hkpClosestRayHitCollector collectors[NUM_DIRECTIONS];

		//
		//	Calc Cache
		//
		HK_TIMER_BEGIN_LIST("UseAabbCache", "CalcCache");
		hkpBroadPhaseAabbCache* cache;
		int                    cacheSize;
		{	
			hkAabb aabb;
			aabb.m_min.set( xPos - m_rayLength, -m_rayLength, zPos-m_rayLength);
			aabb.m_max.set( xPos + m_rayLength, +m_rayLength, zPos+m_rayLength);

			cacheSize = m_world->getBroadPhase()->getAabbCacheSize();
			cache     = reinterpret_cast<hkpBroadPhaseAabbCache*>(hkAllocateStack<char>(cacheSize));
			
			m_world->getBroadPhase()->calcAabbCache( aabb, cache );
		}

		//
		//	Cast Rays
		//
		HK_TIMER_SPLIT_LIST("CastRays");
		{
			for (int i = 0; i < NUM_DIRECTIONS; i++)
			{
				inputs[i].m_from.set( xPos, 0, zPos);
				inputs[i].m_to.setAddMul4(inputs[i].m_from, rayDirections[i], 1.f*m_rayLength);

				hkpWorldRayCaster rayCaster;
				rayCaster.castRay( *m_world->getBroadPhase(), inputs[i], m_world->getCollisionFilter(), cache, collectors[i] ); 
			}
		}
		HK_TIMER_END_LIST();
		hkDeallocateStack<char>( (char*)cache);
		displayHits( inputs, NUM_DIRECTIONS, collectors, hkColor::YELLOW);
	}
	
	
	// This third set of raycasts (blue) is using a the hkpBroadPhaseAabbCache and
	// also makes use of the fact that many rays starting at the same position can
	// be handled specially.
	// Unfortunately we cannot use our simple hkpWorld::castRay() function, but have to use
	// a small helper class hkpWorldRayCaster (which is actually used by the hkpWorld::castRay()).
	{
		angle += HK_REAL_PI * 0.3f;

		hkReal xPos = m_rayLength * 3.0f * hkMath::sin(angle);
		hkReal zPos = m_rayLength * 3.0f * hkMath::cos(angle);

		hkpWorldRayCastInput      inputs[NUM_DIRECTIONS];
		hkpClosestRayHitCollector collectors[NUM_DIRECTIONS];

		//
		//	Calc Cache
		//
		HK_TIMER_BEGIN_LIST("CacheSameStart", "CalcCache");
		hkpBroadPhaseAabbCache* cache;
		int                    cacheSize;
		{	
			hkAabb aabb;
			aabb.m_min.set( xPos - m_rayLength, -m_rayLength, zPos-m_rayLength);
			aabb.m_max.set( xPos + m_rayLength, +m_rayLength, zPos+m_rayLength);

			cacheSize = m_world->getBroadPhase()->getAabbCacheSize();
			cache = reinterpret_cast<hkpBroadPhaseAabbCache*>(hkAllocateStack<char>(cacheSize));
			
			m_world->getBroadPhase()->calcAabbCache( aabb, cache );
		}
		
		//
		//	Cast Rays
		//
		HK_TIMER_SPLIT_LIST("CastRays");
		{
			for (int i = 0; i < NUM_DIRECTIONS; i++)
			{
				inputs[i].m_from.set( xPos, 0, zPos);
				inputs[i].m_to.setAddMul4(inputs[i].m_from, rayDirections[i], 1.f*m_rayLength);
			}
			hkpWorldRayCaster rayCaster;
			rayCaster.castRaysFromSinglePoint( *m_world->getBroadPhase(), inputs, NUM_DIRECTIONS, m_world->getCollisionFilter(), cache, collectors, hkSizeOf( collectors[0] ) ); 
		}
		HK_TIMER_END_LIST();
		hkDeallocateStack<char>( (char*)cache);
		displayHits( inputs, NUM_DIRECTIONS, collectors, hkColor::BLUE);
	}

	// This 4th set of raycasts (green) is using a the AabbPhantom
	// A phantom is like a persistent aabb cache, so it only makes sense if our aabb shows some
	// framecoherency. 
	// Unfortunetaly the current phantom implementations simply casts the ray against all objects
	// overlapping with the phantom. Therefor, if too many objects are intersecting the phantoms
	// aabb, performance could get bad.
	{
		angle += HK_REAL_PI * 0.3f;
		hkReal xPos = m_rayLength * 3.0f * hkMath::sin(angle);
		hkReal zPos = m_rayLength * 3.0f * hkMath::cos(angle);

		hkpWorldRayCastInput inputs[NUM_DIRECTIONS];
		hkpClosestRayHitCollector collectors[NUM_DIRECTIONS];

		HK_TIMER_BEGIN_LIST("AabbPhantom", "MovePhantom");
		{	
			hkAabb aabb;
			aabb.m_min.set( xPos - m_rayLength, -m_rayLength, zPos-m_rayLength);
			aabb.m_max.set( xPos + m_rayLength, +m_rayLength, zPos+m_rayLength);

			m_phantom->setAabb( aabb );
		}
		
		HK_TIMER_SPLIT_LIST("CastRays");

		{
			for (int i = 0; i < NUM_DIRECTIONS; i++)
			{
				inputs[i].m_from.set( xPos, 0, zPos);
				inputs[i].m_to.setAddMul4(inputs[i].m_from, rayDirections[i], 1.f*m_rayLength);
				m_phantom->castRay(inputs[i], collectors[i]);
			}
		}

		HK_TIMER_END_LIST();
		displayHits( inputs, NUM_DIRECTIONS, collectors, hkColor::GREEN);
	}

	// fastest (purple), combine all optimizations above
	// We are using a phantom to set up the broadphase cache. This avoids the problem of the hkpPhantom::castRay()
	{
		angle += HK_REAL_PI * 0.3f;
		hkReal xPos = m_rayLength * 3.0f * hkMath::sin(angle);
		hkReal zPos = m_rayLength * 3.0f * hkMath::cos(angle);

		hkpWorldRayCastInput inputs[NUM_DIRECTIONS];
		hkpClosestRayHitCollector collectors[NUM_DIRECTIONS];

		hkpBroadPhaseAabbCache* cache;
		int                    cacheSize;
		HK_TIMER_BEGIN_LIST("AllOpt.", "MovePhantomAndDoCache");
		{	
			hkAabb aabb;
			aabb.m_min.set( xPos - m_rayLength, -m_rayLength, zPos-m_rayLength);
			aabb.m_max.set( xPos + m_rayLength, +m_rayLength, zPos+m_rayLength);

			m_phantomUseCache->setAabb( aabb );

			cacheSize = m_world->getBroadPhase()->getAabbCacheSize();
			cache = reinterpret_cast<hkpBroadPhaseAabbCache*>(hkAllocateStack<char>(cacheSize));
			
			m_world->getBroadPhase()->calcAabbCache( m_phantomUseCache->getOverlappingCollidables(), cache );
		}

		HK_TIMER_SPLIT_LIST("CastRays");

		{
			for (int i = 0; i < NUM_DIRECTIONS; i++)
			{
				inputs[i].m_from.set( xPos, 0, zPos);
				inputs[i].m_to.setAddMul4(inputs[i].m_from, rayDirections[i], 1.f*m_rayLength);
			}
			hkpWorldRayCaster rayCaster;
			rayCaster.castRaysFromSinglePoint( *m_world->getBroadPhase(), inputs, NUM_DIRECTIONS, m_world->getCollisionFilter(), cache, collectors, hkSizeOf( collectors[0] ) ); 
		}

		HK_TIMER_END_LIST();
		hkDeallocateStack<char>( (char*)cache);
		displayHits( inputs, NUM_DIRECTIONS, collectors, hkColor::PURPLE);
	}

	m_world->unlock();

	return hkDefaultPhysicsDemo::stepDemo();
}
示例#4
0
void KateCTagsView::editLookUp()
{
    Tags::TagList list = Tags::getPartialMatches(m_ctagsUi.tagsFile->text(), m_ctagsUi.inputEdit->text());
    if (list.size() == 0) list = Tags::getPartialMatches(m_commonDB, m_ctagsUi.inputEdit->text());
    displayHits(list);
}