mirror of
https://github.com/lubosz/overte.git
synced 2025-08-18 15:31:24 +02:00
Reorganize the sorting classes for maybe compiling on linux gcc 4.8 ?
This commit is contained in:
parent
eef8077417
commit
98160c8d60
1 changed files with 23 additions and 19 deletions
|
@ -200,6 +200,27 @@ void render::cullItems(const SceneContextPointer& sceneContext, const RenderCont
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ItemBound {
|
||||||
|
float _centerDepth = 0.0f;
|
||||||
|
float _nearDepth = 0.0f;
|
||||||
|
float _farDepth = 0.0f;
|
||||||
|
ItemID _id = 0;
|
||||||
|
|
||||||
|
ItemBound() {}
|
||||||
|
ItemBound(float centerDepth, float nearDepth, float farDepth, ItemID id) : _centerDepth(centerDepth), _nearDepth(nearDepth), _farDepth(farDepth), _id(id) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FrontToBackSort {
|
||||||
|
bool operator() (ItemBound& left, ItemBound& right) {
|
||||||
|
return (left._centerDepth < right._centerDepth);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BackToFrontSort {
|
||||||
|
bool operator() (ItemBound& left, ItemBound& right) {
|
||||||
|
return (left._centerDepth > right._centerDepth);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void render::depthSortItems(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, bool frontToBack, const ItemIDs& inItems, ItemIDs& outItems) {
|
void render::depthSortItems(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, bool frontToBack, const ItemIDs& inItems, ItemIDs& outItems) {
|
||||||
assert(renderContext->args);
|
assert(renderContext->args);
|
||||||
|
@ -213,15 +234,6 @@ void render::depthSortItems(const SceneContextPointer& sceneContext, const Rende
|
||||||
|
|
||||||
|
|
||||||
// Make a local dataset of the center distance and closest point distance
|
// Make a local dataset of the center distance and closest point distance
|
||||||
struct ItemBound {
|
|
||||||
float _centerDepth = 0.0f;
|
|
||||||
float _nearDepth = 0.0f;
|
|
||||||
float _farDepth = 0.0f;
|
|
||||||
ItemID _id = 0;
|
|
||||||
|
|
||||||
ItemBound() {}
|
|
||||||
ItemBound(float centerDepth, float nearDepth, float farDepth, ItemID id) : _centerDepth(centerDepth), _nearDepth(nearDepth), _farDepth(farDepth), _id(id) {}
|
|
||||||
};
|
|
||||||
std::vector<ItemBound> itemBounds;
|
std::vector<ItemBound> itemBounds;
|
||||||
itemBounds.reserve(outItems.size());
|
itemBounds.reserve(outItems.size());
|
||||||
|
|
||||||
|
@ -235,18 +247,10 @@ void render::depthSortItems(const SceneContextPointer& sceneContext, const Rende
|
||||||
|
|
||||||
// sort against Z
|
// sort against Z
|
||||||
if (frontToBack) {
|
if (frontToBack) {
|
||||||
struct FrontToBackSort {
|
FrontToBackSort frontToBackSort;
|
||||||
bool operator() (ItemBound& left, ItemBound& right) {
|
|
||||||
return (left._centerDepth < right._centerDepth);
|
|
||||||
}
|
|
||||||
} frontToBackSort;
|
|
||||||
std::sort (itemBounds.begin(), itemBounds.end(), frontToBackSort);
|
std::sort (itemBounds.begin(), itemBounds.end(), frontToBackSort);
|
||||||
} else {
|
} else {
|
||||||
struct BackToFrontSort {
|
BackToFrontSort backToFrontSort;
|
||||||
bool operator() (ItemBound& left, ItemBound& right) {
|
|
||||||
return (left._centerDepth > right._centerDepth);
|
|
||||||
}
|
|
||||||
} backToFrontSort;
|
|
||||||
std::sort (itemBounds.begin(), itemBounds.end(), backToFrontSort);
|
std::sort (itemBounds.begin(), itemBounds.end(), backToFrontSort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue