-
Notifications
You must be signed in to change notification settings - Fork 21
Conversation
Better PR and commit message would be: Implement axis and legend for full volume box 'is working' is assumed at this point :P |
@@ -80,6 +80,11 @@ class Frustum : public Frustumf | |||
LIVRECORE_API Matrix4f getMVPMatrix() const; | |||
|
|||
/** | |||
* @return The normal matrix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't state the obvious. What's the normal matrix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The normal matrix is for normals what modelview matrix is for vertices. I don't know a better name.
Everyone call that normal matrix. In old OpenGL it was called gl_NormalMatrix for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function name is fine, but repeating it in doxygen is not. What about @return the inverse transposed model-view matrix
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Done.
@@ -294,6 +294,11 @@ bool EventHandler< C >::handleEvent( const eq::EventType type, | |||
frameSettings.toggleStatistics(); | |||
return true; | |||
|
|||
case 'a': | |||
case 'A': | |||
_impl->config.getFrameData().getRenderSettings().toogleDrawAxis(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo toggle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
_axis.draw(); | ||
|
||
glUseProgram( 0 ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactor if scope into method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -156,6 +168,7 @@ struct RayCastRenderer::Impl | |||
_nSamplesPerRay = frameData.getVRParameters().getSamplesPerRay(); | |||
_computedSamplesPerRay = _nSamplesPerRay; | |||
_nSamplesPerPixel = frameData.getVRParameters().getSamplesPerPixel(); | |||
_drawAxis = frameData.getRenderSettings().getDrawAxis( ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a comment, i.e., don't change: This is useless dynamic state. Better design would be to pass the frameData state to the method in need of it, instead of duplicating it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the motivation for this duplication was to isolate the renderer from the Equalizer related classes.
{ | ||
for( int32_t i = 0; i < 3; ++i ) | ||
{ | ||
for( int32_t j = 0; j < 4; ++j ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
k-i-j loop nesting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it really matter ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
} | ||
} | ||
|
||
for( uint32_t i = 0; i < vertices.size(); ++i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
size_t
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Erm, I just wanted to unblock PR, not approve. Still learning the new UI here... Somebody else please approve. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will continue tomorrow
@@ -156,6 +168,7 @@ struct RayCastRenderer::Impl | |||
_nSamplesPerRay = frameData.getVRParameters().getSamplesPerRay(); | |||
_computedSamplesPerRay = _nSamplesPerRay; | |||
_nSamplesPerPixel = frameData.getVRParameters().getSamplesPerPixel(); | |||
_drawAxis = frameData.getRenderSettings().getDrawAxis( ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the motivation for this duplication was to isolate the renderer from the Equalizer related classes.
LBASSERT( program ); | ||
glUseProgram( program ); | ||
|
||
GLint tParamNameGL = glGetUniformLocation( program, "renderTexture" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tParamNameGL -> location?
Unless it's inconsistent with the style all around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's everywhere like that... Unless I change it everywhere in Livre I will keep it like that
flat in uint type; | ||
|
||
// http://www.opengl.org/wiki/Compute_eye_space_from_window_space. | ||
vec4 calcPositionInEyeSpaceFromWindowSpace( vec4 windowSpace ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you pass the eye position from the vertex shader? I know that increasing the number of variables passed between shader limits the scalability, but that's not an issue for the axis rendering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the fragment position in eye coordinate, not the camera position.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understood that, my point is that in the vertex shader you can multiply the vertex coordinate by the modelview and pass that to the fragment shader. Then you don't need to unproject here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't get it... I need to multiply vertex coordinate by modelViewProjectionMatrix otherwise my fragments positions will be wrong.
|
||
vec4 dst = imageLoad( renderTexture, ivec2( gl_FragCoord.xy )); | ||
|
||
if( type == 1 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is type 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I put a #define in the shader AXIS = 1 so it's like the enum in c++ code.
if( type == 1 ) | ||
{ | ||
if(!((( dot( pixelEyeSpacePos, normal ) <= 0.0 ) && ( dot( pixelEyeSpacePos, normal2 ) <= 0.0 )) || | ||
(( dot( pixelEyeSpacePos, normal ) >= 0.0 ) && ( dot( pixelEyeSpacePos, normal2 ) >= 0.0 )))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment that explains what all these operations are checking would be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the dot products out of the if and assign them to a const variable. You have the same operation 3 times. This is not about efficiency as much as about readability.
Also I prefer avoiding expressions like !(.....) if they can be rewritten without the !.
In this example you have:
!(( A <= 0 && B <= 0 ) || ( A >=0 && B >= 0))
!( A <= 0 && B <= 0 ) && !( A >= 0 && B >= 0)
( A >= 0 || B >= 0) && ( A <= 0 || B <= 0)
As you can see, there are also unnecessary parenthesis around the comparison operations, which I think don't help making the expression clearer.
A <= 0 and A >= 0 are one the negation of the other, do you need both comparisons to test for equality to 0? Could you replace both with a single variable a A >= 0 (normalPointsForward, or something similar) and use A and !A instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get the "Could you replace both with a single variable a A >= 0 (normalPointsForward, or something similar)"
The code looks like that now:
if(( dotNormal > 0.0 ) && ( dotNormal2 < 0.0 ) ||
( dotNormal < 0.0 ) && ( dotNormal2 > 0.0 ))
float tickSize = 0; | ||
|
||
const float rangeLenght = range.y() - range.x(); | ||
const float rawTickLenght = rangeLenght / maxTickNumber; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit lost with these names. This is the distance between tickets in volume coordinates, why do you call it rawTickLength?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. This is the distance between ticks if you don't do the 1 2 5 fitting magic... it's why I called it "raw". It's an abstract intermediate mathematical result... I am not sure a better name can be found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tickDistanceHint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
const float z = volInfo.worldSize.z() * 0.5f; | ||
|
||
_createLocalTicks( volInfo, { -x, -y, z }, { x, -y, z }, { 0, 1, 0 }, { 0, 0, -1 }, | ||
false, tickSize, factor, vertices, normals, normals2, colors, types ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a struct for all the parameters that do not change (including volInfo).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why ? Maybe I don't undestand the comment because for me if I add a struct it will only increase the size of code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Vector3f posOnAxis = start + axisDir * ( worldSpaceOffset + worldSpaceTickSize * i ); | ||
vertices.push_back( posOnAxis.x( )); | ||
vertices.push_back( posOnAxis.y( )); | ||
vertices.push_back( posOnAxis.z( )); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
write a helper funtion to write: append(vertices, posOnAxis)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
false, tickSize, factor, vertices, normals, normals2, colors, types ); | ||
_createLocalTicks( volInfo, { -x, -y, z }, { x, -y, z }, { 0, 0, -1 }, { 0, 1, 0 }, | ||
true, tickSize, factor, vertices, normals, normals2, colors, types ); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write a comment before each block to know which face are you adding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
glGenBuffers( 1, &_typeBufferId ); | ||
glBindBuffer( GL_ARRAY_BUFFER, _typeBufferId ); | ||
glBufferData( GL_ARRAY_BUFFER, sizeof(GLubyte) * types.size(), | ||
&types[0], GL_STATIC_DRAW ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally, a single VBO is used for all the data so you don't have to rebind a new buffer to set each vertex attrib pointer. You can use glBufferSubData to upload the pieces one by one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Strange, I thought that dismissing the review would put the PR in a non-mergeable state, but that's not the case (at least I can merge it, I don't know if @chevtche can) |
Retest this please |
glUniformMatrix4fv( tParamNameGL, 1, false, frustum.getNormalMatrix( ).array ); | ||
|
||
tParamNameGL = glGetUniformLocation( program, "invProjectionMatrix" ); | ||
glUniformMatrix4fv( tParamNameGL, 1, false, frustum.getInvProjMatrix( ).array ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After removing calcPositionInEyeSpaceFromWindowSpace you don't need this, do you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I need it in the shader.
"vec3 pixelWorldSpacePos = vec3(( invModelViewMatrix * pixelEyeSpacePos ).xyz );"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But not for the axis, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, done.
} | ||
|
||
// There is a possible optimization here, it is possible to append directly | ||
// in the code lines [ 50 - 89 ]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why aren't you doing it? It seems trivial and you reduce the verbosity of the code. You can do it simply by:
std::vector< Vector3f >& vertices = bbAxisData.vertices;
....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This technique will not work for bbAxisData.normals, bbAxisData.normals2, bbAxisData.color, bbAxisData.types. There is a way to do it for everything in the loop but it will take more time and the code will be even more complicated. Here you are only copying 48 vertexes...
I just put a comment for future work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the comment then, the optimization is quite negligible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Done.
You should have done a new commit for the CR changes, now it's difficult to keep track of what you changed. |
currentAxis = Vector3f( end - start ).find_min_index(); | ||
|
||
const Vector2f range = _computeRange( bbAxisData.volInfo, currentAxis ); | ||
const float rangeLenght = range.y() - range.x(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still same typo: Lenght -> Length
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
const Vector2f range = _computeRange( bbAxisData.volInfo, currentAxis ); | ||
const float rangeLenght = range.y() - range.x(); | ||
|
||
const float worldSpaceLenght = start.distance( end ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And also here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
if( flipTick ) | ||
sign = -(( 0.0f < cross[ tickAxis ]) - ( cross[ tickAxis ] < 0.0f )); | ||
else | ||
sign = ( 0.0f < cross[ tickAxis ]) - ( cross[ tickAxis ] < 0.0f ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace lines 312-325 by:
int sign = ( 0.0f < cross[ tickAxis ]) - ( cross[ tickAxis ] < 0.0f );
if( flipTick )
sign = -sign;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
container.push_back( vector.x( )); | ||
container.push_back( vector.y( )); | ||
container.push_back( vector.z( )); | ||
container.push_back( vector.w( )); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the _appendXdVector functions free functions inside an anonymous namespace, it doesn't make sense to make them member functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why cannot it be a member function ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not that it can't.
When a "member" function doesn't need any state of the object to which it belongs it's better to make it a free function to keep the class interface clean. In this case the member function is even private, so making it a free function contained in the .cpp allows you to change it in the future without touching the .h file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok Done
const Vector2f range = _computeRange( bbAxisData.volInfo, longestBBAxis ); | ||
|
||
const uint32_t maxTickNumber = 50; | ||
const float tickSizes[4] = { 1, 2, 5, 10 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be called tickDistances for consistency, shouldn't it? And the same goes for bbAxisData.tickSize.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed everything to distance.
Retest this please |
Merge or not merge ? |
No description provided.