std::string TrackableUnifiedHandleObject::getStatusInfo()
	{
		std::string ret = "TrackableUnifiedHandleObject:\r\n";

		int trackablesInPool = 0;
		int unitTrackables = 0;
		int toTrackables = 0;
		std::string poolVis = "";

		for (int i = 0; i < TUHO_POOL_SIZE; i++)
		{
			if (tuho_pool[i].handle != 0)
			{
				if (IS_UNIFIED_HANDLE_UNIT(tuho_pool[i].handle))
				{
					unitTrackables++;
				}
				if (IS_UNIFIED_HANDLE_TERRAIN_OBJECT(tuho_pool[i].handle))
				{
					toTrackables++;
				}
				trackablesInPool++;
				int attachCacheAmount = 0;
				for (int j = 0; j < TRACKABLEUNIFIEDHANDLEOBJECT_TRACKED_BY_CACHE_SIZE; j++)
				{
					if (tuho_pool[i].trackedBy[j] != UNIFIED_HANDLE_NONE)
					{
						attachCacheAmount++;
					}
				}
				char foo[2];
				if (tuho_pool[i].trackedByCount > attachCacheAmount)
					foo[0] = 'N';
				else
					foo[0] = '0' + attachCacheAmount;
				foo[1] = '\0';
				poolVis += foo;
			} else {
				poolVis += "-";
			}
		}

		assert(tuho_pool_used == trackablesInPool);

		ret += std::string("Unified handle trackables in pool: ") + int2str(trackablesInPool);
		ret += std::string("\r\n");

		ret += std::string("Unified handle trackables pointing to units: ") + int2str(unitTrackables);
		ret += std::string("\r\n");

		ret += std::string("Unified handle trackables pointing to terrain objects: ") + int2str(toTrackables);
		ret += std::string("\r\n");

		ret += std::string("Unified handle trackables pool utilization visualization: ") + poolVis;
		ret += std::string("\r\n");

		return ret;
	}
Ejemplo n.º 2
0
	int UnitList::unifiedHandleToUnitId(UnifiedHandle unifiedHandle) const
	{
		// why bother removing the bit, no reason for that... duh.
		//assert(IS_UNIFIED_HANDLE_UNIT(unifiedHandle));
		//return (unifiedHandle ^ UNIFIED_HANDLE_BIT_UNIT);

		// the correct implementation...
		assert(VALIDATE_UNIFIED_HANDLE_BITS(unifiedHandle));
		assert(IS_UNIFIED_HANDLE_UNIT(unifiedHandle));
		return unifiedHandle;
	}
Ejemplo n.º 3
0
	UnifiedHandle UnitList::getUnifiedHandle(int unitId) const
	{
		// why bother removing the bit, no reason for that... duh.
		//assert(!IS_UNIFIED_HANDLE_UNIT(unitId));
		//assert(IS_UNIFIED_HANDLE_UNIT(unitId | UNIFIED_HANDLE_BIT_UNIT));
		//return (unitId | UNIFIED_HANDLE_BIT_UNIT);

		// the correct implementation...
		assert(VALIDATE_UNIFIED_HANDLE_BITS(unitId));
		assert(IS_UNIFIED_HANDLE_UNIT(unitId));
		return unitId;
	}
Ejemplo n.º 4
0
	bool UnifiedHandleManager::doesObjectExist(UnifiedHandle uh) const
	{
		if (IS_UNIFIED_HANDLE_UNIT(uh))
		{
			return game->units->doesTrackableUnifiedHandleObjectExist(uh);
		}
		else if (IS_UNIFIED_HANDLE_TERRAIN_OBJECT(uh))
		{
			if (game->gameUI->getTerrain())
				return game->gameUI->getTerrain()->doesTrackableUnifiedHandleObjectExist(uh);
			else
				return false;
		}
		else if (IS_UNIFIED_HANDLE_LIGHT(uh))
		{
			if (game->gameUI->getLightManager())
				return game->gameUI->getLightManager()->doesLightExist(uh);
			else
				return false;
		}
		else if (IS_UNIFIED_HANDLE_DYNAMIC_LIGHT(uh))
		{
			if (game->gameUI->getDynamicLightManager())
				return game->gameUI->getDynamicLightManager()->doesLightExist(uh);
			else
				return false;
		}
		else if (IS_UNIFIED_HANDLE_TRACKER(uh))
		{
			ITrackerObject *t = game->objectTracker->getTrackerByUnifiedHandle(uh);
			if (t != NULL)
			{
				return true;
			} else {
				return false;
			}
		}
		else if (IS_UNIFIED_HANDLE_PARTICLE_SPAWNER(uh))
		{
			if (game->particleSpawnerManager)
				return game->particleSpawnerManager->doesParticleSpawnerExist(uh);
			else
				return false;
		}
		else 
		{
			// TODO: other types.
			assert(!"UnifiedHandleManager::doesObjectExist - TODO, other types.");
			return false;
		}
	}
