@@ -32,26 +32,21 @@ namespace QgsRayCastingUtils
3232
3333 Ray3D::Ray3D ()
3434 : m_direction( 0 .0f , 0 .0f , 1 .0f )
35- , m_distance( 1 .0f )
3635 {
3736 }
3837
39- Ray3D::Ray3D ( const QVector3D & origin, const QVector3D & direction, float distance )
38+ Ray3D::Ray3D ( QVector3D origin, QVector3D direction, float distance )
4039 : m_origin( origin )
4140 , m_direction( direction )
4241 , m_distance( distance )
4342 {}
4443
45- Ray3D::~Ray3D ()
46- {
47- }
48-
4944 QVector3D Ray3D::origin () const
5045 {
5146 return m_origin;
5247 }
5348
54- void Ray3D::setOrigin ( const QVector3D & value )
49+ void Ray3D::setOrigin ( QVector3D value )
5550 {
5651 m_origin = value;
5752 }
@@ -61,7 +56,7 @@ namespace QgsRayCastingUtils
6156 return m_direction;
6257 }
6358
64- void Ray3D::setDirection ( const QVector3D & value )
59+ void Ray3D::setDirection ( QVector3D value )
6560 {
6661 if ( value.isNull () )
6762 return ;
@@ -107,7 +102,7 @@ namespace QgsRayCastingUtils
107102 return !( *this == other );
108103 }
109104
110- bool Ray3D::contains ( const QVector3D & point ) const
105+ bool Ray3D::contains ( QVector3D point ) const
111106 {
112107 QVector3D ppVec ( point - m_origin );
113108 if ( ppVec.isNull () ) // point coincides with origin
@@ -126,22 +121,22 @@ namespace QgsRayCastingUtils
126121 return contains ( ray.origin () );
127122 }
128123
129- float Ray3D::projectedDistance ( const QVector3D & point ) const
124+ float Ray3D::projectedDistance ( QVector3D point ) const
130125 {
131126 Q_ASSERT ( !m_direction.isNull () );
132127
133128 return QVector3D::dotProduct ( point - m_origin, m_direction ) /
134129 m_direction.lengthSquared ();
135130 }
136131
137- QVector3D Ray3D::project ( const QVector3D & vector ) const
132+ QVector3D Ray3D::project ( QVector3D vector ) const
138133 {
139134 QVector3D norm = m_direction.normalized ();
140135 return QVector3D::dotProduct ( vector, norm ) * norm;
141136 }
142137
143138
144- float Ray3D::distance ( const QVector3D & point ) const
139+ float Ray3D::distance ( QVector3D point ) const
145140 {
146141 float t = projectedDistance ( point );
147142 return ( point - ( m_origin + t * m_direction ) ).length ();
@@ -198,7 +193,7 @@ struct ray
198193// https://tavianator.com/fast-branchless-raybounding-box-intersections/
199194// https://tavianator.com/fast-branchless-raybounding-box-intersections-part-2-nans/
200195
201- bool intersection ( box b, ray r )
196+ bool intersection ( const box & b, const ray & r )
202197{
203198 double t1 = ( b.min [0 ] - r.origin [0 ] ) * r.dir_inv [0 ];
204199 double t2 = ( b.max [0 ] - r.origin [0 ] ) * r.dir_inv [0 ];
@@ -253,9 +248,9 @@ namespace QgsRayCastingUtils
253248// copied from intersectsSegmentTriangle() from qt3d/src/render/backend/triangleboundingvolume.cpp
254249// by KDAB, licensed under the terms of LGPL
255250 bool rayTriangleIntersection ( const Ray3D &ray,
256- const QVector3D & a,
257- const QVector3D & b,
258- const QVector3D & c,
251+ QVector3D a,
252+ QVector3D b,
253+ QVector3D c,
259254 QVector3D &uvw,
260255 float &t )
261256 {
@@ -305,7 +300,7 @@ namespace QgsRayCastingUtils
305300
306301
307302
308- static QRect windowViewport ( const QSize & area, const QRectF &relativeViewport )
303+ static QRect windowViewport ( QSize area, const QRectF &relativeViewport )
309304{
310305 if ( area.isValid () )
311306 {
@@ -320,8 +315,8 @@ static QRect windowViewport( const QSize &area, const QRectF &relativeViewport )
320315}
321316
322317
323- static QgsRayCastingUtils::Ray3D intersectionRay ( const QPointF & pos, const QMatrix4x4 &viewMatrix,
324- const QMatrix4x4 &projectionMatrix, const QRect & viewport )
318+ static QgsRayCastingUtils::Ray3D intersectionRay ( QPointF pos, const QMatrix4x4 &viewMatrix,
319+ const QMatrix4x4 &projectionMatrix, QRect viewport )
325320{
326321 // if something seems wrong slightly off with the returned intersection rays,
327322 // it may be the case that unproject() has hit qFuzzyIsNull() condition inside
@@ -342,8 +337,8 @@ static QgsRayCastingUtils::Ray3D intersectionRay( const QPointF &pos, const QMat
342337namespace QgsRayCastingUtils
343338{
344339
345- Ray3D rayForViewportAndCamera ( const QSize & area,
346- const QPointF & pos,
340+ Ray3D rayForViewportAndCamera ( QSize area,
341+ QPointF pos,
347342 const QRectF &relativeViewport,
348343 const Qt3DRender::QCamera *camera )
349344 {
0 commit comments