Skip to content

Commit 047190f

Browse files
author
Benjamin Délèze
authored
Merge pull request #6095 from cyberbotics/sync-master-d86ae33e3
Merge master into develop
2 parents af70695 + 8d253a9 commit 047190f

23 files changed

+524
-159
lines changed

docs/reference/changelog-r2023.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ Released on ??
6969
- Fixed bug causing Webots to hang when requesting multiple poses while pose-tracking multiple nodes ([#5952](https://github.com/cyberbotics/webots/pull/5952)).
7070
- Fixed physics state updates of [Solid](solid.md) nodes added to a descendant [`Joint.endPoint`](joint.md) during simulation ([#5961](https://github.com/cyberbotics/webots/pull/5961)).
7171
- Fixed unwanted altitude change when reaching a target waypoint in `mavic2pro_patrol.c` ([#5981](https://github.com/cyberbotics/webots/pull/5981)).
72+
- Fixed the extern controller connection to a target Webots instance when a snap one is running. ([#6002](https://github.com/cyberbotics/webots/pull/6002)).
73+
- Fixed various issues related to the camera's [Recognition](recognition.md) functionality including image annotations in case of spherical and cylindrical projections ([#5967](https://github.com/cyberbotics/webots/pull/5967)).
74+
- Fixed [Camera](camera.md) segmentation image if a [Lens](lens.md) is defined. ([#5967](https://github.com/cyberbotics/webots/pull/5967)).
75+
- Fixed detected object information not available when moving the mouse over the [Camera](camera.md) overlay after the controller termination if [Recognition.occlusion](recognition.md) is set to FALSE. ([#5967](https://github.com/cyberbotics/webots/pull/5967)).
7276
- Fixed the extern controller connection to a target Webots instance when a snap one is running ([#6002](https://github.com/cyberbotics/webots/pull/6002)).
7377
- Fixed the double downloading of meshes ([#6034](https://github.com/cyberbotics/webots/pull/6034)).
7478
- Fixed generation of moment of inertia matrix based on bounding box ([#6048](https://github.com/cyberbotics/webots/pull/6048)).

src/webots/maths/WbAffinePlane.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ void WbAffinePlane::from3Points(const WbVector3 &P, const WbVector3 &Q, const Wb
2323
mC = u[0] * v[1] - u[1] * v[0];
2424
// Compute the scalar product of u cross v with OP
2525
mD = mA * P.x() + mB * P.y() + mC * P.z();
26+
normalize();
2627
}

src/webots/maths/WbAffinePlane.hpp

Lines changed: 9 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
#define WB_AFFINE_PLANE_HPP
1717

1818
//
19-
// Description: data structure for a 3D affine plane defined by the equation ax + by + cz = d
19+
// Description: data structure for a 3D affine plane defined by the equation ax + by + cz = d.
20+
// Normal vector (a, b, c) is a unit vector.
2021
//
2122

2223
#include <cmath>
@@ -29,13 +30,12 @@ class WbAffinePlane {
2930

3031
// construct from coefficients
3132
WbAffinePlane(const WbAffinePlane &other) : mA(other.mA), mB(other.mB), mC(other.mC), mD(other.mD) {}
32-
WbAffinePlane(double a, double b, double c, double d) : mA(a), mB(b), mC(c), mD(d) {}
33-
explicit WbAffinePlane(const double p[4]) : mA(p[0]), mB(p[1]), mC(p[2]), mD(p[3]) {}
3433
// construct from a normal vector and a scalar
35-
WbAffinePlane(const WbVector3 &v, double d) : mA(v.x()), mB(v.y()), mC(v.z()), mD(d) {}
34+
WbAffinePlane(const WbVector3 &v, double d) : mA(v.x()), mB(v.y()), mC(v.z()), mD(d) { normalize(); }
3635
// construct from a normal vector and a point
3736
WbAffinePlane(const WbVector3 &v, const WbVector3 &P) {
3837
mA = v.x(), mB = v.y(), mC = v.z(), mD = v.x() * P.x() + v.y() * P.y() + v.z() * P.z();
38+
normalize();
3939
}
4040
// construct from 3 points
4141
WbAffinePlane(const WbVector3 &P, const WbVector3 &Q, const WbVector3 &R) { from3Points(P, Q, R); }
@@ -49,68 +49,9 @@ class WbAffinePlane {
4949
double d() const { return mD; }
5050
WbVector3 normal() const { return WbVector3(mA, mB, mC); }
5151

52-
// setters
53-
void setA(double a) { mA = a; }
54-
void setB(double b) { mB = b; }
55-
void setC(double c) { mC = c; }
56-
void setD(double d) { mD = d; }
57-
58-
//
59-
void redefine(double a, double b, double c, double d) {
60-
mA = a;
61-
mB = b;
62-
mC = c;
63-
mD = d;
64-
}
65-
void redefine(const double p[4]) {
66-
mA = p[0];
67-
mB = p[1];
68-
mC = p[2];
69-
mD = p[3];
70-
}
71-
void redefine(const WbVector3 &P, const WbVector3 &Q, const WbVector3 &R) { from3Points(P, Q, R); }
7252
void redefine(const WbVector3 &v, const WbVector3 &P) {
7353
mA = v.x(), mB = v.y(), mC = v.z(), mD = v.x() * P.x() + v.y() * P.y() + v.z() * P.z();
74-
}
75-
// normalize
76-
void normalize();
77-
78-
// 3 special planes
79-
void setXZ() {
80-
mA = 0.0;
81-
mB = 1.0;
82-
mC = 0.0;
83-
mD = 0.0;
84-
}
85-
void setXZ(double d) {
86-
mA = 0.0;
87-
mB = 1.0;
88-
mC = 0.0;
89-
mD = d;
90-
}
91-
void setXY() {
92-
mA = 0.0;
93-
mB = 0.0;
94-
mC = 1.0;
95-
mD = 0.0;
96-
}
97-
void setXY(double d) {
98-
mA = 0.0;
99-
mB = 0.0;
100-
mC = 1.0;
101-
mD = d;
102-
}
103-
void setYZ() {
104-
mA = 1.0;
105-
mB = 0.0;
106-
mC = 0.0;
107-
mD = 0.0;
108-
}
109-
void setYZ(double d) {
110-
mA = 1.0;
111-
mB = 0.0;
112-
mC = 0.0;
113-
mD = d;
54+
normalize();
11455
}
11556

11657
// assignment: P1 = P2
@@ -123,17 +64,16 @@ class WbAffinePlane {
12364
}
12465

12566
// pseudo-distance to a 3D point
126-
// this is the signed distance from P to the plane if (a, b, c) is a unit vector, the sign is positive if P lies in the upper
127-
// plane determined by (a, b, c) and negative otherwise.
67+
// this is the signed distance from P to the plane,
68+
// the sign is positive if P lies in the upper plane determined by (a, b, c) and negative otherwise.
12869
double distance(const WbVector3 &v) const { return mA * v.x() + mB * v.y() + mC * v.z() - mD; }
129-
double distance(const double v[3]) const { return mA * v[0] + mB * v[1] + mC * v[2] - mD; }
130-
double distance(double x, double y, double z) const { return mA * x + mB * y + mC * z - mD; }
13170

13271
// project a vector on this plane, returns the project vector
133-
WbVector3 vectorProjection(const WbVector3 &v) const { return v - normal() * (v.dot(normal()) / normal().length2()); }
72+
WbVector3 vectorProjection(const WbVector3 &v) const { return v + normal() * v.dot(normal()); }
13473

13574
private:
13675
double mA, mB, mC, mD;
76+
void normalize();
13777
};
13878

13979
inline void WbAffinePlane::normalize() {

src/webots/nodes/WbAbstractCamera.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,9 @@ void WbAbstractCamera::createWrenCamera() {
508508
bool enableAntiAliasing = antiAliasing() && !WbPreferences::instance()->value("OpenGL/disableAntiAliasing", true).toBool();
509509
mWrenCamera = new WbWrenCamera(wrenNode(), width(), height(), nearValue(), minRange(), maxRange(), fieldOfView(), mCharType,
510510
enableAntiAliasing, mProjection->value());
511+
}
512+
513+
void WbAbstractCamera::applyCameraSettings() {
511514
updateBackground();
512515

513516
connect(mWrenCamera, &WbWrenCamera::cameraInitialized, this, &WbAbstractCamera::applyCameraSettingsToWren);
@@ -795,7 +798,6 @@ void WbAbstractCamera::applyFrustumToWren() {
795798
const float w = width();
796799
const float h = height();
797800
const float fovX = mFieldOfView->value();
798-
const float fovY = WbWrenCamera::computeFieldOfViewY(fovX, w / h); // fovX -> fovY
799801
const float t = tanf(fovX / 2.0f);
800802
const float dw1 = n * t;
801803
const float dh1 = dw1 * h / w;
@@ -853,12 +855,13 @@ void WbAbstractCamera::applyFrustumToWren() {
853855
const float zero[3] = {0.0f, 0.0f, 0.0f};
854856
// Creation of the external outline of the frustum (4 lines)
855857
if (!isPlanarProjection()) {
858+
const float fovY = WbWrenCamera::computeFieldOfViewY(fovX, w / h); // fovX -> fovY
856859
const float angleY[4] = {-fovY / 2.0f, -fovY / 2.0f, fovY / 2.0f, fovY / 2.0f};
857860
const float angleX[4] = {fovX / 2.0f, -fovX / 2.0f, -fovX / 2.0f, fovX / 2.0f};
858861
for (int k = 0; k < 4; ++k) {
859862
const float helper = cosf(angleY[k]);
860863
// get x, y and z from the spherical coordinates
861-
float y = 0.0f;
864+
float y;
862865
if (angleY[k] > M_PI_4 || angleY[k] < -M_PI_4)
863866
y = f * cosf(angleY[k] + M_PI_2) * sinf(angleX[k]);
864867
else

src/webots/nodes/WbAbstractCamera.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ class WbAbstractCamera : public WbRenderingDevice {
120120

121121
virtual int size() const = 0;
122122

123+
void applyCameraSettings();
124+
123125
// Wren methods
124126
virtual void createWrenCamera();
125127
void createWrenOverlay() override;
@@ -183,7 +185,7 @@ protected slots:
183185
void updateMotionBlur();
184186
void updateNoise();
185187
void updateLens();
186-
void applyLensToWren();
188+
virtual void applyLensToWren();
187189
void removeInvisibleNodeFromList(QObject *node);
188190

189191
virtual void updateFrustumDisplayIfNeeded(int optionalRendering) {}

0 commit comments

Comments
 (0)