Skip to content

Commit 74c8dce

Browse files
committed
Closes #818
1 parent 2693cf6 commit 74c8dce

File tree

3 files changed

+45
-65
lines changed

3 files changed

+45
-65
lines changed

src/Interface/Modules/Render/ES/SRInterface.cc

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,11 @@ namespace SCIRun {
300300
}
301301

302302
// Add vertex buffer objects.
303-
//-----------------------------------------------------------------
304-
char* vbo_buffer = 0;
305-
size_t stride_vbo = 0;
306-
//-----------------------------------------------------------------
303+
std::vector<char*> vbo_buffer;
304+
std::vector<size_t> stride_vbo;
307305

308306
int nameIndex = 0;
309-
for (auto it = obj->mVBOs.cbegin(); it != obj->mVBOs.cend(); ++it)
307+
for (auto it = obj->mVBOs.cbegin(); it != obj->mVBOs.cend(); ++it, ++nameIndex)
310308
{
311309
const Core::Datatypes::GeometryObject::SpireVBO& vbo = *it;
312310

@@ -322,17 +320,21 @@ namespace SCIRun {
322320
GLuint vboID = vboMan.addInMemoryVBO(vbo.data->getBuffer(), vbo.data->getBufferSize(),
323321
attributeData, vbo.name);
324322
}
325-
//-----------------------------------------------------------------
326-
vbo_buffer = reinterpret_cast<char*>(vbo.data->getBuffer());
323+
324+
vbo_buffer.push_back(reinterpret_cast<char*>(vbo.data->getBuffer()));
325+
size_t stride = 0;
327326
for (auto a : vbo.attributes)
328-
stride_vbo += a.sizeInBytes;
329-
//-----------------------------------------------------------------
327+
stride += a.sizeInBytes;
328+
stride_vbo.push_back(stride);
329+
330330
bbox.extend(vbo.boundingBox);
331331
}
332332

333+
std::cout << "VBO passes: " << nameIndex << std::endl;
334+
333335
// Add index buffer objects.
334336
nameIndex = 0;
335-
for (auto it = obj->mIBOs.cbegin(); it != obj->mIBOs.cend(); ++it)
337+
for (auto it = obj->mIBOs.cbegin(); it != obj->mIBOs.cend(); ++it, ++nameIndex)
336338
{
337339
const Core::Datatypes::GeometryObject::SpireIBO& ibo = *it;
338340
GLenum primType = GL_UNSIGNED_SHORT;
@@ -373,13 +375,12 @@ namespace SCIRun {
373375
break;
374376
}
375377
/// Create sorted lists of Buffers for transparency in each direction of the axis
376-
//----------------------------------------------------------------
377378
uint32_t* ibo_buffer = reinterpret_cast<uint32_t*>(ibo.data->getBuffer());
378379
size_t num_triangles = ibo.data->getBufferSize() / (sizeof(uint32_t) * 3);
379380
Core::Geometry::Vector dir(0.0, 0.0, 0.0);
380381

381382
std::vector<DepthIndex> rel_depth(num_triangles);
382-
for (int i = 0; i <= 6; ++i)
383+
for (int i = 0; i < 6; ++i)
383384
{
384385
std::string name = ibo.name;
385386

@@ -413,22 +414,16 @@ namespace SCIRun {
413414
dir = Core::Geometry::Vector(0.0, 0.0, -1.0);
414415
name += "NegZ";
415416
}
416-
else if (i == 6)
417-
{
418-
int numPrimitives = ibo.data->getBufferSize() / ibo.indexSize;
419-
iboMan.addInMemoryIBO(ibo.data->getBuffer(), ibo.data->getBufferSize(), primitive, primType, numPrimitives, name);
420-
break;
421-
}
422417

423418
for (size_t j = 0; j < num_triangles; j++)
424419
{
425-
float* vertex1 = reinterpret_cast<float*>(vbo_buffer + stride_vbo * (ibo_buffer[j * 3]));
420+
float* vertex1 = reinterpret_cast<float*>(vbo_buffer[nameIndex] + stride_vbo[nameIndex] * (ibo_buffer[j * 3]));
426421
Core::Geometry::Point node1(vertex1[0], vertex1[1], vertex1[2]);
427422

428-
float* vertex2 = reinterpret_cast<float*>(vbo_buffer + stride_vbo * (ibo_buffer[j * 3 + 1]));
423+
float* vertex2 = reinterpret_cast<float*>(vbo_buffer[nameIndex] + stride_vbo[nameIndex] * (ibo_buffer[j * 3 + 1]));
429424
Core::Geometry::Point node2(vertex2[0], vertex2[1], vertex2[2]);
430425

431-
float* vertex3 = reinterpret_cast<float*>(vbo_buffer + stride_vbo * (ibo_buffer[j * 3 + 2]));
426+
float* vertex3 = reinterpret_cast<float*>(vbo_buffer[nameIndex] + stride_vbo[nameIndex] * (ibo_buffer[j * 3 + 2]));
432427
Core::Geometry::Point node3(vertex3[0], vertex3[1], vertex3[2]);
433428

434429
rel_depth[j].mDepth = Core::Geometry::Dot(dir, node1) + Core::Geometry::Dot(dir, node2) + Core::Geometry::Dot(dir, node3);
@@ -450,14 +445,11 @@ namespace SCIRun {
450445
}
451446

452447
iboMan.addInMemoryIBO(sbuffer, ibo.data->getBufferSize(), primitive, primType, numPrimitives, name);
453-
}
454-
//----------------------------------------------------------------
455-
456-
//int numPrimitives = ibo.data->getBufferSize() / ibo.indexSize;
457-
458-
//iboMan.addInMemoryIBO(ibo.data->getBuffer(), ibo.data->getBufferSize(), primitive, primType, numPrimitives, ibo.name);
448+
}
459449
}
460450

