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