Commit 93d5e3d6 authored by Frédéric Larue's avatar Frédéric Larue
Browse files

Modification added to SelectionTools to give the possibility, in the case of...

Modification added to SelectionTools to give the possibility, in the case of the SelectionToolDisk, to recover the distance of the selected texels to the cursor trajectory.
parent c52893dd
......@@ -21,6 +21,8 @@ std::string SelectionTool::getSelectionShaderFunctions()
"uniform mat4 u_CameraFullTransform;"
"uniform vec3 u_CameraLocation;"
"float _squareDistanceToCursor = 0.0;"
"vec3 getClippingCoordinates( vec3 objCoordVertex )"
"{"
" vec4 projVert = u_CameraFullTransform * vec4(objCoordVertex,1.0);"
......@@ -46,6 +48,11 @@ std::string SelectionTool::getSelectionShaderFunctions()
" projVert.z -= 0.0001*projVert.w;"
" return textureProj( u_DepthBuffer, projVert ) > 0.5;"
"}"
"float squareDistanceToCursor()"
"{"
" return _squareDistanceToCursor;"
"}";
}
......
......@@ -58,7 +58,8 @@ void SelectionToolDisk::updateCircleVertices()
std::string SelectionToolDisk::getSelectionShaderFunctions()
{
return "uniform vec2 u_DiskCenter;"
return SelectionTool::getSelectionShaderFunctions() +
"uniform vec2 u_DiskCenter;"
"uniform vec2 u_DiskAxis;"
"uniform float u_DiskAxisLen;"
"uniform vec2 u_DiskRadiusInv;"
......@@ -68,10 +69,9 @@ std::string SelectionToolDisk::getSelectionShaderFunctions()
" vec2 toCenter = clipCoordVertex.xy*u_DiskRadiusInv - u_DiskCenter;"
" float distAlongAxis = dot( toCenter, u_DiskAxis );"
" vec2 toSegmentClosestPoint = toCenter - max( min(distAlongAxis,u_DiskAxisLen), 0.0 )*u_DiskAxis;"
" return dot(toSegmentClosestPoint,toSegmentClosestPoint) <= 1.0;"
"}"
+ SelectionTool::getSelectionShaderFunctions();
" _squareDistanceToCursor = dot( toSegmentClosestPoint, toSegmentClosestPoint );"
" return _squareDistanceToCursor <= 1.0;"
"}";
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment