mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:38:02 +02:00
make polyline's with faceCamera not depend on normal
This commit is contained in:
parent
7fa676a846
commit
834e44dd3a
4 changed files with 26 additions and 17 deletions
|
@ -165,8 +165,9 @@ void LaserPointer::RenderState::update(const glm::vec3& origin, const glm::vec3&
|
||||||
if (!getPathID().isNull()) {
|
if (!getPathID().isNull()) {
|
||||||
EntityItemProperties properties;
|
EntityItemProperties properties;
|
||||||
QVector<glm::vec3> points;
|
QVector<glm::vec3> points;
|
||||||
points.append(origin);
|
points.append(glm::vec3(0.0f));
|
||||||
points.append(end);
|
points.append(end - origin);
|
||||||
|
properties.setPosition(origin);
|
||||||
properties.setLinePoints(points);
|
properties.setLinePoints(points);
|
||||||
properties.setVisible(true);
|
properties.setVisible(true);
|
||||||
properties.setIgnorePickIntersection(doesPathIgnorePicks());
|
properties.setIgnorePickIntersection(doesPathIgnorePicks());
|
||||||
|
|
|
@ -128,7 +128,8 @@ void PolyLineEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPo
|
||||||
}
|
}
|
||||||
|
|
||||||
// Data
|
// Data
|
||||||
if (faceCamera != _faceCamera || glow != _glow) {
|
bool faceCameraChanged = faceCamera != _faceCamera;
|
||||||
|
if (faceCameraChanged || glow != _glow) {
|
||||||
_faceCamera = faceCamera;
|
_faceCamera = faceCamera;
|
||||||
_glow = glow;
|
_glow = glow;
|
||||||
updateData();
|
updateData();
|
||||||
|
@ -148,7 +149,7 @@ void PolyLineEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPo
|
||||||
_colors = entity->getStrokeColors();
|
_colors = entity->getStrokeColors();
|
||||||
_color = toGlm(entity->getColor());
|
_color = toGlm(entity->getColor());
|
||||||
}
|
}
|
||||||
if (_isUVModeStretch != isUVModeStretch || pointsChanged || widthsChanged || normalsChanged || colorsChanged || textureChanged) {
|
if (_isUVModeStretch != isUVModeStretch || pointsChanged || widthsChanged || normalsChanged || colorsChanged || textureChanged || faceCameraChanged) {
|
||||||
_isUVModeStretch = isUVModeStretch;
|
_isUVModeStretch = isUVModeStretch;
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
}
|
}
|
||||||
|
@ -220,11 +221,17 @@ void PolyLineEntityRenderer::updateGeometry() {
|
||||||
// For last point we can assume binormals are the same since it represents the last two vertices of quad
|
// For last point we can assume binormals are the same since it represents the last two vertices of quad
|
||||||
if (i < maxNumVertices - 1) {
|
if (i < maxNumVertices - 1) {
|
||||||
glm::vec3 tangent = _points[i + 1] - point;
|
glm::vec3 tangent = _points[i + 1] - point;
|
||||||
binormal = glm::normalize(glm::cross(tangent, normal));
|
|
||||||
|
|
||||||
// Check to make sure binormal is not a NAN. If it is, don't add to vertices vector
|
if (_faceCamera) {
|
||||||
if (binormal.x != binormal.x) {
|
// In faceCamera mode, we actually pass the tangent, and recompute the binormal in the shader
|
||||||
continue;
|
binormal = tangent;
|
||||||
|
} else {
|
||||||
|
binormal = glm::normalize(glm::cross(tangent, normal));
|
||||||
|
|
||||||
|
// Check to make sure binormal is not a NAN. If it is, don't add to vertices vector
|
||||||
|
if (binormal.x != binormal.x) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,24 +36,23 @@ void main(void) {
|
||||||
TransformObject obj = getTransformObject();
|
TransformObject obj = getTransformObject();
|
||||||
_distanceFromCenter = -1.0 + 2.0 * evenVertex;
|
_distanceFromCenter = -1.0 + 2.0 * evenVertex;
|
||||||
vec4 position = vec4(vertex.positionAndUCoord.xyz, 1.0);
|
vec4 position = vec4(vertex.positionAndUCoord.xyz, 1.0);
|
||||||
vec3 normal = vertex.normal.xyz;
|
|
||||||
vec3 binormal = vertex.binormalAndHalfWidth.xyz;
|
vec3 binormal = vertex.binormalAndHalfWidth.xyz;
|
||||||
if (_polylineData.faceCameraGlow.x != 0.0) {
|
if (_polylineData.faceCameraGlow.x != 0.0) {
|
||||||
vec4 posEye;
|
vec4 posEye;
|
||||||
vec3 normalEye;
|
vec3 tangentEye;
|
||||||
vec3 binormalEye;
|
|
||||||
<$transformModelToEyePos(cam, obj, position, posEye)$>
|
<$transformModelToEyePos(cam, obj, position, posEye)$>
|
||||||
<$transformModelToEyeDir(cam, obj, normal, normalEye)$>
|
// See comment in RenderablePolyLineEntityItem.cpp: we actually pass in the tangent in faceCamera mode
|
||||||
<$transformModelToEyeDir(cam, obj, binormal, binormalEye)$>
|
<$transformModelToEyeDir(cam, obj, binormal, tangentEye)$>
|
||||||
|
|
||||||
vec3 tangentEye = cross(binormalEye, normalEye);
|
|
||||||
// new normal faces the camera
|
// new normal faces the camera
|
||||||
normalEye = normalize(posEye.xyz);
|
vec3 normalEye = normalize(posEye.xyz);
|
||||||
binormalEye = normalize(cross(normalEye, tangentEye));
|
|
||||||
|
vec3 binormalEye = normalize(cross(normalEye, tangentEye));
|
||||||
posEye.xyz += _distanceFromCenter * vertex.binormalAndHalfWidth.w * binormalEye;
|
posEye.xyz += _distanceFromCenter * vertex.binormalAndHalfWidth.w * binormalEye;
|
||||||
<$transformEyeToClipPos(cam, posEye, gl_Position)$>
|
<$transformEyeToClipPos(cam, posEye, gl_Position)$>
|
||||||
<$transformEyeToWorldDir(cam, normalEye, _normalWS)$>
|
<$transformEyeToWorldDir(cam, normalEye, _normalWS)$>
|
||||||
} else {
|
} else {
|
||||||
|
vec3 normal = vertex.normal.xyz;
|
||||||
position.xyz += _distanceFromCenter * vertex.binormalAndHalfWidth.w * binormal;
|
position.xyz += _distanceFromCenter * vertex.binormalAndHalfWidth.w * binormal;
|
||||||
<$transformModelToClipPos(cam, obj, position, gl_Position)$>
|
<$transformModelToClipPos(cam, obj, position, gl_Position)$>
|
||||||
<$transformModelToWorldDir(cam, obj, normal, _normalWS)$>
|
<$transformModelToWorldDir(cam, obj, normal, _normalWS)$>
|
||||||
|
|
|
@ -1013,6 +1013,8 @@ SelectionDisplay = (function() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We want to first check the drawInFront overlays (i.e. the handles, but really everything except the selectionBoxes)
|
||||||
|
// so that you can click on them even when they're behind things
|
||||||
var overlayIncludesLayered = overlayIncludes.filter(function (value, index, arr) {
|
var overlayIncludesLayered = overlayIncludes.filter(function (value, index, arr) {
|
||||||
return value != selectionBox && value != iconSelectionBox;
|
return value != selectionBox && value != iconSelectionBox;
|
||||||
});
|
});
|
||||||
|
@ -1023,7 +1025,7 @@ SelectionDisplay = (function() {
|
||||||
return value == selectionBox || value == iconSelectionBox;
|
return value == selectionBox || value == iconSelectionBox;
|
||||||
});
|
});
|
||||||
if (overlayIncludesNonLayered.length > 0) {
|
if (overlayIncludesNonLayered.length > 0) {
|
||||||
intersectObj = Overlays.findRayIntersection(queryRay, true, [], overlayExcludes);
|
intersectObj = Overlays.findRayIntersection(queryRay, true, overlayIncludesNonLayered, overlayExcludes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue