Lovelly bug in Interval Tree
This commit is contained in:
parent
5e3f5594b8
commit
3f49ee11ae
2 changed files with 8 additions and 3 deletions
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include "Tree.hpp"
|
#include "Tree.hpp"
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
namespace tp {
|
namespace tp {
|
||||||
|
|
||||||
template <typename tType>
|
template <typename tType>
|
||||||
|
|
@ -31,7 +33,7 @@ namespace tp {
|
||||||
|
|
||||||
template <typename tTreeNodeType>
|
template <typename tTreeNodeType>
|
||||||
inline void updateNodeCache(const tTreeNodeType* node) {
|
inline void updateNodeCache(const tTreeNodeType* node) {
|
||||||
mMax = 0;
|
mMax = std::numeric_limits<tType>::min();
|
||||||
if (node->mRight && node->mRight->key.mMax > mMax) mMax = node->mRight->key.mMax;
|
if (node->mRight && node->mRight->key.mMax > mMax) mMax = node->mRight->key.mMax;
|
||||||
if (node->mLeft && node->mLeft->key.mMax > mMax) mMax = node->mLeft->key.mMax;
|
if (node->mLeft && node->mLeft->key.mMax > mMax) mMax = node->mLeft->key.mMax;
|
||||||
if (mMax < mEnd) mMax = mEnd;
|
if (mMax < mEnd) mMax = mEnd;
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,11 @@ struct Interval {
|
||||||
bool ignore = false;
|
bool ignore = false;
|
||||||
|
|
||||||
void random(halnf span, halnf scale = 1.f) {
|
void random(halnf span, halnf scale = 1.f) {
|
||||||
start = ((halnf) randomFloat()) * (span);
|
auto offset = 0;
|
||||||
end = ((halnf) randomFloat()) * (span);
|
|
||||||
|
start = ((halnf) randomFloat()) * (span) - offset;
|
||||||
|
end = ((halnf) randomFloat()) * (span) - offset;
|
||||||
|
|
||||||
if (start > end) swap(start, end);
|
if (start > end) swap(start, end);
|
||||||
|
|
||||||
auto len = (end - start) * scale * 0.5f;
|
auto len = (end - start) * scale * 0.5f;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue