diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2019-10-15 09:40:09 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2019-10-15 10:00:08 +0200 |
commit | 0ff2215bb0ea479a9de3e87d2cee27454c1bbda5 (patch) | |
tree | 946178a0625dd940fcbf1d784f7fe731f91ac528 /src/render/frontend/sphere_p.h | |
parent | 0ce9f6a41571a938dde47f7f068d7fce76288813 (diff) | |
parent | 7339e9ae93df3720e1b936dd027d821105020bc4 (diff) |
Merge "Merge remote-tracking branch 'origin/5.13' into 5.14"
Diffstat (limited to 'src/render/frontend/sphere_p.h')
-rw-r--r-- | src/render/frontend/sphere_p.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/render/frontend/sphere_p.h b/src/render/frontend/sphere_p.h index 10cf92091..b7585f85a 100644 --- a/src/render/frontend/sphere_p.h +++ b/src/render/frontend/sphere_p.h @@ -69,7 +69,7 @@ class Q_3DRENDERSHARED_PRIVATE_EXPORT Sphere : public RayCasting::BoundingSphere public: inline Sphere(Qt3DCore::QNodeId i = Qt3DCore::QNodeId()) : m_center() - , m_radius(0.0f) + , m_radius(-1.0f) , m_id(i) {} @@ -82,7 +82,7 @@ public: void setCenter(const Vector3D &c); Vector3D center() const override; - inline bool isNull() { return m_center == Vector3D() && m_radius == 0.0f; } + bool isNull() const { return m_center == Vector3D() && m_radius == -1.0f; } void setRadius(float r); float radius() const override; @@ -131,7 +131,9 @@ inline Vector3D Sphere::center() const inline void Sphere::setRadius(float r) { - m_radius = r; + Q_ASSERT(r >= 0.0f); + if (r >= 0.0f) + m_radius = r; } inline float Sphere::radius() const @@ -142,11 +144,14 @@ inline float Sphere::radius() const inline void Sphere::clear() { m_center = Vector3D(); - m_radius = 0.0f; + m_radius = -1.0f; } inline bool intersects(const Sphere &a, const Sphere &b) { + if (a.isNull() || b.isNull()) + return false; + // Calculate squared distance between sphere centers const Vector3D d = a.center() - b.center(); const float distSq = Vector3D::dotProduct(d, d); |