Commit ac226cdf authored by Sylvain Thery's avatar Sylvain Thery

add easy way to use double in position and normal attributes

parent 7c026cab
......@@ -55,36 +55,37 @@ void ColorPerEdgeRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor
{
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::REAL REAL;
typedef Geom::Vec3f VEC3F;
std::vector<VEC3> buffer;
std::vector<VEC3F> buffer;
buffer.reserve(16384);
std::vector<VEC3> bufferColors;
std::vector<VEC3F> bufferColors;
bufferColors.reserve(16384);
TraversorCell<typename PFP::MAP, EDGE> traEdge(map);
for (Dart d=traEdge.begin(); d!=traEdge.end(); d=traEdge.next())
{
buffer.push_back(positions[d]);
bufferColors.push_back(colorPerXXX[d]);
buffer.push_back(PFP::toVec3f(positions[d]);
bufferColors.push_back(PFP::toVec3f(colorPerXXX[d]));
Dart e = map.phi2(d);
buffer.push_back(positions[e]);
bufferColors.push_back(colorPerXXX[e]);
buffer.push_back(PFP::toVec3f(positions[e]));
bufferColors.push_back(PFP::toVec3f(colorPerXXX[e])) ;
}
m_nbEdges = buffer.size()/2;
vboPosition.setDataSize(3);
vboPosition.allocate(buffer.size());
VEC3* ptrPos = reinterpret_cast<VEC3*>(vboPosition.lockPtr());
memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3));
VEC3F* ptrPos = reinterpret_cast<VEC3F*>(vboPosition.lockPtr());
memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3F));
vboPosition.releasePtr();
vboColor.setDataSize(3);
vboColor.allocate(bufferColors.size());
VEC3* ptrCol = reinterpret_cast<VEC3*>(vboColor.lockPtr());
memcpy(ptrCol,&bufferColors[0],bufferColors.size()*sizeof(VEC3));
VEC3F* ptrCol = reinterpret_cast<VEC3F*>(vboColor.lockPtr());
memcpy(ptrCol,&bufferColors[0],bufferColors.size()*sizeof(VEC3F));
vboColor.releasePtr();
}
......
......@@ -55,11 +55,12 @@ void ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor
{
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::REAL REAL;
typedef Geom::Vec3f VEC3F;
std::vector<VEC3> buffer;
std::vector<VEC3F> buffer;
buffer.reserve(16384);
std::vector<VEC3> bufferColors;
std::vector<VEC3F> bufferColors;
bufferColors.reserve(16384);
TraversorCell<typename PFP::MAP, FACE> traFace(map);
......@@ -87,14 +88,14 @@ void ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor
vboPosition.setDataSize(3);
vboPosition.allocate(buffer.size());
VEC3* ptrPos = reinterpret_cast<VEC3*>(vboPosition.lockPtr());
memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3));
VEC3F* ptrPos = reinterpret_cast<VEC3F*>(vboPosition.lockPtr());
memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3F));
vboPosition.releasePtr();
vboColor.setDataSize(3);
vboColor.allocate(bufferColors.size());
VEC3* ptrCol = reinterpret_cast<VEC3*>(vboColor.lockPtr());
memcpy(ptrCol,&bufferColors[0],bufferColors.size()*sizeof(VEC3));
VEC3F* ptrCol = reinterpret_cast<VEC3F*>(vboColor.lockPtr());
memcpy(ptrCol,&bufferColors[0],bufferColors.size()*sizeof(VEC3F));
vboColor.releasePtr();
}
......@@ -105,14 +106,15 @@ void ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboNorma
{
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::REAL REAL;
typedef Geom::Vec3f VEC3F;
std::vector<VEC3> buffer;
std::vector<VEC3F> buffer;
buffer.reserve(16384);
std::vector<VEC3> bufferNormals;
std::vector<VEC3F> bufferNormals;
bufferNormals.reserve(16384);
std::vector<VEC3> bufferColors;
std::vector<VEC3F> bufferColors;
bufferColors.reserve(16384);
TraversorCell<typename PFP::MAP, FACE> traFace(map);
......@@ -125,15 +127,15 @@ void ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboNorma
// loop to cut a polygon in triangle on the fly (works only with convex faces)
do
{
buffer.push_back(positions[d]);
bufferNormals.push_back(normals[d]);
bufferColors.push_back(colorPerXXX[d]);
buffer.push_back(positions[b]);
bufferNormals.push_back(normals[b]);
bufferColors.push_back(colorPerXXX[b]);
buffer.push_back(positions[c]);
bufferNormals.push_back(normals[c]);
bufferColors.push_back(colorPerXXX[c]);
buffer.push_back(PFP::toVec3f(positions[d]));
bufferNormals.push_back(PFP::toVec3f(normals[d]));
bufferColors.push_back(PFP::toVec3f(colorPerXXX[d]));
buffer.push_back(PFP::toVec3f(positions[b]));
bufferNormals.push_back(PFP::toVec3f(normals[b]);
bufferColors.push_back(PFP::toVec3f(colorPerXXX[b]));
buffer.push_back(PFP::toVec3f(positions[c]);
bufferNormals.push_back(PFP::toVec3f(normals[c]));
bufferColors.push_back(PFP::toVec3f(colorPerXXX[c]));
b = c;
c = map.phi1(b);
} while (c != d);
......@@ -143,20 +145,20 @@ void ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboNorma
vboPosition.setDataSize(3);
vboPosition.allocate(buffer.size());
VEC3* ptrPos = reinterpret_cast<VEC3*>(vboPosition.lockPtr());
memcpy(ptrPos, &buffer[0], buffer.size()*sizeof(VEC3));
VEC3F* ptrPos = reinterpret_cast<VEC3F*>(vboPosition.lockPtr());
memcpy(ptrPos, &buffer[0], buffer.size()*sizeof(VEC3F));
vboPosition.releasePtr();
vboNormal.setDataSize(3);
vboNormal.allocate(bufferColors.size());
VEC3* ptrNorm = reinterpret_cast<VEC3*>(vboNormal.lockPtr());
memcpy(ptrNorm, &bufferColors[0], bufferColors.size()*sizeof(VEC3));
VEC3F* ptrNorm = reinterpret_cast<VEC3F*>(vboNormal.lockPtr());
memcpy(ptrNorm, &bufferColors[0], bufferColors.size()*sizeof(VEC3F));
vboNormal.releasePtr();
vboColor.setDataSize(3);
vboColor.allocate(bufferColors.size());
VEC3* ptrCol = reinterpret_cast<VEC3*>(vboColor.lockPtr());
memcpy(ptrCol, &bufferColors[0], bufferColors.size()*sizeof(VEC3));
VEC3F* ptrCol = reinterpret_cast<VEC3F*>(vboColor.lockPtr());
memcpy(ptrCol, &bufferColors[0], bufferColors.size()*sizeof(VEC3F));
vboColor.releasePtr();
}
......
......@@ -54,8 +54,9 @@ DataPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboData, typen
{
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::REAL REAL;
typedef Geom::Vec3f VEC3F;
std::vector<VEC3> buffer;
std::vector<VEC3F> buffer;
buffer.reserve(16384);
std::vector<T> bufferData;
......@@ -71,11 +72,11 @@ DataPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboData, typen
// loop to cut a polygon in triangle on the fly (works only with convex faces)
do
{
buffer.push_back(positions[d]);
buffer.push_back(PFP::toVec3f(positions[d]));
bufferData.push_back(dataPerXXX[d]);
buffer.push_back(positions[b]);
buffer.push_back(PFP::toVec3f(positions[b]));
bufferData.push_back(dataPerXXX[b]);
buffer.push_back(positions[c]);
buffer.push_back(PFP::toVec3f(positions[c]));
bufferData.push_back(dataPerXXX[c]);
b = c;
c = map.phi1(b);
......@@ -86,8 +87,8 @@ DataPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboData, typen
vboPosition.setDataSize(3);
vboPosition.allocate(buffer.size());
VEC3* ptrPos = reinterpret_cast<VEC3*>(vboPosition.lockPtr());
memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3));
VEC3F* ptrPos = reinterpret_cast<VEC3F*>(vboPosition.lockPtr());
memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3F));
vboPosition.releasePtr();
assert(sizeof(T) % sizeof(float) == 0 || !"DataPerFaceRender::updateVBO: VBO's only work with data types which are a multiple of 4 bytes") ;
......
......@@ -22,6 +22,8 @@
* *
*******************************************************************************/
#include "Geometry/vector_gen.h"
namespace CGoGN
{
......@@ -34,11 +36,12 @@ namespace Render
template<typename PFP>
void drawerAddEdge(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& positions, float k)
{
const typename PFP::VEC3& P = positions[d];
const Geom::Vec3f& P = PFP::toVec3f(positions[d]);
Dart e = map.phi1(d);
const typename PFP::VEC3& Q = positions[e];
const Geom::Vec3f& Q = PFP::toVec3f(positions[e]);
typename PFP::VEC3 C = (P+Q)/ typename PFP::REAL(2.0);
Geom::Vec3f C = (P+Q)/ typename PFP::REAL(2.0);
dr.vertex(C*(1.0f-k) + k*P);
dr.vertex(C*(1.0f-k) + k*Q);
......@@ -47,9 +50,9 @@ void drawerAddEdge(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const Vert
template<typename PFP>
void drawerAddEdgeShrink(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& positions, const typename PFP::VEC3& C, float k)
{
const typename PFP::VEC3& P = positions[d];
const Geom::Vec3f& P = PFP::toVec3f(positions[d]);
Dart e = map.phi1(d);
const typename PFP::VEC3& Q = positions[e];
const Geom::Vec3f& Q = PFP::toVec3f(positions[e]);
dr.vertex(C*(1.0f-k) + k*P);
dr.vertex(C*(1.0f-k) + k*Q);
......@@ -58,7 +61,7 @@ void drawerAddEdgeShrink(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, cons
template<typename PFP>
void drawerAddFace(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& positions, float k)
{
typename PFP::VEC3 C = Algo::Surface::Geometry::faceCentroid<PFP>(map,d,positions);
Geom::Vec3f C = PFP::toVec3f(Algo::Surface::Geometry::faceCentroid<PFP>(map,d,positions));
Traversor2FE<typename PFP::MAP> trav(map,d);
for (Dart e=trav.begin(); e!=trav.end(); e=trav.next())
......@@ -70,7 +73,7 @@ void drawerAddFace(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const Vert
template<typename PFP>
void drawerAddVolume(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& positions,float k)
{
typename PFP::VEC3 C = Algo::Surface::Geometry::volumeCentroid<PFP>(map,d,positions);
Geom::Vec3f C = PFP::toVec3f(Algo::Surface::Geometry::volumeCentroid<PFP>(map,d,positions));
Traversor3WE<typename PFP::MAP> trav(map,d);
for (Dart e=trav.begin(); e!=trav.end(); e=trav.next())
......
......@@ -150,17 +150,19 @@ template<typename PFP, typename V_ATT, typename W_ATT>
void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const V_ATT& positions, const W_ATT& colorPerXXX)
{
typedef typename V_ATT::DATA_TYPE VEC3;
typedef typename W_ATT::DATA_TYPE COL3;
typedef typename PFP::REAL REAL;
typedef Geom::Vec3f VEC3F;
VolumeAutoAttribute<VEC3> centerVolumes(map, "centerVolumes");
Algo::Volume::Geometry::Parallel::computeCentroidELWVolumes<PFP>(map, positions, centerVolumes);
std::vector<VEC3> buffer;
std::vector<VEC3F> buffer;
buffer.reserve(16384);
std::vector<VEC3> bufferColors;
std::vector<VEC3F> bufferColors;
bufferColors.reserve(16384);
std::vector<VEC3> bufferNormals;
std::vector<VEC3F> bufferNormals;
bufferNormals.reserve(16384);
std::vector<VEC3> normals;
......@@ -179,7 +181,7 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const V_ATT& posi
computeFace<PFP>(map,d,positions,centerFace,centerNormalFace,vertices,normals);
VEC3 volCol = colorPerXXX[d];
VEC3F volCol = PFP::toVec3f(colorPerXXX[d]);
unsigned int nbs = vertices.size();
// just to have more easy algo further
......@@ -191,40 +193,40 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const V_ATT& posi
if (nbs == 3)
{
buffer.push_back(centerVolumes[d]);
bufferColors.push_back(centerFace);
bufferNormals.push_back(centerNormalFace); // unsused just for fill
buffer.push_back(PFP::toVec3f(centerVolumes[d]));
bufferColors.push_back(PFP::toVec3f(centerFace));
bufferNormals.push_back(PFP::toVec3f(centerNormalFace)); // unsused just for fill
buffer.push_back(*iv++);
bufferNormals.push_back(*in++);
buffer.push_back(PFP::toVec3f(*iv++));
bufferNormals.push_back(PFP::toVec3f(*in++));
bufferColors.push_back(volCol);
buffer.push_back(*iv++);
bufferNormals.push_back(*in++);
buffer.push_back(PFP::toVec3f(*iv++));
bufferNormals.push_back(PFP::toVec3f(*in++));
bufferColors.push_back(volCol);
buffer.push_back(*iv++);
bufferNormals.push_back(*in++);
buffer.push_back(PFP::toVec3f(*iv++));
bufferNormals.push_back(PFP::toVec3f(*in++));
bufferColors.push_back(volCol);
}
else
{
for (unsigned int i=0; i<nbs; ++i)
{
buffer.push_back(centerVolumes[d]);
bufferColors.push_back(centerFace);
bufferNormals.push_back(centerNormalFace); // unsused just for fill
buffer.push_back(PFP::toVec3f(centerVolumes[d]));
bufferColors.push_back(PFP::toVec3f(centerFace));
bufferNormals.push_back(PFP::toVec3f(centerNormalFace)); // unsused just for fill
buffer.push_back(centerFace);
buffer.push_back(PFP::toVec3f(centerFace));
bufferColors.push_back(volCol);
bufferNormals.push_back(centerNormalFace);
bufferNormals.push_back(PFP::toVec3f(centerNormalFace));
buffer.push_back(*iv++);
bufferNormals.push_back(*in++);
buffer.push_back(PFP::toVec3f(*iv++));
bufferNormals.push_back(PFP::toVec3f(*in++));
bufferColors.push_back(volCol);
buffer.push_back(*iv);
bufferNormals.push_back(*in);
buffer.push_back(PFP::toVec3f(*iv));
bufferNormals.push_back(PFP::toVec3f(*in));
bufferColors.push_back(volCol);
}
}
......@@ -234,20 +236,20 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const V_ATT& posi
m_nbTris = buffer.size()/4;
m_vboPos->allocate(buffer.size());
VEC3* ptrPos = reinterpret_cast<VEC3*>(m_vboPos->lockPtr());
memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3));
VEC3F* ptrPos = reinterpret_cast<VEC3F*>(m_vboPos->lockPtr());
memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3F));
m_vboPos->releasePtr();
m_shaderS->setAttributePosition(m_vboPos);
m_vboColors->allocate(bufferColors.size());
VEC3* ptrCol = reinterpret_cast<VEC3*>(m_vboColors->lockPtr());
memcpy(ptrCol,&bufferColors[0],bufferColors.size()*sizeof(VEC3));
VEC3F* ptrCol = reinterpret_cast<VEC3F*>(m_vboColors->lockPtr());
memcpy(ptrCol,&bufferColors[0],bufferColors.size()*sizeof(VEC3F));
m_vboColors->releasePtr();
m_shaderS->setAttributeColor(m_vboColors);
m_vboNormals->allocate(bufferNormals.size());
VEC3* ptrNorm = reinterpret_cast<VEC3*>(m_vboNormals->lockPtr());
memcpy(ptrNorm,&bufferNormals[0],bufferNormals.size()*sizeof(VEC3));
VEC3F* ptrNorm = reinterpret_cast<VEC3F*>(m_vboNormals->lockPtr());
memcpy(ptrNorm,&bufferNormals[0],bufferNormals.size()*sizeof(VEC3F));
m_vboNormals->releasePtr();
m_shaderS->setAttributeNormal(m_vboNormals);
......@@ -256,17 +258,17 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const V_ATT& posi
TraversorCell<typename PFP::MAP, PFP::MAP::EDGE_OF_PARENT> traEdge(map);
for (Dart d = traEdge.begin(); d != traEdge.end(); d = traEdge.next())
{
buffer.push_back(centerVolumes[d]);
buffer.push_back(positions[d]);
buffer.push_back(positions[map.phi1(d)]);
buffer.push_back(PFP::toVec3f(centerVolumes[d]));
buffer.push_back(PFP::toVec3f(positions[d]));
buffer.push_back(PFP::toVec3f(positions[map.phi1(d)]));
}
m_nbLines = buffer.size()/3;
m_vboPosLine->allocate(buffer.size());
ptrPos = reinterpret_cast<VEC3*>(m_vboPosLine->lockPtr());
memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3));
ptrPos = reinterpret_cast<VEC3F*>(m_vboPosLine->lockPtr());
memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3F));
m_vboPosLine->releasePtr();
m_shaderL->setAttributePosition(m_vboPosLine);
......@@ -282,19 +284,19 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const V_ATT& posi
template<typename PFP, typename EMBV>
void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const EMBV& positions)
{
// typedef typename PFP::VEC3 VEC3;
typedef typename EMBV::DATA_TYPE VEC3;
typedef typename PFP::REAL REAL;
typedef typename Geom::Vec3f VEC3F;
VolumeAutoAttribute<VEC3> centerVolumes(map, "centerVolumes");
Algo::Volume::Geometry::Parallel::computeCentroidELWVolumes<PFP>(map, positions, centerVolumes);
std::vector<VEC3> buffer;
std::vector<VEC3F> buffer;
buffer.reserve(16384);
std::vector<VEC3> bufferColors;
std::vector<VEC3F> bufferColors;
bufferColors.reserve(16384);
std::vector<VEC3> bufferNormals;
std::vector<VEC3F> bufferNormals;
bufferNormals.reserve(16384);
std::vector<VEC3> normals;
......@@ -322,40 +324,40 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const EMBV& posit
if (nbs == 3)
{
buffer.push_back(centerVolumes[d]);
bufferColors.push_back(centerFace);
bufferNormals.push_back(centerNormalFace); // unsused just for fill
buffer.push_back(PFP::toVec3f(centerVolumes[d]));
bufferColors.push_back(PFP::toVec3f(centerFace));
bufferNormals.push_back(PFP::toVec3f(centerNormalFace)); // unsused just for fill
buffer.push_back(*iv++);
bufferNormals.push_back(*in++);
buffer.push_back(PFP::toVec3f(*iv++));
bufferNormals.push_back(PFP::toVec3f(*in++));
bufferColors.push_back(m_globalColor);
buffer.push_back(*iv++);
bufferNormals.push_back(*in++);
buffer.push_back(PFP::toVec3f(*iv++));
bufferNormals.push_back(PFP::toVec3f(*in++));
bufferColors.push_back(m_globalColor);
buffer.push_back(*iv++);
bufferNormals.push_back(*in++);
buffer.push_back(PFP::toVec3f(*iv++));
bufferNormals.push_back(PFP::toVec3f(*in++));
bufferColors.push_back(m_globalColor);
}
else
{
for (unsigned int i=0; i<nbs; ++i)
{
buffer.push_back(centerVolumes[d]);
bufferColors.push_back(centerFace);
bufferNormals.push_back(centerNormalFace); // unsused just for fill
buffer.push_back(PFP::toVec3f(centerVolumes[d]));
bufferColors.push_back(PFP::toVec3f(centerFace));
bufferNormals.push_back(PFP::toVec3f(centerNormalFace)); // unsused just for fill
buffer.push_back(centerFace);
buffer.push_back(PFP::toVec3f(centerFace));
bufferColors.push_back(m_globalColor);
bufferNormals.push_back(centerNormalFace);
bufferNormals.push_back(PFP::toVec3f(centerNormalFace));
buffer.push_back(*iv++);
bufferNormals.push_back(*in++);
buffer.push_back(PFP::toVec3f(*iv++));
bufferNormals.push_back(PFP::toVec3f(*in++));
bufferColors.push_back(m_globalColor);
buffer.push_back(*iv);
bufferNormals.push_back(*in);
buffer.push_back(PFP::toVec3f(*iv));
bufferNormals.push_back(PFP::toVec3f(*in));
bufferColors.push_back(m_globalColor);
}
}
......@@ -364,20 +366,20 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const EMBV& posit
m_nbTris = buffer.size()/4;
m_vboPos->allocate(buffer.size());
VEC3* ptrPos = reinterpret_cast<VEC3*>(m_vboPos->lockPtr());
memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3));
VEC3F* ptrPos = reinterpret_cast<VEC3F*>(m_vboPos->lockPtr());
memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3F));
m_vboPos->releasePtr();
m_shaderS->setAttributePosition(m_vboPos);
m_vboColors->allocate(bufferColors.size());
VEC3* ptrCol = reinterpret_cast<VEC3*>(m_vboColors->lockPtr());
memcpy(ptrCol,&bufferColors[0],bufferColors.size()*sizeof(VEC3));
VEC3F* ptrCol = reinterpret_cast<VEC3F*>(m_vboColors->lockPtr());
memcpy(ptrCol,&bufferColors[0],bufferColors.size()*sizeof(VEC3F));
m_vboColors->releasePtr();
m_shaderS->setAttributeColor(m_vboColors);
m_vboNormals->allocate(bufferNormals.size());
VEC3* ptrNorm = reinterpret_cast<VEC3*>(m_vboNormals->lockPtr());
memcpy(ptrNorm,&bufferNormals[0],bufferNormals.size()*sizeof(VEC3));
VEC3F* ptrNorm = reinterpret_cast<VEC3F*>(m_vboNormals->lockPtr());
memcpy(ptrNorm,&bufferNormals[0],bufferNormals.size()*sizeof(VEC3F));
m_vboNormals->releasePtr();
m_shaderS->setAttributeNormal(m_vboNormals);
......@@ -386,17 +388,17 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const EMBV& posit
TraversorCell<typename PFP::MAP, PFP::MAP::EDGE_OF_PARENT> traEdge(map);
for (Dart d = traEdge.begin(); d != traEdge.end(); d = traEdge.next())
{
buffer.push_back(centerVolumes[d]);
buffer.push_back(positions[d]);
buffer.push_back(positions[map.phi1(d)]);
buffer.push_back(PFP::toVec3f(centerVolumes[d]));
buffer.push_back(PFP::toVec3f(positions[d]));
buffer.push_back(PFP::toVec3f(positions[map.phi1(d)]));
}
m_nbLines = buffer.size()/3;
m_vboPosLine->allocate(buffer.size());
ptrPos = reinterpret_cast<VEC3*>(m_vboPosLine->lockPtr());
memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3));
ptrPos = reinterpret_cast<VEC3F*>(m_vboPosLine->lockPtr());
memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3F));
m_vboPosLine->releasePtr();
m_shaderL->setAttributePosition(m_vboPosLine);
......@@ -430,14 +432,15 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const V_ATT& positi
//typedef typename PFP::VEC3 VEC3;
typedef typename V_ATT::DATA_TYPE VEC3;
typedef typename PFP::REAL REAL;
typedef Geom::Vec3f VEC3F;
VolumeAutoAttribute<VEC3> centerVolumes(map, "centerVolumes");
Algo::Volume::Geometry::Parallel::computeCentroidELWVolumes<PFP>(map, positions, centerVolumes);
std::vector<VEC3> buffer;
std::vector<VEC3F> buffer;
buffer.reserve(16384);
std::vector<VEC3> bufferColors;
std::vector<VEC3F> bufferColors;
bufferColors.reserve(16384);
......@@ -445,8 +448,8 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const V_ATT& positi
for (Dart d = traFace.begin(); d != traFace.end(); d = traFace.next())
{
VEC3 centerFace = Algo::Surface::Geometry::faceCentroidELW<PFP>(map, d, positions);
VEC3 volColor = colorPerXXX[d];
VEC3F centerFace = PFP::toVec3f(Algo::Surface::Geometry::faceCentroidELW<PFP>(map, d, positions));
VEC3F volColor = PFP::toVec3f(colorPerXXX[d]);
Dart b = d;
Dart c = map.phi1(b);
......@@ -454,15 +457,15 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const V_ATT& positi
if (map.phi1(a) == d)
{
buffer.push_back(centerVolumes[d]);
buffer.push_back(PFP::toVec3f(centerVolumes[d]));
bufferColors.push_back(centerFace);
buffer.push_back(positions[b]);
buffer.push_back(PFP::toVec3f(positions[b]));
bufferColors.push_back(volColor);
buffer.push_back(positions[c]);
buffer.push_back(PFP::toVec3f(positions[c]));
bufferColors.push_back(volColor);
c = map.phi1(c);
buffer.push_back(positions[c]);