@@ -240,30 +240,30 @@ void mouseMove(int x, int y)
240240
241241void selection (const Eigen::Vector2i &start, const Eigen::Vector2i &end)
242242{
243- std::vector<unsigned int > hits;
243+ std::vector<unsigned int > hits;
244244
245245 selectedParticles.clear ();
246246 ParticleData &pd = model.getParticles ();
247247 if (pd.size () > 0 )
248248 Selection::selectRect (start, end, &pd.getPosition (0 ), &pd.getPosition (pd.size () - 1 ), selectedParticles);
249249
250- selectedBodies.clear ();
250+ selectedBodies.clear ();
251251 SimulationModel::RigidBodyVector &rb = model.getRigidBodies ();
252252 std::vector<Vector3r, Eigen::aligned_allocator<Vector3r> > x;
253253 x.resize (rb.size ());
254- for (unsigned int i = 0 ; i < rb.size (); i++)
255- {
254+ for (unsigned int i = 0 ; i < rb.size (); i++)
255+ {
256256 x[i] = rb[i]->getPosition ();
257- }
257+ }
258258
259259 if (rb.size () > 0 )
260- Selection::selectRect (start, end, &x[0 ], &x[rb.size () - 1 ], selectedBodies);
260+ Selection::selectRect (start, end, &x[0 ], &x[rb.size () - 1 ], selectedBodies);
261261 if ((selectedBodies.size () > 0 ) || (selectedParticles.size () > 0 ))
262- MiniGL::setMouseMoveFunc (GLUT_MIDDLE_BUTTON, mouseMove);
263- else
264- MiniGL::setMouseMoveFunc (-1 , NULL );
262+ MiniGL::setMouseMoveFunc (GLUT_MIDDLE_BUTTON, mouseMove);
263+ else
264+ MiniGL::setMouseMoveFunc (-1 , NULL );
265265
266- MiniGL::unproject (end[0 ], end[1 ], oldMousePos);
266+ MiniGL::unproject (end[0 ], end[1 ], oldMousePos);
267267}
268268
269269void timeStep ()
@@ -516,27 +516,27 @@ void render ()
516516
517517 const VertexData &vd = rb[i]->getGeometry ().getVertexData ();
518518 const IndexedFaceMesh &mesh = rb[i]->getGeometry ().getMesh ();
519- if (shader )
519+ if (!selected )
520520 {
521- if (!selected )
521+ if (rb[i]-> getMass () == 0.0 )
522522 {
523- if (rb[i]->getMass () == 0.0 )
524- {
523+ if (shader)
525524 glUniform3fv (shader->getUniform (" surface_color" ), 1 , staticColor);
526- Visualization::drawMesh (vd, mesh, 0 , staticColor);
527- }
528- else
529- {
530- glUniform3fv (shader->getUniform (" surface_color" ), 1 , surfaceColor);
531- Visualization::drawMesh (vd, mesh, 0 , surfaceColor);
532- }
525+ Visualization::drawMesh (vd, mesh, 0 , staticColor);
533526 }
534527 else
535528 {
536- glUniform3fv (shader->getUniform (" surface_color" ), 1 , selectionColor);
537- Visualization::drawMesh (vd, mesh, 0 , selectionColor);
529+ if (shader)
530+ glUniform3fv (shader->getUniform (" surface_color" ), 1 , surfaceColor);
531+ Visualization::drawMesh (vd, mesh, 0 , surfaceColor);
538532 }
539533 }
534+ else
535+ {
536+ if (shader)
537+ glUniform3fv (shader->getUniform (" surface_color" ), 1 , selectionColor);
538+ Visualization::drawMesh (vd, mesh, 0 , selectionColor);
539+ }
540540 }
541541
542542 if (shader)
0 commit comments