mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-02-04 02:24:00 +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:
parent
76ba2b1211
commit
28766f0d5a
6 changed files with 60 additions and 54 deletions
|
@ -2663,7 +2663,7 @@ void Game::applyState()
|
||||||
{
|
{
|
||||||
l = &dsq->renderObjectLayers[i];
|
l = &dsq->renderObjectLayers[i];
|
||||||
l->followCamera = 0;
|
l->followCamera = 0;
|
||||||
l->followCameraLock = 0;
|
l->followCameraLock = FCL_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
dsq->resetLayerPasses();
|
dsq->resetLayerPasses();
|
||||||
|
|
|
@ -59,8 +59,6 @@ enum CoreLayers
|
||||||
LR_NONE = -1
|
LR_NONE = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
const int NO_FOLLOW_CAMERA = -999;
|
|
||||||
|
|
||||||
class AfterEffectManager;
|
class AfterEffectManager;
|
||||||
|
|
||||||
class Texture;
|
class Texture;
|
||||||
|
@ -167,7 +165,7 @@ public:
|
||||||
bool visible;
|
bool visible;
|
||||||
float followCamera;
|
float followCamera;
|
||||||
|
|
||||||
int followCameraLock;
|
int followCameraLock; // TODO: replace this with x/y scroll factor
|
||||||
|
|
||||||
bool update;
|
bool update;
|
||||||
|
|
||||||
|
|
|
@ -484,14 +484,11 @@ void RenderObject::renderCall(const RenderState& rs, const Vector& renderAt, flo
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
|
float followCamera = this->followCamera;
|
||||||
if (layer != LR_NONE)
|
if (layer != LR_NONE && !followCamera)
|
||||||
{
|
{
|
||||||
RenderObjectLayer *l = &core->renderObjectLayers[layer];
|
const RenderObjectLayer& rl = core->renderObjectLayers[layer];
|
||||||
if (l->followCamera != NO_FOLLOW_CAMERA)
|
followCamera = rl.followCamera;
|
||||||
{
|
|
||||||
followCamera = l->followCamera;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (followCamera!=0 && !parent)
|
if (followCamera!=0 && !parent)
|
||||||
{
|
{
|
||||||
|
@ -521,39 +518,10 @@ void RenderObject::renderCall(const RenderState& rs, const Vector& renderAt, flo
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
glTranslatef(renderPos.x, renderPos.y, renderPos.z);
|
glTranslatef(renderPos.x, renderPos.y, renderPos.z);
|
||||||
|
|
||||||
// TODO: move this to debug render
|
if (RenderObject::renderPaths) // TODO: move this to debug render
|
||||||
if (RenderObject::renderPaths && position.data)
|
debugRenderPaths();
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is the correct way to rotate things.
|
// This is the correct way to rotate things.
|
||||||
glRotatef(renderRotation, 0, 0, 1);
|
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)
|
void RenderObject::addDeathNotify(RenderObject *r)
|
||||||
{
|
{
|
||||||
deathNotifications.remove(r);
|
deathNotifications.remove(r);
|
||||||
|
|
|
@ -83,11 +83,6 @@ struct MotionBlurData
|
||||||
|
|
||||||
class RenderObjectLayer;
|
class RenderObjectLayer;
|
||||||
|
|
||||||
// FIXME: -- fg
|
|
||||||
// I've scattered a few mutables across this class
|
|
||||||
// These should be part of some struct that gets passed along the render() calls
|
|
||||||
// instead of updating the actual class members
|
|
||||||
|
|
||||||
class RenderObject : public ScriptObject
|
class RenderObject : public ScriptObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -262,7 +257,11 @@ public:
|
||||||
CountedPtr<Texture> texture;
|
CountedPtr<Texture> texture;
|
||||||
|
|
||||||
float life;
|
float life;
|
||||||
mutable float followCamera;
|
|
||||||
|
// if 0: use value from RenderLayer.
|
||||||
|
// UI elements have this == 1, ie. are totally unaffacted by camera movement.
|
||||||
|
float followCamera;
|
||||||
|
|
||||||
float alphaMod;
|
float alphaMod;
|
||||||
float updateCull;
|
float updateCull;
|
||||||
int layer;
|
int layer;
|
||||||
|
@ -303,6 +302,7 @@ protected:
|
||||||
|
|
||||||
inline void renderCall(const RenderState& rs, const Vector& renderAt, float renderRotation) const;
|
inline void renderCall(const RenderState& rs, const Vector& renderAt, float renderRotation) const;
|
||||||
virtual void renderCollision(const RenderState& rs) const;
|
virtual void renderCollision(const RenderState& rs) const;
|
||||||
|
void debugRenderPaths() const;
|
||||||
|
|
||||||
typedef std::list<RenderObject*> RenderObjectList;
|
typedef std::list<RenderObject*> RenderObjectList;
|
||||||
RenderObjectList deathNotifications;
|
RenderObjectList deathNotifications;
|
||||||
|
|
|
@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
RenderObjectLayer::RenderObjectLayer()
|
RenderObjectLayer::RenderObjectLayer()
|
||||||
: renderObjects(BASE_ARRAY_SIZE)
|
: renderObjects(BASE_ARRAY_SIZE)
|
||||||
{
|
{
|
||||||
followCamera = NO_FOLLOW_CAMERA;
|
followCamera = 0;
|
||||||
visible = true;
|
visible = true;
|
||||||
startPass = endPass = 0;
|
startPass = endPass = 0;
|
||||||
followCameraLock = FCL_NONE;
|
followCameraLock = FCL_NONE;
|
||||||
|
|
|
@ -34,9 +34,16 @@ inline bool RenderObject::isOnScreen() const
|
||||||
|
|
||||||
Vector RenderObject::getFollowCameraPosition() const
|
Vector RenderObject::getFollowCameraPosition() const
|
||||||
{
|
{
|
||||||
|
assert(!parent); // this makes no sense when we're not a root object
|
||||||
float f = followCamera;
|
float f = followCamera;
|
||||||
if (f == 0 && layer != -1)
|
int fcl = 0;
|
||||||
f = core->renderObjectLayers[layer].followCamera;
|
if (layer != LR_NONE)
|
||||||
|
{
|
||||||
|
const RenderObjectLayer &rl = core->renderObjectLayers[layer];
|
||||||
|
if(!f)
|
||||||
|
f = rl.followCamera;
|
||||||
|
fcl = rl.followCameraLock;
|
||||||
|
}
|
||||||
|
|
||||||
if (f <= 0)
|
if (f <= 0)
|
||||||
{
|
{
|
||||||
|
@ -45,9 +52,6 @@ Vector RenderObject::getFollowCameraPosition() const
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Vector pos = position;
|
Vector pos = position;
|
||||||
int fcl = 0;
|
|
||||||
if (layer != -1)
|
|
||||||
fcl = core->renderObjectLayers[layer].followCameraLock;
|
|
||||||
|
|
||||||
switch (fcl)
|
switch (fcl)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue