mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 14:03:17 +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) {
|
||||
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
|
||||
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;
|
||||
itemBounds.reserve(outItems.size());
|
||||
|
||||
|
@ -235,18 +247,10 @@ void render::depthSortItems(const SceneContextPointer& sceneContext, const Rende
|
|||
|
||||
// sort against Z
|
||||
if (frontToBack) {
|
||||
struct FrontToBackSort {
|
||||
bool operator() (ItemBound& left, ItemBound& right) {
|
||||
return (left._centerDepth < right._centerDepth);
|
||||
}
|
||||
} frontToBackSort;
|
||||
FrontToBackSort frontToBackSort;
|
||||
std::sort (itemBounds.begin(), itemBounds.end(), frontToBackSort);
|
||||
} else {
|
||||
struct BackToFrontSort {
|
||||
bool operator() (ItemBound& left, ItemBound& right) {
|
||||
return (left._centerDepth > right._centerDepth);
|
||||
}
|
||||
} backToFrontSort;
|
||||
BackToFrontSort backToFrontSort;
|
||||
std::sort (itemBounds.begin(), itemBounds.end(), backToFrontSort);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue