diff --git a/Aquaria/Game.cpp b/Aquaria/Game.cpp index 0222b63..814287a 100644 --- a/Aquaria/Game.cpp +++ b/Aquaria/Game.cpp @@ -2663,7 +2663,7 @@ void Game::applyState() { l = &dsq->renderObjectLayers[i]; l->followCamera = 0; - l->followCameraLock = 0; + l->followCameraLock = FCL_NONE; } dsq->resetLayerPasses(); diff --git a/BBGE/Core.h b/BBGE/Core.h index 599b853..132db12 100644 --- a/BBGE/Core.h +++ b/BBGE/Core.h @@ -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; diff --git a/BBGE/RenderObject.cpp b/BBGE/RenderObject.cpp index 89a0b97..5ceb0ac 100644 --- a/BBGE/RenderObject.cpp +++ b/BBGE/RenderObject.cpp @@ -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); diff --git a/BBGE/RenderObject.h b/BBGE/RenderObject.h index 17a2da4..69d3933 100644 --- a/BBGE/RenderObject.h +++ b/BBGE/RenderObject.h @@ -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; 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 RenderObjectList; RenderObjectList deathNotifications; diff --git a/BBGE/RenderObjectLayer.cpp b/BBGE/RenderObjectLayer.cpp index 7634f77..317aee5 100644 --- a/BBGE/RenderObjectLayer.cpp +++ b/BBGE/RenderObjectLayer.cpp @@ -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; diff --git a/BBGE/RenderObject_inline.h b/BBGE/RenderObject_inline.h index 8d76d3f..e37cbf0 100644 --- a/BBGE/RenderObject_inline.h +++ b/BBGE/RenderObject_inline.h @@ -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) {