451+
std::cout << "IBO passes: " << nameIndex << std::endl;
452+
461453
// Add default identity transform to the object globally (instead of per-pass)
462454
glm::mat4 xform;
463455
mSRObjects.push_back(SRObject(objectName, xform, bbox, obj->mColorMap, port));
@@ -476,20 +468,20 @@ namespace SCIRun {
476468
{
477469
//reorderIBO(pass);
478470
addVBOToEntity(entityID, pass.vboName);
479-
for (int i = 0; i <= 6; ++i)
471+
for (int i = 0; i < 6; ++i)
480472
{
481473
std::string name = pass.iboName;
482-
if (i == 1)
474+
if (i == 0)
483475
name += "X";
484-
if (i == 2)
476+
if (i == 1)
485477
name += "Y";
486-
if (i == 3)
478+
if (i == 2)
487479
name += "Z";
488-
if (i == 4)
480+
if (i == 3)
489481
name += "NegX";
490-
if (i == 5)
482+
if (i == 4)
491483
name += "NegY";
492-
if (i == 6)
484+
if (i == 5)
493485
name += "NegZ";
494486

495487
addIBOToEntity(entityID, name);

src/Interface/Modules/Render/ES/systems/RenderTransBasicSys.cc

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,17 @@ class RenderBasicSysTrans :
117117
int index = 0;
118118
for (auto it = ibo.begin(); it != ibo.end(); ++it, ++index)
119119
{
120-
if (index == 1)
120+
if (index == 0)
121121
iboXID = it->glid;
122-
if (index == 2)
122+
if (index == 1)
123123
iboYID = it->glid;
124-
if (index == 3)
124+
if (index == 2)
125125
iboZID = it->glid;
126-
if (index == 4)
126+
if (index == 3)
127127
iboNegXID = it->glid;
128-
if (index == 5)
128+
if (index == 4)
129129
iboNegYID = it->glid;
130-
if (index == 6)
130+
if (index == 5)
131131
iboNegZID = it->glid;
132132
}
133133

@@ -144,21 +144,15 @@ class RenderBasicSysTrans :
144144

145145
if (orZ == absDir.x())
146146
{
147-
iboID = iboXID;
148-
if (currentDir.x() < orZ)
149-
iboID = iboNegXID;
147+
iboID = currentDir.x() < orZ ? iboNegXID : iboXID;
150148
}
151149
if (orZ == absDir.y())
152150
{
153-
iboID = iboYID;
154-
if (currentDir.y() < orZ)
155-
iboID = iboNegYID;
151+
iboID = currentDir.y() < orZ ? iboNegYID : iboYID;
156152
}
157153
if (orZ == absDir.z())
158154
{
159-
iboID = iboZID;
160-
if (currentDir.z() < orZ)
161-
iboID = iboNegZID;
155+
iboID = currentDir.z() < orZ ? iboNegZID : iboZID;
162156
}
163157

164158
// Setup *everything*. We don't want to enter multiple conditional
@@ -216,7 +210,7 @@ class RenderBasicSysTrans :
216210

217211
// Bind VBO and IBO
218212
GL(glBindBuffer(GL_ARRAY_BUFFER, vbo.front().glid));
219-
GL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo.front().glid));
213+
GL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, iboID));
220214

221215
// Bind any common uniforms.
222216
if (commonUniforms.size() > 0)

src/Interface/Modules/Render/ES/systems/RenderTransColorMapSys.cc

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,17 @@ class RenderColorMapSysTrans :
117117
int index = 0;
118118
for (auto it = ibo.begin(); it != ibo.end(); ++it, ++index)
119119
{
120-
if (index == 1)
120+
if (index == 0)
121121
iboXID = it->glid;
122-
if (index == 2)
122+
if (index == 1)
123123
iboYID = it->glid;
124-
if (index == 3)
124+
if (index == 2)
125125
iboZID = it->glid;
126-
if (index == 4)
126+
if (index == 3)
127127
iboNegXID = it->glid;
128-
if (index == 5)
128+
if (index == 4)
129129
iboNegYID = it->glid;
130-
if (index == 6)
130+
if (index == 5)
131131
iboNegZID = it->glid;
132132
}
133133

@@ -144,21 +144,15 @@ class RenderColorMapSysTrans :
144144

145145
if (orZ == absDir.x())
146146
{
147-
iboID = iboXID;
148-
if (currentDir.x() < orZ)
149-
iboID = iboNegXID;
147+
iboID = currentDir.x() < orZ ? iboNegXID : iboXID;
150148
}
151149
if (orZ == absDir.y())
152150
{
153-
iboID = iboYID;
154-
if (currentDir.y() < orZ)
155-
iboID = iboNegYID;
151+
iboID = currentDir.y() < orZ ? iboNegYID : iboYID;
156152
}
157153
if (orZ == absDir.z())
158154
{
159-
iboID = iboZID;
160-
if (currentDir.z() < orZ)
161-
iboID = iboNegZID;
155+
iboID = currentDir.z() < orZ ? iboNegZID : iboZID;
162156
}
163157

164158
// Setup *everything*. We don't want to enter multiple conditional

0 commit comments

Comments
 (0)