mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-07-06 07:56:45 +00:00
Remove RenderObjectLayer::sort() and related
This commit is contained in:
parent
c4b0decc10
commit
9bb4226626
6 changed files with 0 additions and 122 deletions
|
@ -216,8 +216,6 @@ DSQ::DSQ(const std::string& fileSystem, const std::string& extraDataDir)
|
||||||
|
|
||||||
entities.resize(64, 0);
|
entities.resize(64, 0);
|
||||||
|
|
||||||
|
|
||||||
sortEnabled = false;
|
|
||||||
shakeCameraTimer = shakeCameraMag = 0;
|
shakeCameraTimer = shakeCameraMag = 0;
|
||||||
avgFPS.resize(dsq->user.video.fpsSmoothing);
|
avgFPS.resize(dsq->user.video.fpsSmoothing);
|
||||||
|
|
||||||
|
|
|
@ -324,7 +324,6 @@ static bool checkWritable(const std::string& path, bool warn, bool critical)
|
||||||
#endif
|
#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)
|
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)
|
: ActionMapper(), StateManager(), appName(appName)
|
||||||
{
|
{
|
||||||
|
@ -449,8 +448,6 @@ Core::Core(const std::string &filesystem, const std::string& extraDataDir, int n
|
||||||
renderObjectCount = 0;
|
renderObjectCount = 0;
|
||||||
avgFPS.resize(1);
|
avgFPS.resize(1);
|
||||||
minimized = false;
|
minimized = false;
|
||||||
sortFlag = true;
|
|
||||||
sortTimer = SORT_DELAY;
|
|
||||||
numSavedScreenshots = 0;
|
numSavedScreenshots = 0;
|
||||||
shuttingDown = false;
|
shuttingDown = false;
|
||||||
clearedGarbageFlag = false;
|
clearedGarbageFlag = false;
|
||||||
|
@ -875,19 +872,6 @@ void Core::onUpdate(float dt)
|
||||||
{
|
{
|
||||||
afterEffectManager->update(dt);
|
afterEffectManager->update(dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sortFlag)
|
|
||||||
{
|
|
||||||
if (sortTimer>0)
|
|
||||||
{
|
|
||||||
sortTimer -= dt;
|
|
||||||
if (sortTimer <= 0)
|
|
||||||
{
|
|
||||||
sortTimer = SORT_DELAY;
|
|
||||||
sort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::globalScaleChanged()
|
void Core::globalScaleChanged()
|
||||||
|
@ -1854,31 +1838,6 @@ void Core::main(float runTime)
|
||||||
clearGarbage();
|
clearGarbage();
|
||||||
nestedMains--;
|
nestedMains--;
|
||||||
if (verbose) debugLog("exit Core::main");
|
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()
|
void Core::clearBuffers()
|
||||||
|
|
|
@ -504,8 +504,6 @@ public:
|
||||||
|
|
||||||
|
|
||||||
Vector screenCenter;
|
Vector screenCenter;
|
||||||
void sort();
|
|
||||||
void sortLayer(int layer);
|
|
||||||
|
|
||||||
void print(int x, int y, const char *str, float sz=1);
|
void print(int x, int y, const char *str, float sz=1);
|
||||||
|
|
||||||
|
@ -765,8 +763,6 @@ protected:
|
||||||
bool sortEnabled;
|
bool sortEnabled;
|
||||||
Vector cameraOffset;
|
Vector cameraOffset;
|
||||||
std::vector<float> avgFPS;
|
std::vector<float> avgFPS;
|
||||||
float sortTimer;
|
|
||||||
bool sortFlag;
|
|
||||||
virtual void modifyDt(float &dt){}
|
virtual void modifyDt(float &dt){}
|
||||||
void setPixelScale(int pixelScaleX, int pixelScaleY);
|
void setPixelScale(int pixelScaleX, int pixelScaleY);
|
||||||
|
|
||||||
|
|
|
@ -1137,11 +1137,6 @@ bool RenderObject::setTexture(const std::string &n)
|
||||||
return tex && tex->getLoadResult() == TEX_SUCCESS;
|
return tex && tex->getLoadResult() == TEX_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
float RenderObject::getSortDepth()
|
|
||||||
{
|
|
||||||
return position.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderObject::addChild(RenderObject *r, ParentManaged pm, RenderBeforeParent rbp, ChildOrder order)
|
void RenderObject::addChild(RenderObject *r, ParentManaged pm, RenderBeforeParent rbp, ChildOrder order)
|
||||||
{
|
{
|
||||||
if (r->parent)
|
if (r->parent)
|
||||||
|
|
|
@ -163,8 +163,6 @@ public:
|
||||||
Vector getRealPosition();
|
Vector getRealPosition();
|
||||||
Vector getRealScale();
|
Vector getRealScale();
|
||||||
|
|
||||||
virtual float getSortDepth();
|
|
||||||
|
|
||||||
StateData *getStateData();
|
StateData *getStateData();
|
||||||
|
|
||||||
void setPositionSnapTo(InterpolatedVector *positionSnapTo);
|
void setPositionSnapTo(InterpolatedVector *positionSnapTo);
|
||||||
|
|
|
@ -62,74 +62,6 @@ void RenderObjectLayer::setOptimizeStatic(bool opt)
|
||||||
clearDisplayList();
|
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)
|
void RenderObjectLayer::add(RenderObject* r)
|
||||||
{
|
{
|
||||||
int size = renderObjects.size();
|
int size = renderObjects.size();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue