Skip to content

Commit 1cb0cd8

Browse files
committed
- fixed several compiler warnings
1 parent 5376b9f commit 1cb0cd8

File tree

6 files changed

+38
-36
lines changed

6 files changed

+38
-36
lines changed

CMake/Common.cmake

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ if (MSVC)
3333
set(CMAKE_USE_RELATIVE_PATHS "1")
3434
# Set compiler flags
3535
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MP /bigobj")
36-
set(CMAKE_CXX_FLAGS_RELEASE "/MD /MP /Ox /Ob2 /Oi /Ot /D NDEBUG")
37-
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /Zi /MP /Ox /Ob2 /Oi /Ot /D NDEBUG /bigobj")
38-
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO")
39-
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO")
40-
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO")
36+
set(CMAKE_CXX_FLAGS_RELEASE "/MD /MP /Ox /Ob2 /Oi /Ot /fp:fast /D NDEBUG")
37+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /Zi /MP /Ox /Ob2 /Oi /Ot /fp:fast /D NDEBUG /bigobj")
38+
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL")
39+
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/INCREMENTAL")
4140
endif (MSVC)
4241

4342
if (UNIX OR MINGW)
@@ -57,7 +56,9 @@ endif()
5756

5857
set (CMAKE_CXX_STANDARD 11)
5958

59+
if (MSVC)
6060
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
61+
endif(MSVC)
6162

6263
OPTION(USE_DOUBLE_PRECISION "Use double precision" ON)
6364
if (USE_DOUBLE_PRECISION)

Changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
- fixed several compiler warnings
12
- removed MiniBall dependency
23
- update to Eigen 3.3.7
34

Demos/Visualization/MiniGL.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ void MiniGL::drawCylinder(const Vector3r &a, const Vector3r &b, const float *col
189189
if (vz == 0)
190190
vz = .00000001;
191191
Real v = sqrt(vx*vx + vy*vy + vz*vz);
192-
Real ax = 57.2957795*acos(vz / v);
192+
Real ax = static_cast<Real>(57.2957795)*acos(vz / v);
193193
if (vz < 0.0)
194194
ax = -ax;
195195
Real rx = -vy*vz;
@@ -924,18 +924,18 @@ void MiniGL::mouseMove (int x, int y)
924924
// translate scene in z direction
925925
if (modifier_key == GLUT_ACTIVE_CTRL)
926926
{
927-
move (0, 0, -(d_x + d_y) / 10.0);
927+
move (0, 0, -(d_x + d_y) / static_cast<Real>(10.0));
928928
}
929929
// translate scene in x/y direction
930930
else if (modifier_key == GLUT_ACTIVE_SHIFT)
931931
{
932-
move (-d_x / 20.0f, -d_y / 20.0, 0);
932+
move (-d_x / static_cast<Real>(20.0), -d_y / static_cast<Real>(20.0), 0);
933933
}
934934
// rotate scene around x, y axis
935935
else if (modifier_key == GLUT_ACTIVE_ALT)
936936
{
937-
rotateX(d_y/ 100.0);
938-
rotateY(-d_x/ 100.0);
937+
rotateX(d_y/ static_cast<Real>(100.0));
938+
rotateY(-d_x/ static_cast<Real>(100.0));
939939
}
940940
}
941941

PositionBasedDynamics/PositionBasedRigidBodyDynamics.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,21 @@ void PositionBasedRigidBodyDynamics::computeMatrixK(
9090
// ----------------------------------------------------------------------------------------------
9191
void PositionBasedRigidBodyDynamics::computeMatrixG(const Quaternionr &q, Eigen::Matrix<Real, 4, 3, Eigen::DontAlign> &G)
9292
{
93-
G(0, 0) = -0.5*q.x();
94-
G(0, 1) = -0.5*q.y();
95-
G(0, 2) = -0.5*q.z();
93+
G(0, 0) = -static_cast<Real>(0.5)*q.x();
94+
G(0, 1) = -static_cast<Real>(0.5)*q.y();
95+
G(0, 2) = -static_cast<Real>(0.5)*q.z();
9696

97-
G(1, 0) = 0.5*q.w();
98-
G(1, 1) = 0.5*q.z();
99-
G(1, 2) = -0.5*q.y();
97+
G(1, 0) = static_cast<Real>(0.5)*q.w();
98+
G(1, 1) = static_cast<Real>(0.5)*q.z();
99+
G(1, 2) = static_cast<Real>(-0.5)*q.y();
100100

101-
G(2, 0) = -0.5*q.z();
102-
G(2, 1) = 0.5*q.w();
103-
G(2, 2) = 0.5*q.x();
101+
G(2, 0) = static_cast<Real>(-0.5)*q.z();
102+
G(2, 1) = static_cast<Real>(0.5)*q.w();
103+
G(2, 2) = static_cast<Real>(0.5)*q.x();
104104

105-
G(3, 0) = 0.5*q.y();
106-
G(3, 1) = -0.5*q.x();
107-
G(3, 2) = 0.5*q.w();
105+
G(3, 0) = static_cast<Real>(0.5)*q.y();
106+
G(3, 1) = static_cast<Real>(-0.5)*q.x();
107+
G(3, 2) = static_cast<Real>(0.5)*q.w();
108108
}
109109

110110
// ----------------------------------------------------------------------------------------------
@@ -371,13 +371,13 @@ bool PositionBasedRigidBodyDynamics::solve_DistanceJoint(
371371
Real alpha = 0.0;
372372
if (stiffness != 0.0)
373373
{
374-
alpha = 1.0 / (stiffness * dt * dt);
374+
alpha = static_cast<Real>(1.0) / (stiffness * dt * dt);
375375
K += alpha;
376376
}
377377

378378
Real Kinv = 0.0;
379379
if (fabs(K) > static_cast<Real>(1e-6))
380-
Kinv = 1.0 / K;
380+
Kinv = static_cast<Real>(1.0) / K;
381381
else
382382
{
383383
corr_x0.setZero();
@@ -1609,7 +1609,7 @@ bool PositionBasedRigidBodyDynamics::solve_TargetAngleMotorHingeJoint(
16091609
const Quaternionr tmp = (q0.conjugate() * q1);
16101610
const Vector4r qVec(tmp.w(), tmp.x(), tmp.y(), tmp.z());
16111611
C.block<3, 1>(3, 0) = Pr * qVec;
1612-
C(3, 0) -= sin(0.5*targetAngle);
1612+
C(3, 0) -= sin(static_cast<Real>(0.5)*targetAngle);
16131613

16141614

16151615
const Vector3r r0 = c0 - x0;
@@ -2085,7 +2085,7 @@ bool PositionBasedRigidBodyDynamics::velocitySolve_TargetVelocityMotorHingeJoint
20852085
Real alpha = 0.0;
20862086
if (stiffness != 0.0)
20872087
{
2088-
alpha = 1.0 / (stiffness * dt * dt);
2088+
alpha = static_cast<Real>(1.0) / (stiffness * dt * dt);
20892089
K(0,0) += alpha;
20902090
}
20912091

Simulation/BoundingSphere.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ namespace PBD
4747
{
4848
const Vector3r ba = b - a;
4949

50-
m_x = (a + b) * 0.5;
51-
m_r = 0.5 * ba.norm();
50+
m_x = (a + b) * static_cast<Real>(0.5);
51+
m_r = static_cast<Real>(0.5) * ba.norm();
5252
}
5353

5454
/**
@@ -69,9 +69,9 @@ namespace PBD
6969
ca[0], ca[1], ca[2],
7070
baxca[0], baxca[1], baxca[2];
7171

72-
r[0] = 0.5 * ba.squaredNorm();
73-
r[1] = 0.5 * ca.squaredNorm();
74-
r[2] = 0.0;
72+
r[0] = static_cast<Real>(0.5) * ba.squaredNorm();
73+
r[1] = static_cast<Real>(0.5) * ca.squaredNorm();
74+
r[2] = static_cast<Real>(0.0);
7575

7676
m_x = T.inverse() * r;
7777
m_r = m_x.norm();
@@ -97,9 +97,9 @@ namespace PBD
9797
ca[0], ca[1], ca[2],
9898
da[0], da[1], da[2];
9999

100-
r[0] = 0.5 * ba.squaredNorm();
101-
r[1] = 0.5 * ca.squaredNorm();
102-
r[2] = 0.5 * da.squaredNorm();
100+
r[0] = static_cast<Real>(0.5) * ba.squaredNorm();
101+
r[1] = static_cast<Real>(0.5) * ca.squaredNorm();
102+
r[2] = static_cast<Real>(0.5) * da.squaredNorm();
103103
m_x = T.inverse() * r;
104104
m_r = m_x.norm();
105105
m_x += a;
@@ -189,7 +189,7 @@ namespace PBD
189189
}
190190

191191
m_x = S.m_x;
192-
m_r = S.m_r + epsilon; //add epsilon to make sure that all non-pertubated points are inside the sphere
192+
m_r = S.m_r + static_cast<Real>(epsilon); //add epsilon to make sure that all non-pertubated points are inside the sphere
193193
}
194194

195195
/**

Utils/Logger.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace Utilities
1414
{
15-
enum LogLevel { DEBUG=0, INFO, WARN, ERR };
15+
enum class LogLevel { DEBUG=0, INFO, WARN, ERR };
1616

1717
class LogSink
1818
{

0 commit comments

Comments
 (0)