Fix pipe mirroring (fixes #750 again)
This commit is contained in:
parent
0fcad65d6f
commit
7ab720d847
@ -412,9 +412,10 @@ void GameSave::Transform(matrix2d transform, vector2d translate, vector2d transl
|
||||
velocityYNew = Allocate2DArray<float>(newBlockWidth, newBlockHeight, 0.0f);
|
||||
ambientHeatNew = Allocate2DArray<float>(newBlockWidth, newBlockHeight, 0.0f);
|
||||
|
||||
|
||||
// * Patch pipes if the transform is (looks close enough to) a 90-degree counter-clockwise rotation.
|
||||
bool patchPipe90 = fabsf(transform.a * transform.d - transform.b * transform.c - 1) < 1e-3 && fabs(atan2f(transform.b, transform.a) - (0.5f * M_PI)) < 1e-3;
|
||||
// Match these up with the matrices provided in GameView::OnKeyPress.
|
||||
bool patchPipeR = transform.a == 0 && transform.b == 1 && transform.c == -1 && transform.d == 0;
|
||||
bool patchPipeH = transform.a == -1 && transform.b == 0 && transform.c == 0 && transform.d == 1;
|
||||
bool patchPipeV = transform.a == 1 && transform.b == 0 && transform.c == 0 && transform.d == -1;
|
||||
|
||||
// rotate and translate signs, parts, walls
|
||||
for (size_t i = 0; i < signs.size(); i++)
|
||||
@ -449,10 +450,23 @@ void GameSave::Transform(matrix2d transform, vector2d translate, vector2d transl
|
||||
vel = m2d_multiply_v2d(transform, vel);
|
||||
particles[i].vx = vel.x;
|
||||
particles[i].vy = vel.y;
|
||||
if (patchPipe90 && (particles[i].type == PT_PIPE || particles[i].type == PT_PPIP))
|
||||
if (particles[i].type == PT_PIPE || particles[i].type == PT_PPIP)
|
||||
{
|
||||
void Element_PIPE_patch90(Particle &part);
|
||||
Element_PIPE_patch90(particles[i]);
|
||||
if (patchPipeR)
|
||||
{
|
||||
void Element_PIPE_patchR(Particle &part);
|
||||
Element_PIPE_patchR(particles[i]);
|
||||
}
|
||||
if (patchPipeH)
|
||||
{
|
||||
void Element_PIPE_patchH(Particle &part);
|
||||
Element_PIPE_patchH(particles[i]);
|
||||
}
|
||||
if (patchPipeV)
|
||||
{
|
||||
void Element_PIPE_patchV(Particle &part);
|
||||
Element_PIPE_patchV(particles[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,15 +83,38 @@ constexpr int PPIP_TMPFLAG_TRIGGERS = 0x1C000000;
|
||||
|
||||
signed char pos_1_rx[] = { -1,-1,-1, 0, 0, 1, 1, 1 };
|
||||
signed char pos_1_ry[] = { -1, 0, 1,-1, 1,-1, 0, 1 };
|
||||
int pos_1_patch90[] = { 2, 4, 7, 1, 6, 0, 3, 5 };
|
||||
|
||||
void Element_PIPE_patch90(Particle &part)
|
||||
static void transformPatch(Particle &part, const int (&patch)[8])
|
||||
{
|
||||
auto oldDirForward = (part.tmp & 0x00001C00) >> 10;
|
||||
auto newDirForward = pos_1_patch90[oldDirForward];
|
||||
auto oldDirReverse = (part.tmp & 0x0001C000) >> 14;
|
||||
auto newDirReverse = pos_1_patch90[oldDirReverse];
|
||||
part.tmp = (part.tmp & 0xFFFE23FF) | (newDirForward << 10) | (newDirReverse << 14);
|
||||
if (part.tmp & 0x00000200) part.tmp = (part.tmp & 0xFFFFE3FF) | (patch[(part.tmp & 0x00001C00) >> 10] << 10);
|
||||
if (part.tmp & 0x00002000) part.tmp = (part.tmp & 0xFFFE3FFF) | (patch[(part.tmp & 0x0001C000) >> 14] << 14);
|
||||
}
|
||||
|
||||
void Element_PIPE_patchR(Particle &part)
|
||||
{
|
||||
// 035 -> 210
|
||||
// 1 6 -> 4 3
|
||||
// 247 -> 765
|
||||
const int patchR[] = { 2, 4, 7, 1, 6, 0, 3, 5 };
|
||||
transformPatch(part, patchR);
|
||||
}
|
||||
|
||||
void Element_PIPE_patchH(Particle &part)
|
||||
{
|
||||
// 035 -> 530
|
||||
// 1 6 -> 6 1
|
||||
// 247 -> 742
|
||||
const int patchH[] = { 5, 6, 7, 3, 4, 0, 1, 2 };
|
||||
transformPatch(part, patchH);
|
||||
}
|
||||
|
||||
void Element_PIPE_patchV(Particle &part)
|
||||
{
|
||||
// 035 -> 247
|
||||
// 1 6 -> 1 6
|
||||
// 247 -> 035
|
||||
const int patchV[] = { 2, 1, 0, 4, 3, 7, 6, 5 };
|
||||
transformPatch(part, patchV);
|
||||
}
|
||||
|
||||
static unsigned int prevColor(unsigned int flags)
|
||||
|
Loading…
Reference in New Issue
Block a user