Exemplo n.º 1
0
  double ComputeSmoothness(Array * heightMap) {
    
    Array  * distances = Make_Array_With_Shape(PLAIN_KIND,UINT32_TYPE,Coord2(heightMap->dims[1], heightMap->dims[0]));
    uint32 * distVals   = AUINT32(distances);
    uint32 * hmVals = AUINT32(heightMap);
    
    Use_Reflective_Boundary();
    
    HeightMapRange range = GetLevelRange(heightMap);
    
    // frame defines the local neighborhood
    Frame * f = Make_Frame(heightMap,Coord2(3,3),Coord2(1,1));
    Histogram * h = Make_Histogram(UVAL,range.maxLayer,ValU(1),ValU(0));
    Place_Frame(f,0);
    
    
    for (Indx_Type i=0; i< heightMap->size; i++) {
      
      Empty_Histogram(h);
      Histagain_Array(h, f, 0);
      
      int middleBin = Value2Bin(h, ValU(hmVals[i]));    // To determine the median value of the pixel's neighborhood, we exlude the current pixel i from the histogram
      h->counts[middleBin]--;
      
      distVals[i] = std::abs(static_cast<double>(hmVals[i]) - static_cast<double>(Percentile2Bin(h, 0.5)));
    }
    
#ifdef DEVELOP
    Write_Image("HeightMapSmoothness", distances, DONT_PRESS);
#endif
    
    Empty_Histogram(h);
    Histagain_Array(h, distances, 0);
    
    double meanDistance = Histogram_Mean(h);
    std::cout << "Smoothness:\n   Mean distance: " << meanDistance << "\n   Sd: " << Histogram_Sigma(h) << std::endl;
    
    Free_Histogram(h);
    Free_Frame(f);
    Free_Array(distances);
    
    return meanDistance;
  }
Exemplo n.º 2
0
void BattleGround::RewardHonorToTeamDepOnLvl(const uint32 Honor[], uint32 TeamID)
{
    for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
    {
        Player *plr = sObjectMgr.GetPlayer(itr->first);

        if(!plr)
        {
            sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
            continue;
        }

        uint32 team = itr->second.Team;
        if(!team) team = plr->GetTeam();

        if(team == TeamID)
        {
            uint32 range = GetLevelRange(plr->getLevel());
            UpdatePlayerScore(plr, SCORE_BONUS_HONOR, Honor[range]);
        }
    }
}