1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-25 09:44:02 +00:00

Remove RenderObjectLayer::sort() and related

This commit is contained in:
fgenesis 2016-05-14 17:20:13 +02:00
parent c4b0decc10
commit 9bb4226626
6 changed files with 0 additions and 122 deletions

View file

@ -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);

View file

@ -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()

View file

@ -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<float> avgFPS;
float sortTimer;
bool sortFlag;
virtual void modifyDt(float &dt){}
void setPixelScale(int pixelScaleX, int pixelScaleY);

View file

@ -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)

View file

@ -163,8 +163,6 @@ public:
Vector getRealPosition();
Vector getRealScale();
virtual float getSortDepth();
StateData *getStateData();
void setPositionSnapTo(InterpolatedVector *positionSnapTo);

View file

@ -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<float> 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();