示例#1
0
文件: sight.cpp 项目: vgck/opendr2
  //
  // Dirty all cells on the map
  //
  static void DirtyAllCells()
  {
    Game::TeamBitfield bits = 0;

    for (U32 t = 0; t < teamCount; t++)
    {
      bits |= (1 << t);
    }

    DirtyCells(0, 0, WorldCtrl::CellMapX()-1, WorldCtrl::CellMapZ()-1, bits);
  }
// Checks if any columns are dependent on the number of children present, and
// refreshes them from the data source if they are.
void ElementDataGridRow::RefreshChildDependentCells()
{
	if (child_index != -1)
	{
		for (int i = 0; i < parent_grid->GetNumColumns(); i++)
		{
			const ElementDataGrid::Column* column = parent_grid->GetColumn(i);
			if (column->refresh_on_child_change)
			{
				DirtyCells();
			}
		}
	}
}
示例#3
0
文件: sight.cpp 项目: vgck/opendr2
  //
  // Unsweep for a sight map
  //
  static void Unsweep(Map *map)
  {
    START(unSweepTime);

    PREFETCH(&__prefetch);

    // Last sweep position
    S32 tileX = map->lastX;
    S32 tileZ = map->lastZ;

    // Last sweep radius
    S32 r = map->lastR;

    // Get viewing mask for lower layer
    U8 *mapLo = map->GetByteMap(Map::LV_LO);
    U8 maskLo = map->GetBitMask(Map::LV_LO);

    // Dirty cells that line of sight has changed in
    DirtyCells(tileX - r, tileZ - r, tileX + r, tileZ + r, map->lastTeam);

    // iterate over all tiles within last scan radius
    S32 first = XZToSeemap(-r, -r);

    for (S32 y = -r; y <= r; y++, first += MAPSIDE)
    {
      PREFETCH(&mapLo[first+MAPSIDE]);

      for (S32 x = -r, index = first; x <= r; x++, index++)
      {
        // Unsweep tile on ground level if was swept
        if (mapLo[index] & maskLo)
        {
          // Unsweep for all teams last swept
          CantSee(tileX + x, tileZ + y, x, y, map->lastTeam, Map::LV_LO);

          // Clear seen bit
          mapLo[index] &= ~maskLo;
        }
      }
    }

    // Reset last radius and team mask
    map->lastR = 0;
    map->lastTeam = 0;
    map->lastAlt = F32_MAX;

    STOP(unSweepTime);
  }
示例#4
0
文件: sight.cpp 项目: vgck/opendr2
    //
    // New and improved sweep
    //
    void Sweep(UnitObj *u)
    {
      ASSERT(sysInit);
      ASSERT(u);
      //ASSERT(u->GetTeam());
      ASSERT(u->OnMap());

      START(sweepTime);

      r = u->GetSeeingRange();
      unit = u;
      cellX = u->cellX;
      cellZ = u->cellZ;

      ASSERT(r < MAXR)

      // Get sight map and mask
      maskLo = u->sightMap->GetBitMask(Map::LV_LO);
      mapLo = u->sightMap->GetByteMap(Map::LV_LO);

      // Reset max radius seen
      u->sightMap->lastR = S16_MIN;

      // Set teams that this sweep will provide LOS for
      Team *myTeam = u->GetTeam();
      teamBits = 0;

      if (myTeam)
      {
        for (U32 team = 0; team < Game::MAX_TEAMS; ++team)
        {
          Team *other = Team::Id2Team(team);

          if (other)
          {
            if
            (
              // Other team is an ally
              Team::TestUnitRelation(u, other, Relation::ALLY)

              ||

              // Other team is giving us line of sight
              myTeam->GivingSightTo(other->GetId())
            )
            {
              ASSERT(teamRemap[team] < teamCount)
              Game::TeamSet(teamBits, teamRemap[team]);
            }
          }
        }
      }

      // Dirty cells that line of sight has changed in
      DirtyCells(cellX - r, cellZ - r, cellX + r, cellZ + r, teamBits);

      // Set up viewing radius
      if (r > 0)
      {
        r2 = r * r;
        r2Inv = 1.0f / F32(r2);

        // Get eye position
        eyePos = EyePosition(u);

        // In the code below the row and column of cells with the
        // same y and x value of the unit are processed twice but
        // their viewing information is only updated once. Stuff
        // the slight inneficiency (2*r extra comparisons). This
        // way we require 1/4 the memory and the code is more
        // elegant.

        // scan ++ quadrant
        quadrantX = POS;
        quadrantZ = POS;

        FillGradMap();
        FillMaxGradMapPosZ();
        CompareGradPosPos();

        // Scan -+ quadrant
        quadrantX = NEG;

        FillGradMapRotated();
        FillMaxGradMapPosZ();
        CompareGradNegPos();

        // Scan -- quadrant
        quadrantZ = NEG;

        FillGradMap();
        FillMaxGradMapNegZ();
        CompareGradNegNeg();

        // Scan +- quadrant
        quadrantX = POS;

        FillGradMapRotated();
        FillMaxGradMapNegZ();
        CompareGradPosNeg();
      }

      // Can always see cell that unit is occupying
      CanSee(cellX, cellZ, 0, 0, mapLo, maskLo, teamBits, Map::LV_LO);

      // Update scan info in unit's sight map
      u->sightMap->lastTeam = teamBits;
      u->sightMap->lastR = S16(r);
      u->sightMap->lastX = cellX;
      u->sightMap->lastZ = cellZ;
      u->sightMap->lastAlt = eyePos;

      STOP(sweepTime);
    }