From 9bb4226626ad7f54d11cc9ad2f012a9c5eee8dc6 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Sat, 14 May 2016 17:20:13 +0200 Subject: [PATCH] Remove RenderObjectLayer::sort() and related --- Aquaria/DSQ.cpp | 2 -- BBGE/Core.cpp | 41 ----------------------- BBGE/Core.h | 4 --- BBGE/RenderObject.cpp | 5 --- BBGE/RenderObject.h | 2 -- BBGE/RenderObjectLayer.cpp | 68 -------------------------------------- 6 files changed, 122 deletions(-) diff --git a/Aquaria/DSQ.cpp b/Aquaria/DSQ.cpp index 6199d93..7841bf6 100644 --- a/Aquaria/DSQ.cpp +++ b/Aquaria/DSQ.cpp @@ -216,8 +216,6 @@ DSQ::DSQ(const std::string& fileSystem, const std::string& extraDataDir) entities.resize(64, 0); - - sortEnabled = false; shakeCameraTimer = shakeCameraMag = 0; avgFPS.resize(dsq->user.video.fpsSmoothing); diff --git a/BBGE/Core.cpp b/BBGE/Core.cpp index d312772..a482e69 100644 --- a/BBGE/Core.cpp +++ b/BBGE/Core.cpp @@ -324,7 +324,6 @@ static bool checkWritable(const std::string& path, bool warn, bool critical) #endif -const float SORT_DELAY = 10; Core::Core(const std::string &filesystem, const std::string& extraDataDir, int numRenderLayers, const std::string &appName, int particleSize, std::string userDataSubFolder) : ActionMapper(), StateManager(), appName(appName) { @@ -449,8 +448,6 @@ Core::Core(const std::string &filesystem, const std::string& extraDataDir, int n renderObjectCount = 0; avgFPS.resize(1); minimized = false; - sortFlag = true; - sortTimer = SORT_DELAY; numSavedScreenshots = 0; shuttingDown = false; clearedGarbageFlag = false; @@ -875,19 +872,6 @@ void Core::onUpdate(float dt) { afterEffectManager->update(dt); } - - if (!sortFlag) - { - if (sortTimer>0) - { - sortTimer -= dt; - if (sortTimer <= 0) - { - sortTimer = SORT_DELAY; - sort(); - } - } - } } void Core::globalScaleChanged() @@ -1854,31 +1838,6 @@ void Core::main(float runTime) clearGarbage(); nestedMains--; if (verbose) debugLog("exit Core::main"); -} - -// less than through pointer -bool RenderObject_lt(RenderObject* x, RenderObject* y) -{ - return x->getSortDepth() < y->getSortDepth(); -} - -// greater than through pointer -bool RenderObject_gt(RenderObject* x, RenderObject* y) -{ - return x->getSortDepth() > y->getSortDepth(); -} - -void Core::sortLayer(int layer) -{ - if (layer >= 0 && layer < renderObjectLayers.size()) - renderObjectLayers[layer].sort(); -} - -void Core::sort() -{ - - - } void Core::clearBuffers() diff --git a/BBGE/Core.h b/BBGE/Core.h index 8f99f44..4212a71 100644 --- a/BBGE/Core.h +++ b/BBGE/Core.h @@ -504,8 +504,6 @@ public: Vector screenCenter; - void sort(); - void sortLayer(int layer); void print(int x, int y, const char *str, float sz=1); @@ -765,8 +763,6 @@ protected: bool sortEnabled; Vector cameraOffset; std::vector avgFPS; - float sortTimer; - bool sortFlag; virtual void modifyDt(float &dt){} void setPixelScale(int pixelScaleX, int pixelScaleY); diff --git a/BBGE/RenderObject.cpp b/BBGE/RenderObject.cpp index 7361adc..2a24991 100644 --- a/BBGE/RenderObject.cpp +++ b/BBGE/RenderObject.cpp @@ -1137,11 +1137,6 @@ bool RenderObject::setTexture(const std::string &n) return tex && tex->getLoadResult() == TEX_SUCCESS; } -float RenderObject::getSortDepth() -{ - return position.y; -} - void RenderObject::addChild(RenderObject *r, ParentManaged pm, RenderBeforeParent rbp, ChildOrder order) { if (r->parent) diff --git a/BBGE/RenderObject.h b/BBGE/RenderObject.h index 104fa82..edcebfc 100644 --- a/BBGE/RenderObject.h +++ b/BBGE/RenderObject.h @@ -163,8 +163,6 @@ public: Vector getRealPosition(); Vector getRealScale(); - virtual float getSortDepth(); - StateData *getStateData(); void setPositionSnapTo(InterpolatedVector *positionSnapTo); diff --git a/BBGE/RenderObjectLayer.cpp b/BBGE/RenderObjectLayer.cpp index 5faf03c..2e1df3b 100644 --- a/BBGE/RenderObjectLayer.cpp +++ b/BBGE/RenderObjectLayer.cpp @@ -62,74 +62,6 @@ void RenderObjectLayer::setOptimizeStatic(bool opt) clearDisplayList(); } - -void RenderObjectLayer::sort() -{ - if (optimizeStatic && displayListValid) - return; // Assume the order hasn't changed - - // Compress the list before sorting to boost speed. - const int size = renderObjects.size(); - int from, to; - for (to = 0; to < size; to++) { - if (!renderObjects[to]) - break; - } - for (from = to+1; from < size; from++) { - if (renderObjects[from]) - { - renderObjects[to] = renderObjects[from]; - renderObjects[to]->setIdx(to); - to++; - } - } - if (to < size) - renderObjects[to] = 0; - if (to != objectCount) - { - std::ostringstream os; - os << "Objects lost in sort! (" << to << " != " << objectCount << ")"; - errorLog(os.str()); - objectCount = to; - } - const int count = objectCount; - - // Save a copy of all objects' depths so we don't have to call - // getSortDepth() in a greater-order loop. - std::vector sortDepths(count); - for (int i = 0; i < count; i++) - { - sortDepths[i] = renderObjects[i]->getSortDepth(); - } - - // FIXME: Just a simple selection sort for now. Is this fast enough? - // Might need to use quicksort instead. - for (int i = 0; i < count-1; i++) - { - int best = i; - float bestDepth = sortDepths[i]; - for (int j = i+1; j < count; j++) - { - if (sortDepths[j] < bestDepth) - { - best = j; - bestDepth = sortDepths[j]; - } - } - if (best != i) - { - RenderObject *r = renderObjects[i]; - renderObjects[i] = renderObjects[best]; - renderObjects[i]->setIdx(i); - renderObjects[best] = r; - renderObjects[best]->setIdx(best); - float d = sortDepths[i]; - sortDepths[i] = sortDepths[best]; - sortDepths[best] = d; - } - } -} - void RenderObjectLayer::add(RenderObject* r) { int size = renderObjects.size();