Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenFlipper-Free
OpenFlipper
Commits
303685cd
Commit
303685cd
authored
Mar 09, 2020
by
Jan Möbius
Browse files
Switched to uint64 instead of bitset for updatetypes
parent
adf9fb31
Changes
2
Hide whitespace changes
Inline
Side-by-side
common/UpdateType.cc
View file @
303685cd
...
...
@@ -61,13 +61,14 @@ static std::map< UpdateType , size_t > updateTypeToTypeInfo;
*/
static
UpdateType
firstFreeID_
(
UPDATE_UNUSED
);
UpdateType
::
UpdateType
()
:
type_
(
0
)
{
}
UpdateType
::
UpdateType
(
const
UpdateTypeSet
&
_set
)
:
type_
(
_set
)
{
...
...
@@ -75,13 +76,13 @@ UpdateType::UpdateType(const UpdateTypeSet& _set)
}
bool
UpdateType
::
operator
==
(
const
UpdateType
&
_type
)
const
{
return
((
type_
&
_type
.
type_
)
.
any
()
);
return
(
(
type_
&
_type
.
type_
)
!=
0
);
};
UpdateType
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 {
return
true
;
}
return
((
type_
&
_type
.
type_
)
.
any
()
);
return
(
(
type_
&
_type
.
type_
)
!=
0
);
}
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
;
}
...
...
@@ -120,7 +129,7 @@ UpdateType& UpdateType::operator++() {
}
bool
UpdateType
::
operator
<
(
const
UpdateType
&
_i
)
const
{
return
(
type_
.
to_ulong
()
<
_i
.
type_
.
to_ulong
()
);
return
(
type_
<
_i
.
type_
);
}
class
UpdateTypeInfo
{
...
...
common/UpdateType.hh
View file @
303685cd
...
...
@@ -41,19 +41,10 @@
#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
<bitset>
#include
<QString>
typedef
std
::
bitset
<
64
>
UpdateTypeSet
;
typedef
uint64_t
UpdateTypeSet
;
/** \brief Update type class
*
...
...
@@ -71,7 +62,7 @@ class DLLEXPORT UpdateType {
UpdateType
(
const
UpdateType
&
_type
)
=
default
;
UpdateType
(
const
UpdateTypeSet
&
_set
);
explicit
UpdateType
(
const
UpdateTypeSet
&
_set
);
/// Exact compare operator
bool
operator
==
(
const
UpdateType
&
_type
)
const
;
...
...
@@ -109,7 +100,7 @@ const UpdateType UPDATE_NONE( UpdateTypeSet(0) );
const
UpdateType
UPDATE_ALL
(
UpdateTypeSet
(
1
)
);
/// 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
...
...
@@ -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
* 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
*
* Updated Topology ( This update type has to be used if you modify the topology
* 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
...
...
@@ -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
* 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
(
1
6
)
);
/** \brief Vertex selection has changed
*
* 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
*
* 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
*
* 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
(
1
28
)
);
/** \brief Face selection has changed
*
* 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
*
* 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
*
* 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
(
1
024
)
);
/** \brief Textures have changed
*
* Update the Textures.
*/
const
UpdateType
UPDATE_TEXTURE
(
UpdateTypeSet
(
1
)
<<
11
);
const
UpdateType
UPDATE_TEXTURE
(
UpdateTypeSet
(
2048
)
);
/** \brief State 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
const
UpdateType
UPDATE_UNUSED
(
UpdateTypeSet
(
1
)
<<
13
);
const
UpdateType
UPDATE_UNUSED
(
UpdateTypeSet
(
8192
)
);
/**@}*/
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment