Skip to content
Snippets Groups Projects
Commit d33e1737 authored by Fabian Paus's avatar Fabian Paus
Browse files

ArViz: VisualizationRobot cache current color and only change if needed

parent 4ed8b38c
No related branches found
No related tags found
No related merge requests found
......@@ -136,26 +136,33 @@ namespace armarx::viz::coin
if (loadedDrawStyle & data::ModelDrawStyle::OVERRIDE_COLOR)
{
int numChildren = node->getNumChildren();
for (int i = 0; i < numChildren; i++)
if (loadedColor.r != element.color.r
|| loadedColor.g != element.color.g
|| loadedColor.b != element.color.b
|| loadedColor.a != element.color.a)
{
SoSeparator* nodeSep = static_cast<SoSeparator*>(node->getChild(i));
// The first entry must be a SoMaterial (see recreateVisualizationNodes)
SoMaterial* m = dynamic_cast<SoMaterial*>(nodeSep->getChild(0));
if (!m)
int numChildren = node->getNumChildren();
for (int i = 0; i < numChildren; i++)
{
ARMARX_WARNING << "Error at node with index: " << i;
continue;
SoSeparator* nodeSep = static_cast<SoSeparator*>(node->getChild(i));
// The first entry must be a SoMaterial (see recreateVisualizationNodes)
SoMaterial* m = dynamic_cast<SoMaterial*>(nodeSep->getChild(0));
if (!m)
{
ARMARX_WARNING << "Error at node with index: " << i;
continue;
}
auto color = element.color;
const float conv = 1.0f / 255.0f;
float a = color.a * conv;
SbColor coinColor(conv * color.r, conv * color.g, conv * color.b);
m->diffuseColor = coinColor;
m->ambientColor = coinColor;
m->transparency = 1.0f - a;
m->setOverride(true);
}
auto color = element.color;
const float conv = 1.0f / 255.0f;
float a = color.a * conv;
SbColor coinColor(conv * color.r, conv * color.g, conv * color.b);
m->diffuseColor = coinColor;
m->ambientColor = coinColor;
m->transparency = 1.0f - a;
m->setOverride(true);
loadedColor = element.color;
}
}
IceUtil::Time time_color = IceUtil::Time::now();
......
......@@ -25,6 +25,7 @@ namespace armarx::viz::coin
LoadedRobot loaded;
int loadedDrawStyle = data::ModelDrawStyle::ORIGINAL;
armarx::viz::data::Color loadedColor{0, 0, 0, 0};
};
void clearRobotCache();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment