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

ArViz Performance: Do not copy data for point cloud visu

parent 54062065
No related branches found
No related tags found
No related merge requests found
......@@ -23,48 +23,50 @@ namespace armarx::viz::coin
pclMatBind->value = SoMaterialBinding::PER_PART;
pclCoords = new SoCoordinate3;
pclStye = new SoDrawStyle;
pclStyle = new SoDrawStyle;
node->addChild(pclMat);
node->addChild(pclMatBind);
node->addChild(pclCoords);
node->addChild(pclStye);
node->addChild(pclStyle);
node->addChild(new SoPointSet);
}
bool update(ElementType const& element)
{
auto& pcl = element.points;
data::ColoredPointList const& pcl = element.points;
colors.clear();
colors.reserve(pcl.size());
coords.clear();
coords.reserve(pcl.size());
int pclSize = (int)pcl.size();
colors.resize(pclSize);
coords.resize(pclSize);
const float conv = 1.0f / 255.0f;
for (auto& point : pcl)
SbColor* colorsData = colors.data();
SbVec3f* coordsData = coords.data();
for (int i = 0; i < pclSize; ++i)
{
data::ColoredPoint point = pcl[i];
float r = point.color.r * conv;
float g = point.color.g * conv;
float b = point.color.b * conv;
colors.emplace_back(r, g, b);
coords.emplace_back(point.x, point.y, point.z);
colorsData[i].setValue(r, g, b);
coordsData[i].setValue(point.x, point.y, point.z);
}
pclMat->diffuseColor.setValues(0, colors.size(), colors.data());
pclMat->ambientColor.setValues(0, colors.size(), colors.data());
pclMat->diffuseColor.setValuesPointer(pclSize, colors.data());
pclMat->ambientColor.setValuesPointer(pclSize, colors.data());
pclMat->transparency = element.transparency;
pclCoords->point.setValues(0, coords.size(), coords.data());
pclCoords->point.setNum(coords.size());
pclCoords->point.setValuesPointer(pclSize, coords.data());
pclCoords->point.setNum(pclSize);
pclStye->pointSize = element.pointSizeInPixels;
pclStyle->pointSize = element.pointSizeInPixels;
return true;
}
SoMaterial* pclMat;
SoCoordinate3* pclCoords;
SoDrawStyle* pclStye;
SoDrawStyle* pclStyle;
std::vector<SbColor> colors;
std::vector<SbVec3f> coords;
......
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