Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RobotAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lennard Hofmann
RobotAPI
Commits
23af3dd8
Commit
23af3dd8
authored
4 years ago
by
Fabian Paus
Browse files
Options
Downloads
Patches
Plain Diff
ArViz Performance: Do not create new nodes on every update call
parent
1a903e48
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/RobotAPI/components/ArViz/Coin/VisualizationEllipsoid.h
+26
-35
26 additions, 35 deletions
...e/RobotAPI/components/ArViz/Coin/VisualizationEllipsoid.h
with
26 additions
and
35 deletions
source/RobotAPI/components/ArViz/Coin/VisualizationEllipsoid.h
+
26
−
35
View file @
23af3dd8
...
...
@@ -4,8 +4,9 @@
#include
<RobotAPI/interface/ArViz/Elements.h>
#include
<VirtualRobot/Visualization/CoinVisualization/CoinVisualizationFactory.h>
#include
<VirtualRobot/Visualization/CoinVisualization/CoinVisualizationNode.h>
#include
<Inventor/nodes/SoComplexity.h>
#include
<Inventor/nodes/SoScale.h>
#include
<Inventor/nodes/SoSphere.h>
namespace
armarx
::
viz
::
coin
{
...
...
@@ -13,43 +14,33 @@ namespace armarx::viz::coin
{
using
ElementType
=
data
::
ElementEllipsoid
;
VisualizationEllipsoid
()
{
complexity
=
new
SoComplexity
();
complexity
->
type
.
setValue
(
SoComplexity
::
OBJECT_SPACE
);
complexity
->
value
.
setValue
(
1.0
f
);
scale
=
new
SoScale
;
sphere
=
new
SoSphere
();
// We create a unit sphere and create an ellipsoid through scaling
sphere
->
radius
.
setValue
(
1.0
f
);
node
->
addChild
(
complexity
);
node
->
addChild
(
scale
);
node
->
addChild
(
sphere
);
}
bool
update
(
ElementType
const
&
element
)
{
auto
color
=
element
.
color
;
constexpr
float
conv
=
1.0
f
/
255.0
f
;
const
float
r
=
color
.
r
*
conv
;
const
float
g
=
color
.
g
*
conv
;
const
float
b
=
color
.
b
*
conv
;
const
float
a
=
color
.
a
*
conv
;
VirtualRobot
::
VisualizationNodePtr
ellipsoid_node
;
{
// Params.
SoMaterial
*
mat
=
new
SoMaterial
;
mat
->
diffuseColor
.
setValue
(
r
,
g
,
b
);
mat
->
ambientColor
.
setValue
(
r
,
g
,
b
);
mat
->
transparency
.
setValue
(
1.
-
a
);
const
bool
show_axes
=
false
;
// Do not show axes. If needed, draw a Pose instead.
SoSeparator
*
res
=
new
SoSeparator
();
res
->
ref
();
SoUnits
*
u
=
new
SoUnits
();
u
->
units
=
SoUnits
::
MILLIMETERS
;
res
->
addChild
(
u
);
res
->
addChild
(
VirtualRobot
::
CoinVisualizationFactory
::
CreateEllipse
(
element
.
axisLengths
.
e0
,
element
.
axisLengths
.
e1
,
element
.
axisLengths
.
e2
,
mat
,
show_axes
));
ellipsoid_node
.
reset
(
new
VirtualRobot
::
CoinVisualizationNode
(
res
));
res
->
unref
();
}
SoNode
*
ellipsoid
=
dynamic_cast
<
VirtualRobot
::
CoinVisualizationNode
&>
(
*
ellipsoid_node
).
getCoinVisualization
();
node
->
removeAllChildren
();
node
->
addChild
(
ellipsoid
);
scale
->
scaleFactor
.
setValue
(
element
.
axisLengths
.
e0
,
element
.
axisLengths
.
e1
,
element
.
axisLengths
.
e2
);
return
true
;
}
SoMaterial
*
material
=
nullptr
;
SoComplexity
*
complexity
=
nullptr
;
SoScale
*
scale
=
nullptr
;
SoSphere
*
sphere
=
nullptr
;
};
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment