Skip to content

Commit 6a1eff5

Browse files
committed
Edges work when they aren't transparent.
This is now at the same state as the slower transparency.
1 parent b9eec5c commit 6a1eff5

File tree

4 files changed

+58
-30
lines changed

4 files changed

+58
-30
lines changed

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

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ namespace SCIRun {
378378
Core::Geometry::Vector dir(0.0, 0.0, 0.0);
379379

380380
std::vector<DepthIndex> rel_depth(num_triangles);
381-
for (int i = 0; i < 6; ++i)
381+
for (int i = 0; i <= 6; ++i)
382382
{
383383
std::string name = ibo.name;
384384

@@ -387,62 +387,69 @@ namespace SCIRun {
387387
dir = Core::Geometry::Vector(1.0, 0.0, 0.0);
388388
name += "X";
389389
}
390-
else if (i == 1)
390+
if (i == 1)
391391
{
392392
dir = Core::Geometry::Vector(0.0, 1.0, 0.0);
393393
name += "Y";
394394
}
395-
else if (i == 2)
395+
if (i == 2)
396396
{
397397
dir = Core::Geometry::Vector(0.0, 0.0, 1.0);
398398
name += "Z";
399399
}
400-
else if (i == 3)
400+
if (i == 3)
401401
{
402402
dir = Core::Geometry::Vector(-1.0, 0.0, 0.0);
403403
name += "NegX";
404404
}
405-
else if (i == 4)
405+
if (i == 4)
406406
{
407407
dir = Core::Geometry::Vector(0.0, -1.0, 0.0);
408408
name += "NegY";
409409
}
410-
else if (i == 5)
410+
if (i == 5)
411411
{
412412
dir = Core::Geometry::Vector(0.0, 0.0, -1.0);
413413
name += "NegZ";
414414
}
415-
416-
for (size_t j = 0; j < num_triangles; j++)
415+
if (i < 6)
417416
{
418-
float* vertex1 = reinterpret_cast<float*>(vbo_buffer[nameIndex] + stride_vbo[nameIndex] * (ibo_buffer[j * 3]));
419-
Core::Geometry::Point node1(vertex1[0], vertex1[1], vertex1[2]);
417+
for (size_t j = 0; j < num_triangles; j++)
418+
{
419+
float* vertex1 = reinterpret_cast<float*>(vbo_buffer[nameIndex] + stride_vbo[nameIndex] * (ibo_buffer[j * 3]));
420+
Core::Geometry::Point node1(vertex1[0], vertex1[1], vertex1[2]);
420421

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

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

427-
rel_depth[j].mDepth = Core::Geometry::Dot(dir, node1) + Core::Geometry::Dot(dir, node2) + Core::Geometry::Dot(dir, node3);
428-
rel_depth[j].mIndex = j;
429-
}
428+
rel_depth[j].mDepth = Core::Geometry::Dot(dir, node1) + Core::Geometry::Dot(dir, node2) + Core::Geometry::Dot(dir, node3);
429+
rel_depth[j].mIndex = j;
430+
}
431+
432+
std::sort(rel_depth.begin(), rel_depth.end());
430433

431-
std::sort(rel_depth.begin(), rel_depth.end());
434+
int numPrimitives = ibo.data->getBufferSize() / ibo.indexSize;
432435

433-
int numPrimitives = ibo.data->getBufferSize() / ibo.indexSize;
436+
std::vector<char> sorted_buffer(ibo.data->getBufferSize());
437+
char* ibuffer = reinterpret_cast<char*>(ibo.data->getBuffer());
438+
char* sbuffer = reinterpret_cast<char*>(&sorted_buffer[0]);
439+
size_t tri_size = ibo.data->getBufferSize() / num_triangles;
434440

435-
std::vector<char> sorted_buffer(ibo.data->getBufferSize());
436-
char* ibuffer = reinterpret_cast<char*>(ibo.data->getBuffer());
437-
char* sbuffer = reinterpret_cast<char*>(&sorted_buffer[0]);
438-
size_t tri_size = ibo.data->getBufferSize() / num_triangles;
441+
for (size_t j = 0; j < num_triangles; j++)
442+
{
443+
memcpy(sbuffer + j * tri_size, ibuffer + rel_depth[j].mIndex * tri_size, tri_size);
444+
}
439445

440-
for (size_t j = 0; j < num_triangles; j++)
446+
iboMan.addInMemoryIBO(sbuffer, ibo.data->getBufferSize(), primitive, primType, numPrimitives, name);
447+
}
448+
else
441449
{
442-
memcpy(sbuffer + j * tri_size, ibuffer + rel_depth[j].mIndex * tri_size, tri_size);
450+
int numPrimitives = ibo.data->getBufferSize() / ibo.indexSize;
451+
iboMan.addInMemoryIBO(ibo.data->getBuffer(), ibo.data->getBufferSize(), primitive, primType, numPrimitives, ibo.name);
443452
}
444-
445-
iboMan.addInMemoryIBO(sbuffer, ibo.data->getBufferSize(), primitive, primType, numPrimitives, name);
446453
}
447454
}
448455

