mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-12-17 22:21:07 +00:00
Merge pull request #1002 from barfowl/vtr_level_tag_bits
Simplify Vtr bitfield operations to avoid issues with older versions of GCC
This commit is contained in:
commit
2fe36033d5
@ -604,47 +604,33 @@ Level::getFaceETags(Index fIndex, ETag eTags[], int fvarChannel) const {
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
template <typename TAG_TYPE, typename INT_TYPE>
|
||||
void
|
||||
combineTags(TAG_TYPE& dstTag, TAG_TYPE const& srcTag) {
|
||||
|
||||
assert(sizeof(TAG_TYPE) == sizeof(INT_TYPE));
|
||||
|
||||
INT_TYPE const & srcInt = *(reinterpret_cast<INT_TYPE const*>(&srcTag));
|
||||
INT_TYPE & dstInt = *(reinterpret_cast<INT_TYPE *> (&dstTag));
|
||||
|
||||
dstInt |= srcInt;
|
||||
}
|
||||
}
|
||||
|
||||
Level::VTag
|
||||
Level::VTag::BitwiseOr(VTag const vTags[], int size) {
|
||||
|
||||
VTag compTag = vTags[0];
|
||||
VTag::VTagSize tagBits = vTags[0].getBits();
|
||||
for (int i = 1; i < size; ++i) {
|
||||
combineTags<VTag, VTag::VTagSize>(compTag, vTags[i]);
|
||||
tagBits |= vTags[i].getBits();
|
||||
}
|
||||
return compTag;
|
||||
return VTag(tagBits);
|
||||
}
|
||||
Level::ETag
|
||||
Level::ETag::BitwiseOr(ETag const eTags[], int size) {
|
||||
|
||||
ETag compTag = eTags[0];
|
||||
ETag::ETagSize tagBits = eTags[0].getBits();
|
||||
for (int i = 1; i < size; ++i) {
|
||||
combineTags<ETag, ETag::ETagSize>(compTag, eTags[i]);
|
||||
tagBits |= eTags[i].getBits();
|
||||
}
|
||||
return compTag;
|
||||
return ETag(tagBits);
|
||||
}
|
||||
|
||||
Level::VTag
|
||||
Level::getFaceCompositeVTag(ConstIndexArray & fVerts) const {
|
||||
|
||||
VTag compTag = _vertTags[fVerts[0]];
|
||||
VTag::VTagSize tagBits = _vertTags[fVerts[0]].getBits();
|
||||
for (int i = 1; i < fVerts.size(); ++i) {
|
||||
combineTags<VTag, VTag::VTagSize>(compTag, _vertTags[fVerts[i]]);
|
||||
tagBits |= _vertTags[fVerts[i]].getBits();
|
||||
}
|
||||
return compTag;
|
||||
return VTag(tagBits);
|
||||
}
|
||||
Level::VTag
|
||||
Level::getFaceCompositeVTag(Index fIndex, int fvarChannel) const {
|
||||
@ -657,12 +643,11 @@ Level::getFaceCompositeVTag(Index fIndex, int fvarChannel) const {
|
||||
internal::StackBuffer<FVarLevel::ValueTag,64> fvarTags(fVerts.size());
|
||||
fvarLevel.getFaceValueTags(fIndex, fvarTags);
|
||||
|
||||
VTag compTag = fvarTags[0].combineWithLevelVTag(_vertTags[fVerts[0]]);
|
||||
VTag::VTagSize tagBits = fvarTags[0].combineWithLevelVTag(_vertTags[fVerts[0]]).getBits();
|
||||
for (int i = 1; i < fVerts.size(); ++i) {
|
||||
combineTags<VTag, VTag::VTagSize>(compTag,
|
||||
fvarTags[i].combineWithLevelVTag(_vertTags[fVerts[i]]));
|
||||
tagBits |= fvarTags[i].combineWithLevelVTag(_vertTags[fVerts[i]]).getBits();
|
||||
}
|
||||
return compTag;
|
||||
return VTag(tagBits);
|
||||
}
|
||||
}
|
||||
|
||||
@ -675,11 +660,11 @@ Level::getVertexCompositeFVarVTag(Index vIndex, int fvarChannel) const {
|
||||
|
||||
VTag vTag = getVertexTag(vIndex);
|
||||
if (fvTags[0].isMismatch()) {
|
||||
VTag compVTag = fvTags[0].combineWithLevelVTag(vTag);
|
||||
VTag::VTagSize tagBits = fvTags[0].combineWithLevelVTag(vTag).getBits();
|
||||
for (int i = 1; i < fvTags.size(); ++i) {
|
||||
combineTags<VTag, VTag::VTagSize>(compVTag, fvTags[i].combineWithLevelVTag(vTag));
|
||||
tagBits |= fvTags[i].combineWithLevelVTag(vTag).getBits();
|
||||
}
|
||||
return compVTag;
|
||||
return VTag(tagBits);
|
||||
} else {
|
||||
return vTag;
|
||||
}
|
||||
|
@ -119,6 +119,10 @@ public:
|
||||
VTagSize _infSharpCrease : 1; // fixed
|
||||
VTagSize _infIrregular : 1; // fixed
|
||||
|
||||
// Alternate constructor and accessor for dealing with integer bits directly:
|
||||
explicit VTag(VTagSize bits) { *this = *reinterpret_cast<VTag const *>(&bits); }
|
||||
VTagSize getBits() const { return *reinterpret_cast<VTagSize const *>(this); }
|
||||
|
||||
static VTag BitwiseOr(VTag const vTags[], int size = 4);
|
||||
};
|
||||
struct ETag {
|
||||
@ -134,6 +138,10 @@ public:
|
||||
ETagSize _infSharp : 1; // fixed
|
||||
ETagSize _semiSharp : 1; // variable
|
||||
|
||||
// Alternate constructor and accessor for dealing with integer bits directly:
|
||||
explicit ETag(ETagSize bits) { *this = *reinterpret_cast<ETag const *>(&bits); }
|
||||
ETagSize getBits() const { return *reinterpret_cast<ETagSize const *>(this); }
|
||||
|
||||
static ETag BitwiseOr(ETag const eTags[], int size = 4);
|
||||
};
|
||||
struct FTag {
|
||||
|
Loading…
Reference in New Issue
Block a user