mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44: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()) {
|
||||
EntityItemProperties properties;
|
||||
QVector<glm::vec3> points;
|
||||
points.append(origin);
|
||||
points.append(end);
|
||||
points.append(glm::vec3(0.0f));
|
||||
points.append(end - origin);
|
||||
properties.setPosition(origin);
|
||||
properties.setLinePoints(points);
|
||||
properties.setVisible(true);
|
||||
properties.setIgnorePickIntersection(doesPathIgnorePicks());
|
||||
|
|
|
@ -128,7 +128,8 @@ void PolyLineEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPo
|
|||
}
|
||||
|
||||
// Data
|
||||
if (faceCamera != _faceCamera || glow != _glow) {
|
||||
bool faceCameraChanged = faceCamera != _faceCamera;
|
||||
if (faceCameraChanged || glow != _glow) {
|
||||
_faceCamera = faceCamera;
|
||||
_glow = glow;
|
||||
updateData();
|
||||
|
@ -148,7 +149,7 @@ void PolyLineEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPo
|
|||
_colors = entity->getStrokeColors();
|
||||
_color = toGlm(entity->getColor());
|
||||
}
|
||||
if (_isUVModeStretch != isUVModeStretch || pointsChanged || widthsChanged || normalsChanged || colorsChanged || textureChanged) {
|
||||
if (_isUVModeStretch != isUVModeStretch || pointsChanged || widthsChanged || normalsChanged || colorsChanged || textureChanged || faceCameraChanged) {
|
||||
_isUVModeStretch = isUVModeStretch;
|
||||
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
|
||||
if (i < maxNumVertices - 1) {
|
||||
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 (binormal.x != binormal.x) {
|
||||
continue;
|
||||
if (_faceCamera) {
|
||||
// In faceCamera mode, we actually pass the tangent, and recompute the binormal in the shader
|
||||
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();
|
||||
_distanceFromCenter = -1.0 + 2.0 * evenVertex;
|
||||
vec4 position = vec4(vertex.positionAndUCoord.xyz, 1.0);
|
||||
vec3 normal = vertex.normal.xyz;
|
||||
vec3 binormal = vertex.binormalAndHalfWidth.xyz;
|
||||
if (_polylineData.faceCameraGlow.x != 0.0) {
|
||||
vec4 posEye;
|
||||
vec3 normalEye;
|
||||
vec3 binormalEye;
|
||||
vec3 tangentEye;
|
||||
<$transformModelToEyePos(cam, obj, position, posEye)$>
|
||||
<$transformModelToEyeDir(cam, obj, normal, normalEye)$>
|
||||
<$transformModelToEyeDir(cam, obj, binormal, binormalEye)$>
|
||||
// See comment in RenderablePolyLineEntityItem.cpp: we actually pass in the tangent in faceCamera mode
|
||||
<$transformModelToEyeDir(cam, obj, binormal, tangentEye)$>
|
||||
|
||||
vec3 tangentEye = cross(binormalEye, normalEye);
|
||||
// new normal faces the camera
|
||||
normalEye = normalize(posEye.xyz);
|
||||
binormalEye = normalize(cross(normalEye, tangentEye));
|
||||
vec3 normalEye = normalize(posEye.xyz);
|
||||
|
||||
vec3 binormalEye = normalize(cross(normalEye, tangentEye));
|
||||
posEye.xyz += _distanceFromCenter * vertex.binormalAndHalfWidth.w * binormalEye;
|
||||
<$transformEyeToClipPos(cam, posEye, gl_Position)$>
|
||||
<$transformEyeToWorldDir(cam, normalEye, _normalWS)$>
|
||||
} else {
|
||||
vec3 normal = vertex.normal.xyz;
|
||||
position.xyz += _distanceFromCenter * vertex.binormalAndHalfWidth.w * binormal;
|
||||
<$transformModelToClipPos(cam, obj, position, gl_Position)$>
|
||||
<$transformModelToWorldDir(cam, obj, normal, _normalWS)$>
|
||||
|
|
|
@ -1013,6 +1013,8 @@ SelectionDisplay = (function() {
|
|||
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) {
|
||||
return value != selectionBox && value != iconSelectionBox;
|
||||
});
|
||||
|
@ -1023,7 +1025,7 @@ SelectionDisplay = (function() {
|
|||
return value == selectionBox || value == iconSelectionBox;
|
||||
});
|
||||
if (overlayIncludesNonLayered.length > 0) {
|
||||
intersectObj = Overlays.findRayIntersection(queryRay, true, [], overlayExcludes);
|
||||
intersectObj = Overlays.findRayIntersection(queryRay, true, overlayIncludesNonLayered, overlayExcludes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue