void CDirectionalLEDEntitySpaceHashUpdater::operator()(CAbstractSpaceHash<CDirectionalLEDEntity>& c_space_hash, CDirectionalLEDEntity& c_element) { /* Calculate the position of the LED in the space hash */ c_space_hash.SpaceToHashTable(m_nI, m_nJ, m_nK, c_element.GetPosition()); /* Update the corresponding cell */ c_space_hash.UpdateCell(m_nI, m_nJ, m_nK, c_element); }
void CLEDEntitySpaceHashUpdater::operator()(CAbstractSpaceHash<CLEDEntity>& c_space_hash, CLEDEntity& c_element) { /* Discard LEDs switched off */ if(c_element.GetColor() != CColor::BLACK) { /* Calculate the position of the LED in the space hash */ c_space_hash.SpaceToHashTable(m_nI, m_nJ, m_nK, c_element.GetPosition()); /* Update the corresponding cell */ c_space_hash.UpdateCell(m_nI, m_nJ, m_nK, c_element); } }
void CRABEquippedEntitySpaceHashUpdater::operator()(CAbstractSpaceHash<CRABEquippedEntity>& c_space_hash, CRABEquippedEntity& c_element) { /* Calculate the position of the center of the RAB equipped entity in the space hash */ c_space_hash.SpaceToHashTable(m_nCenterI, m_nCenterJ, m_nCenterK, c_element.GetPosition()); /* Update the cells in a sphere around it */ SInt32 nRangeI = c_space_hash.SpaceToHashTable(c_element.GetRange(), 0); SInt32 nRangeJ; SInt32 nRangeK; for(SInt32 i = 0; i <= nRangeI; ++i) { nRangeJ = c_space_hash.SpaceToHashTable( ::sqrt( Square(c_element.GetRange()) - Square(c_space_hash.HashTableToSpace(i, 0)) ), 1); for(SInt32 j = 0; j <= nRangeJ; ++j) { nRangeK = c_space_hash.SpaceToHashTable( ::sqrt( Square(c_element.GetRange()) - Square(c_space_hash.HashTableToSpace(j, 1)) ), 2); for(SInt32 k = 0; k <= nRangeK; ++k) { if(i > 0) { /* * i > 0 */ if(j > 0) { /* * i > 0 * j > 0 */ if(k > 0) { /* * i > 0 * j > 0 * k > 0 */ c_space_hash.UpdateCell(m_nCenterI + i, m_nCenterJ + j, m_nCenterK + k, c_element); c_space_hash.UpdateCell(m_nCenterI + i, m_nCenterJ + j, m_nCenterK - k, c_element); c_space_hash.UpdateCell(m_nCenterI + i, m_nCenterJ - j, m_nCenterK + k, c_element); c_space_hash.UpdateCell(m_nCenterI + i, m_nCenterJ - j, m_nCenterK - k, c_element); c_space_hash.UpdateCell(m_nCenterI - i, m_nCenterJ + j, m_nCenterK + k, c_element); c_space_hash.UpdateCell(m_nCenterI - i, m_nCenterJ + j, m_nCenterK - k, c_element); c_space_hash.UpdateCell(m_nCenterI - i, m_nCenterJ - j, m_nCenterK + k, c_element); c_space_hash.UpdateCell(m_nCenterI - i, m_nCenterJ - j, m_nCenterK - k, c_element); } else { /* * i > 0 * j > 0 * k == 0 */ c_space_hash.UpdateCell(m_nCenterI + i, m_nCenterJ + j, m_nCenterK, c_element); c_space_hash.UpdateCell(m_nCenterI + i, m_nCenterJ - j, m_nCenterK, c_element); c_space_hash.UpdateCell(m_nCenterI - i, m_nCenterJ + j, m_nCenterK, c_element); c_space_hash.UpdateCell(m_nCenterI - i, m_nCenterJ - j, m_nCenterK, c_element); } } else { /* * i > 0 * j == 0 */ if(k > 0) { /* * i > 0 * j == 0 * k > 0 */ c_space_hash.UpdateCell(m_nCenterI + i, m_nCenterJ, m_nCenterK + k, c_element); c_space_hash.UpdateCell(m_nCenterI + i, m_nCenterJ, m_nCenterK - k, c_element); c_space_hash.UpdateCell(m_nCenterI - i, m_nCenterJ, m_nCenterK + k, c_element); c_space_hash.UpdateCell(m_nCenterI - i, m_nCenterJ, m_nCenterK - k, c_element); } else { /* * i > 0 * j == 0 * k == 0 */ c_space_hash.UpdateCell(m_nCenterI + i, m_nCenterJ, m_nCenterK, c_element); c_space_hash.UpdateCell(m_nCenterI - i, m_nCenterJ, m_nCenterK, c_element); } } } else { /* * i == 0 */ if(j > 0) { /* * i == 0 * j > 0 */ if(k > 0) { /* * i == 0 * j > 0 * k > 0 */ c_space_hash.UpdateCell(m_nCenterI, m_nCenterJ + j, m_nCenterK + k, c_element); c_space_hash.UpdateCell(m_nCenterI, m_nCenterJ + j, m_nCenterK - k, c_element); c_space_hash.UpdateCell(m_nCenterI, m_nCenterJ - j, m_nCenterK + k, c_element); c_space_hash.UpdateCell(m_nCenterI, m_nCenterJ - j, m_nCenterK - k, c_element); } else { /* * i == 0 * j > 0 * k == 0 */ c_space_hash.UpdateCell(m_nCenterI, m_nCenterJ + j, m_nCenterK, c_element); c_space_hash.UpdateCell(m_nCenterI, m_nCenterJ - j, m_nCenterK, c_element); } } else { /* * i == 0 * j == 0 */ if(k > 0) { /* * i == 0 * j == 0 * k > 0 */ c_space_hash.UpdateCell(m_nCenterI, m_nCenterJ, m_nCenterK + k, c_element); c_space_hash.UpdateCell(m_nCenterI, m_nCenterJ, m_nCenterK - k, c_element); } else { /* * i == 0 * j == 0 * k == 0 */ c_space_hash.UpdateCell(m_nCenterI, m_nCenterJ, m_nCenterK, c_element); } } } } } } }