@@ -464,7 +471,7 @@ namespace SCIRun {
464471
{
465472
//reorderIBO(pass);
466473
addVBOToEntity(entityID, pass.vboName);
467-
for (int i = 0; i < 6; ++i)
474+
for (int i = 0; i <= 6; ++i)
468475
{
469476
std::string name = pass.iboName;
470477
if (i == 0)

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ class RenderBasicSys :
103103
return;
104104
}
105105

106+
GLuint iboID = ibo.front().glid;
107+
108+
int index = 0;
109+
for (auto it = ibo.begin(); it != ibo.end(); ++it, ++index)
110+
{
111+
if (index == 6)
112+
iboID = it->glid;
113+
}
114+
106115
// Setup *everything*. We don't want to enter multiple conditional
107116
// statements if we can avoid it. So we assume everything has not been
108117
// setup (including uniforms) if the simple geom hasn't been setup.
@@ -158,7 +167,7 @@ class RenderBasicSys :
158167

159168
// Bind VBO and IBO
160169
GL(glBindBuffer(GL_ARRAY_BUFFER, vbo.front().glid));
161-
GL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo.front().glid));
170+
GL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, iboID));
162171

163172
bool depthMask = glIsEnabled(GL_DEPTH_WRITEMASK);
164173
bool cullFace = glIsEnabled(GL_CULL_FACE);

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ class RenderColorMapSys :
103103
return;
104104
}
105105

106+
GLuint iboID = ibo.front().glid;
107+
108+
int index = 0;
109+
for (auto it = ibo.begin(); it != ibo.end(); ++it, ++index)
110+
{
111+
if (index == 6)
112+
iboID = it->glid;
113+
}
114+
106115
// Setup *everything*. We don't want to enter multiple conditional
107116
// statements if we can avoid it. So we assume everything has not been
108117
// setup (including uniforms) if the simple geom hasn't been setup.
@@ -158,7 +167,7 @@ class RenderColorMapSys :
158167

159168
// Bind VBO and IBO
160169
GL(glBindBuffer(GL_ARRAY_BUFFER, vbo.front().glid));
161-
GL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo.front().glid));
170+
GL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, iboID));
162171

163172
// Bind any common uniforms.
164173
if (commonUniforms.size() > 0)

src/Modules/Visualization/ShowField.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ void ShowFieldModule::renderFacesLinear(
420420
//TODO fix so the withNormals tp be woth lighting is called correctly, and the meshes are fixed.
421421
if (withNormals)
422422
{
423+
/// Fix normal of Quads
423424
if (points.size() == 4)
424425
{
425426
Core::Geometry::Vector edge1 = points[1] - points[0];
@@ -436,6 +437,7 @@ void ShowFieldModule::renderFacesLinear(
436437
normals[i] = norm;
437438
}
438439
}
440+
/// Fix Normals of Tris
439441
else
440442
{
441443
Core::Geometry::Vector edge1 = points[1] - points[0];
@@ -448,6 +450,7 @@ void ShowFieldModule::renderFacesLinear(
448450
{
449451
normals[i] = norm;
450452
}
453+
//For future reference for a try at smoother rendering
451454
/*
452455
for (size_t i = 0; i < nodes.size(); i++)
453456
{

0 commit comments

Comments
 (0)