mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 21:10:04 +00:00
Fix x/y pixel offsets of placefile icons
This commit is contained in:
parent
eaf5089526
commit
e66c202edf
2 changed files with 18 additions and 15 deletions
|
|
@ -37,6 +37,6 @@ void main()
|
||||||
vec2 p = latLngToScreenCoordinate(aLatLong) - uMapScreenCoord;
|
vec2 p = latLngToScreenCoordinate(aLatLong) - uMapScreenCoord;
|
||||||
|
|
||||||
// Transform the position to screen coordinates
|
// Transform the position to screen coordinates
|
||||||
gl_Position = uMapMatrix * vec4(p, 0.0f, 1.0f) -
|
gl_Position = uMapMatrix * vec4(p, 0.0f, 1.0f) +
|
||||||
uMVPMatrix * vec4(aXYOffset, 0.0f, 0.0f);
|
uMVPMatrix * vec4(aXYOffset, 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -311,16 +311,19 @@ void PlacefileIcons::Impl::Update()
|
||||||
const float x = static_cast<float>(di->x_);
|
const float x = static_cast<float>(di->x_);
|
||||||
const float y = static_cast<float>(di->y_);
|
const float y = static_cast<float>(di->y_);
|
||||||
|
|
||||||
// Half icon size
|
// Icon size
|
||||||
const float hw = static_cast<float>(icon.iconFile_->iconWidth_) * 0.5f;
|
const float iw = static_cast<float>(icon.iconFile_->iconWidth_);
|
||||||
const float hh =
|
const float ih = static_cast<float>(icon.iconFile_->iconHeight_);
|
||||||
static_cast<float>(icon.iconFile_->iconHeight_) * 0.5f;
|
|
||||||
|
// Hot X/Y (zero-based icon center)
|
||||||
|
const float hx = static_cast<float>(icon.iconFile_->hotX_);
|
||||||
|
const float hy = static_cast<float>(icon.iconFile_->hotY_);
|
||||||
|
|
||||||
// Final X/Y offsets in pixels
|
// Final X/Y offsets in pixels
|
||||||
const float lx = std::roundf(x - hw);
|
const float lx = std::roundf(x - hx);
|
||||||
const float rx = std::roundf(x + hw);
|
const float rx = std::roundf(lx + iw);
|
||||||
const float by = std::roundf(y - hh);
|
const float ty = std::roundf(y + hy);
|
||||||
const float ty = std::roundf(y + hh);
|
const float by = std::roundf(ty - ih);
|
||||||
|
|
||||||
// Angle in degrees
|
// Angle in degrees
|
||||||
// TODO: Properly convert
|
// TODO: Properly convert
|
||||||
|
|
@ -347,12 +350,12 @@ void PlacefileIcons::Impl::Update()
|
||||||
buffer.insert(buffer.end(),
|
buffer.insert(buffer.end(),
|
||||||
{
|
{
|
||||||
// Icon
|
// Icon
|
||||||
lat, lon, lx, by, rs, tt, mc0, mc1, mc2, mc3, a, // BL
|
lat, lon, lx, by, ls, bt, mc0, mc1, mc2, mc3, a, // BL
|
||||||
lat, lon, lx, ty, rs, bt, mc0, mc1, mc2, mc3, a, // TL
|
lat, lon, lx, ty, ls, tt, mc0, mc1, mc2, mc3, a, // TL
|
||||||
lat, lon, rx, by, ls, tt, mc0, mc1, mc2, mc3, a, // BR
|
lat, lon, rx, by, rs, bt, mc0, mc1, mc2, mc3, a, // BR
|
||||||
lat, lon, rx, by, ls, tt, mc0, mc1, mc2, mc3, a, // BR
|
lat, lon, rx, by, rs, bt, mc0, mc1, mc2, mc3, a, // BR
|
||||||
lat, lon, rx, ty, ls, bt, mc0, mc1, mc2, mc3, a, // TR
|
lat, lon, rx, ty, rs, tt, mc0, mc1, mc2, mc3, a, // TR
|
||||||
lat, lon, lx, ty, rs, bt, mc0, mc1, mc2, mc3, a // TL
|
lat, lon, lx, ty, ls, tt, mc0, mc1, mc2, mc3, a // TL
|
||||||
});
|
});
|
||||||
|
|
||||||
numVertices_ += 6;
|
numVertices_ += 6;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue