Fix for EXT-2892/DEV-43568 (if a face is set to show multiple texture repeats, only one of the repeats is interactive)
Added LLViewerMediaImpl::scaleTextureCoords() function to encapsulate the code that maps from texture coordinates to media coordinates. Made scaleTextureCoords() wrap the texture coordinate to the range [0.0, 1.0) before converting to media coordinates.master
parent
37e701dba9
commit
f4e40360e5
|
|
@ -1289,17 +1289,37 @@ void LLViewerMediaImpl::mouseMove(S32 x, S32 y, MASK mask)
|
|||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//static
|
||||
void LLViewerMediaImpl::scaleTextureCoords(const LLVector2& texture_coords, S32 *x, S32 *y)
|
||||
{
|
||||
F32 texture_x = texture_coords.mV[VX];
|
||||
F32 texture_y = texture_coords.mV[VY];
|
||||
|
||||
// Deal with repeating textures by wrapping the coordinates into the range [0, 1.0)
|
||||
texture_x = fmodf(texture_x, 1.0f);
|
||||
if(texture_x < 0.0f)
|
||||
texture_x = 1.0 + texture_x;
|
||||
|
||||
texture_y = fmodf(texture_y, 1.0f);
|
||||
if(texture_y < 0.0f)
|
||||
texture_y = 1.0 + texture_y;
|
||||
|
||||
// scale x and y to texel units.
|
||||
*x = llround(texture_x * mMediaSource->getTextureWidth());
|
||||
*y = llround((1.0f - texture_y) * mMediaSource->getTextureHeight());
|
||||
|
||||
// Adjust for the difference between the actual texture height and the amount of the texture in use.
|
||||
*y -= (mMediaSource->getTextureHeight() - mMediaSource->getHeight());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
void LLViewerMediaImpl::mouseDown(const LLVector2& texture_coords, MASK mask, S32 button)
|
||||
{
|
||||
if(mMediaSource)
|
||||
{
|
||||
// scale x and y to texel units.
|
||||
S32 x = llround(texture_coords.mV[VX] * mMediaSource->getTextureWidth());
|
||||
S32 y = llround((1.0f - texture_coords.mV[VY]) * mMediaSource->getTextureHeight());
|
||||
|
||||
// Adjust for the difference between the actual texture height and the amount of the texture in use.
|
||||
y -= (mMediaSource->getTextureHeight() - mMediaSource->getHeight());
|
||||
S32 x, y;
|
||||
scaleTextureCoords(texture_coords, &x, &y);
|
||||
|
||||
mouseDown(x, y, mask, button);
|
||||
}
|
||||
|
|
@ -1309,12 +1329,8 @@ void LLViewerMediaImpl::mouseUp(const LLVector2& texture_coords, MASK mask, S32
|
|||
{
|
||||
if(mMediaSource)
|
||||
{
|
||||
// scale x and y to texel units.
|
||||
S32 x = llround(texture_coords.mV[VX] * mMediaSource->getTextureWidth());
|
||||
S32 y = llround((1.0f - texture_coords.mV[VY]) * mMediaSource->getTextureHeight());
|
||||
|
||||
// Adjust for the difference between the actual texture height and the amount of the texture in use.
|
||||
y -= (mMediaSource->getTextureHeight() - mMediaSource->getHeight());
|
||||
S32 x, y;
|
||||
scaleTextureCoords(texture_coords, &x, &y);
|
||||
|
||||
mouseUp(x, y, mask, button);
|
||||
}
|
||||
|
|
@ -1324,12 +1340,8 @@ void LLViewerMediaImpl::mouseMove(const LLVector2& texture_coords, MASK mask)
|
|||
{
|
||||
if(mMediaSource)
|
||||
{
|
||||
// scale x and y to texel units.
|
||||
S32 x = llround(texture_coords.mV[VX] * mMediaSource->getTextureWidth());
|
||||
S32 y = llround((1.0f - texture_coords.mV[VY]) * mMediaSource->getTextureHeight());
|
||||
|
||||
// Adjust for the difference between the actual texture height and the amount of the texture in use.
|
||||
y -= (mMediaSource->getTextureHeight() - mMediaSource->getHeight());
|
||||
S32 x, y;
|
||||
scaleTextureCoords(texture_coords, &x, &y);
|
||||
|
||||
mouseMove(x, y, mask);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -185,6 +185,7 @@ public:
|
|||
void setHomeURL(const std::string& home_url) { mHomeURL = home_url; };
|
||||
std::string getMimeType() { return mMimeType; }
|
||||
void scaleMouse(S32 *mouse_x, S32 *mouse_y);
|
||||
void scaleTextureCoords(const LLVector2& texture_coords, S32 *x, S32 *y);
|
||||
|
||||
void update();
|
||||
void updateImagesMediaStreams();
|
||||
|
|
|
|||
Loading…
Reference in New Issue