1549: Allow editing texture UV offsets in Quad properties r=def- a=bojidar-bg

Partial manual cherrypick of de82ad7a26.

Co-authored-by: Bojidar Marinov <bojidar.marinov.bg@gmail.com>
This commit is contained in:
bors[bot] 2019-03-29 13:11:18 +00:00
commit 5c919b6aab

View file

@ -838,6 +838,8 @@ int CEditor::PopupPoint(CEditor *pEditor, CUIRect View)
PROP_POS_X=0,
PROP_POS_Y,
PROP_COLOR,
PROP_TEX_U,
PROP_TEX_V,
NUM_PROPS,
};
@ -849,11 +851,15 @@ int CEditor::PopupPoint(CEditor *pEditor, CUIRect View)
int x = pCurrentQuad->m_aPoints[pEditor->m_SelectedQuadPoint].x/1000;
int y = pCurrentQuad->m_aPoints[pEditor->m_SelectedQuadPoint].y/1000;
int tu = pCurrentQuad->m_aTexcoords[pEditor->m_SelectedQuadPoint].x/1000 * 1024;
int tv = pCurrentQuad->m_aTexcoords[pEditor->m_SelectedQuadPoint].y/1000 * 1024;
CProperty aProps[] = {
{"Pos X", x, PROPTYPE_INT_SCROLL, -1000000, 1000000},
{"Pos Y", y, PROPTYPE_INT_SCROLL, -1000000, 1000000},
{"Color", Color, PROPTYPE_COLOR, -1, pEditor->m_Map.m_lEnvelopes.size()},
{"Tex U", tu, PROPTYPE_INT_SCROLL, -1000000, 1000000},
{"Tex V", tv, PROPTYPE_INT_SCROLL, -1000000, 1000000},
{0},
};
@ -865,6 +871,8 @@ int CEditor::PopupPoint(CEditor *pEditor, CUIRect View)
float OffsetX = NewVal*1000-x*1000;
float OffsetY = NewVal*1000-y*1000;
float OffsetU = NewVal*1000/1024-tu*1000/1024;
float OffsetV = NewVal*1000/1024-tv*1000/1024;
for(int i = 0; i < lQuads.size(); ++i)
{
@ -893,6 +901,18 @@ int CEditor::PopupPoint(CEditor *pEditor, CUIRect View)
}
}
}
if(Prop == PROP_TEX_U)
{
for(int v = 0; v < 4; v++)
if(pEditor->m_SelectedPoints&(1<<v))
lQuads[i]->m_aTexcoords[v].x += OffsetU;
}
if(Prop == PROP_TEX_V)
{
for(int v = 0; v < 4; v++)
if(pEditor->m_SelectedPoints&(1<<v))
lQuads[i]->m_aTexcoords[v].y += OffsetV;
}
}
return 0;