Skip to content

Commit

Permalink
- fixed several compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
janbender committed Apr 16, 2020
1 parent 5376b9f commit 1cb0cd8
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 36 deletions.
11 changes: 6 additions & 5 deletions CMake/Common.cmake
Expand Up @@ -33,11 +33,10 @@ if (MSVC)
set(CMAKE_USE_RELATIVE_PATHS "1")
# Set compiler flags
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MP /bigobj")
set(CMAKE_CXX_FLAGS_RELEASE "/MD /MP /Ox /Ob2 /Oi /Ot /D NDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /Zi /MP /Ox /Ob2 /Oi /Ot /D NDEBUG /bigobj")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO")
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO")
set(CMAKE_CXX_FLAGS_RELEASE "/MD /MP /Ox /Ob2 /Oi /Ot /fp:fast /D NDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /Zi /MP /Ox /Ob2 /Oi /Ot /fp:fast /D NDEBUG /bigobj")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/INCREMENTAL")
endif (MSVC)

if (UNIX OR MINGW)
Expand All @@ -57,7 +56,9 @@ endif()

set (CMAKE_CXX_STANDARD 11)

if (MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
endif(MSVC)

OPTION(USE_DOUBLE_PRECISION "Use double precision" ON)
if (USE_DOUBLE_PRECISION)
Expand Down
1 change: 1 addition & 0 deletions Changelog.txt
@@ -1,3 +1,4 @@
- fixed several compiler warnings
- removed MiniBall dependency
- update to Eigen 3.3.7

Expand Down
10 changes: 5 additions & 5 deletions Demos/Visualization/MiniGL.cpp
Expand Up @@ -189,7 +189,7 @@ void MiniGL::drawCylinder(const Vector3r &a, const Vector3r &b, const float *col
if (vz == 0)
vz = .00000001;
Real v = sqrt(vx*vx + vy*vy + vz*vz);
Real ax = 57.2957795*acos(vz / v);
Real ax = static_cast<Real>(57.2957795)*acos(vz / v);
if (vz < 0.0)
ax = -ax;
Real rx = -vy*vz;
Expand Down Expand Up @@ -924,18 +924,18 @@ void MiniGL::mouseMove (int x, int y)
// translate scene in z direction
if (modifier_key == GLUT_ACTIVE_CTRL)
{
move (0, 0, -(d_x + d_y) / 10.0);
move (0, 0, -(d_x + d_y) / static_cast<Real>(10.0));
}
// translate scene in x/y direction
else if (modifier_key == GLUT_ACTIVE_SHIFT)
{
move (-d_x / 20.0f, -d_y / 20.0, 0);
move (-d_x / static_cast<Real>(20.0), -d_y / static_cast<Real>(20.0), 0);
}
// rotate scene around x, y axis
else if (modifier_key == GLUT_ACTIVE_ALT)
{
rotateX(d_y/ 100.0);
rotateY(-d_x/ 100.0);
rotateX(d_y/ static_cast<Real>(100.0));
rotateY(-d_x/ static_cast<Real>(100.0));
}
}

Expand Down
32 changes: 16 additions & 16 deletions PositionBasedDynamics/PositionBasedRigidBodyDynamics.cpp
Expand Up @@ -90,21 +90,21 @@ void PositionBasedRigidBodyDynamics::computeMatrixK(
// ----------------------------------------------------------------------------------------------
void PositionBasedRigidBodyDynamics::computeMatrixG(const Quaternionr &q, Eigen::Matrix<Real, 4, 3, Eigen::DontAlign> &G)
{
G(0, 0) = -0.5*q.x();
G(0, 1) = -0.5*q.y();
G(0, 2) = -0.5*q.z();
G(0, 0) = -static_cast<Real>(0.5)*q.x();
G(0, 1) = -static_cast<Real>(0.5)*q.y();
G(0, 2) = -static_cast<Real>(0.5)*q.z();

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

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

G(3, 0) = 0.5*q.y();
G(3, 1) = -0.5*q.x();
G(3, 2) = 0.5*q.w();
G(3, 0) = static_cast<Real>(0.5)*q.y();
G(3, 1) = static_cast<Real>(-0.5)*q.x();
G(3, 2) = static_cast<Real>(0.5)*q.w();
}

// ----------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -371,13 +371,13 @@ bool PositionBasedRigidBodyDynamics::solve_DistanceJoint(
Real alpha = 0.0;
if (stiffness != 0.0)
{
alpha = 1.0 / (stiffness * dt * dt);
alpha = static_cast<Real>(1.0) / (stiffness * dt * dt);
K += alpha;
}

Real Kinv = 0.0;
if (fabs(K) > static_cast<Real>(1e-6))
Kinv = 1.0 / K;
Kinv = static_cast<Real>(1.0) / K;
else
{
corr_x0.setZero();
Expand Down Expand Up @@ -1609,7 +1609,7 @@ bool PositionBasedRigidBodyDynamics::solve_TargetAngleMotorHingeJoint(
const Quaternionr tmp = (q0.conjugate() * q1);
const Vector4r qVec(tmp.w(), tmp.x(), tmp.y(), tmp.z());
C.block<3, 1>(3, 0) = Pr * qVec;
C(3, 0) -= sin(0.5*targetAngle);
C(3, 0) -= sin(static_cast<Real>(0.5)*targetAngle);


const Vector3r r0 = c0 - x0;
Expand Down Expand Up @@ -2085,7 +2085,7 @@ bool PositionBasedRigidBodyDynamics::velocitySolve_TargetVelocityMotorHingeJoint
Real alpha = 0.0;
if (stiffness != 0.0)
{
alpha = 1.0 / (stiffness * dt * dt);
alpha = static_cast<Real>(1.0) / (stiffness * dt * dt);
K(0,0) += alpha;
}

Expand Down
18 changes: 9 additions & 9 deletions Simulation/BoundingSphere.h
Expand Up @@ -47,8 +47,8 @@ namespace PBD
{
const Vector3r ba = b - a;

m_x = (a + b) * 0.5;
m_r = 0.5 * ba.norm();
m_x = (a + b) * static_cast<Real>(0.5);
m_r = static_cast<Real>(0.5) * ba.norm();
}

/**
Expand All @@ -69,9 +69,9 @@ namespace PBD
ca[0], ca[1], ca[2],
baxca[0], baxca[1], baxca[2];

r[0] = 0.5 * ba.squaredNorm();
r[1] = 0.5 * ca.squaredNorm();
r[2] = 0.0;
r[0] = static_cast<Real>(0.5) * ba.squaredNorm();
r[1] = static_cast<Real>(0.5) * ca.squaredNorm();
r[2] = static_cast<Real>(0.0);

m_x = T.inverse() * r;
m_r = m_x.norm();
Expand All @@ -97,9 +97,9 @@ namespace PBD
ca[0], ca[1], ca[2],
da[0], da[1], da[2];

r[0] = 0.5 * ba.squaredNorm();
r[1] = 0.5 * ca.squaredNorm();
r[2] = 0.5 * da.squaredNorm();
r[0] = static_cast<Real>(0.5) * ba.squaredNorm();
r[1] = static_cast<Real>(0.5) * ca.squaredNorm();
r[2] = static_cast<Real>(0.5) * da.squaredNorm();
m_x = T.inverse() * r;
m_r = m_x.norm();
m_x += a;
Expand Down Expand Up @@ -189,7 +189,7 @@ namespace PBD
}

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

/**
Expand Down
2 changes: 1 addition & 1 deletion Utils/Logger.h
Expand Up @@ -12,7 +12,7 @@

namespace Utilities
{
enum LogLevel { DEBUG=0, INFO, WARN, ERR };
enum class LogLevel { DEBUG=0, INFO, WARN, ERR };

class LogSink
{
Expand Down

0 comments on commit 1cb0cd8

Please sign in to comment.