mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 10:47:11 +02:00
Merge pull request #14026 from huffman/fix/edit-rotation
Fix edit rotation handle fidgeting
This commit is contained in:
commit
ef063a4072
2 changed files with 33 additions and 32 deletions
|
@ -74,7 +74,7 @@ void Circle3DOverlay::render(RenderArgs* args) {
|
||||||
|
|
||||||
const float FULL_CIRCLE = 360.0f;
|
const float FULL_CIRCLE = 360.0f;
|
||||||
const float SLICES = 180.0f; // The amount of segment to create the circle
|
const float SLICES = 180.0f; // The amount of segment to create the circle
|
||||||
const float SLICE_ANGLE = FULL_CIRCLE / SLICES;
|
const float SLICE_ANGLE_RADIANS = glm::radians(FULL_CIRCLE / SLICES);
|
||||||
const float MAX_COLOR = 255.0f;
|
const float MAX_COLOR = 255.0f;
|
||||||
|
|
||||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
|
@ -111,28 +111,38 @@ void Circle3DOverlay::render(RenderArgs* args) {
|
||||||
vec4 innerEndColor = vec4(toGlm(_innerEndColor), _innerEndAlpha) * pulseModifier;
|
vec4 innerEndColor = vec4(toGlm(_innerEndColor), _innerEndAlpha) * pulseModifier;
|
||||||
vec4 outerEndColor = vec4(toGlm(_outerEndColor), _outerEndAlpha) * pulseModifier;
|
vec4 outerEndColor = vec4(toGlm(_outerEndColor), _outerEndAlpha) * pulseModifier;
|
||||||
|
|
||||||
|
const auto startAtRadians = glm::radians(_startAt);
|
||||||
|
const auto endAtRadians = glm::radians(_endAt);
|
||||||
|
|
||||||
|
const auto totalRange = _endAt - _startAt;
|
||||||
if (_innerRadius <= 0) {
|
if (_innerRadius <= 0) {
|
||||||
_solidPrimitive = gpu::TRIANGLE_FAN;
|
_solidPrimitive = gpu::TRIANGLE_FAN;
|
||||||
points << vec2();
|
points << vec2();
|
||||||
colors << innerStartColor;
|
colors << innerStartColor;
|
||||||
for (float angle = _startAt; angle <= _endAt; angle += SLICE_ANGLE) {
|
for (float angleRadians = startAtRadians; angleRadians < endAtRadians; angleRadians += SLICE_ANGLE_RADIANS) {
|
||||||
float range = (angle - _startAt) / (_endAt - _startAt);
|
float range = (angleRadians - startAtRadians) / totalRange;
|
||||||
float angleRadians = glm::radians(angle);
|
|
||||||
points << glm::vec2(cosf(angleRadians) * _outerRadius, sinf(angleRadians) * _outerRadius);
|
points << glm::vec2(cosf(angleRadians) * _outerRadius, sinf(angleRadians) * _outerRadius);
|
||||||
colors << glm::mix(outerStartColor, outerEndColor, range);
|
colors << glm::mix(outerStartColor, outerEndColor, range);
|
||||||
}
|
}
|
||||||
|
points << glm::vec2(cosf(endAtRadians) * _outerRadius, sinf(endAtRadians) * _outerRadius);
|
||||||
|
colors << outerEndColor;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_solidPrimitive = gpu::TRIANGLE_STRIP;
|
_solidPrimitive = gpu::TRIANGLE_STRIP;
|
||||||
for (float angle = _startAt; angle <= _endAt; angle += SLICE_ANGLE) {
|
for (float angleRadians = startAtRadians; angleRadians < endAtRadians; angleRadians += SLICE_ANGLE_RADIANS) {
|
||||||
float range = (angle - _startAt) / (_endAt - _startAt);
|
float range = (angleRadians - startAtRadians) / totalRange;
|
||||||
|
|
||||||
float angleRadians = glm::radians(angle);
|
|
||||||
points << glm::vec2(cosf(angleRadians) * _innerRadius, sinf(angleRadians) * _innerRadius);
|
points << glm::vec2(cosf(angleRadians) * _innerRadius, sinf(angleRadians) * _innerRadius);
|
||||||
colors << glm::mix(innerStartColor, innerEndColor, range);
|
colors << glm::mix(innerStartColor, innerEndColor, range);
|
||||||
|
|
||||||
points << glm::vec2(cosf(angleRadians) * _outerRadius, sinf(angleRadians) * _outerRadius);
|
points << glm::vec2(cosf(angleRadians) * _outerRadius, sinf(angleRadians) * _outerRadius);
|
||||||
colors << glm::mix(outerStartColor, outerEndColor, range);
|
colors << glm::mix(outerStartColor, outerEndColor, range);
|
||||||
}
|
}
|
||||||
|
points << glm::vec2(cosf(endAtRadians) * _innerRadius, sinf(endAtRadians) * _innerRadius);
|
||||||
|
colors << innerEndColor;
|
||||||
|
|
||||||
|
points << glm::vec2(cosf(endAtRadians) * _outerRadius, sinf(endAtRadians) * _outerRadius);
|
||||||
|
colors << outerEndColor;
|
||||||
}
|
}
|
||||||
geometryCache->updateVertices(_quadVerticesID, points, colors);
|
geometryCache->updateVertices(_quadVerticesID, points, colors);
|
||||||
}
|
}
|
||||||
|
@ -147,29 +157,28 @@ void Circle3DOverlay::render(RenderArgs* args) {
|
||||||
if (geometryChanged) {
|
if (geometryChanged) {
|
||||||
QVector<glm::vec2> points;
|
QVector<glm::vec2> points;
|
||||||
|
|
||||||
float angle = _startAt;
|
const auto startAtRadians = glm::radians(_startAt);
|
||||||
float angleInRadians = glm::radians(angle);
|
const auto endAtRadians = glm::radians(_endAt);
|
||||||
glm::vec2 firstPoint(cosf(angleInRadians) * _outerRadius, sinf(angleInRadians) * _outerRadius);
|
|
||||||
|
float angleRadians = startAtRadians;
|
||||||
|
glm::vec2 firstPoint(cosf(angleRadians) * _outerRadius, sinf(angleRadians) * _outerRadius);
|
||||||
points << firstPoint;
|
points << firstPoint;
|
||||||
|
|
||||||
while (angle < _endAt) {
|
while (angleRadians < endAtRadians) {
|
||||||
angle += SLICE_ANGLE;
|
angleRadians += SLICE_ANGLE_RADIANS;
|
||||||
angleInRadians = glm::radians(angle);
|
glm::vec2 thisPoint(cosf(angleRadians) * _outerRadius, sinf(angleRadians) * _outerRadius);
|
||||||
glm::vec2 thisPoint(cosf(angleInRadians) * _outerRadius, sinf(angleInRadians) * _outerRadius);
|
|
||||||
points << thisPoint;
|
points << thisPoint;
|
||||||
|
|
||||||
if (getIsDashedLine()) {
|
if (getIsDashedLine()) {
|
||||||
angle += SLICE_ANGLE / 2.0f; // short gap
|
angleRadians += SLICE_ANGLE_RADIANS / 2.0f; // short gap
|
||||||
angleInRadians = glm::radians(angle);
|
glm::vec2 dashStartPoint(cosf(angleRadians) * _outerRadius, sinf(angleRadians) * _outerRadius);
|
||||||
glm::vec2 dashStartPoint(cosf(angleInRadians) * _outerRadius, sinf(angleInRadians) * _outerRadius);
|
|
||||||
points << dashStartPoint;
|
points << dashStartPoint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the last slice portion....
|
// get the last slice portion....
|
||||||
angle = _endAt;
|
angleRadians = endAtRadians;
|
||||||
angleInRadians = glm::radians(angle);
|
glm::vec2 lastPoint(cosf(angleRadians) * _outerRadius, sinf(angleRadians) * _outerRadius);
|
||||||
glm::vec2 lastPoint(cosf(angleInRadians) * _outerRadius, sinf(angleInRadians) * _outerRadius);
|
|
||||||
points << lastPoint;
|
points << lastPoint;
|
||||||
geometryCache->updateVertices(_lineVerticesID, points, vec4(toGlm(getColor()), getAlpha()));
|
geometryCache->updateVertices(_lineVerticesID, points, vec4(toGlm(getColor()), getAlpha()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2611,6 +2611,10 @@ SelectionDisplay = (function() {
|
||||||
updateSelectionsRotation(rotationChange, rotationCenter);
|
updateSelectionsRotation(rotationChange, rotationCenter);
|
||||||
updateRotationDegreesOverlay(-angleFromZero, rotationDegreesPosition);
|
updateRotationDegreesOverlay(-angleFromZero, rotationDegreesPosition);
|
||||||
|
|
||||||
|
if (direction === ROTATE_DIRECTION.YAW) {
|
||||||
|
angleFromZero *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
var startAtCurrent = 0;
|
var startAtCurrent = 0;
|
||||||
var endAtCurrent = angleFromZero;
|
var endAtCurrent = angleFromZero;
|
||||||
var maxDegrees = 360;
|
var maxDegrees = 360;
|
||||||
|
@ -2622,18 +2626,6 @@ SelectionDisplay = (function() {
|
||||||
startAt: startAtCurrent,
|
startAt: startAtCurrent,
|
||||||
endAt: endAtCurrent
|
endAt: endAtCurrent
|
||||||
});
|
});
|
||||||
|
|
||||||
// not sure why but this seems to be needed to fix an reverse rotation for yaw ring only
|
|
||||||
if (direction === ROTATE_DIRECTION.YAW) {
|
|
||||||
if (spaceMode === SPACE_LOCAL) {
|
|
||||||
Overlays.editOverlay(handleRotateCurrentRing, { rotation: worldRotationZ });
|
|
||||||
} else {
|
|
||||||
var rotationDegrees = 90;
|
|
||||||
Overlays.editOverlay(handleRotateCurrentRing, {
|
|
||||||
rotation: Quat.fromPitchYawRollDegrees(-rotationDegrees, 0, 0)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
|
|
Loading…
Reference in a new issue