Commit 303685cd authored by Jan Möbius's avatar Jan Möbius
Browse files

Switched to uint64 instead of bitset for updatetypes

parent adf9fb31
...@@ -61,13 +61,14 @@ static std::map< UpdateType , size_t > updateTypeToTypeInfo; ...@@ -61,13 +61,14 @@ static std::map< UpdateType , size_t > updateTypeToTypeInfo;
*/ */
static UpdateType firstFreeID_(UPDATE_UNUSED); static UpdateType firstFreeID_(UPDATE_UNUSED);
UpdateType::UpdateType() UpdateType::UpdateType()
:type_(0) :type_(0)
{ {
} }
UpdateType::UpdateType(const UpdateTypeSet& _set) UpdateType::UpdateType(const UpdateTypeSet& _set)
: type_(_set) : type_(_set)
{ {
...@@ -75,13 +76,13 @@ UpdateType::UpdateType(const UpdateTypeSet& _set) ...@@ -75,13 +76,13 @@ UpdateType::UpdateType(const UpdateTypeSet& _set)
} }
bool UpdateType::operator==(const UpdateType& _type) const { bool UpdateType::operator==(const UpdateType& _type) const {
return ((type_ & _type.type_).any()); return ( (type_ & _type.type_) != 0);
}; };
UpdateType UpdateType
UpdateType::operator|(const UpdateType& _type) const UpdateType::operator|(const UpdateType& _type) const
{ {
return (type_ | _type.type_); return UpdateType(type_|_type.type_);
} }
...@@ -106,11 +107,19 @@ bool UpdateType::contains( const UpdateType& _type ) const { ...@@ -106,11 +107,19 @@ bool UpdateType::contains( const UpdateType& _type ) const {
return true; return true;
} }
return ((type_ & _type.type_).any()); return ( (type_ & _type.type_) != 0 );
} }
UpdateType& UpdateType::operator++() { UpdateType& UpdateType::operator++() {
if ( type_.count() != 1 ) {
UpdateTypeSet check = type_; // count the number of bits set in type_
unsigned int count; // c accumulates the total bits set in v
for (count = 0; check; count++)
{
check &= check - 1; // clear the least significant bit set
}
if ( count != 1 ) {
std::cerr << "Operator ++ for UpdateType which is not atomic!!" << std::endl; std::cerr << "Operator ++ for UpdateType which is not atomic!!" << std::endl;
} }
...@@ -120,7 +129,7 @@ UpdateType& UpdateType::operator++() { ...@@ -120,7 +129,7 @@ UpdateType& UpdateType::operator++() {
} }
bool UpdateType::operator<( const UpdateType& _i ) const { bool UpdateType::operator<( const UpdateType& _i ) const {
return (type_.to_ulong() < _i.type_.to_ulong()); return (type_ < _i.type_);
} }
class UpdateTypeInfo { class UpdateTypeInfo {
......
...@@ -41,19 +41,10 @@ ...@@ -41,19 +41,10 @@
#pragma once #pragma once
// Workaround compiler bug in VS2017 and earlier with colliding Qt operators and bitset
#ifdef _MSC_VER
#if (_MSC_VER <= 1916)
#define QT_NO_FLOAT16_OPERATORS
#endif
#endif
#include <OpenFlipper/common/GlobalDefines.hh> #include <OpenFlipper/common/GlobalDefines.hh>
#include <bitset>
#include <QString> #include <QString>
typedef std::bitset<64> UpdateTypeSet; typedef uint64_t UpdateTypeSet;
/** \brief Update type class /** \brief Update type class
* *
...@@ -71,7 +62,7 @@ class DLLEXPORT UpdateType { ...@@ -71,7 +62,7 @@ class DLLEXPORT UpdateType {
UpdateType(const UpdateType& _type) = default; UpdateType(const UpdateType& _type) = default;
UpdateType(const UpdateTypeSet& _set); explicit UpdateType(const UpdateTypeSet& _set);
/// Exact compare operator /// Exact compare operator
bool operator==(const UpdateType& _type) const; bool operator==(const UpdateType& _type) const;
...@@ -109,7 +100,7 @@ const UpdateType UPDATE_NONE( UpdateTypeSet(0) ); ...@@ -109,7 +100,7 @@ const UpdateType UPDATE_NONE( UpdateTypeSet(0) );
const UpdateType UPDATE_ALL( UpdateTypeSet(1) ); const UpdateType UPDATE_ALL( UpdateTypeSet(1) );
/// This is the update identifier for global Object visibility ( show/hide ) /// This is the update identifier for global Object visibility ( show/hide )
const UpdateType UPDATE_VISIBILITY( UpdateTypeSet(1) << 1 ); const UpdateType UPDATE_VISIBILITY( UpdateTypeSet(2) );
/** \brief Geometry updated /** \brief Geometry updated
...@@ -117,14 +108,14 @@ const UpdateType UPDATE_VISIBILITY( UpdateTypeSet(1) << 1 ); ...@@ -117,14 +108,14 @@ const UpdateType UPDATE_VISIBILITY( UpdateTypeSet(1) << 1 );
* Updated Geometry ( This update type has to be used if you only modify vertex positions of * Updated Geometry ( This update type has to be used if you only modify vertex positions of
* an object. Everything else has to stay as before the update. * an object. Everything else has to stay as before the update.
*/ */
const UpdateType UPDATE_GEOMETRY( UpdateTypeSet(1) << 2 ); const UpdateType UPDATE_GEOMETRY( UpdateTypeSet(4) );
/** \brief Topology updated /** \brief Topology updated
* *
* Updated Topology ( This update type has to be used if you modify the topology * Updated Topology ( This update type has to be used if you modify the topology
* of an object. This includes adding vertices or removing them! ) * of an object. This includes adding vertices or removing them! )
*/ */
const UpdateType UPDATE_TOPOLOGY( UpdateTypeSet(1) << 3 ); const UpdateType UPDATE_TOPOLOGY( UpdateTypeSet(8) );
/** \brief Selection updated /** \brief Selection updated
...@@ -132,60 +123,60 @@ const UpdateType UPDATE_TOPOLOGY( UpdateTypeSet(1) << 3 ); ...@@ -132,60 +123,60 @@ const UpdateType UPDATE_TOPOLOGY( UpdateTypeSet(1) << 3 );
* Updated Selection ( This update type has to be used if you modify the internal * Updated Selection ( This update type has to be used if you modify the internal
* selection of an object. Like selecting a single vertex or a set of faces. ). * selection of an object. Like selecting a single vertex or a set of faces. ).
*/ */
const UpdateType UPDATE_SELECTION( UpdateTypeSet(1) << 4 ); const UpdateType UPDATE_SELECTION( UpdateTypeSet(16) );
/** \brief Vertex selection has changed /** \brief Vertex selection has changed
* *
* This is a more fine grained selection update. UPDATE_SELECTION will also match this update type. * This is a more fine grained selection update. UPDATE_SELECTION will also match this update type.
*/ */
const UpdateType UPDATE_SELECTION_VERTICES( UpdateTypeSet(1) << 5 ); const UpdateType UPDATE_SELECTION_VERTICES( UpdateTypeSet(32) );
/** \brief Edge selection has changed /** \brief Edge selection has changed
* *
* This is a more fine grained selection update. UPDATE_SELECTION will also match this update type. * This is a more fine grained selection update. UPDATE_SELECTION will also match this update type.
*/ */
const UpdateType UPDATE_SELECTION_EDGES( UpdateTypeSet(1) << 6 ); const UpdateType UPDATE_SELECTION_EDGES( UpdateTypeSet(64) );
/** \brief Halfedge selection has changed /** \brief Halfedge selection has changed
* *
* This is a more fine grained selection update. UPDATE_SELECTION will also match this update type. * This is a more fine grained selection update. UPDATE_SELECTION will also match this update type.
*/ */
const UpdateType UPDATE_SELECTION_HALFEDGES( UpdateTypeSet(1) << 7 ); const UpdateType UPDATE_SELECTION_HALFEDGES( UpdateTypeSet(128) );
/** \brief Face selection has changed /** \brief Face selection has changed
* *
* This is a more fine grained selection update. UPDATE_SELECTION will also match this update type. * This is a more fine grained selection update. UPDATE_SELECTION will also match this update type.
*/ */
const UpdateType UPDATE_SELECTION_FACES( UpdateTypeSet(1) << 8 ); const UpdateType UPDATE_SELECTION_FACES( UpdateTypeSet(256) );
/** \brief Knot selection has changed /** \brief Knot selection has changed
* *
* This is a more fine grained selection update. UPDATE_SELECTION will also match this update type. * This is a more fine grained selection update. UPDATE_SELECTION will also match this update type.
*/ */
const UpdateType UPDATE_SELECTION_KNOTS( UpdateTypeSet(1) << 9 ); const UpdateType UPDATE_SELECTION_KNOTS( UpdateTypeSet(512) );
/** \brief Colors have changed /** \brief Colors have changed
* *
* Update the colors. This does not have to be called when topology is also updated * Update the colors. This does not have to be called when topology is also updated
*/ */
const UpdateType UPDATE_COLOR( UpdateTypeSet(1) << 10 ); const UpdateType UPDATE_COLOR( UpdateTypeSet(1024) );
/** \brief Textures have changed /** \brief Textures have changed
* *
* Update the Textures. * Update the Textures.
*/ */
const UpdateType UPDATE_TEXTURE( UpdateTypeSet(1) << 11 ); const UpdateType UPDATE_TEXTURE( UpdateTypeSet(2048) );
/** \brief State has changed /** \brief State has changed
* *
* The object's state (target, source) has changed * The object's state (target, source) has changed
*/ */
const UpdateType UPDATE_STATE( UpdateTypeSet(1) << 12 ); const UpdateType UPDATE_STATE( UpdateTypeSet(4096) );
/// marks the last used ID /// marks the last used ID
const UpdateType UPDATE_UNUSED ( UpdateTypeSet(1) << 13 ); const UpdateType UPDATE_UNUSED ( UpdateTypeSet(8192) );
/**@}*/ /**@}*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment