Skip to content

Commit 2f64c4b

Browse files
Mafo369dlyr
authored andcommitted
[tests] Change transformation logic
1 parent 10be81c commit 2f64c4b

3 files changed

Lines changed: 36 additions & 42 deletions

File tree

examples/CurveEditor/BezierUtils/CubicBezierApproximation.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class CubicBezierApproximation
130130
bool m_hasComputed { false };
131131
int m_dim { 0 };
132132
int m_step { 0 };
133-
float m_distThreshold;
133+
float m_distThreshold { 0.f };
134134
VectorArray<Curve2D::Vector> m_data;
135135
std::vector<float> m_params;
136136
std::set<int> m_bzjunctions;
@@ -174,10 +174,10 @@ class CubicBezierApproximation
174174
int b { (int)( m_data.size() - 1 ) };
175175
float h = ( b - a ) / (float)( nb_junctions - 1 );
176176
std::vector<int> xs( nb_junctions );
177-
typename std::vector<int>::iterator x;
177+
typename std::vector<int>::iterator it;
178178
float val;
179-
for ( x = xs.begin(), val = a; x != xs.end(); ++x, val += h )
180-
*x = (int)val;
179+
for ( it = xs.begin(), val = a; it != xs.end(); ++it, val += h )
180+
*it = (int)val;
181181

182182
for ( int x : xs ) {
183183
m_bzjunctions.insert( x );

examples/CurveEditor/BezierUtils/LeastSquareSystem.hpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class LeastSquareSystem
2929
* @param dimension of the variables (optional)
3030
* @param expected number of constraints (optional)
3131
*/
32-
LeastSquareSystem( int nvar, int dim = 1, int exp_ncstr = 0 ) : m_nvar( nvar ), m_dim( dim ) {
32+
explicit LeastSquareSystem( int nvar, int dim = 1, int exp_ncstr = 0 ) :
33+
m_nvar( nvar ), m_dim( dim ) {
3334
m_constrainedVar.resize( m_nvar, false );
3435
if ( exp_ncstr > 0 ) { m_bval.reserve( exp_ncstr ); }
3536
}
@@ -188,13 +189,6 @@ class LeastSquareSystem
188189
return true;
189190
}
190191

191-
bool simpleCholesky( const SparseMat& A, const VectorXf& b, VectorXf& x ) const {
192-
Eigen::SimplicialCholesky<SparseMat> chol( A.transpose() * A );
193-
if ( chol.info() != Eigen::Success ) { return false; }
194-
x = chol.solve( A.transpose() * b );
195-
return true;
196-
}
197-
198192
bool jacobiSVD( const SparseMat& A, const VectorXf& b, VectorXf& x ) const {
199193
MatrixXf denseA( A );
200194
Eigen::JacobiSVD<MatrixXf> svd( denseA, Eigen::ComputeThinU | Eigen::ComputeThinV );

examples/CurveEditor/CurveEditor.cpp

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ void CurveEditor::updateCurves( bool onRelease ) {
125125
auto oldPoint = pointComponent->m_point;
126126
unsigned int curveIdSize = pointComponent->m_curveId.size();
127127

128-
CurveFactory factory;
129128
m_viewer->makeCurrent();
130129

131130
for ( unsigned int i = 0; i < curveIdSize; i++ ) {
@@ -292,9 +291,9 @@ void CurveEditor::addPointInCurve( const Vector3& worldPos, int mouseX, int mous
292291
auto e = ro->getComponent();
293292

294293
int curveIndex = -1;
295-
for ( int i = 0; i < m_curveEntities.size(); i++ ) {
296-
if ( m_curveEntities[i] == e ) {
297-
curveIndex = i;
294+
for ( int z = 0; z < m_curveEntities.size(); z++ ) {
295+
if ( m_curveEntities[z] == e ) {
296+
curveIndex = z;
298297
break;
299298
}
300299
}
@@ -359,35 +358,14 @@ void CurveEditor::processPicking( const Vector3& worldPos ) {
359358
auto transformTranslate = Transform::Identity();
360359
transformTranslate.translate( worldPos - point );
361360

362-
auto transform = Transform::Identity();
363-
transform = m_selectedRo->getLocalTransform() * transformTranslate;
361+
auto transform = m_selectedRo->getLocalTransform() * transformTranslate;
364362
m_selectedRo->setLocalTransform( transform );
365363

366-
if ( m_smooth && !( m_currentPoint == 0 || m_currentPoint == 1 ||
367-
m_currentPoint == m_pointEntities.size() - 2 ||
368-
m_currentPoint == m_pointEntities.size() - 1 ) ) {
364+
if ( !( m_currentPoint == 0 || m_currentPoint == 1 ||
365+
m_currentPoint == m_pointEntities.size() - 2 ||
366+
m_currentPoint == m_pointEntities.size() - 1 ) ) {
369367

370-
if ( m_currentPoint % 3 == 2 ) {
371-
auto pointMid = m_pointEntities[m_currentPoint + 1];
372-
pointComponent = m_pointEntities[m_currentPoint + 2];
373-
auto symTransform =
374-
computePointTransform( pointComponent, pointMid->m_point, worldPos );
375-
auto ro = m_roMgr->getRenderObject( pointComponent->getRenderObjects()[0] );
376-
ro->setLocalTransform( symTransform );
377-
378-
if ( m_tangentPoints.empty() ) { m_tangentPoints.push_back( m_currentPoint + 2 ); }
379-
}
380-
else if ( m_currentPoint % 3 == 1 ) {
381-
auto pointMid = m_pointEntities[m_currentPoint - 1];
382-
pointComponent = m_pointEntities[m_currentPoint - 2];
383-
auto symTransform =
384-
computePointTransform( pointComponent, pointMid->m_point, worldPos );
385-
auto ro = m_roMgr->getRenderObject( pointComponent->getRenderObjects()[0] );
386-
ro->setLocalTransform( symTransform );
387-
388-
if ( m_tangentPoints.empty() ) { m_tangentPoints.push_back( m_currentPoint - 2 ); }
389-
}
390-
else if ( m_currentPoint % 3 == 0 ) {
368+
if ( m_currentPoint % 3 == 0 ) {
391369
auto leftRo = m_roMgr->getRenderObject(
392370
m_pointEntities[m_currentPoint - 1]->getRenderObjects()[0] );
393371
auto leftTransform = leftRo->getTransform() * transformTranslate;
@@ -403,6 +381,28 @@ void CurveEditor::processPicking( const Vector3& worldPos ) {
403381
m_tangentPoints.push_back( m_currentPoint + 1 );
404382
}
405383
}
384+
else if ( m_smooth ) {
385+
if ( m_currentPoint % 3 == 2 ) {
386+
auto pointMid = m_pointEntities[m_currentPoint + 1];
387+
pointComponent = m_pointEntities[m_currentPoint + 2];
388+
auto symTransform =
389+
computePointTransform( pointComponent, pointMid->m_point, worldPos );
390+
auto ro = m_roMgr->getRenderObject( pointComponent->getRenderObjects()[0] );
391+
ro->setLocalTransform( symTransform );
392+
393+
if ( m_tangentPoints.empty() ) { m_tangentPoints.push_back( m_currentPoint + 2 ); }
394+
}
395+
else if ( m_currentPoint % 3 == 1 ) {
396+
auto pointMid = m_pointEntities[m_currentPoint - 1];
397+
pointComponent = m_pointEntities[m_currentPoint - 2];
398+
auto symTransform =
399+
computePointTransform( pointComponent, pointMid->m_point, worldPos );
400+
auto ro = m_roMgr->getRenderObject( pointComponent->getRenderObjects()[0] );
401+
ro->setLocalTransform( symTransform );
402+
403+
if ( m_tangentPoints.empty() ) { m_tangentPoints.push_back( m_currentPoint - 2 ); }
404+
}
405+
}
406406
}
407407
updateCurves();
408408
}

0 commit comments

Comments
 (0)