Skip to content

Commit 930f401

Browse files
committed
- bugfixes
1 parent 1586c35 commit 930f401

File tree

6 files changed

+180
-164
lines changed

6 files changed

+180
-164
lines changed

CMake/Common.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set(CMAKE_MINSIZEREL_POSTFIX "_ms")
1111
if (WIN32)
1212
set(CMAKE_USE_RELATIVE_PATHS "1")
1313
# Set compiler flags
14-
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MP")
14+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MP")
1515
set(CMAKE_CXX_FLAGS_RELEASE "/MD /MP /Ox /Ob2 /Oi /Ot /D NDEBUG /openmp")
1616
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO")
1717
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO")
@@ -20,6 +20,7 @@ endif (WIN32)
2020

2121
if (UNIX)
2222
set(CMAKE_USE_RELATIVE_PATHS "1")
23+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
2324
# Set compiler flags for "release"
2425
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -fopenmp")
2526
endif (UNIX)

Demos/DistanceFieldDemos/RigidBodyCollisionDemo.cpp

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -266,26 +266,25 @@ void render ()
266266

267267
const VertexData &vd = rb[i]->getGeometry().getVertexData();
268268
const IndexedFaceMesh &mesh = rb[i]->getGeometry().getMesh();
269-
if (shader)
269+
if (rb[i]->getMass() != 0.0)
270270
{
271-
if (rb[i]->getMass() != 0.0)
271+
if (!selected)
272272
{
273-
if (!selected)
274-
{
273+
if (shader)
275274
glUniform3fv(shader->getUniform("surface_color"), 1, surfaceColor);
276-
Visualization::drawMesh(vd, mesh, 0, surfaceColor);
277-
}
278-
else
279-
{
275+
Visualization::drawMesh(vd, mesh, 0, surfaceColor);
276+
}
277+
else
278+
{
279+
if (shader)
280280
glUniform3fv(shader->getUniform("surface_color"), 1, selectionColor);
281-
Visualization::drawMesh(vd, mesh, 0, selectionColor);
282-
}
281+
Visualization::drawMesh(vd, mesh, 0, selectionColor);
283282
}
284283
}
285284
}
286285

287-
if (shaderTex)
288-
shaderTex->end();
286+
if (shader)
287+
shader->end();
289288

290289
if (shaderTex)
291290
{
@@ -312,20 +311,19 @@ void render ()
312311

313312
const VertexData &vd = rb[i]->getGeometry().getVertexData();
314313
const IndexedFaceMesh &mesh = rb[i]->getGeometry().getMesh();
315-
if (shaderTex)
314+
if (rb[i]->getMass() == 0.0)
316315
{
317-
if (rb[i]->getMass() == 0.0)
316+
if (!selected)
318317
{
319-
if (!selected)
320-
{
318+
if (shaderTex)
321319
glUniform3fv(shaderTex->getUniform("surface_color"), 1, staticColor);
322-
Visualization::drawTexturedMesh(vd, mesh, 0, staticColor);
323-
}
324-
else
325-
{
320+
Visualization::drawTexturedMesh(vd, mesh, 0, staticColor);
321+
}
322+
else
323+
{
324+
if (shaderTex)
326325
glUniform3fv(shaderTex->getUniform("surface_color"), 1, selectionColor);
327-
Visualization::drawTexturedMesh(vd, mesh, 0, selectionColor);
328-
}
326+
Visualization::drawTexturedMesh(vd, mesh, 0, selectionColor);
329327
}
330328
}
331329
}

Demos/SceneLoaderDemo/SceneLoaderDemo.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -240,30 +240,30 @@ void mouseMove(int x, int y)
240240

241241
void 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

269269
void 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)

Demos/Simulation/DistanceFieldCollisionDetection.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,13 @@ void DistanceFieldCollisionDetection::collisionDetection(SimulationModel &model)
4545
}
4646

4747
//omp_set_num_threads(1);
48-
std::vector<std::vector<ContactData> > contacts_mt;
49-
contacts_mt.resize(omp_get_max_threads());
48+
std::vector<std::vector<ContactData> > contacts_mt;
49+
#ifdef _DEBUG
50+
const unsigned int maxThreads = 1;
51+
#else
52+
const unsigned int maxThreads = omp_get_max_threads();
53+
#endif
54+
contacts_mt.resize(maxThreads);
5055

5156
#pragma omp parallel default(shared)
5257
{
@@ -206,7 +211,11 @@ void DistanceFieldCollisionDetection::collisionDetectionRigidBodies(RigidBody *r
206211
const Vector3r cp_w = R.transpose() * cp + v2;
207212
const Vector3r n_w = R.transpose() * n;
208213

214+
#ifdef _DEBUG
215+
int tid = 0;
216+
#else
209217
int tid = omp_get_thread_num();
218+
#endif
210219
contacts_mt[tid].push_back({ 0, co1->m_bodyIndex, co2->m_bodyIndex, x_w, cp_w, n_w, dist, restitutionCoeff, frictionCoeff });
211220
}
212221
}
@@ -281,7 +290,11 @@ void DistanceFieldCollisionDetection::collisionDetectionRBSolid(const ParticleDa
281290
const Vector3r cp_w = R.transpose() * cp + v2;
282291
const Vector3r n_w = R.transpose() * n;
283292

293+
#ifdef _DEBUG
294+
int tid = 0;
295+
#else
284296
int tid = omp_get_thread_num();
297+
#endif
285298
contacts_mt[tid].push_back({ 1, index, co2->m_bodyIndex, x_w, cp_w, n_w, dist, restitutionCoeff, frictionCoeff });
286299
}
287300
}

0 commit comments

Comments
 (0)