Skip to content

Commit

Permalink
Merge pull request #1664 from maletsden/c++20_fix
Browse files Browse the repository at this point in the history
Fixed C++20 compatibility of OpenVDB and TBB
  • Loading branch information
Idclip committed Oct 3, 2023
2 parents fd5bfe8 + 98176b8 commit bc63bf9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
3 changes: 2 additions & 1 deletion openvdb/openvdb/points/AttributeSet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ AttributeSet::makeUnique(size_t pos)
{
assert(pos != INVALID_POS);
assert(pos < mAttrs.size());
if (!mAttrs[pos].unique()) {
// Warning: In multithreaded environment, the value returned by use_count is approximate.
if (mAttrs[pos].use_count() != 1) {
mAttrs[pos] = mAttrs[pos]->copy();
}
}
Expand Down
8 changes: 4 additions & 4 deletions openvdb/openvdb/tools/Diagnostics.h
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ class InactiveTileValues
void getInactiveValues(SetType&) const;

inline InactiveTileValues(const InactiveTileValues<TreeType>&, tbb::split);
inline void operator()(IterRange&);
inline void operator()(const IterRange&);
inline void join(const InactiveTileValues<TreeType>&);

private:
Expand Down Expand Up @@ -1252,10 +1252,10 @@ InactiveTileValues<TreeType>::runSerial(IterRange& range)

template<typename TreeType>
inline void
InactiveTileValues<TreeType>::operator()(IterRange& range)
InactiveTileValues<TreeType>::operator()(const IterRange& range)
{
for (; range && !thread::isGroupExecutionCancelled(); ++range) {
typename TreeType::ValueOffCIter iter = range.iterator();
for (IterRange it(range); it.test() && !thread::isGroupExecutionCancelled(); ++it) {
typename TreeType::ValueOffCIter iter = it.iterator();
for (; iter; ++iter) {
mInactiveValues.insert(iter.getValue());
}
Expand Down
12 changes: 6 additions & 6 deletions openvdb/openvdb/tools/GridTransformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -799,11 +799,11 @@ class GridResampler::RangeProcessor
void setInterrupt(const InterruptFunc& f) { mInterrupt = f; }

/// Transform each leaf node in the given range.
void operator()(LeafRange& r)
void operator()(const LeafRange& r)
{
for ( ; r; ++r) {
for (LeafRange it(r); it.test(); ++it) {
if (interrupt()) break;
LeafIterT i = r.iterator();
LeafIterT i = it.iterator();
CoordBBox bbox(i->origin(), i->origin() + Coord(i->dim()));
if (!mBBox.empty()) {
// Intersect the leaf node's bounding box with mBBox.
Expand All @@ -818,12 +818,12 @@ class GridResampler::RangeProcessor
}

/// Transform each non-background tile in the given range.
void operator()(TileRange& r)
void operator()(const TileRange& r)
{
for ( ; r; ++r) {
for (TileRange it(r); it.test(); ++it) {
if (interrupt()) break;

TileIterT i = r.iterator();
TileIterT i = it.iterator();
// Skip voxels and background tiles.
if (!i.isTileValue()) continue;
if (!i.isValueOn() && math::isApproxEqual(*i, mOutTree->background())) continue;
Expand Down
2 changes: 1 addition & 1 deletion openvdb/openvdb/tools/LevelSetSphere.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class LevelSetSphere
Op(TreeT &tree) : mDelete(false), mTree(&tree) {}
Op(const Op& other, tbb::split) : mDelete(true), mTree(new TreeT(other.mTree->background())) {}
~Op() { if (mDelete) delete mTree; }
void operator()(RangeT &r) { for (auto i=r.begin(); i!=r.end(); ++i) this->merge(*i);}
void operator()(const RangeT &r) { for (auto i=r.begin(); i!=r.end(); ++i) this->merge(*i);}
void join(Op &other) { this->merge(*(other.mTree)); }
void merge(TreeT &tree) { mTree->merge(tree, openvdb::MERGE_ACTIVE_STATES); }
} op( mGrid->tree() );
Expand Down
2 changes: 1 addition & 1 deletion openvdb/openvdb/tools/ValueTransformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ class OpAccumulator
}
}

void operator()(IterRange& r) { for ( ; r; ++r) (*mOp)(r.iterator()); }
void operator()(const IterRange& r) { for (IterRange it(r); it.test(); ++it) (*mOp)(it.iterator()); }

void join(OpAccumulator& other) { mOp->join(*other.mOp); }

Expand Down

0 comments on commit bc63bf9

Please sign in to comment.