Ejemplo n.º 5
0
	void UnifiedHandleManager::setObjectPosition(UnifiedHandle uh, const VC3 &position)
	{
		if (IS_UNIFIED_HANDLE_TRACKER(uh))
		{
			ITrackerObject *t = game->objectTracker->getTrackerByUnifiedHandle(uh);
			assert(t != NULL);
			t->setTrackerPosition(position);
		}
		else if (IS_UNIFIED_HANDLE_UNIT(uh))
		{
			assert(game->units->doesTrackableUnifiedHandleObjectExist(uh));
			Unit *u = game->units->getUnitById(game->units->unifiedHandleToUnitId(uh));
			UnitActor *ua = getUnitActorForUnit(u);
			assert(ua != NULL);
			ua->removeUnitObstacle(u);
			u->setPosition(position);
			ua->addUnitObstacle(u);
		}
		else if (IS_UNIFIED_HANDLE_TERRAIN_OBJECT(uh))
		{
			assert(game->gameUI->getTerrain()->doesTrackableUnifiedHandleObjectExist(uh));
			int modelId = 0;
			int instanceId = 0;
			game->gameUI->getTerrain()->unifiedHandleToTerrainIds(uh, &modelId, &instanceId);
			game->gameUI->getTerrain()->setTerrainObjectPosition(modelId, instanceId, position);
		}
		else if (IS_UNIFIED_HANDLE_LIGHT(uh))
		{
			assert(game->gameUI->getLightManager()->doesLightExist(uh));
			game->gameUI->getLightManager()->setLightPositionByUnifiedHandle(uh, position);
		}
		else if (IS_UNIFIED_HANDLE_DYNAMIC_LIGHT(uh))
		{
			assert(game->gameUI->getDynamicLightManager()->doesLightExist(uh));
			game->gameUI->getDynamicLightManager()->setLightPositionByUnifiedHandle(uh, position);
		}
		else if (IS_UNIFIED_HANDLE_PARTICLE_SPAWNER(uh))
		{
			assert(game->particleSpawnerManager->doesParticleSpawnerExist(uh));
			game->particleSpawnerManager->setParticleSpawnerPosition(uh, position);
		}
		else 
		{
			// TODO: other types.
			assert(!"UnifiedHandleManager::setObjectPosition - TODO, other types.");
		}
	}
	QUAT TrackableUnifiedHandleObject::getTrackableObjectRotation() const
	{
		// BUGBUG?? assert ei toimi
		// assert(TrackableUnifiedHandleObject::game != NULL);

		if (IS_UNIFIED_HANDLE_UNIT(handle))
		{
			return tuho_game->units->getTrackableUnifiedHandleRotation(handle);
		}
		else if (IS_UNIFIED_HANDLE_TERRAIN_OBJECT(handle))
		{
			return tuho_game->gameUI->getTerrain()->getTrackableUnifiedHandleRotation(handle);
		} else {
			assert(!"TrackableUnifiedHandleObject::getTrackableObjectRotation - Unified handle maps to unsupported object type.");
			return QUAT();
		}

	}
Ejemplo n.º 7
0
	void SelectionVisualizer::visualizeSelections(game::Game *game)
	{
		VC3 campos = game->gameUI->getGameCamera()->getActualInterpolatedPosition();

		for (int i = 0; i < (int)selectionUnifiedHandles.size(); i++)
		{
			if (IS_UNIFIED_HANDLE_TERRAIN_OBJECT(selectionUnifiedHandles[i]))
			{
				DebugTerrainObjectVisFlags flags = DEBUGTERRAINOBJECTVISUALIZER_FLAG_SELECTED;
				DebugTerrainObjectVisualizer::visualizeTerrainObject(game, selectionUnifiedHandles[i], campos, flags);
			}
			else if (IS_UNIFIED_HANDLE_UNIT(selectionUnifiedHandles[i]))
			{
				Unit *u = game->units->getUnitById(game->units->unifiedHandleToUnitId(selectionUnifiedHandles[i]));
				DebugUnitVisFlags flags = DEBUGUNITVISUALIZER_FLAG_SELECTED;
				DebugUnitVisualizer::visualizeUnit(u, campos, flags);
			}
		}
	}
Ejemplo n.º 8
0
	VC3 UnifiedHandleManager::getObjectPosition(UnifiedHandle uh) const
	{
		if (IS_UNIFIED_HANDLE_UNIT(uh))
		{
			assert(game->units->doesTrackableUnifiedHandleObjectExist(uh));
			return game->units->getTrackableUnifiedHandlePosition(uh);
		}
		else if (IS_UNIFIED_HANDLE_TERRAIN_OBJECT(uh))
		{
			assert(game->gameUI->getTerrain()->doesTrackableUnifiedHandleObjectExist(uh));
			return game->gameUI->getTerrain()->getTrackableUnifiedHandlePosition(uh);
		}
		else if (IS_UNIFIED_HANDLE_LIGHT(uh))
		{
			assert(game->gameUI->getLightManager()->doesLightExist(uh));
			return game->gameUI->getLightManager()->getLightPosition(uh);
		}
		else if (IS_UNIFIED_HANDLE_DYNAMIC_LIGHT(uh))
		{
			assert(game->gameUI->getDynamicLightManager()->doesLightExist(uh));
			return game->gameUI->getDynamicLightManager()->getLightPosition(uh);
		}
		else if (IS_UNIFIED_HANDLE_TRACKER(uh))
		{
			ITrackerObject *t = game->objectTracker->getTrackerByUnifiedHandle(uh);
			assert(t != NULL);
			return t->getTrackerPosition();
		}
		else if (IS_UNIFIED_HANDLE_PARTICLE_SPAWNER(uh))
		{
			assert(game->particleSpawnerManager->doesParticleSpawnerExist(uh));
			return game->particleSpawnerManager->getParticleSpawnerPosition(uh);
		}
		else 
		{
			// TODO: other types.
			assert(!"UnifiedHandleManager::getObjectPosition - TODO, other types.");
			return VC3(0,0,0);
		}
	}