1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-07-17 05:15:29 +00:00

make RenderObject::followCamera not modified during rendering

This takes out the last of the RenderObject mutables.

This also fixes the long-standing editor bug that map tiles
that are once moved to parallax layers and then back to a
normal layer keep their scroll factor until the tile is deleted
or the map saved and reloaded.
This commit is contained in:
fgenesis 2023-03-02 03:41:00 +01:00
parent 76ba2b1211
commit 28766f0d5a
6 changed files with 60 additions and 54 deletions

View file

@ -484,14 +484,11 @@ void RenderObject::renderCall(const RenderState& rs, const Vector& renderAt, flo
glPushMatrix();
if (layer != LR_NONE)
float followCamera = this->followCamera;
if (layer != LR_NONE && !followCamera)
{
RenderObjectLayer *l = &core->renderObjectLayers[layer];
if (l->followCamera != NO_FOLLOW_CAMERA)
{
followCamera = l->followCamera;
}
const RenderObjectLayer& rl = core->renderObjectLayers[layer];
followCamera = rl.followCamera;
}
if (followCamera!=0 && !parent)
{
@ -521,39 +518,10 @@ void RenderObject::renderCall(const RenderState& rs, const Vector& renderAt, flo
}
else
{
glTranslatef(renderPos.x, renderPos.y, renderPos.z);
// TODO: move this to debug render
if (RenderObject::renderPaths && position.data)
if(size_t N = position.data->path.getNumPathNodes())
{
glLineWidth(4);
glEnable(GL_BLEND);
glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
glBindTexture(GL_TEXTURE_2D, 0);
glBegin(GL_LINES);
for (size_t i = 0; i < N-1; i++)
{
const VectorPathNode a = position.data->path[i];
const VectorPathNode b = position.data->path[i+1];
glVertex2f(a.value.x-position.x, a.value.y-position.y);
glVertex2f(b.value.x-position.x, b.value.y-position.y);
}
glEnd();
glPointSize(20);
glBegin(GL_POINTS);
glColor4f(0.5,0.5,1,1);
for (size_t i = 0; i < N; i++)
{
const VectorPathNode& a = position.data->path[i];
glVertex2f(a.value.x-position.x, a.value.y-position.y);
}
glEnd();
}
if (RenderObject::renderPaths) // TODO: move this to debug render
debugRenderPaths();
// This is the correct way to rotate things.
glRotatef(renderRotation, 0, 0, 1);
@ -624,6 +592,42 @@ void RenderObject::renderCollision(const RenderState& rs) const
{
}
void RenderObject::debugRenderPaths() const
{
if(!position.data)
return;
const size_t N = position.data->path.getNumPathNodes();
if(!N)
return;
glLineWidth(4);
glEnable(GL_BLEND);
glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
glBindTexture(GL_TEXTURE_2D, 0);
glBegin(GL_LINES);
for (size_t i = 0; i < N-1; i++)
{
const VectorPathNode a = position.data->path[i];
const VectorPathNode b = position.data->path[i+1];
glVertex2f(a.value.x-position.x, a.value.y-position.y);
glVertex2f(b.value.x-position.x, b.value.y-position.y);
}
glEnd();
glPointSize(20);
glBegin(GL_POINTS);
glColor4f(0.5,0.5,1,1);
for (size_t i = 0; i < N; i++)
{
const VectorPathNode& a = position.data->path[i];
glVertex2f(a.value.x-position.x, a.value.y-position.y);
}
glEnd();
}
void RenderObject::addDeathNotify(RenderObject *r)
{
deathNotifications.remove(r);