|
|
@@ -401,50 +401,30 @@ namespace bs
|
|
|
|
|
|
outputTexture->readData(*outputPixelData);
|
|
|
|
|
|
- Map<UINT32, UINT32> selectionScores;
|
|
|
- UINT32 maxWidth = std::min((UINT32)(position.x + area.x), outputPixelData->getWidth());
|
|
|
- UINT32 maxHeight = std::min((UINT32)(position.y + area.y), outputPixelData->getHeight());
|
|
|
|
|
|
- if (rtProps.requiresTextureFlipping)
|
|
|
- {
|
|
|
- UINT32 vertOffset = outputPixelData->getHeight();
|
|
|
+ Vector2I pickPosition = position;
|
|
|
+ if(rtProps.requiresTextureFlipping)
|
|
|
+ pickPosition.y = rtProps.height - (position.y + area.y);
|
|
|
|
|
|
- for (UINT32 y = maxHeight; y > (UINT32)position.y; y--)
|
|
|
- {
|
|
|
- for (UINT32 x = (UINT32)position.x; x < maxWidth; x++)
|
|
|
- {
|
|
|
- Color color = outputPixelData->getColorAt(x, vertOffset - y);
|
|
|
- UINT32 index = bs::ScenePicking::decodeIndex(color);
|
|
|
+ UINT32 maxWidth = std::min((UINT32)(pickPosition.x + area.x), outputPixelData->getWidth());
|
|
|
+ UINT32 maxHeight = std::min((UINT32)(pickPosition.y + area.y), outputPixelData->getHeight());
|
|
|
|
|
|
- if (index == 0x00FFFFFF) // Nothing selected
|
|
|
- continue;
|
|
|
-
|
|
|
- auto iterFind = selectionScores.find(index);
|
|
|
- if (iterFind == selectionScores.end())
|
|
|
- selectionScores[index] = 1;
|
|
|
- else
|
|
|
- iterFind->second++;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
+ Map<UINT32, UINT32> selectionScores;
|
|
|
+ for (UINT32 y = (UINT32)pickPosition.y; y < maxHeight; y++)
|
|
|
{
|
|
|
- for (UINT32 y = (UINT32)position.y; y < maxHeight; y++)
|
|
|
+ for (UINT32 x = (UINT32)pickPosition.x; x < maxWidth; x++)
|
|
|
{
|
|
|
- for (UINT32 x = (UINT32)position.x; x < maxWidth; x++)
|
|
|
- {
|
|
|
- Color color = outputPixelData->getColorAt(x, y);
|
|
|
- UINT32 index = bs::ScenePicking::decodeIndex(color);
|
|
|
+ Color color = outputPixelData->getColorAt(x, y);
|
|
|
+ UINT32 index = bs::ScenePicking::decodeIndex(color);
|
|
|
|
|
|
- if (index == 0x00FFFFFF) // Nothing selected
|
|
|
- continue;
|
|
|
+ if (index == 0x00FFFFFF) // Nothing selected
|
|
|
+ continue;
|
|
|
|
|
|
- auto iterFind = selectionScores.find(index);
|
|
|
- if (iterFind == selectionScores.end())
|
|
|
- selectionScores[index] = 1;
|
|
|
- else
|
|
|
- iterFind->second++;
|
|
|
- }
|
|
|
+ auto iterFind = selectionScores.find(index);
|
|
|
+ if (iterFind == selectionScores.end())
|
|
|
+ selectionScores[index] = 1;
|
|
|
+ else
|
|
|
+ iterFind->second++;
|
|
|
}
|
|
|
}
|
|
|
|