mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-01-24 17:26:41 +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->followCamera = 0;
|
||||
l->followCameraLock = 0;
|
||||
l->followCameraLock = FCL_NONE;
|
||||
}
|
||||
|
||||
dsq->resetLayerPasses();
|
||||
|
|
|
@ -59,8 +59,6 @@ enum CoreLayers
|
|||
LR_NONE = -1
|
||||
};
|
||||
|
||||
const int NO_FOLLOW_CAMERA = -999;
|
||||
|
||||
class AfterEffectManager;
|
||||
|
||||
class Texture;
|
||||
|
@ -167,7 +165,7 @@ public:
|
|||
bool visible;
|
||||
float followCamera;
|
||||
|
||||
int followCameraLock;
|
||||
int followCameraLock; // TODO: replace this with x/y scroll factor
|
||||
|
||||
bool update;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -83,11 +83,6 @@ struct MotionBlurData
|
|||
|
||||
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
|
||||
{
|
||||
public:
|
||||
|
@ -262,7 +257,11 @@ public:
|
|||
CountedPtr<Texture> texture;
|
||||
|
||||
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 updateCull;
|
||||
int layer;
|
||||
|
@ -303,6 +302,7 @@ protected:
|
|||
|
||||
inline void renderCall(const RenderState& rs, const Vector& renderAt, float renderRotation) const;
|
||||
virtual void renderCollision(const RenderState& rs) const;
|
||||
void debugRenderPaths() const;
|
||||
|
||||
typedef std::list<RenderObject*> RenderObjectList;
|
||||
RenderObjectList deathNotifications;
|
||||
|
|
|
@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
RenderObjectLayer::RenderObjectLayer()
|
||||
: renderObjects(BASE_ARRAY_SIZE)
|
||||
{
|
||||
followCamera = NO_FOLLOW_CAMERA;
|
||||
followCamera = 0;
|
||||
visible = true;
|
||||
startPass = endPass = 0;
|
||||
followCameraLock = FCL_NONE;
|
||||
|
|
|
@ -34,9 +34,16 @@ inline bool RenderObject::isOnScreen() const
|
|||
|
||||
Vector RenderObject::getFollowCameraPosition() const
|
||||
{
|
||||
assert(!parent); // this makes no sense when we're not a root object
|
||||
float f = followCamera;
|
||||
if (f == 0 && layer != -1)
|
||||
f = core->renderObjectLayers[layer].followCamera;
|
||||
int fcl = 0;
|
||||
if (layer != LR_NONE)
|
||||
{
|
||||
const RenderObjectLayer &rl = core->renderObjectLayers[layer];
|
||||
if(!f)
|
||||
f = rl.followCamera;
|
||||
fcl = rl.followCameraLock;
|
||||
}
|
||||
|
||||
if (f <= 0)
|
||||
{
|
||||
|
@ -45,9 +52,6 @@ Vector RenderObject::getFollowCameraPosition() const
|
|||
else
|
||||
{
|
||||
Vector pos = position;
|
||||
int fcl = 0;
|
||||
if (layer != -1)
|
||||
fcl = core->renderObjectLayers[layer].followCameraLock;
|
||||
|
||||
switch (fcl)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue