Skip to content

Commit

Permalink
Fix build errors on Windows + VS2022
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 committed May 29, 2022
1 parent 51e458a commit 712368c
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 51 deletions.
50 changes: 50 additions & 0 deletions dart/common/IncludeWindows.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2011-2022, The DART development contributors
* All rights reserved.
*
* The list of contributors can be found at:
* https://github.com/dartsim/dart/blob/master/LICENSE
*
* This file is provided under the following "BSD-style" License:
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef DART_COMMON_INCLUDEWINDOWS_HPP_
#define DART_COMMON_INCLUDEWINDOWS_HPP_

#ifdef _WIN32
#ifdef NOMINMAX
#include <windows.h>
#undef near
#undef far
#else
#define NOMINMAX
#include <windows.h>
#undef NOMINMAX
#undef near
#undef far
#endif
#endif

#endif // DART_COMMON_INCLUDEWINDOWS_HPP_
8 changes: 1 addition & 7 deletions dart/common/SharedLibrary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,7 @@

#elif DART_OS_WINDOWS

#ifdef NOMINMAX
#include <windows.h>
#else
#define NOMINMAX
#include <windows.h>
#undef NOMINMAX
#endif
#include "dart/common/IncludeWindows.hpp"
using hInstance = HINSTANCE__*;
#define DYNLIB_HANDLE hInstance

Expand Down
20 changes: 7 additions & 13 deletions dart/common/Timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,7 @@
#include <string>

#ifdef _WIN32
#ifdef NOMINMAX
#include <windows.h>
#else
#define NOMINMAX
#include <windows.h>
#undef NOMINMAX
#endif
typedef struct
{
LARGE_INTEGER start;
LARGE_INTEGER stop;
} stopWatch;
#include "dart/common/IncludeWindows.hpp"
#else
#include <sys/time.h>
#endif
Expand Down Expand Up @@ -101,7 +90,12 @@ class DART_DEPRECATED(6.13) Timer
int mCount;

#ifdef _WIN32
stopWatch mTimer;
struct StopWatch
{
LARGE_INTEGER start;
LARGE_INTEGER stop;
};
StopWatch mTimer;
#else
timeval mTimeVal;
double mStartedTime;
Expand Down
4 changes: 4 additions & 0 deletions dart/common/detail/SharedLibraryManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#include "dart/common/Filesystem.hpp"
#include "dart/common/Singleton.hpp"

#ifndef _WIN32

namespace std {

template <>
Expand All @@ -54,6 +56,8 @@ struct hash<::dart::common::filesystem::path>

} // namespace std

#endif

namespace dart {
namespace common {

Expand Down
5 changes: 5 additions & 0 deletions dart/constraint/ConstraintSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,13 @@ bool ConstraintSolver::containSkeleton(const ConstSkeletonPtr& skeleton) const
//==============================================================================
bool ConstraintSolver::hasSkeleton(const ConstSkeletonPtr& skeleton) const
{
#if _WIN32
DART_ASSERT(
skeleton != nullptr && "Not allowed to insert null pointer skeleton.");
#else
DART_ASSERT(
skeleton != nullptr, "Not allowed to insert null pointer skeleton.");
#endif

for (const auto& itrSkel : mSkeletons)
{
Expand Down
8 changes: 1 addition & 7 deletions dart/gui/LoadOpengl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@
#define DART_GUI_LOADOPENGL_HPP_

#if defined(_WIN32)
#ifdef NOMINMAX
#include <windows.h>
#else
#define NOMINMAX
#include <windows.h>
#undef NOMINMAX
#endif
#include "dart/common/IncludeWindows.hpp"
#include <GL/gl.h>
#include <GL/glu.h>
#elif defined(__linux__)
Expand Down
22 changes: 11 additions & 11 deletions dart/gui/osg/DefaultEventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ Eigen::Vector3d DefaultEventHandler::getDeltaCursor(
::osg::Vec3d eye, center, up;
mViewer->getCamera()->getViewMatrixAsLookAt(eye, center, up);

Eigen::Vector3d near, far;
getNearAndFarPointUnderCursor(near, far);
Eigen::Vector3d v1 = far - near;
Eigen::Vector3d nearPt, farPt;
getNearAndFarPointUnderCursor(nearPt, farPt);
Eigen::Vector3d v1 = farPt - nearPt;

if (LINE_CONSTRAINT == _constraint)
{
const Eigen::Vector3d& b1 = near;
const Eigen::Vector3d& b1 = nearPt;
const Eigen::Vector3d& v2 = _constraintVector;
const Eigen::Vector3d& b2 = _fromPosition;

Expand All @@ -131,22 +131,22 @@ Eigen::Vector3d DefaultEventHandler::getDeltaCursor(
else if (PLANE_CONSTRAINT == _constraint)
{
const Eigen::Vector3d& n = _constraintVector;
double s = n.dot(_fromPosition - near) / n.dot(v1);
return near - _fromPosition + s * v1;
double s = n.dot(_fromPosition - nearPt) / n.dot(v1);
return nearPt - _fromPosition + s * v1;
}
else
{
Eigen::Vector3d n = osgToEigVec3(center - eye);
double s = n.dot(_fromPosition - near) / n.dot(v1);
return near - _fromPosition + s * v1;
double s = n.dot(_fromPosition - nearPt) / n.dot(v1);
return nearPt - _fromPosition + s * v1;
}

return Eigen::Vector3d::Zero();
}

//==============================================================================
void DefaultEventHandler::getNearAndFarPointUnderCursor(
Eigen::Vector3d& near, Eigen::Vector3d& far, double distance) const
Eigen::Vector3d& nearPt, Eigen::Vector3d& farPt, double distance) const
{
::osg::Camera* C = mViewer->getCamera();
::osg::Matrix VPW = C->getViewMatrix() * C->getProjectionMatrix()
Expand All @@ -158,8 +158,8 @@ void DefaultEventHandler::getNearAndFarPointUnderCursor(
auto osgNear = ::osg::Vec3d(x, y, 0.0) * invVPW;
auto osgFar = ::osg::Vec3d(x, y, distance) * invVPW;

near = osgToEigVec3(osgNear);
far = osgToEigVec3(osgFar);
nearPt = osgToEigVec3(osgNear);
farPt = osgToEigVec3(osgFar);
}

//==============================================================================
Expand Down
2 changes: 1 addition & 1 deletion dart/gui/osg/TrackballManipulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace osg {
// and dart::gui::osg, we need to explicitly specify the root namespace osg as
// ::osg

class OSGGA_EXPORT TrackballManipulator : public ::osgGA::OrbitManipulator
class TrackballManipulator : public ::osgGA::OrbitManipulator
{
public:
/// Constructor
Expand Down
2 changes: 1 addition & 1 deletion dart/gui/osg/render/MeshShapeNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ void MeshShapeGeometry::extractData(bool firstTime)
// Load textures on the first pass through
if (firstTime)
{
uint unit = 0;
unsigned int unit = 0;
const aiVector3D* aiTexCoords = mAiMesh->mTextureCoords[unit];

while (nullptr != aiTexCoords)
Expand Down
13 changes: 3 additions & 10 deletions python/dartpy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,15 @@ endif()
# Find pybind11, including PythonInterp and PythonLibs
# Needs to set PYBIND11_PYTHON_VERSION before finding pybind11
set(PYBIND11_PYTHON_VERSION ${DARTPY_PYTHON_VERSION})
if(WIN32)
set(PYBIND11_FINDPYTHON TRUE)
endif()
find_package(pybind11 2.2.0 QUIET)
if(NOT pybind11_FOUND)
message(WARNING "Disabling [dartpy] due to missing pybind11 >= 2.2.0.")
return()
endif()

if(NOT PythonInterp_FOUND AND NOT PYTHONINTERP_FOUND)
message(WARNING "Disabling [dartpy] due to missing [PythonInterp].")
return()
endif()

if(NOT PythonLibs_FOUND AND NOT PYTHONLIBS_FOUND)
message(WARNING "Disabling [dartpy] due to missing [PythonLibs].")
return()
endif()

execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
"from distutils.sysconfig import get_python_lib;\
print(get_python_lib(plat_specific=True, prefix=''))"
Expand Down
2 changes: 1 addition & 1 deletion python/dartpy/gui/osg/GUIEventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class PyGUIEventHandler final : public GUIEventHandlerNoRef
{
public:
// Inherit the constructors
using GUIEventHandlerNoRef::GUIEventHandler;
using GUIEventHandlerNoRef::GUIEventHandlerNoRef;

// Trampoline for virtual function
bool handle(
Expand Down

0 comments on commit 712368c

Please sign in to comment.