diff --git a/.gitignore b/.gitignore index baee1828b8..19dfbefc59 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ CTestTestFile.cmake .vscode/ .idea/ cmake-build-debug/ +build-*/ diff --git a/CMakeLists.txt b/CMakeLists.txt index a695b71726..bc7d153b4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,10 @@ cmake_policy(SET CMP0017 NEW) #this line has to appear before 'PROJECT' in order to be able to disable incremental linking SET(MSVC_INCREMENTAL_DEFAULT ON) +if(TOOLCHAIN_ROOT) + include(MinGW64.cmake) +endif() + PROJECT(BULLET_PHYSICS) FILE (STRINGS "VERSION" BULLET_VERSION) @@ -182,7 +186,7 @@ IF(MSVC) SET(CMAKE_CXX_FLAGS "/GR- ${CMAKE_CXX_FLAGS}") ENDIF(USE_MSVC_DISABLE_RTTI) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244 /wd4267") + #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244 /wd4267") ENDIF(MSVC) @@ -269,11 +273,160 @@ IF (BULLET2_USE_OPEN_MP_MULTITHREADING) ENDIF (MSVC) ENDIF (BULLET2_USE_OPEN_MP_MULTITHREADING) +set(CMAKE_CXX_STANDARD 98) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +IF(MSVC) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4005") # macro redefined + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4061") # enumerator 'value' in switch of enum 'type' is not handled explicitly + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4191") # unsafe conversion of function pointers + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4263 /wd4264 /wd4266") # virtual function override with same name and different arguments + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4316") # 'object': object allocated on the heap may not be aligned n + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4464") # relative include paths + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4505") # unreferenced function with internal linkage has been removed + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4512 /wd4514 /wd4623 /wd4625 /wd4626 /wd5026 /wd5027") # implicitly deleted constructor, destructor, assignment operators + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4548") # expression before comma has no effect; expected expression with side-effect + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4668") # 'symbol' is not defined as a preprocessor macro, replacing with '0' for 'directives' + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4710 /wd4711 /wd4714") # not inlined + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4820") # 'bytes' bytes padding added after construct 'member_name' + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4826") # Conversion from 'type1' to 'type2' is sign-extended. The may cause unexprected runtime behavior + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996") # tr1 namespace deprecated + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd5039") # function': pointer or reference to potentially throwing function passed to extern C function under -EHc. Undefined behavior may occur if this function throws an exception. + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd5045") # Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd5267") # definition of implicit copy constructor for 'class' is deprecated because it has a user-provided assignment operator + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd6101") # Returning uninitialized memory 'var' - Windows SDK headers ws2tcpip + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd6262") # Function uses 'amount' bytes of stack. Consider moving some data to heap + # Enet: + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd5287") # operands are different enum types + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd5287") # operands are different enum types + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4146") # unary minus operator applied to unsigned type, result still unsigned + # Eigen: + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd5266") # 'const' qualifier on return type has no effect + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd6255") # '_alloca' indicates failure by raising a stack overflow exception. Consider using _malloca + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd6294") # Ill-defined for-loop. Loop body not executed + # STB: + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd6246") # Local declaration of 'var' hides declaration of the same name in outer scope. + # Analyzer - most are checked with asserts in debug builds + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd6001") # Using uninitialized memory 'var' + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd6385") # Reading invalid data from 'var' + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd6386") # Buffer overrun while writing to 'var' + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd6387") # 'var' could be '0' + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd6239") # ( && ) always evaluates to the result of + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd6031") # Return value ignored: 'func' + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd6011") # Dereferencing NULL pointer 'var'. + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd28182") # Dereferencing NULL pointer 'var'. + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd28301") # No annotations for first declaration of 'func' - Windows SDK headers winnt + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.10) # from MSVC 2017 + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus,preprocessor /permissive-") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++14") # earliest c++ standard explicitly supported + endif() + # static analyzer: + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /analyze:stacksize 65736") # static analyzer + # gtest: + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd6326") # Potential comparison of a constant with another constant + add_compile_options(/analyze) +ELSE() + IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything") + ELSE() + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic") + ENDIF() + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-int-to-pointer-cast") # hellovr, stb_image + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-long-long") # C++98 has no long long + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-variadic-macros") # C++98 variadic macros + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers") # gtest, stb_image + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual") # exampleBrowser OpenGLGuiHelper and btDeformable* + IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized") # gtest + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-ignored-attributes") # b3Int64 cl_long + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy") # GIMPACT + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-strict-aliasing") # GIMPACT, btSoftBody, OpenCL + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-overflow") # btAlignedObjectArray - placement new & findResourcePath + # add_compile_options(-fanalyzer) # lots of null dereference - be very cautious! + ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat-pedantic") # long long is incompatible with C++98 + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat") # override keyword is incompatible with C++98 + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-zero-as-null-pointer-constant") # 0, NULL or nullptr + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy-with-user-provided-copy") # GIMPACT + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy-with-user-provided-dtor") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy-with-dtor") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-null-pointer-subtraction") # btSoftBody + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c99-extensions") # btAssign128 + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-gnu-statement-expression-from-macro-expansion") # ARM build + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-over-aligned") # GLInstancingRenderer - 32bit build + + # -Weverything - with Clang 21 + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-global-constructors") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-exit-time-destructors") + + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-old-style-cast") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unsafe-buffer-usage") # false positives + + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-local-typedef") # for extra semi uselessTypeDefTrailingSemicolon + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedef") # for extra semi uselessTypeDefTrailingSemicolon + + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-documentation-unknown-command") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-documentation-deprecated-sync") + + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reserved-macro-identifier") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reserved-identifier") + + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-cast-qual") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-cast-align") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-float-equal") + + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-shift-sign-overflow") # gtest + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-double-promotion") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-conversion") + + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-string-conversion") # btAssert + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-format-nonliteral") + + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-suggest-override") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-suggest-destructor-override") + + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-disabled-macro-expansion") # in system headers and stbi_image + + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch-default") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-covered-switch-default") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch-enum") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-implicit-fallthrough") + + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-packed") # Enet + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-padded") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-alloca") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-weak-vtables") + + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-variable-declarations") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-macros") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-template") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-member-function") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-used-but-marked-unused") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undefined-func-template") + # SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --analyze -Wno-unused-command-line-argument") # static analyzer + ENDIF() + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-but-set-parameter") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-but-set-variable") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-label") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-local-typedefs") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-parameter") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-value") + + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function") + IF(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + SET(CMAKE_OBJC_FLAGS "${CMAKE_OBJC_FLAGS} -Wno-deprecated-declarations") + ADD_DEFINITIONS(-DGL_SILENCE_DEPRECATION) + ENDIF() +ENDIF() + IF (BULLET2_USE_TBB_MULTITHREADING) SET (BULLET2_TBB_INCLUDE_DIR "not found" CACHE PATH "Directory for Intel TBB includes.") SET (BULLET2_TBB_LIB_DIR "not found" CACHE PATH "Directory for Intel TBB libraries.") - find_library(TBB_LIBRARY tbb PATHS ${BULLET2_TBB_LIB_DIR}) - find_library(TBBMALLOC_LIBRARY tbbmalloc PATHS ${BULLET2_TBB_LIB_DIR}) + find_library(TBB_LIBRARY tbb REQUIRED PATHS ${BULLET2_TBB_LIB_DIR}) + find_library(TBBMALLOC_LIBRARY tbbmalloc REQUIRED PATHS ${BULLET2_TBB_LIB_DIR}) ADD_DEFINITIONS("-DBT_USE_TBB=1") INCLUDE_DIRECTORIES( ${BULLET2_TBB_INCLUDE_DIR} ) LINK_LIBRARIES( ${TBB_LIBRARY} ${TBBMALLOC_LIBRARY} ) @@ -324,7 +477,7 @@ ENDIF (OPENGL_FOUND) IF (APPLE) - FIND_LIBRARY(COCOA_LIBRARY Cocoa) + FIND_LIBRARY(COCOA_LIBRARY Cocoa REQUIRED) ENDIF() OPTION(BUILD_BULLET3 "Set when you want to build Bullet 3" ON) diff --git a/Doxyfile b/Doxyfile index fe2ffd8e84..293d5c4637 100644 --- a/Doxyfile +++ b/Doxyfile @@ -141,7 +141,7 @@ STRIP_CODE_COMMENTS = YES # file names in lower case letters. If set to YES upper case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows -# users are adviced to set this option to NO. +# users are advised to set this option to NO. CASE_SENSE_NAMES = YES @@ -167,7 +167,7 @@ SHOW_INCLUDE_FILES = YES # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like the Qt-style comments (thus requiring an -# explict @brief command for a brief description. +# explicit @brief command for a brief description. JAVADOC_AUTOBRIEF = YES @@ -432,7 +432,7 @@ DISABLE_INDEX = NO ENUM_VALUES_PER_LINE = 1 -# If the GENERATE_TREEVIEW tag is set to YES, a side pannel will be +# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be # generated containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript and frames is required (for instance Netscape 4.0+ @@ -537,7 +537,7 @@ COMPACT_RTF = NO RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assigments. You only have to provide +# config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = @@ -637,7 +637,7 @@ PREDEFINED = "ATTRIBUTE_ALIGNED128(x)=x" \ EXPAND_AS_DEFINED = #--------------------------------------------------------------------------- -# Configuration::addtions related to external references +# Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES tag can be used to specify one or more tagfiles. @@ -736,7 +736,7 @@ GENERATE_LEGEND = YES DOT_CLEANUP = YES #--------------------------------------------------------------------------- -# Configuration::addtions related to the search engine +# Configuration::additions related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be diff --git a/Extras/BulletRobotics/CMakeLists.txt b/Extras/BulletRobotics/CMakeLists.txt index 626721973f..4ff84df7b9 100644 --- a/Extras/BulletRobotics/CMakeLists.txt +++ b/Extras/BulletRobotics/CMakeLists.txt @@ -273,6 +273,10 @@ IF(BUILD_CLSOCKET) ) ENDIF() +IF((BUILD_CLSOCKET OR BUILD_ENET) AND WIN32) + LINK_LIBRARIES(ws2_32 winmm) +ENDIF() + ADD_DEFINITIONS(-DPHYSICS_SERVER_DIRECT) diff --git a/Extras/ConvexDecomposition/ConvexBuilder.cpp b/Extras/ConvexDecomposition/ConvexBuilder.cpp index de48d94851..4737c6396d 100644 --- a/Extras/ConvexDecomposition/ConvexBuilder.cpp +++ b/Extras/ConvexDecomposition/ConvexBuilder.cpp @@ -76,7 +76,7 @@ bool ConvexBuilder::isDuplicate(unsigned int i1, unsigned int i2, unsigned int i return dcount == 3; } -void ConvexBuilder::getMesh(const ConvexDecomposition::ConvexResult &cr, VertexLookup vc, UintVector &indices) +void ConvexBuilder::getMesh(const ConvexDecomposition::ConvexResult &cr, VertexLookup vc, UintVector & /*indices*/) { unsigned int *src = cr.mHullIndices; @@ -93,6 +93,9 @@ void ConvexBuilder::getMesh(const ConvexDecomposition::ConvexResult &cr, VertexL i1 = Vl_getIndex(vc, p1); i2 = Vl_getIndex(vc, p2); i3 = Vl_getIndex(vc, p3); + (void)i1; + (void)i2; + (void)i3; #if 0 bool duplicate = false; @@ -138,7 +141,7 @@ CHull *ConvexBuilder::canMerge(CHull *a, CHull *b) unsigned int vcount = Vl_getVcount(vc); const float *vertices = Vl_getVertices(vc); - unsigned int tcount = indices.size() / 3; + unsigned int tcount = (unsigned int)(indices.size() / 3); //don't do anything if hull is empty if (!tcount) @@ -196,7 +199,7 @@ bool ConvexBuilder::combineHulls(void) { CHull *match = mChulls[j]; - if (cr != match) // don't try to merge a hull with itself, that be stoopid + if (cr != match) // don't try to merge a hull with itself, that be stupid { CHull *merge = canMerge(cr, match); // if we can merge these two.... @@ -207,10 +210,10 @@ bool ConvexBuilder::combineHulls(void) ++i; while (i != mChulls.size()) { - CHull *cr = mChulls[i]; - if (cr != match) + CHull *ch = mChulls[i]; + if (ch != match) { - output.push_back(cr); + output.push_back(ch); } i++; } @@ -277,15 +280,15 @@ unsigned int ConvexBuilder::process(const ConvexDecomposition::DecompDesc &desc) hdesc.mVertexStride = sizeof(float) * 3; hdesc.mMaxVertices = desc.mMaxVertices; // maximum number of vertices allowed in the output - if (desc.mSkinWidth) + if (desc.mSkinWidth != 0.0f) { hdesc.mSkinWidth = desc.mSkinWidth; hdesc.SetHullFlag(ConvexDecomposition::QF_SKIN_WIDTH); // do skin width computation. } - ConvexDecomposition::HullError ret = hl.CreateConvexHull(hdesc, result); + ConvexDecomposition::HullError retCreate = hl.CreateConvexHull(hdesc, result); - if (ret == ConvexDecomposition::QE_OK) + if (retCreate == ConvexDecomposition::QE_OK) { ConvexDecomposition::ConvexResult r(result.mNumOutputVertices, result.mOutputVertices, result.mNumFaces, result.mIndices); @@ -311,7 +314,7 @@ unsigned int ConvexBuilder::process(const ConvexDecomposition::DecompDesc &desc) delete cr; } - ret = mChulls.size(); + ret = (unsigned int)mChulls.size(); mChulls.clear(); diff --git a/Extras/ConvexDecomposition/ConvexDecomposition.cpp b/Extras/ConvexDecomposition/ConvexDecomposition.cpp index 828169213d..045bc53df3 100644 --- a/Extras/ConvexDecomposition/ConvexDecomposition.cpp +++ b/Extras/ConvexDecomposition/ConvexDecomposition.cpp @@ -62,7 +62,7 @@ namespace ConvexDecomposition class FaceTri { public: - FaceTri(void){}; + FaceTri(void){} FaceTri(const float *vertices, unsigned int i1, unsigned int i2, unsigned int i3) { mP1.Set(&vertices[i1 * 3]); @@ -76,7 +76,7 @@ class FaceTri Vector3d mNormal; }; -void addTri(VertexLookup vl, UintVector &list, const Vector3d &p1, const Vector3d &p2, const Vector3d &p3) +static void addTri(VertexLookup vl, UintVector &list, const Vector3d &p1, const Vector3d &p2, const Vector3d &p3) { unsigned int i1 = Vl_getIndex(vl, p1.Ptr()); unsigned int i2 = Vl_getIndex(vl, p2.Ptr()); @@ -198,7 +198,7 @@ void calcConvexDecomposition(unsigned int vcount, showmesh = true; #endif - if (0) + if (/* DISABLES CODE */ (0)) { showmesh = true; for (float x = -1; x < 1; x += 0.10f) @@ -311,6 +311,8 @@ void calcConvexDecomposition(unsigned int vcount, } } + break; + default: break; } } @@ -318,11 +320,11 @@ void calcConvexDecomposition(unsigned int vcount, // ok... here we recursively call if (ifront.size()) { - unsigned int vcount = Vl_getVcount(vfront); - const float *vertices = Vl_getVertices(vfront); - unsigned int tcount = ifront.size() / 3; + unsigned int vertCount = Vl_getVcount(vfront); + const float *verts = Vl_getVertices(vfront); + unsigned int triCount = (unsigned int)(ifront.size() / 3); - calcConvexDecomposition(vcount, vertices, tcount, &ifront[0], callback, masterVolume, depth + 1); + calcConvexDecomposition(vertCount, verts, triCount, &ifront[0], callback, masterVolume, depth + 1); } ifront.clear(); @@ -331,11 +333,11 @@ void calcConvexDecomposition(unsigned int vcount, if (iback.size()) { - unsigned int vcount = Vl_getVcount(vback); - const float *vertices = Vl_getVertices(vback); - unsigned int tcount = iback.size() / 3; + unsigned int vertCount = Vl_getVcount(vback); + const float *verts = Vl_getVertices(vback); + unsigned int triCount = (unsigned int)(iback.size() / 3); - calcConvexDecomposition(vcount, vertices, tcount, &iback[0], callback, masterVolume, depth + 1); + calcConvexDecomposition(vertCount, verts, triCount, &iback[0], callback, masterVolume, depth + 1); } iback.clear(); diff --git a/Extras/ConvexDecomposition/ConvexDecomposition.h b/Extras/ConvexDecomposition/ConvexDecomposition.h index ad5c1f9605..13d124c77c 100644 --- a/Extras/ConvexDecomposition/ConvexDecomposition.h +++ b/Extras/ConvexDecomposition/ConvexDecomposition.h @@ -140,11 +140,11 @@ class ConvexResult class ConvexDecompInterface { public: - virtual ~ConvexDecompInterface(){}; - virtual void ConvexDebugTri(const float *p1, const float *p2, const float *p3, unsigned int color){}; - virtual void ConvexDebugPoint(const float *p, float dist, unsigned int color){}; - virtual void ConvexDebugBound(const float *bmin, const float *bmax, unsigned int color){}; - virtual void ConvexDebugOBB(const float *sides, const float *matrix, unsigned int color){}; + virtual ~ConvexDecompInterface(){} + virtual void ConvexDebugTri(const float * /*p1*/, const float * /*p2*/, const float * /*p3*/, unsigned int /*color*/){} + virtual void ConvexDebugPoint(const float * /*p*/, float /*dist*/, unsigned int /*color*/){} + virtual void ConvexDebugBound(const float * /*bmin*/, const float * /*bmax*/, unsigned int /*color*/){} + virtual void ConvexDebugOBB(const float * /*sides*/, const float * /*matrix*/, unsigned int /*color*/){} virtual void ConvexDecompResult(ConvexResult &result) = 0; }; diff --git a/Extras/ConvexDecomposition/bestfit.cpp b/Extras/ConvexDecomposition/bestfit.cpp index 09024177e8..d3a1a4f290 100644 --- a/Extras/ConvexDecomposition/bestfit.cpp +++ b/Extras/ConvexDecomposition/bestfit.cpp @@ -55,13 +55,13 @@ namespace BestFit class Vec3 { public: - Vec3(void){}; + Vec3(void){} Vec3(float _x, float _y, float _z) { x = _x; y = _y; z = _z; - }; + } float dot(const Vec3 &v) { diff --git a/Extras/ConvexDecomposition/bestfitobb.cpp b/Extras/ConvexDecomposition/bestfitobb.cpp index fbbebf3f09..52fa9138fd 100644 --- a/Extras/ConvexDecomposition/bestfitobb.cpp +++ b/Extras/ConvexDecomposition/bestfitobb.cpp @@ -44,7 +44,7 @@ #include "float_math.h" // computes the OBB for this set of points relative to this transform matrix. -void computeOBB(unsigned int vcount, const float *points, unsigned int pstride, float *sides, const float *matrix) +static void computeOBB(unsigned int vcount, const float *points, unsigned int pstride, float *sides, const float *matrix) { const char *src = (const char *)points; diff --git a/Extras/ConvexDecomposition/cd_hull.cpp b/Extras/ConvexDecomposition/cd_hull.cpp index f97514e8e9..bd5780be2d 100644 --- a/Extras/ConvexDecomposition/cd_hull.cpp +++ b/Extras/ConvexDecomposition/cd_hull.cpp @@ -120,7 +120,7 @@ class int3 { public: int x, y, z; - int3(){}; + int3(){} int3(int _x, int _y, int _z) { x = _x; @@ -141,7 +141,7 @@ class float2 { x = 0; y = 0; - }; + } float2(float _x, float _y) { x = _x; @@ -172,13 +172,13 @@ class float3 // 3D x = 0; y = 0; z = 0; - }; + } float3(float _x, float _y, float _z) { x = _x; y = _y; z = _z; - }; + } //operator float *() { return &x;}; float &operator[](int i) { @@ -215,7 +215,7 @@ float3 operator*(const float s, const float3 &v); float3 operator/(const float3 &v, const float s); inline int operator==(const float3 &a, const float3 &b) { return (a.x == b.x && a.y == b.y && a.z == b.z); } inline int operator!=(const float3 &a, const float3 &b) { return (a.x != b.x || a.y != b.y || a.z != b.z); } -// due to ambiguity and inconsistent standards ther are no overloaded operators for mult such as va*vb. +// due to ambiguity and inconsistent standards there are no overloaded operators for mult such as va*vb. float dot(const float3 &a, const float3 &b); float3 cmul(const float3 &a, const float3 &b); float3 cross(const float3 &a, const float3 &b); @@ -278,7 +278,7 @@ class float4 y = 0; z = 0; w = 0; - }; + } float4(float _x, float _y, float _z, float _w) { x = _x; @@ -574,7 +574,7 @@ float3 normalize(const float3 &v) float d = magnitude(v); if (d == 0) { - printf("Cant normalize ZERO vector\n"); + printf("Can't normalize ZERO vector\n"); assert(0); // yes this could go here d = 0.1f; } @@ -637,7 +637,7 @@ float3x3 Inverse(const float3x3 &a) int i2 = (i + 2) % 3; int j1 = (j + 1) % 3; int j2 = (j + 2) % 3; - // reverse indexs i&j to take transpose + // reverse indices i&j to take transpose b[j][i] = (a[i1][j1] * a[i2][j2] - a[i1][j2] * a[i2][j1]) / d; } } @@ -979,7 +979,7 @@ float3 operator*(const Quaternion &q, const float3 &v) (2 * (qxqz - qyqw)) * v.x + (2 * (qyqz + qxqw)) * v.y + (1 - 2 * (qx2 + qy2)) * v.z); } -float3 operator*(const float3 &v, const Quaternion &q) +float3 operator*(const float3 & /*v*/, const Quaternion & /*q*/) { assert(0); // must multiply with the quat on the left return float3(0.0f, 0.0f, 0.0f); @@ -1097,7 +1097,6 @@ void Plane::Transform(const float3 &position, const Quaternion &orientation) // Routine taken from game programming gems. Quaternion RotationArc(float3 v0, float3 v1) { - Quaternion q; v0 = normalize(v0); // Comment these two lines out if you know its not needed. v1 = normalize(v1); // If vector is already unit length then why do it again? float3 c = cross(v0, v1); @@ -1107,6 +1106,7 @@ Quaternion RotationArc(float3 v0, float3 v1) return Quaternion(1, 0, 0, 0); } // 180 about x axis float s = sqrtf((1 + d) * 2); + Quaternion q; q.x = c.x / s; q.y = c.y / s; q.z = c.z / s; @@ -1358,7 +1358,7 @@ Quaternion VirtualTrackBall(const float3 &cop, const float3 &cor, const float3 & return RotationArc(u, v); } -int countpolyhit = 0; +static int countpolyhit = 0; int PolyHit(const float3 *vert, const int n, const float3 &v0, const float3 &v1, float3 *impact, float3 *normal) { countpolyhit++; @@ -1543,9 +1543,12 @@ void Array::allocate(int s) array_size = s; element = (Type *)malloc(sizeof(Type) * array_size); assert(element); - for (int i = 0; i < count; i++) + if(element) { - element[i] = old[i]; + for (int i = 0; i < count; i++) + { + element[i] = old[i]; + } } if (old) { @@ -1702,7 +1705,7 @@ class PHullResult #define SPLIT (OVER | UNDER) #define PAPERWIDTH (0.001f) -float planetestepsilon = PAPERWIDTH; +static float planetestepsilon = PAPERWIDTH; class ConvexH { @@ -1732,7 +1735,7 @@ ConvexH::ConvexH(int vertices_size, int edges_size, int facets_size) facets.count = facets_size; } -ConvexH *ConvexHDup(ConvexH *src) +static ConvexH *ConvexHDup(ConvexH *src) { ConvexH *dst = new ConvexH(src->vertices.count, src->edges.count, src->facets.count); memcpy(dst->vertices.element, src->vertices.element, sizeof(float3) * src->vertices.count); @@ -1741,14 +1744,14 @@ ConvexH *ConvexHDup(ConvexH *src) return dst; } -int PlaneTest(const Plane &p, const REAL3 &v) +static int PlaneTest(const Plane &p, const REAL3 &v) { REAL a = dot(v, p.normal) + p.dist; int flag = (a > planetestepsilon) ? OVER : ((a < -planetestepsilon) ? UNDER : COPLANAR); return flag; } -int SplitTest(ConvexH &convex, const Plane &plane) +static int SplitTest(ConvexH &convex, const Plane &plane) { int flag = 0; for (int i = 0; i < convex.vertices.count; i++) @@ -1788,7 +1791,7 @@ class Coplanar unsigned char v1; }; -int AssertIntact(ConvexH &convex) +static int AssertIntact(ConvexH &convex) { int i; int estart = 0; @@ -1839,7 +1842,7 @@ int AssertIntact(ConvexH &convex) } // back to back quads -ConvexH *test_btbq() +static ConvexH *test_btbq() { ConvexH *convex = new ConvexH(4, 8, 2); convex->vertices[0] = REAL3(0, 0, 0); @@ -1860,7 +1863,7 @@ ConvexH *test_btbq() AssertIntact(*convex); return convex; } -ConvexH *test_cube() +static ConvexH *test_cube() { ConvexH *convex = new ConvexH(8, 24, 6); convex->vertices[0] = REAL3(0, 0, 0); @@ -1911,7 +1914,7 @@ ConvexH *test_cube() return convex; } -ConvexH *ConvexHMakeCube(const REAL3 &bmin, const REAL3 &bmax) +static ConvexH *ConvexHMakeCube(const REAL3 &bmin, const REAL3 &bmax) { ConvexH *convex = test_cube(); convex->vertices[0] = REAL3(bmin.x, bmin.y, bmin.z); @@ -1931,7 +1934,7 @@ ConvexH *ConvexHMakeCube(const REAL3 &bmin, const REAL3 &bmax) convex->facets[5] = Plane(REAL3(0, 0, 1), -bmax.z); return convex; } -ConvexH *ConvexHCrop(ConvexH &convex, const Plane &slice) +static ConvexH *ConvexHCrop(ConvexH &convex, const Plane &slice) { int i; int vertcountunder = 0; @@ -1945,7 +1948,7 @@ ConvexH *ConvexHCrop(ConvexH &convex, const Plane &slice) EdgeFlag edgeflag[512]; VertFlag vertflag[256]; - PlaneFlag planeflag[128]; + PlaneFlag planeflag[128]; (void)planeflag; HalfEdge tmpunderedges[512]; Plane tmpunderplanes[128]; Coplanar coplanaredges[512]; @@ -1955,21 +1958,21 @@ ConvexH *ConvexHCrop(ConvexH &convex, const Plane &slice) // do the side-of-plane tests for (i = 0; i < convex.vertices.count; i++) { - vertflag[i].planetest = PlaneTest(slice, convex.vertices[i]); + vertflag[i].planetest = (unsigned char)PlaneTest(slice, convex.vertices[i]); if (vertflag[i].planetest == COPLANAR) { // ? vertscoplanar.Add(i); - vertflag[i].undermap = vertcountunder++; - vertflag[i].overmap = vertcountover++; + vertflag[i].undermap = (unsigned char)vertcountunder++; + vertflag[i].overmap = (unsigned char)vertcountover++; } else if (vertflag[i].planetest == UNDER) { - vertflag[i].undermap = vertcountunder++; + vertflag[i].undermap = (unsigned char)vertcountunder++; } else { assert(vertflag[i].planetest == OVER); - vertflag[i].overmap = vertcountover++; + vertflag[i].overmap = (unsigned char)vertcountover++; vertflag[i].undermap = 255; // for debugging purposes } } @@ -2014,15 +2017,15 @@ ConvexH *ConvexHCrop(ConvexH &convex, const Plane &slice) { // at least one endpoint under, the other coplanar or under - edgeflag[e0].undermap = under_edge_count; + edgeflag[e0].undermap = (short)under_edge_count; tmpunderedges[under_edge_count].v = vertflag[edge0.v].undermap; - tmpunderedges[under_edge_count].p = underplanescount; + tmpunderedges[under_edge_count].p = (unsigned char)underplanescount; if (edge0.ea < e0) { // connect the neighbors assert(edgeflag[edge0.ea].undermap != -1); tmpunderedges[under_edge_count].ea = edgeflag[edge0.ea].undermap; - tmpunderedges[edgeflag[edge0.ea].undermap].ea = under_edge_count; + tmpunderedges[edgeflag[edge0.ea].undermap].ea = (short)under_edge_count; } under_edge_count++; } @@ -2039,9 +2042,9 @@ ConvexH *ConvexHCrop(ConvexH &convex, const Plane &slice) HalfEdge &edge2 = convex.edges[e2]; if (vertflag[edge2.v].planetest == UNDER) { - edgeflag[e0].undermap = under_edge_count; + edgeflag[e0].undermap = (short)under_edge_count; tmpunderedges[under_edge_count].v = vertflag[edge0.v].undermap; - tmpunderedges[under_edge_count].p = underplanescount; + tmpunderedges[under_edge_count].p = (unsigned char)underplanescount; tmpunderedges[under_edge_count].ea = -1; // make sure this edge is added to the "coplanar" list coplanaredge = under_edge_count; @@ -2058,15 +2061,15 @@ ConvexH *ConvexHCrop(ConvexH &convex, const Plane &slice) { // first is under 2nd is over - edgeflag[e0].undermap = under_edge_count; + edgeflag[e0].undermap = (short)under_edge_count; tmpunderedges[under_edge_count].v = vertflag[edge0.v].undermap; - tmpunderedges[under_edge_count].p = underplanescount; + tmpunderedges[under_edge_count].p = (unsigned char)underplanescount; if (edge0.ea < e0) { assert(edgeflag[edge0.ea].undermap != -1); // connect the neighbors tmpunderedges[under_edge_count].ea = edgeflag[edge0.ea].undermap; - tmpunderedges[edgeflag[edge0.ea].undermap].ea = under_edge_count; + tmpunderedges[edgeflag[edge0.ea].undermap].ea = (short)under_edge_count; vout = tmpunderedges[edgeflag[edge0.ea].undermap].v; } else @@ -2079,10 +2082,10 @@ ConvexH *ConvexHCrop(ConvexH &convex, const Plane &slice) vout = vertcountunder++; } under_edge_count++; - /// hmmm something to think about: i might be able to output this edge regarless of - // wheter or not we know v-in yet. ok i;ll try this now: - tmpunderedges[under_edge_count].v = vout; - tmpunderedges[under_edge_count].p = underplanescount; + /// hmmm something to think about: i might be able to output this edge regardless of + // whether or not we know v-in yet. ok i;ll try this now: + tmpunderedges[under_edge_count].v = (unsigned char)vout; + tmpunderedges[under_edge_count].p = (unsigned char)underplanescount; tmpunderedges[under_edge_count].ea = -1; coplanaredge = under_edge_count; under_edge_count++; @@ -2101,7 +2104,7 @@ ConvexH *ConvexHCrop(ConvexH &convex, const Plane &slice) edgeflag[e0].undermap = -1; vout = vertflag[edge0.v].undermap; - // I hate this but i have to make sure part of this face is UNDER before ouputting this vert + // I hate this but i have to make sure part of this face is UNDER before outputting this vert int k = estart; assert(edge0.p == currentplane); while (!(planeside & UNDER) && k < convex.edges.count && convex.edges[k].p == edge0.p) @@ -2111,8 +2114,8 @@ ConvexH *ConvexHCrop(ConvexH &convex, const Plane &slice) } if (planeside & UNDER) { - tmpunderedges[under_edge_count].v = vout; - tmpunderedges[under_edge_count].p = underplanescount; + tmpunderedges[under_edge_count].v = (unsigned char)vout; + tmpunderedges[under_edge_count].p = (unsigned char)underplanescount; tmpunderedges[under_edge_count].ea = -1; coplanaredge = under_edge_count; // hmmm should make a note of the edge # for later on under_edge_count++; @@ -2140,6 +2143,7 @@ ConvexH *ConvexHCrop(ConvexH &convex, const Plane &slice) vin = tmpunderedges[nea + 1].v; assert(vin < vertcountunder); assert(vin >= vertcountunderold); // for debugging only + (void)vertcountunderold; } if (vout != -1) { @@ -2148,15 +2152,15 @@ ConvexH *ConvexHCrop(ConvexH &convex, const Plane &slice) // ADD THIS EDGE TO THE LIST OF EDGES THAT NEED NEIGHBOR ON PARTITION PLANE!! } // output edge - tmpunderedges[under_edge_count].v = vin; - tmpunderedges[under_edge_count].p = underplanescount; - edgeflag[e0].undermap = under_edge_count; + tmpunderedges[under_edge_count].v = (unsigned char)vin; + tmpunderedges[under_edge_count].p = (unsigned char)underplanescount; + edgeflag[e0].undermap = (short)under_edge_count; if (e0 > edge0.ea) { assert(edgeflag[edge0.ea].undermap != -1); // connect the neighbors tmpunderedges[under_edge_count].ea = edgeflag[edge0.ea].undermap; - tmpunderedges[edgeflag[edge0.ea].undermap].ea = under_edge_count; + tmpunderedges[edgeflag[edge0.ea].undermap].ea = (short)under_edge_count; } assert(edgeflag[e0].undermap == under_edge_count); under_edge_count++; @@ -2187,7 +2191,7 @@ ConvexH *ConvexHCrop(ConvexH &convex, const Plane &slice) e0 = enextface; if (planeside & UNDER) { - planeflag[currentplane].undermap = underplanescount; + planeflag[currentplane].undermap = (unsigned char)underplanescount; tmpunderplanes[underplanescount] = convex.facets[currentplane]; underplanescount++; } @@ -2200,9 +2204,9 @@ ConvexH *ConvexHCrop(ConvexH &convex, const Plane &slice) assert(vin >= 0); assert(coplanaredge >= 0); assert(coplanaredge != 511); - coplanaredges[coplanaredges_num].ea = coplanaredge; - coplanaredges[coplanaredges_num].v0 = vin; - coplanaredges[coplanaredges_num].v1 = vout; + coplanaredges[coplanaredges_num].ea = (unsigned short)coplanaredge; + coplanaredges[coplanaredges_num].v0 = (unsigned char)vin; + coplanaredges[coplanaredges_num].v1 = (unsigned char)vout; coplanaredges_num++; } } @@ -2253,9 +2257,9 @@ ConvexH *ConvexHCrop(ConvexH &convex, const Plane &slice) for (i = 0; i < coplanaredges_num; i++) { - under.edges[under_edge_count + i].p = underplanescount - 1; - under.edges[under_edge_count + i].ea = coplanaredges[i].ea; - tmpunderedges[coplanaredges[i].ea].ea = under_edge_count + i; + under.edges[under_edge_count + i].p = (unsigned char)(underplanescount - 1); + under.edges[under_edge_count + i].ea = (short)coplanaredges[i].ea; + tmpunderedges[coplanaredges[i].ea].ea = (short)(under_edge_count + i); under.edges[under_edge_count + i].v = coplanaredges[i].v0; } @@ -2333,7 +2337,7 @@ int maxdirfiltered(const T *p, int count, const T &dir, Array &allow) return m; } -float3 orth(const float3 &v) +static float3 orth(const float3 &v) { float3 a = cross(v, float3(0, 0, 1)); float3 b = cross(v, float3(0, 1, 0)); @@ -2366,9 +2370,9 @@ int maxdirsterid(const T *p, int count, const T &dir, Array &allow) int mc = ma; for (float xx = x - 40.0f; xx <= x; xx += 5.0f) { - float s = sinf(DEG2RAD * (xx)); - float c = cosf(DEG2RAD * (xx)); - int md = maxdirfiltered(p, count, dir + (u * s + v * c) * 0.025f, allow); + float sin = sinf(DEG2RAD * (xx)); + float cos = cosf(DEG2RAD * (xx)); + int md = maxdirfiltered(p, count, dir + (u * sin + v * cos) * 0.025f, allow); if (mc == m && md == m) { allow[m] = 3; @@ -2386,7 +2390,7 @@ int maxdirsterid(const T *p, int count, const T &dir, Array &allow) return m; } -int operator==(const int3 &a, const int3 &b) +static int operator==(const int3 &a, const int3 &b) { for (int i = 0; i < 3; i++) { @@ -2395,7 +2399,7 @@ int operator==(const int3 &a, const int3 &b) return 1; } -int3 roll3(int3 a) +static int3 roll3(int3 a) { int tmp = a[0]; a[0] = a[1]; @@ -2403,20 +2407,20 @@ int3 roll3(int3 a) a[2] = tmp; return a; } -int isa(const int3 &a, const int3 &b) +static int isa(const int3 &a, const int3 &b) { return (a == b || roll3(a) == b || a == roll3(b)); } -int b2b(const int3 &a, const int3 &b) +static int b2b(const int3 &a, const int3 &b) { return isa(a, int3(b[2], b[1], b[0])); } -int above(float3 *vertices, const int3 &t, const float3 &p, float epsilon) +static int above(float3 *vertices, const int3 &t, const float3 &p, float epsilon) { float3 n = TriNormal(vertices[t[0]], vertices[t[1]], vertices[t[2]]); return (dot(n, p - vertices[t[0]]) > epsilon); // EPSILON??? } -int hasedge(const int3 &t, int a, int b) +static int hasedge(const int3 &t, int a, int b) { for (int i = 0; i < 3; i++) { @@ -2425,11 +2429,11 @@ int hasedge(const int3 &t, int a, int b) } return 0; } -int hasvert(const int3 &t, int v) +static int hasvert(const int3 &t, int v) { return (t[0] == v || t[1] == v || t[2] == v); } -int shareedge(const int3 &a, const int3 &b) +static int shareedge(const int3 &a, const int3 &b) { int i; for (i = 0; i < 3; i++) @@ -2482,7 +2486,7 @@ int &btHullTriangle::neib(int a, int b) assert(0); return er; } -void b2bfix(btHullTriangle *s, btHullTriangle *t, Array &tris) +static void b2bfix(btHullTriangle *s, btHullTriangle *t, Array &tris) { int i; for (i = 0; i < 3; i++) @@ -2498,17 +2502,18 @@ void b2bfix(btHullTriangle *s, btHullTriangle *t, Array &tris) } } -void removeb2b(btHullTriangle *s, btHullTriangle *t, Array &tris) +static void removeb2b(btHullTriangle *s, btHullTriangle *t, Array &tris) { b2bfix(s, t, tris); delete s; delete t; } -void checkit(btHullTriangle *t, Array &tris) +static void checkit(btHullTriangle *t, Array & tris) { int i; assert(tris[t->id] == t); + (void)tris; for (i = 0; i < 3; i++) { int i1 = (i + 1) % 3; @@ -2517,9 +2522,11 @@ void checkit(btHullTriangle *t, Array &tris) int b = (*t)[i2]; assert(a != b); assert(tris[t->n[i]]->neib(b, a) == t->id); + (void)a; + (void)b; } } -void extrude(btHullTriangle *t0, int v, Array &tris) +static void extrude(btHullTriangle *t0, int v, Array &tris) { int3 t = *t0; int n = tris.count; @@ -2541,7 +2548,7 @@ void extrude(btHullTriangle *t0, int v, Array &tris) delete t0; } -btHullTriangle *extrudable(float epsilon, Array &tris) +static btHullTriangle *extrudable(float epsilon, Array &tris) { int i; btHullTriangle *t = NULL; @@ -2552,14 +2559,14 @@ btHullTriangle *extrudable(float epsilon, Array &tris) t = tris[i]; } } - return (t->rise > epsilon) ? t : NULL; + return (t && t->rise > epsilon) ? t : NULL; } class int4 { public: int x, y, z, w; - int4(){}; + int4(){} int4(int _x, int _y, int _z, int _w) { x = _x; @@ -2571,7 +2578,7 @@ class int4 int &operator[](int i) { return (&x)[i]; } }; -int4 FindSimplex(float3 *verts, int verts_count, Array &allow) +static int4 FindSimplex(float3 *verts, int verts_count, Array &allow) { float3 basis[3]; basis[0] = float3(0.01f, 0.02f, 1.0f); @@ -2604,7 +2611,7 @@ int4 FindSimplex(float3 *verts, int verts_count, Array &allow) return int4(p0, p1, p2, p3); } -int calchullgen(float3 *verts, int verts_count, int vlimit, Array &tris) +static int calchullgen(float3 *verts, int verts_count, int vlimit, Array &tris) { if (verts_count < 4) return 0; if (vlimit == 0) vlimit = 1000000000; @@ -2650,7 +2657,11 @@ int calchullgen(float3 *verts, int verts_count, int vlimit, Array 0 && (te = extrudable(epsilon, tris))) + if(vlimit > 0) + te = extrudable(epsilon, tris); + else + te = NULL; + while (vlimit > 0 && te) { // int3 ti=*te; int v = te->vmax; @@ -2702,11 +2713,12 @@ int calchullgen(float3 *verts, int verts_count, int vlimit, Array &tris) +static int calchull(float3 *verts, int verts_count, int *&tris_out, int &tris_count, int vlimit, Array &tris) { int rc = calchullgen(verts, verts_count, vlimit, tris); if (!rc) return 0; @@ -2725,7 +2737,7 @@ int calchull(float3 *verts, int verts_count, int *&tris_out, int &tris_count, in return 1; } -int calchullpbev(float3 *verts, int verts_count, int vlimit, Array &planes, float bevangle, Array &tris) +static int calchullpbev(float3 *verts, int verts_count, int vlimit, Array &planes, float bevangle, Array &tris) { int i, j; planes.count = 0; @@ -2759,7 +2771,7 @@ int calchullpbev(float3 *verts, int verts_count, int vlimit, Array &plane return 1; } -int overhull(Plane *planes, int planes_count, float3 *verts, int verts_count, int maxplanes, +static int overhull(Plane *planes, int planes_count, float3 *verts, int verts_count, int maxplanes, float3 *&verts_out, int &verts_count_out, int *&faces_out, int &faces_count_out, float inflate) { int i, j; @@ -2809,24 +2821,27 @@ int overhull(Plane *planes, int planes_count, float3 *verts, int verts_count, in faces_out = (int *)malloc(sizeof(int) * (1 + c->facets.count + c->edges.count)); // new int[1+c->facets.count+c->edges.count]; faces_count_out = 0; i = 0; - faces_out[faces_count_out++] = -1; k = 0; - while (i < c->edges.count) + if(faces_out) { - j = 1; - while (j + i < c->edges.count && c->edges[i].p == c->edges[i + j].p) - { - j++; - } - faces_out[faces_count_out++] = j; - while (j--) + faces_out[faces_count_out++] = -1; + while (i < c->edges.count) { - faces_out[faces_count_out++] = c->edges[i].v; - i++; + j = 1; + while (j + i < c->edges.count && c->edges[i].p == c->edges[i + j].p) + { + j++; + } + faces_out[faces_count_out++] = j; + while (j--) + { + faces_out[faces_count_out++] = c->edges[i].v; + i++; + } + k++; } - k++; + faces_out[0] = k; // number of faces. } - faces_out[0] = k; // number of faces. assert(k == c->facets.count); assert(faces_count_out == 1 + c->facets.count + c->edges.count); verts_out = c->vertices.element; // new float3[c->vertices.count]; @@ -2841,7 +2856,7 @@ int overhull(Plane *planes, int planes_count, float3 *verts, int verts_count, in return 1; } -int overhullv(float3 *verts, int verts_count, int maxplanes, +static int overhullv(float3 *verts, int verts_count, int maxplanes, float3 *&verts_out, int &verts_count_out, int *&faces_out, int &faces_count_out, float inflate, float bevangle, int vlimit, Array &tris) { if (!verts_count) return 0; @@ -2852,7 +2867,7 @@ int overhullv(float3 *verts, int verts_count, int maxplanes, return overhull(planes.element, planes.count, verts, verts_count, maxplanes, verts_out, verts_count_out, faces_out, faces_count_out, inflate); } -bool ComputeHull(unsigned int vcount, const float *vertices, PHullResult &result, unsigned int vlimit, float inflate, Array &arrtris) +static bool ComputeHull(unsigned int vcount, const float *vertices, PHullResult &result, unsigned int vlimit, float inflate, Array &arrtris) { int index_count; int *faces; @@ -2863,7 +2878,7 @@ bool ComputeHull(unsigned int vcount, const float *vertices, PHullResult &result { int *tris_out; int tris_count; - int ret = calchull((float3 *)vertices, (int)vcount, tris_out, tris_count, vlimit, arrtris); + int ret = calchull((float3 *)vertices, (int)vcount, tris_out, tris_count, (int)vlimit, arrtris); if (!ret) return false; result.mIndexCount = (unsigned int)(tris_count * 3); result.mFaceCount = (unsigned int)tris_count; @@ -2873,7 +2888,7 @@ bool ComputeHull(unsigned int vcount, const float *vertices, PHullResult &result return true; } - int ret = overhullv((float3 *)vertices, vcount, 35, verts_out, verts_count_out, faces, index_count, inflate, 120.0f, vlimit, arrtris); + int ret = overhullv((float3 *)vertices, (int)vcount, 35, verts_out, verts_count_out, faces, index_count, inflate, 120.0f, (int)vlimit, arrtris); if (!ret) return false; Array tris; @@ -2898,7 +2913,7 @@ bool ComputeHull(unsigned int vcount, const float *vertices, PHullResult &result return true; } -void ReleaseHull(PHullResult &result) +static void ReleaseHull(PHullResult &result) { if (result.mIndices) { @@ -2925,7 +2940,7 @@ void ReleaseHull(PHullResult &result) //********************************************************************* HullError HullLibrary::CreateConvexHull(const HullDesc &desc, // describes the input request - HullResult &result) // contains the resulst + HullResult &result) // contains the results { HullError ret = QE_FAIL; @@ -2980,26 +2995,30 @@ HullError HullLibrary::CreateConvexHull(const HullDesc &desc, // describes the result.mIndices = (unsigned int *)malloc(sizeof(unsigned int) * hr.mIndexCount); - memcpy(result.mOutputVertices, vscratch, sizeof(float) * 3 * ovcount); + if(result.mOutputVertices) + memcpy(result.mOutputVertices, vscratch, sizeof(float) * 3 * ovcount); - if (desc.HasHullFlag(QF_REVERSE_ORDER)) + if(result.mIndices && hr.mIndices) { - const unsigned int *source = hr.mIndices; - unsigned int *dest = result.mIndices; + if (desc.HasHullFlag(QF_REVERSE_ORDER)) + { + const unsigned int *source = hr.mIndices; + unsigned int *dest = result.mIndices; - for (unsigned int i = 0; i < hr.mFaceCount; i++) + for (unsigned int i = 0; i < hr.mFaceCount; i++) + { + dest[0] = source[2]; + dest[1] = source[1]; + dest[2] = source[0]; + dest += 3; + source += 3; + } + } + else { - dest[0] = source[2]; - dest[1] = source[1]; - dest[2] = source[0]; - dest += 3; - source += 3; + memcpy(result.mIndices, hr.mIndices, sizeof(unsigned int) * hr.mIndexCount); } } - else - { - memcpy(result.mIndices, hr.mIndices, sizeof(unsigned int) * hr.mIndexCount); - } } else { @@ -3009,9 +3028,10 @@ HullError HullLibrary::CreateConvexHull(const HullDesc &desc, // describes the result.mNumFaces = hr.mFaceCount; result.mNumIndices = hr.mIndexCount + hr.mFaceCount; result.mIndices = (unsigned int *)malloc(sizeof(unsigned int) * result.mNumIndices); - memcpy(result.mOutputVertices, vscratch, sizeof(float) * 3 * ovcount); + if(result.mOutputVertices && vscratch) + memcpy(result.mOutputVertices, vscratch, sizeof(float) * 3 * ovcount); - if (1) + if (result.mIndices && hr.mIndices) { const unsigned int *source = hr.mIndices; unsigned int *dest = result.mIndices; @@ -3076,7 +3096,7 @@ static void addPoint(unsigned int &vcount, float *p, float x, float y, float z) vcount++; } -float GetDist(float px, float py, float pz, const float *p2) +static float GetDist(float px, float py, float pz, const float *p2) { float dx = px - p2[0]; float dy = py - p2[1]; @@ -3099,7 +3119,7 @@ bool HullLibrary::CleanupVertices(unsigned int svcount, vcount = 0; - float recip[3]; + float recip[3] = {}; if (scale) { @@ -3226,11 +3246,11 @@ bool HullLibrary::CleanupVertices(unsigned int svcount, float y = v[1]; float z = v[2]; - float dx = fabsf(x - px); - float dy = fabsf(y - py); - float dz = fabsf(z - pz); + float dxL = fabsf(x - px); + float dyL = fabsf(y - py); + float dzL = fabsf(z - pz); - if (dx < normalepsilon && dy < normalepsilon && dz < normalepsilon) + if (dxL < normalepsilon && dyL < normalepsilon && dzL < normalepsilon) { // ok, it is close enough to the old one // now let us see if it is further from the center of the point cloud than the one we already recorded. @@ -3264,54 +3284,54 @@ bool HullLibrary::CleanupVertices(unsigned int svcount, // ok..now make sure we didn't prune so many vertices it is now invalid. if (1) { - float bmin[3] = {FLT_MAX, FLT_MAX, FLT_MAX}; - float bmax[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX}; + float bbmin[3] = {FLT_MAX, FLT_MAX, FLT_MAX}; + float bbmax[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX}; for (unsigned int i = 0; i < vcount; i++) { const float *p = &vertices[i * 3]; for (int j = 0; j < 3; j++) { - if (p[j] < bmin[j]) bmin[j] = p[j]; - if (p[j] > bmax[j]) bmax[j] = p[j]; + if (p[j] < bbmin[j]) bbmin[j] = p[j]; + if (p[j] > bbmax[j]) bbmax[j] = p[j]; } } - float dx = bmax[0] - bmin[0]; - float dy = bmax[1] - bmin[1]; - float dz = bmax[2] - bmin[2]; + float dxL = bbmax[0] - bbmin[0]; + float dyL = bbmax[1] - bbmin[1]; + float dzL = bbmax[2] - bbmin[2]; - if (dx < EPSILON || dy < EPSILON || dz < EPSILON || vcount < 3) + if (dxL < EPSILON || dyL < EPSILON || dzL < EPSILON || vcount < 3) { - float cx = dx * 0.5f + bmin[0]; - float cy = dy * 0.5f + bmin[1]; - float cz = dz * 0.5f + bmin[2]; + float cx = dxL * 0.5f + bbmin[0]; + float cy = dyL * 0.5f + bbmin[1]; + float cz = dzL * 0.5f + bbmin[2]; float len = FLT_MAX; - if (dx >= EPSILON && dx < len) len = dx; - if (dy >= EPSILON && dy < len) len = dy; - if (dz >= EPSILON && dz < len) len = dz; + if (dxL >= EPSILON && dxL < len) len = dxL; + if (dyL >= EPSILON && dyL < len) len = dyL; + if (dzL >= EPSILON && dzL < len) len = dzL; if (len == FLT_MAX) { - dx = dy = dz = 0.01f; // one centimeter + dxL = dyL = dzL = 0.01f; // one centimeter } else { - if (dx < EPSILON) dx = len * 0.05f; // 1/5th the shortest non-zero edge. - if (dy < EPSILON) dy = len * 0.05f; - if (dz < EPSILON) dz = len * 0.05f; + if (dxL < EPSILON) dxL = len * 0.05f; // 1/5th the shortest non-zero edge. + if (dyL < EPSILON) dyL = len * 0.05f; + if (dzL < EPSILON) dzL = len * 0.05f; } - float x1 = cx - dx; - float x2 = cx + dx; + float x1 = cx - dxL; + float x2 = cx + dxL; - float y1 = cy - dy; - float y2 = cy + dy; + float y1 = cy - dyL; + float y2 = cy + dyL; - float z1 = cz - dz; - float z2 = cz + dz; + float z1 = cz - dzL; + float z2 = cz + dzL; vcount = 0; // add box @@ -3334,7 +3354,8 @@ bool HullLibrary::CleanupVertices(unsigned int svcount, void HullLibrary::BringOutYourDead(const float *verts, unsigned int vcount, float *overts, unsigned int &ocount, unsigned int *indices, unsigned indexcount) { unsigned int *used = (unsigned int *)malloc(sizeof(unsigned int) * vcount); - memset(used, 0, sizeof(unsigned int) * vcount); + if(!used) return; + memset(used, 0, sizeof(unsigned int) * vcount); ocount = 0; @@ -3342,7 +3363,7 @@ void HullLibrary::BringOutYourDead(const float *verts, unsigned int vcount, floa { unsigned int v = indices[i]; // original array index - assert(v >= 0 && v < vcount); + assert(v < vcount); if (used[v]) // if already remapped { @@ -3358,7 +3379,7 @@ void HullLibrary::BringOutYourDead(const float *verts, unsigned int vcount, floa ocount++; // increment output vert count - assert(ocount >= 0 && ocount <= vcount); + assert(ocount <= vcount); used[v] = ocount; // assign new index remapping } diff --git a/Extras/ConvexDecomposition/cd_hull.h b/Extras/ConvexDecomposition/cd_hull.h index 212815f863..ab02bd946c 100644 --- a/Extras/ConvexDecomposition/cd_hull.h +++ b/Extras/ConvexDecomposition/cd_hull.h @@ -75,7 +75,7 @@ class HullDesc mMaxVertices = 4096; // maximum number of points to be considered for a convex hull. mMaxFaces = 4096; mSkinWidth = 0.01f; // default is one centimeter - }; + } HullDesc(HullFlag flag, unsigned int vcount, @@ -127,7 +127,7 @@ class HullLibrary { public: HullError CreateConvexHull(const HullDesc &desc, // describes the input request - HullResult &result); // contains the resulst + HullResult &result); // contains the results HullError ReleaseResult(HullResult &result); // release memory allocated for this result, we are done with it. diff --git a/Extras/ConvexDecomposition/cd_vector.h b/Extras/ConvexDecomposition/cd_vector.h index 6d46b2f3ec..551cc86a2c 100644 --- a/Extras/ConvexDecomposition/cd_vector.h +++ b/Extras/ConvexDecomposition/cd_vector.h @@ -36,7 +36,9 @@ // http://www.amillionpixels.us // +#ifdef _MSC_VER #pragma warning(disable : 4786) +#endif #include #include @@ -50,45 +52,45 @@ const float RAD_TO_DEG = (360.0f / (2.0f * 3.141592654f)); class Vector3d { public: - Vector3d(void){}; // null constructor, does not inialize point. + Vector3d(void){} // null constructor, does not initialize point. Vector3d(const Vector3d &a) // constructor copies existing vector. { x = a.x; y = a.y; z = a.z; - }; + } Vector3d(float a, float b, float c) // construct with initial point. { x = a; y = b; z = c; - }; + } Vector3d(const float *t) { x = t[0]; y = t[1]; z = t[2]; - }; + } Vector3d(const int *t) { - x = t[0]; - y = t[1]; - z = t[2]; - }; + x = (float)t[0]; + y = (float)t[1]; + z = (float)t[2]; + } bool operator==(const Vector3d &a) const { return (a.x == x && a.y == y && a.z == z); - }; + } bool operator!=(const Vector3d &a) const { return (a.x != x || a.y != y || a.z != z); - }; + } // Operators Vector3d &operator=(const Vector3d &A) // ASSIGNMENT (=) @@ -97,58 +99,58 @@ class Vector3d y = A.y; z = A.z; return (*this); - }; + } Vector3d operator+(const Vector3d &A) const // ADDITION (+) { Vector3d Sum(x + A.x, y + A.y, z + A.z); return (Sum); - }; + } Vector3d operator-(const Vector3d &A) const // SUBTRACTION (-) { Vector3d Diff(x - A.x, y - A.y, z - A.z); return (Diff); - }; + } Vector3d operator*(const float s) const // MULTIPLY BY SCALAR (*) { Vector3d Scaled(x * s, y * s, z * s); return (Scaled); - }; + } Vector3d operator+(const float s) const // ADD CONSTANT TO ALL 3 COMPONENTS (*) { Vector3d Scaled(x + s, y + s, z + s); return (Scaled); - }; + } Vector3d operator/(const float s) const // DIVIDE BY SCALAR (/) { float r = 1.0f / s; Vector3d Scaled(x * r, y * r, z * r); return (Scaled); - }; + } void operator/=(float A) // ACCUMULATED VECTOR ADDITION (/=) { x /= A; y /= A; z /= A; - }; + } void operator+=(const Vector3d A) // ACCUMULATED VECTOR ADDITION (+=) { x += A.x; y += A.y; z += A.z; - }; + } void operator-=(const Vector3d A) // ACCUMULATED VECTOR SUBTRACTION (+=) { x -= A.x; y -= A.y; z -= A.z; - }; + } void operator*=(const float s) // ACCUMULATED SCALAR MULTIPLICATION (*=) (bpc 4/24/2000) { x *= s; @@ -161,36 +163,36 @@ class Vector3d x += A; y += A; z += A; - }; + } Vector3d operator-(void) const // NEGATION (-) { Vector3d Negated(-x, -y, -z); return (Negated); - }; + } float operator[](const int i) const // ALLOWS VECTOR ACCESS AS AN ARRAY. { return ((i == 0) ? x : ((i == 1) ? y : z)); - }; + } float &operator[](const int i) { return ((i == 0) ? x : ((i == 1) ? y : z)); - }; + } // // accessor methods. - float GetX(void) const { return x; }; - float GetY(void) const { return y; }; - float GetZ(void) const { return z; }; + float GetX(void) const { return x; } + float GetY(void) const { return y; } + float GetZ(void) const { return z; } - float X(void) const { return x; }; - float Y(void) const { return y; }; - float Z(void) const { return z; }; + float X(void) const { return x; } + float Y(void) const { return y; } + float Z(void) const { return z; } - void SetX(float t) { x = t; }; - void SetY(float t) { y = t; }; - void SetZ(float t) { z = t; }; + void SetX(float t) { x = t; } + void SetY(float t) { y = t; } + void SetZ(float t) { z = t; } bool IsSame(const Vector3d &v, float epsilon) const { @@ -251,14 +253,14 @@ class Vector3d float t = y; y = z; z = t; - }; + } void Get(float *v) const { v[0] = x; v[1] = y; v[2] = z; - }; + } void Set(const int *p) { @@ -279,12 +281,12 @@ class Vector3d x = a; y = b; z = c; - }; + } void Zero(void) { x = y = z = 0; - }; + } const float *Ptr() const { return &x; } float *Ptr() { return &x; } @@ -302,28 +304,28 @@ class Vector3d float Magnitude(void) const { return float(sqrt(x * x + y * y + z * z)); - }; + } float FastMagnitude(void) const { return float(sqrtf(x * x + y * y + z * z)); - }; + } float FasterMagnitude(void) const { return float(sqrtf(x * x + y * y + z * z)); - }; + } void Lerp(const Vector3d &from, const Vector3d &to, float slerp) { x = ((to.x - from.x) * slerp) + from.x; y = ((to.y - from.y) * slerp) + from.y; z = ((to.z - from.z) * slerp) + from.z; - }; + } // Highly specialized interpolate routine. Will compute the interpolated position // shifted forward or backwards along the ray defined between (from) and (to). - // Reason for existance is so that when a bullet collides with a wall, for + // Reason for existence is so that when a bullet collides with a wall, for // example, you can generate a graphic effect slightly *before* it hit the // wall so that the effect doesn't sort into the wall itself. void Interpolate(const Vector3d &from, const Vector3d &to, float offset) @@ -340,7 +342,7 @@ class Vector3d x = x * d + from.x; y = y * d + from.y; z = z * d + from.z; - }; + } bool BinaryEqual(const Vector3d &p) const { @@ -352,7 +354,7 @@ class Vector3d source[2] == dest[2]) return true; return false; - }; + } /*bool BinaryEqual(const Vector3d &p) const { @@ -376,19 +378,19 @@ class Vector3d x = -d.x; y = -d.y; z = -d.z; - }; + } void AngleAxis(float angle, const Vector3d &axis) { x = axis.x * angle; y = axis.y * angle; z = axis.z * angle; - }; + } float Length(void) const // length of vector. { return float(sqrt(x * x + y * y + z * z)); - }; + } float ComputePlane(const Vector3d &A, const Vector3d &B, @@ -431,18 +433,18 @@ class Vector3d float FastLength(void) const // length of vector. { return float(sqrtf(x * x + y * y + z * z)); - }; + } float FasterLength(void) const // length of vector. { return float(sqrtf(x * x + y * y + z * z)); - }; + } float Length2(void) const // squared distance, prior to square root. { float l2 = x * x + y * y + z * z; return l2; - }; + } float Distance(const Vector3d &a) const // distance between two points. { @@ -476,7 +478,7 @@ class Vector3d float dy = a.y - y; float dz = a.z - z; return dx * dx + dy * dy + dz * dz; - }; + } float Partial(const Vector3d &p) const { @@ -506,7 +508,7 @@ class Vector3d x = y = z = 1; } return d; - }; + } inline float FastNormalize(void) // normalize to a unit vector, returns distance. { @@ -523,7 +525,7 @@ class Vector3d x = y = z = 1; } return d; - }; + } inline float FasterNormalize(void) // normalize to a unit vector, returns distance. { @@ -540,12 +542,12 @@ class Vector3d x = y = z = 1; } return d; - }; + } float Dot(const Vector3d &a) const // computes dot product. { return (x * a.x + y * a.y + z * a.z); - }; + } Vector3d Cross(const Vector3d &other) const { @@ -559,7 +561,7 @@ class Vector3d x = a.y * b.z - a.z * b.y; y = a.z * b.x - a.x * b.z; z = a.x * b.y - a.y * b.x; - }; + } /******************************************/ // Check if next edge (b to c) turns inward @@ -615,7 +617,7 @@ class Vector3d if (mag > 0.0f) return false; return (true); - }; + } bool PointTestXY(const Vector3d &i, const Vector3d &j) const { @@ -649,7 +651,7 @@ class Vector3d float bCROSScp = bx * cpy - by * cpx; return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f)); - }; + } // test to see if this point is inside the triangle specified by // these three points on the X/Y plane. @@ -675,7 +677,7 @@ class Vector3d float bCROSScp = by * cpz - bz * cpy; return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f)); - }; + } // test to see if this point is inside the triangle specified by // these three points on the X/Y plane. @@ -701,7 +703,7 @@ class Vector3d float bCROSScp = bz * cpx - bx * cpz; return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f)); - }; + } // Given a point and a line (defined by two points), compute the closest point // in the line. (The line is treated as infinitely long.) @@ -857,6 +859,7 @@ class Vector3d bForce = false; bestMagnitude2 = closeMagnitude2; nearestPoint = closePoint; + (void)bestMagnitude2; } } @@ -887,25 +890,25 @@ class Vector3d class Vector2d { public: - Vector2d(void){}; // null constructor, does not inialize point. + Vector2d(void){} // null constructor, does not initialize point. Vector2d(const Vector2d &a) // constructor copies existing vector. { x = a.x; y = a.y; - }; + } Vector2d(const float *t) { x = t[0]; y = t[1]; - }; + } Vector2d(float a, float b) // construct with initial point. { x = a; y = b; - }; + } const float *Ptr() const { return &x; } float *Ptr() { return &x; } @@ -915,66 +918,66 @@ class Vector2d x += a.x; y += a.y; return *this; - }; + } Vector2d &operator-=(const Vector2d &a) { x -= a.x; y -= a.y; return *this; - }; + } Vector2d &operator*=(const Vector2d &a) { x *= a.x; y *= a.y; return *this; - }; + } Vector2d &operator/=(const Vector2d &a) { x /= a.x; y /= a.y; return *this; - }; + } bool operator==(const Vector2d &a) const { if (a.x == x && a.y == y) return true; return false; - }; + } bool operator!=(const Vector2d &a) const { if (a.x != x || a.y != y) return true; return false; - }; + } Vector2d operator+(Vector2d a) const { a.x += x; a.y += y; return a; - }; + } Vector2d operator-(Vector2d a) const { a.x = x - a.x; a.y = y - a.y; return a; - }; + } Vector2d operator-(void) const { return negative(); - }; + } Vector2d operator*(Vector2d a) const { a.x *= x; a.y *= y; return a; - }; + } Vector2d operator*(float c) const { @@ -984,36 +987,36 @@ class Vector2d a.y = y * c; return a; - }; + } Vector2d operator/(Vector2d a) const { a.x = x / a.x; a.y = y / a.y; return a; - }; + } float Dot(const Vector2d &a) const // computes dot product. { return (x * a.x + y * a.y); - }; + } - float GetX(void) const { return x; }; - float GetY(void) const { return y; }; + float GetX(void) const { return x; } + float GetY(void) const { return y; } - void SetX(float t) { x = t; }; - void SetY(float t) { y = t; }; + void SetX(float t) { x = t; } + void SetY(float t) { y = t; } void Set(float a, float b) { x = a; y = b; - }; + } void Zero(void) { x = y = 0; - }; + } Vector2d negative(void) const { @@ -1043,17 +1046,17 @@ class Vector2d float Length(void) const // length of vector. { return float(sqrtf(x * x + y * y)); - }; + } float FastLength(void) const // length of vector. { return float(sqrtf(x * x + y * y)); - }; + } float FasterLength(void) const // length of vector. { return float(sqrtf(x * x + y * y)); - }; + } float Length2(void) // squared distance, prior to square root. { @@ -1066,7 +1069,7 @@ class Vector2d float dy = a.y - y; float d = dx * dx + dy * dy; return sqrtf(d); - }; + } float FastDistance(const Vector2d &a) const // distance between two points. { @@ -1074,7 +1077,7 @@ class Vector2d float dy = a.y - y; float d = dx * dx + dy * dy; return sqrtf(d); - }; + } float FasterDistance(const Vector2d &a) const // distance between two points. { @@ -1082,26 +1085,26 @@ class Vector2d float dy = a.y - y; float d = dx * dx + dy * dy; return sqrtf(d); - }; + } float Distance2(Vector2d &a) // squared distance. { float dx = a.x - x; float dy = a.y - y; return dx * dx + dy * dy; - }; + } void Lerp(const Vector2d &from, const Vector2d &to, float slerp) { x = ((to.x - from.x) * slerp) + from.x; y = ((to.y - from.y) * slerp) + from.y; - }; + } void Cross(const Vector2d &a, const Vector2d &b) // cross two vectors result in this one. { x = a.y * b.x - a.x * b.y; y = a.x * b.x - a.x * b.x; - }; + } float Normalize(void) // normalize to a unit vector, returns distance. { @@ -1117,7 +1120,7 @@ class Vector2d x = y = 0; } return l; - }; + } float FastNormalize(void) // normalize to a unit vector, returns distance. { @@ -1133,7 +1136,7 @@ class Vector2d x = y = 0; } return l; - }; + } float FasterNormalize(void) // normalize to a unit vector, returns distance. { @@ -1149,7 +1152,7 @@ class Vector2d x = y = 0; } return l; - }; + } float x; float y; @@ -1162,7 +1165,7 @@ class Line { mP1 = from; mP2 = to; - }; + } // JWR Test for the intersection of two lines. bool Intersect(const Line &src, Vector3d §); diff --git a/Extras/ConvexDecomposition/cd_wavefront.cpp b/Extras/ConvexDecomposition/cd_wavefront.cpp index 53b5784dfa..a5c70f11d6 100644 --- a/Extras/ConvexDecomposition/cd_wavefront.cpp +++ b/Extras/ConvexDecomposition/cd_wavefront.cpp @@ -87,7 +87,7 @@ typedef std::vector FloatVector; class InPlaceParserInterface { public: - virtual ~InPlaceParserInterface(){}; + virtual ~InPlaceParserInterface(){} virtual int ParseLine(int lineno, int argc, const char **argv) = 0; // return TRUE to continue parsing, return FALSE to abort parsing process }; @@ -131,7 +131,7 @@ class InPlaceParser for (int i = 0; i < 256; i++) { mHard[i] = ST_DATA; - mHardString[i * 2] = i; + mHardString[i * 2] = (char)i; mHardString[i * 2 + 1] = 0; } mHard[0] = ST_EOS; @@ -148,7 +148,7 @@ class InPlaceParser mData = data; mLen = len; mMyAlloc = false; - }; + } int Parse(InPlaceParserInterface *callback); // returns true if entire file was parsed, false if it aborted for some reason @@ -224,18 +224,18 @@ void InPlaceParser::SetFile(const char *fname) if (fph) { fseek(fph, 0L, SEEK_END); - mLen = ftell(fph); + mLen = (int)ftell(fph); fseek(fph, 0L, SEEK_SET); - if (mLen) + if (mLen > 0) { mData = (char *)malloc(sizeof(char) * (mLen + 1)); - int ok = fread(mData, mLen, 1, fph); - if (!ok) + int ok = mData ? (int)fread(mData, (size_t)mLen, 1, fph) : 0; + if (!ok && mData) { free(mData); mData = 0; } - else + else if(mData) { mData[mLen] = 0; // zero byte terminate end of file marker. mMyAlloc = true; @@ -536,7 +536,7 @@ class GeometryVertex class GeometryInterface { public: - virtual void NodeTriangle(const GeometryVertex *v1, const GeometryVertex *v2, const GeometryVertex *v3) {} + virtual void NodeTriangle(const GeometryVertex * /*v1*/, const GeometryVertex * /*v2*/, const GeometryVertex * /*v3*/) {} virtual ~GeometryInterface() {} }; @@ -611,7 +611,7 @@ void OBJ::getVertex(GeometryVertex &v, const char *face) const if (tindex >= 0 && tindex < (int)(mTexels.size() / 2)) { - const float *t = &mTexels[tindex * 2]; + const float *t = &mTexels[(size_t)tindex * 2]; v.mTexel[0] = t[0]; v.mTexel[1] = t[1]; @@ -624,7 +624,7 @@ void OBJ::getVertex(GeometryVertex &v, const char *face) const if (nindex >= 0 && nindex < (int)(mNormals.size() / 3)) { - const float *n = &mNormals[nindex * 3]; + const float *n = &mNormals[(size_t)nindex * 3]; v.mNormal[0] = n[0]; v.mNormal[1] = n[1]; @@ -635,7 +635,7 @@ void OBJ::getVertex(GeometryVertex &v, const char *face) const if (index >= 0 && index < (int)(mVerts.size() / 3)) { - const float *p = &mVerts[index * 3]; + const float *p = &mVerts[(size_t)index * 3]; v.mPos[0] = p[0]; v.mPos[1] = p[1]; @@ -643,7 +643,7 @@ void OBJ::getVertex(GeometryVertex &v, const char *face) const } } -int OBJ::ParseLine(int lineno, int argc, const char **argv) // return TRUE to continue parsing, return FALSE to abort parsing process +int OBJ::ParseLine(int /*lineno*/, int argc, const char **argv) // return TRUE to continue parsing, return FALSE to abort parsing process { int ret = 0; @@ -738,7 +738,7 @@ class BuildMesh : public GeometryInterface public: int getIndex(const float *p) { - int vcount = mVertices.size() / 3; + int vcount = (int)(mVertices.size() / 3); if (vcount > 0) { @@ -766,8 +766,8 @@ class BuildMesh : public GeometryInterface mIndices.push_back(getIndex(v3->mPos)); } - const FloatVector &GetVertices(void) const { return mVertices; }; - const IntVector &GetIndices(void) const { return mIndices; }; + const FloatVector &GetVertices(void) const { return mVertices; } + const IntVector &GetIndices(void) const { return mIndices; } private: FloatVector mVertices; @@ -809,13 +809,13 @@ unsigned int WavefrontObj::loadObj(const char *fname) // load a wavefront obj r const IntVector &indices = bm.GetIndices(); if (vlist.size()) { - mVertexCount = vlist.size() / 3; - mVertices = new float[mVertexCount * 3]; + mVertexCount = (int)(vlist.size() / 3); + mVertices = new float[(size_t)mVertexCount * 3]; memcpy(mVertices, &vlist[0], sizeof(float) * mVertexCount * 3); - mTriCount = indices.size() / 3; + mTriCount = (int)(indices.size() / 3); mIndices = new int[mTriCount * 3 * sizeof(int)]; memcpy(mIndices, &indices[0], sizeof(int) * mTriCount * 3); - ret = mTriCount; + ret = (unsigned int)mTriCount; } return ret; diff --git a/Extras/ConvexDecomposition/concavity.cpp b/Extras/ConvexDecomposition/concavity.cpp index 023181a44a..a7cc4ff411 100644 --- a/Extras/ConvexDecomposition/concavity.cpp +++ b/Extras/ConvexDecomposition/concavity.cpp @@ -54,7 +54,7 @@ namespace ConvexDecomposition { -unsigned int getDebugColor(void) +static unsigned int getDebugColor(void) { static unsigned int colors[8] = { @@ -127,7 +127,7 @@ static void intersect(const float *p1, const float *p2, float *split, const floa class CTri { public: - CTri(void){}; + CTri(void){} CTri(const float *p1, const float *p2, const float *p3, unsigned int i1, unsigned int i2, unsigned int i3) { @@ -318,7 +318,7 @@ class CTri return a; } - void addWeighted(WpointVector &list, ConvexDecompInterface *callback) + void addWeighted(WpointVector &list, ConvexDecompInterface * /*callback*/) { Wpoint p1(mP1, mC1); Wpoint p2(mP2, mC2); @@ -395,7 +395,7 @@ class CTri typedef std::vector CTriVector; -bool featureMatch(CTri &m, const CTriVector &tris, ConvexDecompInterface *callback, const CTriVector &input_mesh) +static bool featureMatch(CTri &m, const CTriVector &tris, ConvexDecompInterface * /*callback*/, const CTriVector &input_mesh) { bool ret = false; @@ -451,12 +451,12 @@ bool featureMatch(CTri &m, const CTriVector &tris, ConvexDecompInterface *callba if (ret) { - if (0) + if (/* DISABLES CODE */ (0)) { - CTriVector::const_iterator i; - for (i = input_mesh.begin(); i != input_mesh.end(); ++i) + CTriVector::const_iterator it; + for (it = input_mesh.begin(); it != input_mesh.end(); ++it) { - const CTri &c = (*i); + const CTri &c = (*it); if (c.mI1 != m.mI1 && c.mI2 != m.mI2 && c.mI3 != m.mI3) { c.clip(m.mP1, m.mNear1); @@ -496,7 +496,7 @@ bool featureMatch(CTri &m, const CTriVector &tris, ConvexDecompInterface *callba return ret; } -bool isFeatureTri(CTri &t, CTriVector &flist, float fc, ConvexDecompInterface *callback, unsigned int color) +static bool isFeatureTri(CTri &t, CTriVector &flist, float fc, ConvexDecompInterface * /*callback*/, unsigned int /*color*/) { bool ret = false; @@ -546,7 +546,7 @@ float computeConcavity(unsigned int vcount, unsigned int tcount, const unsigned int *indices, ConvexDecompInterface *callback, - float *plane, // plane equation to split on + float * /*plane*/, // plane equation to split on float &volume) { float cret = 0; @@ -623,12 +623,12 @@ float computeConcavity(unsigned int vcount, CTriVector input_mesh; if (1) { - const unsigned int *src = indices; + const unsigned int *srcIdx = indices; for (unsigned int i = 0; i < tcount; i++) { - unsigned int i1 = *src++; - unsigned int i2 = *src++; - unsigned int i3 = *src++; + unsigned int i1 = *srcIdx++; + unsigned int i2 = *srcIdx++; + unsigned int i3 = *srcIdx++; const float *p1 = &vertices[i1 * 3]; const float *p2 = &vertices[i2 * 3]; diff --git a/Extras/ConvexDecomposition/float_math.h b/Extras/ConvexDecomposition/float_math.h index b23280011a..241cee81e4 100644 --- a/Extras/ConvexDecomposition/float_math.h +++ b/Extras/ConvexDecomposition/float_math.h @@ -2,7 +2,7 @@ #define FLOAT_MATH_H -#ifdef _WIN32 +#ifdef _MSC_VER #pragma warning(disable : 4324) // disable padding warning #pragma warning(disable : 4244) // disable padding warning #pragma warning(disable : 4267) // possible loss of data diff --git a/Extras/ConvexDecomposition/meshvolume.cpp b/Extras/ConvexDecomposition/meshvolume.cpp index c7427d5712..5f63797d2d 100644 --- a/Extras/ConvexDecomposition/meshvolume.cpp +++ b/Extras/ConvexDecomposition/meshvolume.cpp @@ -50,7 +50,7 @@ float computeMeshVolume(const float *vertices, unsigned int tcount, const unsign const float *p2 = &vertices[indices[1] * 3]; const float *p3 = &vertices[indices[2] * 3]; - volume += det(p1, p2, p3); // compute the volume of the tetrahedran relative to the origin. + volume += det(p1, p2, p3); // compute the volume of the tetrahedron relative to the origin. } volume *= (1.0f / 6.0f); @@ -101,7 +101,7 @@ inline float tetVolume(const float *p0, const float *p1, const float *p2, const return volume; } -inline float det(const float *p0, const float *p1, const float *p2, const float *p3) +inline float det(const float * /*p0*/, const float *p1, const float *p2, const float *p3) { return p1[0] * p2[1] * p3[2] + p2[0] * p3[1] * p1[2] + p3[0] * p1[1] * p2[2] - p1[0] * p3[1] * p2[2] - p2[0] * p1[1] * p3[2] - p3[0] * p2[1] * p1[2]; } diff --git a/Extras/ConvexDecomposition/raytri.cpp b/Extras/ConvexDecomposition/raytri.cpp index 25f9cd3320..6c4e40ffd2 100644 --- a/Extras/ConvexDecomposition/raytri.cpp +++ b/Extras/ConvexDecomposition/raytri.cpp @@ -45,7 +45,7 @@ #define vector(a, b, c) \ (a)[0] = (b)[0] - (c)[0]; \ (a)[1] = (b)[1] - (c)[1]; \ - (a)[2] = (b)[2] - (c)[2]; + (a)[2] = (b)[2] - (c)[2] #define innerProduct(v, q) \ ((v)[0] * (q)[0] + \ @@ -55,7 +55,7 @@ #define crossProduct(a, b, c) \ (a)[0] = (b)[1] * (c)[2] - (c)[1] * (b)[2]; \ (a)[1] = (b)[2] * (c)[0] - (c)[2] * (b)[0]; \ - (a)[2] = (b)[0] * (c)[1] - (c)[0] * (b)[1]; + (a)[2] = (b)[0] * (c)[1] - (c)[0] * (b)[1] bool rayIntersectsTriangle(const float *p, const float *d, const float *v0, const float *v1, const float *v2, float &t) { diff --git a/Extras/ConvexDecomposition/splitplane.cpp b/Extras/ConvexDecomposition/splitplane.cpp index 22bfdd9cee..9814c63ebd 100644 --- a/Extras/ConvexDecomposition/splitplane.cpp +++ b/Extras/ConvexDecomposition/splitplane.cpp @@ -92,7 +92,7 @@ static void computePlane(const float *A, const float *B, const float *C, float * class Rect3d { public: - Rect3d(void){}; + Rect3d(void){} Rect3d(const float *bmin, const float *bmax) { @@ -137,7 +137,7 @@ class Rect3d float mMax[3]; }; -void splitRect(unsigned int axis, +static void splitRect(unsigned int axis, const Rect3d &source, Rect3d &b1, Rect3d &b2, @@ -168,15 +168,17 @@ void splitRect(unsigned int axis, b2.SetMin(source.mMin[0], source.mMin[1], midpoint[2]); b2.SetMax(source.mMax); + break; + default: break; } } bool computeSplitPlane(unsigned int vcount, const float *vertices, - unsigned int tcount, - const unsigned int *indices, - ConvexDecompInterface *callback, + unsigned int /*tcount*/, + const unsigned int * /*indices*/, + ConvexDecompInterface * /*callback*/, float *plane) { float bmin[3] = {1e9, 1e9, 1e9}; @@ -200,6 +202,7 @@ bool computeSplitPlane(unsigned int vcount, float dz = bmax[2] - bmin[2]; float laxis = dx; + (void)laxis; unsigned int axis = 0; @@ -214,6 +217,7 @@ bool computeSplitPlane(unsigned int vcount, axis = 2; laxis = dz; } + (void)laxis; float p1[3]; float p2[3]; @@ -281,6 +285,8 @@ bool computeSplitPlane(unsigned int vcount, p3[1] = bmax[1]; } + break; + default: break; } diff --git a/Extras/ConvexDecomposition/vlookup.cpp b/Extras/ConvexDecomposition/vlookup.cpp index ee181342e5..599f0698f8 100644 --- a/Extras/ConvexDecomposition/vlookup.cpp +++ b/Extras/ConvexDecomposition/vlookup.cpp @@ -4,7 +4,9 @@ #include #include +#ifdef _MSC_VER #pragma warning(disable : 4786) +#endif #include #include @@ -113,13 +115,13 @@ namespace Vlookup class VertexPosition { public: - VertexPosition(void){}; + VertexPosition(void){} VertexPosition(const float *p) { mPos[0] = p[0]; mPos[1] = p[1]; mPos[2] = p[2]; - }; + } void Set(int index, const float *pos) { @@ -128,11 +130,11 @@ class VertexPosition mPos[0] = p[0]; mPos[1] = p[1]; mPos[2] = p[2]; - }; + } - float GetX(void) const { return mPos[0]; }; - float GetY(void) const { return mPos[1]; }; - float GetZ(void) const { return mPos[2]; }; + float GetX(void) const { return mPos[0]; } + float GetY(void) const { return mPos[1]; } + float GetZ(void) const { return mPos[2]; } float mPos[3]; }; @@ -153,7 +155,7 @@ struct Tracker { mFind = match; mList = list; - }; + } }; struct VertexID @@ -178,7 +180,7 @@ class VertexLess { if (index.mID == -1) return index.mTracker->mFind; VertexVector &vlist = *index.mTracker->mList; - return vlist[index.mID]; + return vlist[(size_t)index.mID]; } }; @@ -202,31 +204,31 @@ class VertexPool mVtxs.push_back(vtx); mVertSet.insert(VertexID(idx, &mTracker)); return idx; - }; + } const float *GetPos(int idx) const { - return mVtxs[idx].mPos; + return mVtxs[(size_t)idx].mPos; } const Type &Get(int idx) const { return mVtxs[idx]; - }; + } unsigned int GetSize(void) const { return mVtxs.size(); - }; + } void Clear(int reservesize) // clear the vertice pool. { mVertSet.clear(); mVtxs.clear(); mVtxs.reserve(reservesize); - }; + } - const VertexVector &GetVertexList(void) const { return mVtxs; }; + const VertexVector &GetVertexList(void) const { return mVtxs; } void Set(const Type &vtx) { @@ -235,13 +237,13 @@ class VertexPool unsigned int GetVertexCount(void) const { - return mVtxs.size(); - }; + return (unsigned int)mVtxs.size(); + } Type *getBuffer(void) { return &mVtxs[0]; - }; + } private: VertexSet mVertSet; // ordered list. @@ -295,7 +297,7 @@ unsigned int Vl_getIndex(VertexLookup vlook, const float *pos) // get index. { VertexPool *vp = (VertexPool *)vlook; VertexPosition p(pos); - return vp->getVertex(p); + return (unsigned int)vp->getVertex(p); } const float *Vl_getVertices(VertexLookup vlook) diff --git a/Extras/GIMPACTUtils/CMakeLists.txt b/Extras/GIMPACTUtils/CMakeLists.txt index c32a885dfb..d6f48dd3f5 100644 --- a/Extras/GIMPACTUtils/CMakeLists.txt +++ b/Extras/GIMPACTUtils/CMakeLists.txt @@ -1,5 +1,4 @@ INCLUDE_DIRECTORIES( -${BULLET_PHYSICS_SOURCE_DIR}/Extras/GIMPACT/include ${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Extras/GIMPACTUtils ${BULLET_PHYSICS_SOURCE_DIR}/Extras/ConvexDecomposition diff --git a/Extras/GIMPACTUtils/btGImpactConvexDecompositionShape.cpp b/Extras/GIMPACTUtils/btGImpactConvexDecompositionShape.cpp index 755021483a..b2da5604e4 100644 --- a/Extras/GIMPACTUtils/btGImpactConvexDecompositionShape.cpp +++ b/Extras/GIMPACTUtils/btGImpactConvexDecompositionShape.cpp @@ -129,10 +129,10 @@ class GIM_ConvexDecomposition : public ConvexDecomposition::ConvexDecompInterfac for (int vi = 0; vi < trimeshInterface->get_vertex_count(); vi++) { btVector3 vec; - trimeshInterface->get_vertex(vi, vec); - vertices.push_back(vec[0]); - vertices.push_back(vec[1]); - vertices.push_back(vec[2]); + trimeshInterface->get_vertex((unsigned int)vi, vec); + vertices.push_back((float)vec[0]); + vertices.push_back((float)vec[1]); + vertices.push_back((float)vec[2]); } //collect indices @@ -157,9 +157,9 @@ class GIM_ConvexDecomposition : public ConvexDecomposition::ConvexDecompInterfac float skinWidth = 0.0f; ConvexDecomposition::DecompDesc desc; - desc.mVcount = trimeshInterface->get_vertex_count(); + desc.mVcount = (unsigned int)trimeshInterface->get_vertex_count(); desc.mVertices = &vertices[0]; - desc.mTcount = trimeshInterface->get_primitive_count(); + desc.mTcount = (unsigned int)trimeshInterface->get_primitive_count(); desc.mIndices = &indices[0]; desc.mDepth = depth; desc.mCpercent = cpercent; @@ -192,7 +192,7 @@ btGImpactConvexDecompositionShape::~btGImpactConvexDecompositionShape() { delete m_decomposition; } -void btGImpactConvexDecompositionShape::processAllTriangles(btTriangleCallback* callback, const btVector3& aabbMin, const btVector3& aabbMax) const +void btGImpactConvexDecompositionShape::processAllTriangles(btTriangleCallback* callback, const btVector3& /*aabbMin*/, const btVector3& /*aabbMax*/) const { int part_count = m_trimeshInterfaces.size(); for (int part = 0; part < part_count; part++) diff --git a/Extras/GIMPACTUtils/btGImpactConvexDecompositionShape.h b/Extras/GIMPACTUtils/btGImpactConvexDecompositionShape.h index 47a327065c..4adddf3dc3 100644 --- a/Extras/GIMPACTUtils/btGImpactConvexDecompositionShape.h +++ b/Extras/GIMPACTUtils/btGImpactConvexDecompositionShape.h @@ -1,5 +1,5 @@ /*! \file btGImpactConvexDecompositionShape.h -\author Francisco León Nájera +\author Francisco León Nájera */ /* This source file is part of GIMPACT Library. diff --git a/Extras/HACD/hacdCircularList.h b/Extras/HACD/hacdCircularList.h index d09237ae27..2442d11a55 100644 --- a/Extras/HACD/hacdCircularList.h +++ b/Extras/HACD/hacdCircularList.h @@ -65,7 +65,7 @@ class CircularList { while (Delete()) ; - }; + } const CircularList& operator=(const CircularList& rhs); //! Constructor CircularList() @@ -75,7 +75,7 @@ class CircularList } CircularList(const CircularList& rhs); //! Destructor - virtual ~CircularList(void) { Clear(); }; + virtual ~CircularList(void) { Clear(); } private: CircularListElement* m_head; //!< a pointer to the head of the circular list diff --git a/Extras/HACD/hacdCircularList.inl b/Extras/HACD/hacdCircularList.inl index 471f9ed449..25717e6970 100644 --- a/Extras/HACD/hacdCircularList.inl +++ b/Extras/HACD/hacdCircularList.inl @@ -16,12 +16,12 @@ namespace HACD { CircularListElement * next = element->GetNext(); CircularListElement * prev = element->GetPrev(); + if (element == m_head) + { + m_head = next; + } delete element; m_size--; - if (element == m_head) - { - m_head = next; - } next->GetPrev() = prev; prev->GetNext() = next; return true; diff --git a/Extras/HACD/hacdGraph.cpp b/Extras/HACD/hacdGraph.cpp index 486dc30ee0..eb72fd53f1 100644 --- a/Extras/HACD/hacdGraph.cpp +++ b/Extras/HACD/hacdGraph.cpp @@ -79,7 +79,7 @@ long Graph::AddVertex() { size_t name = m_vertices.size(); m_vertices.resize(name + 1); - m_vertices[name].m_name = static_cast(name); + m_vertices[(size_t)name].m_name = static_cast(name); m_nV++; return static_cast(name); } @@ -88,11 +88,11 @@ long Graph::AddEdge(long v1, long v2) { size_t name = m_edges.size(); m_edges.push_back(GraphEdge()); - m_edges[name].m_name = static_cast(name); - m_edges[name].m_v1 = v1; - m_edges[name].m_v2 = v2; - m_vertices[v1].AddEdge(static_cast(name)); - m_vertices[v2].AddEdge(static_cast(name)); + m_edges[(size_t)name].m_name = static_cast(name); + m_edges[(size_t)name].m_v1 = v1; + m_edges[(size_t)name].m_v2 = v2; + m_vertices[(size_t)v1].AddEdge(static_cast(name)); + m_vertices[(size_t)v2].AddEdge(static_cast(name)); m_nE++; return static_cast(name); } @@ -101,15 +101,15 @@ bool Graph::DeleteEdge(long name) { if (name < static_cast(m_edges.size())) { - long v1 = m_edges[name].m_v1; - long v2 = m_edges[name].m_v2; - m_edges[name].m_deleted = true; - m_vertices[v1].DeleteEdge(name); - m_vertices[v2].DeleteEdge(name); - delete m_edges[name].m_convexHull; - m_edges[name].m_distPoints.clear(); - m_edges[name].m_boudaryEdges.clear(); - m_edges[name].m_convexHull = 0; + long v1 = m_edges[(size_t)name].m_v1; + long v2 = m_edges[(size_t)name].m_v2; + m_edges[(size_t)name].m_deleted = true; + m_vertices[(size_t)v1].DeleteEdge(name); + m_vertices[(size_t)v2].DeleteEdge(name); + delete m_edges[(size_t)name].m_convexHull; + m_edges[(size_t)name].m_distPoints.clear(); + m_edges[(size_t)name].m_boudaryEdges.clear(); + m_edges[(size_t)name].m_convexHull = 0; m_nE--; return true; } @@ -119,13 +119,13 @@ bool Graph::DeleteVertex(long name) { if (name < static_cast(m_vertices.size())) { - m_vertices[name].m_deleted = true; - m_vertices[name].m_edges.clear(); - m_vertices[name].m_ancestors = std::vector(); - delete m_vertices[name].m_convexHull; - m_vertices[name].m_distPoints.clear(); - m_vertices[name].m_boudaryEdges.clear(); - m_vertices[name].m_convexHull = 0; + m_vertices[(size_t)name].m_deleted = true; + m_vertices[(size_t)name].m_edges.clear(); + m_vertices[(size_t)name].m_ancestors = std::vector(); + delete m_vertices[(size_t)name].m_convexHull; + m_vertices[(size_t)name].m_distPoints.clear(); + m_vertices[(size_t)name].m_boudaryEdges.clear(); + m_vertices[(size_t)name].m_convexHull = 0; m_nV--; return true; } @@ -139,36 +139,36 @@ bool Graph::EdgeCollapse(long v1, long v2) // delete the edge (v1, v2) DeleteEdge(edgeToDelete); // add v2 to v1 ancestors - m_vertices[v1].m_ancestors.push_back(v2); + m_vertices[(size_t)v1].m_ancestors.push_back(v2); // add v2's ancestors to v1's ancestors - m_vertices[v1].m_ancestors.insert(m_vertices[v1].m_ancestors.begin(), - m_vertices[v2].m_ancestors.begin(), - m_vertices[v2].m_ancestors.end()); + m_vertices[(size_t)v1].m_ancestors.insert(m_vertices[(size_t)v1].m_ancestors.begin(), + m_vertices[(size_t)v2].m_ancestors.begin(), + m_vertices[(size_t)v2].m_ancestors.end()); // update adjacency information - std::set& v1Edges = m_vertices[v1].m_edges; - std::set::const_iterator ed(m_vertices[v2].m_edges.begin()); - std::set::const_iterator itEnd(m_vertices[v2].m_edges.end()); + std::set& v1Edges = m_vertices[(size_t)v1].m_edges; + std::set::const_iterator ed(m_vertices[(size_t)v2].m_edges.begin()); + std::set::const_iterator itEnd(m_vertices[(size_t)v2].m_edges.end()); long b = -1; for (; ed != itEnd; ++ed) { - if (m_edges[*ed].m_v1 == v2) + if (m_edges[(size_t)*ed].m_v1 == v2) { - b = m_edges[*ed].m_v2; + b = m_edges[(size_t)*ed].m_v2; } else { - b = m_edges[*ed].m_v1; + b = m_edges[(size_t)*ed].m_v1; } if (GetEdgeID(v1, b) >= 0) { - m_edges[*ed].m_deleted = true; - m_vertices[b].DeleteEdge(*ed); + m_edges[(size_t)*ed].m_deleted = true; + m_vertices[(size_t)b].DeleteEdge(*ed); m_nE--; } else { - m_edges[*ed].m_v1 = v1; - m_edges[*ed].m_v2 = b; + m_edges[(size_t)*ed].m_v1 = v1; + m_edges[(size_t)*ed].m_v2 = b; v1Edges.insert(*ed); } } @@ -181,16 +181,16 @@ bool Graph::EdgeCollapse(long v1, long v2) long Graph::GetEdgeID(long v1, long v2) const { - if (v1 < static_cast(m_vertices.size()) && !m_vertices[v1].m_deleted) + if (v1 < static_cast(m_vertices.size()) && !m_vertices[(size_t)v1].m_deleted) { - std::set::const_iterator ed(m_vertices[v1].m_edges.begin()); - std::set::const_iterator itEnd(m_vertices[v1].m_edges.end()); + std::set::const_iterator ed(m_vertices[(size_t)v1].m_edges.begin()); + std::set::const_iterator itEnd(m_vertices[(size_t)v1].m_edges.end()); for (; ed != itEnd; ++ed) { - if ((m_edges[*ed].m_v1 == v2) || - (m_edges[*ed].m_v2 == v2)) + if ((m_edges[(size_t)*ed].m_v1 == v2) || + (m_edges[(size_t)*ed].m_v2 == v2)) { - return m_edges[*ed].m_name; + return m_edges[(size_t)*ed].m_name; } } } @@ -211,7 +211,7 @@ void Graph::Print() const std::set::const_iterator itEnd(currentVertex.m_edges.end()); for (; ed != itEnd; ++ed) { - std::cout << "(" << m_edges[*ed].m_v1 << "," << m_edges[*ed].m_v2 << ") "; + std::cout << "(" << m_edges[(size_t)*ed].m_v1 << "," << m_edges[(size_t)*ed].m_v2 << ") "; } std::cout << std::endl; } @@ -263,21 +263,21 @@ long Graph::ExtractCCs() { long vertex = temp[temp.size() - 1]; temp.pop_back(); - std::set::const_iterator ed(m_vertices[vertex].m_edges.begin()); - std::set::const_iterator itEnd(m_vertices[vertex].m_edges.end()); + std::set::const_iterator ed(m_vertices[(size_t)vertex].m_edges.begin()); + std::set::const_iterator itEnd(m_vertices[(size_t)vertex].m_edges.end()); for (; ed != itEnd; ++ed) { - if (m_edges[*ed].m_v1 == vertex) + if (m_edges[(size_t)*ed].m_v1 == vertex) { - v2 = m_edges[*ed].m_v2; + v2 = m_edges[(size_t)*ed].m_v2; } else { - v2 = m_edges[*ed].m_v1; + v2 = m_edges[(size_t)*ed].m_v1; } - if (!m_vertices[v2].m_deleted && m_vertices[v2].m_cc == -1) + if (!m_vertices[(size_t)v2].m_deleted && m_vertices[(size_t)v2].m_cc == -1) { - m_vertices[v2].m_cc = static_cast(m_nCCs); + m_vertices[(size_t)v2].m_cc = static_cast(m_nCCs); temp.push_back(v2); } } diff --git a/Extras/HACD/hacdGraph.h b/Extras/HACD/hacdGraph.h index 7df9dd51fc..4f7d79681d 100644 --- a/Extras/HACD/hacdGraph.h +++ b/Extras/HACD/hacdGraph.h @@ -39,7 +39,7 @@ class GraphVertex } bool DeleteEdge(long name); GraphVertex(); - ~GraphVertex() { delete m_convexHull; }; + ~GraphVertex() { delete m_convexHull; } private: long m_name; @@ -66,7 +66,7 @@ class GraphEdge { public: GraphEdge(); - ~GraphEdge() { delete m_convexHull; }; + ~GraphEdge() { delete m_convexHull; } private: long m_name; diff --git a/Extras/HACD/hacdHACD.cpp b/Extras/HACD/hacdHACD.cpp index d9347e0c2c..0224191ee7 100644 --- a/Extras/HACD/hacdHACD.cpp +++ b/Extras/HACD/hacdHACD.cpp @@ -26,7 +26,7 @@ #include #include "assert.h" -bool gCancelRequest = false; +static bool gCancelRequest = false; namespace HACD { double HACD::Concavity(ICHull& ch, std::map& distPoints) @@ -67,9 +67,9 @@ void HACD::CreateGraph() vertexToTriangles.resize(m_nPoints); for (size_t t = 0; t < m_nTriangles; ++t) { - vertexToTriangles[m_triangles[t].X()].insert(static_cast(t)); - vertexToTriangles[m_triangles[t].Y()].insert(static_cast(t)); - vertexToTriangles[m_triangles[t].Z()].insert(static_cast(t)); + vertexToTriangles[(size_t)m_triangles[t].X()].insert(static_cast(t)); + vertexToTriangles[(size_t)m_triangles[t].Y()].insert(static_cast(t)); + vertexToTriangles[(size_t)m_triangles[t].Z()].insert(static_cast(t)); } m_graph.Clear(); @@ -87,9 +87,9 @@ void HACD::CreateGraph() i1 = m_triangles[t1].X(); j1 = m_triangles[t1].Y(); k1 = m_triangles[t1].Z(); - tr1[0] = GetEdgeIndex(i1, j1); - tr1[1] = GetEdgeIndex(j1, k1); - tr1[2] = GetEdgeIndex(k1, i1); + tr1[0] = GetEdgeIndex((unsigned long long)i1, (unsigned long long)j1); + tr1[1] = GetEdgeIndex((unsigned long long)j1, (unsigned long long)k1); + tr1[2] = GetEdgeIndex((unsigned long long)k1, (unsigned long long)i1); std::set::const_iterator it2(it1); for (++it2; it2 != itEnd; ++it2) { @@ -97,9 +97,9 @@ void HACD::CreateGraph() i2 = m_triangles[t2].X(); j2 = m_triangles[t2].Y(); k2 = m_triangles[t2].Z(); - tr2[0] = GetEdgeIndex(i2, j2); - tr2[1] = GetEdgeIndex(j2, k2); - tr2[2] = GetEdgeIndex(k2, i2); + tr2[0] = GetEdgeIndex((unsigned long long)i2, (unsigned long long)j2); + tr2[1] = GetEdgeIndex((unsigned long long)j2, (unsigned long long)k2); + tr2[2] = GetEdgeIndex((unsigned long long)k2, (unsigned long long)i2); int shared = 0; for (int i = 0; i < 3; ++i) { @@ -129,9 +129,9 @@ void HACD::CreateGraph() for (size_t t = 0; t < m_nTriangles; ++t) { cc = m_graph.m_vertices[t].m_cc; - cc2V[cc].insert(m_triangles[t].X()); - cc2V[cc].insert(m_triangles[t].Y()); - cc2V[cc].insert(m_triangles[t].Z()); + cc2V[(size_t)cc].insert(m_triangles[t].X()); + cc2V[(size_t)cc].insert(m_triangles[t].Y()); + cc2V[(size_t)cc].insert(m_triangles[t].Z()); } for (size_t cc1 = 0; cc1 < m_graph.m_nCCs; ++cc1) @@ -152,10 +152,10 @@ void HACD::CreateGraph() if (dist < distC1C2) { distC1C2 = dist; - t1 = *vertexToTriangles[*itV1].begin(); + t1 = *vertexToTriangles[(size_t)*itV1].begin(); - std::set::const_iterator it2(vertexToTriangles[*itV2].begin()), - it2End(vertexToTriangles[*itV2].end()); + std::set::const_iterator it2(vertexToTriangles[(size_t)*itV2].begin()), + it2End(vertexToTriangles[(size_t)*itV2].end()); t2 = -1; for (; it2 != it2End; ++it2) { @@ -190,10 +190,10 @@ void HACD::InitializeDualGraph() m_facePoints = new Vec3[m_nTriangles]; m_faceNormals = new Vec3[m_nTriangles]; } - memset(m_normals, 0, sizeof(Vec3) * m_nPoints); + memset((void*)m_normals, 0, sizeof(Vec3) * m_nPoints); for (unsigned long f = 0; f < m_nTriangles; f++) { - if (m_callBack) (*m_callBack)("+ InitializeDualGraph\n", f, m_nTriangles, 0); + if (m_callBack) (*m_callBack)("+ InitializeDualGraph\n", (double)f, (double)m_nTriangles, 0); if (gCancelRequest) return; @@ -227,9 +227,9 @@ void HACD::InitializeDualGraph() normal.Normalize(); - m_graph.m_vertices[f].m_boudaryEdges.insert(GetEdgeIndex(i, j)); - m_graph.m_vertices[f].m_boudaryEdges.insert(GetEdgeIndex(j, k)); - m_graph.m_vertices[f].m_boudaryEdges.insert(GetEdgeIndex(k, i)); + m_graph.m_vertices[f].m_boudaryEdges.insert(GetEdgeIndex((unsigned long)i, (unsigned long)j)); + m_graph.m_vertices[f].m_boudaryEdges.insert(GetEdgeIndex((unsigned long)j, (unsigned long)k)); + m_graph.m_vertices[f].m_boudaryEdges.insert(GetEdgeIndex((unsigned long)k, (unsigned long)i)); if (m_addFacesPoints) { m_faceNormals[f] = normal; @@ -284,9 +284,9 @@ void HACD::InitializeDualGraph() } } } - for (size_t v = 0; v < m_nPoints; v++) + for (size_t p = 0; p < m_nPoints; p++) { - m_normals[v].Normalize(); + m_normals[p].Normalize(); } } @@ -378,22 +378,22 @@ HACD::~HACD(void) delete[] m_facePoints; delete[] m_faceNormals; } -int iteration = 0; +static int iteration = 0; void HACD::ComputeEdgeCost(size_t e) { GraphEdge& gE = m_graph.m_edges[e]; long v1 = gE.m_v1; long v2 = gE.m_v2; - if (m_graph.m_vertices[v2].m_distPoints.size() > m_graph.m_vertices[v1].m_distPoints.size()) + if (m_graph.m_vertices[(size_t)v2].m_distPoints.size() > m_graph.m_vertices[(size_t)v1].m_distPoints.size()) { gE.m_v1 = v2; gE.m_v2 = v1; //std::swap(v1, v2); std::swap(v1, v2); } - GraphVertex& gV1 = m_graph.m_vertices[v1]; - GraphVertex& gV2 = m_graph.m_vertices[v2]; + GraphVertex& gV1 = m_graph.m_vertices[(size_t)v1]; + GraphVertex& gV2 = m_graph.m_vertices[(size_t)v2]; // delete old convex-hull delete gE.m_convexHull; @@ -454,13 +454,13 @@ void HACD::ComputeEdgeCost(size_t e) if (ch->IsFlat()) { bool insideHull; - std::map::iterator itDP(gE.m_distPoints.begin()); - std::map::iterator itDPEnd(gE.m_distPoints.end()); - for (; itDP != itDPEnd; ++itDP) + std::map::iterator iterDP(gE.m_distPoints.begin()); + std::map::iterator iterDPEnd(gE.m_distPoints.end()); + for (; iterDP != iterDPEnd; ++iterDP) { - if (itDP->first >= 0) + if (iterDP->first >= 0) { - concavity = std::max(concavity, ch->ComputeDistance(itDP->first, m_points[itDP->first], m_normals[itDP->first], insideHull, false)); + concavity = std::max(concavity, ch->ComputeDistance(iterDP->first, m_points[iterDP->first], m_normals[iterDP->first], insideHull, false)); } } } @@ -480,8 +480,8 @@ void HACD::ComputeEdgeCost(size_t e) long a, b, c; for (; ed != itEnd; ++ed) { - a = m_graph.m_edges[*ed].m_v1; - b = m_graph.m_edges[*ed].m_v2; + a = m_graph.m_edges[(size_t)*ed].m_v1; + b = m_graph.m_edges[(size_t)*ed].m_v2; if (a != v2 && a != v1) { c = a; @@ -496,22 +496,22 @@ void HACD::ComputeEdgeCost(size_t e) } if (c > 0) { - GraphVertex& gVC = m_graph.m_vertices[c]; - std::map::iterator itDP(gVC.m_distPoints.begin()); - std::map::iterator itDPEnd(gVC.m_distPoints.end()); - std::map::iterator itDP1; - for (; itDP != itDPEnd; ++itDP) + GraphVertex& gVC = m_graph.m_vertices[(size_t)c]; + std::map::iterator iterDP(gVC.m_distPoints.begin()); + std::map::iterator iterDPEnd(gVC.m_distPoints.end()); + std::map::iterator iterDP1; + for (; iterDP != iterDPEnd; ++iterDP) { - itDP1 = gE.m_distPoints.find(itDP->first); - if (itDP1 == gE.m_distPoints.end()) + iterDP1 = gE.m_distPoints.find(iterDP->first); + if (iterDP1 == gE.m_distPoints.end()) { - if (itDP->first >= 0 && itDP1 == gE.m_distPoints.end() && ch->IsInside(m_points[itDP->first])) + if (iterDP->first >= 0 && iterDP1 == gE.m_distPoints.end() && ch->IsInside(m_points[iterDP->first])) { - gE.m_distPoints[itDP->first].m_distOnly = true; + gE.m_distPoints[iterDP->first].m_distOnly = true; } - else if (itDP->first < 0 && ch->IsInside(m_facePoints[-itDP->first - 1])) + else if (iterDP->first < 0 && ch->IsInside(m_facePoints[-iterDP->first - 1])) { - gE.m_distPoints[itDP->first].m_distOnly = true; + gE.m_distPoints[iterDP->first].m_distOnly = true; } } } @@ -521,7 +521,7 @@ void HACD::ComputeEdgeCost(size_t e) concavity = Concavity(*ch, gE.m_distPoints); } - // compute boudary edges + // compute boundary edges double perimeter = 0.0; double surf = 1.0; if (m_alpha > 0.0) @@ -556,7 +556,7 @@ bool HACD::InitializePriorityQueue() m_pqueue.reserve(m_graph.m_nE + 100); for (size_t e = 0; e < m_graph.m_nE; ++e) { - ComputeEdgeCost(static_cast(e)); + ComputeEdgeCost((size_t)static_cast(e)); m_pqueue.push(GraphEdgePriorityQueue(static_cast(e), m_graph.m_edges[e].m_error)); } return true; @@ -574,7 +574,7 @@ void HACD::Simplify() (m_graph.GetNVertices() > m_nMinClusters) && (m_graph.GetNEdges() > 0)) { - progress = 100.0 - m_graph.GetNVertices() * 100.0 / m_nTriangles; + progress = 100.0 - (double)m_graph.GetNVertices() * 100.0 / (double)m_nTriangles; if (fabs(progress - progressOld) > ptgStep && m_callBack) { sprintf(msg, "%3.2f %% V = %lu \t C = %f \t \t \r", progress, static_cast(m_graph.GetNVertices()), globalConcavity); @@ -602,35 +602,35 @@ void HACD::Simplify() } currentEdge = m_pqueue.top(); m_pqueue.pop(); - } while (m_graph.m_edges[currentEdge.m_name].m_deleted || - m_graph.m_edges[currentEdge.m_name].m_error != currentEdge.m_priority); + } while (m_graph.m_edges[(size_t)currentEdge.m_name].m_deleted || + m_graph.m_edges[(size_t)currentEdge.m_name].m_error != currentEdge.m_priority); - if (m_graph.m_edges[currentEdge.m_name].m_concavity < m_concavity && !done) + if (m_graph.m_edges[(size_t)currentEdge.m_name].m_concavity < m_concavity && !done) { - globalConcavity = std::max(globalConcavity, m_graph.m_edges[currentEdge.m_name].m_concavity); - v1 = m_graph.m_edges[currentEdge.m_name].m_v1; - v2 = m_graph.m_edges[currentEdge.m_name].m_v2; + globalConcavity = std::max(globalConcavity, m_graph.m_edges[(size_t)currentEdge.m_name].m_concavity); + v1 = m_graph.m_edges[(size_t)currentEdge.m_name].m_v1; + v2 = m_graph.m_edges[(size_t)currentEdge.m_name].m_v2; // update vertex info - m_graph.m_vertices[v1].m_error = m_graph.m_edges[currentEdge.m_name].m_error; - m_graph.m_vertices[v1].m_surf = m_graph.m_edges[currentEdge.m_name].m_surf; - m_graph.m_vertices[v1].m_volume = m_graph.m_edges[currentEdge.m_name].m_volume; - m_graph.m_vertices[v1].m_concavity = m_graph.m_edges[currentEdge.m_name].m_concavity; - m_graph.m_vertices[v1].m_perimeter = m_graph.m_edges[currentEdge.m_name].m_perimeter; - m_graph.m_vertices[v1].m_distPoints = m_graph.m_edges[currentEdge.m_name].m_distPoints; - (*m_graph.m_vertices[v1].m_convexHull) = (*m_graph.m_edges[currentEdge.m_name].m_convexHull); - (m_graph.m_vertices[v1].m_convexHull)->SetDistPoints(&(m_graph.m_vertices[v1].m_distPoints)); - m_graph.m_vertices[v1].m_boudaryEdges = m_graph.m_edges[currentEdge.m_name].m_boudaryEdges; + m_graph.m_vertices[(size_t)v1].m_error = m_graph.m_edges[(size_t)currentEdge.m_name].m_error; + m_graph.m_vertices[(size_t)v1].m_surf = m_graph.m_edges[(size_t)currentEdge.m_name].m_surf; + m_graph.m_vertices[(size_t)v1].m_volume = m_graph.m_edges[(size_t)currentEdge.m_name].m_volume; + m_graph.m_vertices[(size_t)v1].m_concavity = m_graph.m_edges[(size_t)currentEdge.m_name].m_concavity; + m_graph.m_vertices[(size_t)v1].m_perimeter = m_graph.m_edges[(size_t)currentEdge.m_name].m_perimeter; + m_graph.m_vertices[(size_t)v1].m_distPoints = m_graph.m_edges[(size_t)currentEdge.m_name].m_distPoints; + (*m_graph.m_vertices[(size_t)v1].m_convexHull) = (*m_graph.m_edges[(size_t)currentEdge.m_name].m_convexHull); + (m_graph.m_vertices[(size_t)v1].m_convexHull)->SetDistPoints(&(m_graph.m_vertices[(size_t)v1].m_distPoints)); + m_graph.m_vertices[(size_t)v1].m_boudaryEdges = m_graph.m_edges[(size_t)currentEdge.m_name].m_boudaryEdges; // We apply the optimal ecol // std::cout << "v1 " << v1 << " v2 " << v2 << std::endl; m_graph.EdgeCollapse(v1, v2); // recompute the adjacent edges costs - std::set::const_iterator itE(m_graph.m_vertices[v1].m_edges.begin()), - itEEnd(m_graph.m_vertices[v1].m_edges.end()); + std::set::const_iterator itE(m_graph.m_vertices[(size_t)v1].m_edges.begin()), + itEEnd(m_graph.m_vertices[(size_t)v1].m_edges.end()); for (; itE != itEEnd; ++itE) { - size_t e = *itE; - ComputeEdgeCost(static_cast(e)); + size_t e = (size_t)*itE; + ComputeEdgeCost((size_t)static_cast(e)); m_pqueue.push(GraphEdgePriorityQueue(static_cast(e), m_graph.m_edges[e].m_error)); } } @@ -653,9 +653,9 @@ void HACD::Simplify() { if (m_callBack) { - char msg[1024]; - sprintf(msg, "\t CH \t %lu \t %lf \t %lf\n", static_cast(p), m_graph.m_vertices[v].m_concavity, m_graph.m_vertices[v].m_error); - (*m_callBack)(msg, 0.0, 0.0, m_nClusters); + char message[1024]; + sprintf(message, "\t CH \t %lu \t %f \t %f\n", static_cast(p), m_graph.m_vertices[v].m_concavity, m_graph.m_vertices[v].m_error); + (*m_callBack)(message, 0.0, 0.0, m_nClusters); p++; } m_cVertices.push_back(static_cast(v)); @@ -686,8 +686,8 @@ bool HACD::Compute(bool fullCH, bool exportDistPoints) msg << "+ Parameters" << std::endl; msg << "\t min # of clusters \t" << m_nMinClusters << std::endl; msg << "\t max concavity \t" << m_concavity << std::endl; - msg << "\t compacity weigth \t" << m_alpha << std::endl; - msg << "\t volume weigth \t" << m_beta << std::endl; + msg << "\t compacity weight \t" << m_alpha << std::endl; + msg << "\t volume weight \t" << m_beta << std::endl; msg << "\t # vertices per convex-hull \t" << m_nVerticesPerCH << std::endl; msg << "\t scale \t" << m_scale << std::endl; msg << "\t add extra distance points \t" << m_addExtraDistPoints << std::endl; @@ -724,7 +724,7 @@ bool HACD::Compute(bool fullCH, bool exportDistPoints) m_partition = new long[m_nTriangles]; for (size_t p = 0; p != m_cVertices.size(); ++p) { - size_t v = m_cVertices[p]; + size_t v = (size_t)m_cVertices[p]; m_partition[v] = static_cast(p); for (size_t a = 0; a < m_graph.m_vertices[v].m_ancestors.size(); a++) { diff --git a/Extras/HACD/hacdHACD.h b/Extras/HACD/hacdHACD.h index efb0fe85ee..71a26255a5 100644 --- a/Extras/HACD/hacdHACD.h +++ b/Extras/HACD/hacdHACD.h @@ -29,7 +29,7 @@ namespace HACD const double sc_pi = 3.14159265; class HACD; -// just to be able to set the capcity of the container +// just to be able to set the capacity of the container template , class _Pr = std::less > class reservable_priority_queue : public std::priority_queue<_Ty, _Container, _Pr> @@ -37,7 +37,7 @@ class reservable_priority_queue : public std::priority_queue<_Ty, _Container, _P typedef typename std::priority_queue<_Ty, _Container, _Pr>::size_type size_type; public: - reservable_priority_queue(size_type capacity = 0) { reserve(capacity); }; + reservable_priority_queue(size_type capacity = 0) { reserve(capacity); } void reserve(size_type capacity) { this->c.reserve(capacity); } size_type capacity() const { return this->c.capacity(); } }; @@ -99,19 +99,19 @@ class HACD //! Specifies whether faces points should be added when computing the concavity //! @param addFacesPoints true = faces points should be added void SetAddFacesPoints(bool addFacesPoints) { m_addFacesPoints = addFacesPoints; } - //! Specifies wheter faces points should be added when computing the concavity + //! Specifies whether faces points should be added when computing the concavity //! @return true = faces points should be added bool GetAddFacesPoints() const { return m_addFacesPoints; } //! Specifies whether extra points should be added when computing the concavity - //! @param addExteraDistPoints true = extra points should be added + //! @param addExtraDistPoints true = extra points should be added void SetAddExtraDistPoints(bool addExtraDistPoints) { m_addExtraDistPoints = addExtraDistPoints; } - //! Specifies wheter extra points should be added when computing the concavity + //! Specifies whether extra points should be added when computing the concavity //! @return true = extra points should be added bool GetAddExtraDistPoints() const { return m_addExtraDistPoints; } //! Specifies whether extra points should be added when computing the concavity - //! @param addExteraDistPoints true = extra points should be added + //! @param addNeighboursDistPoints true = extra points should be added void SetAddNeighboursDistPoints(bool addNeighboursDistPoints) { m_addNeighboursDistPoints = addNeighboursDistPoints; } - //! Specifies wheter extra points should be added when computing the concavity + //! Specifies whether extra points should be added when computing the concavity //! @return true = extra points should be added bool GetAddNeighboursDistPoints() const { return m_addNeighboursDistPoints; } //! Sets the points of the input mesh (Remark: the input points will be scaled and shifted. Use DenormalizeData() to invert those operations) @@ -151,7 +151,7 @@ class HACD //! @return maximum concavity double GetConcavity() const { return m_concavity; } //! Sets the maximum allowed distance to get CCs connected. - //! @param concavity maximum distance to get CCs connected + //! @param ccConnectDist maximum distance to get CCs connected void SetConnectDist(double ccConnectDist) { m_ccConnectDist = ccConnectDist; } //! Gives the maximum allowed distance to get CCs connected. //! @return maximum distance to get CCs connected @@ -185,18 +185,18 @@ class HACD //! @param numCH cluster's number //! @param points pointer to the vector of points to be filled //! @param triangles pointer to the vector of triangles to be filled - //! @return true if sucess + //! @return true if success bool GetCH(size_t numCH, Vec3 *const points, Vec3 *const triangles); //! Computes the HACD decomposition. //! @param fullCH specifies whether to generate convex-hulls with a full or limited (i.e. < m_nVerticesPerCH) number of vertices - //! @param exportDistPoints specifies wheter distance points should ne exported or not (used only for debugging). - //! @return true if sucess + //! @param exportDistPoints specifies whether distance points should ne exported or not (used only for debugging). + //! @return true if success bool Compute(bool fullCH = false, bool exportDistPoints = false); //! Saves the generated convex-hulls in a VRML 2.0 file. //! @param fileName the output file name //! @param uniColor specifies whether the different convex-hulls should have the same color or not //! @param numCluster specifies the cluster to be saved, if numCluster < 0 export all clusters - //! @return true if sucess + //! @return true if success bool Save(const char *fileName, bool uniColor, long numCluster = -1) const; //! Shifts and scales to the data to have all the coordinates between 0.0 and 1000.0. void NormalizeData(); @@ -226,7 +226,6 @@ class HACD double Concavity(ICHull &ch, std::map &distPoints); //! Computes the perimeter of a cluster. //! @param triIndices the cluster's triangles - //! @param distPoints the cluster's points //! @return cluster's perimeter double ComputePerimeter(const std::vector &triIndices) const; //! Creates the Graph by associating to each mesh triangle a vertex in the graph and to each couple of adjacent triangles an edge in the graph. @@ -237,7 +236,6 @@ class HACD //! @param e edge's id void ComputeEdgeCost(size_t e); //! Initializes the priority queue - //! @param fast specifies whether fast mode is used //! @return true if success bool InitializePriorityQueue(); //! Cleans the intersection between convex-hulls @@ -246,7 +244,6 @@ class HACD //! @param fullCH specifies whether to generate convex-hulls with a full or limited (i.e. < m_nVerticesPerCH) number of vertices void ComputeConvexHulls(bool fullCH); //! Simplifies the graph - //! @param fast specifies whether fast mode is used void Simplify(); private: @@ -262,8 +259,8 @@ class HACD size_t m_nMinClusters; //>! minimum number of clusters double m_ccConnectDist; //>! maximum allowed distance to connect CCs double m_concavity; //>! maximum concavity - double m_alpha; //>! compacity weigth - double m_beta; //>! volume weigth + double m_alpha; //>! compacity weight + double m_beta; //>! volume weight double m_diag; //>! length of the BB diagonal Vec3 m_barycenter; //>! barycenter of the mesh std::vector m_cVertices; //>! array of vertices each belonging to a different cluster diff --git a/Extras/HACD/hacdICHull.cpp b/Extras/HACD/hacdICHull.cpp index 16796296e9..b0856b3dc0 100644 --- a/Extras/HACD/hacdICHull.cpp +++ b/Extras/HACD/hacdICHull.cpp @@ -175,11 +175,11 @@ ICHullError ICHull::Process() m_mesh.m_vertices.Delete(m_dummyVertex); m_dummyVertex = 0; size_t nV = m_mesh.GetNVertices(); - CircularList &vertices = m_mesh.GetVertices(); + CircularList &verts = m_mesh.GetVertices(); for (size_t v = 0; v < nV; ++v) { - vertices.GetData().m_tag = false; - vertices.Next(); + verts.GetData().m_tag = false; + verts.Next(); } CleanEdges(); CleanTriangles(); @@ -312,11 +312,11 @@ ICHullError ICHull::Process(unsigned long nPointsCH) m_mesh.m_vertices.Delete(m_dummyVertex); m_dummyVertex = 0; size_t nV = m_mesh.GetNVertices(); - CircularList &vertices = m_mesh.GetVertices(); + CircularList &verts = m_mesh.GetVertices(); for (size_t v = 0; v < nV; ++v) { - vertices.GetData().m_tag = false; - vertices.Next(); + verts.GetData().m_tag = false; + verts.Next(); } CleanEdges(); CleanTriangles(); @@ -431,6 +431,7 @@ ICHullError ICHull::DoubleTriangle() m_isFlat = true; v3 = v2->GetNext(); vol = Volume(v0->GetData().m_pos, v1->GetData().m_pos, v2->GetData().m_pos, v3->GetData().m_pos); + (void)vol; return ICHullErrorOK; } else if (v3 != vertices.GetHead()) @@ -460,7 +461,7 @@ CircularListElement *ICHull::MakeFace(CircularListElementGetData().m_edges[2]; e1 = fold->GetData().m_edges[1]; @@ -491,7 +492,8 @@ CircularListElement *ICHull::MakeConeFace(CircularListElement *newEdges[2]; for (int i = 0; i < 2; ++i) { - if (!(newEdges[i] = e->GetData().m_vertices[i]->GetData().m_duplicate)) + newEdges[i] = e->GetData().m_vertices[i]->GetData().m_duplicate; + if (!newEdges[i]) { // if the edge doesn't exits add it and mark the vertex as duplicated newEdges[i] = m_mesh.AddEdge(); newEdges[i]->GetData().m_vertices[0] = e->GetData().m_vertices[i]; @@ -684,7 +686,7 @@ bool ICHull::CleanEdges() e->GetData().m_newFace = 0; } } - // delete edges maked for deletion + // delete edges marked for deletion CircularList &edges = m_mesh.GetEdges(); const std::vector *>::iterator itEndDelete = m_edgesToDelete.end(); for (std::vector *>::iterator it = m_edgesToDelete.begin(); it != itEndDelete; ++it) @@ -950,7 +952,7 @@ double ICHull::ComputeDistance(long name, const Vec3 &pt, const Vec3 } else { - Vec3 ptNormal(static_cast(normal.X()), + Vec3 pointNormal(static_cast(normal.X()), static_cast(normal.Y()), static_cast(normal.Z())); @@ -988,7 +990,7 @@ double ICHull::ComputeDistance(long name, const Vec3 &pt, const Vec3 ver2.X() = currentTriangle.m_vertices[2]->GetData().m_pos.X(); ver2.Y() = currentTriangle.m_vertices[2]->GetData().m_pos.Y(); ver2.Z() = currentTriangle.m_vertices[2]->GetData().m_pos.Z(); - nhit = IntersectRayTriangle(p0, ptNormal, ver0, ver1, ver2, dist); + nhit = IntersectRayTriangle(p0, pointNormal, ver0, ver1, ver2, dist); } if (nhit == 1 && distance <= dist) diff --git a/Extras/HACD/hacdICHull.h b/Extras/HACD/hacdICHull.h index c7d83956fe..8f52870d8f 100644 --- a/Extras/HACD/hacdICHull.h +++ b/Extras/HACD/hacdICHull.h @@ -67,7 +67,7 @@ class ICHull //! Constructor ICHull(void); //! Destructor - virtual ~ICHull(void){}; + virtual ~ICHull(void){} private: //! DoubleTriangle builds the initial double triangle. It first finds 3 noncollinear points and makes two faces out of them, in opposite order. It then finds a fourth point that is not coplanar with that face. The vertices are stored in the face structure in counterclockwise order so that the volume between the face and the point is negative. Lastly, the 3 newfaces to the fourth point are constructed and the data structures are cleaned up. diff --git a/Extras/HACD/hacdManifoldMesh.h b/Extras/HACD/hacdManifoldMesh.h index 1d22918702..b0d1af404e 100644 --- a/Extras/HACD/hacdManifoldMesh.h +++ b/Extras/HACD/hacdManifoldMesh.h @@ -50,8 +50,8 @@ class DPoint DPoint(Real dist = 0, bool computed = false, bool distOnly = false) : m_dist(dist), m_computed(computed), - m_distOnly(distOnly){}; - ~DPoint(){}; + m_distOnly(distOnly){} + ~DPoint(){} private: Real m_dist; diff --git a/Extras/HACD/hacdVector.inl b/Extras/HACD/hacdVector.inl index b1f0c1b2a3..912e4bad1b 100644 --- a/Extras/HACD/hacdVector.inl +++ b/Extras/HACD/hacdVector.inl @@ -156,7 +156,7 @@ namespace HACD m_data[2] = rhs.m_data[2]; } template - inline Vec3::~Vec3(void){}; + inline Vec3::~Vec3(void){} template inline Vec3::Vec3() {} diff --git a/Extras/HACD/hacdVersion.h b/Extras/HACD/hacdVersion.h index c9f7f28da9..1b7c016b84 100644 --- a/Extras/HACD/hacdVersion.h +++ b/Extras/HACD/hacdVersion.h @@ -17,4 +17,4 @@ #define HACD_VERSION_H #define HACD_VERSION_MAJOR 0 #define HACD_VERSION_MINOR 0 -#endif \ No newline at end of file +#endif diff --git a/Extras/InverseDynamics/CoilCreator.cpp b/Extras/InverseDynamics/CoilCreator.cpp index 627e3cc568..0400ea84c6 100644 --- a/Extras/InverseDynamics/CoilCreator.cpp +++ b/Extras/InverseDynamics/CoilCreator.cpp @@ -4,38 +4,38 @@ namespace btInverseDynamics { -CoilCreator::CoilCreator(int n) : m_num_bodies(n), m_parent(n) +CoilCreator::CoilCreator(int n) : m_num_bodies(n), m_parent((size_t)n) { for (int i = 0; i < m_num_bodies; i++) { - m_parent[i] = i - 1; + m_parent[(size_t)i] = i - 1; } // DH parameters (that's what's in the paper ...) const idScalar theta_DH = 0; const idScalar d_DH = 0.0; - const idScalar a_DH = 1.0 / m_num_bodies; - const idScalar alpha_DH = 5.0 * BT_ID_PI / m_num_bodies; + const idScalar a_DH = idScalar(1.0) / idScalar(m_num_bodies); + const idScalar alpha_DH = idScalar(5.0) * BT_ID_PI / idScalar(m_num_bodies); getVecMatFromDH(theta_DH, d_DH, a_DH, alpha_DH, &m_parent_r_parent_body_ref, &m_body_T_parent_ref); // always z-axis - m_body_axis_of_motion(0) = 0.0; - m_body_axis_of_motion(1) = 0.0; - m_body_axis_of_motion(2) = 1.0; + m_body_axis_of_motion(0) = idScalar(0.0); + m_body_axis_of_motion(1) = idScalar(0.0); + m_body_axis_of_motion(2) = idScalar(1.0); - m_mass = 1.0 / m_num_bodies; - m_body_r_body_com(0) = 1.0 / (2.0 * m_num_bodies); - m_body_r_body_com(1) = 0.0; - m_body_r_body_com(2) = 0.0; + m_mass = idScalar(1.0 / m_num_bodies); + m_body_r_body_com(0) = idScalar(1.0) / (idScalar(2.0) * idScalar(m_num_bodies)); + m_body_r_body_com(1) = idScalar(0.0); + m_body_r_body_com(2) = idScalar(0.0); - m_body_I_body(0, 0) = 1e-4 / (2.0 * m_num_bodies); - m_body_I_body(0, 1) = 0.0; - m_body_I_body(0, 2) = 0.0; - m_body_I_body(1, 0) = 0.0; - m_body_I_body(1, 1) = (3e-4 + 4.0 / BT_ID_POW(m_num_bodies, 2)) / (12.0 * m_num_bodies); - m_body_I_body(1, 2) = 0.0; - m_body_I_body(2, 0) = 0.0; - m_body_I_body(2, 1) = 0.0; + m_body_I_body(0, 0) = idScalar(1e-4 / (idScalar(2.0) * idScalar(m_num_bodies))); + m_body_I_body(0, 1) = idScalar(0.0); + m_body_I_body(0, 2) = idScalar(0.0); + m_body_I_body(1, 0) = idScalar(0.0); + m_body_I_body(1, 1) = (idScalar(3e-4) + idScalar(4.0) / BT_ID_POW(idScalar(m_num_bodies), idScalar(2))) / (idScalar(12.0) * idScalar(m_num_bodies)); + m_body_I_body(1, 2) = idScalar(0.0); + m_body_I_body(2, 0) = idScalar(0.0); + m_body_I_body(2, 1) = idScalar(0.0); m_body_I_body(2, 2) = m_body_I_body(1, 1); } @@ -57,7 +57,7 @@ int CoilCreator::getBody(int body_index, int* parent_index, JointType* joint_typ bt_id_error_message("invalid body index %d\n", body_index); return -1; } - *parent_index = m_parent[body_index]; + *parent_index = m_parent[(size_t)body_index]; *joint_type = REVOLUTE; *parent_r_parent_body_ref = m_parent_r_parent_body_ref; *body_T_parent_ref = m_body_T_parent_ref; diff --git a/Extras/InverseDynamics/CoilCreator.hpp b/Extras/InverseDynamics/CoilCreator.hpp index 886214a7be..1aa180a94c 100644 --- a/Extras/InverseDynamics/CoilCreator.hpp +++ b/Extras/InverseDynamics/CoilCreator.hpp @@ -5,7 +5,7 @@ namespace btInverseDynamics { -/// Creator class for building a "coil" system as intruduced as benchmark example in +/// Creator class for building a "coil" system as introduced as benchmark example in /// Featherstone (1999), "A Divide-and-Conquer Articulated-Body Algorithm for Parallel O(log(n)) /// Calculation of Rigid-Body Dynamics. Part 2: Trees, Loops, and Accuracy.", The International /// Journal of Robotics Research 18 (9): 876–892. doi : 10.1177 / 02783649922066628. diff --git a/Extras/InverseDynamics/DillCreator.cpp b/Extras/InverseDynamics/DillCreator.cpp index 58def07888..85c763c620 100644 --- a/Extras/InverseDynamics/DillCreator.cpp +++ b/Extras/InverseDynamics/DillCreator.cpp @@ -4,7 +4,7 @@ namespace btInverseDynamics { DillCreator::DillCreator(int level) : m_level(level), - m_num_bodies(BT_ID_POW(2, level)) + m_num_bodies((int)BT_ID_POW(btScalar(2), btScalar(level))) { m_parent.resize(m_num_bodies); m_parent_r_parent_body_ref.resize(m_num_bodies); @@ -71,7 +71,7 @@ int DillCreator::getBody(const int body_index, int* parent_index, JointType* joi return 0; } -int DillCreator::recurseDill(const int level, const int parent, const idScalar d_DH_in, +int DillCreator::recurseDill(const int level, const int parent, const idScalar /*d_DH_in*/, const idScalar a_DH_in, const idScalar alpha_DH_in) { if (level < 0) @@ -87,7 +87,7 @@ int DillCreator::recurseDill(const int level, const int parent, const idScalar d return -1; } - idScalar size = BT_ID_MAX(level, 1); + idScalar size = (idScalar)BT_ID_MAX(level, 1); const int body = m_current_body; // length = 0.1 * size; // with = 2 * 0.01 * size; @@ -95,8 +95,8 @@ int DillCreator::recurseDill(const int level, const int parent, const idScalar d /// these parameters are from the paper ... /// TODO: add proper citation m_parent[body] = parent; - m_mass[body] = 0.1 * BT_ID_POW(size, 3); - m_body_r_body_com[body](0) = 0.05 * size; + m_mass[body] = idScalar(0.1) * BT_ID_POW(size, 3); + m_body_r_body_com[body](0) = idScalar(0.05) * size; m_body_r_body_com[body](1) = 0; m_body_r_body_com[body](2) = 0; // initialization @@ -109,9 +109,9 @@ int DillCreator::recurseDill(const int level, const int parent, const idScalar d m_body_T_parent_ref[body](i, j) = 0.0; } } - const idScalar size_5 = std::pow(size, 5); - m_body_I_body[body](0, 0) = size_5 / 0.2e6; - m_body_I_body[body](1, 1) = size_5 * 403 / 1.2e6; + const idScalar size_5 = (idScalar)std::pow(size, 5); + m_body_I_body[body](0, 0) = size_5 / idScalar(0.2e6); + m_body_I_body[body](1, 1) = size_5 * idScalar(403 / 1.2e6); m_body_I_body[body](2, 2) = m_body_I_body[body](1, 1); getVecMatFromDH(0, 0, a_DH_in, alpha_DH_in, &m_parent_r_parent_body_ref[body], @@ -120,13 +120,13 @@ int DillCreator::recurseDill(const int level, const int parent, const idScalar d // attach "level" Dill systems of levels 1...level for (int i = 1; i <= level; i++) { - idScalar d_DH = 0.01 * size; + idScalar d_DH = idScalar(0.01) * size; if (i == level) { d_DH = 0.0; } - const idScalar a_DH = i * 0.1; - const idScalar alpha_DH = i * BT_ID_PI / 3.0; + const idScalar a_DH = idScalar(i) * idScalar(0.1); + const idScalar alpha_DH = (btScalar)i * BT_ID_PI / idScalar(3.0); m_current_body++; recurseDill(i - 1, body, d_DH, a_DH, alpha_DH); } diff --git a/Extras/InverseDynamics/DillCreator.hpp b/Extras/InverseDynamics/DillCreator.hpp index 854e769647..6649d89bf0 100644 --- a/Extras/InverseDynamics/DillCreator.hpp +++ b/Extras/InverseDynamics/DillCreator.hpp @@ -5,7 +5,7 @@ namespace btInverseDynamics { -/// Creator class for building a "Dill" system as intruduced as benchmark example in +/// Creator class for building a "Dill" system as introduced as benchmark example in /// Featherstone (1999), "A Divide-and-Conquer Articulated-Body Algorithm for Parallel O(log(n)) /// Calculation of Rigid-Body Dynamics. Part 2: Trees, Loops, and Accuracy.", The International /// Journal of Robotics Research 18 (9): 876–892. doi : 10.1177 / 02783649922066628. diff --git a/Extras/InverseDynamics/IDRandomUtil.cpp b/Extras/InverseDynamics/IDRandomUtil.cpp index 30411e5a83..290d6493e4 100644 --- a/Extras/InverseDynamics/IDRandomUtil.cpp +++ b/Extras/InverseDynamics/IDRandomUtil.cpp @@ -10,17 +10,17 @@ namespace btInverseDynamics { // constants for random mass and inertia generation // these are arbitrary positive values. -static const float mass_min = 0.001; -static const float mass_max = 1.0; +static const float mass_min = 0.001f; +static const float mass_max = 1.0f; -void randomInit() { srand(time(NULL)); } +void randomInit() { srand((unsigned int)time(NULL)); } void randomInit(unsigned seed) { srand(seed); } int randomInt(int low, int high) { return rand() % (high + 1 - low) + low; } float randomFloat(float low, float high) { - return low + static_cast(rand()) / RAND_MAX * (high - low); + return low + static_cast(rand()) / (float)RAND_MAX * (high - low); } float randomMass() { return randomFloat(mass_min, mass_max); } @@ -43,8 +43,8 @@ mat33 randomInertiaMatrix() // generate random valid inertia matrix by first getting valid components // along major axes and then rotating by random amount vec3 principal = randomInertiaPrincipal(); - mat33 rot(transformX(randomFloat(-BT_ID_PI, BT_ID_PI)) * transformY(randomFloat(-BT_ID_PI, BT_ID_PI)) * - transformZ(randomFloat(-BT_ID_PI, BT_ID_PI))); + mat33 rot(transformX(randomFloat((float)-BT_ID_PI, (float)BT_ID_PI)) * transformY(randomFloat((float)-BT_ID_PI, (float)BT_ID_PI)) * + transformZ(randomFloat((float)-BT_ID_PI, (float)BT_ID_PI))); mat33 inertia; inertia(0, 0) = principal(0); inertia(0, 1) = 0; diff --git a/Extras/InverseDynamics/IDRandomUtil.hpp b/Extras/InverseDynamics/IDRandomUtil.hpp index 405e6472cc..5b2df8d5bd 100644 --- a/Extras/InverseDynamics/IDRandomUtil.hpp +++ b/Extras/InverseDynamics/IDRandomUtil.hpp @@ -13,7 +13,7 @@ void randomInit(unsigned seed); /// The results will *not* be perfectly uniform. /// \param low is the lower bound (inclusive) /// \param high is the lower bound (inclusive) -/// \return a random number within [\param low, \param high] +/// \return a random number within [\p low, \p high] int randomInt(int low, int high); /// Generate a (not quite) uniformly distributed random floats in [low, high] /// Note: this is a low-quality implementation using only rand(), as @@ -21,7 +21,7 @@ int randomInt(int low, int high); /// The results will *not* be perfectly uniform. /// \param low is the lower bound (inclusive) /// \param high is the lower bound (inclusive) -/// \return a random number within [\param low, \param high] +/// \return a random number within [\p low, \p high] float randomFloat(float low, float high); /// generate a random valid mass value diff --git a/Extras/InverseDynamics/MultiBodyNameMap.hpp b/Extras/InverseDynamics/MultiBodyNameMap.hpp index e094154545..c144f5bf08 100644 --- a/Extras/InverseDynamics/MultiBodyNameMap.hpp +++ b/Extras/InverseDynamics/MultiBodyNameMap.hpp @@ -25,12 +25,12 @@ class MultiBodyNameMap int addJoint(const int index, const std::string& name); /// get body name from index /// @param index of the body - /// @param body_name name of the body + /// @param name name of the body /// @return 0 on success, -1 on failure int getBodyName(const int index, std::string* name) const; /// get joint name from index /// @param index of the joint - /// @param joint_name name of the joint + /// @param name name of the joint /// @return 0 on success, -1 on failure int getJointName(const int index, std::string* name) const; /// get body index from name diff --git a/Extras/InverseDynamics/MultiBodyTreeCreator.hpp b/Extras/InverseDynamics/MultiBodyTreeCreator.hpp index 2d15b09237..02685a6339 100644 --- a/Extras/InverseDynamics/MultiBodyTreeCreator.hpp +++ b/Extras/InverseDynamics/MultiBodyTreeCreator.hpp @@ -38,7 +38,7 @@ class MultiBodyTreeCreator /// @param creator an object implementing the MultiBodyTreeCreator interface /// that returns data defining the system /// @return A pointer to an allocated multibodytree instance, or -/// 0x0 if an error occured. +/// 0x0 if an error occurred. MultiBodyTree* CreateMultiBodyTree(const MultiBodyTreeCreator& creator); } // namespace btInverseDynamics diff --git a/Extras/InverseDynamics/RandomTreeCreator.cpp b/Extras/InverseDynamics/RandomTreeCreator.cpp index 4717e3189d..ebf81222a9 100644 --- a/Extras/InverseDynamics/RandomTreeCreator.cpp +++ b/Extras/InverseDynamics/RandomTreeCreator.cpp @@ -65,24 +65,24 @@ int RandomTreeCreator::getBody(const int body_index, int* parent_index, JointTyp (*parent_r_parent_body_ref)(1) = randomFloat(-1.0, 1.0); (*parent_r_parent_body_ref)(2) = randomFloat(-1.0, 1.0); - bodyTParentFromAxisAngle(randomAxis(), randomFloat(-BT_ID_PI, BT_ID_PI), body_T_parent_ref); + bodyTParentFromAxisAngle(randomAxis(), randomFloat((float)-BT_ID_PI, (float)BT_ID_PI), body_T_parent_ref); *body_axis_of_motion = randomAxis(); *mass = randomMass(); (*body_r_body_com)(0) = randomFloat(-1.0, 1.0); (*body_r_body_com)(1) = randomFloat(-1.0, 1.0); (*body_r_body_com)(2) = randomFloat(-1.0, 1.0); - const double a = randomFloat(-BT_ID_PI, BT_ID_PI); - const double b = randomFloat(-BT_ID_PI, BT_ID_PI); - const double c = randomFloat(-BT_ID_PI, BT_ID_PI); + const double a = randomFloat((float)-BT_ID_PI, (float)BT_ID_PI); + const double b = randomFloat((float)-BT_ID_PI, (float)BT_ID_PI); + const double c = randomFloat((float)-BT_ID_PI, (float)BT_ID_PI); vec3 ii = randomInertiaPrincipal(); mat33 ii_diag; setZero(ii_diag); ii_diag(0, 0) = ii(0); ii_diag(1, 1) = ii(1); ii_diag(2, 2) = ii(2); - *body_I_body = transformX(a) * transformY(b) * transformZ(c) * ii_diag * - transformZ(-c) * transformY(-b) * transformX(-a); + *body_I_body = transformX(idScalar(a)) * transformY(idScalar(b)) * transformZ(idScalar(c)) * ii_diag * + transformZ(idScalar(-c)) * transformY(idScalar(-b)) * transformX(idScalar(-a)); *user_int = 0; *user_ptr = 0; diff --git a/Extras/InverseDynamics/RandomTreeCreator.hpp b/Extras/InverseDynamics/RandomTreeCreator.hpp index 71b39dd005..438d6e0ef0 100644 --- a/Extras/InverseDynamics/RandomTreeCreator.hpp +++ b/Extras/InverseDynamics/RandomTreeCreator.hpp @@ -14,7 +14,6 @@ class RandomTreeCreator : public MultiBodyTreeCreator public: /// ctor /// @param max_bodies maximum number of bodies - /// @param gravity gravitational acceleration /// @param use_seed if true, seed random number generator RandomTreeCreator(const int max_bodies, bool use_seed = false); ~RandomTreeCreator(); diff --git a/Extras/InverseDynamics/btMultiBodyFromURDF.hpp b/Extras/InverseDynamics/btMultiBodyFromURDF.hpp index 63455c3997..f3cfc9178b 100644 --- a/Extras/InverseDynamics/btMultiBodyFromURDF.hpp +++ b/Extras/InverseDynamics/btMultiBodyFromURDF.hpp @@ -64,7 +64,7 @@ class MyBtMultiBodyFromURDF ConvertURDF2Bullet(u2b, creation, identityTrans, m_dynamicsWorld, use_multibody, u2b.getPathPrefix(), m_flag); m_multibody = creation.getBulletMultiBody(); - m_dynamicsWorld->stepSimulation(1. / 240., 0); + m_dynamicsWorld->stepSimulation(btScalar(1. / 240.), 0); } } /// @return pointer to the btMultiBody model @@ -76,7 +76,7 @@ class MyBtMultiBodyFromURDF { m_collisionConfiguration = new btDefaultCollisionConfiguration(); - /// use the default collision dispatcher. For parallel processing you can use a diffent + /// use the default collision dispatcher. For parallel processing you can use a different /// dispatcher (see Extras/BulletMultiThreaded) m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); diff --git a/Extras/InverseDynamics/invdyn_bullet_comparison.hpp b/Extras/InverseDynamics/invdyn_bullet_comparison.hpp index c333533005..e14ce98c04 100644 --- a/Extras/InverseDynamics/invdyn_bullet_comparison.hpp +++ b/Extras/InverseDynamics/invdyn_bullet_comparison.hpp @@ -21,8 +21,7 @@ class MultiBodyTree; /// @param u vector of generalized speeds (matches id_tree) /// @param gravity gravitational acceleration in world frame /// @param dot_u vector of generalized accelerations (matches id_tree) -/// @param gravity gravitational acceleration in world frame -/// @param base_fixed set base joint to fixed or +/// @param verbose report verbosely /// @param pos_error is set to the maximum of the euclidean norm of position+rotation errors of all /// center of gravity positions and link frames /// @param acc_error is set to the square root of the sum of squared differences of generalized diff --git a/Extras/Serialize/BlenderSerialize/bBlenderFile.h b/Extras/Serialize/BlenderSerialize/bBlenderFile.h index 8c0ba2d40c..92d00bae72 100644 --- a/Extras/Serialize/BlenderSerialize/bBlenderFile.h +++ b/Extras/Serialize/BlenderSerialize/bBlenderFile.h @@ -53,6 +53,6 @@ class bBlenderFile : public bFile virtual void writeDNA(FILE* fp); }; -}; // namespace bParse +} // namespace bParse #endif //B_BLENDER_FILE_H diff --git a/Extras/Serialize/BulletFileLoader/autogenerated/bullet.h b/Extras/Serialize/BulletFileLoader/autogenerated/bullet.h index bfec77bb26..9da430b452 100644 --- a/Extras/Serialize/BulletFileLoader/autogenerated/bullet.h +++ b/Extras/Serialize/BulletFileLoader/autogenerated/bullet.h @@ -1577,4 +1577,4 @@ typedef struct bInvalidHandle { } -#endif//__BULLET_H__ \ No newline at end of file +#endif//__BULLET_H__ diff --git a/Extras/Serialize/BulletFileLoader/bDNA.cpp b/Extras/Serialize/BulletFileLoader/bDNA.cpp index 8d581d2787..c5d06e3d82 100644 --- a/Extras/Serialize/BulletFileLoader/bDNA.cpp +++ b/Extras/Serialize/BulletFileLoader/bDNA.cpp @@ -254,7 +254,7 @@ for (i = 0; i < (int)mStructs.size(); i++) static int name_is_array(char *name, int *dim1, int *dim2) { - int len = strlen(name); + int len = (int)strlen(name); /*fprintf(stderr,"[%s]",name);*/ /*if (len >= 1) { if (name[len-1] != ']') @@ -342,7 +342,7 @@ static int name_is_array(char *name, int *dim1, int *dim2) } // ----------------------------------------------------- // -void bDNA::init(char *data, int len, bool swap) +void bDNA::init(char *data, int /*len*/, bool swap) { int *intPtr = 0; short *shtPtr = 0; @@ -503,7 +503,7 @@ void bDNA::init(char *data, int len, bool swap) int bDNA::getArraySize(char *string) { int ret = 1; - int len = strlen(string); + int len = (int)strlen(string); char *next = 0; for (int i = 0; i < len; i++) diff --git a/Extras/Serialize/BulletFileLoader/bDefines.h b/Extras/Serialize/BulletFileLoader/bDefines.h index c5ad20acf7..860f2b7953 100644 --- a/Extras/Serialize/BulletFileLoader/bDefines.h +++ b/Extras/Serialize/BulletFileLoader/bDefines.h @@ -118,7 +118,7 @@ s_i = p_i[1]; \ p_i[1] = p_i[2]; \ p_i[2] = s_i; \ - } + } do{} while(0) // ------------------------------------------------------------ #define SWITCH_SHORT(a) \ @@ -128,7 +128,7 @@ s_i = p_i[0]; \ p_i[0] = p_i[1]; \ p_i[1] = s_i; \ - } + } do{} while(0) // ------------------------------------------------------------ #define SWITCH_LONGINT(a) \ @@ -147,6 +147,6 @@ s_i = p_i[3]; \ p_i[3] = p_i[4]; \ p_i[4] = s_i; \ - } + } do{} while(0) #endif //__B_DEFINES_H__ diff --git a/Extras/Serialize/BulletFileLoader/bFile.cpp b/Extras/Serialize/BulletFileLoader/bFile.cpp index 5f19dd5762..089a1a201d 100644 --- a/Extras/Serialize/BulletFileLoader/bFile.cpp +++ b/Extras/Serialize/BulletFileLoader/bFile.cpp @@ -29,9 +29,9 @@ subject to the following restrictions: using namespace bParse; #define MAX_STRLEN 1024 -const char *getCleanName(const char *memName, char *buffer) +static const char *getCleanName(const char *memName, char *buffer) { - int slen = strlen(memName); + int slen = (int)strlen(memName); assert(slen < MAX_STRLEN); slen = btMin(slen, MAX_STRLEN); for (int i = 0; i < slen; i++) @@ -49,7 +49,7 @@ const char *getCleanName(const char *memName, char *buffer) return buffer; } -int numallocs = 0; +static int numallocs = 0; // ----------------------------------------------------- // bFile::bFile(const char *filename, const char headerString[7]) @@ -71,13 +71,17 @@ bFile::bFile(const char *filename, const char headerString[7]) if (fp) { fseek(fp, 0L, SEEK_END); - mFileLen = ftell(fp); + mFileLen = (int)ftell(fp); fseek(fp, 0L, SEEK_SET); - mFileBuffer = (char *)malloc(mFileLen + 1); - memset(mFileBuffer, 0, mFileLen+1); - size_t bytesRead; - bytesRead = fread(mFileBuffer, mFileLen, 1, fp); + mFileBuffer = (char *)malloc((size_t)mFileLen + 1); + if(mFileBuffer) + { + memset(mFileBuffer, 0, (size_t)mFileLen+1); + size_t bytesRead; + bytesRead = fread(mFileBuffer, (size_t)mFileLen, 1, fp); + (void)bytesRead; + } fclose(fp); @@ -133,7 +137,7 @@ void bFile::parseHeader() if (strncmp(header, m_headerString, 6) != 0) { - memcpy(header, m_headerString, SIZEOFBLENDERHEADER); + memcpy(header, m_headerString, 7); return; } @@ -316,7 +320,7 @@ void bFile::swap(char *head, bChunkInd &dataChunk, bool ignoreEndianFlag) { short *oldStruct = mFileDNA->getStruct(dataChunk.dna_nr); char *oldType = mFileDNA->getType(oldStruct[0]); - if (strncmp(oldType, s, szs) == 0) + if (strncmp(oldType, s, (size_t)szs) == 0) { return; } @@ -333,7 +337,6 @@ void bFile::swap(char *head, bChunkInd &dataChunk, bool ignoreEndianFlag) void bFile::swapLen(char *dataPtr) { - const bool VOID_IS_8 = ((sizeof(void *) == 8)); if (VOID_IS_8) { if (mFlags & FD_BITS_VARIES) @@ -538,8 +541,11 @@ void bFile::swapDNA(char *ptr) void bFile::writeFile(const char *fileName) { FILE *f = fopen(fileName, "wb"); - fwrite(mFileBuffer, 1, mFileLen, f); - fclose(f); + if(f) + { + fwrite(mFileBuffer, 1, (size_t)mFileLen, f); + fclose(f); + } } void bFile::preSwap() @@ -629,6 +635,7 @@ char *bFile::readStruct(char *head, bChunkInd &dataChunk) short *oldStruct, *curStruct; char *oldType, *newType; int oldLen, curLen, reverseOld; + (void)newType; oldStruct = mFileDNA->getStruct(dataChunk.dna_nr); oldType = mFileDNA->getType(oldStruct[0]); @@ -644,8 +651,8 @@ char *bFile::readStruct(char *head, bChunkInd &dataChunk) if ((strcmp(oldType, "btShortIntIndexData") == 0)) { int allocLen = 2; - char *dataAlloc = new char[(dataChunk.nr * allocLen) + sizeof(void*)]; - memset(dataAlloc, 0, (dataChunk.nr * allocLen) + sizeof(void*)); + char *dataAlloc = new char[(size_t)(dataChunk.nr * allocLen) + sizeof(void*)]; + memset(dataAlloc, 0, (size_t)(dataChunk.nr * allocLen) + sizeof(void*)); short *dest = (short *)dataAlloc; const short *src = (short *)head; for (int i = 0; i < dataChunk.nr; i++) @@ -683,8 +690,8 @@ char *bFile::readStruct(char *head, bChunkInd &dataChunk) // numBlocks * length int allocLen = (curLen); - char *dataAlloc = new char[(dataChunk.nr * allocLen) + sizeof(void*)]; - memset(dataAlloc, 0, (dataChunk.nr * allocLen) + sizeof(void*)); + char *dataAlloc = new char[(size_t)(dataChunk.nr * allocLen) + sizeof(void*)]; + memset(dataAlloc, 0, (size_t)(dataChunk.nr * allocLen) + sizeof(void*)); // track allocated addDataBlock(dataAlloc); @@ -720,13 +727,13 @@ char *bFile::readStruct(char *head, bChunkInd &dataChunk) #endif // } - char *dataAlloc = new char[(dataChunk.len) + sizeof(void*)]; - memset(dataAlloc, 0, dataChunk.len + sizeof(void*)); + char *dataAlloc = new char[(size_t)(dataChunk.len) + sizeof(void*)]; + memset(dataAlloc, 0, (size_t)dataChunk.len + sizeof(void*)); // track allocated addDataBlock(dataAlloc); - memcpy(dataAlloc, head, dataChunk.len); + memcpy(dataAlloc, head, (size_t)dataChunk.len); return dataAlloc; } @@ -742,7 +749,7 @@ void bFile::parseStruct(char *strcPtr, char *dtPtr, int old_dna, int new_dna, bo short *strc = mFileDNA->getStruct(old_dna); int len = mFileDNA->getLength(strc[0]); - memcpy(strcPtr, dtPtr, len); + memcpy(strcPtr, dtPtr, (size_t)len); return; } @@ -801,6 +808,7 @@ void bFile::parseStruct(char *strcPtr, char *dtPtr, int old_dna, int new_dna, bo } cpc += size; cpo += fpLen; + (void)cpo; } else cpc += size; @@ -816,37 +824,37 @@ void bFile::parseStruct(char *strcPtr, char *dtPtr, int old_dna, int new_dna, bo // ----------------------------------------------------- // static void getElement(int arrayLen, const char *cur, const char *old, char *oldPtr, char *curData) { -#define getEle(value, current, type, cast, size, ptr) \ - if (strcmp(current, type) == 0) \ - { \ - value = (*(cast *)ptr); \ - ptr += size; \ - } - -#define setEle(value, current, type, cast, size, ptr) \ - if (strcmp(current, type) == 0) \ - { \ - (*(cast *)ptr) = (cast)value; \ - ptr += size; \ - } +#define getEle(value, valueType, current, type, cast, size, ptr) \ + if (strcmp(current, type) == 0) \ + { \ + value = (valueType)(*(cast *)ptr); \ + ptr += size; \ + } do{} while(0) + +#define setEle(value, valueType, current, type, cast, size, ptr) \ + if (strcmp(current, type) == 0) \ + { \ + (*(cast *)ptr) = (cast)value; \ + ptr += size; \ + } do{} while(0) double value = 0.0; for (int i = 0; i < arrayLen; i++) { - getEle(value, old, "char", char, sizeof(char), oldPtr); - setEle(value, cur, "char", char, sizeof(char), curData); - getEle(value, old, "short", short, sizeof(short), oldPtr); - setEle(value, cur, "short", short, sizeof(short), curData); - getEle(value, old, "ushort", unsigned short, sizeof(unsigned short), oldPtr); - setEle(value, cur, "ushort", unsigned short, sizeof(unsigned short), curData); - getEle(value, old, "int", int, sizeof(int), oldPtr); - setEle(value, cur, "int", int, sizeof(int), curData); - getEle(value, old, "long", int, sizeof(int), oldPtr); - setEle(value, cur, "long", int, sizeof(int), curData); - getEle(value, old, "float", float, sizeof(float), oldPtr); - setEle(value, cur, "float", float, sizeof(float), curData); - getEle(value, old, "double", double, sizeof(double), oldPtr); - setEle(value, cur, "double", double, sizeof(double), curData); + getEle(value, double, old, "char", char, sizeof(char), oldPtr); + setEle(value, double, cur, "char", char, sizeof(char), curData); + getEle(value, double, old, "short", short, sizeof(short), oldPtr); + setEle(value, double, cur, "short", short, sizeof(short), curData); + getEle(value, double, old, "ushort", unsigned short, sizeof(unsigned short), oldPtr); + setEle(value, double, cur, "ushort", unsigned short, sizeof(unsigned short), curData); + getEle(value, double, old, "int", int, sizeof(int), oldPtr); + setEle(value, double, cur, "int", int, sizeof(int), curData); + getEle(value, double, old, "long", int, sizeof(int), oldPtr); + setEle(value, double, cur, "long", int, sizeof(int), curData); + getEle(value, double, old, "float", float, sizeof(float), oldPtr); + setEle(value, double, cur, "float", float, sizeof(float), curData); + getEle(value, double, old, "double", double, sizeof(double), oldPtr); + setEle(value, double, cur, "double", double, sizeof(double), curData); } } @@ -887,12 +895,12 @@ void bFile::safeSwapPtr(char *dst, const char *src) int ptrFile = mFileDNA->getPointerSize(); int ptrMem = mMemoryDNA->getPointerSize(); - if (!src && !dst) + if (!src || !dst) return; if (ptrFile == ptrMem) { - memcpy(dst, src, ptrMem); + memcpy(dst, src, (size_t)ptrMem); } else if (ptrMem == 4 && ptrFile == 8) { @@ -1009,7 +1017,7 @@ void bFile::getMatchingFileDNA(short *dna_addr, const char *lookupName, const ch } else if (strcmp(type, lookupType) == 0) - memcpy(strcData, data, eleLen); + memcpy(strcData, data, (size_t)eleLen); else getElement(arrayLen, lookupType, type, data, strcData); @@ -1079,7 +1087,7 @@ void bFile::swapStruct(int dna_nr, char *data, bool ignoreEndianFlag) else { char *tmpBuf = buf; - for (int i = 0; i < arrayLen; i++) + for (int j = 0; j < arrayLen; j++) { swapStruct(old_nr, tmpBuf, ignoreEndianFlag); tmpBuf += size / arrayLen; @@ -1126,7 +1134,7 @@ void bFile::resolvePointersMismatch() void **ptrptr = (void **)cur; bChunkInd *block = m_chunkPtrPtrMap.find(*ptrptr); - if (block) + if (block && mMemoryDNA && mFileDNA) { int ptrMem = mMemoryDNA->getPointerSize(); int ptrFile = mFileDNA->getPointerSize(); @@ -1136,9 +1144,9 @@ void bFile::resolvePointersMismatch() void *onptr = findLibPointer(*ptrptr); if (onptr) { - char *newPtr = new char[blockLen * ptrMem]; + char *newPtr = new char[(size_t)(blockLen * ptrMem)]; addDataBlock(newPtr); - memset(newPtr, 0, blockLen * ptrMem); + memset(newPtr, 0, (size_t)(blockLen * ptrMem)); void **onarray = (void **)onptr; char *oldPtr = (char *)onarray; @@ -1272,7 +1280,7 @@ int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verbose char cleanName[MAX_STRLEN]; getCleanName(memName, cleanName); - int arrayLen = fileDna->getArraySizeNew(oldStruct[1]); + int arrayLength = fileDna->getArraySizeNew(oldStruct[1]); int byteOffset = 0; if (verboseMode & FD_VERBOSE_EXPORT_XML) @@ -1282,9 +1290,9 @@ int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verbose printf(" "); } - if (arrayLen > 1) + if (arrayLength > 1) { - printf("<%s type=\"%s\" count=%d>\n", cleanName, memType, arrayLen); + printf("<%s type=\"%s\" count=%d>\n", cleanName, memType, arrayLength); } else { @@ -1292,7 +1300,7 @@ int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verbose } } - for (int i = 0; i < arrayLen; i++) + for (int i = 0; i < arrayLength; i++) { byteOffset += resolvePointersStructRecursive(elemPtr + byteOffset, revType, verboseMode, recursion + 1); } @@ -1508,6 +1516,7 @@ void bFile::writeChunks(FILE *fp, bool fixupPointers) short *oldStruct, *curStruct; char *oldType, *newType; int curLen, reverseOld; + (void)newType; oldStruct = fileDna->getStruct(dataChunk.dna_nr); oldType = fileDna->getType(oldStruct[0]); @@ -1542,11 +1551,12 @@ void bFile::writeChunks(FILE *fp, bool fixupPointers) short int *curStruct1; curStruct1 = mMemoryDNA->getStruct(dataChunk.dna_nr); assert(curStruct1 == curStruct); + (void)curStruct1; char *cur = fixupPointers ? (char *)findLibPointer(dataChunk.oldPtr) : (char *)dataChunk.oldPtr; //write the actual contents of the structure(s) - fwrite(cur, dataChunk.len, 1, fp); + fwrite(cur, (size_t)dataChunk.len, 1, fp); } else { @@ -1592,7 +1602,7 @@ int bFile::getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int fla SWITCH_INT(chunk.nr); } - memcpy(dataChunk, &chunk, sizeof(bChunkInd)); + memcpy((void*)dataChunk, &chunk, sizeof(bChunkInd)); } else { @@ -1609,7 +1619,7 @@ int bFile::getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int fla SWITCH_INT(c.nr); } - memcpy(dataChunk, &c, sizeof(bChunkInd)); + memcpy((void*)dataChunk, &c, sizeof(bChunkInd)); } } else @@ -1649,7 +1659,7 @@ int bFile::getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int fla SWITCH_INT(chunk.nr); } - memcpy(dataChunk, &chunk, sizeof(bChunkInd)); + memcpy((void*)dataChunk, &chunk, sizeof(bChunkInd)); } else { @@ -1665,7 +1675,7 @@ int bFile::getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int fla SWITCH_INT(c.dna_nr); SWITCH_INT(c.nr); } - memcpy(dataChunk, &c, sizeof(bChunkInd)); + memcpy((void*)dataChunk, &c, sizeof(bChunkInd)); } } diff --git a/Extras/Serialize/BulletFileLoader/bFile.h b/Extras/Serialize/BulletFileLoader/bFile.h index f6fae97ed8..ba044c9e32 100644 --- a/Extras/Serialize/BulletFileLoader/bFile.h +++ b/Extras/Serialize/BulletFileLoader/bFile.h @@ -42,7 +42,7 @@ enum bFileVerboseMode FD_VERBOSE_EXPORT_XML = 1, FD_VERBOSE_DUMP_DNA_TYPE_DEFINITIONS = 2, FD_VERBOSE_DUMP_CHUNKS = 4, - FD_VERBOSE_DUMP_FILE_INFO = 8, + FD_VERBOSE_DUMP_FILE_INFO = 8 }; // ----------------------------------------------------- // class bFile diff --git a/Extras/Serialize/BulletFileLoader/btBulletFile.cpp b/Extras/Serialize/BulletFileLoader/btBulletFile.cpp index 74f27c4a51..a928ea2269 100644 --- a/Extras/Serialize/BulletFileLoader/btBulletFile.cpp +++ b/Extras/Serialize/BulletFileLoader/btBulletFile.cpp @@ -51,25 +51,25 @@ btBulletFile::btBulletFile() #ifdef BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES #ifdef _WIN64 - m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen64, 16); - memcpy(m_DnaCopy, sBulletDNAstr64, sBulletDNAlen64); + m_DnaCopy = (char*)btAlignedAlloc((size_t)sBulletDNAlen64, 16); + memcpy(m_DnaCopy, sBulletDNAstr64, (size_t)sBulletDNAlen64); mMemoryDNA->init(m_DnaCopy, sBulletDNAlen64); #else //_WIN64 - m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen, 16); - memcpy(m_DnaCopy, sBulletDNAstr, sBulletDNAlen); + m_DnaCopy = (char*)btAlignedAlloc((size_t)sBulletDNAlen, 16); + memcpy(m_DnaCopy, sBulletDNAstr, (size_t)sBulletDNAlen); mMemoryDNA->init(m_DnaCopy, sBulletDNAlen); #endif //_WIN64 #else //BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES if (VOID_IS_8) { - m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen64, 16); - memcpy(m_DnaCopy, sBulletDNAstr64, sBulletDNAlen64); + m_DnaCopy = (char*)btAlignedAlloc((size_t)sBulletDNAlen64, 16); + memcpy(m_DnaCopy, sBulletDNAstr64, (size_t)sBulletDNAlen64); mMemoryDNA->init(m_DnaCopy, sBulletDNAlen64); } else { - m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen, 16); - memcpy(m_DnaCopy, sBulletDNAstr, sBulletDNAlen); + m_DnaCopy = (char*)btAlignedAlloc((size_t)sBulletDNAlen, 16); + memcpy(m_DnaCopy, sBulletDNAstr, (size_t)sBulletDNAlen); mMemoryDNA->init(m_DnaCopy, sBulletDNAlen); } #endif //BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES @@ -117,7 +117,7 @@ void btBulletFile::parseData() remain -= 12; //invalid/empty file? - if (remain < sizeof(bChunkInd)) + if (remain < (int)sizeof(bChunkInd)) return; char* dataPtr = mFileBuffer + mDataStart; @@ -264,7 +264,7 @@ void btBulletFile::writeDNA(FILE* fp) dataChunk.len = sBulletDNAlen64; dataChunk.oldPtr = sBulletDNAstr64; fwrite(&dataChunk, sizeof(bChunkInd), 1, fp); - fwrite(sBulletDNAstr64, sBulletDNAlen64, 1, fp); + fwrite(sBulletDNAstr64, (size_t)sBulletDNAlen64, 1, fp); #else btAssert(0); #endif @@ -275,7 +275,7 @@ void btBulletFile::writeDNA(FILE* fp) dataChunk.len = sBulletDNAlen; dataChunk.oldPtr = sBulletDNAstr; fwrite(&dataChunk, sizeof(bChunkInd), 1, fp); - fwrite(sBulletDNAstr, sBulletDNAlen, 1, fp); + fwrite(sBulletDNAstr, (size_t)sBulletDNAlen, 1, fp); #else //_WIN64 btAssert(0); #endif //_WIN64 @@ -286,14 +286,14 @@ void btBulletFile::writeDNA(FILE* fp) dataChunk.len = sBulletDNAlen64; dataChunk.oldPtr = sBulletDNAstr64; fwrite(&dataChunk, sizeof(bChunkInd), 1, fp); - fwrite(sBulletDNAstr64, sBulletDNAlen64, 1, fp); + fwrite(sBulletDNAstr64, (size_t)sBulletDNAlen64, 1, fp); } else { dataChunk.len = sBulletDNAlen; dataChunk.oldPtr = sBulletDNAstr; fwrite(&dataChunk, sizeof(bChunkInd), 1, fp); - fwrite(sBulletDNAstr, sBulletDNAlen, 1, fp); + fwrite(sBulletDNAstr, (size_t)sBulletDNAlen, 1, fp); } #endif //BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES } @@ -307,8 +307,8 @@ void btBulletFile::parse(int verboseMode) if (m_DnaCopy) delete m_DnaCopy; - m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen64, 16); - memcpy(m_DnaCopy, sBulletDNAstr64, sBulletDNAlen64); + m_DnaCopy = (char*)btAlignedAlloc((size_t)sBulletDNAlen64, 16); + memcpy(m_DnaCopy, sBulletDNAstr64, (size_t)sBulletDNAlen64); parseInternal(verboseMode, (char*)sBulletDNAstr64, sBulletDNAlen64); #else btAssert(0); @@ -320,8 +320,8 @@ void btBulletFile::parse(int verboseMode) if (m_DnaCopy) delete m_DnaCopy; - m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen, 16); - memcpy(m_DnaCopy, sBulletDNAstr, sBulletDNAlen); + m_DnaCopy = (char*)btAlignedAlloc((size_t)sBulletDNAlen, 16); + memcpy(m_DnaCopy, sBulletDNAstr, (size_t)sBulletDNAlen); parseInternal(verboseMode, m_DnaCopy, sBulletDNAlen); #else btAssert(0); @@ -332,17 +332,17 @@ void btBulletFile::parse(int verboseMode) { if (m_DnaCopy) delete m_DnaCopy; - m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen64, 16); - memset(m_DnaCopy, 0, sBulletDNAlen64); - memcpy(m_DnaCopy, sBulletDNAstr64, sBulletDNAlen64); + m_DnaCopy = (char*)btAlignedAlloc((size_t)sBulletDNAlen64, 16); + memset(m_DnaCopy, 0, (size_t)sBulletDNAlen64); + memcpy(m_DnaCopy, sBulletDNAstr64, (size_t)sBulletDNAlen64); parseInternal(verboseMode, m_DnaCopy, sBulletDNAlen64); } else { if (m_DnaCopy) delete m_DnaCopy; - m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen, 16); - memcpy(m_DnaCopy, sBulletDNAstr, sBulletDNAlen); + m_DnaCopy = (char*)btAlignedAlloc((size_t)sBulletDNAlen, 16); + memcpy(m_DnaCopy, sBulletDNAstr, (size_t)sBulletDNAlen); parseInternal(verboseMode, m_DnaCopy, sBulletDNAlen); } #endif //BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES @@ -362,7 +362,7 @@ int btBulletFile::write(const char* fileName, bool fixupPointers) FILE* fp = fopen(fileName, "wb"); if (fp) { - char header[SIZEOFBLENDERHEADER]; + char header[SIZEOFBLENDERHEADER] = {}; memcpy(header, m_headerString, 7); int endian = 1; endian = ((char*)&endian)[0]; @@ -419,6 +419,7 @@ void btBulletFile::addStruct(const char* structType, void* data, int len, void* elemBytes = mMemoryDNA->getLength(structInfo[0]); // int elemBytes = mMemoryDNA->getElementSize(structInfo[0],structInfo[1]); assert(len == elemBytes); + (void)elemBytes; mLibPointers.insert(dataChunk.oldPtr, (bStructHandle*)data); m_chunks.push_back(dataChunk); diff --git a/Extras/Serialize/BulletFileLoader/btBulletFile.h b/Extras/Serialize/BulletFileLoader/btBulletFile.h index d7c1cb7e07..78bfda4027 100644 --- a/Extras/Serialize/BulletFileLoader/btBulletFile.h +++ b/Extras/Serialize/BulletFileLoader/btBulletFile.h @@ -75,6 +75,6 @@ class btBulletFile : public bFile void addStruct(const char* structType, void* data, int len, void* oldPtr, int code); }; -}; // namespace bParse +} // namespace bParse #endif //BT_BULLET_FILE_H diff --git a/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.cpp b/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.cpp index b50f05654e..0e17a3c3b3 100644 --- a/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.cpp +++ b/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.cpp @@ -125,11 +125,11 @@ bool btBulletWorldImporter::convertAllObjects(bParse::btBulletFile* bulletFile2) } } - for (int i = 0; i < bulletFile2->m_dynamicsWorldInfo.size(); i++) + for (int j = 0; j < bulletFile2->m_dynamicsWorldInfo.size(); j++) { if (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION) { - btDynamicsWorldDoubleData* solverInfoData = (btDynamicsWorldDoubleData*)bulletFile2->m_dynamicsWorldInfo[i]; + btDynamicsWorldDoubleData* solverInfoData = (btDynamicsWorldDoubleData*)bulletFile2->m_dynamicsWorldInfo[j]; btContactSolverInfo solverInfo; btVector3 gravity; @@ -166,7 +166,7 @@ bool btBulletWorldImporter::convertAllObjects(bParse::btBulletFile* bulletFile2) } else { - btDynamicsWorldFloatData* solverInfoData = (btDynamicsWorldFloatData*)bulletFile2->m_dynamicsWorldInfo[i]; + btDynamicsWorldFloatData* solverInfoData = (btDynamicsWorldFloatData*)bulletFile2->m_dynamicsWorldInfo[j]; btContactSolverInfo solverInfo; btVector3 gravity; diff --git a/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.h b/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.h index 0a856bc3b5..f1f7a686ab 100644 --- a/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.h +++ b/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.h @@ -24,7 +24,7 @@ namespace bParse { class btBulletFile; -}; +} ///The btBulletWorldImporter is a starting point to import .bullet files. ///note that not all data is converted yet. You are expected to override or modify this class. diff --git a/Extras/Serialize/BulletWorldImporter/btMultiBodyWorldImporter.cpp b/Extras/Serialize/BulletWorldImporter/btMultiBodyWorldImporter.cpp index f18a5d2c51..9271aed4be 100644 --- a/Extras/Serialize/BulletWorldImporter/btMultiBodyWorldImporter.cpp +++ b/Extras/Serialize/BulletWorldImporter/btMultiBodyWorldImporter.cpp @@ -64,7 +64,7 @@ void syncContactManifolds(T** contactManifolds, int numContactManifolds, btMulti { dispatcher->dispatchAllCollisionPairs(pairCache, dispatchInfo, dispatcher); } - int numExistingManifolds = m_data->m_mbDynamicsWorld->getDispatcher()->getNumManifolds(); + // int numExistingManifolds = m_data->m_mbDynamicsWorld->getDispatcher()->getNumManifolds(); btManifoldArray manifoldArray; for (int i = 0; i < pairCache->getNumOverlappingPairs(); i++) { @@ -93,7 +93,7 @@ void syncContactManifolds(T** contactManifolds, int numContactManifolds, btMulti else { existingManifold->setNumContacts(0); - //printf("Issue: cannot find maching contact manifold (%d, %d), may cause issues in determinism.\n", uid0, uid1); + //printf("Issue: cannot find matching contact manifold (%d, %d), may cause issues in determinism.\n", uid0, uid1); } manifoldArray.clear(); @@ -104,10 +104,10 @@ void syncContactManifolds(T** contactManifolds, int numContactManifolds, btMulti } template -void syncMultiBody(T* mbd, btMultiBody* mb, btMultiBodyWorldImporterInternalData* m_data, btAlignedObjectArray& scratchQ, btAlignedObjectArray& scratchM) +void syncMultiBody(T* mbd, btMultiBody* mb, btMultiBodyWorldImporterInternalData* /*m_data*/, btAlignedObjectArray& scratchQ, btAlignedObjectArray& scratchM) { - bool isFixedBase = mbd->m_baseMass == 0; - bool canSleep = false; + // bool isFixedBase = mbd->m_baseMass == 0; + // bool canSleep = false; btVector3 baseInertia; baseInertia.deSerialize(mbd->m_baseInertia); @@ -139,14 +139,14 @@ void syncMultiBody(T* mbd, btMultiBody* mb, btMultiBodyWorldImporterInternalData } case btMultibodyLink::ePrismatic: { - mb->setJointPos(i, mbd->m_links[i].m_jointPos[0]); - mb->setJointVel(i, mbd->m_links[i].m_jointVel[0]); + mb->setJointPos(i, (btScalar)mbd->m_links[i].m_jointPos[0]); + mb->setJointVel(i, (btScalar)mbd->m_links[i].m_jointVel[0]); break; } case btMultibodyLink::eRevolute: { - mb->setJointPos(i, mbd->m_links[i].m_jointPos[0]); - mb->setJointVel(i, mbd->m_links[i].m_jointVel[0]); + mb->setJointPos(i, (btScalar)mbd->m_links[i].m_jointPos[0]); + mb->setJointVel(i, (btScalar)mbd->m_links[i].m_jointVel[0]); break; } case btMultibodyLink::eSpherical: @@ -178,7 +178,7 @@ void convertMultiBody(T* mbd, btMultiBodyWorldImporterInternalData* m_data) bool canSleep = false; btVector3 baseInertia; baseInertia.deSerialize(mbd->m_baseInertia); - btMultiBody* mb = new btMultiBody(mbd->m_numLinks, mbd->m_baseMass, baseInertia, isFixedBase, canSleep); + btMultiBody* mb = new btMultiBody(mbd->m_numLinks, (btScalar)mbd->m_baseMass, baseInertia, isFixedBase, canSleep); mb->setHasSelfCollision(false); btVector3 baseWorldPos; @@ -205,7 +205,7 @@ void convertMultiBody(T* mbd, btMultiBodyWorldImporterInternalData* m_data) { case btMultibodyLink::eFixed: { - mb->setupFixed(i, mbd->m_links[i].m_linkMass, localInertiaDiagonal, mbd->m_links[i].m_parentIndex, + mb->setupFixed(i, (btScalar)mbd->m_links[i].m_linkMass, localInertiaDiagonal, mbd->m_links[i].m_parentIndex, parentRotToThis, parentComToThisPivotOffset, thisPivotToThisComOffset); //search for the collider //mbd->m_links[i].m_linkCollider @@ -216,11 +216,11 @@ void convertMultiBody(T* mbd, btMultiBodyWorldImporterInternalData* m_data) btVector3 jointAxis; jointAxis.deSerialize(mbd->m_links[i].m_jointAxisBottom[0]); bool disableParentCollision = true; //todo - mb->setupPrismatic(i, mbd->m_links[i].m_linkMass, localInertiaDiagonal, mbd->m_links[i].m_parentIndex, + mb->setupPrismatic(i, (btScalar)mbd->m_links[i].m_linkMass, localInertiaDiagonal, mbd->m_links[i].m_parentIndex, parentRotToThis, jointAxis, parentComToThisPivotOffset, thisPivotToThisComOffset, disableParentCollision); - mb->setJointPos(i, mbd->m_links[i].m_jointPos[0]); + mb->setJointPos(i, (btScalar)mbd->m_links[i].m_jointPos[0]); mb->finalizeMultiDof(); - mb->setJointVel(i, mbd->m_links[i].m_jointVel[0]); + mb->setJointVel(i, (btScalar)mbd->m_links[i].m_jointVel[0]); break; } case btMultibodyLink::eRevolute: @@ -228,18 +228,18 @@ void convertMultiBody(T* mbd, btMultiBodyWorldImporterInternalData* m_data) btVector3 jointAxis; jointAxis.deSerialize(mbd->m_links[i].m_jointAxisTop[0]); bool disableParentCollision = true; //todo - mb->setupRevolute(i, mbd->m_links[i].m_linkMass, localInertiaDiagonal, mbd->m_links[i].m_parentIndex, + mb->setupRevolute(i, (btScalar)mbd->m_links[i].m_linkMass, localInertiaDiagonal, mbd->m_links[i].m_parentIndex, parentRotToThis, jointAxis, parentComToThisPivotOffset, thisPivotToThisComOffset, disableParentCollision); - mb->setJointPos(i, mbd->m_links[i].m_jointPos[0]); + mb->setJointPos(i, (btScalar)mbd->m_links[i].m_jointPos[0]); mb->finalizeMultiDof(); - mb->setJointVel(i, mbd->m_links[i].m_jointVel[0]); + mb->setJointVel(i, (btScalar)mbd->m_links[i].m_jointVel[0]); break; } case btMultibodyLink::eSpherical: { btAssert(0); bool disableParentCollision = true; //todo - mb->setupSpherical(i, mbd->m_links[i].m_linkMass, localInertiaDiagonal, mbd->m_links[i].m_parentIndex, + mb->setupSpherical(i, (btScalar)mbd->m_links[i].m_linkMass, localInertiaDiagonal, mbd->m_links[i].m_parentIndex, parentRotToThis, parentComToThisPivotOffset, thisPivotToThisComOffset, disableParentCollision); btScalar jointPos[4] = {(btScalar)mbd->m_links[i].m_jointPos[0], (btScalar)mbd->m_links[i].m_jointPos[1], (btScalar)mbd->m_links[i].m_jointPos[2], (btScalar)mbd->m_links[i].m_jointPos[3]}; btScalar jointVel[3] = {(btScalar)mbd->m_links[i].m_jointVel[0], (btScalar)mbd->m_links[i].m_jointVel[1], (btScalar)mbd->m_links[i].m_jointVel[2]}; @@ -304,11 +304,11 @@ bool btMultiBodyWorldImporter::convertAllObjects(bParse::btBulletFile* bulletFil btRigidBodyDoubleData* rbd = (btRigidBodyDoubleData*)bulletFile2->m_rigidBodies[i]; int foundRb = -1; int uid = rbd->m_collisionObjectData.m_uniqueId; - for (int i = 0; i < m_data->m_mbDynamicsWorld->getNumCollisionObjects(); i++) + for (int j = 0; j < m_data->m_mbDynamicsWorld->getNumCollisionObjects(); j++) { - if (uid == m_data->m_mbDynamicsWorld->getCollisionObjectArray()[i]->getBroadphaseHandle()->m_uniqueId) + if (uid == m_data->m_mbDynamicsWorld->getCollisionObjectArray()[j]->getBroadphaseHandle()->m_uniqueId) { - foundRb = i; + foundRb = j; break; } } @@ -389,11 +389,11 @@ bool btMultiBodyWorldImporter::convertAllObjects(bParse::btBulletFile* bulletFil btRigidBodyFloatData* rbd = (btRigidBodyFloatData*)bulletFile2->m_rigidBodies[i]; int foundRb = -1; int uid = rbd->m_collisionObjectData.m_uniqueId; - for (int i = 0; i < m_data->m_mbDynamicsWorld->getNumCollisionObjects(); i++) + for (int j = 0; j < m_data->m_mbDynamicsWorld->getNumCollisionObjects(); j++) { - if (uid == m_data->m_mbDynamicsWorld->getCollisionObjectArray()[i]->getBroadphaseHandle()->m_uniqueId) + if (uid == m_data->m_mbDynamicsWorld->getCollisionObjectArray()[j]->getBroadphaseHandle()->m_uniqueId) { - foundRb = i; + foundRb = j; break; } } @@ -477,8 +477,8 @@ bool btMultiBodyWorldImporter::convertAllObjects(bParse::btBulletFile* bulletFil { btMultiBody* mb = *ptr; mb->finalizeMultiDof(); - btVector3 linvel = mb->getBaseVel(); - btVector3 angvel = mb->getBaseOmega(); + // btVector3 linvel = mb->getBaseVel(); + // btVector3 angvel = mb->getBaseOmega(); mb->forwardKinematics(scratchQ, scratchM); } } @@ -568,4 +568,4 @@ bool btMultiBodyWorldImporter::convertAllObjects(bParse::btBulletFile* bulletFil } } return result; -} \ No newline at end of file +} diff --git a/Extras/Serialize/BulletWorldImporter/btWorldImporter.cpp b/Extras/Serialize/BulletWorldImporter/btWorldImporter.cpp index df4106596e..051d07571a 100644 --- a/Extras/Serialize/BulletWorldImporter/btWorldImporter.cpp +++ b/Extras/Serialize/BulletWorldImporter/btWorldImporter.cpp @@ -220,7 +220,7 @@ btCollisionShape* btWorldImporter::convertCollisionShape(btCollisionShapeData* s { printf("error: wrong up axis for btCapsuleShape\n"); } - }; + } if (shape) { btCapsuleShape* cap = (btCapsuleShape*)shape; @@ -282,7 +282,7 @@ btCollisionShape* btWorldImporter::convertCollisionShape(btCollisionShapeData* s { printf("unknown Cylinder up axis\n"); } - }; + } break; } @@ -311,7 +311,7 @@ btCollisionShape* btWorldImporter::convertCollisionShape(btCollisionShapeData* s { printf("unknown Cone up axis\n"); } - }; + } break; } @@ -378,9 +378,9 @@ btCollisionShape* btWorldImporter::convertCollisionShape(btCollisionShapeData* s { shape->setMargin(bsd->m_collisionMargin); - btVector3 localScaling; - localScaling.deSerializeFloat(bsd->m_localScaling); - shape->setLocalScaling(localScaling); + btVector3 localScale; + localScale.deSerializeFloat(bsd->m_localScaling); + shape->setLocalScaling(localScale); } break; } @@ -493,7 +493,7 @@ char* btWorldImporter::duplicateName(const char* name) { if (name) { - int l = (int)strlen(name); + size_t l = strlen(name); char* newName = new char[l + 1]; memcpy(newName, name, l); newName[l] = 0; @@ -519,7 +519,7 @@ void btWorldImporter::convertConstraintBackwardsCompatible281(btTypedConstraintD pivotInB.deSerializeDouble(p2pData->m_pivotInB); constraint = createPoint2PointConstraint(*rbA, *rbB, pivotInA, pivotInB); } - else + else if(rbA) { btVector3 pivotInA; pivotInA.deSerializeDouble(p2pData->m_pivotInA); @@ -539,18 +539,23 @@ void btWorldImporter::convertConstraintBackwardsCompatible281(btTypedConstraintD rbBFrame.deSerializeDouble(hingeData->m_rbBFrame); hinge = createHingeConstraint(*rbA, *rbB, rbAFrame, rbBFrame, hingeData->m_useReferenceFrameA != 0); } - else + else if(rbA) { btTransform rbAFrame; rbAFrame.deSerializeDouble(hingeData->m_rbAFrame); hinge = createHingeConstraint(*rbA, rbAFrame, hingeData->m_useReferenceFrameA != 0); } - if (hingeData->m_enableAngularMotor) + else + printf("Error in btWorldImporter::createGeneric6DofConstraint: missing rbA\n"); + if(hinge) { - hinge->enableAngularMotor(true, (btScalar)hingeData->m_motorTargetVelocity, (btScalar)hingeData->m_maxMotorImpulse); + if (hingeData->m_enableAngularMotor) + { + hinge->enableAngularMotor(true, (btScalar)hingeData->m_motorTargetVelocity, (btScalar)hingeData->m_maxMotorImpulse); + } + hinge->setAngularOnly(hingeData->m_angularOnly != 0); + hinge->setLimit(btScalar(hingeData->m_lowerLimit), btScalar(hingeData->m_upperLimit), btScalar(hingeData->m_limitSoftness), btScalar(hingeData->m_biasFactor), btScalar(hingeData->m_relaxationFactor)); } - hinge->setAngularOnly(hingeData->m_angularOnly != 0); - hinge->setLimit(btScalar(hingeData->m_lowerLimit), btScalar(hingeData->m_upperLimit), btScalar(hingeData->m_limitSoftness), btScalar(hingeData->m_biasFactor), btScalar(hingeData->m_relaxationFactor)); constraint = hinge; break; @@ -567,15 +572,20 @@ void btWorldImporter::convertConstraintBackwardsCompatible281(btTypedConstraintD rbBFrame.deSerializeFloat(coneData->m_rbBFrame); coneTwist = createConeTwistConstraint(*rbA, *rbB, rbAFrame, rbBFrame); } - else + else if(rbA) { btTransform rbAFrame; rbAFrame.deSerializeFloat(coneData->m_rbAFrame); coneTwist = createConeTwistConstraint(*rbA, rbAFrame); } - coneTwist->setLimit((btScalar)coneData->m_swingSpan1, (btScalar)coneData->m_swingSpan2, (btScalar)coneData->m_twistSpan, (btScalar)coneData->m_limitSoftness, - (btScalar)coneData->m_biasFactor, (btScalar)coneData->m_relaxationFactor); - coneTwist->setDamping((btScalar)coneData->m_damping); + else + printf("Error in btWorldImporter::createGeneric6DofConstraint: missing rbA\n"); + if(coneTwist) + { + coneTwist->setLimit((btScalar)coneData->m_swingSpan1, (btScalar)coneData->m_swingSpan2, (btScalar)coneData->m_twistSpan, (btScalar)coneData->m_limitSoftness, + (btScalar)coneData->m_biasFactor, (btScalar)coneData->m_relaxationFactor); + coneTwist->setDamping((btScalar)coneData->m_damping); + } constraint = coneTwist; break; @@ -683,17 +693,22 @@ void btWorldImporter::convertConstraintBackwardsCompatible281(btTypedConstraintD rbBFrame.deSerializeFloat(sliderData->m_rbBFrame); slider = createSliderConstraint(*rbA, *rbB, rbAFrame, rbBFrame, sliderData->m_useLinearReferenceFrameA != 0); } - else + else if(rbB) { btTransform rbBFrame; rbBFrame.deSerializeFloat(sliderData->m_rbBFrame); slider = createSliderConstraint(*rbB, rbBFrame, sliderData->m_useLinearReferenceFrameA != 0); } - slider->setLowerLinLimit((btScalar)sliderData->m_linearLowerLimit); - slider->setUpperLinLimit((btScalar)sliderData->m_linearUpperLimit); - slider->setLowerAngLimit((btScalar)sliderData->m_angularLowerLimit); - slider->setUpperAngLimit((btScalar)sliderData->m_angularUpperLimit); - slider->setUseFrameOffset(sliderData->m_useOffsetForConstraintFrame != 0); + else + printf("Error in btWorldImporter::createGeneric6DofConstraint: missing rbB\n"); + if(slider) + { + slider->setLowerLinLimit((btScalar)sliderData->m_linearLowerLimit); + slider->setUpperLinLimit((btScalar)sliderData->m_linearUpperLimit); + slider->setLowerAngLimit((btScalar)sliderData->m_angularLowerLimit); + slider->setUpperAngLimit((btScalar)sliderData->m_angularUpperLimit); + slider->setUseFrameOffset(sliderData->m_useOffsetForConstraintFrame != 0); + } constraint = slider; break; } @@ -702,7 +717,7 @@ void btWorldImporter::convertConstraintBackwardsCompatible281(btTypedConstraintD { printf("unknown constraint type\n"); } - }; + } if (constraint) { @@ -742,7 +757,7 @@ void btWorldImporter::convertConstraintFloat(btTypedConstraintFloatData* constra pivotInB.deSerializeFloat(p2pData->m_pivotInB); constraint = createPoint2PointConstraint(*rbA, *rbB, pivotInA, pivotInB); } - else + else if(rbA) { btVector3 pivotInA; pivotInA.deSerializeFloat(p2pData->m_pivotInA); @@ -761,18 +776,23 @@ void btWorldImporter::convertConstraintFloat(btTypedConstraintFloatData* constra rbBFrame.deSerializeFloat(hingeData->m_rbBFrame); hinge = createHingeConstraint(*rbA, *rbB, rbAFrame, rbBFrame, hingeData->m_useReferenceFrameA != 0); } - else + else if(rbA) { btTransform rbAFrame; rbAFrame.deSerializeFloat(hingeData->m_rbAFrame); hinge = createHingeConstraint(*rbA, rbAFrame, hingeData->m_useReferenceFrameA != 0); } - if (hingeData->m_enableAngularMotor) + else + printf("Error in btWorldImporter::createGeneric6DofConstraint: missing rbA\n"); + if(hinge) { - hinge->enableAngularMotor(true, hingeData->m_motorTargetVelocity, hingeData->m_maxMotorImpulse); + if (hingeData->m_enableAngularMotor) + { + hinge->enableAngularMotor(true, hingeData->m_motorTargetVelocity, hingeData->m_maxMotorImpulse); + } + hinge->setAngularOnly(hingeData->m_angularOnly != 0); + hinge->setLimit(btScalar(hingeData->m_lowerLimit), btScalar(hingeData->m_upperLimit), btScalar(hingeData->m_limitSoftness), btScalar(hingeData->m_biasFactor), btScalar(hingeData->m_relaxationFactor)); } - hinge->setAngularOnly(hingeData->m_angularOnly != 0); - hinge->setLimit(btScalar(hingeData->m_lowerLimit), btScalar(hingeData->m_upperLimit), btScalar(hingeData->m_limitSoftness), btScalar(hingeData->m_biasFactor), btScalar(hingeData->m_relaxationFactor)); constraint = hinge; break; @@ -789,14 +809,19 @@ void btWorldImporter::convertConstraintFloat(btTypedConstraintFloatData* constra rbBFrame.deSerializeFloat(coneData->m_rbBFrame); coneTwist = createConeTwistConstraint(*rbA, *rbB, rbAFrame, rbBFrame); } - else + else if(rbA) { btTransform rbAFrame; rbAFrame.deSerializeFloat(coneData->m_rbAFrame); coneTwist = createConeTwistConstraint(*rbA, rbAFrame); } - coneTwist->setLimit(coneData->m_swingSpan1, coneData->m_swingSpan2, coneData->m_twistSpan, coneData->m_limitSoftness, coneData->m_biasFactor, coneData->m_relaxationFactor); - coneTwist->setDamping(coneData->m_damping); + else + printf("Error in btWorldImporter::createGeneric6DofConstraint: missing rbA\n"); + if(coneTwist) + { + coneTwist->setLimit(coneData->m_swingSpan1, coneData->m_swingSpan2, coneData->m_twistSpan, coneData->m_limitSoftness, coneData->m_biasFactor, coneData->m_relaxationFactor); + coneTwist->setDamping(coneData->m_damping); + } constraint = coneTwist; break; @@ -904,17 +929,22 @@ void btWorldImporter::convertConstraintFloat(btTypedConstraintFloatData* constra rbBFrame.deSerializeFloat(sliderData->m_rbBFrame); slider = createSliderConstraint(*rbA, *rbB, rbAFrame, rbBFrame, sliderData->m_useLinearReferenceFrameA != 0); } - else + else if(rbB) { btTransform rbBFrame; rbBFrame.deSerializeFloat(sliderData->m_rbBFrame); slider = createSliderConstraint(*rbB, rbBFrame, sliderData->m_useLinearReferenceFrameA != 0); } - slider->setLowerLinLimit(sliderData->m_linearLowerLimit); - slider->setUpperLinLimit(sliderData->m_linearUpperLimit); - slider->setLowerAngLimit(sliderData->m_angularLowerLimit); - slider->setUpperAngLimit(sliderData->m_angularUpperLimit); - slider->setUseFrameOffset(sliderData->m_useOffsetForConstraintFrame != 0); + else + printf("Error in btWorldImporter::createGeneric6DofConstraint: missing rbA\n"); + if(slider) + { + slider->setLowerLinLimit(sliderData->m_linearLowerLimit); + slider->setUpperLinLimit(sliderData->m_linearUpperLimit); + slider->setLowerAngLimit(sliderData->m_angularLowerLimit); + slider->setUpperAngLimit(sliderData->m_angularUpperLimit); + slider->setUseFrameOffset(sliderData->m_useOffsetForConstraintFrame != 0); + } constraint = slider; break; } @@ -986,7 +1016,7 @@ void btWorldImporter::convertConstraintFloat(btTypedConstraintFloatData* constra dof->setStiffness(i + 3, dofData->m_angularSpringStiffness.m_floats[i], (dofData->m_angularSpringStiffnessLimited[i] != 0)); dof->setEquilibriumPoint(i + 3, dofData->m_angularEquilibriumPoint.m_floats[i]); dof->enableSpring(i + 3, dofData->m_angularEnableSpring[i] != 0); - dof->setDamping(i + 3, dofData->m_angularSpringDamping.m_floats[i], dofData->m_angularSpringDampingLimited[i]); + dof->setDamping(i + 3, dofData->m_angularSpringDamping.m_floats[i], dofData->m_angularSpringDampingLimited[i] != 0); } } } @@ -1027,7 +1057,7 @@ void btWorldImporter::convertConstraintFloat(btTypedConstraintFloatData* constra { printf("unknown constraint type\n"); } - }; + } if (constraint) { @@ -1067,7 +1097,7 @@ void btWorldImporter::convertConstraintDouble(btTypedConstraintDoubleData* const pivotInB.deSerializeDouble(p2pData->m_pivotInB); constraint = createPoint2PointConstraint(*rbA, *rbB, pivotInA, pivotInB); } - else + else if(rbA) { btVector3 pivotInA; pivotInA.deSerializeDouble(p2pData->m_pivotInA); @@ -1087,18 +1117,23 @@ void btWorldImporter::convertConstraintDouble(btTypedConstraintDoubleData* const rbBFrame.deSerializeDouble(hingeData->m_rbBFrame); hinge = createHingeConstraint(*rbA, *rbB, rbAFrame, rbBFrame, hingeData->m_useReferenceFrameA != 0); } - else + else if(rbA) { btTransform rbAFrame; rbAFrame.deSerializeDouble(hingeData->m_rbAFrame); hinge = createHingeConstraint(*rbA, rbAFrame, hingeData->m_useReferenceFrameA != 0); } - if (hingeData->m_enableAngularMotor) + else + printf("Error in btWorldImporter::createGeneric6DofConstraint: missing rbA\n"); + if(hinge) { - hinge->enableAngularMotor(true, (btScalar)hingeData->m_motorTargetVelocity, (btScalar)hingeData->m_maxMotorImpulse); + if (hingeData->m_enableAngularMotor) + { + hinge->enableAngularMotor(true, (btScalar)hingeData->m_motorTargetVelocity, (btScalar)hingeData->m_maxMotorImpulse); + } + hinge->setAngularOnly(hingeData->m_angularOnly != 0); + hinge->setLimit(btScalar(hingeData->m_lowerLimit), btScalar(hingeData->m_upperLimit), btScalar(hingeData->m_limitSoftness), btScalar(hingeData->m_biasFactor), btScalar(hingeData->m_relaxationFactor)); } - hinge->setAngularOnly(hingeData->m_angularOnly != 0); - hinge->setLimit(btScalar(hingeData->m_lowerLimit), btScalar(hingeData->m_upperLimit), btScalar(hingeData->m_limitSoftness), btScalar(hingeData->m_biasFactor), btScalar(hingeData->m_relaxationFactor)); constraint = hinge; break; @@ -1115,15 +1150,20 @@ void btWorldImporter::convertConstraintDouble(btTypedConstraintDoubleData* const rbBFrame.deSerializeDouble(coneData->m_rbBFrame); coneTwist = createConeTwistConstraint(*rbA, *rbB, rbAFrame, rbBFrame); } - else + else if(rbA) { btTransform rbAFrame; rbAFrame.deSerializeDouble(coneData->m_rbAFrame); coneTwist = createConeTwistConstraint(*rbA, rbAFrame); } - coneTwist->setLimit((btScalar)coneData->m_swingSpan1, (btScalar)coneData->m_swingSpan2, (btScalar)coneData->m_twistSpan, (btScalar)coneData->m_limitSoftness, - (btScalar)coneData->m_biasFactor, (btScalar)coneData->m_relaxationFactor); - coneTwist->setDamping((btScalar)coneData->m_damping); + else + printf("Error in btWorldImporter::createGeneric6DofConstraint: missing rbA\n"); + if(coneTwist) + { + coneTwist->setLimit((btScalar)coneData->m_swingSpan1, (btScalar)coneData->m_swingSpan2, (btScalar)coneData->m_twistSpan, (btScalar)coneData->m_limitSoftness, + (btScalar)coneData->m_biasFactor, (btScalar)coneData->m_relaxationFactor); + coneTwist->setDamping((btScalar)coneData->m_damping); + } constraint = coneTwist; break; @@ -1231,17 +1271,22 @@ void btWorldImporter::convertConstraintDouble(btTypedConstraintDoubleData* const rbBFrame.deSerializeDouble(sliderData->m_rbBFrame); slider = createSliderConstraint(*rbA, *rbB, rbAFrame, rbBFrame, sliderData->m_useLinearReferenceFrameA != 0); } - else + else if(rbB) { btTransform rbBFrame; rbBFrame.deSerializeDouble(sliderData->m_rbBFrame); slider = createSliderConstraint(*rbB, rbBFrame, sliderData->m_useLinearReferenceFrameA != 0); } - slider->setLowerLinLimit((btScalar)sliderData->m_linearLowerLimit); - slider->setUpperLinLimit((btScalar)sliderData->m_linearUpperLimit); - slider->setLowerAngLimit((btScalar)sliderData->m_angularLowerLimit); - slider->setUpperAngLimit((btScalar)sliderData->m_angularUpperLimit); - slider->setUseFrameOffset(sliderData->m_useOffsetForConstraintFrame != 0); + else + printf("Error in btWorldImporter::createGeneric6DofConstraint: missing rbB\n"); + if(slider) + { + slider->setLowerLinLimit((btScalar)sliderData->m_linearLowerLimit); + slider->setUpperLinLimit((btScalar)sliderData->m_linearUpperLimit); + slider->setLowerAngLimit((btScalar)sliderData->m_angularLowerLimit); + slider->setUpperAngLimit((btScalar)sliderData->m_angularUpperLimit); + slider->setUseFrameOffset(sliderData->m_useOffsetForConstraintFrame != 0); + } constraint = slider; break; } @@ -1254,7 +1299,7 @@ void btWorldImporter::convertConstraintDouble(btTypedConstraintDoubleData* const btVector3 axisInA, axisInB; axisInA.deSerializeDouble(gearData->m_axisInA); axisInB.deSerializeDouble(gearData->m_axisInB); - gear = createGearConstraint(*rbA, *rbB, axisInA, axisInB, gearData->m_ratio); + gear = createGearConstraint(*rbA, *rbB, axisInA, axisInB, (btScalar)gearData->m_ratio); } else { @@ -1304,17 +1349,17 @@ void btWorldImporter::convertConstraintDouble(btTypedConstraintDoubleData* const //6-dof: 3 linear followed by 3 angular for (i = 0; i < 3; i++) { - dof->setStiffness(i, dofData->m_linearSpringStiffness.m_floats[i], dofData->m_linearSpringStiffnessLimited[i]); - dof->setEquilibriumPoint(i, dofData->m_linearEquilibriumPoint.m_floats[i]); + dof->setStiffness(i, (btScalar)dofData->m_linearSpringStiffness.m_floats[i], dofData->m_linearSpringStiffnessLimited[i] != 0); + dof->setEquilibriumPoint(i, (btScalar)dofData->m_linearEquilibriumPoint.m_floats[i]); dof->enableSpring(i, dofData->m_linearEnableSpring[i] != 0); - dof->setDamping(i, dofData->m_linearSpringDamping.m_floats[i], (dofData->m_linearSpringDampingLimited[i] != 0)); + dof->setDamping(i, (btScalar)dofData->m_linearSpringDamping.m_floats[i], (dofData->m_linearSpringDampingLimited[i] != 0)); } for (i = 0; i < 3; i++) { - dof->setStiffness(i + 3, dofData->m_angularSpringStiffness.m_floats[i], (dofData->m_angularSpringStiffnessLimited[i] != 0)); - dof->setEquilibriumPoint(i + 3, dofData->m_angularEquilibriumPoint.m_floats[i]); + dof->setStiffness(i + 3, (btScalar)dofData->m_angularSpringStiffness.m_floats[i], (dofData->m_angularSpringStiffnessLimited[i] != 0)); + dof->setEquilibriumPoint(i + 3, (btScalar)dofData->m_angularEquilibriumPoint.m_floats[i]); dof->enableSpring(i + 3, dofData->m_angularEnableSpring[i] != 0); - dof->setDamping(i + 3, dofData->m_angularSpringDamping.m_floats[i], (dofData->m_angularSpringDampingLimited[i] != 0)); + dof->setDamping(i + 3, (btScalar)dofData->m_angularSpringDamping.m_floats[i], (dofData->m_angularSpringDampingLimited[i] != 0)); } } } @@ -1356,7 +1401,7 @@ void btWorldImporter::convertConstraintDouble(btTypedConstraintDoubleData* const { printf("unknown constraint type\n"); } - }; + } if (constraint) { @@ -1504,7 +1549,7 @@ btStridingMeshInterfaceData* btWorldImporter::createStridingMeshInterfaceData(bt newData->m_scaling = interfaceData->m_scaling; newData->m_numMeshParts = interfaceData->m_numMeshParts; - newData->m_meshPartsPtr = new btMeshPartData[newData->m_numMeshParts]; + newData->m_meshPartsPtr = new btMeshPartData[(size_t)newData->m_numMeshParts]; for (int i = 0; i < newData->m_numMeshParts; i++) { @@ -1516,7 +1561,7 @@ btStridingMeshInterfaceData* btWorldImporter::createStridingMeshInterfaceData(bt if (curPart->m_vertices3f) { - curNewPart->m_vertices3f = new btVector3FloatData[curNewPart->m_numVertices]; + curNewPart->m_vertices3f = new btVector3FloatData[(size_t)curNewPart->m_numVertices]; memcpy(curNewPart->m_vertices3f, curPart->m_vertices3f, sizeof(btVector3FloatData) * curNewPart->m_numVertices); } else @@ -1524,7 +1569,7 @@ btStridingMeshInterfaceData* btWorldImporter::createStridingMeshInterfaceData(bt if (curPart->m_vertices3d) { - curNewPart->m_vertices3d = new btVector3DoubleData[curNewPart->m_numVertices]; + curNewPart->m_vertices3d = new btVector3DoubleData[(size_t)curNewPart->m_numVertices]; memcpy(curNewPart->m_vertices3d, curPart->m_vertices3d, sizeof(btVector3DoubleData) * curNewPart->m_numVertices); } else @@ -1538,7 +1583,7 @@ btStridingMeshInterfaceData* btWorldImporter::createStridingMeshInterfaceData(bt if (curPart->m_indices32) { uninitialized3indices8Workaround = true; - curNewPart->m_indices32 = new btIntIndexData[numIndices]; + curNewPart->m_indices32 = new btIntIndexData[(size_t)numIndices]; memcpy(curNewPart->m_indices32, curPart->m_indices32, sizeof(btIntIndexData) * numIndices); } else @@ -1547,7 +1592,7 @@ btStridingMeshInterfaceData* btWorldImporter::createStridingMeshInterfaceData(bt if (curPart->m_3indices16) { uninitialized3indices8Workaround = true; - curNewPart->m_3indices16 = new btShortIntIndexTripletData[curNewPart->m_numTriangles]; + curNewPart->m_3indices16 = new btShortIntIndexTripletData[(size_t)curNewPart->m_numTriangles]; memcpy(curNewPart->m_3indices16, curPart->m_3indices16, sizeof(btShortIntIndexTripletData) * curNewPart->m_numTriangles); } else @@ -1556,7 +1601,7 @@ btStridingMeshInterfaceData* btWorldImporter::createStridingMeshInterfaceData(bt if (curPart->m_indices16) { uninitialized3indices8Workaround = true; - curNewPart->m_indices16 = new btShortIntIndexData[numIndices]; + curNewPart->m_indices16 = new btShortIntIndexData[(size_t)numIndices]; memcpy(curNewPart->m_indices16, curPart->m_indices16, sizeof(btShortIntIndexData) * numIndices); } else @@ -1564,7 +1609,7 @@ btStridingMeshInterfaceData* btWorldImporter::createStridingMeshInterfaceData(bt if (!uninitialized3indices8Workaround && curPart->m_3indices8) { - curNewPart->m_3indices8 = new btCharIndexTripletData[curNewPart->m_numTriangles]; + curNewPart->m_3indices8 = new btCharIndexTripletData[(size_t)curNewPart->m_numTriangles]; memcpy(curNewPart->m_3indices8, curPart->m_3indices8, sizeof(btCharIndexTripletData) * curNewPart->m_numTriangles); } else @@ -1602,12 +1647,12 @@ void btWorldImporter::setDynamicsWorldInfo(const btVector3& gravity, const btCon } } -btRigidBody* btWorldImporter::createRigidBody(bool isDynamic, btScalar mass, const btTransform& startTransform, btCollisionShape* shape, const char* bodyName) +btRigidBody* btWorldImporter::createRigidBody(bool /*isDynamic*/, btScalar mass, const btTransform& startTransform, btCollisionShape* shape, const char* bodyName) { btVector3 localInertia; localInertia.setZero(); - if (mass) + if (mass != btScalar(0)) shape->calculateLocalInertia(mass, localInertia); btRigidBody* body = new btRigidBody(mass, 0, shape, localInertia); @@ -1743,7 +1788,7 @@ btBvhTriangleMeshShape* btWorldImporter::createBvhTriangleMeshShape(btStridingMe m_allocatedCollisionShapes.push_back(ts); return ts; } -btCollisionShape* btWorldImporter::createConvexTriangleMeshShape(btStridingMeshInterface* trimesh) +btCollisionShape* btWorldImporter::createConvexTriangleMeshShape(btStridingMeshInterface* /*trimesh*/) { return 0; } @@ -1754,6 +1799,7 @@ btGImpactMeshShape* btWorldImporter::createGimpactShape(btStridingMeshInterface* m_allocatedCollisionShapes.push_back(shape); return shape; #else + (void)trimesh; return 0; #endif } @@ -1985,7 +2031,7 @@ btTriangleInfoMap* btWorldImporter::getTriangleInfoMapByIndex(int index) const void btWorldImporter::convertRigidBodyFloat(btRigidBodyFloatData* colObjData) { - btScalar mass = btScalar(colObjData->m_inverseMass ? 1.f / colObjData->m_inverseMass : 0.f); + btScalar mass = btScalar(colObjData->m_inverseMass != 0.0f ? 1.f / colObjData->m_inverseMass : 0.f); btVector3 localInertia; localInertia.setZero(); btCollisionShape** shapePtr = m_shapeMap.find(colObjData->m_collisionObjectData.m_collisionShape); @@ -2001,7 +2047,7 @@ void btWorldImporter::convertRigidBodyFloat(btRigidBodyFloatData* colObjData) { mass = 0.f; } - if (mass) + if (mass != btScalar(0)) { shape->calculateLocalInertia(mass, localInertia); } @@ -2035,7 +2081,7 @@ void btWorldImporter::convertRigidBodyFloat(btRigidBodyFloatData* colObjData) void btWorldImporter::convertRigidBodyDouble(btRigidBodyDoubleData* colObjData) { - btScalar mass = btScalar(colObjData->m_inverseMass ? 1.f / colObjData->m_inverseMass : 0.f); + btScalar mass = btScalar(colObjData->m_inverseMass != 0.0 ? 1.f / colObjData->m_inverseMass : 0.f); btVector3 localInertia; localInertia.setZero(); btCollisionShape** shapePtr = m_shapeMap.find(colObjData->m_collisionObjectData.m_collisionShape); @@ -2051,7 +2097,7 @@ void btWorldImporter::convertRigidBodyDouble(btRigidBodyDoubleData* colObjData) { mass = 0.f; } - if (mass) + if (mass != btScalar(0)) { shape->calculateLocalInertia(mass, localInertia); } diff --git a/Extras/Serialize/BulletWorldImporter/btWorldImporter.h b/Extras/Serialize/BulletWorldImporter/btWorldImporter.h index ba087fba72..bd91c4dae9 100644 --- a/Extras/Serialize/BulletWorldImporter/btWorldImporter.h +++ b/Extras/Serialize/BulletWorldImporter/btWorldImporter.h @@ -60,7 +60,7 @@ struct btRigidBodyFloatData; enum btWorldImporterFlags { - eRESTORE_EXISTING_OBJECTS = 1, //don't create new objects + eRESTORE_EXISTING_OBJECTS = 1 //don't create new objects }; class btWorldImporter @@ -154,7 +154,7 @@ class btWorldImporter int getNumTriangleInfoMaps() const; btTriangleInfoMap* getTriangleInfoMapByIndex(int index) const; - // queris involving named objects + // queries involving named objects btCollisionShape* getCollisionShapeByName(const char* name); btRigidBody* getRigidBodyByName(const char* name); btTypedConstraint* getConstraintByName(const char* name); @@ -224,4 +224,4 @@ class btWorldImporter virtual btGearConstraint* createGearConstraint(btRigidBody& rbA, btRigidBody& rbB, const btVector3& axisInA, const btVector3& axisInB, btScalar ratio); }; -#endif //BT_WORLD_IMPORTER_H \ No newline at end of file +#endif //BT_WORLD_IMPORTER_H diff --git a/Extras/Serialize/BulletXmlWorldImporter/btBulletXmlWorldImporter.cpp b/Extras/Serialize/BulletXmlWorldImporter/btBulletXmlWorldImporter.cpp index 17b1440241..56e8cd9595 100644 --- a/Extras/Serialize/BulletXmlWorldImporter/btBulletXmlWorldImporter.cpp +++ b/Extras/Serialize/BulletXmlWorldImporter/btBulletXmlWorldImporter.cpp @@ -14,7 +14,14 @@ subject to the following restrictions: */ #include "btBulletXmlWorldImporter.h" +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wextra-semi-stmt" +#endif #include "tinyxml2.h" +#if defined(__clang__) +#pragma clang diagnostic pop +#endif #include "btBulletDynamicsCommon.h" #include "string_split.h" using namespace tinyxml2; @@ -75,7 +82,7 @@ static int get_int_attribute_by_name(const XMLElement* pElement, const char* att return 0; } -void stringToFloatArray(const std::string& string, btAlignedObjectArray& floats) +static void stringToFloatArray(const std::string& string, btAlignedObjectArray& floats) { btAlignedObjectArray pieces; @@ -119,43 +126,43 @@ void btBulletXmlWorldImporter::deSerializeVector3FloatData(XMLNode* pParent, btA #define SET_INT_VALUE(xmlnode, targetdata, argname) \ btAssert((xmlnode)->FirstChildElement(#argname) && (xmlnode)->FirstChildElement(#argname)->ToElement()); \ if ((xmlnode)->FirstChildElement(#argname) && (xmlnode)->FirstChildElement(#argname)->ToElement()) \ - (targetdata)->argname = (int)atof(xmlnode->FirstChildElement(#argname)->ToElement()->GetText()); + (targetdata)->argname = (int)atof(xmlnode->FirstChildElement(#argname)->ToElement()->GetText()) #define SET_FLOAT_VALUE(xmlnode, targetdata, argname) \ btAssert((xmlnode)->FirstChildElement(#argname) && (xmlnode)->FirstChildElement(#argname)->ToElement()); \ if ((xmlnode)->FirstChildElement(#argname) && (xmlnode)->FirstChildElement(#argname)->ToElement()) \ - (targetdata)->argname = (float)atof(xmlnode->FirstChildElement(#argname)->ToElement()->GetText()); + (targetdata)->argname = (float)atof(xmlnode->FirstChildElement(#argname)->ToElement()->GetText()) #define SET_POINTER_VALUE(xmlnode, targetdata, argname, pointertype) \ - { \ + do { \ XMLNode* node = xmlnode->FirstChildElement(#argname); \ btAssert(node); \ if (node) \ { \ - const char* txt = (node)->ToElement()->GetText(); \ - MyLocalCaster cast; \ - cast.m_int = (int)atof(txt); \ - (targetdata).argname = (pointertype)cast.m_ptr; \ + const char* text = (node)->ToElement()->GetText(); \ + MyLocalCaster caster; \ + caster.m_int = (int)atof(text); \ + (targetdata).argname = (pointertype)caster.m_ptr; \ } \ - } - -#define SET_VECTOR4_VALUE(xmlnode, targetdata, argname) \ - { \ - XMLNode* flNode = xmlnode->FirstChildElement(#argname); \ - btAssert(flNode); \ - if (flNode && flNode->FirstChildElement()) \ - { \ - const char* txt = flNode->FirstChildElement()->ToElement()->GetText(); \ - btVector3FloatData vec4 = TextToVector3Data(txt); \ - (targetdata)->argname.m_floats[0] = vec4.m_floats[0]; \ - (targetdata)->argname.m_floats[1] = vec4.m_floats[1]; \ - (targetdata)->argname.m_floats[2] = vec4.m_floats[2]; \ - (targetdata)->argname.m_floats[3] = vec4.m_floats[3]; \ - } \ - } + } while(0) + +#define SET_VECTOR4_VALUE(xmlnode, targetdata, argname) \ + do { \ + XMLNode* flNode = xmlnode->FirstChildElement(#argname); \ + btAssert(flNode); \ + if (flNode && flNode->FirstChildElement()) \ + { \ + const char* text = flNode->FirstChildElement()->ToElement()->GetText(); \ + btVector3FloatData v4 = TextToVector3Data(text); \ + (targetdata)->argname.m_floats[0] = v4.m_floats[0]; \ + (targetdata)->argname.m_floats[1] = v4.m_floats[1]; \ + (targetdata)->argname.m_floats[2] = v4.m_floats[2]; \ + (targetdata)->argname.m_floats[3] = v4.m_floats[3]; \ + } \ + } while(0) #define SET_MATRIX33_VALUE(n, targetdata, argname) \ - { \ + do { \ XMLNode* xmlnode = n->FirstChildElement(#argname); \ btAssert(xmlnode); \ if (xmlnode) \ @@ -165,53 +172,53 @@ void btBulletXmlWorldImporter::deSerializeVector3FloatData(XMLNode* pParent, btA if (eleNode && eleNode->FirstChildElement()) \ { \ const char* txt = eleNode->FirstChildElement()->ToElement()->GetText(); \ - btVector3FloatData vec4 = TextToVector3Data(txt); \ - (targetdata)->argname.m_el[0].m_floats[0] = vec4.m_floats[0]; \ - (targetdata)->argname.m_el[0].m_floats[1] = vec4.m_floats[1]; \ - (targetdata)->argname.m_el[0].m_floats[2] = vec4.m_floats[2]; \ - (targetdata)->argname.m_el[0].m_floats[3] = vec4.m_floats[3]; \ + btVector3FloatData vec41 = TextToVector3Data(txt); \ + (targetdata)->argname.m_el[0].m_floats[0] = vec41.m_floats[0]; \ + (targetdata)->argname.m_el[0].m_floats[1] = vec41.m_floats[1]; \ + (targetdata)->argname.m_el[0].m_floats[2] = vec41.m_floats[2]; \ + (targetdata)->argname.m_el[0].m_floats[3] = vec41.m_floats[3]; \ \ XMLNode* n1 = eleNode->FirstChildElement()->NextSibling(); \ btAssert(n1); \ if (n1) \ { \ - const char* txt = n1->ToElement()->GetText(); \ - btVector3FloatData vec4 = TextToVector3Data(txt); \ - (targetdata)->argname.m_el[1].m_floats[0] = vec4.m_floats[0]; \ - (targetdata)->argname.m_el[1].m_floats[1] = vec4.m_floats[1]; \ - (targetdata)->argname.m_el[1].m_floats[2] = vec4.m_floats[2]; \ - (targetdata)->argname.m_el[1].m_floats[3] = vec4.m_floats[3]; \ + const char* txt2 = n1->ToElement()->GetText(); \ + btVector3FloatData vec42 = TextToVector3Data(txt2); \ + (targetdata)->argname.m_el[1].m_floats[0] = vec42.m_floats[0]; \ + (targetdata)->argname.m_el[1].m_floats[1] = vec42.m_floats[1]; \ + (targetdata)->argname.m_el[1].m_floats[2] = vec42.m_floats[2]; \ + (targetdata)->argname.m_el[1].m_floats[3] = vec42.m_floats[3]; \ \ XMLNode* n2 = n1->NextSibling(); \ btAssert(n2); \ if (n2) \ { \ - const char* txt = n2->ToElement()->GetText(); \ - btVector3FloatData vec4 = TextToVector3Data(txt); \ - (targetdata)->argname.m_el[2].m_floats[0] = vec4.m_floats[0]; \ - (targetdata)->argname.m_el[2].m_floats[1] = vec4.m_floats[1]; \ - (targetdata)->argname.m_el[2].m_floats[2] = vec4.m_floats[2]; \ - (targetdata)->argname.m_el[2].m_floats[3] = vec4.m_floats[3]; \ + const char* txt3 = n2->ToElement()->GetText(); \ + btVector3FloatData vec43 = TextToVector3Data(txt3); \ + (targetdata)->argname.m_el[2].m_floats[0] = vec43.m_floats[0]; \ + (targetdata)->argname.m_el[2].m_floats[1] = vec43.m_floats[1]; \ + (targetdata)->argname.m_el[2].m_floats[2] = vec43.m_floats[2]; \ + (targetdata)->argname.m_el[2].m_floats[3] = vec43.m_floats[3]; \ } \ } \ } \ } \ - } - -#define SET_TRANSFORM_VALUE(n, targetdata, argname) \ - { \ - XMLNode* trNode = n->FirstChildElement(#argname); \ - btAssert(trNode); \ - if (trNode) \ - { \ - SET_VECTOR4_VALUE(trNode, &(targetdata)->argname, m_origin) \ - SET_MATRIX33_VALUE(trNode, &(targetdata)->argname, m_basis) \ - } \ - } + } while(0) + +#define SET_TRANSFORM_VALUE(n, targetdata, argname) \ + do { \ + XMLNode* trNode = n->FirstChildElement(#argname); \ + btAssert(trNode); \ + if (trNode) \ + { \ + SET_VECTOR4_VALUE(trNode, &(targetdata)->argname, m_origin); \ + SET_MATRIX33_VALUE(trNode, &(targetdata)->argname, m_basis); \ + } \ + } while(0) void btBulletXmlWorldImporter::deSerializeCollisionShapeData(XMLNode* pParent, btCollisionShapeData* colShapeData) { - SET_INT_VALUE(pParent, colShapeData, m_shapeType) + SET_INT_VALUE(pParent, colShapeData, m_shapeType); colShapeData->m_name = 0; } @@ -230,9 +237,9 @@ void btBulletXmlWorldImporter::deSerializeConvexHullShapeData(XMLNode* pParent) deSerializeCollisionShapeData(xmlColShape, &convexHullData->m_convexInternalShapeData.m_collisionShapeData); - SET_FLOAT_VALUE(xmlConvexInt, &convexHullData->m_convexInternalShapeData, m_collisionMargin) - SET_VECTOR4_VALUE(xmlConvexInt, &convexHullData->m_convexInternalShapeData, m_localScaling) - SET_VECTOR4_VALUE(xmlConvexInt, &convexHullData->m_convexInternalShapeData, m_implicitShapeDimensions) + SET_FLOAT_VALUE(xmlConvexInt, &convexHullData->m_convexInternalShapeData, m_collisionMargin); + SET_VECTOR4_VALUE(xmlConvexInt, &convexHullData->m_convexInternalShapeData, m_localScaling); + SET_VECTOR4_VALUE(xmlConvexInt, &convexHullData->m_convexInternalShapeData, m_implicitShapeDimensions); //convexHullData->m_unscaledPointsFloatPtr //#define SET_POINTER_VALUE(xmlnode, targetdata, argname, pointertype) @@ -243,9 +250,9 @@ void btBulletXmlWorldImporter::deSerializeConvexHullShapeData(XMLNode* pParent) if (node) { const char* txt = (node)->ToElement()->GetText(); - MyLocalCaster cast; - cast.m_int = (int)atof(txt); - (*convexHullData).m_unscaledPointsFloatPtr = (btVector3FloatData*)cast.m_ptr; + MyLocalCaster caster; + caster.m_int = (int)atof(txt); + (*convexHullData).m_unscaledPointsFloatPtr = (btVector3FloatData*)caster.m_ptr; } } @@ -274,13 +281,13 @@ void btBulletXmlWorldImporter::deSerializeCompoundShapeChildData(XMLNode* pParen while (transNode && colShapeNode && marginNode && childTypeNode) { compoundChildArrayPtr->expandNonInitializing(); - SET_VECTOR4_VALUE(transNode, &compoundChildArrayPtr->at(i).m_transform, m_origin) - SET_MATRIX33_VALUE(transNode, &compoundChildArrayPtr->at(i).m_transform, m_basis) + SET_VECTOR4_VALUE(transNode, &compoundChildArrayPtr->at(i).m_transform, m_origin); + SET_MATRIX33_VALUE(transNode, &compoundChildArrayPtr->at(i).m_transform, m_basis); const char* txt = (colShapeNode)->ToElement()->GetText(); - MyLocalCaster cast; - cast.m_int = (int)atof(txt); - compoundChildArrayPtr->at(i).m_childShape = (btCollisionShapeData*)cast.m_ptr; + MyLocalCaster caster; + caster.m_int = (int)atof(txt); + compoundChildArrayPtr->at(i).m_childShape = (btCollisionShapeData*)caster.m_ptr; btAssert(childTypeNode->ToElement()); if (childTypeNode->ToElement()) @@ -335,9 +342,9 @@ void btBulletXmlWorldImporter::deSerializeCompoundShapeData(XMLNode* pParent) while (node) { const char* txt = (node)->ToElement()->GetText(); - MyLocalCaster cast; - cast.m_int = (int)atof(txt); - compoundData->m_childShapePtr = (btCompoundShapeChildData*)cast.m_ptr; + MyLocalCaster caster; + caster.m_int = (int)atof(txt); + compoundData->m_childShapePtr = (btCompoundShapeChildData*)caster.m_ptr; node = node->NextSiblingElement("m_childShapePtr"); } //SET_POINTER_VALUE(xmlColShape, *compoundData,m_childShapePtr,btCompoundShapeChildData*); @@ -367,7 +374,7 @@ void btBulletXmlWorldImporter::deSerializeStaticPlaneShapeData(XMLNode* pParent) m_pointerLookup.insert(cast.m_ptr, planeData); } -void btBulletXmlWorldImporter::deSerializeDynamicsWorldData(XMLNode* pParent) +void btBulletXmlWorldImporter::deSerializeDynamicsWorldData(XMLNode* /*pParent*/) { btContactSolverInfo solverInfo; //btVector3 gravity(0,0,0); @@ -390,9 +397,9 @@ void btBulletXmlWorldImporter::deSerializeConvexInternalShapeData(XMLNode* pPare deSerializeCollisionShapeData(xmlShapeData, &convexShape->m_collisionShapeData); - SET_FLOAT_VALUE(pParent, convexShape, m_collisionMargin) - SET_VECTOR4_VALUE(pParent, convexShape, m_localScaling) - SET_VECTOR4_VALUE(pParent, convexShape, m_implicitShapeDimensions) + SET_FLOAT_VALUE(pParent, convexShape, m_collisionMargin); + SET_VECTOR4_VALUE(pParent, convexShape, m_localScaling); + SET_VECTOR4_VALUE(pParent, convexShape, m_implicitShapeDimensions); m_collisionShapeData.push_back((btCollisionShapeData*)convexShape); m_pointerLookup.insert(cast.m_ptr, convexShape); @@ -470,9 +477,9 @@ void btBulletXmlWorldImporter::deSerializeRigidBodyFloatData(XMLNode* pParent) SET_POINTER_VALUE(n, rbData->m_collisionObjectData, m_collisionShape, void*); SET_TRANSFORM_VALUE(n, &rbData->m_collisionObjectData, m_worldTransform); SET_TRANSFORM_VALUE(n, &rbData->m_collisionObjectData, m_interpolationWorldTransform); - SET_VECTOR4_VALUE(n, &rbData->m_collisionObjectData, m_interpolationLinearVelocity) - SET_VECTOR4_VALUE(n, &rbData->m_collisionObjectData, m_interpolationAngularVelocity) - SET_VECTOR4_VALUE(n, &rbData->m_collisionObjectData, m_anisotropicFriction) + SET_VECTOR4_VALUE(n, &rbData->m_collisionObjectData, m_interpolationLinearVelocity); + SET_VECTOR4_VALUE(n, &rbData->m_collisionObjectData, m_interpolationAngularVelocity); + SET_VECTOR4_VALUE(n, &rbData->m_collisionObjectData, m_anisotropicFriction); SET_FLOAT_VALUE(n, &rbData->m_collisionObjectData, m_contactProcessingThreshold); SET_FLOAT_VALUE(n, &rbData->m_collisionObjectData, m_deactivationTime); SET_FLOAT_VALUE(n, &rbData->m_collisionObjectData, m_friction); @@ -493,15 +500,15 @@ void btBulletXmlWorldImporter::deSerializeRigidBodyFloatData(XMLNode* pParent) SET_MATRIX33_VALUE(pParent, rbData, m_invInertiaTensorWorld); - SET_VECTOR4_VALUE(pParent, rbData, m_linearVelocity) - SET_VECTOR4_VALUE(pParent, rbData, m_angularVelocity) - SET_VECTOR4_VALUE(pParent, rbData, m_angularFactor) - SET_VECTOR4_VALUE(pParent, rbData, m_linearFactor) - SET_VECTOR4_VALUE(pParent, rbData, m_gravity) - SET_VECTOR4_VALUE(pParent, rbData, m_gravity_acceleration) - SET_VECTOR4_VALUE(pParent, rbData, m_invInertiaLocal) - SET_VECTOR4_VALUE(pParent, rbData, m_totalTorque) - SET_VECTOR4_VALUE(pParent, rbData, m_totalForce) + SET_VECTOR4_VALUE(pParent, rbData, m_linearVelocity); + SET_VECTOR4_VALUE(pParent, rbData, m_angularVelocity); + SET_VECTOR4_VALUE(pParent, rbData, m_angularFactor); + SET_VECTOR4_VALUE(pParent, rbData, m_linearFactor); + SET_VECTOR4_VALUE(pParent, rbData, m_gravity); + SET_VECTOR4_VALUE(pParent, rbData, m_gravity_acceleration); + SET_VECTOR4_VALUE(pParent, rbData, m_invInertiaLocal); + SET_VECTOR4_VALUE(pParent, rbData, m_totalTorque); + SET_VECTOR4_VALUE(pParent, rbData, m_totalForce); SET_FLOAT_VALUE(pParent, rbData, m_inverseMass); SET_FLOAT_VALUE(pParent, rbData, m_linearDamping); SET_FLOAT_VALUE(pParent, rbData, m_angularDamping); diff --git a/Extras/Serialize/BulletXmlWorldImporter/btBulletXmlWorldImporter.h b/Extras/Serialize/BulletXmlWorldImporter/btBulletXmlWorldImporter.h index aa88c088a2..6393055157 100644 --- a/Extras/Serialize/BulletXmlWorldImporter/btBulletXmlWorldImporter.h +++ b/Extras/Serialize/BulletXmlWorldImporter/btBulletXmlWorldImporter.h @@ -23,7 +23,7 @@ class btDynamicsWorld; namespace tinyxml2 { class XMLNode; -}; +} struct btConvexInternalShapeData; struct btCollisionShapeData; diff --git a/Extras/Serialize/BulletXmlWorldImporter/string_split.cpp b/Extras/Serialize/BulletXmlWorldImporter/string_split.cpp index 4325126b3e..602774ca46 100644 --- a/Extras/Serialize/BulletXmlWorldImporter/string_split.cpp +++ b/Extras/Serialize/BulletXmlWorldImporter/string_split.cpp @@ -28,20 +28,20 @@ namespace bullet_utils void split(btAlignedObjectArray &pieces, const std::string &vector_str, const std::string &separator) { char **strArray = str_split(vector_str.c_str(), separator.c_str()); - int numSubStr = str_array_len(strArray); + int numSubStr = (int)str_array_len(strArray); for (int i = 0; i < numSubStr; i++) pieces.push_back(std::string(strArray[i])); str_array_free(strArray); } -}; // namespace bullet_utils +} // namespace bullet_utils /* Append an item to a dynamically allocated array of strings. On failure, return NULL, in which case the original array is intact. The item string is dynamically copied. If the array is NULL, allocate a new array. Otherwise, extend the array. Make sure the array is always NULL-terminated. Input string might not be '\0'-terminated. */ -char **str_array_append(char **array, size_t nitems, const char *item, +static char **str_array_append(char **array, size_t nitems, const char *item, size_t itemlen) { /* Make a dynamic copy of the item. */ @@ -60,12 +60,14 @@ char **str_array_append(char **array, size_t nitems, const char *item, /* Extend array with one element. Except extend it by two elements, in case it did not yet exist. This might mean it is a teeny bit too big, but we don't care. */ - array = (char **)realloc(array, (nitems + 2) * sizeof(array[0])); - if (array == NULL) + char ** reallocated = (char **)realloc(array, (nitems + 2) * sizeof(array[0])); + if (reallocated == NULL) { free(copy); return NULL; } + else + array = reallocated; /* Add copy of item to array, and return it. */ array[nitems] = copy; @@ -78,8 +80,12 @@ void str_array_free(char **array) { if (array == NULL) return; - for (size_t i = 0; array[i] != NULL; ++i) + size_t i = 0; + while(array[i] != NULL) + { free(array[i]); + ++i; + } free(array); } @@ -95,6 +101,7 @@ char **str_split(const char *input, const char *sep) size_t seplen = strlen(sep); const char *item; size_t itemlen; + (void)next; for (;;) { @@ -122,7 +129,7 @@ char **str_split(const char *input, const char *sep) else { item = start; - itemlen = next - item; + itemlen = (size_t)(next - item); } char **newstr = str_array_append(array, nitems, item, itemlen); if (newstr == NULL) diff --git a/Extras/Serialize/BulletXmlWorldImporter/string_split.h b/Extras/Serialize/BulletXmlWorldImporter/string_split.h index 16d629d610..78353780d7 100644 --- a/Extras/Serialize/BulletXmlWorldImporter/string_split.h +++ b/Extras/Serialize/BulletXmlWorldImporter/string_split.h @@ -27,7 +27,7 @@ subject to the following restrictions: namespace bullet_utils { void split(btAlignedObjectArray& pieces, const std::string& vector_str, const std::string& separator); -}; +} ///The string split C code is by Lars Wirzenius ///See http://stackoverflow.com/questions/2531605/how-to-split-a-string-with-a-delimiter-larger-than-one-single-char diff --git a/Extras/Serialize/HeaderGenerator/apiGen.cpp b/Extras/Serialize/HeaderGenerator/apiGen.cpp index 233bee9f58..affcc11d04 100644 --- a/Extras/Serialize/HeaderGenerator/apiGen.cpp +++ b/Extras/Serialize/HeaderGenerator/apiGen.cpp @@ -73,7 +73,7 @@ class bVariable }; /////////////////////////////////////////////////////////////////////////////// -bool dataTypeStandard(bString dataType) +static bool dataTypeStandard(bString dataType) { if (dataType == "char") return true; @@ -95,7 +95,7 @@ bool dataTypeStandard(bString dataType) } /////////////////////////////////////////////////////////////////////////////// -void writeTemplate(short *structData) +static void writeTemplate(short *structData) { bString type = mDNA->getType(structData[0]); bString className = type; @@ -259,6 +259,7 @@ int main(int argc, char **argv) swap = (f.getFlags() & FD_ENDIAN_SWAP)!=0; } #else + (void)argc; (void)argv; isBulletFile = true; bool swap = false; char *memBuf = sBulletDNAstr; @@ -285,26 +286,29 @@ int main(int argc, char **argv) } FILE *fpdna = fopen("dnaString.txt", "w"); - char buf[1024]; - - for (int i = 0; i < len - sdnaPos; i++) + if(fpdna) { - int dnaval = (memBuf + sdnaPos)[i]; + char buf[1024]; - if ((i % 32) == 0) - { - sprintf(buf, "%d,\n", dnaval); - } - else + for (int i = 0; i < len - sdnaPos; i++) { - sprintf(buf, "%d,", dnaval); + int dnaval = (memBuf + sdnaPos)[i]; + + if ((i % 32) == 0) + { + sprintf(buf, "%d,\n", dnaval); + } + else + { + sprintf(buf, "%d,", dnaval); + } + + fwrite(buf, strlen(buf), 1, fpdna); } - fwrite(buf, strlen(buf), 1, fpdna); + fclose(fpdna); } - fclose(fpdna); - mDNA = new bDNA(); //mDNA->initMemory(); @@ -332,13 +336,13 @@ int main(int argc, char **argv) /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -int _getArraySize(char *str) +static int _getArraySize(char *str) { int a, mul = 1; char stri[100], *cp = 0; int len = (int)strlen(str); - memcpy(stri, str, len + 1); + memcpy(stri, str, (size_t)len + 1); for (a = 0; a < len; a++) { if (str[a] == '[') diff --git a/Extras/Serialize/makesdna/makesdna.cpp b/Extras/Serialize/makesdna/makesdna.cpp index 525ec5f069..c46943be08 100644 --- a/Extras/Serialize/makesdna/makesdna.cpp +++ b/Extras/Serialize/makesdna/makesdna.cpp @@ -56,7 +56,7 @@ extern "C" #if defined(_WIN32) && !defined(FREE_WINDOWS) - /* The __intXX are built-in types of the visual complier! So we don't + /* The __intXX are built-in types of the visual compiler! So we don't * need to include anything else here. */ typedef signed __int8 int8_t; @@ -111,7 +111,7 @@ typedef intptr_t btintptr_t; #include //#include "DNA_sdna_types.h" -// include files for automatic dependancies +// include files for automatic dependencies #include "DNA_rigidbody.h" #include "LinearMath/btVector3.h" #include "LinearMath/btQuaternion.h" @@ -159,7 +159,7 @@ typedef intptr_t btintptr_t; /* Included the path relative from /source/blender/ here, so we can move */ /* headers around with more freedom. */ -char *includefiles[] = { +const char *includefiles[] = { // if you add files here, please add them at the end // of makesdna.c (this file) as well @@ -204,10 +204,10 @@ char *includefiles[] = { // empty string to indicate end of includefiles ""}; -void *malloc_and_setzero(int numbytes) +static void *malloc_and_setzero(int numbytes) { - char *buf = (char *)malloc(numbytes); - memset(buf, 0, numbytes); + char *buf = (char *)malloc((size_t)numbytes); + memset(buf, 0, (size_t)numbytes); return buf; } @@ -215,11 +215,11 @@ int maxdata = 500000, maxnr = 50000; int nr_names = 0; int nr_types = 0; int nr_structs = 0; -char **names, *namedata; /* at adress names[a] is string a */ -char **types, *typedata; /* at adress types[a] is string a */ +char **names, *namedata; /* at address names[a] is string a */ +char **types, *typedata; /* at address types[a] is string a */ short *typelens; /* at typelens[a] is de length of type a */ short *alphalens; /* contains sizes as they are calculated on the DEC Alpha (64 bits) */ -short **structs, *structdata; /* at sp= structs[a] is the first adress of a struct definition +short **structs, *structdata; /* at sp= structs[a] is the first address of a struct definition sp[0] is type number sp[1] is amount of elements sp[2] sp[3] is typenr, namenr (etc) */ @@ -240,7 +240,7 @@ int additional_slen_offset; /** * Add type to struct indexed by , if it was not yet found. */ -int add_type(char *str, int len); +int add_type(const char *str, int len); /** * Add variable to @@ -267,7 +267,7 @@ int convert_include(char *filename); /** * Determine how many bytes are needed for an array. */ -int arraysize(char *astr, int len); +int arraysize(const char *astr, int len); /** * Determine how many bytes are needed for each struct. @@ -280,7 +280,7 @@ static int calculate_structlens(int); void dna_write(FILE *file, void *pntr, int size); /** - * Report all structures found so far, and print their lenghts. + * Report all structures found so far, and print their lengths. */ void printStructLenghts(void); @@ -290,7 +290,7 @@ void printStructLenghts(void); /* ************************* MAKEN DNA ********************** */ -int add_type(char *str, int len) +int add_type(const char *str, int len) { int nr; char *cp; @@ -304,8 +304,8 @@ int add_type(char *str, int len) { if (len) { - typelens[nr] = len; - alphalens[nr] = len; + typelens[nr] = (short)len; + alphalens[nr] = (short)len; } return nr; } @@ -320,14 +320,13 @@ int add_type(char *str, int len) } strcpy(cp, str); types[nr_types] = cp; - typelens[nr_types] = len; - alphalens[nr_types] = len; + typelens[nr_types] = (short)len; + alphalens[nr_types] = (short)len; if (nr_types >= maxnr) { printf("too many types\n"); return nr_types - 1; - ; } nr_types++; @@ -351,7 +350,7 @@ int add_name(char *str) additional_slen_offset = 0; - if ((str[0] == 0) /* || (str[1]==0) */) return -1; + if (str[0] == 0 /* || (str[1]==0) */) return -1; if (str[0] == '(' && str[1] == '*') { @@ -398,7 +397,7 @@ int add_name(char *str) else if (str[j] == ')') { if (debugSDNA > 3) printf("offsetting for brace\n"); - ; /* don't get extra offset */ + /* don't get extra offset */ } else { @@ -493,7 +492,7 @@ short *add_struct(int namecode) } sp = structs[nr_structs]; - sp[0] = namecode; + sp[0] = (short)namecode; if (nr_structs >= maxnr) { @@ -511,7 +510,7 @@ int preprocess_include(char *maindata, int len) char *cp, *temp, *md; temp = (char *)malloc_and_setzero(len); - memcpy(temp, maindata, len); + memcpy(temp, maindata, (size_t)len); // remove all c++ comments /* replace all enters/tabs/etc with spaces */ @@ -528,7 +527,7 @@ int preprocess_include(char *maindata, int len) { comment = 0; } - if (comment || *cp < 32 || *cp > 128) *cp = 32; + if (comment || *cp < 32) *cp = 32; cp++; } @@ -587,7 +586,7 @@ static void *read_file_data(char *filename, int *len_r) } fseek(fp, 0L, SEEK_END); - *len_r = ftell(fp); + *len_r = (int)ftell(fp); fseek(fp, 0L, SEEK_SET); data = malloc_and_setzero(*len_r); @@ -598,7 +597,7 @@ static void *read_file_data(char *filename, int *len_r) return NULL; } - if (fread(data, *len_r, 1, fp) != 1) + if (fread(data, (size_t)*len_r, 1, fp) != 1) { *len_r = -1; free(data); @@ -620,7 +619,7 @@ const char *skipStructTypes[] = "btTriangleInfo", ""}; -int skipStruct(const char *structType) +static int skipStruct(const char *structType) { int i = 0; while (strlen(skipStructTypes[i])) @@ -736,8 +735,8 @@ int convert_include(char *filename) name = add_name(md1); slen += additional_slen_offset; - sp[0] = type; - sp[1] = name; + sp[0] = (short)type; + sp[1] = (short)name; if ((debugSDNA > 1) && (names[name] != 0)) printf("%s |", names[name]); @@ -751,8 +750,8 @@ int convert_include(char *filename) name = add_name(md1); slen += additional_slen_offset; - sp[0] = type; - sp[1] = name; + sp[0] = (short)type; + sp[1] = (short)name; if ((debugSDNA > 1) && (names[name] != 0)) printf("%s ||", names[name]); structpoin[1]++; @@ -780,12 +779,12 @@ int convert_include(char *filename) return 0; } -int arraysize(char *astr, int len) +int arraysize(const char *astr, int len) { int a, mul = 1; char str[100], *cp = 0; - memcpy(str, astr, len + 1); + memcpy(str, astr, (size_t)len + 1); for (a = 0; a < len; a++) { @@ -845,7 +844,8 @@ static int calculate_structlens(int firststruct) if (cp[namelen - 1] == ']') mul = arraysize(cp, namelen); /* 4-8 aligned/ */ - if (sizeof(void *) == 4) + const bool is32bitSystem = sizeof(void *) == 4; + if (is32bitSystem) { if (len % 4) { @@ -868,7 +868,7 @@ static int calculate_structlens(int firststruct) dna_error = 1; } - len += sizeof(void *) * mul; + len += sizeof(void *) * (size_t)mul; alphalen += 8 * mul; } else if (typelens[type]) @@ -880,7 +880,8 @@ static int calculate_structlens(int firststruct) /* struct alignment */ if (type >= firststruct) { - if (sizeof(void *) == 8 && (len % 8)) + const bool is64bitSystem = sizeof(void *) == 8; + if (is64bitSystem && (len % 8)) { printf("Align struct error: %s %s\n", types[structtype], cp); dna_error = 1; @@ -916,8 +917,8 @@ static int calculate_structlens(int firststruct) } else { - typelens[structtype] = len; - alphalens[structtype] = alphalen; + typelens[structtype] = (short)len; + alphalens[structtype] = (short)alphalen; // two ways to detect if a struct contains a pointer: // has_pointer is set or alphalen != len if (has_pointer || alphalen != len) @@ -970,7 +971,7 @@ static int calculate_structlens(int firststruct) structpoin = structs[a]; structtype = structpoin[0]; - /* length unkown yet */ + /* length unknown yet */ if (typelens[structtype] == 0) { printf(" %s\n", types[structtype]); @@ -1005,13 +1006,13 @@ void dna_write(FILE *file, void *pntr, int size) void printStructLenghts(void) { - int a, unknown = nr_structs, lastunknown, structtype; + int a, unknown = nr_structs, /*lastunknown,*/ structtype; short *structpoin; printf("\n\n*** All detected structs:\n"); while (unknown) { - lastunknown = unknown; + /* lastunknown = unknown; */ unknown = 0; /* check all structs... */ @@ -1026,7 +1027,7 @@ void printStructLenghts(void) printf("*** End of list\n"); } -int make_structDNA(char *baseDirectory, FILE *file) +static int make_structDNA(char *baseDirectory, FILE *file) { int len, i; short *sp; @@ -1041,17 +1042,17 @@ int make_structDNA(char *baseDirectory, FILE *file) printf("Running makesdna at debug level %d\n", debugSDNA); } - /* the longest known struct is 50k, so we assume 100k is sufficent! */ + /* the longest known struct is 50k, so we assume 100k is sufficient! */ namedata = (char *)malloc_and_setzero(maxdata); typedata = (char *)malloc_and_setzero(maxdata); structdata = (short *)malloc_and_setzero(maxdata); /* a maximum of 5000 variables, must be sufficient? */ - names = (char **)malloc_and_setzero(sizeof(char *) * maxnr); - types = (char **)malloc_and_setzero(sizeof(char *) * maxnr); - typelens = (short *)malloc_and_setzero(sizeof(short) * maxnr); - alphalens = (short *)malloc_and_setzero(sizeof(short) * maxnr); - structs = (short **)malloc_and_setzero(sizeof(short) * maxnr); + names = (char **)malloc_and_setzero(int(sizeof(char *) * (size_t)maxnr)); + types = (char **)malloc_and_setzero(int(sizeof(char *) * (size_t)maxnr)); + typelens = (short *)malloc_and_setzero(int(sizeof(short) * (size_t)maxnr)); + alphalens = (short *)malloc_and_setzero(int(sizeof(short) * (size_t)maxnr)); + structs = (short **)malloc_and_setzero(int(sizeof(short) * (size_t)maxnr)); /* insertion of all known types */ /* watch it: uint is not allowed! use in structs an unsigned int */ @@ -1146,7 +1147,7 @@ int make_structDNA(char *baseDirectory, FILE *file) /* calculate size of datablock with strings */ cp = names[nr_names - 1]; cp += strlen(names[nr_names - 1]) + 1; /* +1: null-terminator */ - len = (btintptr_t)(cp - (char *)names[0]); + len = (int)(cp - (char *)names[0]); len = (len + 3) & ~3; dna_write(file, names[0], len); @@ -1159,7 +1160,7 @@ int make_structDNA(char *baseDirectory, FILE *file) /* calculate datablock size */ cp = types[nr_types - 1]; cp += strlen(types[nr_types - 1]) + 1; /* +1: null-terminator */ - len = (btintptr_t)(cp - (char *)types[0]); + len = (int)(cp - (char *)types[0]); len = (len + 3) & ~3; dna_write(file, types[0], len); @@ -1181,13 +1182,13 @@ int make_structDNA(char *baseDirectory, FILE *file) /* calc datablock size */ sp = structs[nr_structs - 1]; sp += 2 + 2 * (sp[1]); - len = (btintptr_t)((char *)sp - (char *)structs[0]); + len = (int)((char *)sp - (char *)structs[0]); len = (len + 3) & ~3; dna_write(file, structs[0], len); /* a simple dna padding test */ - if (0) + if (/* DISABLES CODE */ (0)) { FILE *fp; int a; @@ -1315,7 +1316,8 @@ int main(int argc, char **argv) strcpy(baseDirectory, BASE_HEADER); } - if (sizeof(void *) == 8) + const bool is64bitSystem = sizeof(void *) == 8; + if (is64bitSystem) { fprintf(file, "char sBulletDNAstr64[]= {\n"); } @@ -1334,7 +1336,7 @@ int main(int argc, char **argv) else { fprintf(file, "};\n"); - if (sizeof(void *) == 8) + if (is64bitSystem) { fprintf(file, "int sBulletDNAlen64= sizeof(sBulletDNAstr64);\n"); } diff --git a/Extras/VHACD/inc/vhacdCircularList.h b/Extras/VHACD/inc/vhacdCircularList.h index 9e4b7ae3f7..b8486d3467 100644 --- a/Extras/VHACD/inc/vhacdCircularList.h +++ b/Extras/VHACD/inc/vhacdCircularList.h @@ -63,7 +63,7 @@ class CircularList { while (Delete()) ; - }; + } const CircularList& operator=(const CircularList& rhs); //! Constructor CircularList() @@ -73,7 +73,7 @@ class CircularList } CircularList(const CircularList& rhs); //! Destructor - ~CircularList(void) { Clear(); }; + ~CircularList(void) { Clear(); } private: CircularListElement* m_head; //!< a pointer to the head of the circular list @@ -81,4 +81,4 @@ class CircularList }; } // namespace VHACD #include "vhacdCircularList.inl" -#endif // VHACD_CIRCULAR_LIST_H \ No newline at end of file +#endif // VHACD_CIRCULAR_LIST_H diff --git a/Extras/VHACD/inc/vhacdCircularList.inl b/Extras/VHACD/inc/vhacdCircularList.inl index 2be5180524..592df9fc89 100644 --- a/Extras/VHACD/inc/vhacdCircularList.inl +++ b/Extras/VHACD/inc/vhacdCircularList.inl @@ -14,12 +14,12 @@ namespace VHACD { CircularListElement * next = element->GetNext(); CircularListElement * prev = element->GetPrev(); - delete element; - m_size--; if (element == m_head) { m_head = next; } + delete element; + m_size--; next->GetPrev() = prev; prev->GetNext() = next; return true; @@ -158,4 +158,4 @@ namespace VHACD return (*this); } } -#endif \ No newline at end of file +#endif diff --git a/Extras/VHACD/inc/vhacdICHull.h b/Extras/VHACD/inc/vhacdICHull.h index ef799c600d..936ab2e8fd 100644 --- a/Extras/VHACD/inc/vhacdICHull.h +++ b/Extras/VHACD/inc/vhacdICHull.h @@ -55,7 +55,7 @@ class ICHull //! Constructor ICHull(); //! Destructor - ~ICHull(void){}; + ~ICHull(void){} private: //! DoubleTriangle builds the initial double triangle. It first finds 3 noncollinear points and makes two faces out of them, in opposite order. It then finds a fourth point that is not coplanar with that face. The vertices are stored in the face structure in counterclockwise order so that the volume between the face and the point is negative. Lastly, the 3 newfaces to the fourth point are constructed and the data structures are cleaned up. diff --git a/Extras/VHACD/inc/vhacdManifoldMesh.h b/Extras/VHACD/inc/vhacdManifoldMesh.h index 2c3ebe508f..f644891016 100644 --- a/Extras/VHACD/inc/vhacdManifoldMesh.h +++ b/Extras/VHACD/inc/vhacdManifoldMesh.h @@ -144,4 +144,4 @@ class TMMesh friend class ICHull; }; } // namespace VHACD -#endif // VHACD_MANIFOLD_MESH_H \ No newline at end of file +#endif // VHACD_MANIFOLD_MESH_H diff --git a/Extras/VHACD/inc/vhacdMesh.h b/Extras/VHACD/inc/vhacdMesh.h index a617fc8ca1..f41bf01c9b 100644 --- a/Extras/VHACD/inc/vhacdMesh.h +++ b/Extras/VHACD/inc/vhacdMesh.h @@ -60,7 +60,7 @@ struct Material m_emissiveColor.Z() = 0.0; m_shininess = 0.4; m_transparency = 0.0; - }; + } }; #endif // VHACD_DEBUG_MESH @@ -68,24 +68,24 @@ struct Material class Mesh { public: - void AddPoint(const Vec3& pt) { m_points.PushBack(pt); }; - void SetPoint(size_t index, const Vec3& pt) { m_points[index] = pt; }; - const Vec3& GetPoint(size_t index) const { return m_points[index]; }; - Vec3& GetPoint(size_t index) { return m_points[index]; }; - size_t GetNPoints() const { return m_points.Size(); }; + void AddPoint(const Vec3& pt) { m_points.PushBack(pt); } + void SetPoint(size_t index, const Vec3& pt) { m_points[index] = pt; } + const Vec3& GetPoint(size_t index) const { return m_points[index]; } + Vec3& GetPoint(size_t index) { return m_points[index]; } + size_t GetNPoints() const { return m_points.Size(); } double* GetPoints() { return (double*)m_points.Data(); } // ugly - const double* const GetPoints() const { return (double*)m_points.Data(); } // ugly - const Vec3* const GetPointsBuffer() const { return m_points.Data(); } // - Vec3* const GetPointsBuffer() { return m_points.Data(); } // - void AddTriangle(const Vec3& tri) { m_triangles.PushBack(tri); }; - void SetTriangle(size_t index, const Vec3& tri) { m_triangles[index] = tri; }; - const Vec3& GetTriangle(size_t index) const { return m_triangles[index]; }; - Vec3& GetTriangle(size_t index) { return m_triangles[index]; }; - size_t GetNTriangles() const { return m_triangles.Size(); }; + const double* GetPoints() const { return (double*)m_points.Data(); } // ugly + const Vec3* GetPointsBuffer() const { return m_points.Data(); } // + Vec3* GetPointsBuffer() { return m_points.Data(); } // + void AddTriangle(const Vec3& tri) { m_triangles.PushBack(tri); } + void SetTriangle(size_t index, const Vec3& tri) { m_triangles[index] = tri; } + const Vec3& GetTriangle(size_t index) const { return m_triangles[index]; } + Vec3& GetTriangle(size_t index) { return m_triangles[index]; } + size_t GetNTriangles() const { return m_triangles.Size(); } int* GetTriangles() { return (int*)m_triangles.Data(); } // ugly - const int* const GetTriangles() const { return (int*)m_triangles.Data(); } // ugly - const Vec3* const GetTrianglesBuffer() const { return m_triangles.Data(); } - Vec3* const GetTrianglesBuffer() { return m_triangles.Data(); } + const int* GetTriangles() const { return (int*)m_triangles.Data(); } // ugly + const Vec3* GetTrianglesBuffer() const { return m_triangles.Data(); } + Vec3* GetTrianglesBuffer() { return m_triangles.Data(); } const Vec3& GetCenter() const { return m_center; } const Vec3& GetMinBB() const { return m_minBB; } const Vec3& GetMaxBB() const { return m_maxBB; } @@ -130,4 +130,4 @@ class Mesh double m_diag; }; } // namespace VHACD -#endif \ No newline at end of file +#endif diff --git a/Extras/VHACD/inc/vhacdMutex.h b/Extras/VHACD/inc/vhacdMutex.h index 78c1113835..0ba10923e5 100644 --- a/Extras/VHACD/inc/vhacdMutex.h +++ b/Extras/VHACD/inc/vhacdMutex.h @@ -5,7 +5,7 @@ ** Portions of this source has been released with the PhysXViewer application, as well as ** Rocket, CreateDynamics, ODF, and as a number of sample code snippets. ** -** If you find this code useful or you are feeling particularily generous I would +** If you find this code useful or you are feeling particularly generous I would ** ask that you please go to http://www.amillionpixels.us and make a donation ** to Troy DeMolay. ** @@ -50,7 +50,7 @@ #ifndef VHACD_MUTEX_H #define VHACD_MUTEX_H -#if defined(WIN32) +#if defined(_MSC_VER) //#define _WIN32_WINNT 0x400 #include @@ -97,6 +97,7 @@ class Mutex VHACD_VERIFY(pthread_mutexattr_settype(&mutexAttr, PTHREAD_MUTEX_RECURSIVE_NP) == 0); VHACD_VERIFY(pthread_mutex_init(&m_mutex, &mutexAttr) == 0); VHACD_VERIFY(pthread_mutexattr_destroy(&mutexAttr) == 0); + (void)mutexAttr; #endif } ~Mutex(void) diff --git a/Extras/VHACD/inc/vhacdSArray.h b/Extras/VHACD/inc/vhacdSArray.h index 22a6a9dadc..79530ec183 100644 --- a/Extras/VHACD/inc/vhacdSArray.h +++ b/Extras/VHACD/inc/vhacdSArray.h @@ -42,11 +42,11 @@ class SArray { return m_size; } - T* const Data() + T* Data() { return (m_maxSize == N) ? m_data0 : m_data; } - const T* const Data() const + const T* Data() const { return (m_maxSize == N) ? m_data0 : m_data; } @@ -66,7 +66,7 @@ class SArray if (size > m_maxSize) { T* temp = new T[size]; - memcpy(temp, Data(), m_size * sizeof(T)); + memcpy((void*)temp, Data(), m_size * sizeof(T)); delete[] m_data; m_data = temp; m_maxSize = size; @@ -84,7 +84,7 @@ class SArray { size_t maxSize = (m_maxSize << 1); T* temp = new T[maxSize]; - memcpy(temp, Data(), m_maxSize * sizeof(T)); + memcpy((void*)temp, Data(), m_maxSize * sizeof(T)); delete[] m_data; m_data = temp; m_maxSize = maxSize; @@ -130,7 +130,7 @@ class SArray m_data = new T[m_maxSize]; } m_size = rhs.m_size; - memcpy(Data(), rhs.Data(), m_size * sizeof(T)); + memcpy((void*)Data(), rhs.Data(), m_size * sizeof(T)); } void Initialize() { @@ -161,4 +161,4 @@ class SArray size_t m_maxSize; }; } // namespace VHACD -#endif \ No newline at end of file +#endif diff --git a/Extras/VHACD/inc/vhacdTimer.h b/Extras/VHACD/inc/vhacdTimer.h index 6c50e41254..986ac44552 100644 --- a/Extras/VHACD/inc/vhacdTimer.h +++ b/Extras/VHACD/inc/vhacdTimer.h @@ -21,7 +21,7 @@ #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #endif #include -#elif __MACH__ +#elif defined(__MACH__) #include #include #else @@ -40,8 +40,8 @@ class Timer m_start.QuadPart = 0; m_stop.QuadPart = 0; QueryPerformanceFrequency(&m_freq); - }; - ~Timer(void){}; + } + ~Timer(void){} void Tic() { QueryPerformanceCounter(&m_start); @@ -54,7 +54,7 @@ class Timer { LARGE_INTEGER delta; delta.QuadPart = m_stop.QuadPart - m_start.QuadPart; - return (1000.0 * delta.QuadPart) / (double)m_freq.QuadPart; + return (1000.0 * (double)delta.QuadPart) / (double)m_freq.QuadPart; } private: @@ -63,7 +63,7 @@ class Timer LARGE_INTEGER m_freq; }; -#elif __MACH__ +#elif defined(__MACH__) class Timer { public: @@ -71,11 +71,11 @@ class Timer { memset(this, 0, sizeof(Timer)); host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &m_cclock); - }; + } ~Timer(void) { mach_port_deallocate(mach_task_self(), m_cclock); - }; + } void Tic() { clock_get_time(m_cclock, &m_start); @@ -101,8 +101,8 @@ class Timer Timer(void) { memset(this, 0, sizeof(Timer)); - }; - ~Timer(void){}; + } + ~Timer(void){} void Tic() { clock_gettime(CLOCK_REALTIME, &m_start); @@ -113,7 +113,7 @@ class Timer } double GetElapsedTime() // in ms { - return 1000.0 * (m_stop.tv_sec - m_start.tv_sec + (1.0E-9) * (m_stop.tv_nsec - m_start.tv_nsec)); + return 1000.0 * ((double)(m_stop.tv_sec - m_start.tv_sec) + (1.0E-9) * (double)(m_stop.tv_nsec - m_start.tv_nsec)); } private: diff --git a/Extras/VHACD/inc/vhacdVHACD.h b/Extras/VHACD/inc/vhacdVHACD.h index 405296bf49..476f3e740b 100644 --- a/Extras/VHACD/inc/vhacdVHACD.h +++ b/Extras/VHACD/inc/vhacdVHACD.h @@ -38,7 +38,7 @@ class VHACD : public IVHACD //! Constructor. VHACD() { -#if USE_THREAD == 1 && _OPENMP +#if USE_THREAD == 1 && defined(_OPENMP) m_ompNumProcessors = 2 * omp_get_num_procs(); omp_set_num_threads(m_ompNumProcessors); #else //USE_THREAD == 1 && _OPENMP @@ -282,8 +282,8 @@ class VHACD : public IVHACD params.m_logger->Log(msg.str().c_str()); } - double a = pow((double)(params.m_resolution) / n, 0.33); - size_t dim_next = (size_t)(m_dim * a + 0.5); + double a = pow((double)(params.m_resolution) / (double)n, 0.33); + size_t dim_next = (size_t)((double)m_dim * a + 0.5); if (n < params.m_resolution && iteration < maxIteration && m_volume->GetNPrimitivesOnSurf() < params.m_resolution / 8 && m_dim != dim_next) { delete m_volume; @@ -318,7 +318,7 @@ class VHACD : public IVHACD Init(); if (params.m_oclAcceleration) { - // build kernals + // build kernels } AlignMesh(points, stridePoints, nPoints, triangles, strideTriangles, nTriangles, params); VoxelizeMesh(points, stridePoints, nPoints, triangles, strideTriangles, nTriangles, params); @@ -328,7 +328,7 @@ class VHACD : public IVHACD SimplifyConvexHulls(params); if (params.m_oclAcceleration) { - // Release kernals + // Release kernels } if (GetCancel()) { diff --git a/Extras/VHACD/inc/vhacdVector.h b/Extras/VHACD/inc/vhacdVector.h index 0e724cc6ae..a68da3e102 100644 --- a/Extras/VHACD/inc/vhacdVector.h +++ b/Extras/VHACD/inc/vhacdVector.h @@ -98,9 +98,9 @@ class Vec2 }; template -const bool Colinear(const Vec3& a, const Vec3& b, const Vec3& c); +bool Colinear(const Vec3& a, const Vec3& b, const Vec3& c); template const T ComputeVolume4(const Vec3& a, const Vec3& b, const Vec3& c, const Vec3& d); } // namespace VHACD #include "vhacdVector.inl" // template implementation -#endif \ No newline at end of file +#endif diff --git a/Extras/VHACD/inc/vhacdVector.inl b/Extras/VHACD/inc/vhacdVector.inl index 223c2ef173..fd00e73ffc 100644 --- a/Extras/VHACD/inc/vhacdVector.inl +++ b/Extras/VHACD/inc/vhacdVector.inl @@ -156,13 +156,13 @@ namespace VHACD m_data[2] = rhs.m_data[2]; } template - inline Vec3::~Vec3(void){}; + inline Vec3::~Vec3(void){} template inline Vec3::Vec3() {} template - inline const bool Colinear(const Vec3 & a, const Vec3 & b, const Vec3 & c) + inline bool Colinear(const Vec3 & a, const Vec3 & b, const Vec3 & c) { return ((c.Z() - a.Z()) * (b.Y() - a.Y()) - (b.Z() - a.Z()) * (c.Y() - a.Y()) == 0.0 /*EPS*/) && ((b.Z() - a.Z()) * (c.X() - a.X()) - (b.X() - a.X()) * (c.Z() - a.Z()) == 0.0 /*EPS*/) && @@ -333,7 +333,7 @@ namespace VHACD m_data[1] = rhs.m_data[1]; } template - inline Vec2::~Vec2(void){}; + inline Vec2::~Vec2(void){} template inline Vec2::Vec2() {} @@ -343,7 +343,7 @@ namespace VHACD defined by A, B, C. */ template - inline const bool InsideTriangle(const Vec2 & a, const Vec2 & b, const Vec2 & c, const Vec2 & p) + inline bool InsideTriangle(const Vec2 & a, const Vec2 & b, const Vec2 & c, const Vec2 & p) { T ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy; T cCROSSap, bCROSScp, aCROSSbp; @@ -359,4 +359,4 @@ namespace VHACD return ((aCROSSbp >= 0.0) && (bCROSScp >= 0.0) && (cCROSSap >= 0.0)); } } -#endif //VHACD_VECTOR_INL \ No newline at end of file +#endif //VHACD_VECTOR_INL diff --git a/Extras/VHACD/inc/vhacdVolume.h b/Extras/VHACD/inc/vhacdVolume.h index cd89ca7843..3c896de63a 100644 --- a/Extras/VHACD/inc/vhacdVolume.h +++ b/Extras/VHACD/inc/vhacdVolume.h @@ -39,14 +39,14 @@ struct Voxel class PrimitiveSet { public: - virtual ~PrimitiveSet(){}; + virtual ~PrimitiveSet(){} virtual PrimitiveSet* Create() const = 0; - virtual const size_t GetNPrimitives() const = 0; - virtual const size_t GetNPrimitivesOnSurf() const = 0; - virtual const size_t GetNPrimitivesInsideSurf() const = 0; - virtual const double GetEigenValue(AXIS axis) const = 0; - virtual const double ComputeMaxVolumeError() const = 0; - virtual const double ComputeVolume() const = 0; + virtual size_t GetNPrimitives() const = 0; + virtual size_t GetNPrimitivesOnSurf() const = 0; + virtual size_t GetNPrimitivesInsideSurf() const = 0; + virtual double GetEigenValue(AXIS axis) const = 0; + virtual double ComputeMaxVolumeError() const = 0; + virtual double ComputeVolume() const = 0; virtual void Clip(const Plane& plane, PrimitiveSet* const positivePart, PrimitiveSet* const negativePart) const = 0; virtual void Intersect(const Plane& plane, SArray >* const positivePts, @@ -62,8 +62,8 @@ class PrimitiveSet virtual void AlignToPrincipalAxes() = 0; virtual void RevertAlignToPrincipalAxes() = 0; virtual void Convert(Mesh& mesh, const VOXEL_VALUE value) const = 0; - const Mesh& GetConvexHull() const { return m_convexHull; }; - Mesh& GetConvexHull() { return m_convexHull; }; + const Mesh& GetConvexHull() const { return m_convexHull; } + Mesh& GetConvexHull() { return m_convexHull; } private: Mesh m_convexHull; @@ -80,12 +80,12 @@ class VoxelSet : public PrimitiveSet //! Constructor. VoxelSet(); - const size_t GetNPrimitives() const { return m_voxels.Size(); } - const size_t GetNPrimitivesOnSurf() const { return m_numVoxelsOnSurface; } - const size_t GetNPrimitivesInsideSurf() const { return m_numVoxelsInsideSurface; } - const double GetEigenValue(AXIS axis) const { return m_D[axis][axis]; } - const double ComputeVolume() const { return m_unitVolume * m_voxels.Size(); } - const double ComputeMaxVolumeError() const { return m_unitVolume * m_numVoxelsOnSurface; } + size_t GetNPrimitives() const { return m_voxels.Size(); } + size_t GetNPrimitivesOnSurf() const { return m_numVoxelsOnSurface; } + size_t GetNPrimitivesInsideSurf() const { return m_numVoxelsInsideSurface; } + double GetEigenValue(AXIS axis) const { return m_D[axis][axis]; } + double ComputeVolume() const { return m_unitVolume * (double)m_voxels.Size(); } + double ComputeMaxVolumeError() const { return m_unitVolume * (double)m_numVoxelsOnSurface; } const Vec3& GetMinBBVoxels() const { return m_minBBVoxels; } const Vec3& GetMaxBBVoxels() const { return m_maxBBVoxels; } const Vec3& GetMinBB() const { return m_minBB; } @@ -125,10 +125,10 @@ class VoxelSet : public PrimitiveSet { return new VoxelSet(); } - void AlignToPrincipalAxes(){}; - void RevertAlignToPrincipalAxes(){}; - Voxel* const GetVoxels() { return m_voxels.Data(); } - const Voxel* const GetVoxels() const { return m_voxels.Data(); } + void AlignToPrincipalAxes(){} + void RevertAlignToPrincipalAxes(){} + Voxel* GetVoxels() { return m_voxels.Data(); } + const Voxel* GetVoxels() const { return m_voxels.Data(); } private: size_t m_numVoxelsOnSurface; @@ -165,16 +165,16 @@ class TetrahedronSet : public PrimitiveSet //! Constructor. TetrahedronSet(); - const size_t GetNPrimitives() const { return m_tetrahedra.Size(); } - const size_t GetNPrimitivesOnSurf() const { return m_numTetrahedraOnSurface; } - const size_t GetNPrimitivesInsideSurf() const { return m_numTetrahedraInsideSurface; } + size_t GetNPrimitives() const { return m_tetrahedra.Size(); } + size_t GetNPrimitivesOnSurf() const { return m_numTetrahedraOnSurface; } + size_t GetNPrimitivesInsideSurf() const { return m_numTetrahedraInsideSurface; } const Vec3& GetMinBB() const { return m_minBB; } const Vec3& GetMaxBB() const { return m_maxBB; } const Vec3& GetBarycenter() const { return m_barycenter; } - const double GetEigenValue(AXIS axis) const { return m_D[axis][axis]; } - const double GetSacle() const { return m_scale; } - const double ComputeVolume() const; - const double ComputeMaxVolumeError() const; + double GetEigenValue(AXIS axis) const { return m_D[axis][axis]; } + double GetSacle() const { return m_scale; } + double ComputeVolume() const; + double ComputeMaxVolumeError() const; void ComputeConvexHull(Mesh& meshCH, const size_t sampling = 1) const; void ComputePrincipalAxes(); void AlignToPrincipalAxes(); @@ -226,20 +226,20 @@ class Volume const size_t dim, const Vec3& barycenter, const double (&rot)[3][3]); unsigned char& GetVoxel(const size_t i, const size_t j, const size_t k) { - assert(i < m_dim[0] || i >= 0); - assert(j < m_dim[0] || j >= 0); - assert(k < m_dim[0] || k >= 0); + assert(i < m_dim[0]); + assert(j < m_dim[0]); + assert(k < m_dim[0]); return m_data[i + j * m_dim[0] + k * m_dim[0] * m_dim[1]]; } const unsigned char& GetVoxel(const size_t i, const size_t j, const size_t k) const { - assert(i < m_dim[0] || i >= 0); - assert(j < m_dim[0] || j >= 0); - assert(k < m_dim[0] || k >= 0); + assert(i < m_dim[0]); + assert(j < m_dim[0]); + assert(k < m_dim[0]); return m_data[i + j * m_dim[0] + k * m_dim[0] * m_dim[1]]; } - const size_t GetNPrimitivesOnSurf() const { return m_numVoxelsOnSurface; } - const size_t GetNPrimitivesInsideSurf() const { return m_numVoxelsInsideSurface; } + size_t GetNPrimitivesOnSurf() const { return m_numVoxelsOnSurface; } + size_t GetNPrimitivesInsideSurf() const { return m_numVoxelsInsideSurface; } void Convert(Mesh& mesh, const VOXEL_VALUE value) const; void Convert(VoxelSet& vset) const; void Convert(TetrahedronSet& tset) const; @@ -267,8 +267,8 @@ class Volume int TriBoxOverlap(const Vec3& boxcenter, const Vec3& boxhalfsize, const Vec3& triver0, const Vec3& triver1, const Vec3& triver2); template -inline void ComputeAlignedPoint(const T* const points, const unsigned int idx, const Vec3& barycenter, - const double (&rot)[3][3], Vec3& pt){}; +inline void ComputeAlignedPoint(const T* const /*points*/, const unsigned int /*idx*/, const Vec3& /*barycenter*/, + const double (& /*rot*/)[3][3], Vec3& /*pt*/){} template <> inline void ComputeAlignedPoint(const float* const points, const unsigned int idx, const Vec3& barycenter, const double (&rot)[3][3], Vec3& pt) { @@ -300,7 +300,7 @@ void Volume::ComputeBB(const T* const points, const unsigned int stridePoints, c for (unsigned int v = 1; v < nPoints; ++v) { ComputeAlignedPoint(points, v * stridePoints, barycenter, rot, pt); - for (int i = 0; i < 3; ++i) + for (size_t i = 0; i < 3; ++i) { if (pt[i] < m_minBB[i]) m_minBB[i] = pt[i]; @@ -326,26 +326,26 @@ void Volume::Voxelize(const T* const points, const unsigned int stridePoints, co { r = d[0]; m_dim[0] = dim; - m_dim[1] = 2 + static_cast(dim * d[1] / d[0]); - m_dim[2] = 2 + static_cast(dim * d[2] / d[0]); + m_dim[1] = 2 + static_cast((double)dim * d[1] / d[0]); + m_dim[2] = 2 + static_cast((double)dim * d[2] / d[0]); } else if (d[1] > d[0] && d[1] > d[2]) { r = d[1]; m_dim[1] = dim; - m_dim[0] = 2 + static_cast(dim * d[0] / d[1]); - m_dim[2] = 2 + static_cast(dim * d[2] / d[1]); + m_dim[0] = 2 + static_cast((double)dim * d[0] / d[1]); + m_dim[2] = 2 + static_cast((double)dim * d[2] / d[1]); } else { r = d[2]; m_dim[2] = dim; - m_dim[0] = 2 + static_cast(dim * d[0] / d[2]); - m_dim[1] = 2 + static_cast(dim * d[1] / d[2]); + m_dim[0] = 2 + static_cast((double)dim * d[0] / d[2]); + m_dim[1] = 2 + static_cast((double)dim * d[1] / d[2]); } - m_scale = r / (dim - 1); - double invScale = (dim - 1) / r; + m_scale = r / ((double)dim - 1); + double invScale = ((double)dim - 1) / r; Allocate(); m_numVoxelsOnSurface = 0; @@ -353,9 +353,9 @@ void Volume::Voxelize(const T* const points, const unsigned int stridePoints, co m_numVoxelsOutsideSurface = 0; Vec3 p[3]; - size_t i, j, k; - size_t i0, j0, k0; - size_t i1, j1, k1; + size_t i = 0, j = 0, k = 0; + size_t i0 = 0, j0 = 0, k0 = 0; + size_t i1 = 0, j1 = 0, k1 = 0; Vec3 boxcenter; Vec3 pt; const Vec3 boxhalfsize(0.5, 0.5, 0.5); @@ -366,14 +366,14 @@ void Volume::Voxelize(const T* const points, const unsigned int stridePoints, co triangles[ti + 2]); for (int c = 0; c < 3; ++c) { - ComputeAlignedPoint(points, tri[c] * stridePoints, barycenter, rot, pt); + ComputeAlignedPoint(points, (unsigned int)(tri[(unsigned int)c] * stridePoints), barycenter, rot, pt); p[c][0] = (pt[0] - m_minBB[0]) * invScale; p[c][1] = (pt[1] - m_minBB[1]) * invScale; p[c][2] = (pt[2] - m_minBB[2]) * invScale; i = static_cast(p[c][0] + 0.5); j = static_cast(p[c][1] + 0.5); k = static_cast(p[c][2] + 0.5); - assert(i < m_dim[0] && i >= 0 && j < m_dim[1] && j >= 0 && k < m_dim[2] && k >= 0); + assert(i < m_dim[0] && j < m_dim[1] && k < m_dim[2]); if (c == 0) { @@ -409,17 +409,17 @@ void Volume::Voxelize(const T* const points, const unsigned int stridePoints, co ++j1; if (k1 < m_dim[2]) ++k1; - for (size_t i = i0; i < i1; ++i) + for (size_t ii = i0; ii < i1; ++ii) { boxcenter[0] = (double)i; - for (size_t j = j0; j < j1; ++j) + for (size_t jj = j0; jj < j1; ++jj) { boxcenter[1] = (double)j; - for (size_t k = k0; k < k1; ++k) + for (size_t kk = k0; kk < k1; ++kk) { - boxcenter[2] = (double)k; + boxcenter[2] = (double)kk; int res = TriBoxOverlap(boxcenter, boxhalfsize, p[0], p[1], p[2]); - unsigned char& value = GetVoxel(i, j, k); + unsigned char& value = GetVoxel(ii, jj, kk); if (res == 1 && value == PRIMITIVE_UNDEFINED) { value = PRIMITIVE_ON_SURFACE; diff --git a/Extras/VHACD/public/VHACD.h b/Extras/VHACD/public/VHACD.h index 2197a34ce5..be3dac7352 100644 --- a/Extras/VHACD/public/VHACD.h +++ b/Extras/VHACD/public/VHACD.h @@ -27,7 +27,7 @@ class IVHACD class IUserCallback { public: - virtual ~IUserCallback(){}; + virtual ~IUserCallback(){} virtual void Update(const double overallProgress, const double stageProgress, const double operationProgress, @@ -38,7 +38,7 @@ class IVHACD class IUserLogger { public: - virtual ~IUserLogger(){}; + virtual ~IUserLogger(){} virtual void Log(const char* const msg) = 0; }; @@ -120,4 +120,4 @@ class IVHACD }; IVHACD* CreateVHACD(void); } // namespace VHACD -#endif // VHACD_H \ No newline at end of file +#endif // VHACD_H diff --git a/Extras/VHACD/src/VHACD.cpp b/Extras/VHACD/src/VHACD.cpp index 2853fc56f0..29a3df2129 100644 --- a/Extras/VHACD/src/VHACD.cpp +++ b/Extras/VHACD/src/VHACD.cpp @@ -13,14 +13,16 @@ 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 _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS +#endif #include #include #include #include #include -#if _OPENMP +#ifdef _OPENMP #include #endif // _OPENMP @@ -212,7 +214,7 @@ IVHACD* CreateVHACD(void) { return new VHACD(); } -bool VHACD::OCLInit(void* const oclDevice, IUserLogger* const logger) +bool VHACD::OCLInit(void* const /*oclDevice*/, IUserLogger* const /*logger*/) { #ifdef CL_VERSION_1_1 m_oclDevice = (cl_device_id*)oclDevice; @@ -229,7 +231,7 @@ bool VHACD::OCLInit(void* const oclDevice, IUserLogger* const logger) #ifdef OCL_SOURCE_FROM_FILE std::string cl_files = OPENCL_CL_FILES; -// read kernal from file +// read kernel from file #ifdef _WIN32 std::replace(cl_files.begin(), cl_files.end(), '/', '\\'); #endif // _WIN32 @@ -353,7 +355,7 @@ bool VHACD::OCLInit(void* const oclDevice, IUserLogger* const logger) return false; #endif //CL_VERSION_1_1 } -bool VHACD::OCLRelease(IUserLogger* const logger) +bool VHACD::OCLRelease(IUserLogger* const /*logger*/) { #ifdef CL_VERSION_1_1 cl_int error; @@ -366,7 +368,7 @@ bool VHACD::OCLRelease(IUserLogger* const logger) { if (logger) { - logger->Log("Couldn't release kernal\n"); + logger->Log("Couldn't release kernel\n"); } return false; } @@ -382,7 +384,7 @@ bool VHACD::OCLRelease(IUserLogger* const logger) { if (logger) { - logger->Log("Couldn't release kernal\n"); + logger->Log("Couldn't release kernel\n"); } return false; } @@ -493,7 +495,7 @@ bool VHACD::Compute(const float* const points, const unsigned int stridePoints, { return ComputeACD(points, stridePoints, nPoints, triangles, strideTriangles, nTriangles, params); } -double ComputePreferredCuttingDirection(const PrimitiveSet* const tset, Vec3& dir) +static double ComputePreferredCuttingDirection(const PrimitiveSet* const tset, Vec3& dir) { double ex = tset->GetEigenValue(AXIS_X); double ey = tset->GetEigenValue(AXIS_Y); @@ -526,7 +528,7 @@ double ComputePreferredCuttingDirection(const PrimitiveSet* const tset, Vec3& planes) +static void ComputeAxesAlignedClippingPlanes(const VoxelSet& vset, const short downsampling, SArray& planes) { const Vec3 minV = vset.GetMinBBVoxels(); const Vec3 maxV = vset.GetMaxBBVoxels(); @@ -572,7 +574,7 @@ void ComputeAxesAlignedClippingPlanes(const VoxelSet& vset, const short downsamp planes.PushBack(plane); } } -void ComputeAxesAlignedClippingPlanes(const TetrahedronSet& tset, const short downsampling, SArray& planes) +static void ComputeAxesAlignedClippingPlanes(const TetrahedronSet& tset, const short downsampling, SArray& planes) { const Vec3 minV = tset.GetMinBB(); const Vec3 maxV = tset.GetMaxBB(); @@ -619,7 +621,7 @@ void ComputeAxesAlignedClippingPlanes(const TetrahedronSet& tset, const short do planes.PushBack(plane); } } -void RefineAxesAlignedClippingPlanes(const VoxelSet& vset, const Plane& bestPlane, const short downsampling, +static void RefineAxesAlignedClippingPlanes(const VoxelSet& vset, const Plane& bestPlane, const short downsampling, SArray& planes) { const Vec3 minV = vset.GetMinBBVoxels(); @@ -676,7 +678,7 @@ void RefineAxesAlignedClippingPlanes(const VoxelSet& vset, const Plane& bestPlan } } } -void RefineAxesAlignedClippingPlanes(const TetrahedronSet& tset, const Plane& bestPlane, const short downsampling, +static void RefineAxesAlignedClippingPlanes(const TetrahedronSet& tset, const Plane& bestPlane, const short downsampling, SArray& planes) { const Vec3 minV = tset.GetMinBB(); @@ -743,7 +745,7 @@ inline double ComputeConcavity(const double volume, const double volumeCH, const } //#define DEBUG_TEMP -void VHACD::ComputeBestClippingPlane(const PrimitiveSet* inputPSet, const double volume, const SArray& planes, +void VHACD::ComputeBestClippingPlane(const PrimitiveSet* inputPSet, const double /*volume*/, const SArray& planes, const Vec3& preferredCuttingDirection, const double w, const double alpha, const double beta, const int convexhullDownsampling, const double progress0, const double progress1, Plane& bestPlane, double& minConcavity, const Parameters& params) @@ -764,15 +766,15 @@ void VHACD::ComputeBestClippingPlane(const PrimitiveSet* inputPSet, const double double minSymmetry = MAX_DOUBLE; minConcavity = MAX_DOUBLE; - SArray >* chPts = new SArray >[2 * m_ompNumProcessors]; - Mesh* chs = new Mesh[2 * m_ompNumProcessors]; + SArray >* chPts = new SArray >[2 * (size_t)m_ompNumProcessors]; + Mesh* chs = new Mesh[2 * (size_t)m_ompNumProcessors]; PrimitiveSet* onSurfacePSet = inputPSet->Create(); inputPSet->SelectOnSurface(onSurfacePSet); PrimitiveSet** psets = 0; if (!params.m_convexhullApproximation) { - psets = new PrimitiveSet*[2 * m_ompNumProcessors]; + psets = new PrimitiveSet*[2 * (size_t)m_ompNumProcessors]; for (int i = 0; i < 2 * m_ompNumProcessors; ++i) { psets[i] = inputPSet->Create(); @@ -847,6 +849,7 @@ void VHACD::ComputeBestClippingPlane(const PrimitiveSet* inputPSet, const double } } #else // CL_VERSION_1_1 + (void)oclAcceleration; oclAcceleration = false; #endif // CL_VERSION_1_1 @@ -855,13 +858,13 @@ void VHACD::ComputeBestClippingPlane(const PrimitiveSet* inputPSet, const double timerComputeCost.Tic(); #endif // DEBUG_TEMP -#if USE_THREAD == 1 && _OPENMP +#if USE_THREAD == 1 && defined(_OPENMP) #pragma omp parallel for #endif for (int x = 0; x < nPlanes; ++x) { int threadID = 0; -#if USE_THREAD == 1 && _OPENMP +#if USE_THREAD == 1 && defined(_OPENMP) threadID = omp_get_thread_num(); #pragma omp flush(cancel) #endif @@ -871,11 +874,11 @@ void VHACD::ComputeBestClippingPlane(const PrimitiveSet* inputPSet, const double if (GetCancel()) { cancel = true; -#if USE_THREAD == 1 && _OPENMP +#if USE_THREAD == 1 && defined(_OPENMP) #pragma omp flush(cancel) #endif } - Plane plane = planes[x]; + Plane plane = planes[(size_t)x]; if (oclAcceleration) { @@ -948,7 +951,7 @@ void VHACD::ComputeBestClippingPlane(const PrimitiveSet* inputPSet, const double SArray >& rightCHPts = chPts[threadID + m_ompNumProcessors]; rightCHPts.Resize(0); leftCHPts.Resize(0); - onSurfacePSet->Intersect(plane, &rightCHPts, &leftCHPts, convexhullDownsampling * 32); + onSurfacePSet->Intersect(plane, &rightCHPts, &leftCHPts, (size_t)convexhullDownsampling * 32); inputPSet->GetConvexHull().Clip(plane, rightCHPts, leftCHPts); rightCH.ComputeConvexHull((double*)rightCHPts.Data(), rightCHPts.Size()); leftCH.ComputeConvexHull((double*)leftCHPts.Data(), leftCHPts.Size()); @@ -970,8 +973,8 @@ void VHACD::ComputeBestClippingPlane(const PrimitiveSet* inputPSet, const double PrimitiveSet* const right = psets[threadID]; PrimitiveSet* const left = psets[threadID + m_ompNumProcessors]; onSurfacePSet->Clip(plane, right, left); - right->ComputeConvexHull(rightCH, convexhullDownsampling); - left->ComputeConvexHull(leftCH, convexhullDownsampling); + right->ComputeConvexHull(rightCH, (size_t)convexhullDownsampling); + left->ComputeConvexHull(leftCH, (size_t)convexhullDownsampling); } double volumeLeftCH = leftCH.ComputeVolume(); double volumeRightCH = rightCH.ComputeVolume(); @@ -1013,7 +1016,7 @@ void VHACD::ComputeBestClippingPlane(const PrimitiveSet* inputPSet, const double double symmetry = beta * d; double total = concavity + balance + symmetry; -#if USE_THREAD == 1 && _OPENMP +#if USE_THREAD == 1 && defined(_OPENMP) #pragma omp critical #endif { @@ -1115,9 +1118,9 @@ void VHACD::ComputeACD(const Parameters& params) Update(m_stageProgress, 0.0, params); for (size_t p = 0; p < nInputParts && !m_cancel; ++p) { - const double progress0 = p * 100.0 / nInputParts; - const double progress1 = (p + 0.75) * 100.0 / nInputParts; - const double progress2 = (p + 1.00) * 100.0 / nInputParts; + const double progress0 = (double)p * 100.0 / (double)nInputParts; + const double progress1 = ((double)p + 0.75) * 100.0 / (double)nInputParts; + const double progress2 = ((double)p + 1.00) * 100.0 / (double)nInputParts; Update(m_stageProgress, progress0, params); @@ -1166,12 +1169,12 @@ void VHACD::ComputeACD(const Parameters& params) if (params.m_mode == 0) { VoxelSet* vset = (VoxelSet*)pset; - ComputeAxesAlignedClippingPlanes(*vset, params.m_planeDownsampling, planes); + ComputeAxesAlignedClippingPlanes(*vset, (short)params.m_planeDownsampling, planes); } else { TetrahedronSet* tset = (TetrahedronSet*)pset; - ComputeAxesAlignedClippingPlanes(*tset, params.m_planeDownsampling, planes); + ComputeAxesAlignedClippingPlanes(*tset, (short)params.m_planeDownsampling, planes); } if (params.m_logger) @@ -1203,12 +1206,12 @@ void VHACD::ComputeACD(const Parameters& params) if (params.m_mode == 0) { VoxelSet* vset = (VoxelSet*)pset; - RefineAxesAlignedClippingPlanes(*vset, bestPlane, params.m_planeDownsampling, planesRef); + RefineAxesAlignedClippingPlanes(*vset, bestPlane, (short)params.m_planeDownsampling, planesRef); } else { TetrahedronSet* tset = (TetrahedronSet*)pset; - RefineAxesAlignedClippingPlanes(*tset, bestPlane, params.m_planeDownsampling, planesRef); + RefineAxesAlignedClippingPlanes(*tset, bestPlane, (short)params.m_planeDownsampling, planesRef); } if (params.m_logger) @@ -1315,7 +1318,7 @@ void VHACD::ComputeACD(const Parameters& params) m_convexHulls.Resize(0); for (size_t p = 0; p < nConvexHulls && !m_cancel; ++p) { - Update(m_stageProgress, p * 100.0 / nConvexHulls, params); + Update(m_stageProgress, (double)p * 100.0 / (double)nConvexHulls, params); m_convexHulls.PushBack(new Mesh); parts[p]->ComputeConvexHull(*m_convexHulls[p]); size_t nv = m_convexHulls[p]->GetNPoints(); @@ -1342,8 +1345,8 @@ void VHACD::ComputeACD(const Parameters& params) if (GetCancel()) { - const size_t nConvexHulls = m_convexHulls.Size(); - for (size_t p = 0; p < nConvexHulls; ++p) + const size_t numConvexHulls = m_convexHulls.Size(); + for (size_t p = 0; p < numConvexHulls; ++p) { delete m_convexHulls[p]; } @@ -1361,15 +1364,15 @@ void VHACD::ComputeACD(const Parameters& params) params.m_logger->Log(msg.str().c_str()); } } -void AddPoints(const Mesh* const mesh, SArray >& pts) +static void AddPoints(const Mesh* const mesh, SArray >& pts) { const int n = (int)mesh->GetNPoints(); for (int i = 0; i < n; ++i) { - pts.PushBack(mesh->GetPoint(i)); + pts.PushBack(mesh->GetPoint((size_t)i)); } } -void ComputeConvexHull(const Mesh* const ch1, const Mesh* const ch2, SArray >& pts, Mesh* const combinedCH) +static void ComputeConvexHull(const Mesh* const ch1, const Mesh* const ch2, SArray >& pts, Mesh* const combinedCH) { pts.Resize(0); AddPoints(ch1, pts); @@ -1431,15 +1434,15 @@ void VHACD::MergeConvexHulls(const Parameters& params) costMatrix.Resize(((nConvexHulls * nConvexHulls) - nConvexHulls) >> 1); for (size_t p1 = 1; p1 < nConvexHulls; ++p1) { - const float volume1 = m_convexHulls[p1]->ComputeVolume(); + const double volume1 = m_convexHulls[p1]->ComputeVolume(); for (size_t p2 = 0; p2 < p1; ++p2) { ComputeConvexHull(m_convexHulls[p1], m_convexHulls[p2], pts, &combinedCH); - costMatrix[idx++] = ComputeConcavity(volume1 + m_convexHulls[p2]->ComputeVolume(), combinedCH.ComputeVolume(), m_volumeCH0); + costMatrix[idx++] = (float)ComputeConcavity(volume1 + m_convexHulls[p2]->ComputeVolume(), combinedCH.ComputeVolume(), m_volumeCH0); } } - // Until we cant merge below the maximum cost + // Until we can't merge below the maximum cost size_t costSize = m_convexHulls.Size(); while (!m_cancel) { @@ -1449,19 +1452,17 @@ void VHACD::MergeConvexHulls(const Parameters& params) // Search for lowest cost float bestCost = (std::numeric_limits::max)(); - const size_t addr = FindMinimumElement(costMatrix.Data(), &bestCost, 0, costMatrix.Size()); + const size_t addr = (size_t)FindMinimumElement(costMatrix.Data(), &bestCost, 0, (int)costMatrix.Size()); // Check if we should merge these hulls if (bestCost >= threshold) { break; } - double nr = 1 + (8 * addr); - const size_t addrI = (static_cast(sqrt(nr)) - 1) >> 1; + double nr = (double)(1 + (8 * addr)); + const size_t addrI = (size_t)((static_cast(sqrt(nr)) - 1) >> 1); const size_t p1 = addrI + 1; const size_t p2 = addr - ((addrI * (addrI + 1)) >> 1); - assert(p1 >= 0); - assert(p2 >= 0); assert(p1 < costSize); assert(p2 < costSize); @@ -1487,20 +1488,19 @@ void VHACD::MergeConvexHulls(const Parameters& params) // Calculate costs versus the new hull size_t rowIdx = ((p2 - 1) * p2) >> 1; - const float volume1 = m_convexHulls[p2]->ComputeVolume(); + const double volume1 = m_convexHulls[p2]->ComputeVolume(); for (size_t i = 0; (i < p2) && (!m_cancel); ++i) { ComputeConvexHull(m_convexHulls[p2], m_convexHulls[i], pts, &combinedCH); - costMatrix[rowIdx++] = ComputeConcavity(volume1 + m_convexHulls[i]->ComputeVolume(), combinedCH.ComputeVolume(), m_volumeCH0); + costMatrix[rowIdx++] = (float)ComputeConcavity(volume1 + m_convexHulls[i]->ComputeVolume(), combinedCH.ComputeVolume(), m_volumeCH0); } rowIdx += p2; for (size_t i = p2 + 1; (i < costSize) && (!m_cancel); ++i) { ComputeConvexHull(m_convexHulls[p2], m_convexHulls[i], pts, &combinedCH); - costMatrix[rowIdx] = ComputeConcavity(volume1 + m_convexHulls[i]->ComputeVolume(), combinedCH.ComputeVolume(), m_volumeCH0); + costMatrix[rowIdx] = (float)ComputeConcavity(volume1 + m_convexHulls[i]->ComputeVolume(), combinedCH.ComputeVolume(), m_volumeCH0); rowIdx += i; - assert(rowIdx >= 0); } // Move the top column in to replace its space @@ -1525,7 +1525,6 @@ void VHACD::MergeConvexHulls(const Parameters& params) { costMatrix[rowIdx] = costMatrix[top_row++]; rowIdx += i; - assert(rowIdx >= 0); } } costMatrix.Resize(erase_idx); @@ -1541,7 +1540,7 @@ void VHACD::MergeConvexHulls(const Parameters& params) params.m_logger->Log(msg.str().c_str()); } } -void SimplifyConvexHull(Mesh* const ch, const size_t nvertices, const double minVolume) +static void SimplifyConvexHull(Mesh* const ch, const size_t nvertices, const double minVolume) { if (nvertices <= 4) { diff --git a/Extras/VHACD/src/vhacdICHull.cpp b/Extras/VHACD/src/vhacdICHull.cpp index eed3b784c7..728be8d1fa 100644 --- a/Extras/VHACD/src/vhacdICHull.cpp +++ b/Extras/VHACD/src/vhacdICHull.cpp @@ -113,15 +113,15 @@ ICHullError ICHull::Process() if (!GetMesh().CheckConsistancy()) { size_t nV = m_mesh.GetNVertices(); - CircularList& vertices = m_mesh.GetVertices(); + CircularList& verts = m_mesh.GetVertices(); for (size_t v = 0; v < nV; ++v) { - if (vertices.GetData().m_name == sc_dummyIndex) + if (verts.GetData().m_name == sc_dummyIndex) { - vertices.Delete(); + verts.Delete(); break; } - vertices.Next(); + verts.Next(); } return ICHullErrorInconsistent; } @@ -166,17 +166,17 @@ ICHullError ICHull::Process() m_mesh.m_edges.Next(); } size_t nV = m_mesh.GetNVertices(); - CircularList& vertices = m_mesh.GetVertices(); + CircularList& verts = m_mesh.GetVertices(); for (size_t v = 0; v < nV; ++v) { - if (vertices.GetData().m_name == sc_dummyIndex) + if (verts.GetData().m_name == sc_dummyIndex) { - vertices.Delete(); + verts.Delete(); } else { - vertices.GetData().m_tag = false; - vertices.Next(); + verts.GetData().m_tag = false; + verts.Next(); } } CleanEdges(); @@ -257,15 +257,15 @@ ICHullError ICHull::Process(const unsigned int nPointsCH, if (!GetMesh().CheckConsistancy()) { size_t nV = m_mesh.GetNVertices(); - CircularList& vertices = m_mesh.GetVertices(); + CircularList& verts = m_mesh.GetVertices(); for (size_t v = 0; v < nV; ++v) { - if (vertices.GetData().m_name == sc_dummyIndex) + if (verts.GetData().m_name == sc_dummyIndex) { - vertices.Delete(); + verts.Delete(); break; } - vertices.Next(); + verts.Next(); } return ICHullErrorInconsistent; } @@ -316,17 +316,17 @@ ICHullError ICHull::Process(const unsigned int nPointsCH, m_mesh.m_edges.Next(); } size_t nV = m_mesh.GetNVertices(); - CircularList& vertices = m_mesh.GetVertices(); + CircularList& verts = m_mesh.GetVertices(); for (size_t v = 0; v < nV; ++v) { - if (vertices.GetData().m_name == sc_dummyIndex) + if (verts.GetData().m_name == sc_dummyIndex) { - vertices.Delete(); + verts.Delete(); } else { - vertices.GetData().m_tag = false; - vertices.Next(); + verts.GetData().m_tag = false; + verts.Next(); } } CleanEdges(); @@ -464,7 +464,7 @@ CircularListElement* ICHull::MakeFace(CircularListElementGetData().m_edges[2]; e1 = fold->GetData().m_edges[1]; @@ -495,7 +495,8 @@ CircularListElement* ICHull::MakeConeFace(CircularListElement* newEdges[2]; for (int i = 0; i < 2; ++i) { - if (!(newEdges[i] = e->GetData().m_vertices[i]->GetData().m_duplicate)) + newEdges[i] = e->GetData().m_vertices[i]->GetData().m_duplicate; + if (!newEdges[i]) { // if the edge doesn't exits add it and mark the vertex as duplicated newEdges[i] = m_mesh.AddEdge(); newEdges[i]->GetData().m_vertices[0] = e->GetData().m_vertices[i]; @@ -686,7 +687,7 @@ bool ICHull::CleanEdges() e->GetData().m_newFace = 0; } } - // delete edges maked for deletion + // delete edges marked for deletion CircularList& edges = m_mesh.GetEdges(); const size_t ne_delete = m_edgesToDelete.Size(); for (size_t i = 0; i < ne_delete; ++i) diff --git a/Extras/VHACD/src/vhacdManifoldMesh.cpp b/Extras/VHACD/src/vhacdManifoldMesh.cpp index 8ff8aeb6c7..fe26fe48bc 100644 --- a/Extras/VHACD/src/vhacdManifoldMesh.cpp +++ b/Extras/VHACD/src/vhacdManifoldMesh.cpp @@ -232,4 +232,4 @@ bool TMMesh::CheckConsistancy() } return true; } -} // namespace VHACD \ No newline at end of file +} // namespace VHACD diff --git a/Extras/VHACD/src/vhacdMesh.cpp b/Extras/VHACD/src/vhacdMesh.cpp index 113b5c4fdd..c663ee98ea 100644 --- a/Extras/VHACD/src/vhacdMesh.cpp +++ b/Extras/VHACD/src/vhacdMesh.cpp @@ -12,7 +12,9 @@ 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 _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS +#endif #include "LinearMath/btConvexHullComputer.h" #include "vhacdMesh.h" @@ -50,12 +52,12 @@ double Mesh::ComputeVolume() const Vec3 ver0, ver1, ver2; double totalVolume = 0.0; - for (int t = 0; t < nT; t++) + for (unsigned int t = 0; t < nT; t++) { const Vec3& tri = GetTriangle(t); - ver0 = GetPoint(tri[0]); - ver1 = GetPoint(tri[1]); - ver2 = GetPoint(tri[2]); + ver0 = GetPoint((size_t)tri[0]); + ver1 = GetPoint((size_t)tri[1]); + ver2 = GetPoint((size_t)tri[2]); totalVolume += ComputeVolume4(ver0, ver1, ver2, bary); } return totalVolume / 6.0; @@ -128,12 +130,12 @@ bool Mesh::IsInside(const Vec3& pt) const } Vec3 ver0, ver1, ver2; double volume; - for (int t = 0; t < nT; t++) + for (unsigned int t = 0; t < nT; t++) { const Vec3& tri = GetTriangle(t); - ver0 = GetPoint(tri[0]); - ver1 = GetPoint(tri[1]); - ver2 = GetPoint(tri[2]); + ver0 = GetPoint((size_t)tri[0]); + ver1 = GetPoint((size_t)tri[1]); + ver2 = GetPoint((size_t)tri[2]); volume = ComputeVolume4(ver0, ver1, ver2, pt); if (volume < 0.0) { @@ -291,7 +293,9 @@ bool Mesh::LoadOFF(const std::string& fileName, bool invert) { const std::string strOFF("OFF"); char temp[1024]; - fscanf(fid, "%s", temp); + temp[1023] = '\0'; + int len = fscanf(fid, "%s", temp); + (void)len; if (std::string(temp) != strOFF) { fclose(fid); @@ -302,47 +306,49 @@ bool Mesh::LoadOFF(const std::string& fileName, bool invert) int nv = 0; int nf = 0; int ne = 0; - fscanf(fid, "%i", &nv); - fscanf(fid, "%i", &nf); - fscanf(fid, "%i", &ne); - m_points.Resize(nv); - m_triangles.Resize(nf); + len = fscanf(fid, "%i", &nv); (void)len; + len = fscanf(fid, "%i", &nf); (void)len; + len = fscanf(fid, "%i", &ne); (void)len; + m_points.Resize((size_t)nv); + m_triangles.Resize((size_t)nf); Vec3 coord; float x, y, z; for (int p = 0; p < nv; p++) { - fscanf(fid, "%f", &x); - fscanf(fid, "%f", &y); - fscanf(fid, "%f", &z); - m_points[p][0] = x; - m_points[p][1] = y; - m_points[p][2] = z; + len = fscanf(fid, "%f", &x); (void)len; + len = fscanf(fid, "%f", &y); (void)len; + len = fscanf(fid, "%f", &z); (void)len; + m_points[(size_t)p][0] = x; + m_points[(size_t)p][1] = y; + m_points[(size_t)p][2] = z; } int i, j, k, s; for (int t = 0; t < nf; ++t) { - fscanf(fid, "%i", &s); + len = fscanf(fid, "%i", &s); (void)len; if (s == 3) { - fscanf(fid, "%i", &i); - fscanf(fid, "%i", &j); - fscanf(fid, "%i", &k); - m_triangles[t][0] = i; + len = fscanf(fid, "%i", &i); (void)len; + len = fscanf(fid, "%i", &j); (void)len; + len = fscanf(fid, "%i", &k); (void)len; + m_triangles[(size_t)t][0] = i; if (invert) { - m_triangles[t][1] = k; - m_triangles[t][2] = j; + m_triangles[(size_t)t][1] = k; + m_triangles[(size_t)t][2] = j; } else { - m_triangles[t][1] = j; - m_triangles[t][2] = k; + m_triangles[(size_t)t][1] = j; + m_triangles[(size_t)t][2] = k; } } else // Fix me: support only triangular meshes { for (int h = 0; h < s; ++h) - fscanf(fid, "%i", &s); + { + len = fscanf(fid, "%i", &s); (void)len; + } } } fclose(fid); diff --git a/Extras/VHACD/src/vhacdVolume.cpp b/Extras/VHACD/src/vhacdVolume.cpp index f420667b96..5e99c1fb25 100644 --- a/Extras/VHACD/src/vhacdVolume.cpp +++ b/Extras/VHACD/src/vhacdVolume.cpp @@ -12,7 +12,9 @@ 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 _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS +#endif #include "LinearMath/btConvexHullComputer.h" #include "vhacdVolume.h" #include @@ -25,7 +27,7 @@ namespace VHACD { /********************************************************/ /* AABB-triangle overlap test code */ -/* by Tomas Akenine-Möller */ +/* by Tomas Akenine-Möller */ /* Function: int triBoxOverlap(float boxcenter[3], */ /* float boxhalfsize[3],float triverts[3][3]); */ /* History: */ @@ -49,7 +51,7 @@ namespace VHACD if (x2 < min) \ min = x2; \ if (x2 > max) \ - max = x2; + max = x2 #define AXISTEST_X01(a, b, fa, fb) \ p0 = a * v0[Y] - b * v0[Z]; \ @@ -66,7 +68,7 @@ namespace VHACD } \ rad = fa * boxhalfsize[Y] + fb * boxhalfsize[Z]; \ if (min > rad || max < -rad) \ - return 0; + return 0 #define AXISTEST_X2(a, b, fa, fb) \ p0 = a * v0[Y] - b * v0[Z]; \ @@ -83,7 +85,7 @@ namespace VHACD } \ rad = fa * boxhalfsize[Y] + fb * boxhalfsize[Z]; \ if (min > rad || max < -rad) \ - return 0; + return 0 #define AXISTEST_Y02(a, b, fa, fb) \ p0 = -a * v0[X] + b * v0[Z]; \ @@ -100,7 +102,7 @@ namespace VHACD } \ rad = fa * boxhalfsize[X] + fb * boxhalfsize[Z]; \ if (min > rad || max < -rad) \ - return 0; + return 0 #define AXISTEST_Y1(a, b, fa, fb) \ p0 = -a * v0[X] + b * v0[Z]; \ @@ -117,7 +119,7 @@ namespace VHACD } \ rad = fa * boxhalfsize[X] + fb * boxhalfsize[Z]; \ if (min > rad || max < -rad) \ - return 0; + return 0 #define AXISTEST_Z12(a, b, fa, fb) \ p1 = a * v1[X] - b * v1[Y]; \ @@ -134,7 +136,7 @@ namespace VHACD } \ rad = fa * boxhalfsize[X] + fb * boxhalfsize[Y]; \ if (min > rad || max < -rad) \ - return 0; + return 0 #define AXISTEST_Z0(a, b, fa, fb) \ p0 = a * v0[X] - b * v0[Y]; \ @@ -151,13 +153,13 @@ namespace VHACD } \ rad = fa * boxhalfsize[X] + fb * boxhalfsize[Y]; \ if (min > rad || max < -rad) \ - return 0; + return 0 -int PlaneBoxOverlap(const Vec3& normal, +static int PlaneBoxOverlap(const Vec3& normal, const Vec3& vert, const Vec3& maxbox) { - int q; + size_t q; Vec3 vmin, vmax; double v; for (q = X; q <= Z; q++) @@ -270,12 +272,12 @@ int TriBoxOverlap(const Vec3& boxcenter, // Slightly modified version of Stan Melax's code for 3x3 matrix diagonalization (Thanks Stan!) // source: http://www.melax.com/diag.html?attredirects=0 -void Diagonalize(const double (&A)[3][3], double (&Q)[3][3], double (&D)[3][3]) +static void Diagonalize(const double (&A)[3][3], double (&Q)[3][3], double (&D)[3][3]) { // A must be a symmetric matrix. // returns Q and D such that // Diagonal matrix D = QT * A * Q; and A = Q*D*QT - const int maxsteps = 24; // certainly wont need that many. + const int maxsteps = 24; // certainly won't need that many. int k0, k1, k2; double o[3], m[3]; double q[4] = {0.0, 0.0, 0.0, 1.0}; @@ -394,7 +396,7 @@ void VoxelSet::ComputeBB() const size_t nVoxels = m_voxels.Size(); if (nVoxels == 0) return; - for (int h = 0; h < 3; ++h) + for (size_t h = 0; h < 3; ++h) { m_minBBVoxels[h] = m_voxels[0].m_coord[h]; m_maxBBVoxels[h] = m_voxels[0].m_coord[h]; @@ -402,7 +404,7 @@ void VoxelSet::ComputeBB() Vec3 bary(0.0); for (size_t p = 0; p < nVoxels; ++p) { - for (int h = 0; h < 3; ++h) + for (size_t h = 0; h < 3; ++h) { bary[h] += m_voxels[p].m_coord[h]; if (m_minBBVoxels[h] > m_voxels[p].m_coord[h]) @@ -412,7 +414,7 @@ void VoxelSet::ComputeBB() } } bary /= (double)nVoxels; - for (int h = 0; h < 3; ++h) + for (size_t h = 0; h < 3; ++h) { m_minBBPts[h] = m_minBBVoxels[h] * m_scale + m_minBB[h]; m_maxBBPts[h] = m_maxBBVoxels[h] * m_scale + m_minBB[h]; @@ -652,8 +654,8 @@ void VoxelSet::ComputeClippedVolumes(const Plane& plane, nPositiveVoxels += (d >= 0.0); } size_t nNegativeVoxels = nVoxels - nPositiveVoxels; - positiveVolume = m_unitVolume * nPositiveVoxels; - negativeVolume = m_unitVolume * nNegativeVoxels; + positiveVolume = m_unitVolume * (double)nPositiveVoxels; + negativeVolume = m_unitVolume * (double)nNegativeVoxels; } void VoxelSet::SelectOnSurface(PrimitiveSet* const onSurfP) const { @@ -662,7 +664,7 @@ void VoxelSet::SelectOnSurface(PrimitiveSet* const onSurfP) const if (nVoxels == 0) return; - for (int h = 0; h < 3; ++h) + for (size_t h = 0; h < 3; ++h) { onSurf->m_minBB[h] = m_minBB[h]; } @@ -692,7 +694,7 @@ void VoxelSet::Clip(const Plane& plane, if (nVoxels == 0) return; - for (int h = 0; h < 3; ++h) + for (size_t h = 0; h < 3; ++h) { negativePart->m_minBB[h] = positivePart->m_minBB[h] = m_minBB[h]; } @@ -809,12 +811,12 @@ void VoxelSet::ComputePrincipalAxes() covMat[0][2] += x * z; covMat[1][2] += y * z; } - covMat[0][0] /= nVoxels; - covMat[1][1] /= nVoxels; - covMat[2][2] /= nVoxels; - covMat[0][1] /= nVoxels; - covMat[0][2] /= nVoxels; - covMat[1][2] /= nVoxels; + covMat[0][0] /= (double)nVoxels; + covMat[1][1] /= (double)nVoxels; + covMat[2][2] /= (double)nVoxels; + covMat[0][1] /= (double)nVoxels; + covMat[0][2] /= (double)nVoxels; + covMat[1][2] /= (double)nVoxels; covMat[1][0] = covMat[0][1]; covMat[2][0] = covMat[0][2]; covMat[2][1] = covMat[1][2]; @@ -875,7 +877,7 @@ void Volume::FillOutsideSurface(const size_t i0, current[1] = (short)j; current[2] = (short)k; fifo.push(current); - GetVoxel(current[0], current[1], current[2]) = PRIMITIVE_OUTSIDE_SURFACE; + GetVoxel((size_t)current[0], (size_t)current[1], (size_t)current[2]) = PRIMITIVE_OUTSIDE_SURFACE; ++m_numVoxelsOutsideSurface; while (fifo.size() > 0) { @@ -890,7 +892,7 @@ void Volume::FillOutsideSurface(const size_t i0, { continue; } - unsigned char& v = GetVoxel(a, b, c); + unsigned char& v = GetVoxel((size_t)a, (size_t)b, (size_t)c); if (v == PRIMITIVE_UNDEFINED) { v = PRIMITIVE_OUTSIDE_SURFACE; @@ -939,14 +941,14 @@ void Volume::Convert(Mesh& mesh, const VOXEL_VALUE value) const const unsigned char& voxel = GetVoxel(i, j, k); if (voxel == value) { - Vec3 p0((i - 0.5) * m_scale, (j - 0.5) * m_scale, (k - 0.5) * m_scale); - Vec3 p1((i + 0.5) * m_scale, (j - 0.5) * m_scale, (k - 0.5) * m_scale); - Vec3 p2((i + 0.5) * m_scale, (j + 0.5) * m_scale, (k - 0.5) * m_scale); - Vec3 p3((i - 0.5) * m_scale, (j + 0.5) * m_scale, (k - 0.5) * m_scale); - Vec3 p4((i - 0.5) * m_scale, (j - 0.5) * m_scale, (k + 0.5) * m_scale); - Vec3 p5((i + 0.5) * m_scale, (j - 0.5) * m_scale, (k + 0.5) * m_scale); - Vec3 p6((i + 0.5) * m_scale, (j + 0.5) * m_scale, (k + 0.5) * m_scale); - Vec3 p7((i - 0.5) * m_scale, (j + 0.5) * m_scale, (k + 0.5) * m_scale); + Vec3 p0(((double)i - 0.5) * m_scale, ((double)j - 0.5) * m_scale, ((double)k - 0.5) * m_scale); + Vec3 p1(((double)i + 0.5) * m_scale, ((double)j - 0.5) * m_scale, ((double)k - 0.5) * m_scale); + Vec3 p2(((double)i + 0.5) * m_scale, ((double)j + 0.5) * m_scale, ((double)k - 0.5) * m_scale); + Vec3 p3(((double)i - 0.5) * m_scale, ((double)j + 0.5) * m_scale, ((double)k - 0.5) * m_scale); + Vec3 p4(((double)i - 0.5) * m_scale, ((double)j - 0.5) * m_scale, ((double)k + 0.5) * m_scale); + Vec3 p5(((double)i + 0.5) * m_scale, ((double)j - 0.5) * m_scale, ((double)k + 0.5) * m_scale); + Vec3 p6(((double)i + 0.5) * m_scale, ((double)j + 0.5) * m_scale, ((double)k + 0.5) * m_scale); + Vec3 p7(((double)i - 0.5) * m_scale, ((double)j + 0.5) * m_scale, ((double)k + 0.5) * m_scale); int s = (int)mesh.GetNPoints(); mesh.AddPoint(p0 + m_minBB); mesh.AddPoint(p1 + m_minBB); @@ -975,7 +977,7 @@ void Volume::Convert(Mesh& mesh, const VOXEL_VALUE value) const } void Volume::Convert(VoxelSet& vset) const { - for (int h = 0; h < 3; ++h) + for (size_t h = 0; h < 3; ++h) { vset.m_minBB[h] = m_minBB[h]; } @@ -994,7 +996,7 @@ void Volume::Convert(VoxelSet& vset) const { for (short k = 0; k < k0; ++k) { - const unsigned char& value = GetVoxel(i, j, k); + const unsigned char& value = GetVoxel((size_t)i, (size_t)j, (size_t)k); if (value == PRIMITIVE_INSIDE_SURFACE) { voxel.m_coord[0] = i; @@ -1034,7 +1036,7 @@ void Volume::Convert(TetrahedronSet& tset) const { for (short k = 0; k < k0; ++k) { - const unsigned char& value = GetVoxel(i, j, k); + const unsigned char& value = GetVoxel((size_t)i, (size_t)j, (size_t)k); if (value == PRIMITIVE_INSIDE_SURFACE || value == PRIMITIVE_ON_SURFACE) { tetrahedron.m_data = value; @@ -1103,7 +1105,7 @@ void Volume::AlignToPrincipalAxes(double (&rot)[3][3]) const { for (short k = 0; k < k0; ++k) { - const unsigned char& value = GetVoxel(i, j, k); + const unsigned char& value = GetVoxel((size_t)i, (size_t)j, (size_t)k); if (value == PRIMITIVE_INSIDE_SURFACE || value == PRIMITIVE_ON_SURFACE) { barycenter[0] += i; @@ -1126,7 +1128,7 @@ void Volume::AlignToPrincipalAxes(double (&rot)[3][3]) const { for (short k = 0; k < k0; ++k) { - const unsigned char& value = GetVoxel(i, j, k); + const unsigned char& value = GetVoxel((size_t)i, (size_t)j, (size_t)k); if (value == PRIMITIVE_INSIDE_SURFACE || value == PRIMITIVE_ON_SURFACE) { x = i - barycenter[0]; @@ -1168,16 +1170,16 @@ void TetrahedronSet::ComputeBB() if (nTetrahedra == 0) return; - for (int h = 0; h < 3; ++h) + for (size_t h = 0; h < 3; ++h) { m_minBB[h] = m_maxBB[h] = m_tetrahedra[0].m_pts[0][h]; m_barycenter[h] = 0.0; } for (size_t p = 0; p < nTetrahedra; ++p) { - for (int i = 0; i < 4; ++i) + for (size_t i = 0; i < 4; ++i) { - for (int h = 0; h < 3; ++h) + for (size_t h = 0; h < 3; ++h) { if (m_minBB[h] > m_tetrahedra[p].m_pts[i][h]) m_minBB[h] = m_tetrahedra[p].m_pts[i][h]; @@ -1212,10 +1214,10 @@ void TetrahedronSet::ComputeConvexHull(Mesh& meshCH, const size_t sampling) cons if (s == sampling) { s = 0; - for (int a = 0; a < 4; ++a) + for (size_t a = 0; a < 4; ++a) { points[q++] = m_tetrahedra[p].m_pts[a]; - for (int xx = 0; xx < 3; ++xx) + for (size_t xx = 0; xx < 3; ++xx) { assert(m_tetrahedra[p].m_pts[a][xx] + EPS >= m_minBB[xx]); assert(m_tetrahedra[p].m_pts[a][xx] <= m_maxBB[xx] + EPS); @@ -1264,8 +1266,8 @@ inline bool TetrahedronSet::Add(Tetrahedron& tetrahedron) { double v = ComputeVolume4(tetrahedron.m_pts[0], tetrahedron.m_pts[1], tetrahedron.m_pts[2], tetrahedron.m_pts[3]); - const double EPS = 0.0000000001; - if (fabs(v) < EPS) + const double EPSILON = 0.0000000001; + if (fabs(v) < EPSILON) { return false; } @@ -1276,12 +1278,12 @@ inline bool TetrahedronSet::Add(Tetrahedron& tetrahedron) tetrahedron.m_pts[1] = tmp; } - for (int a = 0; a < 4; ++a) + for (size_t a = 0; a < 4; ++a) { - for (int xx = 0; xx < 3; ++xx) + for (size_t xx = 0; xx < 3; ++xx) { - assert(tetrahedron.m_pts[a][xx] + EPS >= m_minBB[xx]); - assert(tetrahedron.m_pts[a][xx] <= m_maxBB[xx] + EPS); + assert(tetrahedron.m_pts[a][xx] + EPSILON >= m_minBB[xx]); + assert(tetrahedron.m_pts[a][xx] <= m_maxBB[xx] + EPSILON); } } m_tetrahedra.PushBack(tetrahedron); @@ -1493,23 +1495,23 @@ void TetrahedronSet::AddClippedTetrahedra(const Vec3 (&pts)[10], const i } } -void TetrahedronSet::Intersect(const Plane& plane, - SArray >* const positivePts, - SArray >* const negativePts, - const size_t sampling) const +void TetrahedronSet::Intersect(const Plane& /*plane*/, + SArray >* const /*positivePts*/, + SArray >* const /*negativePts*/, + const size_t /*sampling*/) const { const size_t nTetrahedra = m_tetrahedra.Size(); if (nTetrahedra == 0) return; } -void TetrahedronSet::ComputeExteriorPoints(const Plane& plane, - const Mesh& mesh, - SArray >* const exteriorPts) const +void TetrahedronSet::ComputeExteriorPoints(const Plane& /*plane*/, + const Mesh& /*mesh*/, + SArray >* const /*exteriorPts*/) const { } -void TetrahedronSet::ComputeClippedVolumes(const Plane& plane, - double& positiveVolume, - double& negativeVolume) const +void TetrahedronSet::ComputeClippedVolumes(const Plane& /*plane*/, + double& /*positiveVolume*/, + double& /*negativeVolume*/) const { const size_t nTetrahedra = m_tetrahedra.Size(); if (nTetrahedra == 0) @@ -1637,6 +1639,7 @@ void TetrahedronSet::Clip(const Plane& plane, else { int nnew = 0; + (void)nnew; for (int j = 0; j < 6; ++j) { if (sign[edges[j][0]] * sign[edges[j][1]] == -1) @@ -1647,7 +1650,7 @@ void TetrahedronSet::Clip(const Plane& plane, alpha = -(plane.m_d + (n * P1)) / delta; assert(alpha >= 0.0 && alpha <= 1.0); M = alpha * P0 + (1 - alpha) * P1; - for (int xx = 0; xx < 3; ++xx) + for (size_t xx = 0; xx < 3; ++xx) { assert(M[xx] + EPS >= m_minBB[xx]); assert(M[xx] <= m_maxBB[xx] + EPS); @@ -1684,9 +1687,9 @@ void TetrahedronSet::Convert(Mesh& mesh, const VOXEL_VALUE value) const } } } -const double TetrahedronSet::ComputeVolume() const +double TetrahedronSet::ComputeVolume() const { - const size_t nTetrahedra = m_tetrahedra.Size(); + size_t nTetrahedra = m_tetrahedra.Size(); if (nTetrahedra == 0) return 0.0; double volume = 0.0; @@ -1697,7 +1700,7 @@ const double TetrahedronSet::ComputeVolume() const } return volume / 6.0; } -const double TetrahedronSet::ComputeMaxVolumeError() const +double TetrahedronSet::ComputeMaxVolumeError() const { const size_t nTetrahedra = m_tetrahedra.Size(); if (nTetrahedra == 0) @@ -1759,7 +1762,7 @@ void TetrahedronSet::ComputePrincipalAxes() covMat[1][2] += y * z; } } - double n = nTetrahedra * 4.0; + double n = (double)nTetrahedra * 4.0; covMat[0][0] /= n; covMat[1][1] /= n; covMat[2][2] /= n; diff --git a/Extras/VHACD/test/src/main_vhacd.cpp b/Extras/VHACD/test/src/main_vhacd.cpp index b41c6df019..23d2b4faa8 100644 --- a/Extras/VHACD/test/src/main_vhacd.cpp +++ b/Extras/VHACD/test/src/main_vhacd.cpp @@ -13,7 +13,9 @@ 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 _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS +#endif #include #include #include @@ -37,7 +39,7 @@ using namespace VHACD; using namespace std; -bool replace(std::string& str, const std::string& from, const std::string& to) +static bool replace(std::string& str, const std::string& from, const std::string& to) { size_t start_pos = str.find(from); if (start_pos == std::string::npos) @@ -50,21 +52,21 @@ class MyCallback : public IVHACD::IUserCallback { public: MyCallback(void) {} - ~MyCallback(){}; + ~MyCallback(){} void Update(const double overallProgress, const double stageProgress, const double operationProgress, const char* const stage, const char* const operation) { cout << setfill(' ') << setw(3) << (int)(overallProgress + 0.5) << "% " << "[ " << stage << " " << setfill(' ') << setw(3) << (int)(stageProgress + 0.5) << "% ] " << operation << " " << setfill(' ') << setw(3) << (int)(operationProgress + 0.5) << "%" << endl; - }; + } }; class MyLogger : public IVHACD::IUserLogger { public: MyLogger(void) {} MyLogger(const string& fileName) { OpenFile(fileName); } - ~MyLogger(){}; + ~MyLogger(){} void Log(const char* const msg) { if (m_file.is_open()) @@ -103,7 +105,7 @@ struct Material m_emissiveColor[2] = 0.0f; m_shininess = 0.4f; m_transparency = 0.5f; - }; + } }; struct Parameters { @@ -138,7 +140,7 @@ void ComputeRandomColor(Material& mat); void Usage(const Parameters& params); void ParseParameters(int argc, char* argv[], Parameters& params); -int main_vhacd2(Parameters& params) +static int main_vhacd2(Parameters& params) { MyCallback myCallback; MyLogger myLogger(params.m_fileNameLog); @@ -236,7 +238,7 @@ int main_vhacd2(Parameters& params) { interfaceVHACD->GetConvexHull(p, ch); - SaveOBJ(foutCH, ch.m_points, ch.m_triangles, ch.m_nPoints, ch.m_nTriangles, mat, myLogger, p, vertexOffset); + SaveOBJ(foutCH, ch.m_points, ch.m_triangles, ch.m_nPoints, ch.m_nTriangles, mat, myLogger, (int)p, vertexOffset); vertexOffset += ch.m_nPoints; msg.str(""); msg << "\t CH[" << setfill('0') << setw(5) << p << "] " << ch.m_nPoints << " V, " << ch.m_nTriangles << " T" << endl; @@ -270,6 +272,7 @@ int main_vhacd2(Parameters& params) return 0; } +int main_vhacd_ext(const std::string& fileNameIn, const std::string& fileNameOut, const std::string& fileNameLog, VHACD::IVHACD::Parameters& paramsVHACD); // prototype int main_vhacd_ext(const std::string& fileNameIn, const std::string& fileNameOut, const std::string& fileNameLog, VHACD::IVHACD::Parameters& paramsVHACD) { Parameters params; @@ -280,7 +283,7 @@ int main_vhacd_ext(const std::string& fileNameIn, const std::string& fileNameOut return main_vhacd2(params); } -int main_vhacd(int argc, char* argv[]) +static int main_vhacd(int argc, char* argv[]) { // --input camel.off --output camel_acd.obj --log log.txt --resolution 1000000 --depth 20 --concavity 0.0025 --planeDownsampling 4 --convexhullDownsampling 4 --alpha 0.05 --beta 0.05 --gamma 0.00125 --pca 0 --mode 0 --maxNumVerticesPerCH 256 --minVolumePerCH 0.0001 --convexhullApproximation 1 --oclDeviceID 2 // set parameters @@ -359,7 +362,7 @@ void ParseParameters(int argc, char* argv[], Parameters& params) else if (!strcmp(argv[i], "--resolution")) { if (++i < argc) - params.m_paramsVHACD.m_resolution = atoi(argv[i]); + params.m_paramsVHACD.m_resolution = (unsigned int)atoi(argv[i]); } else if (!strcmp(argv[i], "--depth")) { @@ -409,7 +412,7 @@ void ParseParameters(int argc, char* argv[], Parameters& params) else if (!strcmp(argv[i], "--maxNumVerticesPerCH")) { if (++i < argc) - params.m_paramsVHACD.m_maxNumVerticesPerCH = atoi(argv[i]); + params.m_paramsVHACD.m_maxNumVerticesPerCH = (unsigned int)atoi(argv[i]); } else if (!strcmp(argv[i], "--minVolumePerCH")) { @@ -429,12 +432,12 @@ void ParseParameters(int argc, char* argv[], Parameters& params) else if (!strcmp(argv[i], "--oclPlatformID")) { if (++i < argc) - params.m_oclPlatformID = atoi(argv[i]); + params.m_oclPlatformID = (unsigned int)atoi(argv[i]); } else if (!strcmp(argv[i], "--oclDeviceID")) { if (++i < argc) - params.m_oclDeviceID = atoi(argv[i]); + params.m_oclDeviceID = (unsigned int)atoi(argv[i]); } else if (!strcmp(argv[i], "--help")) { @@ -456,7 +459,8 @@ void GetFileExtension(const string& fileName, string& fileExtension) else { fileExtension = fileName.substr(lastDotPosition, fileName.size()); - transform(fileExtension.begin(), fileExtension.end(), fileExtension.begin(), ::toupper); + for(size_t i=0;i& points, vector& triangles, IVHACD::IUserLogger& logger) @@ -476,7 +480,9 @@ bool LoadOFF(const string& fileName, vector& points, vector& triangl { const string strOFF("OFF"); char temp[1024]; - fscanf(fid, "%s", temp); + temp[1023] = '\0'; + int len = fscanf(fid, "%s", temp); + (void)len; if (string(temp) != strOFF) { logger.Log("Loading error: format not recognized \n"); @@ -488,30 +494,32 @@ bool LoadOFF(const string& fileName, vector& points, vector& triangl int nv = 0; int nf = 0; int ne = 0; - fscanf(fid, "%i", &nv); - fscanf(fid, "%i", &nf); - fscanf(fid, "%i", &ne); - points.resize(nv * 3); - triangles.resize(nf * 3); + len = fscanf(fid, "%i", &nv); (void)len; + len = fscanf(fid, "%i", &nf); (void)len; + len = fscanf(fid, "%i", &ne); (void)len; + points.resize((size_t)nv * 3); + triangles.resize((size_t)nf * 3); const int np = nv * 3; for (int p = 0; p < np; p++) { - fscanf(fid, "%f", &(points[p])); + len = fscanf(fid, "%f", &(points[(size_t)p])); (void)len; } int s; for (int t = 0, r = 0; t < nf; ++t) { - fscanf(fid, "%i", &s); + len = fscanf(fid, "%i", &s); (void)len; if (s == 3) { - fscanf(fid, "%i", &(triangles[r++])); - fscanf(fid, "%i", &(triangles[r++])); - fscanf(fid, "%i", &(triangles[r++])); + len = fscanf(fid, "%i", &(triangles[(size_t)r++])); (void)len; + len = fscanf(fid, "%i", &(triangles[(size_t)r++])); (void)len; + len = fscanf(fid, "%i", &(triangles[(size_t)r++])); (void)len; } else // Fix me: support only triangular meshes { for (int h = 0; h < s; ++h) - fscanf(fid, "%i", &s); + { + len = fscanf(fid, "%i", &s); (void)len; + } } } fclose(fid); @@ -640,7 +648,7 @@ bool SaveOFF(const string& fileName, const float* const& points, const int* cons } bool SaveOBJ(ofstream& fout, const double* const& points, const int* const& triangles, const unsigned int& nPoints, - const unsigned int& nTriangles, const Material& material, IVHACD::IUserLogger& logger, int convexPart, int vertexOffset) + const unsigned int& nTriangles, const Material& /*material*/, IVHACD::IUserLogger& logger, int convexPart, int vertexOffset) { if (fout.is_open()) { diff --git a/Extras/obj2sdf/obj2sdf.cpp b/Extras/obj2sdf/obj2sdf.cpp index 60881d50e3..338ba329a2 100644 --- a/Extras/obj2sdf/obj2sdf.cpp +++ b/Extras/obj2sdf/obj2sdf.cpp @@ -44,11 +44,12 @@ struct ShapeContainer b3AlignedObjectArray m_shapeIndices; }; -b3HashMap gMaterialNames; +static b3HashMap gMaterialNames; #define MAX_PATH_LEN 1024 +#define APPEND_SIZE 20 -std::string StripExtension(const std::string& sPath) +static std::string StripExtension(const std::string& sPath) { for (std::string::const_reverse_iterator i = sPath.rbegin(); i != sPath.rend(); i++) { @@ -86,10 +87,11 @@ int main(int argc, char* argv[]) } bool mergeMaterials = args.CheckCmdLineFlag("mergeMaterials"); - char fileNameWithPath[MAX_PATH_LEN]; + char fileNameWithPath[MAX_PATH_LEN-APPEND_SIZE]; bool fileFound = (b3ResourcePath::findResourcePath(fileName, fileNameWithPath, MAX_PATH_LEN,0)) > 0; - char materialPrefixPath[MAX_PATH_LEN]; - b3FileUtils::extractPath(fileNameWithPath, materialPrefixPath, MAX_PATH_LEN); + (void)fileFound; + char materialPrefixPath[MAX_PATH_LEN-APPEND_SIZE]; + b3FileUtils::extractPath(fileNameWithPath, materialPrefixPath, MAX_PATH_LEN-APPEND_SIZE); std::vector shapes; bt_tinyobj::attrib_t attribute; @@ -108,7 +110,7 @@ int main(int argc, char* argv[]) fprintf(sdfFile, "\n\t\n\t0 0 -9.8\n"); - for (int s = 0; s < (int)shapes.size(); s++) + for (size_t s = 0; s < shapes.size(); s++) { bt_tinyobj::shape_t& shape = shapes[s]; bt_tinyobj::material_t mat = shape.material; @@ -126,42 +128,42 @@ int main(int argc, char* argv[]) ShapeContainer* shapeC = gMaterialNames.find(key); if (shapeC) { - shapeC->m_shapeIndices.push_back(s); + shapeC->m_shapeIndices.push_back((int)s); - int curPositions = shapeC->positions.size() / 3; - int curNormals = shapeC->normals.size() / 3; - int curTexcoords = shapeC->texcoords.size() / 2; + size_t curPositions = shapeC->positions.size() / 3; + size_t curNormals = shapeC->normals.size() / 3; + size_t curTexcoords = shapeC->texcoords.size() / 2; - int faceCount = shape.mesh.indices.size(); - int vertexCount = attribute.vertices.size(); - for (int v = 0; v < vertexCount; v++) + size_t faceCount = shape.mesh.indices.size(); + size_t vertexCount = attribute.vertices.size(); + for (size_t v = 0; v < vertexCount; v++) { shapeC->positions.push_back(attribute.vertices[v]); } - int numNormals = int(attribute.normals.size()); - for (int vn = 0; vn < numNormals; vn++) + size_t numNormals = attribute.normals.size(); + for (size_t vn = 0; vn < numNormals; vn++) { shapeC->normals.push_back(attribute.normals[vn]); } - int numTexCoords = int(attribute.texcoords.size()); - for (int vt = 0; vt < numTexCoords; vt++) + size_t numTexCoords = attribute.texcoords.size(); + for (size_t vt = 0; vt < numTexCoords; vt++) { shapeC->texcoords.push_back(attribute.texcoords[vt]); } - for (int face = 0; face < faceCount; face += 3) + for (size_t face = 0; face < faceCount; face += 3) { - if (face < 0 && face >= int(shape.mesh.indices.size())) + if (face >= shape.mesh.indices.size()) { continue; } index_t index; - for (int ii = 0; ii < 3; ii++) + for (size_t ii = 0; ii < 3; ii++) { - index.vertex_index = shape.mesh.indices[face + ii].vertex_index + curPositions; - index.normal_index = shape.mesh.indices[face + ii].normal_index + curNormals; - index.texcoord_index = shape.mesh.indices[face + ii].texcoord_index + curTexcoords; + index.vertex_index = shape.mesh.indices[face + ii].vertex_index + (int)curPositions; + index.normal_index = shape.mesh.indices[face + ii].normal_index + (int)curNormals; + index.texcoord_index = shape.mesh.indices[face + ii].texcoord_index + (int)curTexcoords; shapeC->indices.push_back(index); } } @@ -210,8 +212,8 @@ int main(int argc, char* argv[]) fprintf(f, "mtllib bedroom.mtl\n"); } - int faceCount = shapeCon->indices.size(); - int vertexCount = shapeCon->positions.size(); + size_t faceCount = shapeCon->indices.size(); + size_t vertexCount = shapeCon->positions.size(); bt_tinyobj::material_t mat = shapeCon->material; if (shapeCon->m_matName.length()) { @@ -219,9 +221,9 @@ int main(int argc, char* argv[]) printf("mat.name = %s\n", objName); fprintf(f, "#object %s\n\n", objName); } - for (int v = 0; v < vertexCount / 3; v++) + for (size_t v = 0; v < vertexCount / 3; v++) { - fprintf(f, "v %f %f %f\n", shapeCon->positions[v * 3 + 0], shapeCon->positions[v * 3 + 1], shapeCon->positions[v * 3 + 2]); + fprintf(f, "v %f %f %f\n", (double)shapeCon->positions[v * 3 + 0], (double)shapeCon->positions[v * 3 + 1], (double)shapeCon->positions[v * 3 + 2]); } if (mat.name.length()) @@ -234,25 +236,25 @@ int main(int argc, char* argv[]) } fprintf(f, "\n"); - int numNormals = int(shapeCon->normals.size()); + size_t numNormals = shapeCon->normals.size(); - for (int vn = 0; vn < numNormals / 3; vn++) + for (size_t vn = 0; vn < numNormals / 3; vn++) { - fprintf(f, "vn %f %f %f\n", shapeCon->normals[vn * 3 + 0], shapeCon->normals[vn * 3 + 1], shapeCon->normals[vn * 3 + 2]); + fprintf(f, "vn %f %f %f\n", (double)shapeCon->normals[vn * 3 + 0], (double)shapeCon->normals[vn * 3 + 1], (double)shapeCon->normals[vn * 3 + 2]); } fprintf(f, "\n"); - int numTexCoords = int(shapeCon->texcoords.size()); - for (int vt = 0; vt < numTexCoords / 2; vt++) + size_t numTexCoords = shapeCon->texcoords.size(); + for (size_t vt = 0; vt < numTexCoords / 2; vt++) { - fprintf(f, "vt %f %f\n", shapeCon->texcoords[vt * 2 + 0], shapeCon->texcoords[vt * 2 + 1]); + fprintf(f, "vt %f %f\n", (double)shapeCon->texcoords[vt * 2 + 0], (double)shapeCon->texcoords[vt * 2 + 1]); } fprintf(f, "s off\n"); - for (int face = 0; face < faceCount; face += 3) + for (size_t face = 0; face < faceCount; face += 3) { - if (face < 0 && face >= int(shapeCon->indices.size())) + if (face >= shapeCon->indices.size()) { continue; } @@ -310,14 +312,14 @@ int main(int argc, char* argv[]) "\t\t\t\n", objSdfPartFileName, m, m, objSdfPartFileName, objSdfPartFileName, - kdRed, kdGreen, kdBlue, transparency); + (double)kdRed, (double)kdGreen, (double)kdBlue, (double)transparency); } } else { for (int s = 0; s < (int)shapes.size(); s++) { - bt_tinyobj::shape_t& shape = shapes[s]; + bt_tinyobj::shape_t& shape = shapes[(size_t)s]; if (shape.name.length()) { @@ -349,8 +351,8 @@ int main(int argc, char* argv[]) fprintf(f, "mtllib bedroom.mtl\n"); } - int faceCount = shape.mesh.indices.size(); - int vertexCount = attribute.vertices.size(); + size_t faceCount = shape.mesh.indices.size(); + size_t vertexCount = attribute.vertices.size(); bt_tinyobj::material_t mat = shape.material; if (shape.name.length()) { @@ -358,9 +360,9 @@ int main(int argc, char* argv[]) printf("mat.name = %s\n", objName); fprintf(f, "#object %s\n\n", objName); } - for (int v = 0; v < vertexCount / 3; v++) + for (size_t v = 0; v < vertexCount / 3; v++) { - fprintf(f, "v %f %f %f\n", attribute.vertices[v * 3 + 0], attribute.vertices[v * 3 + 1], attribute.vertices[v * 3 + 2]); + fprintf(f, "v %f %f %f\n", (double)attribute.vertices[v * 3 + 0], (double)attribute.vertices[v * 3 + 1], (double)attribute.vertices[v * 3 + 2]); } if (mat.name.length()) @@ -373,25 +375,25 @@ int main(int argc, char* argv[]) } fprintf(f, "\n"); - int numNormals = int(attribute.normals.size()); + size_t numNormals = attribute.normals.size(); - for (int vn = 0; vn < numNormals / 3; vn++) + for (size_t vn = 0; vn < numNormals / 3; vn++) { - fprintf(f, "vn %f %f %f\n", attribute.normals[vn * 3 + 0], attribute.normals[vn * 3 + 1], attribute.normals[vn * 3 + 2]); + fprintf(f, "vn %f %f %f\n", (double)attribute.normals[vn * 3 + 0], (double)attribute.normals[vn * 3 + 1], (double)attribute.normals[vn * 3 + 2]); } fprintf(f, "\n"); - int numTexCoords = int(attribute.texcoords.size()); - for (int vt = 0; vt < numTexCoords / 2; vt++) + size_t numTexCoords = attribute.texcoords.size(); + for (size_t vt = 0; vt < numTexCoords / 2; vt++) { - fprintf(f, "vt %f %f\n", attribute.texcoords[vt * 2 + 0], attribute.texcoords[vt * 2 + 1]); + fprintf(f, "vt %f %f\n", (double)attribute.texcoords[vt * 2 + 0], (double)attribute.texcoords[vt * 2 + 1]); } fprintf(f, "s off\n"); - for (int face = 0; face < faceCount; face += 3) + for (size_t face = 0; face < faceCount; face += 3) { - if (face < 0 && face >= int(shape.mesh.indices.size())) + if (face >= shape.mesh.indices.size()) { continue; } @@ -450,7 +452,7 @@ int main(int argc, char* argv[]) "\t\t\t\n", objSdfPartFileName, s, s, objSdfPartFileName, objSdfPartFileName, - kdRed, kdGreen, kdBlue, transparency); + (double)kdRed, (double)kdGreen, (double)kdBlue, (double)transparency); } } fprintf(sdfFile, "\t\n\n"); diff --git a/MinGW64.cmake b/MinGW64.cmake new file mode 100644 index 0000000000..3f6447dc03 --- /dev/null +++ b/MinGW64.cmake @@ -0,0 +1,35 @@ +# source: https://gist.github.com/peterspackman/8cf73f7f12ba270aa8192d6911972fe8 + +# Sample toolchain file for building for Windows from an Ubuntu Linux system. +# +# Typical usage: +# *) install cross compiler: `sudo apt-get install mingw-w64` +# *) cd build +# *) cmake -DCMAKE_TOOLCHAIN_FILE=~/mingw-w64-x86_64.cmake .. +# This is free and unencumbered software released into the public domain. + +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + set(EXE_EXTENSION .exe) +else() + set(EXE_EXTENSION) +endif() +set(CMAKE_SYSTEM_NAME Windows) +set(TOOLCHAIN_PREFIX ${TOOLCHAIN_ROOT}x86_64-w64-mingw32) + +# cross compilers to use for C, C++ and Fortran +set(CMAKE_ASM_COMPILER ${TOOLCHAIN_PREFIX}-gcc${EXE_EXTENSION}) +set(CMAKE_C_COMPILER_AR ${TOOLCHAIN_PREFIX}-ar${EXE_EXTENSION}) +set(CMAKE_C_COMPILER_RANLIB ${TOOLCHAIN_PREFIX}-ranlib${EXE_EXTENSION}) +set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc${EXE_EXTENSION}) +set(CMAKE_CXX_COMPILER_AR ${TOOLCHAIN_PREFIX}-ar${EXE_EXTENSION}) +set(CMAKE_CXX_COMPILER_RANLIB ${TOOLCHAIN_PREFIX}-ranlib${EXE_EXTENSION}) +set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++${EXE_EXTENSION}) +set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran${EXE_EXTENSION}) +set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres${EXE_EXTENSION}) +# target environment on the build host system +set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_PREFIX}) + +# modify default behavior of FIND_XXX() commands +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/README.md b/README.md index d8009db5ae..b9fad4f790 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ https://docs.google.com/document/d/1u9vyzPtrVoVhYqQOGNWUgjRbfwfCdIts_NzmvgiJ144/ The entire collision detection and rigid body dynamics can be executed on the GPU. A high-end desktop GPU, such as an AMD Radeon 7970 or NVIDIA GTX 680 or better. -We succesfully tested the software under Windows, Linux and Mac OSX. +We successfully tested the software under Windows, Linux and Mac OSX. The software currently doesn't work on OpenCL CPU devices. It might run on a laptop GPU but performance will not likely be very good. Note that often an OpenCL drivers fails to compile a kernel. Some unit tests exist to diff --git a/build3/cmake/FindNumPy.cmake b/build3/cmake/FindNumPy.cmake index 5ce9e178c5..16008a76ce 100644 --- a/build3/cmake/FindNumPy.cmake +++ b/build3/cmake/FindNumPy.cmake @@ -43,7 +43,7 @@ if(PYTHONINTERP_FOUND) endif() endif() else() - message(STATUS "To find NumPy Python interpretor is required to be found.") + message(STATUS "To find NumPy Python interpreter is required to be found.") endif() include(FindPackageHandleStandardArgs) diff --git a/build3/cmake/FindPythonLibs.cmake b/build3/cmake/FindPythonLibs.cmake index cebac58f42..d736362c33 100644 --- a/build3/cmake/FindPythonLibs.cmake +++ b/build3/cmake/FindPythonLibs.cmake @@ -44,7 +44,7 @@ if(NOT DEFINED PYTHON_INCLUDE_DIR) if(DEFINED PYTHON_INCLUDE_PATH) - # For backward compatibility, repect PYTHON_INCLUDE_PATH. + # For backward compatibility, respect PYTHON_INCLUDE_PATH. set(PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_PATH}" CACHE PATH "Path to where Python.h is found" FORCE) else() @@ -104,7 +104,7 @@ else() list(APPEND _PYTHON_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) endif() if (NOT _PYTHON_VERSIONS) - set(_PYTHON_VERSIONS ";") # empty entry at the front makeing sure we search for "python" first + set(_PYTHON_VERSIONS ";") # empty entry at the front making sure we search for "python" first endif() list(APPEND _PYTHON_VERSIONS ${_PYTHON_FIND_OTHER_VERSIONS}) diff --git a/build3/lcpp.lua b/build3/lcpp.lua index 1c66e36994..2a150dabb4 100644 --- a/build3/lcpp.lua +++ b/build3/lcpp.lua @@ -354,7 +354,7 @@ local function screener(input) --line = trim(line) if #line > 0 then if line:byte(1) == CMD_BYTE then - --line = line:gsub("#%s*(.*)", "#%1") -- remove optinal whitespaces after "#". reduce triming later. + --line = line:gsub("#%s*(.*)", "#%1") -- remove optional whitespaces after "#". reduce trimming later. if #buffer > 0 then coroutine.yield(table.concat(buffer, NEWL)) buffer = {} @@ -596,7 +596,7 @@ local function define(state, key, value, override) state.defines[key] = value end --- parses CPP exressions +-- parses CPP expressions -- i.e.: #if !defined(_UNICODE) && !defined(UNICODE) -- --BNF: @@ -655,7 +655,7 @@ local function parseDefined(state, input) end end - -- wiht and w/o brackets allowed + -- with and w/o brackets allowed if ident and ((bropen and brclose) or (not bropen and not brclose)) then return state:defined(ident) end @@ -747,7 +747,7 @@ local function parseFunction(state, input) pattern = table.concat(buf) end - -- build macro funcion + -- build macro function local func = function(input) return input:gsub(pattern, repl) end @@ -760,14 +760,14 @@ end -- LCPP INTERFACE -- ------------ ---- initialies a lcpp state. not needed manually. handy for testing +--- initializes a lcpp state. not needed manually. handy for testing function lcpp.init(input, predefines) - -- create sate var + -- create state var local state = {} -- init the state object state.defines = {} -- the table of known defines and replacements state.screener = screener(input) state.lineno = 0 -- the current line number - state.stack = {} -- stores wether the current stack level is to be included + state.stack = {} -- stores whether the current stack level is to be included state.once = {} -- stack level was once true (first if that evals to true) -- funcs @@ -802,7 +802,7 @@ function lcpp.init(input, predefines) state.stack[#state.stack] = nil state.once [#state.once] = nil state:define(__LCPP_INDENT__, state:getIndent(), true) - if state:getIndent() < 0 then error("Unopened block detected. Indentaion problem.") end + if state:getIndent() < 0 then error("Unopened block detected. Indentation problem.") end end state.skip = function(state) for i = 1, #state.stack do diff --git a/build3/premake4.lua b/build3/premake4.lua index 73dbd89653..41dc69e2f8 100644 --- a/build3/premake4.lua +++ b/build3/premake4.lua @@ -293,7 +293,7 @@ newoption { trigger = "lua", - description = "Enable Lua scipting support in Example Browser" + description = "Enable Lua scripting support in Example Browser" } newoption diff --git a/codespell.txt b/codespell.txt new file mode 100644 index 0000000000..d5ae38379d --- /dev/null +++ b/codespell.txt @@ -0,0 +1 @@ +codespell -L acount,ans,bload,bReal,Buss,childs,colorIn,directionA,empy,findn,halfs,inout,inport,lastr,lod,lowd,observ,padd,paeth,matA,matC,mi,ND,normalY,numer,preverse,prverse,pEvent,pointIn,reacher,scond,SEH,ser,strIn,te,thet,ue \ No newline at end of file diff --git a/data/kuka_iiwa/kuka_with_gripper.sdf b/data/kuka_iiwa/kuka_with_gripper.sdf index 4d2a07ec69..7bc4b824bc 100644 --- a/data/kuka_iiwa/kuka_with_gripper.sdf +++ b/data/kuka_iiwa/kuka_with_gripper.sdf @@ -1,6 +1,6 @@ + @@ -86,7 +86,7 @@ 1 - + @@ -124,7 +124,7 @@ 1 - + @@ -156,7 +156,7 @@ 1 - + @@ -188,7 +188,7 @@ 1 - + @@ -226,7 +226,7 @@ 1 - + diff --git a/data/racecar/racecar_differential.urdf b/data/racecar/racecar_differential.urdf index c4f6ee42e4..104951d84e 100644 --- a/data/racecar/racecar_differential.urdf +++ b/data/racecar/racecar_differential.urdf @@ -30,7 +30,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -96,7 +96,7 @@ - + @@ -128,7 +128,7 @@ 1 - + @@ -160,7 +160,7 @@ 1 - + @@ -204,7 +204,7 @@ 1 - + diff --git a/data/sponza_closed.obj b/data/sponza_closed.obj index 27df6c6590..c9a136fd24 100644 --- a/data/sponza_closed.obj +++ b/data/sponza_closed.obj @@ -152,7 +152,7 @@ v -33.2568 -13.4405 6.21415 v -31.3613 -13.4405 -6.21414 v -31.3613 -13.4405 -6.94274 v -33.2568 -13.4405 -6.21414 -# 150 verticies +# 150 vertices vt 0.0369231 1 vt 0.0753846 1 vt 0.0753846 0.9 @@ -228,7 +228,7 @@ vt 0.00674519 0.12 vt 0.918103 1 vt 0.913255 0.9 vt 0.913255 0.12 -# 75 texture verticies +# 75 texture vertices vn -1 0 0 vn 0 -0.335682 -0.941975 vn 0 -0.373379 -0.927679 @@ -1326,7 +1326,7 @@ v -31.2924 -13.4405 -7.00686 v -31.2823 -13.4405 -7.04475 v -31.3211 -13.4405 -6.96023 v -31.3613 -13.4405 -6.94274 -# 800 verticies +# 800 vertices vt 0.105211 0.24 vt 0.141003 0.24 vt 0.141003 0.275 @@ -1727,7 +1727,7 @@ vt 0.925795 0.86 vt 0.925589 0.9 vt 0.925333 0.95 vt 0.925236 1 -# 400 texture verticies +# 400 texture vertices vn -0.530751 0.219371 0.818645 vn -0.530418 0.316527 0.786427 vn -0.665071 0.262684 0.699055 @@ -7243,7 +7243,7 @@ v -30.8777 1.37852 -20.5388 v -33.5089 1.57955 -20.4831 v -30.8219 1.57955 -20.4831 v -46.556 2.15394 -20.7352 -# 3496 verticies +# 3496 vertices vt 0.5 0.0388888 vt 0.5 0 vt 0.197019 0 @@ -7354,7 +7354,7 @@ vt 0.877583 0.375555 vt 0.870551 0.32 vt 0.405978 0.444445 vt 0.36272 0.443665 -# 110 texture verticies +# 110 texture vertices vn 0 -0.746426 -0.665468 vn 0 -0.119772 -0.992801 vn 0 -0.2563 -0.966597 @@ -13045,7 +13045,7 @@ v -33.2467 -3.96324 -6.52929 v -33.2769 -3.834 -6.49914 v -33.2567 -3.81965 -9.13268 v -33.2769 -3.834 -9.15278 -# 381 verticies +# 381 vertices vt 0.75 0.10125 vt 0.75 0 vt 0.844196 0 @@ -13142,7 +13142,7 @@ vt 2.25 0.6875 vt -0.25 1 vt -0.25 0.96875 vt 0.25 0.969498 -# 96 texture verticies +# 96 texture vertices vn 0 0 -1 vn 1.70693e-006 -4.05882e-005 1 vn 3.41385e-006 0 1 @@ -14107,7 +14107,7 @@ v -33.2567 -3.81964 -6.51924 v -33.2567 1.06261 -6.51924 v -33.2567 1.06261 -9.13268 v -33.2567 -3.81965 -9.13268 -# 64 verticies +# 64 vertices vt 0.625 0.79 vt 0.432628 0.79 vt 0.432628 0.08 @@ -14123,7 +14123,7 @@ vt 0.875 0.79 vt -0.125 0.08 vt -0.125 0.79 vt -0.125 0.0795898 -# 15 texture verticies +# 15 texture vertices vn -1 0 0 vn 0 -9.76675e-008 -1 vn 0 1.95335e-007 1 @@ -14342,7 +14342,7 @@ v -18.0069 -20.9075 -8.57751 v -18.5621 -20.9075 -9.13268 v -19.9024 -20.9075 -7.79238 v -19.9024 -14.4744 -7.79238 -# 144 verticies +# 144 vertices vt 0.1875 0.77 vt 0.0625 0.77 vt 0.0625 0.07 @@ -14361,7 +14361,7 @@ vt 0.5625 0.07 vt 0.6875 0.07 vt 1.0625 0.07 vt 1.0625 0.77 -# 18 texture verticies +# 18 texture vertices vn 0.707107 0 -0.707107 vn -0.707107 -1.04825e-007 -0.707107 vn 0 -7.41224e-008 -1 @@ -15055,7 +15055,7 @@ v -17.7771 -4.27915 -7.00746 v -20.1321 -4.27915 -7.00746 v -20.1321 -4.27915 -9.36243 v -17.7771 -4.27915 -9.36243 -# 480 verticies +# 480 vertices vt 0.125 0.3125 vt 0.875 0.3125 vt 0.875 0.28125 @@ -15108,7 +15108,7 @@ vt 0.375 0 vt 0.125 0 vt 0.875 0 vt 0.625 0 -# 52 texture verticies +# 52 texture vertices vn 0.133532 0.982007 -0.133532 vn 0.0925842 0.991393 0.092566 vn 0.235704 0.942809 0.235702 @@ -17317,7 +17317,7 @@ v -19.9024 1.06261 -9.13268 v -19.9024 1.06261 -7.23722 v -20.1666 2.15393 -9.3969 v -20.1666 2.15393 -6.973 -# 672 verticies +# 672 vertices vt 0 0 vt 0.25 0 vt 0.25 0.0249994 @@ -17369,7 +17369,7 @@ vt 1 0.825 vt 1 0.875 vt 1 1 vt 1 1.0015 -# 51 texture verticies +# 51 texture vertices vn 3.38154e-008 -0.573522 -0.81919 vn 0 -0.573524 -0.819189 vn 6.76308e-008 -0.57352 -0.819191 @@ -19015,7 +19015,7 @@ v -19.9024 -3.81965 -9.13268 v -18.0069 1.06261 -9.13268 v -18.0069 -3.81965 -9.13268 v -19.9024 1.06261 -9.13268 -# 80 verticies +# 80 vertices vt 0.125 0.79 vt 0.125 0.08 vt 0.375 0.08 @@ -19025,7 +19025,7 @@ vt 0.875 0.79 vt 0.875 0.08 vt 0.625 0.79 vt 0.625 0.08 -# 9 texture verticies +# 9 texture vertices vn 0 -9.76673e-008 -1 vn 1 4.88337e-008 1.25784e-007 vn 1 2.457e-014 2.51568e-007 @@ -19951,7 +19951,7 @@ v -0.603104 -2.61344 -8.18495 v -0.574385 -3.81965 -8.18495 v -0.574384 -0.890298 -8.18495 v -0.545665 1.0626 -8.18495 -# 816 verticies +# 816 vertices vt 0.5625 0.521739 vt 0.5625 0.826087 vt 0.5 0.826087 @@ -20020,7 +20020,7 @@ vt 0 0.26087 vt 0 0.0695652 vt 0 0.521739 vt 0 0.826087 -# 68 texture verticies +# 68 texture vertices vn -0.923779 0.0156891 0.382604 vn -0.89646 0.0146606 0.442881 vn -0.997704 0.0146594 0.066118 @@ -22993,7 +22993,7 @@ v -5.22701 -11.2755 -9.13268 v -5.46489 -11.9762 -9.13268 v -5.60927 -12.7021 -9.13268 v -5.65767 -13.4406 -9.13268 -# 1000 verticies +# 1000 vertices vt 0.541667 0.05 vt 0.5 0.05 vt 0.5 0.7 @@ -23094,7 +23094,7 @@ vt 0.875 0 vt 0.916667 0 vt 0.958333 0 vt 1 0 -# 100 texture verticies +# 100 texture vertices vn -0.108844 -0.994059 -3.69064e-009 vn -1.11999e-008 -1 -4.45042e-016 vn -1.11999e-008 -1 -5.00673e-016 @@ -25851,7 +25851,7 @@ v -31.0971 23.7507 -6.973 v -31.1315 23.7723 -7.00747 v -31.1315 23.7723 -7.00747 v -31.3613 23.7794 -7.23722 -# 768 verticies +# 768 vertices vt 1 0.17875 vt 0.095626 0.17875 vt 0.0955403 0.1375 @@ -25948,7 +25948,7 @@ vt 0.98123 0.9375 vt 0.97867 0.96875 vt 0.961607 1.195 vt 0.97867 1 -# 96 texture verticies +# 96 texture vertices vn 1.48811e-008 -0.256434 -0.966562 vn -2.53462e-007 -0.256523 -0.966538 vn -1.30023e-007 -0.351114 -0.936333 @@ -27666,7 +27666,7 @@ v -47.0041 -20.9075 20.9951 v 47.0041 -20.9075 -20.936 v -2.45449e-006 -20.9075 -20.936 v -47.0041 -20.9075 -20.936 -# 76 verticies +# 76 vertices vt 0.80625 2.76878 vt 0.8175 2.76266 vt 0.812969 2.76781 @@ -27725,7 +27725,7 @@ vt 5.56562 0.5 vt 5.56562 2.76266 vt -4.56562 -1.75625 vt 5.56562 -1.75625 -# 58 texture verticies +# 58 texture vertices vn 0 1 0 vn 7.15732e-008 1 -1.58631e-007 vn 6.19938e-008 1 -2.31878e-007 @@ -28782,7 +28782,7 @@ v -33.2568 -12.7021 -6.45037 v -33.2568 -12.8544 -6.10672 v -33.2568 -13.4405 -6.50603 v -33.2568 -13.4405 -6.21414 -# 932 verticies +# 932 vertices vt 3.68 9.5 vt 3.68 9.48315 vt 3.68 9.43287 @@ -28959,7 +28959,7 @@ vt -1.62636 2.3041 vt -1.74602 2.35714 vt -1.66377 2.1 vt -1.7654 2.1 -# 176 texture verticies +# 176 texture vertices vn 0 0 1 vn -1.15267e-007 4.15032e-007 1 vn 3.27829e-007 1.28609e-006 1 @@ -30215,7 +30215,7 @@ v -30.4136 -14.4744 -8.57751 v -30.4136 -20.9075 -8.57751 v -30.9687 -20.9075 -9.13268 v -32.7016 -14.4744 -9.13268 -# 124 verticies +# 124 vertices vt 2.22045e-016 0 vt 0.162885 1 vt 0.0871147 1 @@ -30243,7 +30243,7 @@ vt 0.587115 0 vt 0.662885 0 vt 0.740908 0 vt -0.160908 1.00281 -# 27 texture verticies +# 27 texture vertices vn 0 1 0 vn 0 1 -3.84002e-005 vn 1.40818e-005 1 -3.3282e-005 @@ -30849,7 +30849,7 @@ v -30.6433 1.06261 -7.23722 v -30.6433 1.06261 -9.13268 v -30.6433 1.06261 -9.13268 v -33.2567 1.06261 -9.13268 -# 449 verticies +# 449 vertices vt 0.12 1 vt 1.25 1 vt 0.365 1 @@ -30928,7 +30928,7 @@ vt 0.615 -0.02 vt 0.865 -0.02 vt 1.25 -0.02 vt 0.865 -0.0199208 -# 78 texture verticies +# 78 texture vertices vn -9.83615e-008 1 -7.58843e-008 vn 0 1 0 vn -7.58835e-008 1 -7.58836e-008 @@ -32138,7 +32138,7 @@ v 31.3613 14.4457 -5.112 v 31.3613 10.5686 3.81964 v 31.3613 10.5686 -1.69565e-007 v 31.3613 10.5686 -3.67605 -# 18 verticies +# 18 vertices vt 0.682584 0.96 vt 0.5 0.96 vt 0.640449 0.886667 @@ -32157,7 +32157,7 @@ vt 0 0.45 vt 0.879551 0 vt 0.5 0 vt 0.100449 0 -# 18 texture verticies +# 18 texture vertices vn -1 0 0 # 1 normals usemtl sp_02_reljef @@ -32497,7 +32497,7 @@ v -31.3613 2.15394 6.51049 v -33.2567 2.15394 6.51049 v -33.2567 2.15393 0.554411 v -31.3613 2.15393 0.554411 -# 318 verticies +# 318 vertices vt 0.88 0.56 vt 0.908168 1 vt 0.88 1 @@ -32580,7 +32580,7 @@ vt 1.0137 0.56 vt 1 0.8944 vt 0.96 0.91308 vt 1.01296 0.900401 -# 82 texture verticies +# 82 texture vertices vn -1 0 0 vn -1 1.12415e-015 0 vn -1 1.87359e-015 0 @@ -34320,7 +34320,7 @@ v -31.7562 12.6149 0.495402 v -31.7562 12.6149 -0.495407 v -33.2567 12.6077 0.488222 v -33.2567 12.6077 -0.488228 -# 1086 verticies +# 1086 vertices vt 0.382292 3.07255 vt 0.391625 3.0485 vt 0.387542 3.067 @@ -35385,7 +35385,7 @@ vt -1.15604 0.6725 vt -1.15604 0.3275 vt -1.24313 0.67 vt -1.24313 0.33 -# 1064 texture verticies +# 1064 texture vertices vn 0 1 0 vn 0.782993 0 -0.622031 vn 0.707887 0 -0.706326 @@ -37418,7 +37418,7 @@ v -50 23.7794 -22.4009 v -50 -23.7794 -22.4009 v -50 -23.7794 -22.4009 v -50 23.7794 -22.4009 -# 56 verticies +# 56 vertices vt 0.5 1.49375 vt 0.5 2.9375 vt -3.14375 1.49375 @@ -37453,7 +37453,7 @@ vt 5.94062 6.98333 vt 5.94062 0.0833334 vt -1.9375 0.0833334 vt -1.9375 6.98333 -# 34 texture verticies +# 34 texture vertices vn -2.84794e-008 1 -1.43753e-007 vn -3.33132e-008 1 -1.07815e-007 vn -3.55488e-008 1 -8.12938e-008 @@ -38888,7 +38888,7 @@ v -30.6433 2.15393 -7.23722 v -31.3613 2.15393 -7.23722 v -30.9305 2.15393 -9.17629 v -28.2309 5.81932 -9.17629 -# 1333 verticies +# 1333 vertices vt 0.910528 1 vt 0.916667 0.7 vt 0.916667 0.988534 @@ -38972,7 +38972,7 @@ vt 1 5.96046e-008 vt 0.596675 5.96046e-008 vt 0.565217 0.699967 vt 0.146568 0.992935 -# 83 texture verticies +# 83 texture vertices vn 8.38879e-007 -2.84731e-007 -1 vn 0 0 -1 vn 6.17131e-007 -2.97456e-007 -1 @@ -41848,7 +41848,7 @@ v -33.2568 -4.27915 -9.13268 v -31.3613 -4.27915 -7.23722 v -31.3613 23.7794 -7.23722 v -33.2567 23.7794 -9.13268 -# 274 verticies +# 274 vertices vt -3.6925 9.067 vt -3.6645 8.995 vt -3.67675 9.05667 @@ -42107,7 +42107,7 @@ vt -5.29 -10.1 vt 0.5 -10.1 vt 6.29 -10.1 vt 5.96 -7.9 -# 258 texture verticies +# 258 texture vertices vn 0 1 0 vn 7.19475e-008 1 -1.31006e-006 vn -7.09354e-006 1 1.97729e-005 @@ -48804,7 +48804,7 @@ v -31.7059 21.4056 -0.449656 v -33.2567 21.4056 -0.449656 v -33.2567 21.3558 -0.375118 v -31.7059 21.3558 -0.375118 -# 6388 verticies +# 6388 vertices vt -0.0950223 3.95755 vt -0.0929699 3.94782 vt -0.0890194 3.96647 @@ -54893,7 +54893,7 @@ vt 2.15313 0.343432 vt 2.24312 0.343431 vt 2.24312 0.369386 vt 2.15313 0.369386 -# 6088 texture verticies +# 6088 texture vertices vn 0 0 -1 vn 2.30636e-006 -2.27221e-007 -1 vn 7.87711e-008 -2.40365e-006 -1 @@ -75160,7 +75160,7 @@ v -33.2568 -11.2755 6.01079 v -33.2568 -11.9762 6.28435 v -33.2568 -12.7021 6.45038 v -33.2568 -13.4405 6.50604 -# 6616 verticies +# 6616 vertices vt 1.87909 9.09291 vt 2.10288 8.923 vt 2.15188 8.923 @@ -75691,7 +75691,7 @@ vt -1.78469 2.1 vt -1.7654 2.1 vt 0.204306 4.05315 vt -0.0863287 4.00287 -# 530 texture verticies +# 530 texture vertices vn -0.0123611 -0.837717 -0.545964 vn -0.00738112 -0.828716 -0.559621 vn -0.0425936 -0.747256 -0.66317 @@ -94029,7 +94029,7 @@ v -31.1315 2.58243 7.68954 v -31.3613 2.58243 7.69672 v -31.3613 2.15394 7.68586 v -31.1315 2.15394 7.67869 -# 1436 verticies +# 1436 vertices vt 0.809599 0.15 vt 0.836618 0.28 vt 0.809599 0.28 @@ -94399,7 +94399,7 @@ vt 0.820013 0.52 vt 0.825944 0.4 vt 0.800224 0.775 vt 0.800223 1 -# 369 texture verticies +# 369 texture vertices vn -0.984606 -0.0845813 -0.152962 vn -0.98169 -0.190484 -3.36585e-007 vn -0.935407 -0.17879 -0.305038 @@ -98708,7 +98708,7 @@ v -32.7235 -14.2734 -9.18552 v -32.7235 -14.216 -9.18552 v -32.7006 -14.1585 -9.13038 v -32.7006 -14.1585 -9.13038 -# 645 verticies +# 645 vertices vt 0.0871514 0.305555 vt 0.162849 0.305555 vt 0.125 0.444445 @@ -98871,7 +98871,7 @@ vt 0.74359 0.194444 vt 0.74359 0.25 vt 0.740787 0.305555 vt 0.740787 0.305061 -# 162 texture verticies +# 162 texture vertices vn 0.179118 -0.967386 -0.179111 vn 0.179121 -0.967386 0.179111 vn -0.179118 -0.967386 -0.179112 @@ -101480,7 +101480,7 @@ v -19.9552 -14.2734 -8.5994 v -19.9552 -14.216 -8.5994 v -19.9001 -14.1585 -8.57656 v -19.9001 -14.1585 -7.79334 -# 920 verticies +# 920 vertices vt 0.0625 0.305555 vt 0.1875 0.305555 vt 0.125 0.444445 @@ -101596,7 +101596,7 @@ vt -0.0625 0.194444 vt -0.0625 0.25 vt -0.0625 0.305555 vt 1.0625 0.305555 -# 115 texture verticies +# 115 texture vertices vn 0.179121 -0.967384 -0.179121 vn 0.0962144 -0.847872 -0.521398 vn 0.0472089 -0.815436 -0.576918 @@ -106357,7 +106357,7 @@ v -0.910488 2.01033 -9.09544 v 0.910485 2.01033 -9.09544 v 0.942977 2.01033 -9.12793 v -0.94298 2.01033 -9.12793 -# 2269 verticies +# 2269 vertices vt 0.005 0.8 vt 0.3175 0.8 vt 0.38 0.8 @@ -106495,7 +106495,7 @@ vt 1.005 0.825 vt 1.005 0.875 vt 0.755 0.875 vt 0.505 0.875 -# 137 texture verticies +# 137 texture vertices vn 3.05762e-008 1 -1.53735e-007 vn -2.16292e-008 1 -1.75364e-007 vn -1.08703e-007 1 -2.62436e-007 @@ -115472,7 +115472,7 @@ v 0.63679 -4.10684 -7.92118 v 0.689257 -4.10684 -8.18495 v -0.872776 -4.14274 -9.05772 v 0.872772 -4.14274 -9.05772 -# 2772 verticies +# 2772 vertices vt 0.9375 0.0217391 vt 0.875 0.0217391 vt 1 0.0217391 @@ -115673,7 +115673,7 @@ vt -0.125 0.0195652 vt 0.875 0.0195652 vt 0.625 0.0195652 vt 0.375 0.0195652 -# 200 texture verticies +# 200 texture vertices vn 0.663955 -0.71316 0.224872 vn 0 -1 0 vn 0.310144 -0.948683 0.0617299 @@ -129555,7 +129555,7 @@ v -31.4618 2.15393 -7.15838 v -31.7634 2.15393 -6.95003 v -31.8208 2.15393 -7.23722 v -31.8136 2.15393 -7.00747 -# 5398 verticies +# 5398 vertices vt 0.888701 0.698612 vt 0.875 0.667161 vt 0.875 0.698612 @@ -129897,7 +129897,7 @@ vt 1 0.698612 vt 1 0.370461 vt 1 0 vt 1 0.147649 -# 341 texture verticies +# 341 texture vertices vn -0.000153679 -0.0661097 -0.997812 vn 0.0183423 -0.061968 -0.99791 vn 0.186001 -0.0770573 -0.979523 @@ -147756,7 +147756,7 @@ v -18.9546 -12.2266 -6.95003 v -18.9546 -12.0062 -6.95003 v -18.9546 -11.8593 -6.973 v -18.9546 -11.7859 -7.00746 -# 3856 verticies +# 3856 vertices vt 0.958333 0.542818 vt 0.97577 0.559828 vt 0.958333 0.559828 @@ -148161,7 +148161,7 @@ vt 0.0496636 0.49 vt 0.0532671 0.46 vt 0.0604261 0.4 vt 0.0710459 0.305975 -# 404 texture verticies +# 404 texture vertices vn -0.889814 -0.117244 -0.441004 vn -0.68959 -0.0451984 -0.722788 vn -0.762043 -0.117348 -0.636804 @@ -160921,7 +160921,7 @@ v -45.9172 -11.2754 20.7352 v -46.1907 -11.9762 20.7352 v -46.3568 -12.7021 20.7352 v -46.4124 -13.4405 20.7352 -# 3023 verticies +# 3023 vertices vt -0.928125 5.3625 vt -2.19688 5.3625 vt -1.61875 6.5875 @@ -162674,7 +162674,7 @@ vt 1.75307 1.92482 vt 1.71324 1.91244 vt 1.6741 1.89661 vt 1.65313 1.88332 -# 1752 texture verticies +# 1752 texture vertices vn -8.17903e-008 6.14826e-008 1 vn 0 1.12949e-007 1 vn 0 8.53652e-008 1 @@ -168032,7 +168032,7 @@ v 10.6835 -16.2263 21.4388 v 14.5893 -16.2263 21.4388 v 10.6835 -12.8087 21.4388 v 14.5893 -12.8087 21.4388 -# 169 verticies +# 169 vertices vt 0.150538 0.813263 vt 0 0.93359 vt 0 0.813282 @@ -168089,7 +168089,7 @@ vt 0.865591 0.120308 vt 0.134409 0.120308 vt 0.134409 0.692974 vt 0.865591 0.692974 -# 56 texture verticies +# 56 texture vertices vn 0.00349924 0.0148109 -0.999884 vn 0.00440949 0.0128837 -0.999907 vn -0.010516 -0.0107252 -0.999887 @@ -169182,7 +169182,7 @@ v 1.72314 -20.7926 -20.942 v 1.79063 -20.8601 -20.8817 v 1.74899 -20.8056 -20.9032 v -1.749 -20.8056 -20.9032 -# 629 verticies +# 629 vertices vt 0.181452 0.03 vt 0.181452 0.0437457 vt 0.104839 0.03 @@ -169713,7 +169713,7 @@ vt 0.827419 0.0111763 vt 0.835215 0.00461024 vt 0.827419 0.00866163 vt 0.172581 0.00866163 -# 530 texture verticies +# 530 texture vertices vn -0.0894975 0.0842257 -0.992419 vn -0.0993984 -3.63238e-009 -0.995048 vn -0.13858 -8.39882e-009 -0.990351 @@ -171628,7 +171628,7 @@ v 0.00315179 -0.00222454 -19.6584 v 0.0031519 0.0519715 -20.2779 v 0.00315179 -0.00222454 -19.6584 v 0.0031519 0.0519715 -20.2779 -# 147 verticies +# 147 vertices vt 0 0.75 vt 0.0833333 0.777778 vt 0 0.777778 @@ -171759,7 +171759,7 @@ vt 0.75 1 vt 0.833333 1 vt 0.916667 1 vt 1 1 -# 130 texture verticies +# 130 texture vertices vn 0.257899 0.084206 0.962495 vn 0.500187 0.146536 0.853429 vn 0.258716 0.195395 0.945985 @@ -172161,7 +172161,7 @@ v -0.150231 0.162185 -20.1968 v -0.150231 0.162185 -20.7763 v -0.150231 0.162185 -20.1968 v -0.150231 0.162185 -20.7763 -# 43 verticies +# 43 vertices vt 0.5 0 vt 0.805556 0 vt 0.75 0 @@ -172202,7 +172202,7 @@ vt 0.583333 1 vt 0.638889 1 vt 0.694444 1 vt 0.5 1 -# 40 texture verticies +# 40 texture vertices vn 1.64214e-013 8.25503e-007 1 vn 0 0 1 vn 1.88604e-006 2.24769e-006 1 @@ -172376,7 +172376,7 @@ v -0.14624 -7.58281 -16.666 v -0.14624 -3.8227 -16.666 v -0.14624 -7.58281 -16.666 v -0.14624 -3.8227 -16.666 -# 43 verticies +# 43 vertices vt 0.5 0 vt 0.805556 0 vt 0.75 0 @@ -172417,7 +172417,7 @@ vt 0.583333 1 vt 0.638889 1 vt 0.694444 1 vt 0.5 1 -# 40 texture verticies +# 40 texture vertices vn 2.63004e-007 -1 9.57256e-008 vn 0 -1 0 vn 8.22064e-007 -1 -1.44952e-007 @@ -172710,7 +172710,7 @@ v -32.2752 -1.25419 -5.78013 v -32.2752 -0.644176 -6.0328 v -32.2752 -0.644176 -6.0328 v -32.2752 0.0104496 -6.11899 -# 171 verticies +# 171 vertices vt 0.5138 0.5 vt 0.386879 0.990358 vt 0.513801 1.00766 @@ -172786,7 +172786,7 @@ vt 0.665271 0.556758 vt 0.665271 0.443242 vt 0.705521 0.556758 vt 0.705521 0.443242 -# 75 texture verticies +# 75 texture vertices vn -1 -7.63925e-007 -5.8618e-007 vn -1 3.90355e-007 -1.45682e-006 vn -1 -6.32383e-013 -1.50821e-006 @@ -172998,7 +172998,7 @@ v -32.3937 4.87829 -1.09416 v -32.3937 1.86487 -2.45521 v -32.3937 4.87829 -1.09416 v -32.3937 1.86487 -2.45521 -# 17 verticies +# 17 vertices vt 0.5 0 vt 0.55 0 vt 0.75 0 @@ -173013,7 +173013,7 @@ vt 0.15 1 vt -0.05 1 vt 0.95 1 vt 0.5 1 -# 14 texture verticies +# 14 texture vertices vn -1.07089e-006 0.911351 0.411629 vn -1.26046e-006 0.911353 0.411625 vn 0 0.911351 0.411629 @@ -173073,7 +173073,7 @@ v -31.3368 23.7785 -1.99672e-006 v 31.3368 23.7785 -7.1243 v -6.29988e-006 23.7785 -7.1243 v -31.3368 23.7785 -7.1243 -# 9 verticies +# 9 vertices vt 0.5 0.5 vt -4.94062 0.5 vt -4.94062 2.9375 @@ -173083,7 +173083,7 @@ vt 5.94062 0.5 vt -4.94062 -1.9375 vt 0.5 -1.9375 vt 5.94062 -1.9375 -# 9 texture verticies +# 9 texture vertices vn 3.80413e-008 -1 1.00397e-007 vn -5.88432e-015 -1 1.33862e-007 vn 3.0433e-008 -1 1.33862e-007 @@ -173147,7 +173147,7 @@ v -0.150231 -3.90127 -16.5781 v -0.150231 -3.32179 -16.5781 v -0.150231 -3.90127 -16.5781 v -0.150231 -3.32179 -16.5781 -# 43 verticies +# 43 vertices vt 0.5 0 vt 0.805556 0 vt 0.75 0 @@ -173188,7 +173188,7 @@ vt 0.583333 1 vt 0.638889 1 vt 0.694444 1 vt 0.5 1 -# 40 texture verticies +# 40 texture vertices vn 8.02659e-008 -1 1.60662e-013 vn 3.61197e-007 -1 2.58843e-007 vn 2.50885e-007 -1 -2.30926e-014 @@ -173360,7 +173360,7 @@ v -3.83801 0.162185 -20.1968 v -3.83801 0.162185 -20.7763 v -3.83801 0.162185 -20.1968 v -3.83801 0.162185 -20.7763 -# 43 verticies +# 43 vertices vt 0.5 0 vt 0.805556 0 vt 0.75 0 @@ -173401,7 +173401,7 @@ vt 0.583333 1 vt 0.638889 1 vt 0.694444 1 vt 0.5 1 -# 40 texture verticies +# 40 texture vertices vn 1.38951e-013 8.25503e-007 1 vn 0 0 1 vn 1.88603e-006 2.24769e-006 1 @@ -173575,7 +173575,7 @@ v -3.83801 -3.90127 -16.5781 v -3.83801 -3.32179 -16.5781 v -3.83801 -3.90127 -16.5781 v -3.83801 -3.32179 -16.5781 -# 43 verticies +# 43 vertices vt 0.5 0 vt 0.805556 0 vt 0.75 0 @@ -173616,7 +173616,7 @@ vt 0.583333 1 vt 0.638889 1 vt 0.694444 1 vt 0.5 1 -# 40 texture verticies +# 40 texture vertices vn 1.60532e-007 -1 -1.42109e-014 vn 0 -1 0 vn 4.04762e-007 -1 1.83385e-007 @@ -173796,7 +173796,7 @@ v -3.83402 -7.58281 -16.666 v -3.83402 -3.8227 -16.666 v -3.83402 -7.58281 -16.666 v -3.83402 -3.8227 -16.666 -# 43 verticies +# 43 vertices vt 0.5 0 vt 0.805556 0 vt 0.75 0 @@ -173837,7 +173837,7 @@ vt 0.583333 1 vt 0.638889 1 vt 0.694444 1 vt 0.5 1 -# 40 texture verticies +# 40 texture vertices vn 0 -1 0 vn -0.998277 -1.26596e-007 0.0586744 vn -0.958142 -1.21506e-007 0.286295 @@ -174110,7 +174110,7 @@ v -3.68462 -0.00222486 -19.6584 v -3.68462 0.0519711 -20.2779 v -3.68462 -0.00222486 -19.6584 v -3.68462 0.0519711 -20.2779 -# 147 verticies +# 147 vertices vt 0 0.75 vt 0.0833333 0.777778 vt 0 0.777778 @@ -174241,7 +174241,7 @@ vt 0.75 1 vt 0.833333 1 vt 0.916667 1 vt 1 1 -# 130 texture verticies +# 130 texture vertices vn 0.257899 0.0842061 0.962495 vn 0.500187 0.146536 0.853429 vn 0.258716 0.195395 0.945985 @@ -174616,7 +174616,7 @@ v -32.3937 4.91972 -6.00544 v -32.3937 2.0622 -4.40746 v -32.3937 4.91972 -6.00544 v -32.3937 2.0622 -4.40746 -# 17 verticies +# 17 vertices vt 0.5 0 vt 0.55 0 vt 0.75 0 @@ -174631,7 +174631,7 @@ vt 0.15 1 vt -0.05 1 vt 0.95 1 vt 0.5 1 -# 14 texture verticies +# 14 texture vertices vn 7.31432e-007 0.872798 -0.488081 vn 2.72403e-006 0.872798 -0.488082 vn 0 0.872799 -0.488079 diff --git a/data/xacro_standalone.py b/data/xacro_standalone.py index 384c91bf6f..36c3c16b38 100755 --- a/data/xacro_standalone.py +++ b/data/xacro_standalone.py @@ -48,7 +48,7 @@ except NameError: _basestr = str -# Dictionary of subtitution args +# Dictionary of substitution args substitution_args_context = {} @@ -632,7 +632,7 @@ def eval_self_contained(doc): def print_usage(exit_code=0): print("Usage: %s [-o ] " % 'xacro.py') print(" %s --deps Prints dependencies" % 'xacro.py') - print(" %s --includes Only evalutes includes" % 'xacro.py') + print(" %s --includes Only evaluates includes" % 'xacro.py') sys.exit(exit_code) diff --git a/docs/latex/BulletQuickstart.tex b/docs/latex/BulletQuickstart.tex index f731e64045..be84251284 100644 --- a/docs/latex/BulletQuickstart.tex +++ b/docs/latex/BulletQuickstart.tex @@ -39,7 +39,7 @@ %support for C++ source code snippets %you can even import existing C++ code as-is -%or a range of lines within markers beween rangeprefix/rangesuffix +%or a range of lines within markers between rangeprefix/rangesuffix \usepackage{listings} %\usepackage{color} \renewcommand{\lstlistingname}{Source Code} diff --git a/examples/BasicDemo/BasicExample.cpp b/examples/BasicDemo/BasicExample.cpp index 67f670d07c..aa89a60b0d 100644 --- a/examples/BasicDemo/BasicExample.cpp +++ b/examples/BasicDemo/BasicExample.cpp @@ -68,15 +68,15 @@ void BasicExample::initPhysics() groundTransform.setOrigin(btVector3(0, -50, 0)); { - btScalar mass(0.); + float mass(0.); createRigidBody(mass, groundTransform, groundShape, btVector4(0, 0, 1, 1)); } { //create a few dynamic rigidbodies - // Re-using the same collision is better for memory usage and performance + // Reusing the same collision is better for memory usage and performance - btBoxShape* colShape = createBoxShape(btVector3(.1, .1, .1)); + btBoxShape* colShape = createBoxShape(btVector3(btScalar(.1), btScalar(.1), btScalar(.1))); //btCollisionShape* colShape = new btSphereShape(btScalar(1.)); m_collisionShapes.push_back(colShape); @@ -105,7 +105,7 @@ void BasicExample::initPhysics() btScalar(2 + .2 * k), btScalar(0.2 * j))); - createRigidBody(mass, startTransform, colShape); + createRigidBody((float)mass, startTransform, colShape); } } } diff --git a/examples/BasicDemo/CMakeLists.txt b/examples/BasicDemo/CMakeLists.txt index 7a08fd2d7c..a11b3b65ef 100644 --- a/examples/BasicDemo/CMakeLists.txt +++ b/examples/BasicDemo/CMakeLists.txt @@ -40,7 +40,6 @@ ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES) INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/src - ${BULLET_PHYSICS_SOURCE_DIR}/btgui ${BULLET_PHYSICS_SOURCE_DIR}/examples ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/glad ) @@ -65,29 +64,20 @@ LINK_LIBRARIES( #some code to support OpenGL and Glew cross platform IF (WIN32) - INCLUDE_DIRECTORIES( - ${BULLET_PHYSICS_SOURCE_DIR}/btgui/OpenGLWindow/GlewWindows - ) ADD_DEFINITIONS(-DGLEW_STATIC) LINK_LIBRARIES( ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ) -ELSE(WIN32) - IF(APPLE) - find_library(COCOA NAMES Cocoa) - MESSAGE(${COCOA}) - link_libraries(${COCOA} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}) - - ELSE(APPLE) - INCLUDE_DIRECTORIES( - ${BULLET_PHYSICS_SOURCE_DIR}/btgui/OpenGLWindow/GlewWindows - ) - ADD_DEFINITIONS("-DGLEW_INIT_OPENGL11_FUNCTIONS=1") - ADD_DEFINITIONS("-DGLEW_STATIC") - ADD_DEFINITIONS("-DGLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1") - - FIND_PACKAGE(Threads) - LINK_LIBRARIES( ${CMAKE_THREAD_LIBS_INIT} ${DL} ) - ENDIF(APPLE) -ENDIF(WIN32) +ELSEIF(APPLE) + find_library(COCOA NAMES Cocoa REQUIRED) + MESSAGE(${COCOA}) + link_libraries(${COCOA} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}) +ELSE() + ADD_DEFINITIONS("-DGLEW_INIT_OPENGL11_FUNCTIONS=1") + ADD_DEFINITIONS("-DGLEW_STATIC") + ADD_DEFINITIONS("-DGLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1") + + FIND_PACKAGE(Threads) + LINK_LIBRARIES( ${CMAKE_THREAD_LIBS_INIT} ${DL} ) +ENDIF() ADD_EXECUTABLE(AppBasicExampleGui diff --git a/examples/BasicDemo/main.cpp b/examples/BasicDemo/main.cpp index 08ac541fe9..18c8cd6205 100644 --- a/examples/BasicDemo/main.cpp +++ b/examples/BasicDemo/main.cpp @@ -24,7 +24,7 @@ subject to the following restrictions: #include "LinearMath/btTransform.h" #include "LinearMath/btHashMap.h" -int main(int argc, char* argv[]) +int main(int /*argc*/, char* /*argv*/[]) { DummyGUIHelper noGfx; diff --git a/examples/Benchmarks/BenchmarkDemo.cpp b/examples/Benchmarks/BenchmarkDemo.cpp index d9dcdc5a3c..6efff31fbd 100644 --- a/examples/Benchmarks/BenchmarkDemo.cpp +++ b/examples/Benchmarks/BenchmarkDemo.cpp @@ -22,7 +22,14 @@ subject to the following restrictions: #include "btBulletDynamicsCommon.h" #include //printf debugging #include "TaruData.h" +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable: 4305) // 'initializing': truncation from 'double' to 'float' +#endif #include "HaltonData.h" +#if defined(_MSC_VER) +#pragma warning(pop) +#endif #include "landscapeData.h" #include "BulletCollision/BroadphaseCollision/btDbvtBroadphase.h" @@ -60,7 +67,7 @@ class BenchmarkDemo : public CommonRigidBodyMTBase //?? } - void setCameraDistance(btScalar dist) + void setCameraDistance(btScalar /*dist*/) { } void createTest1(); @@ -104,7 +111,7 @@ class BenchmarkDemo : public CommonRigidBodyMTBase float dist = 120; float pitch = -35; float yaw = 52; - float targetPos[3] = {0, 10.46, 0}; + float targetPos[3] = {0, 10.46f, 0}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } }; @@ -146,7 +153,7 @@ class btRaycastBar2 sum_ms = 0; } - btRaycastBar2(btScalar ray_length, btScalar z, btScalar max_y, struct GUIHelperInterface* guiHelper) + btRaycastBar2(btScalar ray_length, btScalar z, btScalar max_y_, struct GUIHelperInterface* guiHelper) { m_guiHelper = guiHelper; frame_counter = 0; @@ -158,19 +165,19 @@ class btRaycastBar2 dx = 10.0; min_x = 0; max_x = 0; - this->max_y = max_y; + this->max_y = max_y_; sign = 1.0; btScalar dalpha = 2 * SIMD_2_PI / NUMRAYS; for (int i = 0; i < NUMRAYS; i++) { - btScalar alpha = dalpha * i; + btScalar alpha = dalpha * (btScalar)i; // rotate around by alpha degrees y btQuaternion q(btVector3(0.0, 1.0, 0.0), alpha); direction[i] = btVector3(1.0, 0.0, 0.0); direction[i] = quatRotate(q, direction[i]); direction[i] = direction[i] * ray_length; - source[i] = btVector3(min_x, max_y, z); + source[i] = btVector3(min_x, max_y_, z); dest[i] = source[i] + direction[i]; dest[i][1] = -1000; normal[i] = btVector3(1.0, 0.0, 0.0); @@ -200,7 +207,7 @@ class btRaycastBar2 { BT_PROFILE("cw->rayTest"); - cw->rayTest(source[i], dest[i], cb); + if(cw) cw->rayTest(source[i], dest[i], cb); } if (cb.hasHit()) { @@ -269,7 +276,7 @@ class btRaycastBar2 castRays(cw, 0, NUMRAYS); } #ifdef USE_BT_CLOCK - ms += frame_timer.getTimeMilliseconds(); + ms += (int)frame_timer.getTimeMilliseconds(); #endif //USE_BT_CLOCK frame_counter++; if (frame_counter > 50) @@ -293,21 +300,21 @@ class btRaycastBar2 btAlignedObjectArray indices; btAlignedObjectArray points; - float lineColor[4] = {1, 0.4, .4, 1}; + float lineColor[4] = {1, 0.4f, .4f, 1}; for (int i = 0; i < NUMRAYS; i++) { btVector3FloatData s, h; for (int w = 0; w < 4; w++) { - s.m_floats[w] = source[i][w]; - h.m_floats[w] = hit[i][w]; + s.m_floats[w] = (float)source[i][w]; + h.m_floats[w] = (float)hit[i][w]; } points.push_back(s); points.push_back(h); - indices.push_back(indices.size()); - indices.push_back(indices.size()); + indices.push_back((unsigned int)indices.size()); + indices.push_back((unsigned int)indices.size()); } m_guiHelper->getRenderInterface()->drawLines(&points[0].m_floats[0], lineColor, points.size(), sizeof(btVector3FloatData), &indices[0], indices.size(), 1); @@ -345,7 +352,7 @@ void BenchmarkDemo::initPhysics() //cci.m_defaultMaxPersistentManifoldPoolSize = 32768; //m_collisionConfiguration = new btDefaultCollisionConfiguration(cci); - /////use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) + /////use the default collision dispatcher. For parallel processing you can use a different dispatcher (see Extras/BulletMultiThreaded) //m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); // //m_dispatcher->setDispatcherFlags(btCollisionDispatcher::CD_DISABLE_CONTACTPOOL_DYNAMIC_ALLOCATION); @@ -467,7 +474,7 @@ void BenchmarkDemo::createTest1() const float cubeSize = 1.0f; float spacing = cubeSize; btVector3 pos(0.0f, cubeSize * 2, 0.f); - float offset = -size * (cubeSize * 2.0f + spacing) * 0.5f; + float offset = (float)-size * (cubeSize * 2.0f + spacing) * 0.5f; btBoxShape* blockShape = new btBoxShape(btVector3(cubeSize - COLLISION_RADIUS, cubeSize - COLLISION_RADIUS, cubeSize - COLLISION_RADIUS)); btVector3 localInertia(0, 0, 0); @@ -489,9 +496,10 @@ void BenchmarkDemo::createTest1() trans.setOrigin(pos); btRigidBody* cmbody; cmbody = createRigidBody(mass, trans, blockShape); + (void)cmbody; } } - offset -= 0.05f * spacing * (size - 1); + offset -= 0.05f * spacing * (float)(size - 1); // spacing *= 1.01f; pos[1] += (cubeSize * 2.0f + spacing); } @@ -512,7 +520,7 @@ void BenchmarkDemo::createWall(const btVector3& offsetPosition, int stackSize, c btScalar diffY = boxSize[1] * 1.0f; btScalar diffZ = boxSize[2] * 1.0f; - btScalar offset = -stackSize * (diffZ * 2.0f) * 0.5f; + btScalar offset = (btScalar)-stackSize * (diffZ * 2.0f) * 0.5f; btVector3 pos(0.0f, diffY, 0.0f); btTransform trans; @@ -551,8 +559,8 @@ void BenchmarkDemo::createPyramid(const btVector3& offsetPosition, int stackSize btScalar diffY = boxSize[1] * 1.02f; btScalar diffZ = boxSize[2] * 1.02f; - btScalar offsetX = -stackSize * (diffX * 2.0f + space) * 0.5f; - btScalar offsetZ = -stackSize * (diffZ * 2.0f + space) * 0.5f; + btScalar offsetX = (btScalar)-stackSize * (diffX * 2.0f + space) * 0.5f; + btScalar offsetZ = (btScalar)-stackSize * (diffZ * 2.0f + space) * 0.5f; while (stackSize) { for (int j = 0; j < stackSize; j++) @@ -562,7 +570,7 @@ void BenchmarkDemo::createPyramid(const btVector3& offsetPosition, int stackSize { pos[0] = offsetX + (float)i * (diffX * 2.0f + space); trans.setOrigin(offsetPosition + pos); - this->createRigidBody(mass, trans, blockShape); + this->createRigidBody((float)mass, trans, blockShape); } } offsetX += diffX; @@ -572,13 +580,13 @@ void BenchmarkDemo::createPyramid(const btVector3& offsetPosition, int stackSize } } -const btVector3 rotate(const btQuaternion& quat, const btVector3& vec) +static const btVector3 rotate(const btQuaternion& quat, const btVector3& vec) { float tmpX, tmpY, tmpZ, tmpW; - tmpX = (((quat.getW() * vec.getX()) + (quat.getY() * vec.getZ())) - (quat.getZ() * vec.getY())); - tmpY = (((quat.getW() * vec.getY()) + (quat.getZ() * vec.getX())) - (quat.getX() * vec.getZ())); - tmpZ = (((quat.getW() * vec.getZ()) + (quat.getX() * vec.getY())) - (quat.getY() * vec.getX())); - tmpW = (((quat.getX() * vec.getX()) + (quat.getY() * vec.getY())) + (quat.getZ() * vec.getZ())); + tmpX = float(((quat.getW() * vec.getX()) + (quat.getY() * vec.getZ())) - (quat.getZ() * vec.getY())); + tmpY = float(((quat.getW() * vec.getY()) + (quat.getZ() * vec.getX())) - (quat.getX() * vec.getZ())); + tmpZ = float(((quat.getW() * vec.getZ()) + (quat.getX() * vec.getY())) - (quat.getY() * vec.getX())); + tmpW = float(((quat.getX() * vec.getX()) + (quat.getY() * vec.getY())) + (quat.getZ() * vec.getZ())); return btVector3( ((((tmpW * quat.getX()) + (tmpX * quat.getW())) - (tmpY * quat.getZ())) + (tmpZ * quat.getY())), ((((tmpW * quat.getY()) + (tmpY * quat.getW())) - (tmpZ * quat.getX())) + (tmpX * quat.getZ())), @@ -596,11 +604,11 @@ void BenchmarkDemo::createTowerCircle(const btVector3& offsetPosition, int stack btVector3 localInertia(0, 0, 0); blockShape->calculateLocalInertia(mass, localInertia); - float radius = 1.3f * rotSize * boxSize[0] / SIMD_PI; + float radius = float(btScalar(1.3) * (btScalar)rotSize * boxSize[0] / SIMD_PI); // create active boxes btQuaternion rotY(0, 1, 0, 0); - float posY = boxSize[1]; + float posY = (float)boxSize[1]; for (int i = 0; i < stackSize; i++) { @@ -610,10 +618,10 @@ void BenchmarkDemo::createTowerCircle(const btVector3& offsetPosition, int stack trans.setRotation(rotY); createRigidBody(mass, trans, blockShape); - rotY *= btQuaternion(btVector3(0, 1, 0), SIMD_PI / (rotSize * btScalar(0.5))); + rotY *= btQuaternion(btVector3(0, 1, 0), SIMD_PI / ((btScalar)rotSize * btScalar(0.5))); } - posY += boxSize[1] * 2.0f; + posY += (float)boxSize[1] * 2.0f; rotY *= btQuaternion(btVector3(0, 1, 0), SIMD_PI / (float)rotSize); } } @@ -763,22 +771,22 @@ class RagDoll transform.setIdentity(); transform.setOrigin(scale * btVector3(btScalar(-0.35), btScalar(1.45), btScalar(0.))); - transform.getBasis().setEulerZYX(0, 0, M_PI_2); + transform.getBasis().setEulerZYX(0, 0, btScalar(M_PI_2)); m_bodies[BODYPART_LEFT_UPPER_ARM] = createRigidBody(btScalar(1.), offset * transform, m_shapes[BODYPART_LEFT_UPPER_ARM]); transform.setIdentity(); transform.setOrigin(scale * btVector3(btScalar(-0.7), btScalar(1.45), btScalar(0.))); - transform.getBasis().setEulerZYX(0, 0, M_PI_2); + transform.getBasis().setEulerZYX(0, 0, btScalar(M_PI_2)); m_bodies[BODYPART_LEFT_LOWER_ARM] = createRigidBody(btScalar(1.), offset * transform, m_shapes[BODYPART_LEFT_LOWER_ARM]); transform.setIdentity(); transform.setOrigin(scale * btVector3(btScalar(0.35), btScalar(1.45), btScalar(0.))); - transform.getBasis().setEulerZYX(0, 0, -M_PI_2); + transform.getBasis().setEulerZYX(0, 0, btScalar(-M_PI_2)); m_bodies[BODYPART_RIGHT_UPPER_ARM] = createRigidBody(btScalar(1.), offset * transform, m_shapes[BODYPART_RIGHT_UPPER_ARM]); transform.setIdentity(); transform.setOrigin(scale * btVector3(btScalar(0.7), btScalar(1.45), btScalar(0.))); - transform.getBasis().setEulerZYX(0, 0, -M_PI_2); + transform.getBasis().setEulerZYX(0, 0, btScalar(-M_PI_2)); m_bodies[BODYPART_RIGHT_LOWER_ARM] = createRigidBody(btScalar(1.), offset * transform, m_shapes[BODYPART_RIGHT_LOWER_ARM]); // Setup some damping on the m_bodies @@ -797,9 +805,9 @@ class RagDoll localA.setIdentity(); localB.setIdentity(); - localA.getBasis().setEulerZYX(0, M_PI_2, 0); + localA.getBasis().setEulerZYX(0, btScalar(M_PI_2), 0); localA.setOrigin(scale * btVector3(btScalar(0.), btScalar(0.15), btScalar(0.))); - localB.getBasis().setEulerZYX(0, M_PI_2, 0); + localB.getBasis().setEulerZYX(0, btScalar(M_PI_2), 0); localB.setOrigin(scale * btVector3(btScalar(0.), btScalar(-0.15), btScalar(0.))); hingeC = new btHingeConstraint(*m_bodies[BODYPART_PELVIS], *m_bodies[BODYPART_SPINE], localA, localB); hingeC->setLimit(btScalar(-M_PI_4), btScalar(M_PI_2)); @@ -808,31 +816,31 @@ class RagDoll localA.setIdentity(); localB.setIdentity(); - localA.getBasis().setEulerZYX(0, 0, M_PI_2); + localA.getBasis().setEulerZYX(0, 0, btScalar(M_PI_2)); localA.setOrigin(scale * btVector3(btScalar(0.), btScalar(0.30), btScalar(0.))); - localB.getBasis().setEulerZYX(0, 0, M_PI_2); + localB.getBasis().setEulerZYX(0, 0, btScalar(M_PI_2)); localB.setOrigin(scale * btVector3(btScalar(0.), btScalar(-0.14), btScalar(0.))); coneC = new btConeTwistConstraint(*m_bodies[BODYPART_SPINE], *m_bodies[BODYPART_HEAD], localA, localB); - coneC->setLimit(M_PI_4, M_PI_4, M_PI_2); + coneC->setLimit(btScalar(M_PI_4), btScalar(M_PI_4), btScalar(M_PI_2)); m_joints[JOINT_SPINE_HEAD] = coneC; m_ownerWorld->addConstraint(m_joints[JOINT_SPINE_HEAD], true); localA.setIdentity(); localB.setIdentity(); - localA.getBasis().setEulerZYX(0, 0, -M_PI_4 * 5); + localA.getBasis().setEulerZYX(0, 0, btScalar(-M_PI_4 * 5)); localA.setOrigin(scale * btVector3(btScalar(-0.18), btScalar(-0.10), btScalar(0.))); - localB.getBasis().setEulerZYX(0, 0, -M_PI_4 * 5); + localB.getBasis().setEulerZYX(0, 0, btScalar(-M_PI_4 * 5)); localB.setOrigin(scale * btVector3(btScalar(0.), btScalar(0.225), btScalar(0.))); coneC = new btConeTwistConstraint(*m_bodies[BODYPART_PELVIS], *m_bodies[BODYPART_LEFT_UPPER_LEG], localA, localB); - coneC->setLimit(M_PI_4, M_PI_4, 0); + coneC->setLimit(btScalar(M_PI_4), btScalar(M_PI_4), 0); m_joints[JOINT_LEFT_HIP] = coneC; m_ownerWorld->addConstraint(m_joints[JOINT_LEFT_HIP], true); localA.setIdentity(); localB.setIdentity(); - localA.getBasis().setEulerZYX(0, M_PI_2, 0); + localA.getBasis().setEulerZYX(0, btScalar(M_PI_2), 0); localA.setOrigin(scale * btVector3(btScalar(0.), btScalar(-0.225), btScalar(0.))); - localB.getBasis().setEulerZYX(0, M_PI_2, 0); + localB.getBasis().setEulerZYX(0, btScalar(M_PI_2), 0); localB.setOrigin(scale * btVector3(btScalar(0.), btScalar(0.185), btScalar(0.))); hingeC = new btHingeConstraint(*m_bodies[BODYPART_LEFT_UPPER_LEG], *m_bodies[BODYPART_LEFT_LOWER_LEG], localA, localB); hingeC->setLimit(btScalar(0), btScalar(M_PI_2)); @@ -841,20 +849,20 @@ class RagDoll localA.setIdentity(); localB.setIdentity(); - localA.getBasis().setEulerZYX(0, 0, M_PI_4); + localA.getBasis().setEulerZYX(0, 0, btScalar(M_PI_4)); localA.setOrigin(scale * btVector3(btScalar(0.18), btScalar(-0.10), btScalar(0.))); - localB.getBasis().setEulerZYX(0, 0, M_PI_4); + localB.getBasis().setEulerZYX(0, 0, btScalar(M_PI_4)); localB.setOrigin(scale * btVector3(btScalar(0.), btScalar(0.225), btScalar(0.))); coneC = new btConeTwistConstraint(*m_bodies[BODYPART_PELVIS], *m_bodies[BODYPART_RIGHT_UPPER_LEG], localA, localB); - coneC->setLimit(M_PI_4, M_PI_4, 0); + coneC->setLimit(btScalar(M_PI_4), btScalar(M_PI_4), 0); m_joints[JOINT_RIGHT_HIP] = coneC; m_ownerWorld->addConstraint(m_joints[JOINT_RIGHT_HIP], true); localA.setIdentity(); localB.setIdentity(); - localA.getBasis().setEulerZYX(0, M_PI_2, 0); + localA.getBasis().setEulerZYX(0, btScalar(M_PI_2), 0); localA.setOrigin(scale * btVector3(btScalar(0.), btScalar(-0.225), btScalar(0.))); - localB.getBasis().setEulerZYX(0, M_PI_2, 0); + localB.getBasis().setEulerZYX(0, btScalar(M_PI_2), 0); localB.setOrigin(scale * btVector3(btScalar(0.), btScalar(0.185), btScalar(0.))); hingeC = new btHingeConstraint(*m_bodies[BODYPART_RIGHT_UPPER_LEG], *m_bodies[BODYPART_RIGHT_LOWER_LEG], localA, localB); hingeC->setLimit(btScalar(0), btScalar(M_PI_2)); @@ -863,23 +871,23 @@ class RagDoll localA.setIdentity(); localB.setIdentity(); - localA.getBasis().setEulerZYX(0, 0, M_PI); + localA.getBasis().setEulerZYX(0, 0, btScalar(M_PI)); localA.setOrigin(scale * btVector3(btScalar(-0.2), btScalar(0.15), btScalar(0.))); - localB.getBasis().setEulerZYX(0, 0, M_PI_2); + localB.getBasis().setEulerZYX(0, 0, btScalar(M_PI_2)); localB.setOrigin(scale * btVector3(btScalar(0.), btScalar(-0.18), btScalar(0.))); coneC = new btConeTwistConstraint(*m_bodies[BODYPART_SPINE], *m_bodies[BODYPART_LEFT_UPPER_ARM], localA, localB); - coneC->setLimit(M_PI_2, M_PI_2, 0); + coneC->setLimit(btScalar(M_PI_2), btScalar(M_PI_2), 0); m_joints[JOINT_LEFT_SHOULDER] = coneC; m_ownerWorld->addConstraint(m_joints[JOINT_LEFT_SHOULDER], true); localA.setIdentity(); localB.setIdentity(); - localA.getBasis().setEulerZYX(0, M_PI_2, 0); + localA.getBasis().setEulerZYX(0, btScalar(M_PI_2), 0); localA.setOrigin(scale * btVector3(btScalar(0.), btScalar(0.18), btScalar(0.))); - localB.getBasis().setEulerZYX(0, M_PI_2, 0); + localB.getBasis().setEulerZYX(0, btScalar(M_PI_2), 0); localB.setOrigin(scale * btVector3(btScalar(0.), btScalar(-0.14), btScalar(0.))); hingeC = new btHingeConstraint(*m_bodies[BODYPART_LEFT_UPPER_ARM], *m_bodies[BODYPART_LEFT_LOWER_ARM], localA, localB); - hingeC->setLimit(btScalar(-M_PI_2), btScalar(0)); + hingeC->setLimit(btScalar(btScalar(-M_PI_2)), btScalar(0)); m_joints[JOINT_LEFT_ELBOW] = hingeC; m_ownerWorld->addConstraint(m_joints[JOINT_LEFT_ELBOW], true); @@ -887,21 +895,21 @@ class RagDoll localB.setIdentity(); localA.getBasis().setEulerZYX(0, 0, 0); localA.setOrigin(scale * btVector3(btScalar(0.2), btScalar(0.15), btScalar(0.))); - localB.getBasis().setEulerZYX(0, 0, M_PI_2); + localB.getBasis().setEulerZYX(0, 0, btScalar(M_PI_2)); localB.setOrigin(scale * btVector3(btScalar(0.), btScalar(-0.18), btScalar(0.))); coneC = new btConeTwistConstraint(*m_bodies[BODYPART_SPINE], *m_bodies[BODYPART_RIGHT_UPPER_ARM], localA, localB); - coneC->setLimit(M_PI_2, M_PI_2, 0); + coneC->setLimit(btScalar(M_PI_2), btScalar(M_PI_2), 0); m_joints[JOINT_RIGHT_SHOULDER] = coneC; m_ownerWorld->addConstraint(m_joints[JOINT_RIGHT_SHOULDER], true); localA.setIdentity(); localB.setIdentity(); - localA.getBasis().setEulerZYX(0, M_PI_2, 0); + localA.getBasis().setEulerZYX(0, btScalar(M_PI_2), 0); localA.setOrigin(scale * btVector3(btScalar(0.), btScalar(0.18), btScalar(0.))); - localB.getBasis().setEulerZYX(0, M_PI_2, 0); + localB.getBasis().setEulerZYX(0, btScalar(M_PI_2), 0); localB.setOrigin(scale * btVector3(btScalar(0.), btScalar(-0.14), btScalar(0.))); hingeC = new btHingeConstraint(*m_bodies[BODYPART_RIGHT_UPPER_ARM], *m_bodies[BODYPART_RIGHT_LOWER_ARM], localA, localB); - hingeC->setLimit(btScalar(-M_PI_2), btScalar(0)); + hingeC->setLimit(btScalar(btScalar(-M_PI_2)), btScalar(0)); m_joints[JOINT_RIGHT_ELBOW] = hingeC; m_ownerWorld->addConstraint(m_joints[JOINT_RIGHT_ELBOW], true); } @@ -948,7 +956,7 @@ void BenchmarkDemo::createTest3() btVector3 pos(0.0f, sizeY, 0.0f); while (size) { - float offset = -size * (sizeX * 6.0f) * 0.5f; + float offset = (float)-size * (sizeX * 6.0f) * 0.5f; for (int i = 0; i < size; i++) { pos[0] = offset + (float)i * (sizeX * 6.0f); @@ -961,6 +969,7 @@ void BenchmarkDemo::createTest3() pos[1] += (sizeY * 7.0f); pos[2] -= sizeX * 2.0f; size--; + (void)offset; } } void BenchmarkDemo::createTest4() @@ -971,7 +980,7 @@ void BenchmarkDemo::createTest4() const float cubeSize = 1.5f; float spacing = cubeSize; btVector3 pos(0.0f, cubeSize * 2, 0.0f); - float offset = -size * (cubeSize * 2.0f + spacing) * 0.5f; + float offset = (float)-size * (cubeSize * 2.0f + spacing) * 0.5f; btConvexHullShape* convexHullShape = new btConvexHullShape(); @@ -1007,7 +1016,7 @@ void BenchmarkDemo::createTest4() createRigidBody(mass, trans, convexHullShape); } } - offset -= 0.05f * spacing * (size - 1); + offset -= 0.05f * spacing * (float)(size - 1); spacing *= 1.01f; pos[1] += (cubeSize * 2.0f + spacing); } @@ -1016,7 +1025,7 @@ void BenchmarkDemo::createTest4() /////////////////////////////////////////////////////////////////////////////// // LargeMesh -int LandscapeVtxCount[] = { +static int LandscapeVtxCount[] = { Landscape01VtxCount, Landscape02VtxCount, Landscape03VtxCount, @@ -1027,7 +1036,7 @@ int LandscapeVtxCount[] = { Landscape08VtxCount, }; -int LandscapeIdxCount[] = { +static int LandscapeIdxCount[] = { Landscape01IdxCount, Landscape02IdxCount, Landscape03IdxCount, @@ -1038,7 +1047,7 @@ int LandscapeIdxCount[] = { Landscape08IdxCount, }; -btScalar* LandscapeVtx[] = { +static btScalar* LandscapeVtx[] = { Landscape01Vtx, Landscape02Vtx, Landscape03Vtx, @@ -1049,7 +1058,7 @@ btScalar* LandscapeVtx[] = { Landscape08Vtx, }; -btScalar* LandscapeNml[] = { +static btScalar* LandscapeNml[] = { Landscape01Nml, Landscape02Nml, Landscape03Nml, @@ -1060,7 +1069,7 @@ btScalar* LandscapeNml[] = { Landscape08Nml, }; -btScalar* LandscapeTex[] = { +static btScalar* LandscapeTex[] = { Landscape01Tex, Landscape02Tex, Landscape03Tex, @@ -1071,7 +1080,7 @@ btScalar* LandscapeTex[] = { Landscape08Tex, }; -unsigned short* LandscapeIdx[] = { +static unsigned short* LandscapeIdx[] = { Landscape01Idx, Landscape02Idx, Landscape03Idx, @@ -1127,12 +1136,13 @@ void BenchmarkDemo::createTest5() int size = 10; int height = 10; - const float cubeSize = boxSize[0]; + const float cubeSize = (float)boxSize[0]; float spacing = 2.0f; btVector3 pos(0.0f, 20.0f, 0.0f); - float offset = -size * (cubeSize * 2.0f + spacing) * 0.5f; + float offset = (float)-size * (cubeSize * 2.0f + spacing) * 0.5f; int numBodies = 0; + (void)numBodies; for (int k = 0; k < height; k++) { @@ -1154,7 +1164,7 @@ void BenchmarkDemo::createTest5() case 1: case 2: { - float r = 0.5f * (idx + 1); + float r = 0.5f * (float)(idx + 1); btBoxShape* boxShape = new btBoxShape(boxSize * r); createRigidBody(boxMass * r, trans, boxShape); } @@ -1164,7 +1174,7 @@ void BenchmarkDemo::createTest5() case 4: case 5: { - float r = 0.5f * (idx - 3 + 1); + float r = 0.5f * (float)(idx - 3 + 1); btSphereShape* sphereShape = new btSphereShape(sphereRadius * r); createRigidBody(sphereMass * r, trans, sphereShape); } @@ -1174,17 +1184,19 @@ void BenchmarkDemo::createTest5() case 7: case 8: { - float r = 0.5f * (idx - 6 + 1); + float r = 0.5f * (float)(idx - 6 + 1); btCapsuleShape* capsuleShape = new btCapsuleShape(capsuleRadius * r, capsuleHalf * r); createRigidBody(capsuleMass * r, trans, capsuleShape); } break; + default: + break; } numBodies++; } } - offset -= 0.05f * spacing * (size - 1); + offset -= 0.05f * spacing * (float)(size - 1); spacing *= 1.1f; pos[1] += (cubeSize * 2.0f + spacing); } @@ -1217,10 +1229,10 @@ void BenchmarkDemo::createTest6() int size = 10; int height = 10; - const float cubeSize = boxSize[0]; + const float cubeSize = (float)boxSize[0]; float spacing = 2.0f; btVector3 pos(0.0f, 20.0f, 0.0f); - float offset = -size * (cubeSize * 2.0f + spacing) * 0.5f; + float offset = (float)-size * (cubeSize * 2.0f + spacing) * 0.5f; for (int k = 0; k < height; k++) { @@ -1236,7 +1248,7 @@ void BenchmarkDemo::createTest6() createRigidBody(mass, trans, convexHullShape); } } - offset -= 0.05f * spacing * (size - 1); + offset -= 0.05f * spacing * (float)(size - 1); spacing *= 1.1f; pos[1] += (cubeSize * 2.0f + spacing); } diff --git a/examples/Benchmarks/HaltonData.h b/examples/Benchmarks/HaltonData.h index 1f6c6a44a4..ce873bd4be 100644 --- a/examples/Benchmarks/HaltonData.h +++ b/examples/Benchmarks/HaltonData.h @@ -1,4 +1,8 @@ // Generated by ./Tools/mksrc.py +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wimplicit-float-conversion" +#endif // h00 const int h00_numv = 14; @@ -645,3 +649,7 @@ const float* halton_pos[ halton_numc ] = { const float* halton_verts[ halton_numc ] = { h00_verts,h01_verts,h02_verts,h03_verts,h04_verts,h05_verts,h06_verts,h07_verts,h08_verts,h09_verts,h10_verts,h11_verts,h12_verts,h13_verts,h14_verts,h15_verts,h16_verts,h17_verts,h18_verts,h19_verts,h20_verts,h21_verts,h22_verts,h23_verts,h24_verts,h25_verts,h26_verts,h27_verts,h28_verts,h29_verts,h30_verts,h31_verts,h32_verts,h33_verts,h34_verts,h35_verts,h36_verts,h37_verts,h38_verts,h39_verts,h40_verts,h41_verts,h42_verts,h43_verts,h44_verts,h45_verts,h46_verts,h47_verts,h48_verts,h49_verts,h50_verts,h51_verts,h52_verts,h53_verts,h54_verts,h55_verts,h56_verts,h57_verts,h58_verts,h59_verts,h60_verts,h61_verts,h62_verts,h63_verts,h64_verts,h65_verts,h66_verts,h67_verts,h68_verts,h69_verts,h70_verts,h71_verts,h72_verts,h73_verts,h74_verts,h75_verts,h76_verts,h77_verts,h78_verts,h79_verts,h80_verts,h81_verts,h82_verts,h83_verts,h84_verts,h85_verts,h86_verts,h87_verts,h88_verts,h89_verts, }; + +#if defined(__clang__) +#pragma clang diagnostic pop +#endif diff --git a/examples/BulletRobotics/BoxStack.cpp b/examples/BulletRobotics/BoxStack.cpp index df4056465a..bdcadd0916 100644 --- a/examples/BulletRobotics/BoxStack.cpp +++ b/examples/BulletRobotics/BoxStack.cpp @@ -29,6 +29,7 @@ class BoxStackExample : public CommonExampleInterface m_options(options) { m_app->setUpAxis(2); + (void)m_options; } virtual ~BoxStackExample() @@ -57,7 +58,7 @@ class BoxStackExample : public CommonExampleInterface int mass = 1; for (int i = 0; i < 8; i++) { - args.m_startPosition.setValue(0, 0, i * .06); + args.m_startPosition.setValue(0, 0, btScalar(i * .06)); int boxIdx = m_robotSim.loadURDF("cube_small.urdf", args); dynamicsArgs.m_mass = mass; m_robotSim.changeDynamics(boxIdx, -1, dynamicsArgs); @@ -72,7 +73,7 @@ class BoxStackExample : public CommonExampleInterface { m_robotSim.disconnect(); } - virtual void stepSimulation(float deltaTime) + virtual void stepSimulation(float /*deltaTime*/) { m_robotSim.stepSimulation(); } @@ -89,7 +90,7 @@ class BoxStackExample : public CommonExampleInterface { return m_robotSim.mouseButtonCallback(button, state, x, y); } - virtual bool keyboardCallback(int key, int state) + virtual bool keyboardCallback(int /*key*/, int /*state*/) { return false; } @@ -99,7 +100,7 @@ class BoxStackExample : public CommonExampleInterface float dist = 1.5; float pitch = -10; float yaw = 18; - float targetPos[3] = {-0.2, 0.8, 0.3}; + float targetPos[3] = {-0.2f, 0.8f, 0.3f}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); diff --git a/examples/BulletRobotics/FixJointBoxes.cpp b/examples/BulletRobotics/FixJointBoxes.cpp index 51cd1842d1..2b96dda205 100644 --- a/examples/BulletRobotics/FixJointBoxes.cpp +++ b/examples/BulletRobotics/FixJointBoxes.cpp @@ -31,10 +31,11 @@ class FixJointBoxes : public CommonExampleInterface FixJointBoxes(GUIHelperInterface* helper, int options) : m_guiHelper(helper), m_options(options), - numCubes(30), - cubeIds(numCubes, 0), - solver(solverId) + solver((int)solverId), + numCubes(30), + cubeIds(numCubes, 0) { + (void)m_options; } virtual ~FixJointBoxes() @@ -61,10 +62,10 @@ class FixJointBoxes : public CommonExampleInterface b3RobotSimulatorLoadUrdfFileArgs args; b3RobotSimulatorChangeDynamicsArgs dynamicsArgs; - for (int i = 0; i < numCubes; i++) + for (unsigned int i = 0; i < numCubes; i++) { args.m_forceOverrideFixedBase = (i == 0); - args.m_startPosition.setValue(0, i * 0.05, 1); + args.m_startPosition.setValue(0, btScalar(i * 0.05), 1); cubeIds[i] = m_robotSim.loadURDF("cube_small.urdf", args); b3RobotJointInfo jointInfo; @@ -109,14 +110,14 @@ class FixJointBoxes : public CommonExampleInterface void resetCubePosition() { - for (int i = 0; i < numCubes; i++) + for (unsigned int i = 0; i < numCubes; i++) { - btVector3 pos(0, i * (btScalar)0.05, 1); + btVector3 pos(0, (btScalar)i * (btScalar)0.05, 1); btQuaternion quar(0, 0, 0, 1); m_robotSim.resetBasePositionAndOrientation(cubeIds[i], pos, quar); } } - virtual void stepSimulation(float deltaTime) + virtual void stepSimulation(float /*deltaTime*/) { int newSolver = (int)(solverId + 0.5); if (newSolver != solver) @@ -151,7 +152,7 @@ class FixJointBoxes : public CommonExampleInterface { return m_robotSim.mouseButtonCallback(button, state, x, y); } - virtual bool keyboardCallback(int key, int state) + virtual bool keyboardCallback(int /*key*/, int /*state*/) { return false; } @@ -161,7 +162,7 @@ class FixJointBoxes : public CommonExampleInterface float dist = 1; float pitch = -20; float yaw = -30; - float targetPos[3] = {0, 0.2, 0.5}; + float targetPos[3] = {0, 0.2f, 0.5f}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } }; diff --git a/examples/BulletRobotics/JointLimit.cpp b/examples/BulletRobotics/JointLimit.cpp index 6a4d91eefb..e4290a90b1 100644 --- a/examples/BulletRobotics/JointLimit.cpp +++ b/examples/BulletRobotics/JointLimit.cpp @@ -26,6 +26,7 @@ class JointLimit : public CommonExampleInterface : m_guiHelper(helper), m_options(options) { + (void)m_options; } virtual ~JointLimit() @@ -70,7 +71,7 @@ class JointLimit : public CommonExampleInterface { m_robotSim.disconnect(); } - virtual void stepSimulation(float deltaTime) + virtual void stepSimulation(float /*deltaTime*/) { m_robotSim.stepSimulation(); } @@ -87,7 +88,7 @@ class JointLimit : public CommonExampleInterface { return m_robotSim.mouseButtonCallback(button, state, x, y); } - virtual bool keyboardCallback(int key, int state) + virtual bool keyboardCallback(int /*key*/, int /*state*/) { return false; } @@ -97,7 +98,7 @@ class JointLimit : public CommonExampleInterface float dist = 3; float pitch = -10; float yaw = 18; - float targetPos[3] = {0.6, 0.8, 0.3}; + float targetPos[3] = {0.6f, 0.8f, 0.3f}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } diff --git a/examples/Collision/CollisionSdkC_Api.cpp b/examples/Collision/CollisionSdkC_Api.cpp index c0541d2518..4eebf26f3d 100644 --- a/examples/Collision/CollisionSdkC_Api.cpp +++ b/examples/Collision/CollisionSdkC_Api.cpp @@ -89,7 +89,7 @@ plCollisionObjectHandle plCreateCollisionObject(plCollisionSdkHandle collisionSd return sdk->createCollisionObject(worldHandle, userData, userIndex, cshape, childPos, childOrn); } -void plDeleteCollisionObject(plCollisionSdkHandle collisionSdkHandle, plCollisionWorldHandle worldHandle, plCollisionObjectHandle body) +void plDeleteCollisionObject(plCollisionSdkHandle collisionSdkHandle, plCollisionWorldHandle /*worldHandle*/, plCollisionObjectHandle body) { CollisionSdkInterface* sdk = (CollisionSdkInterface*)collisionSdkHandle; sdk->deleteCollisionObject(body); diff --git a/examples/Collision/CollisionTutorialBullet2.cpp b/examples/Collision/CollisionTutorialBullet2.cpp index 015e539025..c086e3385e 100644 --- a/examples/Collision/CollisionTutorialBullet2.cpp +++ b/examples/Collision/CollisionTutorialBullet2.cpp @@ -25,17 +25,19 @@ const int sPointCapacity = 10000; const int sNumCompounds = 10; const int sNumSpheres = 10; -lwContactPoint pointsOut[sPointCapacity]; -int numNearCallbacks = 0; +static lwContactPoint pointsOut[sPointCapacity]; +static int numNearCallbacks = 0; +// clang-format off static btVector4 sColors[4] = - { - btVector4(1, 0.7, 0.7, 1), - btVector4(1, 1, 0.7, 1), - btVector4(0.7, 1, 0.7, 1), - btVector4(0.7, 1, 1, 1), +{ + btVector4(btScalar(1) , btScalar(0.7), btScalar(0.7), btScalar(1)), + btVector4(btScalar(1) , btScalar(1) , btScalar(0.7), btScalar(1)), + btVector4(btScalar(0.7), btScalar(1) , btScalar(0.7), btScalar(1)), + btVector4(btScalar(0.7), btScalar(1) , btScalar(1) , btScalar(1)), }; +// clang-format on -void myNearCallback(plCollisionSdkHandle sdkHandle, plCollisionWorldHandle worldHandle, void* userData, plCollisionObjectHandle objA, plCollisionObjectHandle objB) +static void myNearCallback(plCollisionSdkHandle sdkHandle, plCollisionWorldHandle worldHandle, void* /*userData*/, plCollisionObjectHandle objA, plCollisionObjectHandle objB) { numNearCallbacks++; int remainingCapacity = sPointCapacity - gTotalPoints; @@ -112,7 +114,7 @@ class CollisionTutorialBullet2 : public CommonExampleInterface for (int i = 0; i < sNumSpheres; i++) { - btVector3 childPos(i * 1.5, 0, 0); + btVector3 childPos(btScalar(i * 1.5), 0, 0); btQuaternion childOrn(0, 0, 0, 1); btVector3 scaling(radius, radius, radius); @@ -132,7 +134,7 @@ class CollisionTutorialBullet2 : public CommonExampleInterface } { - btVector3 pos(j * sNumSpheres * 1.5, -2.4, 0); + btVector3 pos(btScalar(j * sNumSpheres * 1.5), btScalar(-2.4), btScalar(0)); btQuaternion orn(0, 0, 0, 1); plCollisionObjectHandle colObjHandle = plCreateCollisionObject(m_collisionSdkHandle, m_collisionWorldHandle, userPointer, -1, compoundShape, pos, orn); if (m_tutorialIndex == TUT_SPHERE_PLANE_BULLET2) @@ -186,10 +188,10 @@ class CollisionTutorialBullet2 : public CommonExampleInterface m_timeSeriesCanvas0 = new TimeSeriesCanvas(m_app->m_2dCanvasInterface, 512, 256, "Unknown"); m_timeSeriesCanvas0->setupTimeSeries(1, 60, 0); } - }; + } { - int boxId = m_app->registerCubeShape(100, 0.01, 100); + int boxId = m_app->registerCubeShape(100.0f, 0.01f, 100.0f); b3Vector3 pos = b3MakeVector3(0, -3.5, 0); b3Quaternion orn(0, 0, 0, 1); b3Vector4 color = b3MakeVector4(1, 1, 1, 1); @@ -199,10 +201,11 @@ class CollisionTutorialBullet2 : public CommonExampleInterface { int textureIndex = -1; + (void)textureIndex; if (1) { - int width, height, n; + int width=0, height=0, n; const char* filename = "data/cube.png"; const unsigned char* image = 0; @@ -221,6 +224,7 @@ class CollisionTutorialBullet2 : public CommonExampleInterface if (image) { textureIndex = m_app->m_renderer->registerTexture(image, width, height); + (void)textureIndex; } } } @@ -245,7 +249,7 @@ class CollisionTutorialBullet2 : public CommonExampleInterface { } - virtual void stepSimulation(float deltaTime) + virtual void stepSimulation(float /*deltaTime*/) { #ifndef BT_NO_PROFILE CProfileManager::Reset(); @@ -322,18 +326,18 @@ class CollisionTutorialBullet2 : public CommonExampleInterface } } - virtual void physicsDebugDraw(int debugDrawFlags) + virtual void physicsDebugDraw(int /*debugDrawFlags*/) { } - virtual bool mouseMoveCallback(float x, float y) + virtual bool mouseMoveCallback(float /*x*/, float /*y*/) { return false; } - virtual bool mouseButtonCallback(int button, int state, float x, float y) + virtual bool mouseButtonCallback(int /*button*/, int /*state*/, float /*x*/, float /*y*/) { return false; } - virtual bool keyboardCallback(int key, int state) + virtual bool keyboardCallback(int /*key*/, int /*state*/) { return false; } diff --git a/examples/Collision/CollisionTutorialBullet2.h b/examples/Collision/CollisionTutorialBullet2.h index 6ed76f243f..59b95ae025 100644 --- a/examples/Collision/CollisionTutorialBullet2.h +++ b/examples/Collision/CollisionTutorialBullet2.h @@ -4,7 +4,7 @@ enum EnumCollisionTutorialTypes { TUT_SPHERE_PLANE_BULLET2 = 0, - TUT_SPHERE_PLANE_RTB3, + TUT_SPHERE_PLANE_RTB3 }; class CommonExampleInterface* CollisionTutorialBullet2CreateFunc(struct CommonExampleOptions& options); diff --git a/examples/Collision/Internal/Bullet2CollisionSdk.cpp b/examples/Collision/Internal/Bullet2CollisionSdk.cpp index b03d7fc98d..0f7f1ef60f 100644 --- a/examples/Collision/Internal/Bullet2CollisionSdk.cpp +++ b/examples/Collision/Internal/Bullet2CollisionSdk.cpp @@ -64,7 +64,7 @@ plCollisionShapeHandle Bullet2CollisionSdk::createSphereShape(plCollisionWorldHa return (plCollisionShapeHandle)sphereShape; } -plCollisionShapeHandle Bullet2CollisionSdk::createPlaneShape(plCollisionWorldHandle worldHandle, +plCollisionShapeHandle Bullet2CollisionSdk::createPlaneShape(plCollisionWorldHandle /*worldHandle*/, plReal planeNormalX, plReal planeNormalY, plReal planeNormalZ, @@ -74,7 +74,7 @@ plCollisionShapeHandle Bullet2CollisionSdk::createPlaneShape(plCollisionWorldHan return (plCollisionShapeHandle)planeShape; } -plCollisionShapeHandle Bullet2CollisionSdk::createCapsuleShape(plCollisionWorldHandle worldHandle, +plCollisionShapeHandle Bullet2CollisionSdk::createCapsuleShape(plCollisionWorldHandle /*worldHandle*/, plReal radius, plReal height, int capsuleAxis) @@ -106,11 +106,11 @@ plCollisionShapeHandle Bullet2CollisionSdk::createCapsuleShape(plCollisionWorldH return (plCollisionShapeHandle)capsule; } -plCollisionShapeHandle Bullet2CollisionSdk::createCompoundShape(plCollisionWorldHandle worldHandle) +plCollisionShapeHandle Bullet2CollisionSdk::createCompoundShape(plCollisionWorldHandle /*worldHandle*/) { return (plCollisionShapeHandle) new btCompoundShape(); } -void Bullet2CollisionSdk::addChildShape(plCollisionWorldHandle worldHandle, plCollisionShapeHandle compoundShapeHandle, plCollisionShapeHandle childShapeHandle, plVector3 childPos, plQuaternion childOrn) +void Bullet2CollisionSdk::addChildShape(plCollisionWorldHandle /*worldHandle*/, plCollisionShapeHandle compoundShapeHandle, plCollisionShapeHandle childShapeHandle, plVector3 childPos, plQuaternion childOrn) { btCompoundShape* compound = (btCompoundShape*)compoundShapeHandle; btCollisionShape* childShape = (btCollisionShape*)childShapeHandle; @@ -147,7 +147,7 @@ void Bullet2CollisionSdk::removeCollisionObject(plCollisionWorldHandle worldHand } } -plCollisionObjectHandle Bullet2CollisionSdk::createCollisionObject(plCollisionWorldHandle worldHandle, void* userPointer, int userIndex, plCollisionShapeHandle shapeHandle, +plCollisionObjectHandle Bullet2CollisionSdk::createCollisionObject(plCollisionWorldHandle /*worldHandle*/, void* userPointer, int userIndex, plCollisionShapeHandle shapeHandle, plVector3 startPosition, plQuaternion startOrientation) { @@ -194,7 +194,7 @@ struct Bullet2ContactResultCallback : public btCollisionWorld::ContactResultCall m_pointCapacity(pointCapacity) { } - virtual btScalar addSingleResult(btManifoldPoint& cp, const btCollisionObjectWrapper* colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper* colObj1Wrap, int partId1, int index1) + virtual btScalar addSingleResult(btManifoldPoint& cp, const btCollisionObjectWrapper* /*colObj0Wrap*/, int /*partId0*/, int /*index0*/, const btCollisionObjectWrapper* /*colObj1Wrap*/, int /*partId1*/, int /*index1*/) { if (m_numContacts < m_pointCapacity) { @@ -239,7 +239,7 @@ static plCollisionWorldHandle gCollisionWorldHandle = 0; static void* gUserData = 0; -void Bullet2NearCallback(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo) +static void Bullet2NearCallback(btBroadphasePair& collisionPair, btCollisionDispatcher& /*dispatcher*/, const btDispatcherInfo& /*dispatchInfo*/) { btCollisionObject* colObj0 = (btCollisionObject*)collisionPair.m_pProxy0->m_clientObject; btCollisionObject* colObj1 = (btCollisionObject*)collisionPair.m_pProxy1->m_clientObject; diff --git a/examples/Collision/Internal/RealTimeBullet3CollisionSdk.cpp b/examples/Collision/Internal/RealTimeBullet3CollisionSdk.cpp index 2ffff03e55..e168f5e69e 100644 --- a/examples/Collision/Internal/RealTimeBullet3CollisionSdk.cpp +++ b/examples/Collision/Internal/RealTimeBullet3CollisionSdk.cpp @@ -27,7 +27,7 @@ enum RTB3ShapeTypes RTB3_SHAPE_PLANE, RTB3_SHAPE_CAPSULE, MAX_NUM_SINGLE_SHAPE_TYPES, - RTB3_SHAPE_COMPOUND_INTERNAL, + RTB3_SHAPE_COMPOUND_INTERNAL }; @@ -124,7 +124,7 @@ plCollisionShapeHandle RealTimeBullet3CollisionSdk::createSphereShape(plCollisio b3GpuChildShape& shape = world->m_childShapes[world->m_nextFreeShapeIndex]; shape.m_childPosition.setZero(); shape.m_childOrientation.setValue(0, 0, 0, 1); - shape.m_radius = radius; + shape.m_radius = (float)radius; shape.m_shapeType = RTB3_SHAPE_SPHERE; world->m_nextFreeShapeIndex++; return (plCollisionShapeHandle)world->m_nextFreeShapePtr; @@ -146,7 +146,7 @@ plCollisionShapeHandle RealTimeBullet3CollisionSdk::createPlaneShape(plCollision b3GpuChildShape& shape = world->m_childShapes[world->m_nextFreeShapeIndex]; shape.m_childPosition.setZero(); shape.m_childOrientation.setValue(0, 0, 0, 1); - world->m_planeFaces[world->m_nextFreePlaneFaceIndex].m_plane = b3MakeVector4(planeNormalX, planeNormalY, planeNormalZ, planeConstant); + world->m_planeFaces[world->m_nextFreePlaneFaceIndex].m_plane = b3MakeVector4((b3Scalar)planeNormalX, (b3Scalar)planeNormalY, (b3Scalar)planeNormalZ, (b3Scalar)planeConstant); shape.m_shapeIndex = world->m_nextFreePlaneFaceIndex++; shape.m_shapeType = RTB3_SHAPE_PLANE; world->m_nextFreeShapeIndex++; @@ -168,8 +168,8 @@ plCollisionShapeHandle RealTimeBullet3CollisionSdk::createCapsuleShape(plCollisi b3GpuChildShape& shape = world->m_childShapes[world->m_nextFreeShapeIndex]; shape.m_childPosition.setZero(); shape.m_childOrientation.setValue(0, 0, 0, 1); - shape.m_radius = radius; - shape.m_height = height; + shape.m_radius = (float)radius; + shape.m_height = (float)height; shape.m_shapeIndex = capsuleAxis; shape.m_shapeType = RTB3_SHAPE_CAPSULE; world->m_nextFreeShapeIndex++; @@ -196,10 +196,10 @@ plCollisionShapeHandle RealTimeBullet3CollisionSdk::createCompoundShape(plCollis return 0; } -void RealTimeBullet3CollisionSdk::addChildShape(plCollisionWorldHandle worldHandle, plCollisionShapeHandle compoundShape, plCollisionShapeHandle childShape, plVector3 childPos, plQuaternion childOrn) +void RealTimeBullet3CollisionSdk::addChildShape(plCollisionWorldHandle /*worldHandle*/, plCollisionShapeHandle /*compoundShape*/, plCollisionShapeHandle /*childShape*/, plVector3 /*childPos*/, plQuaternion /*childOrn*/) { } -void RealTimeBullet3CollisionSdk::deleteShape(plCollisionWorldHandle worldHandle, plCollisionShapeHandle shape) +void RealTimeBullet3CollisionSdk::deleteShape(plCollisionWorldHandle /*worldHandle*/, plCollisionShapeHandle /*shape*/) { ///todo //deleting shapes would involve a garbage collection phase, and mess up all user indices @@ -207,12 +207,12 @@ void RealTimeBullet3CollisionSdk::deleteShape(plCollisionWorldHandle worldHandle //for now, we don't delete and eventually run out-of-shapes } -void RealTimeBullet3CollisionSdk::addCollisionObject(plCollisionWorldHandle world, plCollisionObjectHandle object) +void RealTimeBullet3CollisionSdk::addCollisionObject(plCollisionWorldHandle /*world*/, plCollisionObjectHandle /*object*/) { ///createCollisionObject already adds it to the world } -void RealTimeBullet3CollisionSdk::removeCollisionObject(plCollisionWorldHandle world, plCollisionObjectHandle object) +void RealTimeBullet3CollisionSdk::removeCollisionObject(plCollisionWorldHandle /*world*/, plCollisionObjectHandle /*object*/) { ///todo, see deleteShape } @@ -226,8 +226,8 @@ plCollisionObjectHandle RealTimeBullet3CollisionSdk::createCollisionObject(plCol if (world->m_nextFreeCollidableIndex < world->m_collidables.size()) { b3Collidable& collidable = world->m_collidables[world->m_nextFreeCollidableIndex]; - world->m_collidablePositions[world->m_nextFreeCollidableIndex].setValue(startPosition[0], startPosition[1], startPosition[2]); - world->m_collidableOrientations[world->m_nextFreeCollidableIndex].setValue(startOrientation[0], startOrientation[1], startOrientation[2], startOrientation[3]); + world->m_collidablePositions[world->m_nextFreeCollidableIndex].setValue((b3Scalar)startPosition[0], (b3Scalar)startPosition[1], (b3Scalar)startPosition[2]); + world->m_collidableOrientations[world->m_nextFreeCollidableIndex].setValue((b3Scalar)startOrientation[0], (b3Scalar)startOrientation[1], (b3Scalar)startOrientation[2], (b3Scalar)startOrientation[3]); world->m_collidableTransforms[world->m_nextFreeCollidableIndex].setOrigin(world->m_collidablePositions[world->m_nextFreeCollidableIndex]); world->m_collidableTransforms[world->m_nextFreeCollidableIndex].setRotation(world->m_collidableOrientations[world->m_nextFreeCollidableIndex]); world->m_collidableUserPointers[world->m_nextFreeCollidableIndex] = userPointer; @@ -274,13 +274,13 @@ plCollisionObjectHandle RealTimeBullet3CollisionSdk::createCollisionObject(plCol return 0; } -void RealTimeBullet3CollisionSdk::deleteCollisionObject(plCollisionObjectHandle body) +void RealTimeBullet3CollisionSdk::deleteCollisionObject(plCollisionObjectHandle /*body*/) { ///todo, see deleteShape } -void RealTimeBullet3CollisionSdk::setCollisionObjectTransform(plCollisionWorldHandle world, plCollisionObjectHandle body, - plVector3 position, plQuaternion orientation) +void RealTimeBullet3CollisionSdk::setCollisionObjectTransform(plCollisionWorldHandle /*world*/, plCollisionObjectHandle /*body*/, + plVector3 /*position*/, plQuaternion /*orientation*/) { } @@ -294,28 +294,30 @@ struct plContactCache typedef void (*plDetectCollisionFunc)(RTB3CollisionWorld* world, int colA, int shapeIndexA, int colB, int shapeIndexB, plContactCache* contactCache); -void detectCollisionDummy(RTB3CollisionWorld* world, int colA, int shapeIndexA, int colB, int shapeIndexB, +static void detectCollisionDummy(RTB3CollisionWorld* world, int colA, int shapeIndexA, int colB, int shapeIndexB, plContactCache* contactCache) { (void)world; (void)colA, (void)colB; (void)contactCache; + (void)shapeIndexA; + (void)shapeIndexB; } -void plVecCopy(float* dst, const b3Vector3& src) +static void plVecCopy(float* dst, const b3Vector3& src) { dst[0] = src.x; dst[1] = src.y; dst[2] = src.z; } -void plVecCopy(double* dst, const b3Vector3& src) +static void plVecCopy(double* dst, const b3Vector3& src) { dst[0] = src.x; dst[1] = src.y; dst[2] = src.z; } -void ComputeClosestPointsPlaneSphere(const b3Vector3& planeNormalWorld, b3Scalar planeConstant, const b3Vector3& spherePosWorld, b3Scalar sphereRadius, plContactCache* contactCache) +static void ComputeClosestPointsPlaneSphere(const b3Vector3& planeNormalWorld, b3Scalar planeConstant, const b3Vector3& spherePosWorld, b3Scalar sphereRadius, plContactCache* contactCache) { if (contactCache->numAddedPoints < contactCache->pointCapacity) { @@ -334,7 +336,7 @@ void ComputeClosestPointsPlaneSphere(const b3Vector3& planeNormalWorld, b3Scalar } } -void ComputeClosestPointsSphereSphere(b3Scalar sphereARadius, const b3Vector3& sphereAPosWorld, b3Scalar sphereBRadius, const b3Vector3& sphereBPosWorld, plContactCache* contactCache) +static void ComputeClosestPointsSphereSphere(b3Scalar sphereARadius, const b3Vector3& sphereAPosWorld, b3Scalar sphereBRadius, const b3Vector3& sphereBPosWorld, plContactCache* contactCache) { if (contactCache->numAddedPoints < contactCache->pointCapacity) { @@ -354,7 +356,7 @@ void ComputeClosestPointsSphereSphere(b3Scalar sphereARadius, const b3Vector3& s plVecCopy(pointOut.m_normalOnB, normOnB); b3Vector3 ptAWorld = sphereAPosWorld - sphereARadius * normOnB; plVecCopy(pointOut.m_ptOnAWorld, ptAWorld); - plVecCopy(pointOut.m_ptOnBWorld, ptAWorld - normOnB * pointOut.m_distance); + plVecCopy(pointOut.m_ptOnBWorld, ptAWorld - normOnB * (b3Scalar)pointOut.m_distance); contactCache->numAddedPoints++; } @@ -380,7 +382,7 @@ B3_FORCE_INLINE void detectCollisionSphereSphere(RTB3CollisionWorld* world, int ComputeClosestPointsSphereSphere(radiusA, spherePosAWorld, radiusB, spherePosBWorld, contactCache); } -void detectCollisionSpherePlane(RTB3CollisionWorld* world, int colA, int shapeIndexA, int colB, int shapeIndexB, +static void detectCollisionSpherePlane(RTB3CollisionWorld* world, int colA, int shapeIndexA, int /*colB*/, int shapeIndexB, plContactCache* contactCache) { const b3Transform& trA = world->m_collidableTransforms[colA]; @@ -395,7 +397,7 @@ void detectCollisionSpherePlane(RTB3CollisionWorld* world, int colA, int shapeIn ComputeClosestPointsPlaneSphere(planeNormal, planeConstant, spherePosAWorld, world->m_childShapes[shapeIndexA].m_radius, contactCache); } -void detectCollisionPlaneSphere(RTB3CollisionWorld* world, int colA, int shapeIndexA, int colB, int shapeIndexB, +static void detectCollisionPlaneSphere(RTB3CollisionWorld* world, int colA, int shapeIndexA, int colB, int shapeIndexB, plContactCache* contactCache) { (void)world; @@ -404,13 +406,13 @@ void detectCollisionPlaneSphere(RTB3CollisionWorld* world, int colA, int shapeIn } #ifdef RTB3_SHAPE_CAPSULE -plDetectCollisionFunc funcTbl_detectCollision[MAX_NUM_SINGLE_SHAPE_TYPES, ][MAX_NUM_SINGLE_SHAPE_TYPES, ] = { +static plDetectCollisionFunc funcTbl_detectCollision[MAX_NUM_SINGLE_SHAPE_TYPES, ][MAX_NUM_SINGLE_SHAPE_TYPES, ] = { {detectCollisionSphereSphere, detectCollisionSpherePlane, detectCollisionSphereCapsule}, {detectCollisionPlaneSphere, detectCollisionDummy, detectCollisionPlaneCapsule}, {detectCollisionCapsuleSphere, detectCollisionCapsulePlane, detectCollisionCapsuleCapsule}, }; #else -plDetectCollisionFunc funcTbl_detectCollision[MAX_NUM_SINGLE_SHAPE_TYPES][MAX_NUM_SINGLE_SHAPE_TYPES] = { +static plDetectCollisionFunc funcTbl_detectCollision[MAX_NUM_SINGLE_SHAPE_TYPES][MAX_NUM_SINGLE_SHAPE_TYPES] = { {detectCollisionSphereSphere, detectCollisionSpherePlane}, {detectCollisionPlaneSphere, detectCollisionDummy}, }; @@ -444,10 +446,8 @@ int RealTimeBullet3CollisionSdk::collide(plCollisionWorldHandle worldHandle, plC // [world->m_childShapes[colB.m_shapeIndex+j].m_shapeType](world,colAIndex,colA.m_shapeIndex+i,colBIndex,colB.m_shapeIndex+j,&contactCache); } } - return contactCache.numAddedPoints; } - - return 0; + return contactCache.numAddedPoints; } void RealTimeBullet3CollisionSdk::collideWorld(plCollisionWorldHandle worldHandle, @@ -476,4 +476,4 @@ void RealTimeBullet3CollisionSdk::collideWorld(plCollisionWorldHandle worldHandl plCollisionSdkHandle RealTimeBullet3CollisionSdk::createRealTimeBullet3CollisionSdkHandle() { return (plCollisionSdkHandle) new RealTimeBullet3CollisionSdk(); -} \ No newline at end of file +} diff --git a/examples/CommonInterfaces/CommonCallbacks.h b/examples/CommonInterfaces/CommonCallbacks.h index 3047d143e2..e523bdf691 100644 --- a/examples/CommonInterfaces/CommonCallbacks.h +++ b/examples/CommonInterfaces/CommonCallbacks.h @@ -41,7 +41,7 @@ enum B3G_SHIFT, B3G_CONTROL, B3G_ALT, - B3G_RETURN, + B3G_RETURN }; diff --git a/examples/CommonInterfaces/CommonDeformableBodyBase.h b/examples/CommonInterfaces/CommonDeformableBodyBase.h index 90dbf8f06f..521dce344c 100644 --- a/examples/CommonInterfaces/CommonDeformableBodyBase.h +++ b/examples/CommonInterfaces/CommonDeformableBodyBase.h @@ -28,7 +28,7 @@ struct CommonDeformableBodyBase : public CommonMultiBodyBase m_mouseForce(0), m_pickingForceElasticStiffness(100), m_pickingForceDampingStiffness(0.0), - m_maxPickingForce(0.3) + m_maxPickingForce(btScalar(0.3)) { } diff --git a/examples/CommonInterfaces/CommonExampleInterface.h b/examples/CommonInterfaces/CommonExampleInterface.h index fc4e05ce89..f0efa4e50a 100644 --- a/examples/CommonInterfaces/CommonExampleInterface.h +++ b/examples/CommonInterfaces/CommonExampleInterface.h @@ -48,17 +48,17 @@ class CommonExampleInterface virtual void renderScene() = 0; virtual void physicsDebugDraw(int debugFlags) = 0; //for now we reuse the flags in Bullet/src/LinearMath/btIDebugDraw.h //reset camera is only called when switching demo. this way you can restart (initPhysics) and watch in a specific location easier - virtual void resetCamera(){}; + virtual void resetCamera(){} virtual bool mouseMoveCallback(float x, float y) = 0; virtual bool mouseButtonCallback(int button, int state, float x, float y) = 0; virtual bool keyboardCallback(int key, int state) = 0; - virtual void vrControllerMoveCallback(int controllerId, float pos[4], float orientation[4], float analogAxis, float auxAnalogAxes[10]) {} - virtual void vrControllerButtonCallback(int controllerId, int button, int state, float pos[4], float orientation[4]) {} - virtual void vrHMDMoveCallback(int controllerId, float pos[4], float orientation[4]) {} - virtual void vrGenericTrackerMoveCallback(int controllerId, float pos[4], float orientation[4]) {} + virtual void vrControllerMoveCallback(int /*controllerId*/, float /*pos*/[4], float /*orientation*/[4], float /*analogAxis*/, float /*auxAnalogAxes*/[10]) {} + virtual void vrControllerButtonCallback(int /*controllerId*/, int /*button*/, int /*state*/, float /*pos*/[4], float /*orientation*/[4]) {} + virtual void vrHMDMoveCallback(int /*controllerId*/, float /*pos*/[4], float /*orientation*/[4]) {} + virtual void vrGenericTrackerMoveCallback(int /*controllerId*/, float /*pos*/[4], float /*orientation*/[4]) {} - virtual void processCommandLineArgs(int argc, char* argv[]){}; + virtual void processCommandLineArgs(int /*argc*/, char* /*argv*/[]){} }; class ExampleEntries diff --git a/examples/CommonInterfaces/CommonFileIOInterface.h b/examples/CommonInterfaces/CommonFileIOInterface.h index beb25edd6b..835bd7d25b 100644 --- a/examples/CommonInterfaces/CommonFileIOInterface.h +++ b/examples/CommonInterfaces/CommonFileIOInterface.h @@ -25,4 +25,4 @@ struct CommonFileIOInterface virtual void enableFileCaching(bool enable) = 0; }; -#endif //COMMON_FILE_IO_INTERFACE_H \ No newline at end of file +#endif //COMMON_FILE_IO_INTERFACE_H diff --git a/examples/CommonInterfaces/CommonGUIHelperInterface.h b/examples/CommonInterfaces/CommonGUIHelperInterface.h index 2d4500374d..41eb0933a3 100644 --- a/examples/CommonInterfaces/CommonGUIHelperInterface.h +++ b/examples/CommonInterfaces/CommonGUIHelperInterface.h @@ -31,8 +31,8 @@ struct GUIHelperInterface virtual void createCollisionShapeGraphicsObject(btCollisionShape* collisionShape) = 0; virtual void syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWorld) = 0; - virtual void syncPhysicsToGraphics2(const btDiscreteDynamicsWorld* rbWorld) {} - virtual void syncPhysicsToGraphics2(const GUISyncPosition* positions, int numPositions) {} + virtual void syncPhysicsToGraphics2(const btDiscreteDynamicsWorld* /*rbWorld*/) {} + virtual void syncPhysicsToGraphics2(const GUISyncPosition* /*positions*/, int /*numPositions*/) {} virtual void render(const btDiscreteDynamicsWorld* rbWorld) = 0; @@ -42,17 +42,17 @@ struct GUIHelperInterface virtual int registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices, int primitiveType, int textureId) = 0; virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling) = 0; virtual void removeAllGraphicsInstances() = 0; - virtual void removeGraphicsInstance(int graphicsUid) {} - virtual void changeInstanceFlags(int instanceUid, int flags) {} - virtual void changeRGBAColor(int instanceUid, const double rgbaColor[4]) {} - virtual void changeScaling(int instanceUid, const double scaling[3]) {} - virtual void changeSpecularColor(int instanceUid, const double specularColor[3]) {} - virtual void changeTexture(int textureUniqueId, const unsigned char* rgbTexels, int width, int height) {} - virtual void updateShape(int shapeIndex, float* vertices, int numVertices) {} - virtual int getShapeIndexFromInstance(int instanceUid) { return -1; } - virtual void replaceTexture(int shapeIndex, int textureUid) {} - virtual void removeTexture(int textureUid) {} - virtual void setBackgroundColor(const double rgbBackground[3]) {} + virtual void removeGraphicsInstance(int /*graphicsUid*/) {} + virtual void changeInstanceFlags(int /*instanceUid*/, int /*flags*/) {} + virtual void changeRGBAColor(int /*instanceUid*/, const double /*rgbaColor*/[4]) {} + virtual void changeScaling(int /*instanceUid*/, const double /*scaling*/[3]) {} + virtual void changeSpecularColor(int /*instanceUid*/, const double /*specularColor*/[3]) {} + virtual void changeTexture(int /*textureUniqueId*/, const unsigned char* /*rgbTexels*/, int /*width*/, int /*height*/) {} + virtual void updateShape(int /*shapeIndex*/, float* /*vertices*/, int /*numVertices*/) {} + virtual int getShapeIndexFromInstance(int /*instanceUid*/) { return -1; } + virtual void replaceTexture(int /*shapeIndex*/, int /*textureUid*/) {} + virtual void removeTexture(int /*textureUid*/) {} + virtual void setBackgroundColor(const double /*rgbBackground*/[3]) {} virtual Common2dCanvasInterface* get2dCanvasInterface() = 0; @@ -72,12 +72,12 @@ struct GUIHelperInterface virtual void resetCamera(float camDist, float yaw, float pitch, float camPosX, float camPosY, float camPosZ) = 0; - virtual bool getCameraInfo(int* width, int* height, float viewMatrix[16], float projectionMatrix[16], float camUp[3], float camForward[3], float hor[3], float vert[3], float* yaw, float* pitch, float* camDist, float camTarget[3]) const + virtual bool getCameraInfo(int* /*width*/, int* /*height*/, float /*viewMatrix*/[16], float /*projectionMatrix*/[16], float /*camUp*/[3], float /*camForward*/[3], float /*hor*/[3], float /*vert*/[3], float* /*yaw*/, float* /*pitch*/, float* /*camDist*/, float /*camTarget*/[3]) const { return false; } - virtual void setVisualizerFlag(int flag, int enable){}; + virtual void setVisualizerFlag(int /*flag*/, int /*enable*/){} virtual void copyCameraImageData(const float viewMatrix[16], const float projectionMatrix[16], unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels, @@ -96,34 +96,34 @@ struct GUIHelperInterface float* depthBuffer, int depthBufferSizeInPixels, int* segmentationMaskBuffer, int segmentationMaskBufferSizeInPixels, int startPixelIndex, int destinationWidth, int destinationHeight, int* numPixelsCopied) = 0; - virtual void debugDisplayCameraImageData(const float viewMatrix[16], const float projectionMatrix[16], - unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels, - float* depthBuffer, int depthBufferSizeInPixels, - int* segmentationMaskBuffer, int segmentationMaskBufferSizeInPixels, - int startPixelIndex, int destinationWidth, int destinationHeight, int* numPixelsCopied) {} + virtual void debugDisplayCameraImageData(const float /*viewMatrix*/[16], const float /*projectionMatrix*/[16], + unsigned char* /*pixelsRGBA*/, int /*rgbaBufferSizeInPixels*/, + float* /*depthBuffer*/, int /*depthBufferSizeInPixels*/, + int* /*segmentationMaskBuffer*/, int /*segmentationMaskBufferSizeInPixels*/, + int /*startPixelIndex*/, int /*destinationWidth*/, int /*destinationHeight*/, int* /*numPixelsCopied*/) {} - virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16]) {} - virtual void setProjectiveTexture(bool useProjectiveTexture) {} + virtual void setProjectiveTextureMatrices(const float /*viewMatrix*/[16], const float /*projectionMatrix*/[16]) {} + virtual void setProjectiveTexture(bool /*useProjectiveTexture*/) {} virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) = 0; - virtual void drawText3D(const char* txt, float posX, float posY, float posZ, float size) {} - virtual void drawText3D(const char* txt, float position[3], float orientation[4], float color[4], float size, int optionFlag) {} + virtual void drawText3D(const char* /*txt*/, float /*posX*/, float /*posY*/, float /*posZ*/, float /*size*/) {} + virtual void drawText3D(const char* /*txt*/, float /*position*/[3], float /*orientation*/[4], float /*color*/[4], float /*size*/, int /*optionFlag*/) {} - virtual int addUserDebugText3D(const char* txt, const double positionXYZ[3], const double orientation[4], const double textColorRGB[3], double size, double lifeTime, int trackingVisualShapeIndex, int optionFlags, int replaceItemUid) { return -1; } - virtual int addUserDebugLine(const double debugLineFromXYZ[3], const double debugLineToXYZ[3], const double debugLineColorRGB[3], double lineWidth, double lifeTime, int trackingVisualShapeIndex, int replaceItemUid) { return -1; }; - virtual int addUserDebugPoints(const double debugPointPositionXYZ[], const double debugPointColorRGB[3], double pointSize, double lifeTime, int trackingVisualShapeIndex, int replaceItemUid, int debugPointNum) { return -1; }; - virtual int addUserDebugParameter(const char* txt, double rangeMin, double rangeMax, double startValue) { return -1; }; - virtual int readUserDebugParameter(int itemUniqueId, double* value) { return 0; } + virtual int addUserDebugText3D(const char* /*txt*/, const double /*positionXYZ*/[3], const double /*orientation*/[4], const double /*textColorRGB*/[3], double /*size*/, double /*lifeTime*/, int /*trackingVisualShapeIndex*/, int /*optionFlags*/, int /*replaceItemUid*/) { return -1; } + virtual int addUserDebugLine(const double /*debugLineFromXYZ*/[3], const double /*debugLineToXYZ*/[3], const double /*debugLineColorRGB*/[3], double /*lineWidth*/, double /*lifeTime*/, int /*trackingVisualShapeIndex*/, int /*replaceItemUid*/) { return -1; } + virtual int addUserDebugPoints(const double /*debugPointPositionXYZ*/[], const double /*debugPointColorRGB*/[3], double /*pointSize*/, double /*lifeTime*/, int /*trackingVisualShapeIndex*/, int /*replaceItemUid*/, int /*debugPointNum*/) { return -1; } + virtual int addUserDebugParameter(const char* /*txt*/, double /*rangeMin*/, double /*rangeMax*/, double /*startValue*/) { return -1; } + virtual int readUserDebugParameter(int /*itemUniqueId*/, double* /*value*/) { return 0; } - virtual void removeUserDebugItem(int debugItemUniqueId){}; - virtual void removeAllUserDebugItems(){}; - virtual void removeAllUserParameters() {}; + virtual void removeUserDebugItem(int /*debugItemUniqueId*/){} + virtual void removeAllUserDebugItems(){} + virtual void removeAllUserParameters() {} - virtual void setVisualizerFlagCallback(VisualizerFlagCallback callback) {} + virtual void setVisualizerFlagCallback(VisualizerFlagCallback /*callback*/) {} //empty name stops dumping video - virtual void dumpFramesToVideo(const char* mp4FileName){}; + virtual void dumpFramesToVideo(const char* /*mp4FileName*/){} virtual void drawDebugDrawerLines(){} virtual void clearLines(){} virtual bool isRemoteVisualizer() { return false; } @@ -138,25 +138,25 @@ struct DummyGUIHelper : public GUIHelperInterface } virtual ~DummyGUIHelper() {} - virtual void createRigidBodyGraphicsObject(btRigidBody* body, const btVector3& color) {} + virtual void createRigidBodyGraphicsObject(btRigidBody* /*body*/, const btVector3& /*color*/) {} - virtual void createCollisionObjectGraphicsObject(btCollisionObject* obj, const btVector3& color) {} + virtual void createCollisionObjectGraphicsObject(btCollisionObject* /*obj*/, const btVector3& /*color*/) {} - virtual void createCollisionShapeGraphicsObject(btCollisionShape* collisionShape) {} + virtual void createCollisionShapeGraphicsObject(btCollisionShape* /*collisionShape*/) {} - virtual void syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWorld) {} + virtual void syncPhysicsToGraphics(const btDiscreteDynamicsWorld* /*rbWorld*/) {} - virtual void render(const btDiscreteDynamicsWorld* rbWorld) {} + virtual void render(const btDiscreteDynamicsWorld* /*rbWorld*/) {} - virtual void createPhysicsDebugDrawer(btDiscreteDynamicsWorld* rbWorld) {} + virtual void createPhysicsDebugDrawer(btDiscreteDynamicsWorld* /*rbWorld*/) {} - virtual int registerTexture(const unsigned char* texels, int width, int height) { return -1; } - virtual int registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices, int primitiveType, int textureId) { return -1; } - virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling) { return -1; } + virtual int registerTexture(const unsigned char* /*texels*/, int /*width*/, int /*height*/) { return -1; } + virtual int registerGraphicsShape(const float* /*vertices*/, int /*numvertices*/, const int* /*indices*/, int /*numIndices*/, int /*primitiveType*/, int /*textureId*/) { return -1; } + virtual int registerGraphicsInstance(int /*shapeIndex*/, const float* /*position*/, const float* /*quaternion*/, const float* /*color*/, const float* /*scaling*/) { return -1; } virtual void removeAllGraphicsInstances() {} - virtual void removeGraphicsInstance(int graphicsUid) {} - virtual void changeRGBAColor(int instanceUid, const double rgbaColor[4]) {} - virtual void changeScaling(int instanceUid, const double scaling[3]) {} + virtual void removeGraphicsInstance(int /*graphicsUid*/) {} + virtual void changeRGBAColor(int /*instanceUid*/, const double /*rgbaColor*/[4]) {} + virtual void changeScaling(int /*instanceUid*/, const double /*scaling*/[3]) {} virtual Common2dCanvasInterface* get2dCanvasInterface() { @@ -178,53 +178,53 @@ struct DummyGUIHelper : public GUIHelperInterface return 0; } - virtual void setUpAxis(int axis) + virtual void setUpAxis(int /*axis*/) { } - virtual void resetCamera(float camDist, float yaw, float pitch, float camPosX, float camPosY, float camPosZ) + virtual void resetCamera(float /*camDist*/, float /*yaw*/, float /*pitch*/, float /*camPosX*/, float /*camPosY*/, float /*camPosZ*/) { } - virtual void copyCameraImageData(const float viewMatrix[16], const float projectionMatrix[16], - unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels, - float* depthBuffer, int depthBufferSizeInPixels, - int* segmentationMaskBuffer, int segmentationMaskBufferSizeInPixels, - int startPixelIndex, int width, int height, int* numPixelsCopied) + virtual void copyCameraImageData(const float /*viewMatrix*/[16], const float /*projectionMatrix*/[16], + unsigned char* /*pixelsRGBA*/, int /*rgbaBufferSizeInPixels*/, + float* /*depthBuffer*/, int /*depthBufferSizeInPixels*/, + int* /*segmentationMaskBuffer*/, int /*segmentationMaskBufferSizeInPixels*/, + int /*startPixelIndex*/, int /*width*/, int /*height*/, int* numPixelsCopied) { if (numPixelsCopied) *numPixelsCopied = 0; } - virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16]) + virtual void setProjectiveTextureMatrices(const float /*viewMatrix*/[16], const float /*projectionMatrix*/[16]) { } - virtual void setProjectiveTexture(bool useProjectiveTexture) + virtual void setProjectiveTexture(bool /*useProjectiveTexture*/) { } - virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) + virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* /*rbWorld*/) { } - virtual void drawText3D(const char* txt, float posX, float posZY, float posZ, float size) + virtual void drawText3D(const char* /*txt*/, float /*posX*/, float /*posZY*/, float /*posZ*/, float /*size*/) { } - virtual void drawText3D(const char* txt, float position[3], float orientation[4], float color[4], float size, int optionFlag) + virtual void drawText3D(const char* /*txt*/, float /*position*/[3], float /*orientation*/[4], float /*color*/[4], float /*size*/, int /*optionFlag*/) { } - virtual int addUserDebugLine(const double debugLineFromXYZ[3], const double debugLineToXYZ[3], const double debugLineColorRGB[3], double lineWidth, double lifeTime, int trackingVisualShapeIndex, int replaceItemUid) + virtual int addUserDebugLine(const double /*debugLineFromXYZ*/[3], const double /*debugLineToXYZ*/[3], const double /*debugLineColorRGB*/[3], double /*lineWidth*/, double /*lifeTime*/, int /*trackingVisualShapeIndex*/, int /*replaceItemUid*/) { return -1; } - virtual int addUserDebugPoints(const double debugPointPositionXYZ[3], const double debugPointColorRGB[3], double pointSize, double lifeTime, int trackingVisualShapeIndex, int replaceItemUid, int debugPointNum) + virtual int addUserDebugPoints(const double /*debugPointPositionXYZ*/[3], const double /*debugPointColorRGB*/[3], double /*pointSize*/, double /*lifeTime*/, int /*trackingVisualShapeIndex*/, int /*replaceItemUid*/, int /*debugPointNum*/) { return -1; - }; - virtual void removeUserDebugItem(int debugItemUniqueId) + } + virtual void removeUserDebugItem(int /*debugItemUniqueId*/) { } virtual void removeAllUserDebugItems() diff --git a/examples/CommonInterfaces/CommonGraphicsAppInterface.h b/examples/CommonInterfaces/CommonGraphicsAppInterface.h index a3d9d3eac6..3608f069c7 100644 --- a/examples/CommonInterfaces/CommonGraphicsAppInterface.h +++ b/examples/CommonInterfaces/CommonGraphicsAppInterface.h @@ -30,7 +30,7 @@ enum EnumSphereLevelOfDetail SPHERE_LOD_POINT_SPRITE = 0, SPHERE_LOD_LOW, SPHERE_LOD_MEDIUM, - SPHERE_LOD_HIGH, + SPHERE_LOD_HIGH }; struct CommonGraphicsApp @@ -39,7 +39,7 @@ struct CommonGraphicsApp { eDrawText3D_OrtogonalFaceCamera = 1, eDrawText3D_TrueType = 2, - eDrawText3D_TrackObject = 4, + eDrawText3D_TrackObject = 4 }; class CommonWindowInterface* m_window; struct CommonRenderInterface* m_renderer; @@ -70,19 +70,19 @@ struct CommonGraphicsApp m_mouseYpos(0.f), m_mouseInitialized(false) { - m_backgroundColorRGB[0] = 0.7; - m_backgroundColorRGB[1] = 0.7; - m_backgroundColorRGB[2] = 0.8; + m_backgroundColorRGB[0] = 0.7f; + m_backgroundColorRGB[1] = 0.7f; + m_backgroundColorRGB[2] = 0.8f; } virtual ~CommonGraphicsApp() { } - virtual void dumpNextFrameToPng(const char* pngFilename) {} - virtual void dumpFramesToVideo(const char* mp4Filename) {} + virtual void dumpNextFrameToPng(const char* /*pngFilename*/) {} + virtual void dumpFramesToVideo(const char* /*mp4Filename*/) {} - virtual void getScreenPixels(unsigned char* rgbaBuffer, int bufferSizeInBytes, float* depthBuffer, int depthBufferSizeInBytes) {} - virtual void setViewport(int width, int height) {} + virtual void getScreenPixels(unsigned char* /*rgbaBuffer*/, int /*bufferSizeInBytes*/, float* /*depthBuffer*/, int /*depthBufferSizeInBytes*/) {} + virtual void setViewport(int /*width*/, int /*height*/) {} virtual void getBackgroundColor(float* red, float* green, float* blue) const { @@ -93,7 +93,7 @@ struct CommonGraphicsApp if (blue) *blue = m_backgroundColorRGB[2]; } - virtual void setMp4Fps(int fps) {} + virtual void setMp4Fps(int /*fps*/) {} virtual void setBackgroundColor(float red, float green, float blue) { m_backgroundColorRGB[0] = red; @@ -205,12 +205,12 @@ struct CommonGraphicsApp if (m_middleMouseButton) { - cameraTargetPosition += cameraUp * yDelta *m_mouseMoveMultiplier* 0.01; + cameraTargetPosition += cameraUp * yDelta *m_mouseMoveMultiplier* 0.01f; b3Vector3 fwd = cameraTargetPosition - cameraPosition; b3Vector3 side = cameraUp.cross(fwd); side.normalize(); - cameraTargetPosition += side * xDelta *m_mouseMoveMultiplier* 0.01; + cameraTargetPosition += side * xDelta *m_mouseMoveMultiplier* 0.01f; } if (m_rightMouseButton) { diff --git a/examples/CommonInterfaces/CommonMultiBodyBase.h b/examples/CommonInterfaces/CommonMultiBodyBase.h index ad6c2a4c68..eda92dab7f 100644 --- a/examples/CommonInterfaces/CommonMultiBodyBase.h +++ b/examples/CommonInterfaces/CommonMultiBodyBase.h @@ -102,7 +102,7 @@ struct CommonMultiBodyBase : public CommonExampleInterface //m_collisionConfiguration->setConvexConvexMultipointIterations(); m_filterCallback = new MyOverlapFilterCallback2(); - ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) + ///use the default collision dispatcher. For parallel processing you can use a different dispatcher (see Extras/BulletMultiThreaded) m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_pairCache = new btHashedOverlappingPairCache(); @@ -234,7 +234,7 @@ struct CommonMultiBodyBase : public CommonExampleInterface m_dynamicsWorld->serialize(serializer); FILE* file = fopen("testFile.bullet", "wb"); - fwrite(serializer->getBufferPointer(), serializer->getCurrentBufferSize(), 1, file); + fwrite(serializer->getBufferPointer(), (size_t)serializer->getCurrentBufferSize(), 1, file); fclose(file); //b3Printf("btDefaultSerializer wrote testFile.bullet"); delete serializer; @@ -257,7 +257,7 @@ struct CommonMultiBodyBase : public CommonExampleInterface float bottom = -1.f; float nearPlane = 1.f; float tanFov = (top - bottom) * 0.5f / nearPlane; - float fov = btScalar(2.0) * btAtan(tanFov); + float fov = float(btScalar(2.0) * btAtan(tanFov)); btVector3 camPos, camTarget; renderer->getActiveCamera()->getCameraPosition(camPos); @@ -490,13 +490,14 @@ struct CommonMultiBodyBase : public CommonExampleInterface btRigidBody* createRigidBody(float mass, const btTransform& startTransform, btCollisionShape* shape, const btVector4& color = btVector4(1, 0, 0, 1)) { + (void)color; btAssert((!shape || shape->getShapeType() != INVALID_SHAPE_PROXYTYPE)); //rigidbody is dynamic if and only if mass is non zero, otherwise static bool isDynamic = (mass != 0.f); btVector3 localInertia(0, 0, 0); - if (isDynamic) + if (isDynamic && shape) shape->calculateLocalInertia(mass, localInertia); //using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects diff --git a/examples/CommonInterfaces/CommonRenderInterface.h b/examples/CommonInterfaces/CommonRenderInterface.h index 01f5499edd..ffc80168db 100644 --- a/examples/CommonInterfaces/CommonRenderInterface.h +++ b/examples/CommonInterfaces/CommonRenderInterface.h @@ -13,7 +13,7 @@ enum { B3_INSTANCE_TRANSPARANCY = 1, B3_INSTANCE_TEXTURE = 2, - B3_INSTANCE_DOUBLE_SIDED = 4, + B3_INSTANCE_DOUBLE_SIDED = 4 }; enum @@ -25,7 +25,7 @@ enum B3_USE_SHADOWMAP_RENDERMODE_REFLECTION, B3_USE_SHADOWMAP_RENDERMODE_REFLECTION_PLANE, B3_USE_PROJECTIVE_TEXTURE_RENDERMODE, - B3_SEGMENTATION_MASK_RENDERMODE, + B3_SEGMENTATION_MASK_RENDERMODE }; struct GfxVertexFormat0 @@ -63,11 +63,11 @@ struct CommonRenderInterface virtual void setShadowMapWorldSize(float worldSize) = 0; - virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16]){}; - virtual void setProjectiveTexture(bool useProjectiveTexture){}; + virtual void setProjectiveTextureMatrices(const float /*viewMatrix*/[16], const float /*projectionMatrix*/[16]){} + virtual void setProjectiveTexture(bool /*useProjectiveTexture*/){} virtual void renderScene() = 0; - virtual void renderSceneInternal(int renderMode = B3_DEFAULT_RENDERMODE){}; + virtual void renderSceneInternal(int renderMode = B3_DEFAULT_RENDERMODE){ (void)renderMode; } virtual int getScreenWidth() = 0; virtual int getScreenHeight() = 0; @@ -89,12 +89,12 @@ struct CommonRenderInterface virtual int registerTexture(const unsigned char* texels, int width, int height, bool flipPixelsY = true) = 0; virtual void updateTexture(int textureIndex, const unsigned char* texels, bool flipPixelsY = true) = 0; virtual void activateTexture(int textureIndex) = 0; - virtual void replaceTexture(int shapeIndex, int textureIndex){}; + virtual void replaceTexture(int /*shapeIndex*/, int /*textureIndex*/){} virtual void removeTexture(int textureIndex) = 0; - virtual void setPlaneReflectionShapeIndex(int index) {} + virtual void setPlaneReflectionShapeIndex(int /*index*/) {} - virtual int getShapeIndexFromInstance(int srcIndex) { return -1; } + virtual int getShapeIndexFromInstance(int /*srcIndex*/) { return -1; } virtual bool readSingleInstanceTransformToCPU(float* position, float* orientation, int srcIndex) = 0; @@ -158,8 +158,8 @@ inline int projectWorldCoordToScreen(T objx, T objy, T objz, out[2] = out[2] * T(0.5) + T(0.5); /* Map x,y to viewport */ - out[0] = out[0] * viewport[2] + viewport[0]; - out[1] = out[1] * viewport[3] + viewport[1]; + out[0] = out[0] * (T)viewport[2] + (T)viewport[0]; + out[1] = out[1] * (T)viewport[3] + (T)viewport[1]; *winx = out[0]; *winy = out[1]; diff --git a/examples/CommonInterfaces/CommonRigidBodyBase.h b/examples/CommonInterfaces/CommonRigidBodyBase.h index 98352bcd3b..a3d79965b0 100644 --- a/examples/CommonInterfaces/CommonRigidBodyBase.h +++ b/examples/CommonInterfaces/CommonRigidBodyBase.h @@ -56,7 +56,7 @@ struct CommonRigidBodyBase : public CommonExampleInterface m_collisionConfiguration = new btDefaultCollisionConfiguration(); //m_collisionConfiguration->setConvexConvexMultipointIterations(); - ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) + ///use the default collision dispatcher. For parallel processing you can use a different dispatcher (see Extras/BulletMultiThreaded) m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); @@ -74,7 +74,7 @@ struct CommonRigidBodyBase : public CommonExampleInterface { if (m_dynamicsWorld) { - m_dynamicsWorld->stepSimulation(deltaTime); + m_dynamicsWorld->stepSimulation((btScalar)deltaTime); } } @@ -157,7 +157,7 @@ struct CommonRigidBodyBase : public CommonExampleInterface m_dynamicsWorld->serialize(serializer); FILE* file = fopen("testFile.bullet", "wb"); - fwrite(serializer->getBufferPointer(), serializer->getCurrentBufferSize(), 1, file); + fwrite(serializer->getBufferPointer(), (size_t)serializer->getCurrentBufferSize(), 1, file); fclose(file); //b3Printf("btDefaultSerializer wrote testFile.bullet"); delete serializer; @@ -180,7 +180,7 @@ struct CommonRigidBodyBase : public CommonExampleInterface float bottom = -1.f; float nearPlane = 1.f; float tanFov = (top - bottom) * 0.5f / nearPlane; - float fov = btScalar(2.0) * btAtan(tanFov); + float fov = float(btScalar(2.0) * btAtan((btScalar)tanFov)); btVector3 camPos, camTarget; @@ -191,7 +191,7 @@ struct CommonRigidBodyBase : public CommonExampleInterface btVector3 rayForward = (camTarget - camPos); rayForward.normalize(); float farPlane = 10000.f; - rayForward *= farPlane; + rayForward *= (btScalar)farPlane; btVector3 rightOffset; btVector3 cameraUp = btVector3(0, 0, 0); @@ -406,13 +406,14 @@ struct CommonRigidBodyBase : public CommonExampleInterface btRigidBody* createRigidBody(float mass, const btTransform& startTransform, btCollisionShape* shape, const btVector4& color = btVector4(1, 0, 0, 1)) { + (void)color; btAssert((!shape || shape->getShapeType() != INVALID_SHAPE_PROXYTYPE)); //rigidbody is dynamic if and only if mass is non zero, otherwise static bool isDynamic = (mass != 0.f); btVector3 localInertia(0, 0, 0); - if (isDynamic) + if (isDynamic && shape) shape->calculateLocalInertia(mass, localInertia); //using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects diff --git a/examples/Constraints/ConstraintDemo.cpp b/examples/Constraints/ConstraintDemo.cpp index 704b9779db..bde4d6289f 100644 --- a/examples/Constraints/ConstraintDemo.cpp +++ b/examples/Constraints/ConstraintDemo.cpp @@ -62,15 +62,15 @@ class AllConstraintDemo : public CommonRigidBodyBase #define SIMD_PI_2 ((SIMD_PI)*0.5f) #define SIMD_PI_4 ((SIMD_PI)*0.25f) -btTransform sliderTransform; -btVector3 lowerSliderLimit = btVector3(-10, 0, 0); -btVector3 hiSliderLimit = btVector3(10, 0, 0); +static btTransform sliderTransform; +static btVector3 lowerSliderLimit = btVector3(-10, 0, 0); +static btVector3 hiSliderLimit = btVector3(10, 0, 0); -btRigidBody* d6body0 = 0; +static btRigidBody* d6body0 = 0; -btHingeConstraint* spDoorHinge = NULL; -btHingeConstraint* spHingeDynAB = NULL; -btGeneric6DofConstraint* spSlider6Dof = NULL; +static btHingeConstraint* spDoorHinge = NULL; +static btHingeConstraint* spHingeDynAB = NULL; +static btGeneric6DofConstraint* spSlider6Dof = NULL; static bool s_bTestConeTwistMotor = false; @@ -102,6 +102,7 @@ void AllConstraintDemo::initPhysics() groundTransform.setOrigin(btVector3(0, -56, 0)); btRigidBody* groundBody; groundBody = createRigidBody(0, groundTransform, groundShape); + (void)groundBody; btCollisionShape* shape = new btBoxShape(btVector3(CUBE_HALF_EXTENTS, CUBE_HALF_EXTENTS, CUBE_HALF_EXTENTS)); m_collisionShapes.push_back(shape); @@ -123,16 +124,16 @@ void AllConstraintDemo::initPhysics() btRigidBody* bodyB = 0; { - btCollisionShape* cylA = new btCylinderShape(btVector3(0.2, 0.25, 0.2)); - btCollisionShape* cylB = new btCylinderShape(btVector3(L_1, 0.025, L_1)); + btCollisionShape* cylA = new btCylinderShape(btVector3(btScalar(0.2), btScalar(0.25), btScalar(0.2))); + btCollisionShape* cylB = new btCylinderShape(btVector3(btScalar(L_1), btScalar(0.025), btScalar(L_1))); btCompoundShape* cyl0 = new btCompoundShape(); cyl0->addChildShape(btTransform::getIdentity(), cylA); cyl0->addChildShape(btTransform::getIdentity(), cylB); - btScalar mass = 6.28; + btScalar massL = btScalar(6.28); btVector3 localInertia; - cyl0->calculateLocalInertia(mass, localInertia); - btRigidBody::btRigidBodyConstructionInfo ci(mass, 0, cyl0, localInertia); + cyl0->calculateLocalInertia(massL, localInertia); + btRigidBody::btRigidBodyConstructionInfo ci(massL, 0, cyl0, localInertia); ci.m_startWorldTransform.setOrigin(btVector3(-8, 1, -8)); btRigidBody* body = new btRigidBody(ci); //1,0,cyl0,localInertia); @@ -143,16 +144,16 @@ void AllConstraintDemo::initPhysics() } { - btCollisionShape* cylA = new btCylinderShape(btVector3(0.2, 0.26, 0.2)); - btCollisionShape* cylB = new btCylinderShape(btVector3(L_2, 0.025, L_2)); + btCollisionShape* cylA = new btCylinderShape(btVector3(btScalar(0.2), btScalar(0.26), btScalar(0.2))); + btCollisionShape* cylB = new btCylinderShape(btVector3(btScalar(L_2), btScalar(0.025), btScalar(L_2))); btCompoundShape* cyl0 = new btCompoundShape(); cyl0->addChildShape(btTransform::getIdentity(), cylA); cyl0->addChildShape(btTransform::getIdentity(), cylB); - btScalar mass = 6.28; + btScalar massL = btScalar(6.28); btVector3 localInertia; - cyl0->calculateLocalInertia(mass, localInertia); - btRigidBody::btRigidBodyConstructionInfo ci(mass, 0, cyl0, localInertia); + cyl0->calculateLocalInertia(massL, localInertia); + btRigidBody::btRigidBodyConstructionInfo ci(massL, 0, cyl0, localInertia); ci.m_startWorldTransform.setOrigin(btVector3(-10, 2, -8)); btQuaternion orn(btVector3(0, 0, 1), -THETA); @@ -194,7 +195,7 @@ void AllConstraintDemo::initPhysics() btVector3 pivotInA(CUBE_HALF_EXTENTS, CUBE_HALF_EXTENTS, 0); btTypedConstraint* p2p = new btPoint2PointConstraint(*body0, pivotInA); m_dynamicsWorld->addConstraint(p2p); - p2p->setBreakingImpulseThreshold(10.2); + p2p->setBreakingImpulseThreshold(btScalar(10.2)); p2p->setDbgDrawSize(btScalar(5.f)); } #endif @@ -243,23 +244,23 @@ void AllConstraintDemo::initPhysics() #if ENABLE_ALL_DEMOS { - btTransform trans; - trans.setIdentity(); + btTransform transform; + transform.setIdentity(); btVector3 worldPos(-20, 0, 30); - trans.setOrigin(worldPos); + transform.setOrigin(worldPos); btTransform frameInA, frameInB; frameInA = btTransform::getIdentity(); frameInB = btTransform::getIdentity(); - btRigidBody* pRbA1 = createRigidBody(mass, trans, shape); + btRigidBody* pRbA1 = createRigidBody(mass, transform, shape); // btRigidBody* pRbA1 = createRigidBody(0.f, trans, shape); pRbA1->setActivationState(DISABLE_DEACTIVATION); // add dynamic rigid body B1 worldPos.setValue(-30, 0, 30); - trans.setOrigin(worldPos); - btRigidBody* pRbB1 = createRigidBody(mass, trans, shape); + transform.setOrigin(worldPos); + btRigidBody* pRbB1 = createRigidBody(mass, transform, shape); // btRigidBody* pRbB1 = createRigidBody(0.f, trans, shape); pRbB1->setActivationState(DISABLE_DEACTIVATION); @@ -590,11 +591,11 @@ void AllConstraintDemo::initPhysics() btRigidBody* pBodyB = createRigidBody(10.0, tr, shape); pBodyB->setActivationState(DISABLE_DEACTIVATION); // add some data to build constraint frames - btVector3 axisA(0.f, 1.f, 0.f); - btVector3 axisB(0.f, 1.f, 0.f); + btVector3 axisAL(0.f, 1.f, 0.f); + btVector3 axisBL(0.f, 1.f, 0.f); btVector3 pivotA(-5.f, 0.f, 0.f); btVector3 pivotB(5.f, 0.f, 0.f); - spHingeDynAB = new btHingeConstraint(*pBodyA, *pBodyB, pivotA, pivotB, axisA, axisB); + spHingeDynAB = new btHingeConstraint(*pBodyA, *pBodyB, pivotA, pivotB, axisAL, axisBL); spHingeDynAB->setLimit(-SIMD_HALF_PI * 0.5f, SIMD_HALF_PI * 0.5f); // add constraint to world m_dynamicsWorld->addConstraint(spHingeDynAB, true); @@ -791,7 +792,7 @@ void AllConstraintDemo::displayCallback(void) { } #endif -bool AllConstraintDemo::keyboardCallback(int key, int state) +bool AllConstraintDemo::keyboardCallback(int key, int /*state*/) { bool handled = false; diff --git a/examples/Constraints/ConstraintPhysicsSetup.cpp b/examples/Constraints/ConstraintPhysicsSetup.cpp index 40ce53eda5..bc22bc25b1 100644 --- a/examples/Constraints/ConstraintPhysicsSetup.cpp +++ b/examples/Constraints/ConstraintPhysicsSetup.cpp @@ -44,7 +44,7 @@ void ConstraintPhysicsSetup::stepSimulation(float deltaTime) { spDoorHinge->enableAngularMotor(true, targetVel, maxImpulse); - m_dynamicsWorld->stepSimulation(deltaTime, 10, 1. / 240.); + m_dynamicsWorld->stepSimulation(deltaTime, 10, btScalar(1. / 240.)); btHingeConstraint* hinge = spDoorHinge; diff --git a/examples/Constraints/Dof6Spring2Setup.cpp b/examples/Constraints/Dof6Spring2Setup.cpp index d5216a6238..d2d20421bd 100644 --- a/examples/Constraints/Dof6Spring2Setup.cpp +++ b/examples/Constraints/Dof6Spring2Setup.cpp @@ -76,7 +76,7 @@ struct Dof6Spring2SetupInternalData unsigned int frameID; Dof6Spring2SetupInternalData() - : mDt(1. / 60.), frameID(0) + : mDt(1.f / 60.f), frameID(0) { } }; @@ -193,7 +193,7 @@ void Dof6Spring2Setup::initPhysics() shape = new btBoxShape(btVector3(0.5, 0.5, 0.5)); shape->calculateLocalInertia(mass, localInertia); bodyTransform.setIdentity(); - bodyTransform.getBasis().setEulerZYX(0, 0, M_PI_2); + bodyTransform.getBasis().setEulerZYX(0, 0, btScalar(M_PI_2)); motionState = new btDefaultMotionState(bodyTransform); m_data->m_RotateSpringBody = new btRigidBody(mass, motionState, shape, localInertia); m_data->m_RotateSpringBody->setActivationState(DISABLE_DEACTIVATION); @@ -250,7 +250,7 @@ void Dof6Spring2Setup::initPhysics() #else //bounce is named restitution in 6dofspring, but not implemented for translational limit motor, so the following line has no effect constraint->getTranslationalLimitMotor()->m_restitution = 0.0; #endif - constraint->setParam(BT_CONSTRAINT_STOP_ERP, 0.995, 0); + constraint->setParam(BT_CONSTRAINT_STOP_ERP, btScalar(0.995), 0); constraint->setParam(BT_CONSTRAINT_STOP_CFM, 0.0, 0); constraint->setDbgDrawSize(btScalar(2.f)); m_dynamicsWorld->addConstraint(constraint, true); @@ -266,7 +266,7 @@ void Dof6Spring2Setup::initPhysics() #else //bounce is named restitution in 6dofspring, but not implemented for translational limit motor, so the following line has no effect constraint->getTranslationalLimitMotor()->m_restitution = 1.0; #endif - constraint->setParam(BT_CONSTRAINT_STOP_ERP, 0.995, 0); + constraint->setParam(BT_CONSTRAINT_STOP_ERP, btScalar(0.995), 0); constraint->setParam(BT_CONSTRAINT_STOP_CFM, 0.0, 0); constraint->setDbgDrawSize(btScalar(2.f)); m_dynamicsWorld->addConstraint(constraint, true); @@ -335,7 +335,7 @@ void Dof6Spring2Setup::initPhysics() constraint->setTargetVelocity(5, 3.f); constraint->setMaxMotorForce(5, 600.f); constraint->setServo(5, true); - constraint->setServoTarget(5, M_PI_2); + constraint->setServoTarget(5, btScalar(M_PI_2)); #else constraint->getRotationalLimitMotor(2)->m_enableMotor = true; constraint->getRotationalLimitMotor(2)->m_targetVelocity = 3.f; @@ -350,7 +350,7 @@ void Dof6Spring2Setup::initPhysics() ////////// chain of boxes linked together with fully limited rotational and translational constraints ////////// the chain will be pulled to the left and to the right periodically. They should strictly stick together. { - btScalar limitConstraintStrength = 0.6; + btScalar limitConstraintStrength = btScalar(0.6); int bodycount = 10; btRigidBody* prevBody = 0; for (int i = 0; i < bodycount; ++i) @@ -359,7 +359,7 @@ void Dof6Spring2Setup::initPhysics() shape = new btBoxShape(btVector3(0.5, 0.5, 0.5)); shape->calculateLocalInertia(mass, localInertia); bodyTransform.setIdentity(); - bodyTransform.setOrigin(btVector3(-i, 0, 3)); + bodyTransform.setOrigin(btVector3((btScalar)-i, 0, 3)); motionState = new btDefaultMotionState(bodyTransform); btRigidBody* body = new btRigidBody(mass, motionState, shape, localInertia); body->setActivationState(DISABLE_DEACTIVATION); @@ -368,28 +368,28 @@ void Dof6Spring2Setup::initPhysics() { localB.setIdentity(); localB.setOrigin(btVector3(0.5, 0, 0)); - btTransform localA; - localA.setIdentity(); - localA.setOrigin(btVector3(-0.5, 0, 0)); - CONSTRAINT_TYPE* constraint = new CONSTRAINT_TYPE(*prevBody, *body, localA, localB EXTRAPARAMS); - constraint->setLimit(0, -0.01, 0.01); - constraint->setLimit(1, 0, 0); - constraint->setLimit(2, 0, 0); - constraint->setLimit(3, 0, 0); - constraint->setLimit(4, 0, 0); - constraint->setLimit(5, 0, 0); + btTransform localAL; + localAL.setIdentity(); + localAL.setOrigin(btVector3(-0.5, 0, 0)); + CONSTRAINT_TYPE* constraintL = new CONSTRAINT_TYPE(*prevBody, *body, localA, localB EXTRAPARAMS); + constraintL->setLimit(0, btScalar(-0.01), btScalar(0.01)); + constraintL->setLimit(1, 0, 0); + constraintL->setLimit(2, 0, 0); + constraintL->setLimit(3, 0, 0); + constraintL->setLimit(4, 0, 0); + constraintL->setLimit(5, 0, 0); for (int a = 0; a < 6; ++a) { - constraint->setParam(BT_CONSTRAINT_STOP_ERP, 0.9, a); - constraint->setParam(BT_CONSTRAINT_STOP_CFM, 0.0, a); + constraintL->setParam(BT_CONSTRAINT_STOP_ERP, btScalar(0.9), a); + constraintL->setParam(BT_CONSTRAINT_STOP_CFM, 0.0, a); } - constraint->setDbgDrawSize(btScalar(1.f)); - m_dynamicsWorld->addConstraint(constraint, true); + constraintL->setDbgDrawSize(btScalar(1.f)); + m_dynamicsWorld->addConstraint(constraintL, true); if (i < bodycount - 1) { - localA.setIdentity(); - localA.getOrigin() = btVector3(0, 0, 3); + localAL.setIdentity(); + localAL.getOrigin() = btVector3(0, 0, 3); localB.setIdentity(); CONSTRAINT_TYPE* constraintZY = new CONSTRAINT_TYPE(*staticBody, *body, localA, localB EXTRAPARAMS); constraintZY->setLimit(0, 1, -1); @@ -400,7 +400,7 @@ void Dof6Spring2Setup::initPhysics() else { localA.setIdentity(); - localA.getOrigin() = btVector3(bodycount, 0, 3); + localA.getOrigin() = btVector3((btScalar)bodycount, 0, 3); localB.setIdentity(); localB.setOrigin(btVector3(0, 0, 0)); m_data->m_ChainLeftBody = body; @@ -420,7 +420,7 @@ void Dof6Spring2Setup::initPhysics() } m_data->m_ChainRightBody = prevBody; localA.setIdentity(); - localA.getOrigin() = btVector3(-bodycount, 0, 3); + localA.getOrigin() = btVector3((btScalar)-bodycount, 0, 3); localB.setIdentity(); localB.setOrigin(btVector3(0, 0, 0)); m_data->m_ChainRightConstraint = new CONSTRAINT_TYPE(*staticBody, *m_data->m_ChainRightBody, localA, localB EXTRAPARAMS); diff --git a/examples/Constraints/TestHingeTorque.cpp b/examples/Constraints/TestHingeTorque.cpp index f422e219e7..f1bec3fe0d 100644 --- a/examples/Constraints/TestHingeTorque.cpp +++ b/examples/Constraints/TestHingeTorque.cpp @@ -3,9 +3,9 @@ #include "../CommonInterfaces/CommonRigidBodyBase.h" #include "../CommonInterfaces/CommonParameterInterface.h" -int collisionFilterGroup = int(btBroadphaseProxy::CharacterFilter); -int collisionFilterMask = int(btBroadphaseProxy::AllFilter ^ (btBroadphaseProxy::CharacterFilter)); -static btScalar radius(0.2); +static int collisionFilterGroup = int(btBroadphaseProxy::CharacterFilter); +static int collisionFilterMask = int(btBroadphaseProxy::AllFilter ^ (btBroadphaseProxy::CharacterFilter)); +static btScalar radius = btScalar(0.2); struct TestHingeTorque : public CommonRigidBodyBase { @@ -23,7 +23,7 @@ struct TestHingeTorque : public CommonRigidBodyBase float dist = 5; float pitch = -21; float yaw = 270; - float targetPos[3] = {-1.34, 3.4, -0.44}; + float targetPos[3] = {-1.34f, 3.4f, -0.44f}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } }; @@ -41,9 +41,9 @@ TestHingeTorque::~TestHingeTorque() } } -void TestHingeTorque::stepSimulation(float deltaTime) +void TestHingeTorque::stepSimulation(float /*deltaTime*/) { - if (0) //m_once) + if (/* DISABLES CODE */ (0)) //m_once) { m_once = false; btHingeConstraint* hinge = (btHingeConstraint*)m_dynamicsWorld->getConstraint(0); @@ -55,7 +55,7 @@ void TestHingeTorque::stepSimulation(float deltaTime) hinge->getRigidBodyB().applyTorque(hingeAxisInWorld * 10); } - m_dynamicsWorld->stepSimulation(1. / 240, 0); + m_dynamicsWorld->stepSimulation(btScalar(1. / 240), 0); static int count = 0; if ((count & 0x0f) == 0) @@ -109,8 +109,8 @@ void TestHingeTorque::initPhysics() int numLinks = 2; // bool selfCollide = false; - btVector3 linkHalfExtents(0.05, 0.37, 0.1); - btVector3 baseHalfExtents(0.05, 0.37, 0.1); + btVector3 linkHalfExtents(btScalar(0.05), btScalar(0.37), btScalar(0.1)); + btVector3 baseHalfExtents(btScalar(0.05), btScalar(0.37), btScalar(0.1)); btBoxShape* baseBox = new btBoxShape(baseHalfExtents); btVector3 basePosition = btVector3(-0.4f, 3.f, 0.f); @@ -138,7 +138,7 @@ void TestHingeTorque::initPhysics() btTransform linkTrans; linkTrans = baseWorldTrans; - linkTrans.setOrigin(basePosition - btVector3(0, linkHalfExtents[1] * 2.f * (i + 1), 0)); + linkTrans.setOrigin(basePosition - btVector3(0, linkHalfExtents[1] * 2.f * (btScalar)(i + 1), 0)); btCollisionShape* colOb = 0; @@ -197,7 +197,7 @@ void TestHingeTorque::initPhysics() if (1) { - btVector3 groundHalfExtents(1, 1, 0.2); + btVector3 groundHalfExtents(1, 1, btScalar(0.2)); groundHalfExtents[upAxis] = 1.f; btBoxShape* box = new btBoxShape(groundHalfExtents); box->initializePolyhedralFeatures(); @@ -208,8 +208,8 @@ void TestHingeTorque::initPhysics() // btVector3 basePosition = btVector3(-0.4f, 3.f, 0.f); btQuaternion groundOrn(btVector3(0, 1, 0), 0.25 * SIMD_PI); - groundOrigin[upAxis] -= .5; - groundOrigin[2] -= 0.6; + groundOrigin[upAxis] -= btScalar(.5); + groundOrigin[2] -= btScalar(0.6); start.setOrigin(groundOrigin); // start.setRotation(groundOrn); btRigidBody* body = createRigidBody(0, start, box); diff --git a/examples/DeformableDemo/ClothFriction.cpp b/examples/DeformableDemo/ClothFriction.cpp index 1d091fa381..70060386e4 100644 --- a/examples/DeformableDemo/ClothFriction.cpp +++ b/examples/DeformableDemo/ClothFriction.cpp @@ -54,7 +54,7 @@ class ClothFriction : public CommonDeformableBodyBase void stepSimulation(float deltaTime) { - float internalTimeStep = 1. / 240.f; + float internalTimeStep = 1.f / 240.f; m_dynamicsWorld->stepSimulation(deltaTime, 4, internalTimeStep); } @@ -82,7 +82,7 @@ void ClothFriction::initPhysics() ///collision configuration contains default setup for memory, collision setup m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration(); - ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) + ///use the default collision dispatcher. For parallel processing you can use a different dispatcher (see Extras/BulletMultiThreaded) m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); @@ -144,7 +144,7 @@ void ClothFriction::initPhysics() 10,10, 0, true); - psb->getCollisionShape()->setMargin(0.06); + psb->getCollisionShape()->setMargin(btScalar(0.06)); psb->generateBendingConstraints(2); psb->setTotalMass(1); psb->setSpringStiffness(100); @@ -173,7 +173,7 @@ void ClothFriction::initPhysics() btVector3(+s, h, +s), 5,5, 0, true); - psb2->getCollisionShape()->setMargin(0.06); + psb2->getCollisionShape()->setMargin(btScalar(0.06)); psb2->generateBendingConstraints(2); psb2->setTotalMass(1); psb2->setSpringStiffness(100); @@ -186,7 +186,7 @@ void ClothFriction::initPhysics() psb->translate(btVector3(0,0,0)); getDeformableDynamicsWorld()->addSoftBody(psb2); - btDeformableMassSpringForce* mass_spring2 = new btDeformableMassSpringForce(10,.1, true); + btDeformableMassSpringForce* mass_spring2 = new btDeformableMassSpringForce(10,btScalar(.1), true); getDeformableDynamicsWorld()->addForce(psb2, mass_spring2); m_forces.push_back(mass_spring2); diff --git a/examples/DeformableDemo/Collide.cpp b/examples/DeformableDemo/Collide.cpp index 01590ce7a1..7e3dd38b0f 100644 --- a/examples/DeformableDemo/Collide.cpp +++ b/examples/DeformableDemo/Collide.cpp @@ -28,9 +28,9 @@ ///The Collide shows the contact between volumetric deformable objects and rigid objects. static btScalar E = 50; -static btScalar nu = 0.3; -static btScalar damping_alpha = 0.1; -static btScalar damping_beta = 0.01; +static btScalar nu = btScalar(0.3); +static btScalar damping_alpha = btScalar(0.1); +static btScalar damping_beta = btScalar(0.01); static btScalar COLLIDING_VELOCITY = 15; struct TetraCube @@ -80,7 +80,7 @@ class Collide : public CommonDeformableBodyBase m_linearElasticity->setPoissonRatio(nu); m_linearElasticity->setYoungsModulus(E); m_linearElasticity->setDamping(damping_alpha, damping_beta); - float internalTimeStep = 1. / 60.f; + float internalTimeStep = 1.f / 60.f; m_dynamicsWorld->stepSimulation(deltaTime, 1, internalTimeStep); } @@ -107,7 +107,7 @@ void Collide::initPhysics() ///collision configuration contains default setup for memory, collision setup m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration(); - ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) + ///use the default collision dispatcher. For parallel processing you can use a different dispatcher (see Extras/BulletMultiThreaded) m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); @@ -132,7 +132,7 @@ void Collide::initPhysics() getDeformableDynamicsWorld()->addSoftBody(psb); psb->scale(btVector3(2, 2, 2)); psb->translate(btVector3(0, 7, 0)); - psb->getCollisionShape()->setMargin(0.1); + psb->getCollisionShape()->setMargin(btScalar(0.1)); psb->setTotalMass(0.5); psb->m_cfg.kKHR = 1; // collision hardness with kinematic objects psb->m_cfg.kCHR = 1; // collision hardness with rigid body @@ -144,7 +144,7 @@ void Collide::initPhysics() psb->setVelocity(btVector3(0, -COLLIDING_VELOCITY, 0)); - btDeformableLinearElasticityForce* linearElasticity = new btDeformableLinearElasticityForce(100,100,0.01); + btDeformableLinearElasticityForce* linearElasticity = new btDeformableLinearElasticityForce(100,100,btScalar(0.01)); m_linearElasticity = linearElasticity; getDeformableDynamicsWorld()->addForce(psb, linearElasticity); m_forces.push_back(linearElasticity); @@ -152,9 +152,9 @@ void Collide::initPhysics() getDeformableDynamicsWorld()->setImplicit(true); getDeformableDynamicsWorld()->setLineSearch(false); getDeformableDynamicsWorld()->setUseProjection(true); - getDeformableDynamicsWorld()->getSolverInfo().m_deformable_erp = 0.3; + getDeformableDynamicsWorld()->getSolverInfo().m_deformable_erp = btScalar(0.3); getDeformableDynamicsWorld()->getSolverInfo().m_deformable_maxErrorReduction = btScalar(200); - getDeformableDynamicsWorld()->getSolverInfo().m_leastSquaresResidualThreshold = 1e-3; + getDeformableDynamicsWorld()->getSolverInfo().m_leastSquaresResidualThreshold = btScalar(1e-3); getDeformableDynamicsWorld()->getSolverInfo().m_splitImpulse = true; getDeformableDynamicsWorld()->getSolverInfo().m_numIterations = 100; // add a few rigid bodies @@ -198,8 +198,8 @@ void Collide::initPhysics() } { SliderParams slider("Poisson Ratio", &nu); - slider.m_minVal = 0.05; - slider.m_maxVal = 0.49; + slider.m_minVal = 0.05f; + slider.m_maxVal = 0.49f; if (m_guiHelper->getParameterInterface()) m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider); } @@ -213,7 +213,7 @@ void Collide::initPhysics() { SliderParams slider("Stiffness Damping", &damping_beta); slider.m_minVal = 0; - slider.m_maxVal = 0.1; + slider.m_maxVal = 0.1f; if (m_guiHelper->getParameterInterface()) m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider); } diff --git a/examples/DeformableDemo/DeformableClothAnchor.cpp b/examples/DeformableDemo/DeformableClothAnchor.cpp index 1ed1642403..f6e4466995 100644 --- a/examples/DeformableDemo/DeformableClothAnchor.cpp +++ b/examples/DeformableDemo/DeformableClothAnchor.cpp @@ -51,7 +51,7 @@ class DeformableClothAnchor : public CommonDeformableBodyBase void stepSimulation(float deltaTime) { //use a smaller internal timestep, there are stability issues - float internalTimeStep = 1. / 240.f; + float internalTimeStep = 1.f / 240.f; m_dynamicsWorld->stepSimulation(deltaTime, 4, internalTimeStep); } @@ -79,7 +79,7 @@ void DeformableClothAnchor::initPhysics() ///collision configuration contains default setup for memory, collision setup m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration(); - ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) + ///use the default collision dispatcher. For parallel processing you can use a different dispatcher (see Extras/BulletMultiThreaded) m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); @@ -139,7 +139,7 @@ void DeformableClothAnchor::initPhysics() btVector3(+s, h, -s), btVector3(-s, h, +s), btVector3(+s, h, +s), r, r, 4 + 8, true); - psb->getCollisionShape()->setMargin(0.1); + psb->getCollisionShape()->setMargin(btScalar(0.1)); psb->generateBendingConstraints(2); psb->setTotalMass(1); psb->m_cfg.kKHR = 1; // collision hardness with kinematic objects diff --git a/examples/DeformableDemo/DeformableContact.cpp b/examples/DeformableDemo/DeformableContact.cpp index b1ad0b67b2..b98686aa08 100644 --- a/examples/DeformableDemo/DeformableContact.cpp +++ b/examples/DeformableDemo/DeformableContact.cpp @@ -52,7 +52,7 @@ class DeformableContact : public CommonDeformableBodyBase void stepSimulation(float deltaTime) { - float internalTimeStep = 1. / 240.f; + float internalTimeStep = 1.f / 240.f; m_dynamicsWorld->stepSimulation(deltaTime, 4, internalTimeStep); } @@ -82,7 +82,7 @@ void DeformableContact::initPhysics() ///collision configuration contains default setup for memory, collision setup m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration(); - ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) + ///use the default collision dispatcher. For parallel processing you can use a different dispatcher (see Extras/BulletMultiThreaded) m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); @@ -143,7 +143,7 @@ void DeformableContact::initPhysics() 20,20, 1 + 2 + 4 + 8, true); - psb->getCollisionShape()->setMargin(0.05); + psb->getCollisionShape()->setMargin(btScalar(0.05)); psb->generateBendingConstraints(2); psb->setSpringStiffness(10); psb->setTotalMass(1); @@ -172,7 +172,7 @@ void DeformableContact::initPhysics() btVector3(+s, h, +s), 10,10, 0, true); - psb2->getCollisionShape()->setMargin(0.05); + psb2->getCollisionShape()->setMargin(btScalar(0.05)); psb2->generateBendingConstraints(2); psb2->setSpringStiffness(10); psb2->setTotalMass(1); @@ -197,7 +197,7 @@ void DeformableContact::initPhysics() getDeformableDynamicsWorld()->setLineSearch(false); m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld); int numInstances = m_guiHelper->getRenderInterface()->getTotalNumInstances(); - double rgbaColors[3][4] = { { 1, 0, 0, 1 } , { 0, 1, 0, 1 } ,{ 0, 0, 1, 1 } }; + // double rgbaColors[3][4] = { { 1, 0, 0, 1 } , { 0, 1, 0, 1 } ,{ 0, 0, 1, 1 } }; for (int i = 0; i < numInstances; i++) { diff --git a/examples/DeformableDemo/DeformableMultibody.cpp b/examples/DeformableDemo/DeformableMultibody.cpp index 041624b00c..5050a86edc 100644 --- a/examples/DeformableDemo/DeformableMultibody.cpp +++ b/examples/DeformableDemo/DeformableMultibody.cpp @@ -24,7 +24,6 @@ #include "../CommonInterfaces/CommonRigidBodyBase.h" #include "../Utils/b3ResourcePath.h" -#include "../SoftDemo/BunnyMesh.h" #include "BulletDynamics/Featherstone/btMultiBodyLinkCollider.h" #include "BulletDynamics/Featherstone/btMultiBodyJointFeedback.h" @@ -87,7 +86,7 @@ void DeformableMultibody::initPhysics() ///collision configuration contains default setup for memory, collision setup m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration(); - ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) + ///use the default collision dispatcher. For parallel processing you can use a different dispatcher (see Extras/BulletMultiThreaded) m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); @@ -139,11 +138,11 @@ void DeformableMultibody::initPhysics() bool damping = true; bool gyro = false; int numLinks = 4; - bool spherical = false; //set it ot false -to use 1DoF hinges instead of 3DoF sphericals + bool spherical = false; //set it to false -to use 1DoF hinges instead of 3DoF sphericals bool canSleep = false; bool selfCollide = true; - btVector3 linkHalfExtents(.4, 1, .4); - btVector3 baseHalfExtents(.4, 1, .4); + btVector3 linkHalfExtents(btScalar(.4), 1, btScalar(.4)); + btVector3 baseHalfExtents(btScalar(.4), 1, btScalar(.4)); btMultiBody* mbC = createFeatherstoneMultiBody_testMultiDof(m_dynamicsWorld, numLinks, btVector3(0.f, 10.f,0.f), linkHalfExtents, baseHalfExtents, spherical, g_floatingBase); @@ -192,7 +191,7 @@ void DeformableMultibody::initPhysics() // 3,3, 1 + 2 + 4 + 8, true); - psb->getCollisionShape()->setMargin(0.025); + psb->getCollisionShape()->setMargin(btScalar(0.025)); psb->generateBendingConstraints(2); psb->setTotalMass(1); psb->m_cfg.kKHR = 1; // collision hardness with kinematic objects @@ -262,7 +261,7 @@ void DeformableMultibody::exitPhysics() void DeformableMultibody::stepSimulation(float deltaTime) { // getDeformableDynamicsWorld()->getMultiBodyDynamicsWorld()->stepSimulation(deltaTime); - m_dynamicsWorld->stepSimulation(deltaTime, 5, 1./250.); + m_dynamicsWorld->stepSimulation(deltaTime, 5, btScalar(1./250.)); } @@ -272,7 +271,7 @@ btMultiBody* DeformableMultibody::createFeatherstoneMultiBody_testMultiDof(btMul btVector3 baseInertiaDiag(0.f, 0.f, 0.f); float baseMass = .1f; - if (baseMass) + if (baseMass != 0.0f) { btCollisionShape* pTempBox = new btBoxShape(btVector3(baseHalfExtents[0], baseHalfExtents[1], baseHalfExtents[2])); pTempBox->calculateLocalInertia(baseMass, baseInertiaDiag); @@ -341,7 +340,7 @@ void DeformableMultibody::addColliders_testMultiDof(btMultiBody* pMultiBody, btM btScalar quat[4] = {-world_to_local[0].x(), -world_to_local[0].y(), -world_to_local[0].z(), world_to_local[0].w()}; btCollisionShape* box = new btBoxShape(baseHalfExtents); - box->setMargin(0.01); + box->setMargin(btScalar(0.01)); btMultiBodyLinkCollider* col = new btMultiBodyLinkCollider(pMultiBody, -1); col->setCollisionShape(box); diff --git a/examples/DeformableDemo/DeformableRigid.cpp b/examples/DeformableDemo/DeformableRigid.cpp index 7efe118a69..23dc920b30 100644 --- a/examples/DeformableDemo/DeformableRigid.cpp +++ b/examples/DeformableDemo/DeformableRigid.cpp @@ -51,7 +51,7 @@ class DeformableRigid : public CommonDeformableBodyBase void stepSimulation(float deltaTime) { //use a smaller internal timestep, there are stability issues - float internalTimeStep = 1. / 240.f; + float internalTimeStep = 1.f / 240.f; m_dynamicsWorld->stepSimulation(deltaTime, 4, internalTimeStep); // @@ -97,9 +97,9 @@ class DeformableRigid : public CommonDeformableBodyBase // } } - void Ctor_RbUpStack(int count) + void Ctor_RbUpStack(int /*count*/) { - float mass = .2; + float mass = .2f; btCompoundShape* cylinderCompound = new btCompoundShape; btCollisionShape* cylinderShape = new btCylinderShapeX(btVector3(2, .5, .5)); @@ -178,7 +178,7 @@ void DeformableRigid::initPhysics() ///collision configuration contains default setup for memory, collision setup m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration(); - ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) + ///use the default collision dispatcher. For parallel processing you can use a different dispatcher (see Extras/BulletMultiThreaded) m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); @@ -256,7 +256,7 @@ void DeformableRigid::initPhysics() 2,2, 0, true); - psb->getCollisionShape()->setMargin(0.05); + psb->getCollisionShape()->setMargin(btScalar(0.05)); psb->generateBendingConstraints(2); psb->setTotalMass(1); psb->m_cfg.kKHR = 1; // collision hardness with kinematic objects diff --git a/examples/DeformableDemo/DeformableSelfCollision.cpp b/examples/DeformableDemo/DeformableSelfCollision.cpp index 45f19bd402..f52a18f9ef 100644 --- a/examples/DeformableDemo/DeformableSelfCollision.cpp +++ b/examples/DeformableDemo/DeformableSelfCollision.cpp @@ -31,7 +31,7 @@ class DeformableSelfCollision : public CommonDeformableBodyBase DeformableSelfCollision(struct GUIHelperInterface* helper) : CommonDeformableBodyBase(helper) { - m_maxPickingForce = 0.004; + m_maxPickingForce = btScalar(0.004); } virtual ~DeformableSelfCollision() { @@ -51,7 +51,7 @@ class DeformableSelfCollision : public CommonDeformableBodyBase void stepSimulation(float deltaTime) { - float internalTimeStep = 1. / 240.f; + float internalTimeStep = 1.f / 240.f; m_dynamicsWorld->stepSimulation(deltaTime, 4, internalTimeStep); } @@ -69,7 +69,7 @@ void DeformableSelfCollision::initPhysics() ///collision configuration contains default setup for memory, collision setup m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration(); - ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) + ///use the default collision dispatcher. For parallel processing you can use a different dispatcher (see Extras/BulletMultiThreaded) m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); @@ -83,7 +83,7 @@ void DeformableSelfCollision::initPhysics() m_dynamicsWorld = new btDeformableMultiBodyDynamicsWorld(m_dispatcher, m_broadphase, sol, m_collisionConfiguration, deformableBodySolver); // deformableBodySolver->setWorld(getDeformableDynamicsWorld()); // m_dynamicsWorld->getSolverInfo().m_singleAxisDeformableThreshold = 0.f;//faster but lower quality - btVector3 gravity = btVector3(0, -9.8, 0); + btVector3 gravity = btVector3(0, btScalar(-9.8), 0); m_dynamicsWorld->setGravity(gravity); getDeformableDynamicsWorld()->getWorldInfo().m_gravity = gravity; getDeformableDynamicsWorld()->getWorldInfo().m_sparsesdf.setDefaultVoxelsz(0.25); @@ -94,7 +94,7 @@ void DeformableSelfCollision::initPhysics() { ///create a ground btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(150.), btScalar(2.5), btScalar(150.))); - groundShape->setMargin(0.02); + groundShape->setMargin(btScalar(0.02)); m_collisionShapes.push_back(groundShape); btTransform groundTransform; @@ -120,8 +120,8 @@ void DeformableSelfCollision::initPhysics() //add the ground to the dynamics world m_dynamicsWorld->addRigidBody(body); } - addCloth(btVector3(0, -0.2, 0)); - addCloth(btVector3(0, -0.1, 0)); + addCloth(btVector3(0, btScalar(-0.2), 0)); + addCloth(btVector3(0, btScalar(-0.1), 0)); getDeformableDynamicsWorld()->setImplicit(false); getDeformableDynamicsWorld()->setLineSearch(false); m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld); @@ -129,7 +129,7 @@ void DeformableSelfCollision::initPhysics() void DeformableSelfCollision::addCloth(const btVector3& origin) // create a piece of cloth { - const btScalar s = 0.6; + const btScalar s = btScalar(0.6); const btScalar h = 0; btSoftBody* psb = btSoftBodyHelpers::CreatePatch(getDeformableDynamicsWorld()->getWorldInfo(), btVector3(-s, h, -2*s), @@ -141,16 +141,16 @@ void DeformableSelfCollision::addCloth(const btVector3& origin) 0, true, 0.0); - psb->getCollisionShape()->setMargin(0.02); + psb->getCollisionShape()->setMargin(btScalar(0.02)); psb->generateBendingConstraints(2); psb->setTotalMass(.5); psb->m_cfg.kKHR = 1; // collision hardness with kinematic objects psb->m_cfg.kCHR = 1; // collision hardness with rigid body - psb->m_cfg.kDF = 0.1; + psb->m_cfg.kDF = btScalar(0.1); // psb->rotate(btQuaternion(0, SIMD_PI / 2, 0)); btTransform clothTransform; clothTransform.setIdentity(); - clothTransform.setOrigin(btVector3(0,0.2,0)+origin); + clothTransform.setOrigin(btVector3(0,btScalar(0.2),0)+origin); psb->transform(clothTransform); psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RD; psb->m_cfg.collisions |= btSoftBody::fCollision::SDF_RDN; @@ -159,11 +159,11 @@ void DeformableSelfCollision::addCloth(const btVector3& origin) getDeformableDynamicsWorld()->addSoftBody(psb); psb->setSelfCollision(true); - btDeformableMassSpringForce* mass_spring = new btDeformableMassSpringForce(2,0.2, true); + btDeformableMassSpringForce* mass_spring = new btDeformableMassSpringForce(2,btScalar(0.2), true); psb->setSpringStiffness(4); getDeformableDynamicsWorld()->addForce(psb, mass_spring); m_forces.push_back(mass_spring); - btVector3 gravity = btVector3(0, -9.8, 0); + btVector3 gravity = btVector3(0, btScalar(-9.8), 0); btDeformableGravityForce* gravity_force = new btDeformableGravityForce(gravity); getDeformableDynamicsWorld()->addForce(psb, gravity_force); getDeformableDynamicsWorld()->setUseProjection(true); diff --git a/examples/DeformableDemo/GraspDeformable.cpp b/examples/DeformableDemo/GraspDeformable.cpp index f52f67fe98..178beec221 100644 --- a/examples/DeformableDemo/GraspDeformable.cpp +++ b/examples/DeformableDemo/GraspDeformable.cpp @@ -58,7 +58,6 @@ static bool supportsJointMotor(btMultiBody* mb, int mbLinkIndex) class GraspDeformable : public CommonDeformableBodyBase { - btAlignedObjectArray m_forces; public: GraspDeformable(struct GUIHelperInterface* helper) :CommonDeformableBodyBase(helper) @@ -73,10 +72,10 @@ class GraspDeformable : public CommonDeformableBodyBase void resetCamera() { - float dist = 0.3; + float dist = 0.3f; float pitch = -45; float yaw = 100; - float targetPos[3] = {0, -0.1, 0}; + float targetPos[3] = {0, -0.1f, 0}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } @@ -104,12 +103,12 @@ class GraspDeformable : public CommonDeformableBodyBase { if (dofIndex == 6) { - motor->setVelocityTarget(-fingerTargetVelocities[1], 1); + motor->setVelocityTarget((btScalar)-fingerTargetVelocities[1], 1); motor->setMaxAppliedImpulse(20); } if (dofIndex == 7) { - motor->setVelocityTarget(fingerTargetVelocities[1], 1); + motor->setVelocityTarget((btScalar)fingerTargetVelocities[1], 1); motor->setMaxAppliedImpulse(20); } motor->setMaxAppliedImpulse(1); @@ -120,7 +119,7 @@ class GraspDeformable : public CommonDeformableBodyBase } //use a smaller internal timestep, there are stability issues - float internalTimeStep = 1. / 240.f; + float internalTimeStep = 1.f / 240.f; m_dynamicsWorld->stepSimulation(deltaTime, 4, internalTimeStep); } @@ -130,6 +129,7 @@ class GraspDeformable : public CommonDeformableBodyBase float mass = 2; btCollisionShape* shape[] = { new btBoxShape(btVector3(3, 3, 0.5)), + NULL }; static const int nshapes = sizeof(shape) / sizeof(shape[0]); for (int i = 0; i < count; ++i) @@ -167,11 +167,11 @@ class GraspDeformable : public CommonDeformableBodyBase } } - virtual bool pickBody(const btVector3& rayFromWorld, const btVector3& rayToWorld) + virtual bool pickBody(const btVector3& /*rayFromWorld*/, const btVector3& /*rayToWorld*/) { return false; } - virtual bool movePickedBody(const btVector3& rayFromWorld, const btVector3& rayToWorld) + virtual bool movePickedBody(const btVector3& /*rayFromWorld*/, const btVector3& /*rayToWorld*/) { return false; } @@ -195,14 +195,14 @@ void GraspDeformable::initPhysics() m_solver = sol; m_dynamicsWorld = new btDeformableMultiBodyDynamicsWorld(m_dispatcher, m_broadphase, sol, m_collisionConfiguration, deformableBodySolver); - btVector3 gravity = btVector3(0, -9.81, 0); + btVector3 gravity = btVector3(0, btScalar(-9.81), 0); m_dynamicsWorld->setGravity(gravity); getDeformableDynamicsWorld()->getWorldInfo().m_gravity = gravity; - getDeformableDynamicsWorld()->getSolverInfo().m_deformable_erp = 0.1; + getDeformableDynamicsWorld()->getSolverInfo().m_deformable_erp = btScalar(0.1); getDeformableDynamicsWorld()->getSolverInfo().m_deformable_cfm = 0; getDeformableDynamicsWorld()->getSolverInfo().m_numIterations = 150; m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld); - m_maxPickingForce = 0.001; + m_maxPickingForce = btScalar(0.001); // build a gripper if(1) { @@ -211,8 +211,8 @@ void GraspDeformable::initPhysics() bool canSleep = false; bool selfCollide = true; int numLinks = 2; - btVector3 linkHalfExtents(0.02, 0.018, .003); - btVector3 baseHalfExtents(0.02, 0.002, .002); + btVector3 linkHalfExtents(btScalar(0.02), btScalar(0.018), btScalar(.003)); + btVector3 baseHalfExtents(btScalar(0.02), btScalar(0.002), btScalar(.002)); btMultiBody* mbC = createFeatherstoneMultiBody(getDeformableDynamicsWorld(), btVector3(0.f, 0.05f,0.f), linkHalfExtents, baseHalfExtents, false); mbC->setCanSleep(canSleep); @@ -228,7 +228,7 @@ void GraspDeformable::initPhysics() { int dof = 0; btScalar desiredVelocity = 0.f; - btMultiBodyJointMotor* motor = new btMultiBodyJointMotor(mbC, mbLinkIndex, dof, desiredVelocity, maxMotorImpulse); + btMultiBodyJointMotor* motor = new btMultiBodyJointMotor(mbC, mbLinkIndex, dof, desiredVelocity, (btScalar)maxMotorImpulse); motor->setPositionTarget(0, 0); motor->setVelocityTarget(0, 1); mbC->getLink(mbLinkIndex).m_userPtr = motor; @@ -256,12 +256,12 @@ void GraspDeformable::initPhysics() //create a ground { btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(10.), btScalar(5.), btScalar(10.))); - groundShape->setMargin(0.001); + groundShape->setMargin(btScalar(0.001)); m_collisionShapes.push_back(groundShape); btTransform groundTransform; groundTransform.setIdentity(); - groundTransform.setOrigin(btVector3(0, -5.1, 0)); + groundTransform.setOrigin(btVector3(0, btScalar(-5.1), 0)); groundTransform.setRotation(btQuaternion(btVector3(1, 0, 0), SIMD_PI * 0)); //We can also use DemoApplication::localCreateRigidBody, but for clarity it is provided here: btScalar mass(0.); @@ -284,7 +284,7 @@ void GraspDeformable::initPhysics() } // create a soft block - if (0) + if (/* DISABLES CODE */ (0)) { char absolute_path[1024]; b3BulletDefaultFileIO fileio; @@ -308,13 +308,13 @@ void GraspDeformable::initPhysics() // psb->scale(btVector3(30, 30, 30)); // for banana // psb->scale(btVector3(.7, .7, .7)); - psb->scale(btVector3(.2, .2, .2)); + psb->scale(btVector3(btScalar(.2), btScalar(.2), btScalar(.2))); // psb->scale(btVector3(.3, .3, .3)); // for tube, torus, boot // psb->scale(btVector3(.1, .1, .1)); // for ditto // psb->translate(btVector3(.25, 10, 0.4)); - psb->getCollisionShape()->setMargin(0.01); + psb->getCollisionShape()->setMargin(btScalar(0.01)); psb->setMaxStress(50); - psb->setTotalMass(.1); + psb->setTotalMass(btScalar(.1)); psb->m_cfg.kKHR = 1; // collision hardness with kinematic objects psb->m_cfg.kCHR = 1; // collision hardness with rigid body psb->m_cfg.kDF = 2; @@ -327,7 +327,7 @@ void GraspDeformable::initPhysics() getDeformableDynamicsWorld()->addForce(psb, gravity_force); m_forces.push_back(gravity_force); - btDeformableNeoHookeanForce* neohookean = new btDeformableNeoHookeanForce(20,80,.01); + btDeformableNeoHookeanForce* neohookean = new btDeformableNeoHookeanForce(20,80,btScalar(.01)); getDeformableDynamicsWorld()->addForce(psb, neohookean); m_forces.push_back(neohookean); } @@ -337,8 +337,8 @@ void GraspDeformable::initPhysics() if(1) { bool onGround = false; - const btScalar s = .05; - const btScalar h = -0.02; + const btScalar s = btScalar(.05); + const btScalar h = btScalar(-0.02); btSoftBody* psb = btSoftBodyHelpers::CreatePatch(getDeformableDynamicsWorld()->getWorldInfo(), btVector3(-s, h, -s), btVector3(+s, h, -s), btVector3(-s, h, +s), @@ -355,11 +355,11 @@ void GraspDeformable::initPhysics() 2,2, 0, true); - psb->getCollisionShape()->setMargin(0.001); + psb->getCollisionShape()->setMargin(btScalar(0.001)); psb->generateBendingConstraints(2); - psb->setTotalMass(0.01); + psb->setTotalMass(btScalar(0.01)); psb->setSpringStiffness(10); - psb->setDampingCoefficient(0.05); + psb->setDampingCoefficient(btScalar(0.05)); psb->m_cfg.kKHR = 1; // collision hardness with kinematic objects psb->m_cfg.kCHR = 1; // collision hardness with rigid body psb->m_cfg.kDF = 1; @@ -367,16 +367,16 @@ void GraspDeformable::initPhysics() psb->m_cfg.collisions |= btSoftBody::fCollision::SDF_MDF; psb->m_cfg.collisions |= btSoftBody::fCollision::SDF_RDF; getDeformableDynamicsWorld()->addSoftBody(psb); - getDeformableDynamicsWorld()->addForce(psb, new btDeformableMassSpringForce(0.05,0.005, true)); - getDeformableDynamicsWorld()->addForce(psb, new btDeformableGravityForce(gravity*0.1)); + getDeformableDynamicsWorld()->addForce(psb, new btDeformableMassSpringForce(btScalar(0.05),btScalar(0.005), true)); + getDeformableDynamicsWorld()->addForce(psb, new btDeformableGravityForce(gravity*btScalar(0.1))); } m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld); { SliderParams slider("Moving velocity", &sGripperVerticalVelocity); - slider.m_minVal = -.02; - slider.m_maxVal = .02; + slider.m_minVal = -.02f; + slider.m_maxVal = .02f; m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider); } @@ -437,11 +437,11 @@ btMultiBody* GraspDeformable::createFeatherstoneMultiBody(btMultiBodyDynamicsWor { //init the base btVector3 baseInertiaDiag(0.f, 0.f, 0.f); - float baseMass = 0.1; - float linkMass = 0.1; + float baseMass = 0.1f; + float linkMass = 0.1f; int numLinks = 2; - if (baseMass) + if (baseMass != 0.0f) { btCollisionShape* pTempBox = new btBoxShape(btVector3(baseHalfExtents[0], baseHalfExtents[1], baseHalfExtents[2])); pTempBox->calculateLocalInertia(baseMass, baseInertiaDiag); @@ -508,7 +508,7 @@ void GraspDeformable::addColliders(btMultiBody* pMultiBody, btMultiBodyDynamicsW if (1) { btCollisionShape* box = new btBoxShape(baseHalfExtents); - box->setMargin(0.001); + box->setMargin(btScalar(0.001)); btMultiBodyLinkCollider* col = new btMultiBodyLinkCollider(pMultiBody, -1); col->setCollisionShape(box); @@ -539,7 +539,7 @@ void GraspDeformable::addColliders(btMultiBody* pMultiBody, btMultiBodyDynamicsW btScalar quat[4] = {-world_to_local[i + 1].x(), -world_to_local[i + 1].y(), -world_to_local[i + 1].z(), world_to_local[i + 1].w()}; btCollisionShape* box = new btBoxShape(linkHalfExtents); - box->setMargin(0.001); + box->setMargin(btScalar(0.001)); btMultiBodyLinkCollider* col = new btMultiBodyLinkCollider(pMultiBody, i); col->setCollisionShape(box); diff --git a/examples/DeformableDemo/LargeDeformation.cpp b/examples/DeformableDemo/LargeDeformation.cpp index f1a6a29f58..f02c28aa93 100644 --- a/examples/DeformableDemo/LargeDeformation.cpp +++ b/examples/DeformableDemo/LargeDeformation.cpp @@ -28,9 +28,9 @@ ///The LargeDeformation shows the contact between volumetric deformable objects and rigid objects. static btScalar E = 50; -static btScalar nu = 0.3; -static btScalar damping_alpha = 0.1; -static btScalar damping_beta = 0.01; +static btScalar nu = btScalar(0.3); +static btScalar damping_alpha = btScalar(0.1); +static btScalar damping_beta = btScalar(0.01); struct TetraCube { @@ -68,7 +68,7 @@ class LargeDeformation : public CommonDeformableBodyBase m_linearElasticity->setPoissonRatio(nu); m_linearElasticity->setYoungsModulus(E); m_linearElasticity->setDamping(damping_alpha, damping_beta); - float internalTimeStep = 1. / 60.f; + float internalTimeStep = 1.f / 60.f; m_dynamicsWorld->stepSimulation(deltaTime, 1, internalTimeStep); } @@ -95,7 +95,7 @@ void LargeDeformation::initPhysics() ///collision configuration contains default setup for memory, collision setup m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration(); - ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) + ///use the default collision dispatcher. For parallel processing you can use a different dispatcher (see Extras/BulletMultiThreaded) m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); @@ -118,11 +118,11 @@ void LargeDeformation::initPhysics() getDeformableDynamicsWorld()->addSoftBody(psb); psb->scale(btVector3(2, 2, 2)); psb->translate(btVector3(0, 5, 0)); - psb->getCollisionShape()->setMargin(0.1); + psb->getCollisionShape()->setMargin(btScalar(0.1)); psb->setTotalMass(0.5); psb->m_cfg.kKHR = 1; // collision hardness with kinematic objects psb->m_cfg.kCHR = 1; // collision hardness with rigid body - psb->m_cfg.kDF = 0.5; + psb->m_cfg.kDF = btScalar(0.5); psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RD; psb->m_cfg.collisions |= btSoftBody::fCollision::SDF_RDN; psb->m_sleepingThreshold = 0; @@ -130,11 +130,11 @@ void LargeDeformation::initPhysics() for (int i = 0; i < psb->m_nodes.size(); ++i) { for (int j = 0; j < 3; ++j) - psb->m_nodes[i].m_x[j] = ((double) 2*rand() / (RAND_MAX))-1.0; + psb->m_nodes[i].m_x[j] = btScalar(((double) 2*rand() / (RAND_MAX))-1.0); psb->m_nodes[i].m_x[1]+=8; } - btDeformableLinearElasticityForce* linearElasticity = new btDeformableLinearElasticityForce(100,100,0.01); + btDeformableLinearElasticityForce* linearElasticity = new btDeformableLinearElasticityForce(100,100,btScalar(0.01)); m_linearElasticity = linearElasticity; getDeformableDynamicsWorld()->addForce(psb, linearElasticity); m_forces.push_back(linearElasticity); @@ -142,9 +142,9 @@ void LargeDeformation::initPhysics() getDeformableDynamicsWorld()->setImplicit(true); getDeformableDynamicsWorld()->setLineSearch(false); getDeformableDynamicsWorld()->setUseProjection(true); - getDeformableDynamicsWorld()->getSolverInfo().m_deformable_erp = 0.1; + getDeformableDynamicsWorld()->getSolverInfo().m_deformable_erp = btScalar(0.1); getDeformableDynamicsWorld()->getSolverInfo().m_deformable_maxErrorReduction = btScalar(20); - getDeformableDynamicsWorld()->getSolverInfo().m_leastSquaresResidualThreshold = 1e-3; + getDeformableDynamicsWorld()->getSolverInfo().m_leastSquaresResidualThreshold = btScalar(1e-3); getDeformableDynamicsWorld()->getSolverInfo().m_splitImpulse = true; getDeformableDynamicsWorld()->getSolverInfo().m_numIterations = 100; // add a few rigid bodies @@ -159,8 +159,8 @@ void LargeDeformation::initPhysics() } { SliderParams slider("Poisson Ratio", &nu); - slider.m_minVal = 0.05; - slider.m_maxVal = 0.49; + slider.m_minVal = 0.05f; + slider.m_maxVal = 0.49f; if (m_guiHelper->getParameterInterface()) m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider); } @@ -174,7 +174,7 @@ void LargeDeformation::initPhysics() { SliderParams slider("Stiffness Damping", &damping_beta); slider.m_minVal = 0; - slider.m_maxVal = 0.1; + slider.m_maxVal = 0.1f; if (m_guiHelper->getParameterInterface()) m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider); } diff --git a/examples/DeformableDemo/LoadDeformed.cpp b/examples/DeformableDemo/LoadDeformed.cpp index 283c428c08..2fe4931147 100644 --- a/examples/DeformableDemo/LoadDeformed.cpp +++ b/examples/DeformableDemo/LoadDeformed.cpp @@ -41,10 +41,10 @@ static inline bool isSpace(const char c) { return (c == ' ') || (c == '\t'); } -static inline bool isNewLine(const char c) -{ - return (c == '\r') || (c == '\n') || (c == '\0'); -} +//static inline bool isNewLine(const char c) +//{ +// return (c == '\r') || (c == '\n') || (c == '\0'); +//} static inline float parseFloat(const char*& token) { token += strspn(token, " \t"); @@ -88,9 +88,9 @@ std::string CustomSoftBodyHelper::loadDeformableState(btAlignedObjectArray buf(maxchars); // Alloc enough size. + std::vector buf((size_t)maxchars); // Alloc enough size. std::string linebuf; - linebuf.reserve(maxchars); + linebuf.reserve((size_t)maxchars); #ifdef USE_STREAM while (ifs.peek() != -1) @@ -184,9 +184,10 @@ class LoadDeformed : public CommonDeformableBodyBase : CommonDeformableBodyBase(helper) { steps = 0; - psb = nullptr; + psb = NULL; reset_frame = 0; sim_time = 0; + (void)filename; } virtual ~LoadDeformed() { @@ -209,18 +210,18 @@ class LoadDeformed : public CommonDeformableBodyBase steps++; sim_time += deltaTime; //// int seconds = 1/deltaTime; - if (0) + if (/* DISABLES CODE */ (0)) { // if (reset_frame==0 && steps<100){ //// printf("steps %d, seconds %d, steps/seconds %d\n", steps,seconds,steps/seconds); - char filename[100]; - sprintf(filename, "%s_%d_%d.txt", "states", reset_frame, steps); - btSoftBodyHelpers::writeState(filename, psb); + char file_name[100]; + sprintf(file_name, "%s_%d_%d.txt", "states", reset_frame, steps); + btSoftBodyHelpers::writeState(file_name, psb); } if (sim_time + reset_frame * 0.05 >= 5) exit(0); - float internalTimeStep = 1. / 240.f; + float internalTimeStep = 1.f / 240.f; // float internalTimeStep = 0.1f; - m_dynamicsWorld->stepSimulation(deltaTime, deltaTime / internalTimeStep, internalTimeStep); + m_dynamicsWorld->stepSimulation(deltaTime, int(deltaTime / internalTimeStep), internalTimeStep); } void addCloth(const btVector3& origin); @@ -232,10 +233,10 @@ class LoadDeformed : public CommonDeformableBodyBase for (int i = 0; i < deformableWorld->getSoftBodyArray().size(); i++) { - btSoftBody* psb = (btSoftBody*)deformableWorld->getSoftBodyArray()[i]; + btSoftBody* pSoftBody = (btSoftBody*)deformableWorld->getSoftBodyArray()[i]; { - btSoftBodyHelpers::DrawFrame(psb, deformableWorld->getDebugDrawer()); - btSoftBodyHelpers::Draw(psb, deformableWorld->getDebugDrawer(), deformableWorld->getDrawFlags()); + btSoftBodyHelpers::DrawFrame(pSoftBody, deformableWorld->getDebugDrawer()); + btSoftBodyHelpers::Draw(pSoftBody, deformableWorld->getDebugDrawer(), deformableWorld->getDrawFlags()); } } } @@ -248,7 +249,7 @@ void LoadDeformed::initPhysics() ///collision configuration contains default setup for memory, collision setup m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration(); - ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) + ///use the default collision dispatcher. For parallel processing you can use a different dispatcher (see Extras/BulletMultiThreaded) m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); @@ -259,7 +260,7 @@ void LoadDeformed::initPhysics() m_solver = sol; m_dynamicsWorld = new btDeformableMultiBodyDynamicsWorld(m_dispatcher, m_broadphase, sol, m_collisionConfiguration, deformableBodySolver); - btVector3 gravity = btVector3(0, -9.8, 0); + btVector3 gravity = btVector3(0, btScalar(-9.8), 0); m_dynamicsWorld->setGravity(gravity); getDeformableDynamicsWorld()->getWorldInfo().m_gravity = gravity; getDeformableDynamicsWorld()->getWorldInfo().m_sparsesdf.setDefaultVoxelsz(0.25); @@ -269,7 +270,7 @@ void LoadDeformed::initPhysics() { ///create a ground btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(150.), btScalar(2.5), btScalar(150.))); - groundShape->setMargin(0.02); + groundShape->setMargin(btScalar(0.02)); m_collisionShapes.push_back(groundShape); btTransform groundTransform; @@ -303,7 +304,7 @@ void LoadDeformed::initPhysics() void LoadDeformed::addCloth(const btVector3& origin) // create a piece of cloth { - const btScalar s = 0.6; + const btScalar s = btScalar(0.6); const btScalar h = 0; psb = btSoftBodyHelpers::CreatePatch(getDeformableDynamicsWorld()->getWorldInfo(), btVector3(-s, h, -2 * s), @@ -313,23 +314,23 @@ void LoadDeformed::addCloth(const btVector3& origin) 15, 30, 0, true, 0.0); - psb->getCollisionShape()->setMargin(0.02); + psb->getCollisionShape()->setMargin(btScalar(0.02)); psb->generateBendingConstraints(2); psb->setTotalMass(.5); psb->m_cfg.kKHR = 1; // collision hardness with kinematic objects psb->m_cfg.kCHR = 1; // collision hardness with rigid body - psb->m_cfg.kDF = 0.1; + psb->m_cfg.kDF = btScalar(0.1); psb->rotate(btQuaternion(0, SIMD_PI / 2, 0)); btTransform clothTransform; clothTransform.setIdentity(); - clothTransform.setOrigin(btVector3(0, 0.2, 0) + origin); + clothTransform.setOrigin(btVector3(0, btScalar(0.2), 0) + origin); psb->transform(clothTransform); b3BulletDefaultFileIO fileio; char absolute_path[1024]; - char filename[100]; - sprintf(filename, "/Users/fuchuyuan/Documents/mybullet/build_cmake/examples/ExampleBrowser/states_0_%d.txt", reset_frame); - fileio.findResourcePath(filename, absolute_path, 1024); + char file_name[100]; + sprintf(file_name, "/Users/fuchuyuan/Documents/mybullet/build_cmake/examples/ExampleBrowser/states_0_%d.txt", reset_frame); + fileio.findResourcePath(file_name, absolute_path, 1024); btAlignedObjectArray qs; btAlignedObjectArray vs; CustomSoftBodyHelper::loadDeformableState(qs, vs, absolute_path, &fileio); @@ -344,11 +345,11 @@ void LoadDeformed::addCloth(const btVector3& origin) getDeformableDynamicsWorld()->addSoftBody(psb); psb->setSelfCollision(false); - btDeformableMassSpringForce* mass_spring = new btDeformableMassSpringForce(2, 0.2, true); + btDeformableMassSpringForce* mass_spring = new btDeformableMassSpringForce(2, btScalar(0.2), true); psb->setSpringStiffness(4); getDeformableDynamicsWorld()->addForce(psb, mass_spring); m_forces.push_back(mass_spring); - btVector3 gravity = btVector3(0, -9.8, 0); + btVector3 gravity = btVector3(0, btScalar(-9.8), 0); btDeformableGravityForce* gravity_force = new btDeformableGravityForce(gravity); getDeformableDynamicsWorld()->addForce(psb, gravity_force); // getDeformableDynamicsWorld()->setUseProjection(true); diff --git a/examples/DeformableDemo/MultibodyClothAnchor.cpp b/examples/DeformableDemo/MultibodyClothAnchor.cpp index ab78efa686..a347de878f 100644 --- a/examples/DeformableDemo/MultibodyClothAnchor.cpp +++ b/examples/DeformableDemo/MultibodyClothAnchor.cpp @@ -51,7 +51,7 @@ class MultibodyClothAnchor : public CommonDeformableBodyBase void stepSimulation(float deltaTime) { //use a smaller internal timestep, there are stability issues - float internalTimeStep = 1. / 240.f; + float internalTimeStep = 1.f / 240.f; m_dynamicsWorld->stepSimulation(deltaTime, 4, internalTimeStep); } @@ -83,7 +83,7 @@ void MultibodyClothAnchor::initPhysics() ///collision configuration contains default setup for memory, collision setup m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration(); - ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) + ///use the default collision dispatcher. For parallel processing you can use a different dispatcher (see Extras/BulletMultiThreaded) m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); @@ -143,7 +143,7 @@ void MultibodyClothAnchor::initPhysics() btVector3(+s, h, -s), btVector3(-s, h, +s), btVector3(+s, h, +s), r, r, 4 + 8, true); - psb->getCollisionShape()->setMargin(0.01); + psb->getCollisionShape()->setMargin(btScalar(0.01)); psb->generateBendingConstraints(2); psb->setTotalMass(1); psb->m_cfg.kKHR = 1; // collision hardness with kinematic objects @@ -164,7 +164,7 @@ void MultibodyClothAnchor::initPhysics() bool damping = true; bool gyro = false; int numLinks = 5; - bool spherical = false; //set it ot false -to use 1DoF hinges instead of 3DoF sphericals + bool spherical = false; //set it to false -to use 1DoF hinges instead of 3DoF sphericals bool canSleep = false; bool selfCollide = true; btVector3 linkHalfExtents(1.5, .5, .5); @@ -266,7 +266,7 @@ btMultiBody* MultibodyClothAnchor::createMultiBody(btMultiBodyDynamicsWorld* pWo btVector3 baseInertiaDiag(0.f, 0.f, 0.f); float baseMass = 1.f; - if (baseMass) + if (baseMass != 0.0f) { btCollisionShape* pTempBox = new btBoxShape(btVector3(baseHalfExtents[0], baseHalfExtents[1], baseHalfExtents[2])); pTempBox->calculateLocalInertia(baseMass, baseInertiaDiag); diff --git a/examples/DeformableDemo/Pinch.cpp b/examples/DeformableDemo/Pinch.cpp index dbf1e6c801..6ed489b604 100644 --- a/examples/DeformableDemo/Pinch.cpp +++ b/examples/DeformableDemo/Pinch.cpp @@ -58,7 +58,7 @@ class Pinch : public CommonDeformableBodyBase void stepSimulation(float deltaTime) { //use a smaller internal timestep, there are stability issues - float internalTimeStep = 1. / 240.f; + float internalTimeStep = 1.f / 240.f; m_dynamicsWorld->stepSimulation(deltaTime, 4, internalTimeStep); } @@ -68,6 +68,7 @@ class Pinch : public CommonDeformableBodyBase float mass = 1e6; btCollisionShape* shape[] = { new btBoxShape(btVector3(3, 3, 0.5)), + NULL }; static const int nshapes = sizeof(shape) / sizeof(shape[0]); for (int i = 0; i < count; ++i) @@ -96,13 +97,13 @@ class Pinch : public CommonDeformableBodyBase } }; -void dynamics(btScalar time, btDeformableMultiBodyDynamicsWorld* world) +static void dynamics(btScalar time, btDeformableMultiBodyDynamicsWorld* world) { btAlignedObjectArray& rbs = world->getNonStaticRigidBodies(); if (rbs.size()<2) return; btRigidBody* rb0 = rbs[0]; - btScalar pressTime = 0.9; + btScalar pressTime = btScalar(0.9); btScalar liftTime = 2.5; btScalar shiftTime = 3.5; btScalar holdTime = 4.5*1000; @@ -256,6 +257,7 @@ void Pinch::initPhysics() // create a soft block { + /* btScalar verts[24] = {0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 1.f, 0.f, @@ -286,6 +288,7 @@ void Pinch::initPhysics() 4,5,0, 4,5,6, }; + */ // btSoftBody* psb = btSoftBodyHelpers::CreateFromTriMesh(getDeformableDynamicsWorld()->getWorldInfo(), &verts[0], &triangles[0], 20); //// btSoftBody* psb = btSoftBodyHelpers::CreateFromTetGenData(getDeformableDynamicsWorld()->getWorldInfo(), @@ -296,7 +299,7 @@ void Pinch::initPhysics() psb->scale(btVector3(2, 2, 2)); psb->translate(btVector3(0, 4, 0)); - psb->getCollisionShape()->setMargin(0.01); + psb->getCollisionShape()->setMargin(btScalar(0.01)); psb->setTotalMass(1); psb->m_cfg.kKHR = 1; // collision hardness with kinematic objects psb->m_cfg.kCHR = 1; // collision hardness with rigid body @@ -310,11 +313,11 @@ void Pinch::initPhysics() getDeformableDynamicsWorld()->addForce(psb, gravity_force); m_forces.push_back(gravity_force); - btDeformableNeoHookeanForce* neohookean = new btDeformableNeoHookeanForce(8,3, 0.02); - neohookean->setPoissonRatio(0.3); + btDeformableNeoHookeanForce* neohookean = new btDeformableNeoHookeanForce(8,3, btScalar(0.02)); + neohookean->setPoissonRatio(btScalar(0.3)); neohookean->setYoungsModulus(25); - neohookean->setDamping(0.01); - psb->m_cfg.drag = 0.001; + neohookean->setDamping(btScalar(0.01)); + psb->m_cfg.drag = btScalar(0.001); getDeformableDynamicsWorld()->addForce(psb, neohookean); m_forces.push_back(neohookean); // add a grippers diff --git a/examples/DeformableDemo/PinchFriction.cpp b/examples/DeformableDemo/PinchFriction.cpp index 5d31331b6f..0ad0f506f8 100644 --- a/examples/DeformableDemo/PinchFriction.cpp +++ b/examples/DeformableDemo/PinchFriction.cpp @@ -33,7 +33,6 @@ struct TetraCube class PinchFriction : public CommonDeformableBodyBase { - btAlignedObjectArray m_forces; public: PinchFriction(struct GUIHelperInterface* helper) : CommonDeformableBodyBase(helper) @@ -58,7 +57,7 @@ class PinchFriction : public CommonDeformableBodyBase void stepSimulation(float deltaTime) { //use a smaller internal timestep, there are stability issues - float internalTimeStep = 1. / 240.f; + float internalTimeStep = 1.f / 240.f; m_dynamicsWorld->stepSimulation(deltaTime, 4, internalTimeStep); } @@ -68,6 +67,7 @@ class PinchFriction : public CommonDeformableBodyBase float mass = 1e6; btCollisionShape* shape[] = { new btBoxShape(btVector3(3, 3, 0.5)), + NULL }; static const int nshapes = sizeof(shape) / sizeof(shape[0]); for (int i = 0; i < count; ++i) @@ -85,28 +85,28 @@ class PinchFriction : public CommonDeformableBodyBase CommonDeformableBodyBase::renderScene(); } - virtual bool pickBody(const btVector3& rayFromWorld, const btVector3& rayToWorld) + virtual bool pickBody(const btVector3& /*rayFromWorld*/, const btVector3& /*rayToWorld*/) { return false; } - virtual bool movePickedBody(const btVector3& rayFromWorld, const btVector3& rayToWorld) + virtual bool movePickedBody(const btVector3& /*rayFromWorld*/, const btVector3& /*rayToWorld*/) { return false; } virtual void removePickingConstraint(){} }; -void dynamics2(btScalar time, btDeformableMultiBodyDynamicsWorld* world) +static void dynamics2(btScalar time, btDeformableMultiBodyDynamicsWorld* world) { btAlignedObjectArray& rbs = world->getNonStaticRigidBodies(); if (rbs.size()<2) return; btRigidBody* rb0 = rbs[0]; - btScalar pressTime = 0.45; + btScalar pressTime = btScalar(0.45); btScalar liftTime = 5; - btScalar shiftTime = 1.75; + btScalar shiftTime = btScalar(1.75); btScalar holdTime = 7.5; - btScalar dropTime = 8.3; + btScalar dropTime = btScalar(8.3); btTransform rbTransform; rbTransform.setIdentity(); btVector3 translation; @@ -264,10 +264,10 @@ void PinchFriction::initPhysics() false, true, true); psb->scale(btVector3(2, 2, 1)); - psb->translate(btVector3(0, 2.1, 2.2)); - psb->getCollisionShape()->setMargin(0.025); + psb->translate(btVector3(0, btScalar(2.1), btScalar(2.2))); + psb->getCollisionShape()->setMargin(btScalar(0.025)); psb->setSpringStiffness(10); - psb->setTotalMass(.6); + psb->setTotalMass(btScalar(.6)); psb->m_cfg.kKHR = 1; // collision hardness with kinematic objects psb->m_cfg.kCHR = 1; // collision hardness with rigid body psb->m_cfg.kDF = 2; @@ -281,7 +281,7 @@ void PinchFriction::initPhysics() getDeformableDynamicsWorld()->addForce(psb, gravity_force); m_forces.push_back(gravity_force); - btDeformableNeoHookeanForce* neohookean = new btDeformableNeoHookeanForce(6,6,.003); + btDeformableNeoHookeanForce* neohookean = new btDeformableNeoHookeanForce(6,6,btScalar(.003)); getDeformableDynamicsWorld()->addForce(psb, neohookean); m_forces.push_back(neohookean); } @@ -295,9 +295,9 @@ void PinchFriction::initPhysics() false, true, true); psb2->scale(btVector3(2, 2, 1)); - psb2->translate(btVector3(0, 2.1, -2.2)); - psb2->getCollisionShape()->setMargin(0.025); - psb2->setTotalMass(.6); + psb2->translate(btVector3(0, btScalar(2.1), btScalar(-2.2))); + psb2->getCollisionShape()->setMargin(btScalar(0.025)); + psb2->setTotalMass(btScalar(.6)); psb2->m_cfg.kKHR = 1; // collision hardness with kinematic objects psb2->m_cfg.kCHR = 1; // collision hardness with rigid body psb2->m_cfg.kDF = 2; @@ -312,7 +312,7 @@ void PinchFriction::initPhysics() getDeformableDynamicsWorld()->addForce(psb2, gravity_force); m_forces.push_back(gravity_force); - btDeformableNeoHookeanForce* neohookean = new btDeformableNeoHookeanForce(6,6,.003); + btDeformableNeoHookeanForce* neohookean = new btDeformableNeoHookeanForce(6,6,btScalar(.003)); getDeformableDynamicsWorld()->addForce(psb2, neohookean); m_forces.push_back(neohookean); } @@ -326,9 +326,9 @@ void PinchFriction::initPhysics() false, true, true); psb3->scale(btVector3(2, 2, 1)); - psb3->translate(btVector3(0, 2.1, 0)); - psb3->getCollisionShape()->setMargin(0.025); - psb3->setTotalMass(.6); + psb3->translate(btVector3(0, btScalar(2.1), 0)); + psb3->getCollisionShape()->setMargin(btScalar(0.025)); + psb3->setTotalMass(btScalar(.6)); psb3->setSpringStiffness(10); psb3->m_cfg.kKHR = 1; // collision hardness with kinematic objects psb3->m_cfg.kCHR = 1; // collision hardness with rigid body @@ -343,7 +343,7 @@ void PinchFriction::initPhysics() getDeformableDynamicsWorld()->addForce(psb3, gravity_force); m_forces.push_back(gravity_force); - btDeformableNeoHookeanForce* neohookean = new btDeformableNeoHookeanForce(6,6,.003); + btDeformableNeoHookeanForce* neohookean = new btDeformableNeoHookeanForce(6,6,btScalar(.003)); getDeformableDynamicsWorld()->addForce(psb3, neohookean); m_forces.push_back(neohookean); } diff --git a/examples/DeformableDemo/SplitImpulse.cpp b/examples/DeformableDemo/SplitImpulse.cpp index 962d49d668..abb31f70ab 100644 --- a/examples/DeformableDemo/SplitImpulse.cpp +++ b/examples/DeformableDemo/SplitImpulse.cpp @@ -51,20 +51,20 @@ class SplitImpulse : public CommonDeformableBodyBase void stepSimulation(float deltaTime) { //use a smaller internal timestep, there are stability issues - float internalTimeStep = 1. / 240.f; + float internalTimeStep = 1.f / 240.f; m_dynamicsWorld->stepSimulation(deltaTime, 4, internalTimeStep); } - void Ctor_RbUpStack(int count) + void Ctor_RbUpStack(int /*count*/) { - float mass = 0.2; + float mass = 0.2f; btCollisionShape* shape[] = { new btBoxShape(btVector3(1, 1, 1)), }; btTransform startTransform; startTransform.setIdentity(); - startTransform.setOrigin(btVector3(0, 0.7, 0)); + startTransform.setOrigin(btVector3(0, btScalar(0.7), 0)); createRigidBody(mass, startTransform, shape[0]); } @@ -92,7 +92,7 @@ void SplitImpulse::initPhysics() ///collision configuration contains default setup for memory, collision setup m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration(); - ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) + ///use the default collision dispatcher. For parallel processing you can use a different dispatcher (see Extras/BulletMultiThreaded) m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); @@ -160,7 +160,7 @@ void SplitImpulse::initPhysics() // 0, true); - psb->getCollisionShape()->setMargin(0.015); + psb->getCollisionShape()->setMargin(btScalar(0.015)); psb->generateBendingConstraints(2); psb->setTotalMass(1); psb->m_cfg.kKHR = 1; // collision hardness with kinematic objects diff --git a/examples/DeformableDemo/VolumetricDeformable.cpp b/examples/DeformableDemo/VolumetricDeformable.cpp index bfc51a1567..f130bfbaa9 100644 --- a/examples/DeformableDemo/VolumetricDeformable.cpp +++ b/examples/DeformableDemo/VolumetricDeformable.cpp @@ -28,9 +28,9 @@ ///The VolumetricDeformable shows the contact between volumetric deformable objects and rigid objects. static btScalar E = 50; -static btScalar nu = 0.3; -static btScalar damping_alpha = 0.1; -static btScalar damping_beta = 0.01; +static btScalar nu = btScalar(0.3); +static btScalar damping_alpha = btScalar(0.1); +static btScalar damping_beta = btScalar(0.01); struct TetraCube { @@ -72,7 +72,7 @@ class VolumetricDeformable : public CommonDeformableBodyBase m_linearElasticity->setYoungsModulus(E); m_linearElasticity->setDamping(damping_alpha, damping_beta); //use a smaller internal timestep, there are stability issues - float internalTimeStep = 1. / 240; + float internalTimeStep = 1.f / 240; m_dynamicsWorld->stepSimulation(deltaTime, 4, internalTimeStep); } @@ -119,13 +119,14 @@ class VolumetricDeformable : public CommonDeformableBodyBase btCollisionShape* shape[] = { new btBoxShape(btVector3(1, 1, 1)), + NULL }; static const int nshapes = sizeof(shape) / sizeof(shape[0]); for (int i = 0; i < count; ++i) { btTransform startTransform; startTransform.setIdentity(); - startTransform.setOrigin(btVector3(i, 10 + 2 * i, i-1)); + startTransform.setOrigin(btVector3((btScalar)i, btScalar(10 + 2 * i), btScalar(i-1))); createRigidBody(mass, startTransform, shape[i % nshapes]); } } @@ -153,7 +154,7 @@ void VolumetricDeformable::initPhysics() ///collision configuration contains default setup for memory, collision setup m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration(); - ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) + ///use the default collision dispatcher. For parallel processing you can use a different dispatcher (see Extras/BulletMultiThreaded) m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); @@ -212,7 +213,7 @@ void VolumetricDeformable::initPhysics() getDeformableDynamicsWorld()->addSoftBody(psb); psb->scale(btVector3(2, 2, 2)); psb->translate(btVector3(0, 5, 0)); - psb->getCollisionShape()->setMargin(0.1); + psb->getCollisionShape()->setMargin(btScalar(0.1)); psb->setTotalMass(0.5); psb->m_cfg.kKHR = 1; // collision hardness with kinematic objects psb->m_cfg.kCHR = 1; // collision hardness with rigid body @@ -225,7 +226,7 @@ void VolumetricDeformable::initPhysics() getDeformableDynamicsWorld()->addForce(psb, gravity_force); m_forces.push_back(gravity_force); - btDeformableLinearElasticityForce* linearElasticity = new btDeformableLinearElasticityForce(100,100,0.01); + btDeformableLinearElasticityForce* linearElasticity = new btDeformableLinearElasticityForce(100,100,btScalar(0.01)); m_linearElasticity = linearElasticity; getDeformableDynamicsWorld()->addForce(psb, linearElasticity); m_forces.push_back(linearElasticity); @@ -233,9 +234,9 @@ void VolumetricDeformable::initPhysics() getDeformableDynamicsWorld()->setImplicit(true); getDeformableDynamicsWorld()->setLineSearch(false); getDeformableDynamicsWorld()->setUseProjection(true); - getDeformableDynamicsWorld()->getSolverInfo().m_deformable_erp = 0.3; + getDeformableDynamicsWorld()->getSolverInfo().m_deformable_erp = btScalar(0.3); getDeformableDynamicsWorld()->getSolverInfo().m_deformable_maxErrorReduction = btScalar(200); - getDeformableDynamicsWorld()->getSolverInfo().m_leastSquaresResidualThreshold = 1e-3; + getDeformableDynamicsWorld()->getSolverInfo().m_leastSquaresResidualThreshold = btScalar(1e-3); getDeformableDynamicsWorld()->getSolverInfo().m_splitImpulse = true; getDeformableDynamicsWorld()->getSolverInfo().m_numIterations = 100; // add a few rigid bodies @@ -251,8 +252,8 @@ void VolumetricDeformable::initPhysics() } { SliderParams slider("Poisson Ratio", &nu); - slider.m_minVal = 0.05; - slider.m_maxVal = 0.49; + slider.m_minVal = 0.05f; + slider.m_maxVal = 0.49f; if (m_guiHelper->getParameterInterface()) m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider); } @@ -266,7 +267,7 @@ void VolumetricDeformable::initPhysics() { SliderParams slider("Stiffness Damping", &damping_beta); slider.m_minVal = 0; - slider.m_maxVal = 0.1; + slider.m_maxVal = 0.1f; if (m_guiHelper->getParameterInterface()) m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider); } diff --git a/examples/DynamicControlDemo/MotorDemo.cpp b/examples/DynamicControlDemo/MotorDemo.cpp index 850cd6c5d2..8bd3ed12bf 100644 --- a/examples/DynamicControlDemo/MotorDemo.cpp +++ b/examples/DynamicControlDemo/MotorDemo.cpp @@ -64,7 +64,7 @@ class MotorDemo : public CommonRigidBodyBase float dist = 11; float pitch = -35; float yaw = 52; - float targetPos[3] = {0, 0.46, 0}; + float targetPos[3] = {0, 0.46f, 0}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } }; @@ -159,7 +159,7 @@ class TestRig // legs for (i = 0; i < NUM_LEGS; i++) { - float fAngle = 2 * M_PI * i / NUM_LEGS; + float fAngle = float(2 * M_PI * i / NUM_LEGS); float fSin = std::sin(fAngle); float fCos = std::cos(fAngle); @@ -170,7 +170,7 @@ class TestRig // thigh btVector3 vToBone = (vBoneOrigin - vRoot).normalize(); btVector3 vAxis = vToBone.cross(vUp); - transform.setRotation(btQuaternion(vAxis, M_PI_2)); + transform.setRotation(btQuaternion(vAxis, btScalar(M_PI_2))); m_bodies[1 + 2 * i] = localCreateRigidBody(btScalar(1.), offset * transform, m_shapes[1 + 2 * i]); // shin @@ -182,9 +182,9 @@ class TestRig // Setup some damping on the m_bodies for (i = 0; i < BODYPART_COUNT; ++i) { - m_bodies[i]->setDamping(0.05, 0.85); - m_bodies[i]->setDeactivationTime(0.8); - //m_bodies[i]->setSleepingThresholds(1.6, 2.5); + m_bodies[i]->setDamping(0.05f, 0.85f); + m_bodies[i]->setDeactivationTime(0.8f); + //m_bodies[i]->setSleepingThresholds(1.6f, 2.5f); m_bodies[i]->setSleepingThresholds(0.5f, 0.5f); } @@ -198,7 +198,7 @@ class TestRig for (i = 0; i < NUM_LEGS; i++) { - float fAngle = 2 * M_PI * i / NUM_LEGS; + float fAngle = float(2 * M_PI * i / NUM_LEGS); float fSin = std::sin(fAngle); float fCos = std::cos(fAngle); @@ -259,7 +259,7 @@ class TestRig btTypedConstraint** GetJoints() { return &m_joints[0]; } }; -void motorPreTickCallback(btDynamicsWorld* world, btScalar timeStep) +static void motorPreTickCallback(btDynamicsWorld* world, btScalar timeStep) { MotorDemo* motorDemo = (MotorDemo*)world->getWorldUserInfo(); @@ -321,13 +321,13 @@ void MotorDemo::spawnTestRig(const btVector3& startOffset, bool bFixed) m_rigs.push_back(rig); } -void PreStep() +static void PreStep() { } void MotorDemo::setMotorTargets(btScalar deltaTime) { - float ms = deltaTime * 1000000.; + float ms = float(deltaTime * 1000000.); float minFPS = 1000000.f / 60.f; if (ms > minFPS) ms = minFPS; @@ -344,8 +344,8 @@ void MotorDemo::setMotorTargets(btScalar deltaTime) btHingeConstraint* hingeC = static_cast(m_rigs[r]->GetJoints()[i]); btScalar fCurAngle = hingeC->getHingeAngle(); - btScalar fTargetPercent = (int(m_Time / 1000) % int(m_fCyclePeriod)) / m_fCyclePeriod; - btScalar fTargetAngle = 0.5 * (1 + sin(2 * M_PI * fTargetPercent)); + btScalar fTargetPercent = (float)(int(m_Time / 1000) % int(m_fCyclePeriod)) / m_fCyclePeriod; + btScalar fTargetAngle = btScalar(0.5 * (1 + sin(2 * M_PI * fTargetPercent))); btScalar fTargetLimitAngle = hingeC->getLowerLimit() + fTargetAngle * (hingeC->getUpperLimit() - hingeC->getLowerLimit()); btScalar fAngleError = fTargetLimitAngle - fCurAngle; btScalar fDesiredAngularVel = 1000000.f * fAngleError / ms; diff --git a/examples/Evolution/NN3DWalkers.cpp b/examples/Evolution/NN3DWalkers.cpp index 6ac7d8a23b..c549756e1d 100755 --- a/examples/Evolution/NN3DWalkers.cpp +++ b/examples/Evolution/NN3DWalkers.cpp @@ -99,7 +99,7 @@ static btScalar gParallelEvaluations = 10.0f; #define JOINT_COUNT (BODYPART_COUNT - 1) #define DRAW_INTERPENETRATIONS false -void* GROUND_ID = (void*)1; +static void* GROUND_ID = (void*)1; class NN3DWalkersExample : public NN3DWalkersTimeWarpBase { @@ -149,7 +149,7 @@ class NN3DWalkersExample : public NN3DWalkersTimeWarpBase float dist = 11; float pitch = -35; float yaw = 52; - float targetPos[3] = {0, 0.46, 0}; + float targetPos[3] = {0, 0.46f, 0}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } @@ -226,7 +226,7 @@ class NNWalker { for (int j = 0; j < JOINT_COUNT; j++) { - m_sensoryMotorWeights[i + j * BODYPART_COUNT] = ((double)rand() / (RAND_MAX)) * 2.0f - 1.0f; + m_sensoryMotorWeights[i + j * BODYPART_COUNT] = (btScalar)(((double)rand() / (RAND_MAX)) * 2.0f - 1.0f); } } } @@ -267,7 +267,7 @@ class NNWalker transform.setIdentity(); transform.setOrigin(localRootBodyPosition); - btTransform originTransform = transform; + // btTransform originTransform = transform; m_bodies[0] = localCreateRigidBody(btScalar(bFixed ? 0. : 1.), bodyOffset * transform, m_shapes[0]); m_ownerWorld->addRigidBody(m_bodies[0]); @@ -283,7 +283,7 @@ class NNWalker // legs for (i = 0; i < NUM_LEGS; i++) { - float footAngle = 2 * SIMD_PI * i / NUM_LEGS; // legs are uniformly distributed around the root body + float footAngle = float(2 * SIMD_PI * (btScalar)i / (btScalar)NUM_LEGS); // legs are uniformly distributed around the root body float footYUnitPosition = std::sin(footAngle); // y position of the leg on the unit circle float footXUnitPosition = std::cos(footAngle); // x position of the leg on the unit circle @@ -357,9 +357,9 @@ class NNWalker // Setup some damping on the m_bodies for (i = 0; i < BODYPART_COUNT; ++i) { - m_bodies[i]->setDamping(0.05, 0.85); - m_bodies[i]->setDeactivationTime(0.8); - //m_bodies[i]->setSleepingThresholds(1.6, 2.5); + m_bodies[i]->setDamping(0.05f, 0.85f); + m_bodies[i]->setDeactivationTime(0.8f); + //m_bodies[i]->setSleepingThresholds(1.6f, 2.5f); m_bodies[i]->setSleepingThresholds(0.5f, 0.5f); } @@ -537,7 +537,7 @@ class NNWalker void evaluationUpdatePreTickCallback(btDynamicsWorld* world, btScalar timeStep); -bool legContactProcessedCallback(btManifoldPoint& cp, void* body0, void* body1) +static bool legContactProcessedCallback(btManifoldPoint& cp, void* body0, void* body1) { btCollisionObject* o1 = static_cast(body0); btCollisionObject* o2 = static_cast(body1); @@ -553,7 +553,7 @@ bool legContactProcessedCallback(btManifoldPoint& cp, void* body0, void* body1) { if (!nn3DWalkers->mIsHeadless) { - nn3DWalkers->m_dynamicsWorld->getDebugDrawer()->drawSphere(cp.getPositionWorldOnA(), 0.1, btVector3(1., 0., 0.)); + nn3DWalkers->m_dynamicsWorld->getDebugDrawer()->drawSphere(cp.getPositionWorldOnA(), btScalar(0.1), btVector3(1., 0., 0.)); } } @@ -610,7 +610,7 @@ void NN3DWalkersExample::initPhysics() // new SIMD solver for joints clips accumulated impulse, so the new limits for the motor // should be (numberOfsolverIterations * oldLimits) - m_motorStrength = 0.05f * m_dynamicsWorld->getSolverInfo().m_numIterations; + m_motorStrength = 0.05f * (float)m_dynamicsWorld->getSolverInfo().m_numIterations; { // create a slider to change the motor update frequency SliderParams slider("Motor update frequency", &m_targetFrequency); @@ -712,12 +712,12 @@ void NN3DWalkersExample::initPhysics() float maxDimension = 0.2f; // randomize the dimensions - gRootBodyRadius = ((double)rand() / (RAND_MAX)) * (maxDimension - 0.01f) + 0.01f; - gRootBodyHeight = ((double)rand() / (RAND_MAX)) * (maxDimension - 0.01f) + 0.01f; - gLegRadius = ((double)rand() / (RAND_MAX)) * (maxDimension - 0.01f) + 0.01f; - gLegLength = ((double)rand() / (RAND_MAX)) * (maxDimension - 0.01f) + 0.01f; - gForeLegLength = ((double)rand() / (RAND_MAX)) * (maxDimension - 0.01f) + 0.01f; - gForeLegRadius = ((double)rand() / (RAND_MAX)) * (maxDimension - 0.01f) + 0.01f; + gRootBodyRadius = btScalar(((double)rand() / (RAND_MAX)) * (maxDimension - 0.01f) + 0.01f); + gRootBodyHeight = btScalar(((double)rand() / (RAND_MAX)) * (maxDimension - 0.01f) + 0.01f); + gLegRadius = btScalar(((double)rand() / (RAND_MAX)) * (maxDimension - 0.01f) + 0.01f); + gLegLength = btScalar(((double)rand() / (RAND_MAX)) * (maxDimension - 0.01f) + 0.01f); + gForeLegLength = btScalar(((double)rand() / (RAND_MAX)) * (maxDimension - 0.01f) + 0.01f); + gForeLegRadius = btScalar(((double)rand() / (RAND_MAX)) * (maxDimension - 0.01f) + 0.01f); } // Spawn one walker @@ -732,7 +732,7 @@ void NN3DWalkersExample::initPhysics() m_timeSeriesCanvas->setupTimeSeries(40, NUM_WALKERS * EVALUATION_TIME, 0); for (int i = 0; i < NUM_WALKERS; i++) { - m_timeSeriesCanvas->addDataSource(" ", 100 * i / NUM_WALKERS, 100 * (NUM_WALKERS - i) / NUM_WALKERS, 100 * (i) / NUM_WALKERS); + m_timeSeriesCanvas->addDataSource(" ", (unsigned char)(100 * i / NUM_WALKERS), (unsigned char)(100 * (NUM_WALKERS - i) / NUM_WALKERS), (unsigned char)(100 * (i) / NUM_WALKERS)); } } @@ -748,37 +748,37 @@ bool NN3DWalkersExample::detectCollisions() if (m_dynamicsWorld) { m_dynamicsWorld->performDiscreteCollisionDetection(); // let the collisions be calculated - } - - int numManifolds = m_dynamicsWorld->getDispatcher()->getNumManifolds(); - for (int i = 0; i < numManifolds; i++) - { - btPersistentManifold* contactManifold = m_dynamicsWorld->getDispatcher()->getManifoldByIndexInternal(i); - const btCollisionObject* obA = contactManifold->getBody0(); - const btCollisionObject* obB = contactManifold->getBody1(); - if (obA->getUserPointer() != GROUND_ID && obB->getUserPointer() != GROUND_ID) + int numManifolds = m_dynamicsWorld->getDispatcher()->getNumManifolds(); + for (int i = 0; i < numManifolds; i++) { - int numContacts = contactManifold->getNumContacts(); - for (int j = 0; j < numContacts; j++) + btPersistentManifold* contactManifold = m_dynamicsWorld->getDispatcher()->getManifoldByIndexInternal(i); + const btCollisionObject* obA = contactManifold->getBody0(); + const btCollisionObject* obB = contactManifold->getBody1(); + + if (obA->getUserPointer() != GROUND_ID && obB->getUserPointer() != GROUND_ID) { - collisionDetected = true; - btManifoldPoint& pt = contactManifold->getContactPoint(j); - if (pt.getDistance() < 0.f) + int numContacts = contactManifold->getNumContacts(); + for (int j = 0; j < numContacts; j++) { - //const btVector3& ptA = pt.getPositionWorldOnA(); - //const btVector3& ptB = pt.getPositionWorldOnB(); - //const btVector3& normalOnB = pt.m_normalWorldOnB; - - if (!DRAW_INTERPENETRATIONS) + collisionDetected = true; + btManifoldPoint& pt = contactManifold->getContactPoint(j); + if (pt.getDistance() < 0.f) { - return collisionDetected; - } + //const btVector3& ptA = pt.getPositionWorldOnA(); + //const btVector3& ptB = pt.getPositionWorldOnB(); + //const btVector3& normalOnB = pt.m_normalWorldOnB; - if (m_dynamicsWorld->getDebugDrawer()) - { - m_dynamicsWorld->getDebugDrawer()->drawSphere(pt.getPositionWorldOnA(), 0.1, btVector3(0., 0., 1.)); - m_dynamicsWorld->getDebugDrawer()->drawSphere(pt.getPositionWorldOnB(), 0.1, btVector3(0., 0., 1.)); + if (!DRAW_INTERPENETRATIONS) + { + return collisionDetected; + } + + if (m_dynamicsWorld->getDebugDrawer()) + { + m_dynamicsWorld->getDebugDrawer()->drawSphere(pt.getPositionWorldOnA(), btScalar(0.1), btVector3(0., 0., 1.)); + m_dynamicsWorld->getDebugDrawer()->drawSphere(pt.getPositionWorldOnB(), btScalar(0.1), btVector3(0., 0., 1.)); + } } } } @@ -829,7 +829,7 @@ class CommonExampleInterface* ET_NN3DWalkersCreateFunc(struct CommonExampleOptio return nn3DWalkers; } -bool fitnessComparator(const NNWalker* a, const NNWalker* b) +static bool fitnessComparator(const NNWalker* a, const NNWalker* b) { return a->getFitness() > b->getFitness(); // sort walkers descending } @@ -842,7 +842,7 @@ void NN3DWalkersExample::rateEvaluations() for (int i = 0; i < NUM_WALKERS; i++) { - m_timeSeriesCanvas->insertDataAtCurrentTime(btSqrt(m_walkersInPopulation[i]->getDistanceFitness()), 0, true); + m_timeSeriesCanvas->insertDataAtCurrentTime((float)btSqrt(m_walkersInPopulation[i]->getDistanceFitness()), 0, true); } m_timeSeriesCanvas->nextTick(); @@ -856,7 +856,7 @@ void NN3DWalkersExample::rateEvaluations() void NN3DWalkersExample::reap() { int reaped = 0; - for (int i = NUM_WALKERS - 1; i >= (NUM_WALKERS - 1) * (1 - REAP_QTY); i--) + for (int i = NUM_WALKERS - 1; (float)i >= (float)(NUM_WALKERS - 1) * (1 - REAP_QTY); i--) { // reap a certain percentage m_walkersInPopulation[i]->setReaped(true); reaped++; @@ -866,17 +866,17 @@ void NN3DWalkersExample::reap() NNWalker* NN3DWalkersExample::getRandomElite() { - return m_walkersInPopulation[((NUM_WALKERS - 1) * SOW_ELITE_QTY) * (rand() / RAND_MAX)]; + return m_walkersInPopulation[int(((NUM_WALKERS - 1) * SOW_ELITE_QTY) * (float)(rand() / RAND_MAX))]; } NNWalker* NN3DWalkersExample::getRandomNonElite() { - return m_walkersInPopulation[(NUM_WALKERS - 1) * SOW_ELITE_QTY + (NUM_WALKERS - 1) * (1.0f - SOW_ELITE_QTY) * (rand() / RAND_MAX)]; + return m_walkersInPopulation[int((NUM_WALKERS - 1) * SOW_ELITE_QTY + (NUM_WALKERS - 1) * (1.0f - SOW_ELITE_QTY) * (float)(rand() / RAND_MAX))]; } NNWalker* NN3DWalkersExample::getNextReaped() { - if ((NUM_WALKERS - 1) - m_nextReaped >= (NUM_WALKERS - 1) * (1 - REAP_QTY)) + if ((float)((NUM_WALKERS - 1) - m_nextReaped) >= (float)(NUM_WALKERS - 1) * (1 - REAP_QTY)) { m_nextReaped++; } @@ -894,22 +894,22 @@ NNWalker* NN3DWalkersExample::getNextReaped() void NN3DWalkersExample::sow() { int sow = 0; - for (int i = 0; i < NUM_WALKERS * (SOW_CROSSOVER_QTY); i++) + for (int i = 0; (float)i < (float)NUM_WALKERS * (SOW_CROSSOVER_QTY); i++) { // create number of new crossover creatures sow++; b3Printf("%i Walker(s) sown.", sow); NNWalker* mother = getRandomElite(); // Get elite partner (mother) - NNWalker* father = (SOW_ELITE_PARTNER < rand() / RAND_MAX) ? getRandomElite() : getRandomNonElite(); //Get elite or random partner (father) + NNWalker* father = (SOW_ELITE_PARTNER < (float)(rand() / RAND_MAX)) ? getRandomElite() : getRandomNonElite(); //Get elite or random partner (father) NNWalker* offspring = getNextReaped(); crossover(mother, father, offspring); } - for (int i = NUM_WALKERS * SOW_ELITE_QTY; i < NUM_WALKERS * (SOW_ELITE_QTY + SOW_MUTATION_QTY); i++) + for (int i = int((float)NUM_WALKERS * SOW_ELITE_QTY); (float)i < (float)NUM_WALKERS * (SOW_ELITE_QTY + SOW_MUTATION_QTY); i++) { // create mutants - mutate(m_walkersInPopulation[i], btScalar(MUTATION_RATE / (NUM_WALKERS * SOW_MUTATION_QTY) * (i - NUM_WALKERS * SOW_ELITE_QTY))); + mutate(m_walkersInPopulation[i], btScalar(MUTATION_RATE / (NUM_WALKERS * SOW_MUTATION_QTY) * ((float)i - NUM_WALKERS * SOW_ELITE_QTY))); } - for (int i = 0; i < (NUM_WALKERS - 1) * (REAP_QTY - SOW_CROSSOVER_QTY); i++) + for (int i = 0; (float)i < (float)(NUM_WALKERS - 1) * (REAP_QTY - SOW_CROSSOVER_QTY); i++) { sow++; b3Printf("%i Walker(s) sown.", sow); @@ -923,7 +923,7 @@ void NN3DWalkersExample::crossover(NNWalker* mother, NNWalker* father, NNWalker* { for (int i = 0; i < BODYPART_COUNT * JOINT_COUNT; i++) { - btScalar random = ((double)rand() / (RAND_MAX)); + btScalar random = btScalar((double)rand() / (RAND_MAX)); if (random >= 0.5f) { @@ -940,11 +940,11 @@ void NN3DWalkersExample::mutate(NNWalker* mutant, btScalar mutationRate) { for (int i = 0; i < BODYPART_COUNT * JOINT_COUNT; i++) { - btScalar random = ((double)rand() / (RAND_MAX)); + btScalar random = btScalar((double)rand() / (RAND_MAX)); if (random >= mutationRate) { - mutant->getSensoryMotorWeights()[i] = ((double)rand() / (RAND_MAX)) * 2.0f - 1.0f; + mutant->getSensoryMotorWeights()[i] = btScalar(((double)rand() / (RAND_MAX)) * 2.0f - 1.0f); } } } @@ -1007,7 +1007,7 @@ void NN3DWalkersExample::updateEvaluations(const btScalar timeSinceLastTick) if (RANDOM_MOVEMENT) { - targetAngle = ((double)rand() / (RAND_MAX)); + targetAngle = btScalar((double)rand() / (RAND_MAX)); } else { // neural network movement @@ -1025,7 +1025,7 @@ void NN3DWalkersExample::updateEvaluations(const btScalar timeSinceLastTick) btScalar currentAngle = hingeC->getHingeAngle(); btScalar angleError = targetLimitAngle - currentAngle; btScalar desiredAngularVel = 0; - if (delta) + if (delta != btScalar(0)) { desiredAngularVel = angleError / delta; } @@ -1055,7 +1055,7 @@ void NN3DWalkersExample::scheduleEvaluations() m_evaluationsQty--; } - if (m_evaluationsQty < gParallelEvaluations && !m_walkersInPopulation[i]->isInEvaluation() && m_walkersInPopulation[i]->getEvaluationTime() == 0) + if ((btScalar)m_evaluationsQty < gParallelEvaluations && !m_walkersInPopulation[i]->isInEvaluation() && m_walkersInPopulation[i]->getEvaluationTime() == 0) { /**!< Setup the new evaluations */ b3Printf("An evaluation started at %f s.", m_Time); m_evaluationsQty++; @@ -1093,7 +1093,7 @@ void NN3DWalkersExample::drawMarkings() btVector3 walkerPosition = m_walkersInPopulation[i]->getPosition(); char performance[20]; sprintf(performance, "%.2f m", btSqrt(m_walkersInPopulation[i]->getDistanceFitness())); - m_guiHelper->drawText3D(performance, walkerPosition.x(), walkerPosition.y() + 1, walkerPosition.z(), 1); + m_guiHelper->drawText3D(performance, (float)walkerPosition.x(), (float)walkerPosition.y() + 1, (float)walkerPosition.z(), 1); } } @@ -1101,7 +1101,7 @@ void NN3DWalkersExample::drawMarkings() { // draw distance circles if (m_dynamicsWorld->getDebugDrawer()) { - m_dynamicsWorld->getDebugDrawer()->drawArc(btVector3(0, 0, 0), btVector3(0, 1, 0), btVector3(1, 0, 0), btScalar(i), btScalar(i), btScalar(0), btScalar(SIMD_2_PI), btVector3(10 * i, 0, 0), false); + m_dynamicsWorld->getDebugDrawer()->drawArc(btVector3(0, 0, 0), btVector3(0, 1, 0), btVector3(1, 0, 0), btScalar(i), btScalar(i), btScalar(0), btScalar(SIMD_2_PI), btVector3(btScalar(10 * i), 0, 0), false); } } } diff --git a/examples/Evolution/NN3DWalkersTimeWarpBase.h b/examples/Evolution/NN3DWalkersTimeWarpBase.h index deef114766..ac312d4a9a 100644 --- a/examples/Evolution/NN3DWalkersTimeWarpBase.h +++ b/examples/Evolution/NN3DWalkersTimeWarpBase.h @@ -53,7 +53,7 @@ static double /*8*/ QUINCENTUPLE_SPEED = 500; static double /*9*/ MILLITUPLE_SPEED = 1000; static double /*0*/ MAX_SPEED = MILLITUPLE_SPEED; static double /**/ NUM_SPEEDS = 10; -}; // namespace SimulationSpeeds +} // namespace SimulationSpeeds // add speeds from the namespace here static double speeds[] = { @@ -70,9 +70,9 @@ static bool gIsHeadless = false; // demo runs with graphics by default static bool gChangeErpCfm = false; // flag to make recalculation of ERP/CFM -static int gMinSpeed = SimulationSpeeds::PAUSE; // the minimum simulation speed +static int gMinSpeed = (int)SimulationSpeeds::PAUSE; // the minimum simulation speed -static int gMaxSpeed = SimulationSpeeds::MAX_SPEED; // the maximum simulation speed +static int gMaxSpeed = (int)SimulationSpeeds::MAX_SPEED; // the maximum simulation speed static bool gMaximumSpeed = false; // the demo does not try to achieve maximum stepping speed by default @@ -104,7 +104,7 @@ static char NNCGSOLVER[] = "NNCG Solver"; static char DANZIGSOLVER[] = "Danzig Solver"; static char LEMKESOLVER[] = "Lemke Solver"; -}; // namespace SolverType +} // namespace SolverType static const char* solverTypes[NUM_SOLVERS]; @@ -127,7 +127,7 @@ static double fixedPhysicsStepSizeSec = 1.0f / gPhysicsStepsPerSecond; // static double fixedPhysicsStepSizeMilli = 1000.0f / gPhysicsStepsPerSecond; // step size in milliseconds static btScalar gApplicationFrequency = 60.0f; // number of internal application ticks per second -static int gApplicationTick = 1000.0f / gApplicationFrequency; //ms +static int gApplicationTick = int(1000.0f / gApplicationFrequency); //ms static btScalar gFramesPerSecond = 30.0f; // number of frames per second @@ -150,12 +150,12 @@ inline void twxChangeFPS(float framesPerSecond, void*) gFramesPerSecond = framesPerSecond; } -inline void twxChangeERPCFM(float notUsed, void*) +inline void twxChangeERPCFM(float /*notUsed*/, void*) { // function to change ERP/CFM appropriately gChangeErpCfm = true; } -inline void changeSolver(int comboboxId, const char* item, void* userPointer) +inline void changeSolver(int /*comboboxId*/, const char* item, void* /*userPointer*/) { // function to change the solver for (int i = 0; i < NUM_SOLVERS; i++) { @@ -169,7 +169,7 @@ inline void changeSolver(int comboboxId, const char* item, void* userPointer) b3Printf("No Change"); } -inline void twxChangeSolverIterations(float notUsed, void* userPtr) +inline void twxChangeSolverIterations(float /*notUsed*/, void* /*userPtr*/) { // change the solver iterations } @@ -187,29 +187,29 @@ inline void clampToCustomSpeedNotches(float speed, void*) minSpeed = speeds[i]; } } - gSimulationSpeed = minSpeed; + gSimulationSpeed = (btScalar)minSpeed; } -inline void switchInterpolated(int buttonId, bool buttonState, void* userPointer) +inline void switchInterpolated(int /*buttonId*/, bool /*buttonState*/, void* /*userPointer*/) { // toggle if interpolation steps are taken gInterpolate = !gInterpolate; // b3Printf("Interpolate substeps %s", gInterpolate?"on":"off"); } -inline void switchHeadless(int buttonId, bool buttonState, void* userPointer) +inline void switchHeadless(int /*buttonId*/, bool /*buttonState*/, void* /*userPointer*/) { // toggle if the demo should run headless gIsHeadless = !gIsHeadless; // b3Printf("Run headless %s", gIsHeadless?"on":"off"); } -inline void switchMaximumSpeed(int buttonId, bool buttonState, void* userPointer) +inline void switchMaximumSpeed(int /*buttonId*/, bool /*buttonState*/, void* /*userPointer*/) { // toggle it the demo should run as fast as possible // b3Printf("Run maximum speed %s", gMaximumSpeed?"on":"off"); } inline void setApplicationTick(float frequency, void*) { // set internal application tick - gApplicationTick = 1000.0f / frequency; + gApplicationTick = int(1000.0f / frequency); } /** @@ -223,7 +223,7 @@ struct NN3DWalkersTimeWarpBase : public CommonRigidBodyBase mSolverIterationsUpdated(false) { // main frame timer initialization - mApplicationStart = mLoopTimer.getTimeMilliseconds(); /**!< Initialize when the application started running */ + mApplicationStart = (unsigned long)mLoopTimer.getTimeMilliseconds(); /**!< Initialize when the application started running */ mInputClock = mApplicationStart; /**!< Initialize the last time the input was updated */ mPreviousModelIteration = mApplicationStart; mThisModelIteration = mApplicationStart; @@ -247,13 +247,13 @@ struct NN3DWalkersTimeWarpBase : public CommonRigidBodyBase mModelAccumulator = 0; mFrameTime = 0; - fpsTimeStamp = mLoopTimer.getTimeMilliseconds(); // to time the fps - fpsStep = 1000.0f / gFramesPerSecond; + fpsTimeStamp = (unsigned long)mLoopTimer.getTimeMilliseconds(); // to time the fps + fpsStep = double(btScalar(1000.0) / gFramesPerSecond); // performance measurements for this demo performanceTimestamp = 0; performedTime = 0; // time the physics steps consumed - speedUpPrintTimeStamp = mLoopTimer.getTimeSeconds(); // timer to print the speed up periodically + speedUpPrintTimeStamp = (unsigned long)mLoopTimer.getTimeSeconds(); // timer to print the speed up periodically mLoopTimer.reset(); } @@ -280,8 +280,8 @@ struct NN3DWalkersTimeWarpBase : public CommonRigidBodyBase // Force increase the simulation speed to run the simulation with the same accuracy but a higher speed SliderParams slider("Simulation speed", &gSimulationSpeed); - slider.m_minVal = gMinSpeed; - slider.m_maxVal = gMaxSpeed; + slider.m_minVal = (float)gMinSpeed; + slider.m_maxVal = (float)gMaxSpeed; slider.m_callback = clampToCustomSpeedNotches; slider.m_clampToNotches = false; if (m_guiHelper->getParameterInterface()) @@ -343,8 +343,8 @@ struct NN3DWalkersTimeWarpBase : public CommonRigidBodyBase // for the physics update SliderParams slider("Application Ticks", &gApplicationFrequency); - slider.m_minVal = gMinSpeed; - slider.m_maxVal = gMaxSpeed; + slider.m_minVal = (float)gMinSpeed; + slider.m_maxVal = (float)gMaxSpeed; slider.m_callback = setApplicationTick; slider.m_clampToNotches = false; if (m_guiHelper->getParameterInterface()) @@ -381,7 +381,7 @@ struct NN3DWalkersTimeWarpBase : public CommonRigidBodyBase // more complex simulations might need a higher number of iterations to converge, it also // depends on the type of solver. SliderParams slider( - "Solver interations", + "Solver interactions", &gSolverIterations); slider.m_minVal = 0; slider.m_maxVal = 1000; @@ -457,7 +457,7 @@ struct NN3DWalkersTimeWarpBase : public CommonRigidBodyBase m_collisionConfiguration = new btDefaultCollisionConfiguration(); //m_collisionConfiguration->setConvexConvexMultipointIterations(); - ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) + ///use the default collision dispatcher. For parallel processing you can use a different dispatcher (see Extras/BulletMultiThreaded) m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); // default broadphase @@ -546,7 +546,7 @@ struct NN3DWalkersTimeWarpBase : public CommonRigidBodyBase // m_dynamicsWorld->getSolverInfo().m_splitImpulseTurnErp); } - m_dynamicsWorld->getSolverInfo().m_numIterations = gSolverIterations; // set the number of solver iterations for iteration based solvers + m_dynamicsWorld->getSolverInfo().m_numIterations = (int)gSolverIterations; // set the number of solver iterations for iteration based solvers m_dynamicsWorld->setGravity(btVector3(0, -9.81f, 0)); // set gravity to -9.81 } @@ -554,14 +554,14 @@ struct NN3DWalkersTimeWarpBase : public CommonRigidBodyBase btScalar calculatePerformedSpeedup() { // calculate performed speedup // we calculate the performed speed up - btScalar speedUp = ((double)performedTime * 1000.0) / ((double)(mLoopTimer.getTimeMilliseconds() - performanceTimestamp)); + btScalar speedUp = btScalar((performedTime * 1000.0) / (double)(mLoopTimer.getTimeMilliseconds() - performanceTimestamp)); // b3Printf("Avg Effective speedup: %f",speedUp); performedTime = 0; - performanceTimestamp = mLoopTimer.getTimeMilliseconds(); + performanceTimestamp = (unsigned long)mLoopTimer.getTimeMilliseconds(); return speedUp; } - void timeWarpSimulation(float deltaTime) // Override this + void timeWarpSimulation(float /*deltaTime*/) // Override this { } @@ -572,13 +572,13 @@ struct NN3DWalkersTimeWarpBase : public CommonRigidBodyBase // // settings if (mPhysicsStepsPerSecondUpdated) { - changePhysicsStepsPerSecond(gPhysicsStepsPerSecond); + changePhysicsStepsPerSecond((float)gPhysicsStepsPerSecond); mPhysicsStepsPerSecondUpdated = false; } if (mFramesPerSecondUpdated) { - changeFPS(gFramesPerSecond); + changeFPS((float)gFramesPerSecond); mFramesPerSecondUpdated = false; } @@ -590,7 +590,7 @@ struct NN3DWalkersTimeWarpBase : public CommonRigidBodyBase if (mSolverIterationsUpdated) { - changeSolverIterations(gSolverIterations); + changeSolverIterations((int)gSolverIterations); mSolverIterationsUpdated = false; } @@ -604,18 +604,18 @@ struct NN3DWalkersTimeWarpBase : public CommonRigidBodyBase // model update - here you perform updates of your model, be it the physics model, the game or simulation state or anything not related to graphics and input timeWarpSimulation(deltaTime); - if (mLoopTimer.getTimeSeconds() - speedUpPrintTimeStamp > 1) + if (mLoopTimer.getTimeSeconds() - (btScalar)speedUpPrintTimeStamp > 1) { // on reset, we calculate the performed speed up //double speedUp = ((double)performedTime*1000.0)/((double)(mLoopTimer.getTimeMilliseconds()-performanceTimestamp)); // b3Printf("Avg Effective speedup: %f",speedUp); performedTime = 0; - performanceTimestamp = mLoopTimer.getTimeMilliseconds(); - speedUpPrintTimeStamp = mLoopTimer.getTimeSeconds(); + performanceTimestamp = (unsigned long)mLoopTimer.getTimeMilliseconds(); + speedUpPrintTimeStamp = (unsigned long)mLoopTimer.getTimeSeconds(); } // update timers - mThisModelIteration = mLoopTimer.getTimeMilliseconds(); + mThisModelIteration = (unsigned long)mLoopTimer.getTimeMilliseconds(); mFrameTime = mThisModelIteration - mPreviousModelIteration; /**!< Calculate the frame time (in Milliseconds) */ mPreviousModelIteration = mThisModelIteration; @@ -623,8 +623,8 @@ struct NN3DWalkersTimeWarpBase : public CommonRigidBodyBase mApplicationRuntime = mThisModelIteration - mApplicationStart; /**!< Update main frame timer (in Milliseconds) */ - mModelStart = mLoopTimer.getTimeMilliseconds(); /**!< Begin with the model update (in Milliseconds)*/ - mLastGraphicsTick = mModelStart - mGraphicsStart; /**!< Update graphics timer (in Milliseconds) */ + mModelStart = (unsigned long)mLoopTimer.getTimeMilliseconds(); /**!< Begin with the model update (in Milliseconds)*/ + mLastGraphicsTick = (long)(mModelStart - mGraphicsStart); /**!< Update graphics timer (in Milliseconds) */ if (gMaximumSpeed /** If maximum speed is enabled*/) { @@ -635,13 +635,13 @@ struct NN3DWalkersTimeWarpBase : public CommonRigidBodyBase performSpeedStep(); } - mInputStart = mLoopTimer.getTimeMilliseconds(); /**!< Start the input update */ - mLastModelTick = mInputStart - mModelStart; /**!< Calculate the time the model update took */ + mInputStart = (unsigned long)mLoopTimer.getTimeMilliseconds(); /**!< Start the input update */ + mLastModelTick = (long)(mInputStart - mModelStart); /**!< Calculate the time the model update took */ //############# // Input update - Game Clock part of the loop /** This runs once every gApplicationTick milliseconds on average */ - mInputDt = mThisModelIteration - mInputClock; + mInputDt = (long)(mThisModelIteration - mInputClock); if (mInputDt >= gApplicationTick) { mInputClock = mThisModelIteration; @@ -649,8 +649,8 @@ struct NN3DWalkersTimeWarpBase : public CommonRigidBodyBase // mInputHandler.update(mInputClock); /**!< update elements that work on the current input state */ } - mGraphicsStart = mLoopTimer.getTimeMilliseconds(); /**!< Start the graphics update */ - mLastInputTick = mGraphicsStart - mInputStart; /**!< Calculate the time the input injection took */ + mGraphicsStart = (unsigned long)mLoopTimer.getTimeMilliseconds(); /**!< Start the graphics update */ + mLastInputTick = (long)(mGraphicsStart - mInputStart); /**!< Calculate the time the input injection took */ //############# // Graphics update - Here you perform the representation of your model, meaning graphics rendering according to what your game or simulation model describes @@ -661,10 +661,10 @@ struct NN3DWalkersTimeWarpBase : public CommonRigidBodyBase // "Physics time: %u milliseconds / Graphics time: %u milliseconds / Input time: %u milliseconds / Total time passed: %u milliseconds", // mLastModelTick, mLastGraphicsTick, mLastInputTick, mApplicationRuntime); - } while (mLoopTimer.getTimeMilliseconds() - fpsTimeStamp < fpsStep); // escape the loop if it is time to render + } while ((double)(mLoopTimer.getTimeMilliseconds() - fpsTimeStamp) < fpsStep); // escape the loop if it is time to render // Unfortunately, the input is not included in the loop, therefore the input update frequency is equal to the fps - fpsTimeStamp = mLoopTimer.getTimeMilliseconds(); + fpsTimeStamp = (unsigned long)mLoopTimer.getTimeMilliseconds(); } virtual bool keyboardCallback(int key, int state) @@ -673,71 +673,73 @@ struct NN3DWalkersTimeWarpBase : public CommonRigidBodyBase { case '1': { - gSimulationSpeed = SimulationSpeeds::QUARTER_SPEED; + gSimulationSpeed = (btScalar)SimulationSpeeds::QUARTER_SPEED; gMaximumSpeed = false; return true; } case '2': { - gSimulationSpeed = SimulationSpeeds::HALF_SPEED; + gSimulationSpeed = (btScalar)SimulationSpeeds::HALF_SPEED; gMaximumSpeed = false; return true; } case '3': { - gSimulationSpeed = SimulationSpeeds::NORMAL_SPEED; + gSimulationSpeed = (btScalar)SimulationSpeeds::NORMAL_SPEED; gMaximumSpeed = false; return true; } case '4': { - gSimulationSpeed = SimulationSpeeds::DOUBLE_SPEED; + gSimulationSpeed = (btScalar)SimulationSpeeds::DOUBLE_SPEED; gMaximumSpeed = false; return true; } case '5': { - gSimulationSpeed = SimulationSpeeds::QUADRUPLE_SPEED; + gSimulationSpeed = (btScalar)SimulationSpeeds::QUADRUPLE_SPEED; gMaximumSpeed = false; return true; } case '6': { - gSimulationSpeed = SimulationSpeeds::DECUPLE_SPEED; + gSimulationSpeed = (btScalar)SimulationSpeeds::DECUPLE_SPEED; gMaximumSpeed = false; return true; } case '7': { - gSimulationSpeed = SimulationSpeeds::CENTUPLE_SPEED; + gSimulationSpeed = (btScalar)SimulationSpeeds::CENTUPLE_SPEED; gMaximumSpeed = false; return true; } case '8': { - gSimulationSpeed = SimulationSpeeds::QUINCENTUPLE_SPEED; + gSimulationSpeed = (btScalar)SimulationSpeeds::QUINCENTUPLE_SPEED; gMaximumSpeed = false; return true; } case '9': { - gSimulationSpeed = SimulationSpeeds::MILLITUPLE_SPEED; + gSimulationSpeed = (btScalar)SimulationSpeeds::MILLITUPLE_SPEED; gMaximumSpeed = false; return true; } case '0': { - gSimulationSpeed = SimulationSpeeds::MAX_SPEED; + gSimulationSpeed = (btScalar)SimulationSpeeds::MAX_SPEED; gMaximumSpeed = true; return true; } + default: + break; } return CommonRigidBodyBase::keyboardCallback(key, state); } void changePhysicsStepsPerSecond(float physicsStepsPerSecond) { // change the simulation accuracy - if (m_dynamicsWorld && physicsStepsPerSecond) + if (m_dynamicsWorld && physicsStepsPerSecond != 0.0f) { fixedPhysicsStepSizeSec = 1.0f / physicsStepsPerSecond; fixedPhysicsStepSizeMilli = 1000.0f / physicsStepsPerSecond; @@ -751,13 +753,13 @@ struct NN3DWalkersTimeWarpBase : public CommonRigidBodyBase if (m_dynamicsWorld) { m_dynamicsWorld->getSolverInfo().m_erp = b3ERPCFMHelper::getERP( // set the error reduction parameter - fixedPhysicsStepSizeSec, // step size per second + (btScalar)fixedPhysicsStepSizeSec, // step size per second gERPSpringK, // k of a spring in the equation F = k * x (x:position) gERPDamperC); // k of a damper in the equation F = k * v (v:velocity) m_dynamicsWorld->getSolverInfo().m_globalCfm = b3ERPCFMHelper::getCFM( // set the constraint force mixing according to the time step gCFMSingularityAvoidance, // singularity avoidance (if you experience unsolvable constraints, increase this value - fixedPhysicsStepSizeSec, // steps size per second + (btScalar)fixedPhysicsStepSizeSec, // steps size per second gCFMSpringK, // k of a spring in the equation F = k * x (x:position) gCFMDamperC); // k of a damper in the equation F = k * v (v:velocity) @@ -774,34 +776,34 @@ struct NN3DWalkersTimeWarpBase : public CommonRigidBodyBase m_dynamicsWorld->getSolverInfo().m_numIterations = iterations; } - void changeFPS(float framesPerSecond) + void changeFPS(float /*framesPerSecond*/) { // change the frames per second fpsStep = 1000.0f / gFramesPerSecond; } void performTrueSteps(btScalar timeStep) { // physics stepping without interpolated substeps - int subSteps = floor((timeStep / fixedPhysicsStepSizeSec) + 0.5); /**!< Calculate the number of full normal time steps we can take */ + int subSteps = (int)floor((timeStep / fixedPhysicsStepSizeSec) + 0.5); /**!< Calculate the number of full normal time steps we can take */ for (int i = 0; i < subSteps; i++) { /**!< Perform the number of substeps to reach the timestep*/ - if (timeStep && m_dynamicsWorld) + if (timeStep != btScalar(0) && m_dynamicsWorld) { // since we want to perform all proper steps, we perform no interpolated substeps - int subSteps = 1; + int subStepsL = 1; m_dynamicsWorld->stepSimulation(btScalar(timeStep), - btScalar(subSteps), btScalar(fixedPhysicsStepSizeSec)); + subStepsL, btScalar(fixedPhysicsStepSizeSec)); } } } void performInterpolatedSteps(btScalar timeStep) { // physics stepping with interpolated substeps - int subSteps = 1 + floor((timeStep / fixedPhysicsStepSizeSec) + 0.5); /**!< Calculate the number of full normal time steps we can take, plus 1 for safety of not losing time */ - if (timeStep && m_dynamicsWorld) + int subSteps = 1 + (int)floor((timeStep / fixedPhysicsStepSizeSec) + 0.5); /**!< Calculate the number of full normal time steps we can take, plus 1 for safety of not losing time */ + if (timeStep != btScalar(0) && m_dynamicsWorld) { - m_dynamicsWorld->stepSimulation(btScalar(timeStep), btScalar(subSteps), + m_dynamicsWorld->stepSimulation(btScalar(timeStep), subSteps, btScalar(fixedPhysicsStepSizeSec)); /**!< Perform the number of substeps to reach the timestep*/ } } @@ -826,56 +828,56 @@ struct NN3DWalkersTimeWarpBase : public CommonRigidBodyBase if (mPhysicsTick > 0) { // with positive physics tick we perform as many update steps until the time for it is used up - mPhysicsStepStart = mLoopTimer.getTimeMilliseconds(); /**!< The physics updates start (in Milliseconds)*/ + mPhysicsStepStart = (unsigned long)mLoopTimer.getTimeMilliseconds(); /**!< The physics updates start (in Milliseconds)*/ mPhysicsStepEnd = mPhysicsStepStart; - while (mPhysicsTick > mPhysicsStepEnd - mPhysicsStepStart) + while (mPhysicsTick > (long)(mPhysicsStepEnd - mPhysicsStepStart)) { /**!< Update the physics until we run out of time (in Milliseconds) */ // b3Printf("Physics passed: %u", mPhysicsStepEnd - mPhysicsStepStart); double timeStep = fixedPhysicsStepSizeSec; /**!< update the world (in Seconds) */ if (gInterpolate) { - performInterpolatedSteps(timeStep); + performInterpolatedSteps((btScalar)timeStep); } else { - performTrueSteps(timeStep); + performTrueSteps((btScalar)timeStep); } performedTime += timeStep; - mPhysicsStepEnd = mLoopTimer.getTimeMilliseconds(); /**!< Update the last physics step end to stop updating in time (in Milliseconds) */ + mPhysicsStepEnd = (unsigned long)mLoopTimer.getTimeMilliseconds(); /**!< Update the last physics step end to stop updating in time (in Milliseconds) */ } } } void performSpeedStep() { // force-perform the number of steps needed to achieve a certain speed (safe to too high speeds, meaning the application will lose time, not the physics) - if (mFrameTime > gApplicationTick) + if ((int)mFrameTime > gApplicationTick) { /** cap frametime to make the application lose time, not the physics (in Milliseconds) */ - mFrameTime = gApplicationTick; // This prevents the physics time accumulator to sum up too much time + mFrameTime = (unsigned long)gApplicationTick; // This prevents the physics time accumulator to sum up too much time } // The simulation therefore gets slower, but still performs all requested physics steps mModelAccumulator += mFrameTime; /**!< Accumulate the time the physics simulation has to perform in order to stay in real-time (in Milliseconds) */ // b3Printf("Model time accumulator: %u", mModelAccumulator); - int steps = floor(mModelAccumulator / fixedPhysicsStepSizeMilli); /**!< Calculate the number of time steps we can take */ + int steps = (int)floor((double)mModelAccumulator / fixedPhysicsStepSizeMilli); /**!< Calculate the number of time steps we can take */ // b3Printf("Next steps: %i", steps); if (steps > 0) { /**!< Update if we can take at least one step */ - double timeStep = gSimulationSpeed * steps * fixedPhysicsStepSizeSec; /**!< update the universe (in Seconds) */ + double timeStep = (double)gSimulationSpeed * (double)steps * fixedPhysicsStepSizeSec; /**!< update the universe (in Seconds) */ if (gInterpolate) { - performInterpolatedSteps(timeStep); // perform interpolated steps + performInterpolatedSteps((btScalar)timeStep); // perform interpolated steps } else { - performTrueSteps(timeStep); // perform full steps + performTrueSteps((btScalar)timeStep); // perform full steps } performedTime += timeStep; // sum up the performed time for measuring the speed up - mModelAccumulator -= steps * fixedPhysicsStepSizeMilli; /**!< Remove the time performed by the physics simulation from the accumulator, the remaining time carries over to the next cycle (in Milliseconds) */ + mModelAccumulator -= long(steps * fixedPhysicsStepSizeMilli); /**!< Remove the time performed by the physics simulation from the accumulator, the remaining time carries over to the next cycle (in Milliseconds) */ } } @@ -897,7 +899,7 @@ struct NN3DWalkersTimeWarpBase : public CommonRigidBodyBase float dist = 41; float pitch = 52; float yaw = 35; - float targetPos[3] = {0, 0.46, 0}; + float targetPos[3] = {0, 0.46f, 0}; m_guiHelper->resetCamera(dist, pitch, yaw, targetPos[0], targetPos[1], targetPos[2]); } diff --git a/examples/ExampleBrowser/CMakeLists.txt b/examples/ExampleBrowser/CMakeLists.txt index c690a6d88c..ebcc1e2622 100644 --- a/examples/ExampleBrowser/CMakeLists.txt +++ b/examples/ExampleBrowser/CMakeLists.txt @@ -10,20 +10,18 @@ FILE(GLOB GwenGUISupport_HDRS "GwenGUISupport/*" ) IF (WIN32) - INCLUDE_DIRECTORIES( - ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/glad - ) - ADD_DEFINITIONS(-DGLEW_STATIC) -ELSE(WIN32) - IF(APPLE) - find_library(COCOA NAMES Cocoa) - ELSE(APPLE) - ADD_DEFINITIONS("-DGLEW_INIT_OPENGL11_FUNCTIONS=1") - ADD_DEFINITIONS("-DGLEW_STATIC") - ADD_DEFINITIONS("-DGLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1") - INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/glad ) - ENDIF(APPLE) -ENDIF(WIN32) + INCLUDE_DIRECTORIES( + ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/glad + ) + ADD_DEFINITIONS(-DGLEW_STATIC) +ELSEIF(APPLE) + find_library(COCOA NAMES Cocoa REQUIRED) +ELSE() + ADD_DEFINITIONS("-DGLEW_INIT_OPENGL11_FUNCTIONS=1") + ADD_DEFINITIONS("-DGLEW_STATIC") + ADD_DEFINITIONS("-DGLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1") + INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/glad ) +ENDIF() ADD_LIBRARY(BulletExampleBrowserLib @@ -106,21 +104,19 @@ IF (WIN32) ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ) ADD_DEFINITIONS(-DGLEW_STATIC) -ELSE(WIN32) - IF(APPLE) - find_library(COCOA NAMES Cocoa) - MESSAGE(${COCOA}) - link_libraries(${COCOA} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}) - INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/glad ) - ELSE(APPLE) - ADD_DEFINITIONS("-DGLEW_INIT_OPENGL11_FUNCTIONS=1") - ADD_DEFINITIONS("-DGLEW_STATIC") - ADD_DEFINITIONS("-DGLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1") - INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/glad ) - FIND_PACKAGE(Threads) - LINK_LIBRARIES( ${CMAKE_THREAD_LIBS_INIT} ${DL} ) - ENDIF(APPLE) -ENDIF(WIN32) +ELSEIF(APPLE) + find_library(COCOA NAMES Cocoa REQUIRED) + MESSAGE(${COCOA}) + link_libraries(${COCOA} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}) + INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/glad ) +ELSE() + ADD_DEFINITIONS("-DGLEW_INIT_OPENGL11_FUNCTIONS=1") + ADD_DEFINITIONS("-DGLEW_STATIC") + ADD_DEFINITIONS("-DGLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1") + INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/glad ) + FIND_PACKAGE(Threads) + LINK_LIBRARIES( ${CMAKE_THREAD_LIBS_INIT} ${DL} ) +ENDIF() SET(ExtendedTutorialsSources diff --git a/examples/ExampleBrowser/CollisionShape2TriangleMesh.cpp b/examples/ExampleBrowser/CollisionShape2TriangleMesh.cpp index 7ba53d62eb..909207e761 100644 --- a/examples/ExampleBrowser/CollisionShape2TriangleMesh.cpp +++ b/examples/ExampleBrowser/CollisionShape2TriangleMesh.cpp @@ -2,7 +2,7 @@ #include "CollisionShape2TriangleMesh.h" #include "btBulletCollisionCommon.h" -#include "BulletCollision/CollisionShapes/btShapeHull.h" //to create a tesselation of a generic btConvexShape +#include "BulletCollision/CollisionShapes/btShapeHull.h" //to create a tessellation of a generic btConvexShape #include "BulletCollision/CollisionShapes/btConvexPolyhedron.h" void CollisionShape2TriangleMesh(btCollisionShape* collisionShape, const btTransform& parentTransform, btAlignedObjectArray& vertexPositions, btAlignedObjectArray& vertexNormals, btAlignedObjectArray& indicesOut) @@ -82,11 +82,11 @@ void CollisionShape2TriangleMesh(btCollisionShape* collisionShape, const btTrans for (int j = 2; j >= 0; j--) { - int graphicsindex; + int graphicsindex=0; switch (indicestype) { - case PHY_INTEGER: graphicsindex = gfxbase[j]; break; - case PHY_SHORT: graphicsindex = ((unsigned short*)gfxbase)[j]; break; - case PHY_UCHAR: graphicsindex = ((unsigned char*)gfxbase)[j]; break; + case PHY_INTEGER: graphicsindex = (int)gfxbase[j]; break; + case PHY_SHORT: graphicsindex = (int)((unsigned short*)gfxbase)[j]; break; + case PHY_UCHAR: graphicsindex = (int)((unsigned char*)gfxbase)[j]; break; default: btAssert(0); } if (type == PHY_FLOAT) @@ -179,9 +179,9 @@ void CollisionShape2TriangleMesh(btCollisionShape* collisionShape, const btTrans { btVector3 triNormal; - int index0 = hull->getIndexPointer()[t * 3 + 0]; - int index1 = hull->getIndexPointer()[t * 3 + 1]; - int index2 = hull->getIndexPointer()[t * 3 + 2]; + int index0 = (int)hull->getIndexPointer()[t * 3 + 0]; + int index1 = (int)hull->getIndexPointer()[t * 3 + 1]; + int index2 = (int)hull->getIndexPointer()[t * 3 + 2]; btVector3 pos0 = parentTransform * hull->getVertexPointer()[index0]; btVector3 pos1 = parentTransform * hull->getVertexPointer()[index1]; btVector3 pos2 = parentTransform * hull->getVertexPointer()[index2]; @@ -190,7 +190,7 @@ void CollisionShape2TriangleMesh(btCollisionShape* collisionShape, const btTrans for (int v = 0; v < 3; v++) { - int index = hull->getIndexPointer()[t * 3 + v]; + int index = (int)hull->getIndexPointer()[t * 3 + v]; btVector3 pos = parentTransform * hull->getVertexPointer()[index]; indicesOut.push_back(vertexPositions.size()); vertexPositions.push_back(pos); @@ -226,5 +226,5 @@ void CollisionShape2TriangleMesh(btCollisionShape* collisionShape, const btTrans } } } - }; + } } diff --git a/examples/ExampleBrowser/EmptyExample.h b/examples/ExampleBrowser/EmptyExample.h index 95ba27ffae..cd2412a3f3 100644 --- a/examples/ExampleBrowser/EmptyExample.h +++ b/examples/ExampleBrowser/EmptyExample.h @@ -16,12 +16,12 @@ class EmptyExample : public CommonExampleInterface virtual void initPhysics() {} virtual void exitPhysics() {} - virtual void stepSimulation(float deltaTime) {} + virtual void stepSimulation(float /*deltaTime*/) {} virtual void renderScene() {} - virtual void physicsDebugDraw(int debugFlags) {} - virtual bool mouseMoveCallback(float x, float y) { return false; } - virtual bool mouseButtonCallback(int button, int state, float x, float y) { return false; } - virtual bool keyboardCallback(int key, int state) { return false; } + virtual void physicsDebugDraw(int /*debugFlags*/) {} + virtual bool mouseMoveCallback(float /*x*/, float /*y*/) { return false; } + virtual bool mouseButtonCallback(int /*button*/, int /*state*/, float /*x*/, float /*y*/) { return false; } + virtual bool keyboardCallback(int /*key*/, int /*state*/) { return false; } }; #endif //EMPTY_EXAMPLE_H diff --git a/examples/ExampleBrowser/ExampleBrowserInterface.h b/examples/ExampleBrowser/ExampleBrowserInterface.h index f4867987ba..7786bcb091 100644 --- a/examples/ExampleBrowser/ExampleBrowserInterface.h +++ b/examples/ExampleBrowser/ExampleBrowserInterface.h @@ -21,4 +21,4 @@ class ExampleBrowserInterface virtual void setSharedMemoryInterface(class SharedMemoryInterface* sharedMem) = 0; }; -#endif //EXAMPLE_BROWSER_GUI_H \ No newline at end of file +#endif //EXAMPLE_BROWSER_GUI_H diff --git a/examples/ExampleBrowser/ExampleEntries.cpp b/examples/ExampleBrowser/ExampleEntries.cpp index 715a4396d6..d56f4353dc 100644 --- a/examples/ExampleBrowser/ExampleEntries.cpp +++ b/examples/ExampleBrowser/ExampleEntries.cpp @@ -187,7 +187,7 @@ static ExampleEntry gDefaultExamples[] = ExampleEntry(0, "Inverse Dynamics"), ExampleEntry(1, "Inverse Dynamics URDF", "Create a btMultiBody from URDF. Create an inverse MultiBodyTree model from that. Use either decoupled PD control or computed torque control using the inverse model to track joint position targets", InverseDynamicsExampleCreateFunc, BT_ID_LOAD_URDF), - ExampleEntry(1, "Inverse Dynamics Prog", "Create a btMultiBody programatically. Create an inverse MultiBodyTree model from that. Use either decoupled PD control or computed torque control using the inverse model to track joint position targets", InverseDynamicsExampleCreateFunc, BT_ID_PROGRAMMATICALLY), + ExampleEntry(1, "Inverse Dynamics Prog", "Create a btMultiBody programmatically. Create an inverse MultiBodyTree model from that. Use either decoupled PD control or computed torque control using the inverse model to track joint position targets", InverseDynamicsExampleCreateFunc, BT_ID_PROGRAMMATICALLY), ExampleEntry(0, "Inverse Kinematics"), ExampleEntry(1, "SDLS", "Selectively Damped Least Squares by Sam Buss. Example configures the IK tree of a Kuka IIWA", InverseKinematicsExampleCreateFunc, IK_SDLS), @@ -293,7 +293,7 @@ static ExampleEntry gDefaultExamples[] = //#endif ExampleEntry(0, "Importers"), - ExampleEntry(1, "Import .bullet", "Load a binary .bullet file. The serialization mechanism can deal with versioning, differences in endianess, 32 and 64bit, double/single precision. It is easy to save a .bullet file, see the examples/Importers/ImportBullet/SerializeDemo.cpp for a code example how to export a .bullet file.", SerializeBulletCreateFunc), + ExampleEntry(1, "Import .bullet", "Load a binary .bullet file. The serialization mechanism can deal with versioning, differences in endianness, 32 and 64bit, double/single precision. It is easy to save a .bullet file, see the examples/Importers/ImportBullet/SerializeDemo.cpp for a code example how to export a .bullet file.", SerializeBulletCreateFunc), ExampleEntry(1, "Wavefront Obj", "Import a Wavefront .obj file", ImportObjCreateFunc, 0), ExampleEntry(1, "Obj2RigidBody (Show Obj)", "Load a triangle mesh from Wavefront .obj and turn it in a convex hull collision shape, connected to a rigid body. We can use the original .obj mesh data to visualize the rigid body. In 'debug' wireframe mode (press 'w' to toggle) we still see the convex hull data.", ET_RigidBodyFromObjCreateFunc), ExampleEntry(1, "Obj2RigidBody (Show Hull)", "Load a triangle mesh from Wavefront .obj and turn it in a convex hull collision shape, connected to a rigid body", ET_RigidBodyFromObjCreateFunc, ObjUseConvexHullForRendering), @@ -348,13 +348,13 @@ static ExampleEntry gDefaultExamples[] = ExampleEntry(1, "MultiThreading (submitJob)", "Simple example of executing jobs across multiple threads.", MultiThreadingExampleCreateFunc, SINGLE_SIM_THREAD), - ExampleEntry(1, "Voronoi Fracture", "Automatically create a compound rigid body using voronoi tesselation. Individual parts are modeled as rigid bodies using a btConvexHullShape.", + ExampleEntry(1, "Voronoi Fracture", "Automatically create a compound rigid body using voronoi tessellation. Individual parts are modeled as rigid bodies using a btConvexHullShape.", VoronoiFractureCreateFunc), ExampleEntry(1, "Fracture demo", "Create a basic custom implementation to model fracturing objects, based on a btCompoundShape. It explicitly propagates the collision impulses and breaks the rigid body into multiple rigid bodies. Press F to toggle fracture and glue mode.", FractureDemoCreateFunc), ExampleEntry(1, "Planar 2D", "Show the use of 2D collision shapes and rigid body simulation. The collision shape is wrapped into a btConvex2dShape. The rigid bodies are restricted in a plane using the 'setAngularFactor' and 'setLinearFactor' API call.", Planar2DCreateFunc), -#if BT_THREADSAFE +#ifdef BT_THREADSAFE // only enable MultiThreaded demo if a task scheduler is available ExampleEntry(1, "Multithreaded Demo", "Stacks of boxes that do not sleep. Good for testing performance with large numbers of bodies and contacts. Sliders can be used to change the number of stacks (restart needed after each change).", diff --git a/examples/ExampleBrowser/GL_ShapeDrawer.cpp b/examples/ExampleBrowser/GL_ShapeDrawer.cpp index 5bc92adec9..ed3eb76ced 100644 --- a/examples/ExampleBrowser/GL_ShapeDrawer.cpp +++ b/examples/ExampleBrowser/GL_ShapeDrawer.cpp @@ -150,24 +150,24 @@ void GL_ShapeDrawer::drawSphere(btScalar radius, int lats, int longs) int i, j; for (i = 0; i <= lats; i++) { - btScalar lat0 = SIMD_PI * (-btScalar(0.5) + (btScalar)(i - 1) / lats); + btScalar lat0 = SIMD_PI * (-btScalar(0.5) + (btScalar)(i - 1) / (btScalar)lats); btScalar z0 = radius * std::sin(lat0); btScalar zr0 = radius * std::cos(lat0); - btScalar lat1 = SIMD_PI * (-btScalar(0.5) + (btScalar)i / lats); + btScalar lat1 = SIMD_PI * (-btScalar(0.5) + (btScalar)i / (btScalar)lats); btScalar z1 = radius * std::sin(lat1); btScalar zr1 = radius * std::cos(lat1); glBegin(GL_QUAD_STRIP); for (j = 0; j <= longs; j++) { - btScalar lng = 2 * SIMD_PI * (btScalar)(j - 1) / longs; + btScalar lng = 2 * SIMD_PI * (btScalar)(j - 1) / (btScalar)longs; btScalar x = std::cos(lng); btScalar y = std::sin(lng); - glNormal3f(x * zr1, y * zr1, z1); - glVertex3f(x * zr1, y * zr1, z1); - glNormal3f(x * zr0, y * zr0, z0); - glVertex3f(x * zr0, y * zr0, z0); + glNormal3f(GLfloat(x * zr1), GLfloat(y * zr1), GLfloat(z1)); + glVertex3f(GLfloat(x * zr1), GLfloat(y * zr1), GLfloat(z1)); + glNormal3f(GLfloat(x * zr0), GLfloat(y * zr0), GLfloat(z0)); + glVertex3f(GLfloat(x * zr0), GLfloat(y * zr0), GLfloat(z0)); } glEnd(); } @@ -198,15 +198,15 @@ GL_ShapeDrawer::ShapeCache* GL_ShapeDrawer::cache(btConvexShape* shape) { const unsigned int a = ti[j]; const unsigned int b = ti[k]; - ShapeCache::Edge*& e = edges[btMin(a, b) * nv + btMax(a, b)]; + ShapeCache::Edge*& e = edges[(int)(btMin(a, b) * nv + btMax(a, b))]; if (!e) { sc->m_edges.push_back(ShapeCache::Edge()); e = &sc->m_edges[sc->m_edges.size() - 1]; e->n[0] = nrm; e->n[1] = -nrm; - e->v[0] = a; - e->v[1] = b; + e->v[0] = (int)a; + e->v[1] = (int)b; } else { @@ -218,7 +218,7 @@ GL_ShapeDrawer::ShapeCache* GL_ShapeDrawer::cache(btConvexShape* shape) return (sc); } -void renderSquareA(float x, float y, float z) +static void renderSquareA(float x, float y, float z) { glBegin(GL_LINE_LOOP); glVertex3f(x, y, z); @@ -335,7 +335,7 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons { const int s = x >> 4; const GLubyte b = 180; - GLubyte c = b + ((s + (t & 1)) & 1) * (255 - b); + GLubyte c = (GLubyte)(b + ((s + (t & 1)) & 1) * (255 - b)); pi[0] = pi[1] = pi[2] = pi[3] = c; pi += 3; } @@ -384,7 +384,7 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons glDisable(GL_TEXTURE_2D); } - glColor3f(color.x(), color.y(), color.z()); + glColor3f((GLfloat)color.x(), (GLfloat)color.y(), (GLfloat)color.z()); //bool useWireframeFallback = true; @@ -400,7 +400,7 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons case SPHERE_SHAPE_PROXYTYPE: { const btSphereShape* sphereShape = static_cast(shape); - float radius = sphereShape->getMargin(); //radius doesn't include the margin, so draw with margin + float radius = (float)sphereShape->getMargin(); //radius doesn't include the margin, so draw with margin drawSphere(radius, 10, 10); //useWireframeFallback = false; break; @@ -440,15 +440,14 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons for (int i = 0; i < si; i += 3) { const btVector3& v1 = vertices[indices[i]]; - ; const btVector3& v2 = vertices[indices[i + 1]]; const btVector3& v3 = vertices[indices[i + 2]]; btVector3 normal = (v3 - v1).cross(v2 - v1); normal.normalize(); - glNormal3f(normal.getX(), normal.getY(), normal.getZ()); - glVertex3f(v1.x(), v1.y(), v1.z()); - glVertex3f(v2.x(), v2.y(), v2.z()); - glVertex3f(v3.x(), v3.y(), v3.z()); + glNormal3f((GLfloat)normal.getX(), (GLfloat)normal.getY(), (GLfloat)normal.getZ()); + glVertex3f((GLfloat)v1.x(), (GLfloat)v1.y(), (GLfloat)v1.z()); + glVertex3f((GLfloat)v2.x(), (GLfloat)v2.y(), (GLfloat)v2.z()); + glVertex3f((GLfloat)v3.x(), (GLfloat)v3.y(), (GLfloat)v3.z()); } glEnd(); #endif @@ -502,10 +501,10 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons btVector3 pt2 = planeOrigin + vec1 * vecLen; btVector3 pt3 = planeOrigin - vec1 * vecLen; glBegin(GL_LINES); - glVertex3f(pt0.getX(), pt0.getY(), pt0.getZ()); - glVertex3f(pt1.getX(), pt1.getY(), pt1.getZ()); - glVertex3f(pt2.getX(), pt2.getY(), pt2.getZ()); - glVertex3f(pt3.getX(), pt3.getY(), pt3.getZ()); + glVertex3f((GLfloat)pt0.getX(), (GLfloat)pt0.getY(), (GLfloat)pt0.getZ()); + glVertex3f((GLfloat)pt1.getX(), (GLfloat)pt1.getY(), (GLfloat)pt1.getZ()); + glVertex3f((GLfloat)pt2.getX(), (GLfloat)pt2.getY(), (GLfloat)pt2.getZ()); + glVertex3f((GLfloat)pt3.getX(), (GLfloat)pt3.getY(), (GLfloat)pt3.getZ()); glEnd(); break; @@ -553,10 +552,10 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons btVector3 v3 = poly->m_vertices[poly->m_faces[i].m_indices[v + 2]]; btVector3 normal = (v3 - v1).cross(v2 - v1); normal.normalize(); - glNormal3f(normal.getX(), normal.getY(), normal.getZ()); - glVertex3f(v1.x(), v1.y(), v1.z()); - glVertex3f(v2.x(), v2.y(), v2.z()); - glVertex3f(v3.x(), v3.y(), v3.z()); + glNormal3f((GLfloat)normal.getX(), (GLfloat)normal.getY(), (GLfloat)normal.getZ()); + glVertex3f((GLfloat)v1.x(), (GLfloat)v1.y(), (GLfloat)v1.z()); + glVertex3f((GLfloat)v2.x(), (GLfloat)v2.y(), (GLfloat)v2.z()); + glVertex3f((GLfloat)v3.x(), (GLfloat)v3.y(), (GLfloat)v3.z()); } } } @@ -585,9 +584,9 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons i2 < hull->numIndices() && i3 < hull->numIndices()); - int index1 = idx[i1]; - int index2 = idx[i2]; - int index3 = idx[i3]; + int index1 = (int)idx[i1]; + int index2 = (int)idx[i2]; + int index3 = (int)idx[i3]; btAssert(index1 < hull->numVertices() && index2 < hull->numVertices() && index3 < hull->numVertices()); @@ -597,10 +596,10 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons btVector3 v3 = vtx[index3]; btVector3 normal = (v3 - v1).cross(v2 - v1); normal.normalize(); - glNormal3f(normal.getX(), normal.getY(), normal.getZ()); - glVertex3f(v1.x(), v1.y(), v1.z()); - glVertex3f(v2.x(), v2.y(), v2.z()); - glVertex3f(v3.x(), v3.y(), v3.z()); + glNormal3f((GLfloat)normal.getX(), (GLfloat)normal.getY(), (GLfloat)normal.getZ()); + glVertex3f((GLfloat)v1.x(), (GLfloat)v1.y(), (GLfloat)v1.z()); + glVertex3f((GLfloat)v2.x(), (GLfloat)v2.y(), (GLfloat)v2.z()); + glVertex3f((GLfloat)v3.x(), (GLfloat)v3.y(), (GLfloat)v3.z()); } glEnd(); } @@ -695,10 +694,10 @@ void GL_ShapeDrawer::drawShadow(btScalar* m, const btVector3& extrusion, const b const int q = d < 0 ? 1 : 0; const btVector3& a = hull->getVertexPointer()[sc->m_edges[i].v[q]]; const btVector3& b = hull->getVertexPointer()[sc->m_edges[i].v[1 - q]]; - glVertex3f(a[0], a[1], a[2]); - glVertex3f(b[0], b[1], b[2]); - glVertex3f(b[0] + extrusion[0], b[1] + extrusion[1], b[2] + extrusion[2]); - glVertex3f(a[0] + extrusion[0], a[1] + extrusion[1], a[2] + extrusion[2]); + glVertex3f((GLfloat)a[0], (GLfloat)a[1], (GLfloat)a[2]); + glVertex3f((GLfloat)b[0], (GLfloat)b[1], (GLfloat)b[2]); + glVertex3f(GLfloat(b[0] + extrusion[0]), GLfloat(b[1] + extrusion[1]), GLfloat(b[2] + extrusion[2])); + glVertex3f(GLfloat(a[0] + extrusion[0]), GLfloat(a[1] + extrusion[1]), GLfloat(a[2] + extrusion[2])); } } glEnd(); @@ -749,7 +748,6 @@ void GL_ShapeDrawer::drawSceneInternal(const btDiscreteDynamicsWorld* dynamicsWo btMatrix3x3 rot; rot.setIdentity(); const int numObjects = dynamicsWorld->getNumCollisionObjects(); - btVector3 wireColor(1, 0, 0); //glDisable(GL_CULL_FACE); for (int i = 0; i < numObjects; i++) @@ -767,7 +765,7 @@ void GL_ShapeDrawer::drawSceneInternal(const btDiscreteDynamicsWorld* dynamicsWo colObj->getWorldTransform().getOpenGLMatrix(m); rot = colObj->getWorldTransform().getBasis(); } - btVector3 wireColor(1.f, 1.0f, 0.5f); //wants deactivation + btVector3 wireColor = btVector3(1.f, 1.0f, 0.5f); //wants deactivation if (i & 1) wireColor = btVector3(0.f, 0.0f, 1.f); ///color differently for active, sleeping, wantsdeactivation states if (colObj->getActivationState() == 1) //active @@ -825,21 +823,23 @@ void GL_ShapeDrawer::drawSceneInternal(const btDiscreteDynamicsWorld* dynamicsWo case 2: drawOpenGL(m, colObj->getCollisionShape(), wireColor * btScalar(0.3), 0, aabbMin, aabbMax); break; + default: + break; } } } //this GL_ShapeDrawer will be removed, in the meanwhile directly access this global 'useShadoMaps' extern bool useShadowMap; -void GL_ShapeDrawer::drawScene(const btDiscreteDynamicsWorld* dynamicsWorld, bool useShadows1, int cameraUpAxis) +void GL_ShapeDrawer::drawScene(const btDiscreteDynamicsWorld* dynamicsWorld, bool /*useShadows1*/, int cameraUpAxis) { bool useShadows = useShadowMap; - GLfloat light_ambient[] = {btScalar(0.2), btScalar(0.2), btScalar(0.2), btScalar(1.0)}; - GLfloat light_diffuse[] = {btScalar(1.0), btScalar(1.0), btScalar(1.0), btScalar(1.0)}; - GLfloat light_specular[] = {btScalar(1.0), btScalar(1.0), btScalar(1.0), btScalar(1.0)}; + GLfloat light_ambient[] = {GLfloat(0.2), GLfloat(0.2), GLfloat(0.2), GLfloat(1.0)}; + GLfloat light_diffuse[] = {GLfloat(1.0), GLfloat(1.0), GLfloat(1.0), GLfloat(1.0)}; + GLfloat light_specular[] = {GLfloat(1.0), GLfloat(1.0), GLfloat(1.0), GLfloat(1.0)}; /* light_position is NOT default value */ - GLfloat light_position0[] = {btScalar(1.0), btScalar(10.0), btScalar(1.0), btScalar(0.0)}; - GLfloat light_position1[] = {btScalar(-1.0), btScalar(-10.0), btScalar(-1.0), btScalar(0.0)}; + GLfloat light_position0[] = {GLfloat(1.0), GLfloat(10.0), GLfloat(1.0), GLfloat(0.0)}; + GLfloat light_position1[] = {GLfloat(-1.0), GLfloat(-10.0), GLfloat(-1.0), GLfloat(0.0)}; glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); @@ -859,7 +859,7 @@ void GL_ShapeDrawer::drawScene(const btDiscreteDynamicsWorld* dynamicsWorld, boo glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); - glClearColor(btScalar(0.7), btScalar(0.7), btScalar(0.7), btScalar(0)); + glClearColor(GLfloat(0.7), GLfloat(0.7), GLfloat(0.7), GLfloat(0)); if (useShadows) { diff --git a/examples/ExampleBrowser/GL_ShapeDrawer.h b/examples/ExampleBrowser/GL_ShapeDrawer.h index 12c801a9c9..281abf92e0 100644 --- a/examples/ExampleBrowser/GL_ShapeDrawer.h +++ b/examples/ExampleBrowser/GL_ShapeDrawer.h @@ -56,7 +56,7 @@ class GL_ShapeDrawer virtual void drawScene(const btDiscreteDynamicsWorld* world, bool useShadows, int cameraUpAxis); - ///drawOpenGL might allocate temporary memoty, stores pointer in shape userpointer + ///drawOpenGL might allocate temporary memory, stores pointer in shape userpointer virtual void drawOpenGL(btScalar* m, const btCollisionShape* shape, const btVector3& color, int debugMode, const btVector3& worldBoundsMin, const btVector3& worldBoundsMax); virtual void drawShadow(btScalar* m, const btVector3& extrusion, const btCollisionShape* shape, const btVector3& worldBoundsMin, const btVector3& worldBoundsMax); diff --git a/examples/ExampleBrowser/GwenGUISupport/GraphingTexture.cpp b/examples/ExampleBrowser/GwenGUISupport/GraphingTexture.cpp index 5d366618ae..1853932941 100644 --- a/examples/ExampleBrowser/GwenGUISupport/GraphingTexture.cpp +++ b/examples/ExampleBrowser/GwenGUISupport/GraphingTexture.cpp @@ -63,7 +63,7 @@ bool GraphingTexture::create(int texWidth, int texHeight) void GraphingTexture::uploadImageData() { - glBindTexture(GL_TEXTURE_2D, m_textureId); + glBindTexture(GL_TEXTURE_2D, (GLuint)m_textureId); assert(glGetError() == GL_NO_ERROR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &m_imageData[0]); diff --git a/examples/ExampleBrowser/GwenGUISupport/GwenParameterInterface.cpp b/examples/ExampleBrowser/GwenGUISupport/GwenParameterInterface.cpp index d6fd7e0b41..c961b640a8 100644 --- a/examples/ExampleBrowser/GwenGUISupport/GwenParameterInterface.cpp +++ b/examples/ExampleBrowser/GwenGUISupport/GwenParameterInterface.cpp @@ -21,7 +21,7 @@ struct MyButtonEventHandler : public Gwen::Event::Handler { } - void onButtonPress(Gwen::Controls::Base* pControl) + void onButtonPress(Gwen::Controls::Base* /*pControl*/) { if (m_callback) { @@ -68,7 +68,7 @@ struct MySliderEventHandler : public Gwen::Event::Handler if (m_callback) { - (*m_callback)(v, m_userPointer); + (*m_callback)((float)v, m_userPointer); } } @@ -83,13 +83,14 @@ struct MySliderEventHandler : public Gwen::Event::Handler { printf("?\n"); } - m_pSlider->SetValue(v, true); + m_pSlider->SetValue((float)v, true); (*m_targetValue) = v; float val = float(v); //todo: specialize on template type if (m_showValue) { - char txt[1024]; + char txt[1033]; safe_printf(txt, sizeof(txt), "%s : %.3f", m_variableName, val); + txt[1032] = '\0'; m_label->SetText(txt); } } @@ -121,7 +122,7 @@ GwenParameterInterface::~GwenParameterInterface() void GwenParameterInterface::setSliderValue(int sliderIndex, double sliderValue) { - int sliderCapped = sliderValue + 4; + int sliderCapped = int(sliderValue + 4); sliderCapped /= 8; sliderCapped *= 8; @@ -133,7 +134,7 @@ void GwenParameterInterface::setSliderValue(int sliderIndex, double sliderValue) float mappedValue = m_paramInternalData->m_sliders[sliderIndex]->GetRangeMin() + (m_paramInternalData->m_sliders[sliderIndex]->GetRangeMax() - m_paramInternalData->m_sliders[sliderIndex]->GetRangeMin()) * - sliderCapped / 128.f; + (float)sliderCapped / 128.f; printf("mappedValue = %f\n", mappedValue); m_paramInternalData->m_sliders[sliderIndex]->SetValue(mappedValue); } @@ -233,7 +234,7 @@ void GwenParameterInterface::registerSliderFloatParameter(SliderParams& params) pSlider->SetNotchCount(16); //float(params.m_maxVal-params.m_minVal)/100.f); pSlider->SetClampToNotches(params.m_clampToNotches); } - pSlider->SetValue(*params.m_paramValuePointer); //dimensions[i] ); + pSlider->SetValue((float)*params.m_paramValuePointer); //dimensions[i] ); char labelName[1024]; safe_printf(labelName, sizeof(labelName), "%s", params.m_name); //axisNames[0]); MySliderEventHandler* handler = new MySliderEventHandler(labelName, label, pSlider, params.m_paramValuePointer, params.m_callback, params.m_userPointer); @@ -251,7 +252,7 @@ void GwenParameterInterface::syncParameters() for (int i = 0; i < m_paramInternalData->m_sliderEventHandlers.size(); i++) { MySliderEventHandler* handler = m_paramInternalData->m_sliderEventHandlers[i]; - handler->m_pSlider->SetValue(*handler->m_targetValue, true); + handler->m_pSlider->SetValue((float)*handler->m_targetValue, true); } } diff --git a/examples/ExampleBrowser/GwenGUISupport/GwenTextureWindow.cpp b/examples/ExampleBrowser/GwenGUISupport/GwenTextureWindow.cpp index 0e0a2c7327..273d9ad729 100644 --- a/examples/ExampleBrowser/GwenGUISupport/GwenTextureWindow.cpp +++ b/examples/ExampleBrowser/GwenGUISupport/GwenTextureWindow.cpp @@ -51,7 +51,7 @@ class MyMenuItems2 : public Gwen::Controls::Base { } - void MenuItemSelect(Gwen::Controls::Base* pControl) + void MenuItemSelect(Gwen::Controls::Base* /*pControl*/) { if (m_graphWindow->Hidden()) { diff --git a/examples/ExampleBrowser/GwenGUISupport/gwenUserInterface.cpp b/examples/ExampleBrowser/GwenGUISupport/gwenUserInterface.cpp index 740bcce71f..e7ebb4d25b 100644 --- a/examples/ExampleBrowser/GwenGUISupport/gwenUserInterface.cpp +++ b/examples/ExampleBrowser/GwenGUISupport/gwenUserInterface.cpp @@ -5,7 +5,7 @@ #include "Gwen/Controls/ColorPicker.h" //#include "Gwen/Controls/HSVColorPicker.h" -class MyGraphWindow* graphWindow = 0; +static class MyGraphWindow* graphWindow = 0; GwenUserInterface::GwenUserInterface() { @@ -23,14 +23,14 @@ class MyMenuItems : public Gwen::Controls::Base MyMenuItems() : Gwen::Controls::Base(0), m_fileOpenCallback(0) { } - void myQuitApp(Gwen::Controls::Base* pControl) + void myQuitApp(Gwen::Controls::Base* /*pControl*/) { if (m_quitCallback) { (*m_quitCallback)(); } } - void fileOpen(Gwen::Controls::Base* pControl) + void fileOpen(Gwen::Controls::Base* /*pControl*/) { if (m_fileOpenCallback) { @@ -167,7 +167,7 @@ void GwenUserInterface::setExampleDescription(const char* message) int wrapLen = int(wrapmessage.length()); for (int endPos = 0; endPos <= wrapLen; endPos++) { - std::string sub = wrapmessage.substr(startPos, (endPos - startPos)); + std::string sub = wrapmessage.substr((size_t)startPos, (size_t)(endPos - startPos)); Gwen::Point pt = m_data->pRenderer->MeasureText(m_data->pCanvas->GetSkin()->GetDefaultFont(), sub); if (pt.x <= fixedWidth) @@ -233,7 +233,7 @@ void GwenUserInterface::registerQuitCallback(b3QuitCallback callback) m_data->m_menuItems->m_quitCallback = callback; } -void GwenUserInterface::init(int width, int height, Gwen::Renderer::Base* renderer, float retinaScale) +void GwenUserInterface::init(int width, int height, Gwen::Renderer::Base* renderer, float /*retinaScale*/) { m_data->m_curYposition = 20; //m_data->m_primRenderer = new GLPrimitiveRenderer(width,height); @@ -482,10 +482,10 @@ bool GwenUserInterface::mouseMoveCallback(float x, float y) if (!isInitialized) { isInitialized = true; - m_lastmousepos[0] = x + 1; - m_lastmousepos[1] = y + 1; + m_lastmousepos[0] = (int)(x + 1); + m_lastmousepos[1] = (int)(y + 1); } - handled = m_data->pCanvas->InputMouseMoved(x, y, m_lastmousepos[0], m_lastmousepos[1]); + handled = m_data->pCanvas->InputMouseMoved((int)x, (int)y, m_lastmousepos[0], m_lastmousepos[1]); } return handled; } @@ -558,7 +558,7 @@ bool GwenUserInterface::keyboardCallback(int bulletKey, int state) default: { } - }; + } if (gwenKey >= 0) { @@ -581,11 +581,11 @@ bool GwenUserInterface::mouseButtonCallback(int button, int state, float x, floa bool handled = false; if (m_data->pCanvas) { - handled = m_data->pCanvas->InputMouseMoved(x, y, x, y); + handled = m_data->pCanvas->InputMouseMoved((int)x, (int)y, (int)x, (int)y); if (button >= 0) { - handled = m_data->pCanvas->InputMouseButton(button, (bool)state); + handled = m_data->pCanvas->InputMouseButton(button, state != 0); if (handled) { //if (!state) diff --git a/examples/ExampleBrowser/GwenGUISupport/gwenUserInterface.h b/examples/ExampleBrowser/GwenGUISupport/gwenUserInterface.h index 5f246180ef..2d49e78666 100644 --- a/examples/ExampleBrowser/GwenGUISupport/gwenUserInterface.h +++ b/examples/ExampleBrowser/GwenGUISupport/gwenUserInterface.h @@ -13,8 +13,8 @@ namespace Gwen namespace Renderer { class Base; -}; -}; // namespace Gwen +} +} // namespace Gwen class GwenUserInterface { GwenInternalData* m_data; diff --git a/examples/ExampleBrowser/InProcessExampleBrowser.cpp b/examples/ExampleBrowser/InProcessExampleBrowser.cpp index b2d685364f..bd5bc1725b 100644 --- a/examples/ExampleBrowser/InProcessExampleBrowser.cpp +++ b/examples/ExampleBrowser/InProcessExampleBrowser.cpp @@ -53,7 +53,7 @@ static b3ThreadSupportInterface* createExampleBrowserThreadSupport(int numThread #elif defined(_WIN32) #include "../MultiThreading/b3Win32ThreadSupport.h" -b3ThreadSupportInterface* createExampleBrowserThreadSupport(int numThreads) +static b3ThreadSupportInterface* createExampleBrowserThreadSupport(int numThreads) { b3Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("testThreads", ExampleBrowserThreadFunc, ExampleBrowserMemoryFunc, ExampleBrowserMemoryReleaseFunc, numThreads); b3Win32ThreadSupport* threadSupport = new b3Win32ThreadSupport(threadConstructionInfo); @@ -153,7 +153,7 @@ void ExampleEntriesPhysicsServer::initExampleEntries() } } -void ExampleEntriesPhysicsServer::registerExampleEntry(int menuLevel, const char* name, const char* description, CommonExampleInterface::CreateFunc* createFunc, int option) +void ExampleEntriesPhysicsServer::registerExampleEntry(int /*menuLevel*/, const char* /*name*/, const char* /*description*/, CommonExampleInterface::CreateFunc* /*createFunc*/, int /*option*/) { } @@ -246,11 +246,11 @@ void ExampleBrowserThreadFunc(void* userPtr, void* lsMemory) clock.usleep(0); //B3_PROFILE("ExampleBrowserThreadFunc"); - float deltaTimeInSeconds = clock.getTimeMicroseconds() / 1000000.f; + float deltaTimeInSeconds = (float)clock.getTimeMicroseconds() / 1000000.f; { - if (deltaTimeInSeconds > 0.1) + if (deltaTimeInSeconds > 0.1f) { - deltaTimeInSeconds = 0.1; + deltaTimeInSeconds = 0.1f; } if (deltaTimeInSeconds < (gMinUpdateTimeMicroSecs / 1e6)) { @@ -376,7 +376,7 @@ void btShutDownExampleBrowser(btInProcessExampleBrowserInternalData* data) // printf("polling.."); b3Clock::usleep(0); } - }; + } printf("btShutDownExampleBrowser stopping threads\n"); data->m_threadSupport->deleteCriticalSection(data->m_args.m_cs); @@ -403,6 +403,7 @@ btInProcessExampleBrowserMainThreadInternalData* btCreateInProcessExampleBrowser data->m_exampleBrowser->setSharedMemoryInterface(data->m_sharedMem); bool init; init = data->m_exampleBrowser->init(argc, argv); + (void)init; data->m_clock.reset(); return data; } @@ -414,7 +415,7 @@ bool btIsExampleBrowserMainThreadTerminated(btInProcessExampleBrowserMainThreadI void btUpdateInProcessExampleBrowserMainThread(btInProcessExampleBrowserMainThreadInternalData* data) { - float deltaTimeInSeconds = data->m_clock.getTimeMicroseconds() / 1000000.f; + float deltaTimeInSeconds = (float)data->m_clock.getTimeMicroseconds() / 1000000.f; data->m_clock.reset(); data->m_exampleBrowser->updateGraphics(); data->m_exampleBrowser->update(deltaTimeInSeconds); diff --git a/examples/ExampleBrowser/OpenGLExampleBrowser.cpp b/examples/ExampleBrowser/OpenGLExampleBrowser.cpp index 0ff00865d7..64ae18cefa 100644 --- a/examples/ExampleBrowser/OpenGLExampleBrowser.cpp +++ b/examples/ExampleBrowser/OpenGLExampleBrowser.cpp @@ -64,7 +64,7 @@ struct GL3TexLoader : public MyTextureLoader pTexture->m_intData = *texIdPtr; } } - virtual void FreeTexture(Gwen::Texture* pTexture) + virtual void FreeTexture(Gwen::Texture* /*pTexture*/) { } }; @@ -105,8 +105,8 @@ static MyProfileWindow* s_profWindow = 0; static SharedMemoryInterface* sSharedMem = 0; #define DEMO_SELECTION_COMBOBOX 13 -const char* startFileName = "0_Bullet3Demo.txt"; -char staticPngFileName[1024]; +static const char* startFileName = "0_Bullet3Demo.txt"; +static char staticPngFileName[1024]; //static GwenUserInterface* gui = 0; static GwenUserInterface* gui2 = 0; static int sCurrentDemoIndex = -1; @@ -114,47 +114,47 @@ static int sCurrentHightlighted = 0; static CommonExampleInterface* sCurrentDemo = 0; static b3AlignedObjectArray allNames; static float gFixedTimeStep = 0; -bool gAllowRetina = true; -bool gDisableDemoSelection = false; -int gRenderDevice = -1; -int gWindowBackend = 0; +static bool gAllowRetina = true; +static bool gDisableDemoSelection = false; +static int gRenderDevice = -1; +static int gWindowBackend = 0; static class ExampleEntries* gAllExamples = 0; -bool sUseOpenGL2 = false; +static bool sUseOpenGL2 = false; #ifndef USE_OPENGL3 extern bool useShadowMap; #endif -bool visualWireframe = false; +static bool visualWireframe = false; static bool renderVisualGeometry = true; static bool renderGrid = true; static bool gEnableRenderLoop = true; -bool renderGui = true; +static bool renderGui = true; static bool enable_experimental_opencl = false; static bool gEnableDefaultKeyboardShortcuts = true; static bool gEnableDefaultMousePicking = true; -int gDebugDrawFlags = 0; +static int gDebugDrawFlags = 0; static bool pauseSimulation = false; static bool singleStepSimulation = false; -int midiBaseIndex = 176; +static int midiBaseIndex = 176; extern bool gDisableDeactivation; int gSharedMemoryKey = -1; ///some quick test variable for the OpenCL examples -int gPreferredOpenCLDeviceIndex = -1; -int gPreferredOpenCLPlatformIndex = -1; -int gGpuArraySizeX = 45; -int gGpuArraySizeY = 55; -int gGpuArraySizeZ = 45; +static int gPreferredOpenCLDeviceIndex = -1; +static int gPreferredOpenCLPlatformIndex = -1; +static int gGpuArraySizeX = 45; +static int gGpuArraySizeY = 55; +static int gGpuArraySizeZ = 45; //#include //unsigned int fp_control_state = _controlfp(_EM_INEXACT, _MCW_EM); -void deleteDemo() +static void deleteDemo() { if (sCurrentDemo) { @@ -169,12 +169,12 @@ void deleteDemo() } } -const char* gPngFileName = 0; -int gPngSkipFrames = 0; +static const char* gPngFileName = 0; +static int gPngSkipFrames = 0; -b3KeyboardCallback prevKeyboardCallback = 0; +static b3KeyboardCallback prevKeyboardCallback = 0; -void MyKeyboardCallback(int key, int state) +static void MyKeyboardCallback(int key, int state) { //b3Printf("key=%d, state=%d", key, state); bool handled = false; @@ -189,6 +189,7 @@ void MyKeyboardCallback(int key, int state) if (!handled && sCurrentDemo) { handled = sCurrentDemo->keyboardCallback(key, state); + (void)handled; } //checkout: is it desired to ignore keys, if the demo already handles them? @@ -305,7 +306,7 @@ void MyKeyboardCallback(int key, int state) prevKeyboardCallback(key, state); } -b3MouseMoveCallback prevMouseMoveCallback = 0; +static b3MouseMoveCallback prevMouseMoveCallback = 0; static void MyMouseMoveCallback(float x, float y) { bool handled = false; @@ -323,7 +324,7 @@ static void MyMouseMoveCallback(float x, float y) } } -b3MouseButtonCallback prevMouseButtonCallback = 0; +static b3MouseButtonCallback prevMouseButtonCallback = 0; static void MyMouseButtonCallback(int button, int state, float x, float y) { @@ -363,7 +364,7 @@ void OpenGLExampleBrowser::registerFileImporter(const char* extension, CommonExa } #include "../SharedMemory/SharedMemoryPublic.h" -void OpenGLExampleBrowserVisualizerFlagCallback(int flag, bool enable) +static void OpenGLExampleBrowserVisualizerFlagCallback(int flag, bool enable) { if (flag == COV_ENABLE_Y_AXIS_UP) { @@ -424,7 +425,7 @@ void OpenGLExampleBrowserVisualizerFlagCallback(int flag, bool enable) } } -void openFileDemo(const char* filename) +static void openFileDemo(const char* filename) { deleteDemo(); @@ -454,7 +455,7 @@ void openFileDemo(const char* filename) } } -void selectDemo(int demoIndex) +static void selectDemo(int demoIndex) { bool resetCamera = (sCurrentDemoIndex != demoIndex); sCurrentDemoIndex = demoIndex; @@ -504,9 +505,9 @@ void selectDemo(int demoIndex) #include -static void saveCurrentSettings(int currentEntry, const char* startFileName) +static void saveCurrentSettings(int /*currentEntry*/, const char* startFileNameL) { - FILE* f = fopen(startFileName, "w"); + FILE* f = fopen(startFileNameL, "w"); if (f) { fprintf(f, "--start_demo_name=%s\n", gAllExamples->getExampleName(sCurrentDemoIndex)); @@ -534,12 +535,12 @@ static void saveCurrentSettings(int currentEntry, const char* startFileName) fclose(f); } -}; +} -static void loadCurrentSettings(const char* startFileName, b3CommandLineArgs& args) +static void loadCurrentSettings(const char* startFileNameL, b3CommandLineArgs& args) { //int currentEntry= 0; - FILE* f = fopen(startFileName, "r"); + FILE* f = fopen(startFileNameL, "r"); if (f) { char oneline[1024]; @@ -554,9 +555,9 @@ static void loadCurrentSettings(const char* startFileName, b3CommandLineArgs& ar } fclose(f); } -}; +} -void MyComboBoxCallback(int comboId, const char* item) +static void MyComboBoxCallback(int comboId, const char* item) { //printf("comboId = %d, item = %s\n",comboId, item); if (comboId == DEMO_SELECTION_COMBOBOX) @@ -577,7 +578,7 @@ void MyComboBoxCallback(int comboId, const char* item) //in case of multi-threading, don't submit messages while the GUI is rendering (causing crashes) static bool gBlockGuiMessages = false; -void MyGuiPrintf(const char* msg) +static void MyGuiPrintf(const char* msg) { printf("b3Printf: %s\n", msg); if (!gDisableDemoSelection && !gBlockGuiMessages) @@ -587,7 +588,7 @@ void MyGuiPrintf(const char* msg) } } -void MyStatusBarPrintf(const char* msg) +static void MyStatusBarPrintf(const char* msg) { printf("b3Printf: %s\n", msg); if (!gDisableDemoSelection && !gBlockGuiMessages) @@ -597,7 +598,7 @@ void MyStatusBarPrintf(const char* msg) } } -void MyStatusBarError(const char* msg) +static void MyStatusBarError(const char* msg) { printf("Warning: %s\n", msg); if (!gDisableDemoSelection && !gBlockGuiMessages) @@ -648,7 +649,7 @@ struct MyMenuItemHander : public Gwen::Event::Handler saveCurrentSettings(sCurrentDemoIndex, startFileName); } } - void onButtonC(Gwen::Controls::Base* pControl) + void onButtonC(Gwen::Controls::Base* /*pControl*/) { /*Gwen::Controls::Label* label = (Gwen::Controls::Label*) pControl; Gwen::UnicodeString la = label->GetText();// node->GetButton()->GetName();// GetText(); @@ -659,7 +660,7 @@ struct MyMenuItemHander : public Gwen::Event::Handler printf("onButtonC ! %s\n", ha); */ } - void onButtonD(Gwen::Controls::Base* pControl) + void onButtonD(Gwen::Controls::Base* /*pControl*/) { /* Gwen::Controls::Label* label = (Gwen::Controls::Label*) pControl; Gwen::UnicodeString la = label->GetText();// node->GetButton()->GetName();// GetText(); @@ -675,30 +676,30 @@ struct MyMenuItemHander : public Gwen::Event::Handler } } - void onButtonE(Gwen::Controls::Base* pControl) + void onButtonE(Gwen::Controls::Base* /*pControl*/) { // printf("select %d\n",m_buttonId); sCurrentHightlighted = m_buttonId; gui2->setExampleDescription(gAllExamples->getExampleDescription(sCurrentHightlighted)); } - void onButtonF(Gwen::Controls::Base* pControl) + void onButtonF(Gwen::Controls::Base* /*pControl*/) { //printf("selection changed!\n"); } - void onButtonG(Gwen::Controls::Base* pControl) + void onButtonG(Gwen::Controls::Base* /*pControl*/) { //printf("onButtonG !\n"); } }; -void quitCallback() +static void quitCallback() { s_window->setRequestExit(); } -void fileOpenCallback() +static void fileOpenCallback() { char filename[1024]; int len = s_window->fileOpenDialog(filename, 1024); @@ -762,7 +763,7 @@ struct QuickCanvas : public Common2dCanvasInterface } virtual void destroyCanvas(int canvasId) { - btAssert(canvasId >= 0); + btAssert(canvasId >= 0 && canvasId < 5); delete m_gt[canvasId]; m_gt[canvasId] = 0; destroyTextureWindow(m_gw[canvasId]); @@ -1004,7 +1005,7 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[]) else { sth_stash* fontstash = simpleApp->getFontStash(); - m_internalData->m_gwenRenderer = new GwenOpenGL3CoreRenderer(simpleApp->m_primRenderer, fontstash, width, height, s_window->getRetinaScale(), myTexLoader); + m_internalData->m_gwenRenderer = new GwenOpenGL3CoreRenderer(simpleApp->m_primRenderer, fontstash, (float)width, (float)height, s_window->getRetinaScale(), myTexLoader); } #endif @@ -1314,7 +1315,7 @@ void OpenGLExampleBrowser::update(float deltaTime) B3_PROFILE("updateOpenGL"); if (sUseOpenGL2) { - saveOpenGLState(s_instancingRenderer->getScreenWidth() * s_window->getRetinaScale(), s_instancingRenderer->getScreenHeight() * s_window->getRetinaScale()); + saveOpenGLState(int((float)s_instancingRenderer->getScreenWidth() * s_window->getRetinaScale()), int((float)s_instancingRenderer->getScreenHeight() * s_window->getRetinaScale())); } if (m_internalData->m_gui) diff --git a/examples/ExampleBrowser/OpenGLGuiHelper.cpp b/examples/ExampleBrowser/OpenGLGuiHelper.cpp index 7df4e932bc..3d785fe1fe 100644 --- a/examples/ExampleBrowser/OpenGLGuiHelper.cpp +++ b/examples/ExampleBrowser/OpenGLGuiHelper.cpp @@ -17,9 +17,9 @@ struct MyDebugVec3 { MyDebugVec3(const btVector3& org) - : x(org.x()), - y(org.y()), - z(org.z()) + : x((float)org.x()), + y((float)org.y()), + z((float)org.z()) { } @@ -78,22 +78,22 @@ MyDebugDrawer : public btIDebugDraw m_linePoints.push_back(from); m_linePoints.push_back(to); - m_lineIndices.push_back(m_lineIndices.size()); - m_lineIndices.push_back(m_lineIndices.size()); + m_lineIndices.push_back((unsigned int)m_lineIndices.size()); + m_lineIndices.push_back((unsigned int)m_lineIndices.size()); } - virtual void drawContactPoint(const btVector3& PointOnB, const btVector3& normalOnB, btScalar distance, int lifeTime, const btVector3& color) + virtual void drawContactPoint(const btVector3& PointOnB, const btVector3& normalOnB, btScalar distance, int /*lifeTime*/, const btVector3& color) { drawLine(PointOnB, PointOnB + normalOnB * distance, color); btVector3 ncolor(0, 0, 0); - drawLine(PointOnB, PointOnB + normalOnB * 0.01, ncolor); + drawLine(PointOnB, PointOnB + normalOnB * btScalar(0.01), ncolor); } - virtual void reportErrorWarning(const char* warningString) + virtual void reportErrorWarning(const char* /*warningString*/) { } - virtual void draw3dText(const btVector3& location, const char* textString) + virtual void draw3dText(const btVector3& /*location*/, const char* /*textString*/) { } @@ -113,9 +113,9 @@ MyDebugDrawer : public btIDebugDraw if (sz) { float debugColor[4]; - debugColor[0] = m_currentLineColor.x(); - debugColor[1] = m_currentLineColor.y(); - debugColor[2] = m_currentLineColor.z(); + debugColor[0] = (float)m_currentLineColor.x(); + debugColor[1] = (float)m_currentLineColor.y(); + debugColor[2] = (float)m_currentLineColor.z(); debugColor[3] = 1.f; m_glApp->m_renderer->drawLines(&m_linePoints[0].x, debugColor, m_linePoints.size(), sizeof(MyDebugVec3), @@ -183,7 +183,7 @@ struct MyHashShape //to our success SIMD_FORCE_INLINE unsigned int getHash() const { - unsigned int key = m_shapeKey; + unsigned int key = (unsigned int)m_shapeKey; // Thomas Wang's hash key += ~(key << 15); key ^= (key >> 10); @@ -229,7 +229,7 @@ void OpenGLGuiHelper::setVRMode(bool vrMode) m_data->m_vrSkipShadowPass = 0; } -OpenGLGuiHelper::OpenGLGuiHelper(CommonGraphicsApp* glApp, bool useOpenGL2) +OpenGLGuiHelper::OpenGLGuiHelper(CommonGraphicsApp* glApp, bool /*useOpenGL2*/) { m_data = new OpenGLGuiHelperInternalData; m_data->m_glApp = glApp; @@ -280,7 +280,7 @@ class MyTriangleCollector2 : public btTriangleCallback m_pIndicesOut = 0; } - virtual void processTriangle(btVector3* tris, int partId, int triangleIndex) + virtual void processTriangle(btVector3* tris, int /*partId*/, int /*triangleIndex*/) { for (int k = 0; k < 3; k++) { @@ -291,14 +291,14 @@ class MyTriangleCollector2 : public btTriangleCallback normal.safeNormalize(); for (int l = 0; l < 3; l++) { - v.xyzw[l] = tris[k][l]; - v.normal[l] = normal[l]; + v.xyzw[l] = (float)tris[k][l]; + v.normal[l] = (float)normal[l]; } - btVector3 extents = m_aabbMax - m_aabbMin; + // btVector3 extents = m_aabbMax - m_aabbMin; - v.uv[0] = (1.-((v.xyzw[0] - m_aabbMin[0]) / (m_aabbMax[0] - m_aabbMin[0])))*m_textureScaling; - v.uv[1] = (1.-(v.xyzw[1] - m_aabbMin[1]) / (m_aabbMax[1] - m_aabbMin[1]))*m_textureScaling; + v.uv[0] = float((btScalar(1.)-((btScalar)v.xyzw[0] - m_aabbMin[0]) / (m_aabbMax[0] - m_aabbMin[0]))*m_textureScaling); + v.uv[1] = float((btScalar(1.)-((btScalar)v.xyzw[1] - m_aabbMin[1]) / (m_aabbMax[1] - m_aabbMin[1]))*m_textureScaling); m_pIndicesOut->push_back(m_pVerticesOut->size()); m_pVerticesOut->push_back(v); @@ -323,7 +323,7 @@ void OpenGLGuiHelper::createCollisionObjectGraphicsObject(btCollisionObject* bod btSoftBody* sb = btSoftBody::upcast(body); if (sb) { - int graphicsInstanceId = body->getUserIndex(); + graphicsInstanceId = body->getUserIndex(); changeInstanceFlags(graphicsInstanceId, B3_INSTANCE_DOUBLE_SIDED); } } @@ -341,7 +341,7 @@ void OpenGLGuiHelper::removeTexture(int textureUid) m_data->m_glApp->m_renderer->removeTexture(textureUid); } -void OpenGLGuiHelper::changeTexture(int textureUniqueId, const unsigned char* rgbTexels, int width, int height) +void OpenGLGuiHelper::changeTexture(int textureUniqueId, const unsigned char* rgbTexels, int /*width*/, int /*height*/) { bool flipPixelsY = true; m_data->m_glApp->m_renderer->updateTexture(textureUniqueId, rgbTexels, flipPixelsY); @@ -378,7 +378,7 @@ void OpenGLGuiHelper::removeGraphicsInstance(int graphicsUid) if (graphicsUid >= 0) { m_data->m_glApp->m_renderer->removeGraphicsInstance(graphicsUid); - }; + } } int OpenGLGuiHelper::getShapeIndexFromInstance(int instanceUid) @@ -391,7 +391,7 @@ void OpenGLGuiHelper::replaceTexture(int shapeIndex, int textureUid) if (shapeIndex >= 0) { m_data->m_glApp->m_renderer->replaceTexture(shapeIndex, textureUid); - }; + } } void OpenGLGuiHelper::changeInstanceFlags(int instanceUid, int flags) { @@ -406,7 +406,7 @@ void OpenGLGuiHelper::changeScaling(int instanceUid, const double scaling[3]) if (instanceUid >= 0) { m_data->m_glApp->m_renderer->writeSingleInstanceScaleToCPU(scaling, instanceUid); - }; + } } void OpenGLGuiHelper::changeRGBAColor(int instanceUid, const double rgbaColor[4]) @@ -414,14 +414,14 @@ void OpenGLGuiHelper::changeRGBAColor(int instanceUid, const double rgbaColor[4] if (instanceUid >= 0) { m_data->m_glApp->m_renderer->writeSingleInstanceColorToCPU(rgbaColor, instanceUid); - }; + } } void OpenGLGuiHelper::changeSpecularColor(int instanceUid, const double specularColor[3]) { if (instanceUid >= 0) { m_data->m_glApp->m_renderer->writeSingleInstanceSpecularColorToCPU(specularColor, instanceUid); - }; + } } int OpenGLGuiHelper::createCheckeredTexture(int red, int green, int blue) { @@ -441,9 +441,9 @@ int OpenGLGuiHelper::createCheckeredTexture(int red, int green, int blue) if (a == b) { - texels[(i + j * texWidth) * 3 + 0] = red; - texels[(i + j * texWidth) * 3 + 1] = green; - texels[(i + j * texWidth) * 3 + 2] = blue; + texels[(i + j * texWidth) * 3 + 0] = (unsigned char)red; + texels[(i + j * texWidth) * 3 + 1] = (unsigned char)green; + texels[(i + j * texWidth) * 3 + 2] = (unsigned char)blue; // texels[(i+j*texWidth)*4+3] = 255; } /*else @@ -501,7 +501,7 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli } else { - int numVertices = sizeof(cube_vertices_textured) / strideInBytes; + int numVertices = (int)(sizeof(cube_vertices_textured) / strideInBytes); transformedVertices.resize(numVertices * 9); for (int i = 0; i < numVertices; i++) { @@ -511,9 +511,9 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli cube_vertices_textured[i * 9 + 2]); btVector3 trVer = halfExtents * vert; - transformedVertices[i * 9 + 0] = trVer[0]; - transformedVertices[i * 9 + 1] = trVer[1]; - transformedVertices[i * 9 + 2] = trVer[2]; + transformedVertices[i * 9 + 0] = (float)trVer[0]; + transformedVertices[i * 9 + 1] = (float)trVer[1]; + transformedVertices[i * 9 + 2] = (float)trVer[2]; transformedVertices[i * 9 + 3] = cube_vertices_textured[i * 9 + 3]; transformedVertices[i * 9 + 4] = cube_vertices_textured[i * 9 + 4]; transformedVertices[i * 9 + 5] = cube_vertices_textured[i * 9 + 5]; @@ -542,7 +542,7 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli tr.setIdentity(); heightField->getAabb(tr, aabbMin, aabbMax); MyTriangleCollector2 col(aabbMin, aabbMax); - if (heightField->getUserValue3()) + if (heightField->getUserValue3() != btScalar(0)) { col.m_textureScaling = heightField->getUserValue3(); } @@ -585,7 +585,7 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli if (ms->getSphereCount() == 2) { btAlignedObjectArray transformedVertices; - int numVertices = sizeof(textured_detailed_sphere_vertices) / strideInBytes; + int numVertices = (int)(sizeof(textured_detailed_sphere_vertices) / strideInBytes); transformedVertices.resize(numVertices * 9); btVector3 sphere0Pos = ms->getSpherePosition(0); btVector3 sphere1Pos = ms->getSpherePosition(1); @@ -593,8 +593,8 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli MyHashShape shape; shape.m_sphere0Pos = sphere0Pos; shape.m_sphere1Pos = sphere1Pos; - shape.m_radius0 = 2. * ms->getSphereRadius(0); - shape.m_radius1 = 2. * ms->getSphereRadius(1); + shape.m_radius0 = btScalar(2.) * ms->getSphereRadius(0); + shape.m_radius1 = btScalar(2.) * ms->getSphereRadius(1); shape.m_deformFunc = 1; //vert.dot(fromTo) int graphicsShapeIndex = -1; int* graphicsShapeIndexPtr = m_data->m_hashShapes[shape]; @@ -618,20 +618,20 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli if (vert.dot(fromTo) > 0) { - btScalar radiusScale = 2. * ms->getSphereRadius(1); + btScalar radiusScale = btScalar(2.) * ms->getSphereRadius(1); trVer = radiusScale * vert; trVer += sphere1Pos; } else { - btScalar radiusScale = 2. * ms->getSphereRadius(0); + btScalar radiusScale = btScalar(2.) * ms->getSphereRadius(0); trVer = radiusScale * vert; trVer += sphere0Pos; } - transformedVertices[i * 9 + 0] = trVer[0]; - transformedVertices[i * 9 + 1] = trVer[1]; - transformedVertices[i * 9 + 2] = trVer[2]; + transformedVertices[i * 9 + 0] = (float)trVer[0]; + transformedVertices[i * 9 + 1] = (float)trVer[1]; + transformedVertices[i * 9 + 2] = (float)trVer[2]; transformedVertices[i * 9 + 3] = textured_detailed_sphere_vertices[i * 9 + 3]; transformedVertices[i * 9 + 4] = textured_detailed_sphere_vertices[i * 9 + 4]; transformedVertices[i * 9 + 5] = textured_detailed_sphere_vertices[i * 9 + 5]; @@ -656,7 +656,7 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli { btSphereShape* sphereShape = (btSphereShape*)collisionShape; btScalar radius = sphereShape->getRadius(); - btScalar sphereSize = 2. * radius; + btScalar sphereSize = btScalar(2.) * radius; btVector3 radiusScale(sphereSize, sphereSize, sphereSize); btAlignedObjectArray transformedVertices; @@ -672,7 +672,7 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli } else { - int numVertices = sizeof(textured_detailed_sphere_vertices) / strideInBytes; + int numVertices = (int)(sizeof(textured_detailed_sphere_vertices) / strideInBytes); transformedVertices.resize(numVertices * 9); for (int i = 0; i < numVertices; i++) { @@ -682,9 +682,9 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli textured_detailed_sphere_vertices[i * 9 + 2]); btVector3 trVer = radiusScale * vert; - transformedVertices[i * 9 + 0] = trVer[0]; - transformedVertices[i * 9 + 1] = trVer[1]; - transformedVertices[i * 9 + 2] = trVer[2]; + transformedVertices[i * 9 + 0] = (float)trVer[0]; + transformedVertices[i * 9 + 1] = (float)trVer[1]; + transformedVertices[i * 9 + 2] = (float)trVer[2]; transformedVertices[i * 9 + 3] = textured_detailed_sphere_vertices[i * 9 + 3]; transformedVertices[i * 9 + 4] = textured_detailed_sphere_vertices[i * 9 + 4]; transformedVertices[i * 9 + 5] = textured_detailed_sphere_vertices[i * 9 + 5]; @@ -710,7 +710,7 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli { btSphereShape* sphereShape = (btSphereShape*)compound->getChildShape(0); btScalar radius = sphereShape->getRadius(); - btScalar sphereSize = 2. * radius; + btScalar sphereSize = btScalar(2.) * radius; btVector3 radiusScale(sphereSize, sphereSize, sphereSize); MyHashShape shape; @@ -728,7 +728,7 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli else { btAlignedObjectArray transformedVertices; - int numVertices = sizeof(textured_detailed_sphere_vertices) / strideInBytes; + int numVertices = (int)(sizeof(textured_detailed_sphere_vertices) / strideInBytes); transformedVertices.resize(numVertices * 9); for (int i = 0; i < numVertices; i++) { @@ -738,9 +738,9 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli textured_detailed_sphere_vertices[i * 9 + 2]); btVector3 trVer = compound->getChildTransform(0) * (radiusScale * vert); - transformedVertices[i * 9 + 0] = trVer[0]; - transformedVertices[i * 9 + 1] = trVer[1]; - transformedVertices[i * 9 + 2] = trVer[2]; + transformedVertices[i * 9 + 0] = (float)trVer[0]; + transformedVertices[i * 9 + 1] = (float)trVer[1]; + transformedVertices[i * 9 + 2] = (float)trVer[2]; transformedVertices[i * 9 + 3] = textured_detailed_sphere_vertices[i * 9 + 3]; transformedVertices[i * 9 + 4] = textured_detailed_sphere_vertices[i * 9 + 4]; transformedVertices[i * 9 + 5] = textured_detailed_sphere_vertices[i * 9 + 5]; @@ -764,7 +764,7 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli btScalar halfHeight = sphereShape->getHalfHeight(); btScalar radius = sphereShape->getRadius(); - btScalar sphereSize = 2. * radius; + btScalar sphereSize = btScalar(2.) * radius; btVector3 radiusScale = btVector3(sphereSize, sphereSize, sphereSize); @@ -784,7 +784,7 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli else { btAlignedObjectArray transformedVertices; - int numVertices = sizeof(textured_detailed_sphere_vertices) / strideInBytes; + int numVertices = (int)(sizeof(textured_detailed_sphere_vertices) / strideInBytes); transformedVertices.resize(numVertices * 9); for (int i = 0; i < numVertices; i++) { @@ -801,9 +801,9 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli trVer = compound->getChildTransform(0) * trVer; - transformedVertices[i * 9 + 0] = trVer[0]; - transformedVertices[i * 9 + 1] = trVer[1]; - transformedVertices[i * 9 + 2] = trVer[2]; + transformedVertices[i * 9 + 0] = (float)trVer[0]; + transformedVertices[i * 9 + 1] = (float)trVer[1]; + transformedVertices[i * 9 + 2] = (float)trVer[2]; transformedVertices[i * 9 + 3] = textured_detailed_sphere_vertices[i * 9 + 3]; transformedVertices[i * 9 + 4] = textured_detailed_sphere_vertices[i * 9 + 4]; transformedVertices[i * 9 + 5] = textured_detailed_sphere_vertices[i * 9 + 5]; @@ -827,13 +827,13 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli if (ms->getSphereCount() == 2) { btAlignedObjectArray transformedVertices; - int numVertices = sizeof(textured_detailed_sphere_vertices) / strideInBytes; + int numVertices = (int)(sizeof(textured_detailed_sphere_vertices) / strideInBytes); transformedVertices.resize(numVertices * 9); btVector3 sphere0Pos = ms->getSpherePosition(0); btVector3 sphere1Pos = ms->getSpherePosition(1); btVector3 fromTo = sphere1Pos - sphere0Pos; - btScalar radiusScale1 = 2.0 * ms->getSphereRadius(1); - btScalar radiusScale0 = 2.0 * ms->getSphereRadius(0); + btScalar radiusScale1 = btScalar(2.0) * ms->getSphereRadius(1); + btScalar radiusScale0 = btScalar(2.0) * ms->getSphereRadius(0); MyHashShape shape; shape.m_radius0 = radiusScale0; @@ -873,9 +873,9 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli trVer = compound->getChildTransform(0) * trVer; } - transformedVertices[i * 9 + 0] = trVer[0]; - transformedVertices[i * 9 + 1] = trVer[1]; - transformedVertices[i * 9 + 2] = trVer[2]; + transformedVertices[i * 9 + 0] = (float)trVer[0]; + transformedVertices[i * 9 + 1] = (float)trVer[1]; + transformedVertices[i * 9 + 2] = (float)trVer[2]; transformedVertices[i * 9 + 3] = textured_detailed_sphere_vertices[i * 9 + 3]; transformedVertices[i * 9 + 4] = textured_detailed_sphere_vertices[i * 9 + 4]; transformedVertices[i * 9 + 5] = textured_detailed_sphere_vertices[i * 9 + 5]; @@ -901,7 +901,7 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli btScalar halfHeight = sphereShape->getHalfHeight(); btScalar radius = sphereShape->getRadius(); - btScalar sphereSize = 2. * radius; + btScalar sphereSize = btScalar(2.) * radius; btVector3 radiusScale(sphereSize, sphereSize, sphereSize); MyHashShape shape; @@ -919,7 +919,7 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli else { btAlignedObjectArray transformedVertices; - int numVertices = sizeof(textured_detailed_sphere_vertices) / strideInBytes; + int numVertices = (int)(sizeof(textured_detailed_sphere_vertices) / strideInBytes); transformedVertices.resize(numVertices * 9); for (int i = 0; i < numVertices; i++) { @@ -934,9 +934,9 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli else trVer[up] -= halfHeight; - transformedVertices[i * 9 + 0] = trVer[0]; - transformedVertices[i * 9 + 1] = trVer[1]; - transformedVertices[i * 9 + 2] = trVer[2]; + transformedVertices[i * 9 + 0] = (float)trVer[0]; + transformedVertices[i * 9 + 1] = (float)trVer[1]; + transformedVertices[i * 9 + 2] = (float)trVer[2]; transformedVertices[i * 9 + 3] = textured_detailed_sphere_vertices[i * 9 + 3]; transformedVertices[i * 9 + 4] = textured_detailed_sphere_vertices[i * 9 + 4]; transformedVertices[i * 9 + 5] = textured_detailed_sphere_vertices[i * 9 + 5]; @@ -987,13 +987,13 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli btVector3 vtxPos; btVector3 pos = parentTransform * verts[i]; - gfxVertices[i].xyzw[0] = pos[0]; - gfxVertices[i].xyzw[1] = pos[1]; - gfxVertices[i].xyzw[2] = pos[2]; + gfxVertices[i].xyzw[0] = (float)pos[0]; + gfxVertices[i].xyzw[1] = (float)pos[1]; + gfxVertices[i].xyzw[2] = (float)pos[2]; gfxVertices[i].xyzw[3] = 1; - gfxVertices[i].normal[0] = triNormal[0]; - gfxVertices[i].normal[1] = triNormal[1]; - gfxVertices[i].normal[2] = triNormal[2]; + gfxVertices[i].normal[0] = (float)triNormal[0]; + gfxVertices[i].normal[1] = (float)triNormal[1]; + gfxVertices[i].normal[2] = (float)triNormal[2]; } //verts[0] = planeOrigin + vec0*vecLen + vec1*vecLen; @@ -1001,14 +1001,14 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli //verts[2] = planeOrigin - vec0*vecLen - vec1*vecLen; //verts[3] = planeOrigin + vec0*vecLen - vec1*vecLen; - gfxVertices[0].uv[0] = vecLen / 2; - gfxVertices[0].uv[1] = vecLen / 2; - gfxVertices[1].uv[0] = -vecLen / 2; - gfxVertices[1].uv[1] = vecLen / 2; - gfxVertices[2].uv[0] = -vecLen / 2; - gfxVertices[2].uv[1] = -vecLen / 2; - gfxVertices[3].uv[0] = vecLen / 2; - gfxVertices[3].uv[1] = -vecLen / 2; + gfxVertices[0].uv[0] = (float)vecLen / 2; + gfxVertices[0].uv[1] = (float)vecLen / 2; + gfxVertices[1].uv[0] = (float)-vecLen / 2; + gfxVertices[1].uv[1] = (float)vecLen / 2; + gfxVertices[2].uv[0] = (float)-vecLen / 2; + gfxVertices[2].uv[1] = (float)-vecLen / 2; + gfxVertices[3].uv[0] = (float)vecLen / 2; + gfxVertices[3].uv[1] = (float)-vecLen / 2; int shapeId = registerGraphicsShape(&gfxVertices[0].xyzw[0], gfxVertices.size(), &indices[0], indices.size(), B3_GL_TRIANGLES, m_data->m_checkedTexture); collisionShape->setUserIndex(shapeId); @@ -1028,11 +1028,11 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli { for (int j = 0; j < 4; j++) { - gfxVertices[i].xyzw[j] = vertexPositions[i][j]; + gfxVertices[i].xyzw[j] = (float)vertexPositions[i][j]; } for (int j = 0; j < 3; j++) { - gfxVertices[i].normal[j] = vertexNormals[i][j]; + gfxVertices[i].normal[j] = (float)vertexNormals[i][j]; } for (int j = 0; j < 2; j++) { @@ -1070,18 +1070,18 @@ void OpenGLGuiHelper::syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWor { gfxVertices.resize(psb->m_renderNodes.size()); - for (int i = 0; i < psb->m_renderNodes.size(); i++) // Foreach face + for (int j = 0; j < psb->m_renderNodes.size(); j++) // Foreach face { - gfxVertices[i].xyzw[0] = psb->m_renderNodes[i].m_x[0]; - gfxVertices[i].xyzw[1] = psb->m_renderNodes[i].m_x[1]; - gfxVertices[i].xyzw[2] = psb->m_renderNodes[i].m_x[2]; - gfxVertices[i].xyzw[3] = psb->m_renderNodes[i].m_x[3]; - gfxVertices[i].uv[0] = psb->m_renderNodes[i].m_uv1[0]; - gfxVertices[i].uv[1] = psb->m_renderNodes[i].m_uv1[1]; + gfxVertices[j].xyzw[0] = (float)psb->m_renderNodes[j].m_x[0]; + gfxVertices[j].xyzw[1] = (float)psb->m_renderNodes[j].m_x[1]; + gfxVertices[j].xyzw[2] = (float)psb->m_renderNodes[j].m_x[2]; + gfxVertices[j].xyzw[3] = (float)psb->m_renderNodes[j].m_x[3]; + gfxVertices[j].uv[0] = (float)psb->m_renderNodes[j].m_uv1[0]; + gfxVertices[j].uv[1] = (float)psb->m_renderNodes[j].m_uv1[1]; //gfxVertices[i].normal[0] = psb->m_renderNodes[i]. - gfxVertices[i].normal[0] = psb->m_renderNodes[i].m_normal[0]; - gfxVertices[i].normal[1] = psb->m_renderNodes[i].m_normal[1]; - gfxVertices[i].normal[2] = psb->m_renderNodes[i].m_normal[2]; + gfxVertices[j].normal[0] = (float)psb->m_renderNodes[j].m_normal[0]; + gfxVertices[j].normal[1] = (float)psb->m_renderNodes[j].m_normal[1]; + gfxVertices[j].normal[2] = (float)psb->m_renderNodes[j].m_normal[2]; } } else @@ -1107,7 +1107,7 @@ void OpenGLGuiHelper::syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWor } } -void OpenGLGuiHelper::render(const btDiscreteDynamicsWorld* rbWorld) +void OpenGLGuiHelper::render(const btDiscreteDynamicsWorld* /*rbWorld*/) { if (m_data->m_vrMode) { @@ -1202,11 +1202,11 @@ bool OpenGLGuiHelper::getCameraInfo(int* width, int* height, float viewMatrix[16 float top = 1.f; float bottom = -1.f; float tanFov = (top - bottom) * 0.5f / 1; - float fov = btScalar(2.0) * btAtan(tanFov); + float fov = float(btScalar(2.0) * btAtan(tanFov)); btVector3 camPos, camTarget; getRenderInterface()->getActiveCamera()->getCameraPosition(camPos); getRenderInterface()->getActiveCamera()->getCameraTargetPosition(camTarget); - btVector3 rayFrom = camPos; + // btVector3 rayFrom = camPos; btVector3 rayForward = (camTarget - camPos); rayForward.normalize(); float farPlane = 10000.f; @@ -1226,19 +1226,19 @@ bool OpenGLGuiHelper::getCameraInfo(int* width, int* height, float viewMatrix[16 btScalar aspect = float(*width) / float(*height); hori *= aspect; //compute 'hor' and 'vert' vectors, useful to generate raytracer rays - hor[0] = hori[0]; - hor[1] = hori[1]; - hor[2] = hori[2]; - vert[0] = vertical[0]; - vert[1] = vertical[1]; - vert[2] = vertical[2]; + hor[0] = (float)hori[0]; + hor[1] = (float)hori[1]; + hor[2] = (float)hori[2]; + vert[0] = (float)vertical[0]; + vert[1] = (float)vertical[1]; + vert[2] = (float)vertical[2]; *yaw = getRenderInterface()->getActiveCamera()->getCameraYaw(); *pitch = getRenderInterface()->getActiveCamera()->getCameraPitch(); *camDist = getRenderInterface()->getActiveCamera()->getCameraDistance(); - cameraTarget[0] = camTarget[0]; - cameraTarget[1] = camTarget[1]; - cameraTarget[2] = camTarget[2]; + cameraTarget[0] = (float)camTarget[0]; + cameraTarget[1] = (float)camTarget[1]; + cameraTarget[2] = (float)camTarget[2]; return true; } return false; @@ -1256,13 +1256,13 @@ void OpenGLGuiHelper::setProjectiveTexture(bool useProjectiveTexture) void OpenGLGuiHelper::copyCameraImageData(const float viewMatrix[16], const float projectionMatrix[16], unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels, - float* depthBuffer, int depthBufferSizeInPixels, - int* segmentationMaskBuffer, int segmentationMaskBufferSizeInPixels, + float* depthBuffer, int /*depthBufferSizeInPixels*/, + int* segmentationMaskBuffer, int /*segmentationMaskBufferSizeInPixels*/, int startPixelIndex, int destinationWidth, int destinationHeight, int* numPixelsCopied) { - int sourceWidth = btMin(destinationWidth, (int)(m_data->m_glApp->m_window->getWidth() * m_data->m_glApp->m_window->getRetinaScale())); - int sourceHeight = btMin(destinationHeight, (int)(m_data->m_glApp->m_window->getHeight() * m_data->m_glApp->m_window->getRetinaScale())); + int sourceWidth = btMin(destinationWidth, (int)((float)m_data->m_glApp->m_window->getWidth() * m_data->m_glApp->m_window->getRetinaScale())); + int sourceHeight = btMin(destinationHeight, (int)((float)m_data->m_glApp->m_window->getHeight() * m_data->m_glApp->m_window->getRetinaScale())); m_data->m_glApp->setViewport(sourceWidth, sourceHeight); if (numPixelsCopied) @@ -1294,7 +1294,7 @@ void OpenGLGuiHelper::copyCameraImageData(const float viewMatrix[16], const floa sourceDepthBuffer.resize(sourceWidth * sourceHeight); { BT_PROFILE("getScreenPixels"); - m_data->m_glApp->getScreenPixels(&(sourceRgbaPixelBuffer[0]), sourceRgbaPixelBuffer.size(), &sourceDepthBuffer[0], sizeof(float) * sourceDepthBuffer.size()); + m_data->m_glApp->getScreenPixels(&(sourceRgbaPixelBuffer[0]), sourceRgbaPixelBuffer.size(), &sourceDepthBuffer[0], (int)(sizeof(float) * sourceDepthBuffer.size())); } m_data->m_rgbaPixelBuffer1.resize(destinationWidth * destinationHeight * numBytesPerPixel); @@ -1355,7 +1355,7 @@ void OpenGLGuiHelper::copyCameraImageData(const float viewMatrix[16], const floa sourceDepthBuffer.resize(sourceWidth * sourceHeight); { BT_PROFILE("getScreenPixelsSegmentationMask"); - m_data->m_glApp->getScreenPixels(&(sourceRgbaPixelBuffer[0]), sourceRgbaPixelBuffer.size(), &sourceDepthBuffer[0], sizeof(float) * sourceDepthBuffer.size()); + m_data->m_glApp->getScreenPixels(&(sourceRgbaPixelBuffer[0]), sourceRgbaPixelBuffer.size(), &sourceDepthBuffer[0], (int)(sizeof(float) * sourceDepthBuffer.size())); } m_data->m_segmentationMaskBuffer.resize(destinationWidth * destinationHeight, -1); @@ -1444,7 +1444,7 @@ struct MyConvertPointerSizeT size_t m_int; }; }; -bool shapePointerCompareFunc(const btCollisionObject* colA, const btCollisionObject* colB) +static bool shapePointerCompareFunc(const btCollisionObject* colA, const btCollisionObject* colB) { MyConvertPointerSizeT a, b; a.m_ptr = colA->getCollisionShape(); @@ -1454,7 +1454,7 @@ bool shapePointerCompareFunc(const btCollisionObject* colA, const btCollisionObj void OpenGLGuiHelper::autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) { - //sort the collision objects based on collision shape, the gfx library requires instances that re-use a shape to be added after eachother + //sort the collision objects based on collision shape, the gfx library requires instances that reuse a shape to be added after each other btAlignedObjectArray sortedObjects; sortedObjects.reserve(rbWorld->getNumCollisionObjects()); @@ -1534,15 +1534,15 @@ void OpenGLGuiHelper::computeSoftBodyVertices(btCollisionShape* collisionShape, int currentIndex = i * 3 + k; for (int j = 0; j < 3; j++) { - gfxVertices[currentIndex].xyzw[j] = psb->m_faces[i].m_n[k]->m_x[j]; + gfxVertices[currentIndex].xyzw[j] = (float)psb->m_faces[i].m_n[k]->m_x[j]; } for (int j = 0; j < 3; j++) { - gfxVertices[currentIndex].normal[j] = psb->m_faces[i].m_n[k]->m_n[j]; + gfxVertices[currentIndex].normal[j] = (float)psb->m_faces[i].m_n[k]->m_n[j]; } for (int j = 0; j < 2; j++) { - gfxVertices[currentIndex].uv[j] = psb->m_faces[i].m_n[k]->m_x[j]; + gfxVertices[currentIndex].uv[j] = (float)psb->m_faces[i].m_n[k]->m_x[j]; } indices.push_back(currentIndex); } @@ -1552,4 +1552,4 @@ void OpenGLGuiHelper::computeSoftBodyVertices(btCollisionShape* collisionShape, void OpenGLGuiHelper::updateShape(int shapeIndex, float* vertices, int numVertices) { m_data->m_glApp->m_renderer->updateShape(shapeIndex, vertices, numVertices); -} \ No newline at end of file +} diff --git a/examples/ExampleBrowser/OpenGLGuiHelper.h b/examples/ExampleBrowser/OpenGLGuiHelper.h index c512c21b97..0cf9c9cc5a 100644 --- a/examples/ExampleBrowser/OpenGLGuiHelper.h +++ b/examples/ExampleBrowser/OpenGLGuiHelper.h @@ -72,21 +72,21 @@ struct OpenGLGuiHelper : public GUIHelperInterface virtual void drawText3D(const char* txt, float posX, float posY, float posZ, float size); - virtual int addUserDebugText3D(const char* txt, const double positionXYZ[3], const double textColorRGB[3], double size, double lifeTime) + virtual int addUserDebugText3D(const char* /*txt*/, const double /*positionXYZ*/[3], const double /*textColorRGB*/[3], double /*size*/, double /*lifeTime*/) { return -1; } - virtual int addUserDebugLine(const double debugLineFromXYZ[3], const double debugLineToXYZ[3], const double debugLineColorRGB[3], double lineWidth, double lifeTime, int trackingVisualShapeIndex, int replaceItemUid) + virtual int addUserDebugLine(const double /*debugLineFromXYZ*/[3], const double /*debugLineToXYZ*/[3], const double /*debugLineColorRGB*/[3], double /*lineWidth*/, double /*lifeTime*/, int /*trackingVisualShapeIndex*/, int /*replaceItemUid*/) { return -1; } - virtual int addUserDebugParameter(const char* txt, double rangeMin, double rangeMax, double startValue) + virtual int addUserDebugParameter(const char* /*txt*/, double /*rangeMin*/, double /*rangeMax*/, double /*startValue*/) { return -1; } - virtual void removeUserDebugItem(int debugItemUniqueId) + virtual void removeUserDebugItem(int /*debugItemUniqueId*/) { } virtual void removeAllUserDebugItems() diff --git a/examples/ExampleBrowser/main.cpp b/examples/ExampleBrowser/main.cpp index f306c3f029..23733ac821 100644 --- a/examples/ExampleBrowser/main.cpp +++ b/examples/ExampleBrowser/main.cpp @@ -26,7 +26,14 @@ static OpenGLExampleBrowser* sExampleBrowser = 0; #include #include #include -static void cleanup(int signo) + +#if defined(__GNUC__) +#define ANNOTATE_NORETURN __attribute((noreturn)) +#else +#define ANNOTATE_NORETURN +#endif + +static ANNOTATE_NORETURN void cleanup(int signo) { if (!interrupted) { // this is the second time, we're hanging somewhere @@ -41,8 +48,8 @@ static void cleanup(int signo) b3Printf("no action"); exit(EXIT_FAILURE); } - interrupted = true; - warnx("caught signal %d", signo); + // interrupted = true; + // warnx("caught signal %d", signo); } #endif //_WIN32 @@ -53,7 +60,7 @@ int main(int argc, char* argv[]) memset(&action, 0x0, sizeof(action)); action.sa_handler = cleanup; static const int signos[] = {SIGHUP, SIGINT, SIGQUIT, SIGABRT, SIGSEGV, SIGPIPE, SIGTERM}; - for (int ii(0); ii < sizeof(signos) / sizeof(*signos); ++ii) + for (int ii(0); ii < (int)(sizeof(signos) / sizeof(*signos)); ++ii) { if (0 != sigaction(signos[ii], &action, NULL)) { @@ -84,14 +91,14 @@ int main(int argc, char* argv[]) { do { - float deltaTimeInSeconds = clock.getTimeMicroseconds() / 1000000.f; + float deltaTimeInSeconds = (float)clock.getTimeMicroseconds() / 1000000.f; if (deltaTimeInSeconds > 0.1) { - deltaTimeInSeconds = 0.1; + deltaTimeInSeconds = 0.1f; } if (deltaTimeInSeconds < (gMinUpdateTimeMicroSecs / 1e6)) { - b3Clock::usleep(gMinUpdateTimeMicroSecs / 10.); + b3Clock::usleep(int(gMinUpdateTimeMicroSecs / 10.)); } else { diff --git a/examples/Experiments/ImplicitCloth/stan/SpringNetwork.cpp b/examples/Experiments/ImplicitCloth/stan/SpringNetwork.cpp index 82db71f8bc..751198d5a6 100644 --- a/examples/Experiments/ImplicitCloth/stan/SpringNetwork.cpp +++ b/examples/Experiments/ImplicitCloth/stan/SpringNetwork.cpp @@ -9,7 +9,7 @@ extern int numX; // (c) Stan Melax 2006 // http://www.melax.com/cloth // freeware demo and source -// Although its free software, I'll gaurantee and support this software as much as is reasonable. +// Although its free software, I'll guarantee and support this software as much as is reasonable. // However, if you choose to use any of this code, then you agree that // I assume no financial liability should the software not meet your expectations. // But do feel free to send any feedback. @@ -19,7 +19,7 @@ extern int numX; // The remainder of the code builds a cloth system with basic render support, I/O, and manipulators, // so its possible to make use of the technology within a 3D application. // This code is separated from the SpringNetwork class in order to avoid pushing a particular style -// and prevent any dependancies of the algorithms onto unrelated systems. +// and prevent any dependencies of the algorithms onto unrelated systems. // Feel free to adapt any of this into your own 3D engine/environment. // // Instead of having unique Hooke force and damping coefficients on each spring, the SpringNetwork @@ -99,7 +99,7 @@ SpringNetwork::Spring &SpringNetwork::AddBlocks(Spring &s) // Called during initial creation of springs in our spring network. // Sets up the sparse matrices corresponding to connections. // Note the indices (s.iab,s.iba) are also stored with spring to avoid looking them up each time a spring is applied - // All 3 matrices A,dFdX, and dFdV are contstructed identically so the block array layout will be the same for each. + // All 3 matrices A,dFdX, and dFdV are constructed identically so the block array layout will be the same for each. s.iab = A.blocks.count; // added 'ab' blocks will have this index. A.blocks.Add(float3Nx3N::Block(s.a, s.b)); dFdX.blocks.Add(float3Nx3N::Block(s.a, s.b)); @@ -115,7 +115,7 @@ void SpringNetwork::PreSolveSpring(const SpringNetwork::Spring &s) { // Adds this spring's contribution into force vector F and force derivitves dFdX and dFdV // One optimization would be premultiply dfdx by dt*dt and F and dFdV by dt right here in this function. - // However, for educational purposes we wont do that now and intead just follow the paper directly. + // However, for educational purposes we won't do that now and instead just follow the paper directly. //assert(dFdX.blocks[s.a].c==s.a); // delete this assert, no bugs here //assert(dFdX.blocks[s.a].r==s.a); float3 extent = X[s.b] - X[s.a]; diff --git a/examples/Experiments/ImplicitCloth/stan/array.h b/examples/Experiments/ImplicitCloth/stan/array.h index e422c509c1..b9a3bf33a0 100644 --- a/examples/Experiments/ImplicitCloth/stan/array.h +++ b/examples/Experiments/ImplicitCloth/stan/array.h @@ -205,7 +205,7 @@ Type &Array::Add(Type t) } //int i; //for(i=0;iresetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } }; @@ -59,7 +59,7 @@ void BridgeExample::initPhysics() groundTransform.setIdentity(); groundTransform.setOrigin(btVector3(0, -50, 0)); { - btScalar mass(0.); + float mass(0.); createRigidBody(mass, groundTransform, groundShape, btVector4(0, 0, 1, 1)); } @@ -67,14 +67,14 @@ void BridgeExample::initPhysics() { //create a few dynamic rigidbodies - // Re-using the same collision is better for memory usage and performance - btScalar plankWidth = 0.4; - btScalar plankHeight = 0.2; + // Reusing the same collision is better for memory usage and performance + btScalar plankWidth = btScalar(0.4); + btScalar plankHeight = btScalar(0.2); btScalar plankBreadth = 1; btScalar plankOffset = plankWidth; //distance between two planks btScalar bridgeWidth = plankWidth * TOTAL_PLANKS + plankOffset * (TOTAL_PLANKS - 1); btScalar bridgeHeight = 5; - btScalar halfBridgeWidth = bridgeWidth * 0.5f; + btScalar halfBridgeWidth = bridgeWidth * btScalar(0.5); btBoxShape* colShape = createBoxShape(btVector3(plankWidth, plankHeight, plankBreadth)); @@ -98,13 +98,13 @@ void BridgeExample::initPhysics() int lastBoxIndex = TOTAL_PLANKS - 1; for (int i = 0; i < TOTAL_PLANKS; ++i) { - float t = float(i) / lastBoxIndex; - t = -(t * 2 - 1.0f) * halfBridgeWidth; + float t = float(i) / (float)lastBoxIndex; + t = -(t * 2 - 1.0f) * (float)halfBridgeWidth; startTransform.setOrigin(btVector3( btScalar(t), bridgeHeight, btScalar(0))); - boxes.push_back(createRigidBody((i == 0 || i == lastBoxIndex) ? 0 : mass, startTransform, colShape)); + boxes.push_back(createRigidBody((i == 0 || i == lastBoxIndex) ? 0 : (float)mass, startTransform, colShape)); } //add N-1 spring constraints diff --git a/examples/ExtendedTutorials/Chain.cpp b/examples/ExtendedTutorials/Chain.cpp index d8f0b8964c..4b5c3d4797 100644 --- a/examples/ExtendedTutorials/Chain.cpp +++ b/examples/ExtendedTutorials/Chain.cpp @@ -35,7 +35,7 @@ struct ChainExample : public CommonRigidBodyBase float dist = 41; float pitch = -35; float yaw = 52; - float targetPos[3] = {0, 0.46, 0}; + float targetPos[3] = {0, 0.46f, 0}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } }; @@ -59,13 +59,13 @@ void ChainExample::initPhysics() groundTransform.setIdentity(); groundTransform.setOrigin(btVector3(0, -50, 0)); { - btScalar mass(0.); + float mass(0.); createRigidBody(mass, groundTransform, groundShape, btVector4(0, 0, 1, 1)); } { //create a few dynamic rigidbodies - // Re-using the same collision is better for memory usage and performance + // Reusing the same collision is better for memory usage and performance btBoxShape* colShape = createBoxShape(btVector3(1, 1, 0.25)); m_collisionShapes.push_back(colShape); @@ -91,7 +91,7 @@ void ChainExample::initPhysics() btScalar(0), btScalar(5 + i * 2), btScalar(0))); - boxes.push_back(createRigidBody((i == lastBoxIndex) ? 0 : mass, startTransform, colShape)); + boxes.push_back(createRigidBody((i == lastBoxIndex) ? 0 : (float)mass, startTransform, colShape)); } //add N-1 spring constraints diff --git a/examples/ExtendedTutorials/CompoundBoxes.cpp b/examples/ExtendedTutorials/CompoundBoxes.cpp index c9768e6be6..3b7d87a71f 100644 --- a/examples/ExtendedTutorials/CompoundBoxes.cpp +++ b/examples/ExtendedTutorials/CompoundBoxes.cpp @@ -34,7 +34,7 @@ struct CompoundBoxesExample : public CommonRigidBodyBase float dist = 41; float pitch = -35; float yaw = 52; - float targetPos[3] = {0, 0.46, 0}; + float targetPos[3] = {0, 0.46f, 0}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } }; @@ -58,13 +58,13 @@ void CompoundBoxesExample::initPhysics() groundTransform.setIdentity(); groundTransform.setOrigin(btVector3(0, -50, 0)); { - btScalar mass(0.); + float mass(0.); createRigidBody(mass, groundTransform, groundShape, btVector4(0, 0, 1, 1)); } { //create a few dynamic rigidbodies - // Re-using the same collision is better for memory usage and performance + // Reusing the same collision is better for memory usage and performance btBoxShape* cube = createBoxShape(btVector3(0.5, 0.5, 0.5)); m_collisionShapes.push_back(cube); @@ -91,12 +91,12 @@ void CompoundBoxesExample::initPhysics() btVector3 inertia; compoundShape->calculatePrincipalAxisTransform(masses, principal, inertia); - // new compund shape to store + // new compound shape to store btCompoundShape* compound2 = new btCompoundShape(); m_collisionShapes.push_back(compound2); #if 0 - // less efficient way to add the entire compund shape - // to a new compund shape as a child + // less efficient way to add the entire compound shape + // to a new compound shape as a child compound2->addChildShape(principal.inverse(), compoundShape); #else // recompute the shift to make sure the compound shape is re-aligned diff --git a/examples/ExtendedTutorials/InclinedPlane.cpp b/examples/ExtendedTutorials/InclinedPlane.cpp index 5cccc3bd9c..0cbb0917b5 100644 --- a/examples/ExtendedTutorials/InclinedPlane.cpp +++ b/examples/ExtendedTutorials/InclinedPlane.cpp @@ -34,7 +34,7 @@ static btScalar gBoxRestitution = 0; // set box restitution to 0 static btScalar gSphereFriction = 1; // set sphere friction to 1 static btScalar gSphereRollingFriction = 1; // set sphere rolling friction to 1 -static btScalar gSphereSpinningFriction = 0.3; // set sphere spinning friction to 0.3 +static btScalar gSphereSpinningFriction = btScalar(0.3); // set sphere spinning friction to 0.3 static btScalar gSphereRestitution = 0; // set sphere restitution to 0 @@ -60,7 +60,7 @@ struct InclinedPlaneExample : public CommonRigidBodyBase float dist = 41; float pitch = -35; float yaw = 52; - float targetPos[3] = {0, 0.46, 0}; + float targetPos[3] = {0, 0.46f, 0}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } }; @@ -84,7 +84,7 @@ void InclinedPlaneExample::initPhysics() { // create slider to change the ramp tilt SliderParams slider("Ramp Tilt", &gTilt); slider.m_minVal = 0; - slider.m_maxVal = SIMD_PI / 2.0f; + slider.m_maxVal = (float)SIMD_PI / 2.0f; slider.m_clampToNotches = false; slider.m_callback = onRampInclinationChanged; m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider); @@ -178,7 +178,7 @@ void InclinedPlaneExample::initPhysics() groundTransform.setIdentity(); groundTransform.setOrigin(btVector3(0, -50, 0)); - btScalar mass(0.); + float mass(0.); createRigidBody(mass, groundTransform, groundShape, btVector4(0, 0, 1, 1)); } @@ -199,7 +199,7 @@ void InclinedPlaneExample::initPhysics() incline.setRotation(btVector3(0, 0, 1), gTilt); startTransform.setRotation(incline); - btScalar mass(0.); + float mass(0.); ramp = createRigidBody(mass, startTransform, inclinedPlaneShape); ramp->setFriction(gRampFriction); ramp->setRestitution(gRampRestitution); @@ -213,7 +213,7 @@ void InclinedPlaneExample::initPhysics() btTransform startTransform; startTransform.setIdentity(); - btScalar boxMass(1.f); + float boxMass(1.f); startTransform.setOrigin( btVector3(btScalar(0), btScalar(20), btScalar(2))); @@ -232,7 +232,7 @@ void InclinedPlaneExample::initPhysics() btTransform startTransform; startTransform.setIdentity(); - btScalar sphereMass(1.f); + float sphereMass(1.f); startTransform.setOrigin( btVector3(btScalar(0), btScalar(20), btScalar(4))); @@ -293,7 +293,7 @@ void InclinedPlaneExample::renderScene() CommonRigidBodyBase::renderScene(); } -bool InclinedPlaneExample::keyboardCallback(int key, int state) +bool InclinedPlaneExample::keyboardCallback(int key, int /*state*/) { // b3Printf("Key pressed: %d in state %d \n",key,state); @@ -304,6 +304,8 @@ bool InclinedPlaneExample::keyboardCallback(int key, int state) resetScene(); break; } + default: + break; } return false; @@ -346,7 +348,7 @@ void onSphereRestitutionChanged(float restitution, void*) } } -void onRampInclinationChanged(float inclination, void*) +void onRampInclinationChanged(float /*inclination*/, void*) { if (ramp) { diff --git a/examples/ExtendedTutorials/MultiPendulum.cpp b/examples/ExtendedTutorials/MultiPendulum.cpp index 3e0a7feba2..1b44c0ffbc 100644 --- a/examples/ExtendedTutorials/MultiPendulum.cpp +++ b/examples/ExtendedTutorials/MultiPendulum.cpp @@ -64,7 +64,7 @@ struct MultiPendulumExample : public CommonRigidBodyBase float dist = 41; float pitch = -35; float yaw = 52; - float targetPos[3] = {0, 0.46, 0}; + float targetPos[3] = {0, 0.46f, 0}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } @@ -124,7 +124,7 @@ void MultiPendulumExample::initPhysics() { // create a slider to change the force to displace the lowest pendulum SliderParams slider("Displacement force", &gDisplacementForce); - slider.m_minVal = 0.1; + slider.m_minVal = 0.1f; slider.m_maxVal = 200; slider.m_clampToNotches = false; m_guiHelper->getParameterInterface()->registerSliderFloatParameter( @@ -155,7 +155,7 @@ void MultiPendulumExample::initPhysics() btVector3 position(0.0f, 15.0f, 0.0f); // initial top-most pendulum position - // Re-using the same collision is better for memory usage and performance + // Reusing the same collision is better for memory usage and performance btSphereShape* pendulumShape = new btSphereShape(gSphereRadius); m_collisionShapes.push_back(pendulumShape); @@ -169,7 +169,7 @@ void MultiPendulumExample::initPhysics() void MultiPendulumExample::stepSimulation(float deltaTime) { - applyMForceWithForceScalar(gForceScalar); // apply force defined by apply force slider + applyMForceWithForceScalar((float)gForceScalar); // apply force defined by apply force slider if (m_dynamicsWorld) { @@ -201,7 +201,7 @@ void MultiPendulumExample::createMultiPendulum(btSphereShape* colShape, startTransform.setRotation(btQuaternion(0, 0, 0, 1)); // zero rotation - btRigidBody* topSphere = createRigidBody(mass, startTransform, colShape); + btRigidBody* topSphere = createRigidBody((float)mass, startTransform, colShape); // disable the deactivation when object does not move anymore topSphere->setActivationState(DISABLE_DEACTIVATION); @@ -219,17 +219,17 @@ void MultiPendulumExample::createMultiPendulum(btSphereShape* colShape, btRigidBody* parentSphere = topSphere; // set the top sphere as the parent sphere for the next sphere to be created - for (int i = 0; i < pendulaQty; i++) + for (int i = 0; (btScalar)i < pendulaQty; i++) { // produce the number of pendula // create joint element to make the pendulum rotate it // position the joint sphere at the same position as the top sphere - startTransform.setOrigin(position - btVector3(0, length * (i), 0)); + startTransform.setOrigin(position - btVector3(0, length * (btScalar)i, 0)); startTransform.setRotation(btQuaternion(0, 0, 0, 1)); // zero rotation - btRigidBody* jointSphere = createRigidBody(mass, startTransform, + btRigidBody* jointSphere = createRigidBody((float)mass, startTransform, colShape); jointSphere->setFriction(0); // we do not need friction here @@ -251,24 +251,24 @@ void MultiPendulumExample::createMultiPendulum(btSphereShape* colShape, parentSphere->getWorldTransform().getOrigin())); constraintPivotInJointSphereRF.setOrigin(parentSphereInJointSphereRF); - btPoint2PointConstraint* p2pconst = new btPoint2PointConstraint( + btPoint2PointConstraint* p2pconstraint = new btPoint2PointConstraint( *parentSphere, *jointSphere, constraintPivotInParentSphereRF.getOrigin(), constraintPivotInJointSphereRF.getOrigin()); - p2pconst->setDbgDrawSize(btScalar(5.f)); // set the size of the debug drawing + p2pconstraint->setDbgDrawSize(btScalar(5.f)); // set the size of the debug drawing // add the constraint to the world - m_dynamicsWorld->addConstraint(p2pconst, true); + m_dynamicsWorld->addConstraint(p2pconstraint, true); // create a slider constraint to change the length of the pendula while it swings startTransform.setIdentity(); // reset start transform // position the child sphere below the joint sphere - startTransform.setOrigin(position - btVector3(0, length * (i + 1), 0)); + startTransform.setOrigin(position - btVector3(0, length * (btScalar)(i + 1), 0)); startTransform.setRotation(btQuaternion(0, 0, 0, 1)); // zero rotation - btRigidBody* childSphere = createRigidBody(mass, startTransform, + btRigidBody* childSphere = createRigidBody((float)mass, startTransform, colShape); childSphere->setFriction(0); // we do not need friction here pendula.push_back(childSphere); @@ -351,7 +351,7 @@ void MultiPendulumExample::renderScene() CommonRigidBodyBase::renderScene(); } -bool MultiPendulumExample::keyboardCallback(int key, int state) +bool MultiPendulumExample::keyboardCallback(int key, int /*state*/) { //b3Printf("Key pressed: %d in state %d \n",key,state); @@ -389,6 +389,8 @@ bool MultiPendulumExample::keyboardCallback(int key, int state) applyPendulumForce(gDisplacementForce); return true; } + default: + break; } return false; @@ -399,10 +401,10 @@ void MultiPendulumExample::applyPendulumForce(btScalar pendulumForce) if (pendulumForce != 0) { b3Printf("Apply %f to pendulum", pendulumForce); - for (int i = 0; i < gDisplacedPendula; i++) + for (int i = 0; (btScalar)i < gDisplacedPendula; i++) { if (gDisplacedPendula >= 0 && gDisplacedPendula <= gPendulaQty) - pendula[i]->applyCentralForce(btVector3(pendulumForce, 0, 0)); + pendula[(size_t)i]->applyCentralForce(btVector3(pendulumForce, 0, 0)); } } } diff --git a/examples/ExtendedTutorials/MultipleBoxes.cpp b/examples/ExtendedTutorials/MultipleBoxes.cpp index cbb6901880..6f7ebab973 100644 --- a/examples/ExtendedTutorials/MultipleBoxes.cpp +++ b/examples/ExtendedTutorials/MultipleBoxes.cpp @@ -35,7 +35,7 @@ struct MultipleBoxesExample : public CommonRigidBodyBase float dist = 41; float pitch = -35; float yaw = 52; - float targetPos[3] = {0, 0.46, 0}; + float targetPos[3] = {0, 0.46f, 0}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } }; @@ -59,13 +59,13 @@ void MultipleBoxesExample::initPhysics() groundTransform.setIdentity(); groundTransform.setOrigin(btVector3(0, -50, 0)); { - btScalar mass(0.); + float mass(0.); createRigidBody(mass, groundTransform, groundShape, btVector4(0, 0, 1, 1)); } { //create a few dynamic rigidbodies - // Re-using the same collision is better for memory usage and performance + // Reusing the same collision is better for memory usage and performance btBoxShape* colShape = createBoxShape(btVector3(1, 1, 1)); m_collisionShapes.push_back(colShape); @@ -89,7 +89,7 @@ void MultipleBoxesExample::initPhysics() btScalar(0), btScalar(20 + i * 2), btScalar(0))); - createRigidBody(mass, startTransform, colShape); + createRigidBody((float)mass, startTransform, colShape); } } diff --git a/examples/ExtendedTutorials/NewtonsCradle.cpp b/examples/ExtendedTutorials/NewtonsCradle.cpp index ed1645e7d3..58dfdfa7af 100644 --- a/examples/ExtendedTutorials/NewtonsCradle.cpp +++ b/examples/ExtendedTutorials/NewtonsCradle.cpp @@ -64,7 +64,7 @@ struct NewtonsCradleExample : public CommonRigidBodyBase float dist = 41; float pitch = -35; float yaw = 52; - float targetPos[3] = {0, 0.46, 0}; + float targetPos[3] = {0, 0.46f, 0}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } @@ -123,7 +123,7 @@ void NewtonsCradleExample::initPhysics() { // create a slider to change the force to displace the lowest pendulum SliderParams slider("Displacement force", &gDisplacementForce); - slider.m_minVal = 0.1; + slider.m_minVal = 0.1f; slider.m_maxVal = 200; slider.m_clampToNotches = false; m_guiHelper->getParameterInterface()->registerSliderFloatParameter( @@ -155,11 +155,11 @@ void NewtonsCradleExample::initPhysics() btVector3 position(0.0f, 15.0f, 0.0f); // initial left-most pendulum position btQuaternion orientation(0, 0, 0, 1); // orientation of the pendula - // Re-using the same collision is better for memory usage and performance + // Reusing the same collision is better for memory usage and performance btSphereShape* pendulumShape = new btSphereShape(gSphereRadius); m_collisionShapes.push_back(pendulumShape); - for (int i = 0; i < std::floor(gPendulaQty); i++) + for (int i = 0; (btScalar)i < std::floor(gPendulaQty); i++) { // create pendulum createPendulum(pendulumShape, position, gInitialPendulumLength, pendulumMass); @@ -174,7 +174,7 @@ void NewtonsCradleExample::initPhysics() void NewtonsCradleExample::stepSimulation(float deltaTime) { - applyForceWithForceScalar(gForceScalar); // apply force defined by apply force slider + applyForceWithForceScalar((float)gForceScalar); // apply force defined by apply force slider if (m_dynamicsWorld) { @@ -196,7 +196,7 @@ void NewtonsCradleExample::createPendulum(btSphereShape* colShape, const btVecto // position the top sphere above ground with a moving x position startTransform.setOrigin(position); startTransform.setRotation(btQuaternion(0, 0, 0, 1)); // zero rotation - btRigidBody* topSphere = createRigidBody(mass, startTransform, colShape); + btRigidBody* topSphere = createRigidBody((float)mass, startTransform, colShape); // position the bottom sphere below the top sphere startTransform.setOrigin( @@ -204,7 +204,7 @@ void NewtonsCradleExample::createPendulum(btSphereShape* colShape, const btVecto position.z())); startTransform.setRotation(btQuaternion(0, 0, 0, 1)); // zero rotation - btRigidBody* bottomSphere = createRigidBody(mass, startTransform, colShape); + btRigidBody* bottomSphere = createRigidBody((float)mass, startTransform, colShape); bottomSphere->setFriction(0); // we do not need friction here pendula.push_back(bottomSphere); @@ -296,7 +296,7 @@ void NewtonsCradleExample::renderScene() CommonRigidBodyBase::renderScene(); } -bool NewtonsCradleExample::keyboardCallback(int key, int state) +bool NewtonsCradleExample::keyboardCallback(int key, int /*state*/) { //b3Printf("Key pressed: %d in state %d \n",key,state); @@ -334,6 +334,8 @@ bool NewtonsCradleExample::keyboardCallback(int key, int state) applyPendulumForce(gDisplacementForce); return true; } + default: + break; } return false; @@ -344,10 +346,10 @@ void NewtonsCradleExample::applyPendulumForce(btScalar pendulumForce) if (pendulumForce != 0) { b3Printf("Apply %f to pendulum", pendulumForce); - for (int i = 0; i < gDisplacedPendula; i++) + for (int i = 0; (btScalar)i < gDisplacedPendula; i++) { if (gDisplacedPendula >= 0 && gDisplacedPendula <= gPendulaQty) - pendula[i]->applyCentralForce(btVector3(pendulumForce, 0, 0)); + pendula[(size_t)i]->applyCentralForce(btVector3(pendulumForce, 0, 0)); } } } diff --git a/examples/ExtendedTutorials/NewtonsRopeCradle.cpp b/examples/ExtendedTutorials/NewtonsRopeCradle.cpp index 5c60c55905..f8dbe3b9f6 100644 --- a/examples/ExtendedTutorials/NewtonsRopeCradle.cpp +++ b/examples/ExtendedTutorials/NewtonsRopeCradle.cpp @@ -94,7 +94,7 @@ struct NewtonsRopeCradleExample : public CommonRigidBodyBase float dist = 41; float pitch = -35; float yaw = 52; - float targetPos[3] = {0, 0.46, 0}; + float targetPos[3] = {0, 0.46f, 0}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } @@ -169,7 +169,7 @@ void NewtonsRopeCradleExample::initPhysics() { // create a slider to change the force to displace the lowest pendulum SliderParams slider("Displacement force", &gDisplacementForce); - slider.m_minVal = 0.1; + slider.m_minVal = 0.1f; slider.m_maxVal = 200; slider.m_clampToNotches = false; m_guiHelper->getParameterInterface()->registerSliderFloatParameter( @@ -201,11 +201,11 @@ void NewtonsRopeCradleExample::initPhysics() btVector3 position(0.0f, 15.0f, 0.0f); // initial left-most pendulum position btQuaternion orientation(0, 0, 0, 1); // orientation of the pendula - // Re-using the same collision is better for memory usage and performance + // Reusing the same collision is better for memory usage and performance btSphereShape* pendulumShape = new btSphereShape(gSphereRadius); m_collisionShapes.push_back(pendulumShape); - for (int i = 0; i < std::floor(gPendulaQty); i++) + for (int i = 0; (btScalar)i < std::floor(gPendulaQty); i++) { // create pendulum createRopePendulum(pendulumShape, position, orientation, gInitialPendulumWidth, @@ -221,7 +221,7 @@ void NewtonsRopeCradleExample::initPhysics() void NewtonsRopeCradleExample::connectWithRope(btRigidBody* body1, btRigidBody* body2) { - btSoftBody* softBodyRope0 = btSoftBodyHelpers::CreateRope(softBodyWorldInfo, body1->getWorldTransform().getOrigin(), body2->getWorldTransform().getOrigin(), gRopeResolution, 0); + btSoftBody* softBodyRope0 = btSoftBodyHelpers::CreateRope(softBodyWorldInfo, body1->getWorldTransform().getOrigin(), body2->getWorldTransform().getOrigin(), (int)gRopeResolution, 0); softBodyRope0->setTotalMass(0.1f); softBodyRope0->appendAnchor(0, body1); @@ -238,7 +238,7 @@ void NewtonsRopeCradleExample::connectWithRope(btRigidBody* body1, btRigidBody* void NewtonsRopeCradleExample::stepSimulation(float deltaTime) { - applyRForceWithForceScalar(gForceScalar); // apply force defined by apply force slider + applyRForceWithForceScalar((float)gForceScalar); // apply force defined by apply force slider if (m_dynamicsWorld) { @@ -264,25 +264,25 @@ void NewtonsRopeCradleExample::createRopePendulum(btSphereShape* colShape, btVector3 bottomSphereRelPosition(0, -height, 0); // position the top sphere above ground with appropriate orientation - startTransform.setOrigin(btVector3(0, 0, 0)); // no translation intitially + startTransform.setOrigin(btVector3(0, 0, 0)); // no translation initially startTransform.setRotation(pendulumOrientation); // pendulum rotation startTransform.setOrigin(startTransform * topSphere1RelPosition); // rotate this position startTransform.setOrigin(position + startTransform.getOrigin()); // add non-rotated position to the relative position btRigidBody* topSphere1 = createRigidBody(0, startTransform, colShape); // make top sphere static // position the top sphere above ground with appropriate orientation - startTransform.setOrigin(btVector3(0, 0, 0)); // no translation intitially + startTransform.setOrigin(btVector3(0, 0, 0)); // no translation initially startTransform.setRotation(pendulumOrientation); // pendulum rotation startTransform.setOrigin(startTransform * topSphere2RelPosition); // rotate this position startTransform.setOrigin(position + startTransform.getOrigin()); // add non-rotated position to the relative position btRigidBody* topSphere2 = createRigidBody(0, startTransform, colShape); // make top sphere static // position the bottom sphere below the top sphere - startTransform.setOrigin(btVector3(0, 0, 0)); // no translation intitially + startTransform.setOrigin(btVector3(0, 0, 0)); // no translation initially startTransform.setRotation(pendulumOrientation); // pendulum rotation startTransform.setOrigin(startTransform * bottomSphereRelPosition); // rotate this position startTransform.setOrigin(position + startTransform.getOrigin()); // add non-rotated position to the relative position - btRigidBody* bottomSphere = createRigidBody(mass, startTransform, colShape); + btRigidBody* bottomSphere = createRigidBody((float)mass, startTransform, colShape); bottomSphere->setFriction(0); // we do not need friction here pendula.push_back(bottomSphere); @@ -325,7 +325,7 @@ void NewtonsRopeCradleExample::changePendulaRestitution(btScalar restitution) } } -bool NewtonsRopeCradleExample::keyboardCallback(int key, int state) +bool NewtonsRopeCradleExample::keyboardCallback(int key, int /*state*/) { //b3Printf("Key pressed: %d in state %d \n",key,state); @@ -337,6 +337,8 @@ bool NewtonsRopeCradleExample::keyboardCallback(int key, int state) applyPendulumForce(gDisplacementForce); return true; } + default: + break; } return false; @@ -347,10 +349,10 @@ void NewtonsRopeCradleExample::applyPendulumForce(btScalar pendulumForce) if (pendulumForce != 0) { b3Printf("Apply %f to pendulum", pendulumForce); - for (int i = 0; i < gDisplacedPendula; i++) + for (int i = 0; (btScalar)i < gDisplacedPendula; i++) { if (gDisplacedPendula >= 0 && gDisplacedPendula <= gPendulaQty) - pendula[i]->applyCentralForce(btVector3(pendulumForce, 0, 0)); + pendula[(size_t)i]->applyCentralForce(btVector3(pendulumForce, 0, 0)); } } } diff --git a/examples/ExtendedTutorials/RigidBodyFromObj.cpp b/examples/ExtendedTutorials/RigidBodyFromObj.cpp index 2adf96a38b..9a2c97edd9 100644 --- a/examples/ExtendedTutorials/RigidBodyFromObj.cpp +++ b/examples/ExtendedTutorials/RigidBodyFromObj.cpp @@ -43,7 +43,7 @@ struct RigidBodyFromObjExample : public CommonRigidBodyBase float dist = 11; float pitch = -35; float yaw = 52; - float targetPos[3] = {0, 0.46, 0}; + float targetPos[3] = {0, 0.46f, 0}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } }; @@ -67,7 +67,7 @@ void RigidBodyFromObjExample::initPhysics() groundTransform.setIdentity(); groundTransform.setOrigin(btVector3(0, -50, 0)); { - btScalar mass(0.); + float mass(0.); createRigidBody(mass, groundTransform, groundShape, btVector4(0, 0, 1, 1)); } @@ -82,12 +82,12 @@ void RigidBodyFromObjExample::initPhysics() b3BulletDefaultFileIO fileIO; GLInstanceGraphicsShape* glmesh = LoadMeshFromObj(relativeFileName, "",&fileIO); - printf("[INFO] Obj loaded: Extracted %d verticed from obj file [%s]\n", glmesh->m_numvertices, fileName); + printf("[INFO] Obj loaded: Extracted %d vertices from obj file [%s]\n", glmesh->m_numvertices, fileName); const GLInstanceVertex& v = glmesh->m_vertices->at(0); btConvexHullShape* shape = new btConvexHullShape((const btScalar*)(&(v.xyzw[0])), glmesh->m_numvertices, sizeof(GLInstanceVertex)); - float scaling[4] = {0.1, 0.1, 0.1, 1}; + float scaling[4] = {0.1f, 0.1f, 0.1f, 1}; btVector3 localScaling(scaling[0], scaling[1], scaling[2]); shape->setLocalScaling(localScaling); @@ -119,7 +119,7 @@ void RigidBodyFromObjExample::initPhysics() float pos[4] = {0, 3, 0, 0}; btVector3 position(pos[0], pos[1], pos[2]); startTransform.setOrigin(position); - btRigidBody* body = createRigidBody(mass, startTransform, shape); + btRigidBody* body = createRigidBody((float)mass, startTransform, shape); bool useConvexHullForRendering = ((m_options & ObjUseConvexHullForRendering) != 0); diff --git a/examples/ExtendedTutorials/RigidBodyFromObj.h b/examples/ExtendedTutorials/RigidBodyFromObj.h index cd133a3391..80675cecd3 100644 --- a/examples/ExtendedTutorials/RigidBodyFromObj.h +++ b/examples/ExtendedTutorials/RigidBodyFromObj.h @@ -20,7 +20,7 @@ enum ObjToRigidBodyOptionsEnum { ObjUseConvexHullForRendering = 1, OptimizeConvexObj = 2, - ComputePolyhedralFeatures = 4, + ComputePolyhedralFeatures = 4 }; class CommonExampleInterface* ET_RigidBodyFromObjCreateFunc(struct CommonExampleOptions& options); diff --git a/examples/ExtendedTutorials/SimpleBox.cpp b/examples/ExtendedTutorials/SimpleBox.cpp index e2e5bee463..f0ed4be86a 100644 --- a/examples/ExtendedTutorials/SimpleBox.cpp +++ b/examples/ExtendedTutorials/SimpleBox.cpp @@ -34,7 +34,7 @@ struct SimpleBoxExample : public CommonRigidBodyBase float dist = 41; float pitch = -35; float yaw = 52; - float targetPos[3] = {0, 0.46, 0}; + float targetPos[3] = {0, 0.46f, 0}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } }; @@ -58,13 +58,13 @@ void SimpleBoxExample::initPhysics() groundTransform.setIdentity(); groundTransform.setOrigin(btVector3(0, -50, 0)); { - btScalar mass(0.); + float mass(0.); createRigidBody(mass, groundTransform, groundShape, btVector4(0, 0, 1, 1)); } { //create a few dynamic rigidbodies - // Re-using the same collision is better for memory usage and performance + // Reusing the same collision is better for memory usage and performance btBoxShape* colShape = createBoxShape(btVector3(1, 1, 1)); m_collisionShapes.push_back(colShape); @@ -86,7 +86,7 @@ void SimpleBoxExample::initPhysics() btScalar(0), btScalar(20), btScalar(0))); - createRigidBody(mass, startTransform, colShape); + createRigidBody((float)mass, startTransform, colShape); } m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld); diff --git a/examples/ExtendedTutorials/SimpleCloth.cpp b/examples/ExtendedTutorials/SimpleCloth.cpp index f5064d10f7..42a146397d 100644 --- a/examples/ExtendedTutorials/SimpleCloth.cpp +++ b/examples/ExtendedTutorials/SimpleCloth.cpp @@ -61,7 +61,7 @@ struct SimpleClothExample : public CommonRigidBodyBase float dist = 41; float pitch = -35; float yaw = 52; - float targetPos[3] = {0, 0.46, 0}; + float targetPos[3] = {0, 0.46f, 0}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } @@ -88,7 +88,7 @@ void SimpleClothExample::initPhysics() groundTransform.setIdentity(); groundTransform.setOrigin(btVector3(0, -50, 0)); { - btScalar mass(0.); + float mass(0.); createRigidBody(mass, groundTransform, groundShape, btVector4(0, 0, 1, 1)); } diff --git a/examples/ExtendedTutorials/SimpleJoint.cpp b/examples/ExtendedTutorials/SimpleJoint.cpp index ee438cce39..e61a8a845a 100644 --- a/examples/ExtendedTutorials/SimpleJoint.cpp +++ b/examples/ExtendedTutorials/SimpleJoint.cpp @@ -34,7 +34,7 @@ struct SimpleJointExample : public CommonRigidBodyBase float dist = 41; float pitch = -35; float yaw = 52; - float targetPos[3] = {0, 0.46, 0}; + float targetPos[3] = {0, 0.46f, 0}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } }; @@ -58,13 +58,13 @@ void SimpleJointExample::initPhysics() groundTransform.setIdentity(); groundTransform.setOrigin(btVector3(0, -50, 0)); { - btScalar mass(0.); + float mass(0.); createRigidBody(mass, groundTransform, groundShape, btVector4(0, 0, 1, 1)); } { //create a few dynamic rigidbodies - // Re-using the same collision is better for memory usage and performance + // Reusing the same collision is better for memory usage and performance btBoxShape* colShape = createBoxShape(btVector3(1, 1, 1)); m_collisionShapes.push_back(colShape); @@ -86,7 +86,7 @@ void SimpleJointExample::initPhysics() btScalar(0), btScalar(10), btScalar(0))); - btRigidBody* dynamicBox = createRigidBody(mass, startTransform, colShape); + btRigidBody* dynamicBox = createRigidBody((float)mass, startTransform, colShape); //create a static rigid body mass = 0; @@ -95,12 +95,12 @@ void SimpleJointExample::initPhysics() btScalar(20), btScalar(0))); - btRigidBody* staticBox = createRigidBody(mass, startTransform, colShape); + btRigidBody* staticBox = createRigidBody((float)mass, startTransform, colShape); //create a simple p2pjoint constraint btPoint2PointConstraint* p2p = new btPoint2PointConstraint(*dynamicBox, *staticBox, btVector3(0, 3, 0), btVector3(0, 0, 0)); - p2p->m_setting.m_damping = 0.0625; - p2p->m_setting.m_impulseClamp = 0.95; + p2p->m_setting.m_damping = btScalar(0.0625); + p2p->m_setting.m_impulseClamp = btScalar(0.95); m_dynamicsWorld->addConstraint(p2p); } diff --git a/examples/ForkLift/ForkLiftDemo.cpp b/examples/ForkLift/ForkLiftDemo.cpp index 6bb03165b9..e1c424261a 100644 --- a/examples/ForkLift/ForkLiftDemo.cpp +++ b/examples/ForkLift/ForkLiftDemo.cpp @@ -117,21 +117,21 @@ class ForkLiftDemo : public CommonExampleInterface virtual void specialKeyboardUp(int key, int x, int y); - virtual bool mouseMoveCallback(float x, float y) + virtual bool mouseMoveCallback(float /*x*/, float /*y*/) { return false; } - virtual bool mouseButtonCallback(int button, int state, float x, float y) + virtual bool mouseButtonCallback(int /*button*/, int /*state*/, float /*x*/, float /*y*/) { return false; } - virtual bool keyboardCallback(int key, int state); + virtual bool keyboardCallback(int /*key*/, int /*state*/); virtual void renderScene(); - virtual void physicsDebugDraw(int debugFlags); + virtual void physicsDebugDraw(int /*debugFlags*/); void initPhysics(); void exitPhysics(); @@ -141,7 +141,7 @@ class ForkLiftDemo : public CommonExampleInterface float dist = 8; float pitch = -32; float yaw = -45; - float targetPos[3] = {-0.33, -0.72, 4.5}; + float targetPos[3] = {-0.33f, -0.72f, 4.5f}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } @@ -155,10 +155,10 @@ class ForkLiftDemo : public CommonExampleInterface */ }; -btScalar maxMotorImpulse = 4000.f; +static btScalar maxMotorImpulse = 4000.f; //the sequential impulse solver has difficulties dealing with large mass ratios (differences), between loadMass and the fork parts -btScalar loadMass = 350.f; // +static btScalar loadMass = 350.f; // //btScalar loadMass = 10.f;//this should work fine for the SI solver #ifndef M_PI @@ -173,13 +173,13 @@ btScalar loadMass = 350.f; // #define M_PI_4 0.785398163397448309616 #endif -int rightIndex = 0; -int upIndex = 1; -int forwardIndex = 2; -btVector3 wheelDirectionCS0(0, -1, 0); -btVector3 wheelAxleCS(-1, 0, 0); +static int rightIndex = 0; +static int upIndex = 1; +static int forwardIndex = 2; +static btVector3 wheelDirectionCS0(0, -1, 0); +static btVector3 wheelAxleCS(-1, 0, 0); -bool useMCLPSolver = true; +static bool useMCLPSolver = true; #include //printf debugging @@ -188,26 +188,26 @@ bool useMCLPSolver = true; ///btRaycastVehicle is the interface for the constraint that implements the raycast vehicle ///notice that for higher-quality slow-moving vehicles, another approach might be better ///implementing explicit hinged-wheel constraints with cylinder collision, rather then raycasts -float gEngineForce = 0.f; +static float gEngineForce = 0.f; -float defaultBreakingForce = 10.f; -float gBreakingForce = 100.f; +static float defaultBreakingForce = 10.f; +static float gBreakingForce = 100.f; -float maxEngineForce = 1000.f; //this should be engine/velocity dependent -float maxBreakingForce = 100.f; +static float maxEngineForce = 1000.f; //this should be engine/velocity dependent +static float maxBreakingForce = 100.f; -float gVehicleSteering = 0.f; -float steeringIncrement = 0.04f; -float steeringClamp = 0.3f; -float wheelRadius = 0.5f; -float wheelWidth = 0.4f; -float wheelFriction = 1000; //BT_LARGE_FLOAT; -float suspensionStiffness = 20.f; -float suspensionDamping = 2.3f; -float suspensionCompression = 4.4f; -float rollInfluence = 0.1f; //1.0f; +static float gVehicleSteering = 0.f; +static float steeringIncrement = 0.04f; +static float steeringClamp = 0.3f; +static float wheelRadius = 0.5f; +static float wheelWidth = 0.4f; +static float wheelFriction = 1000; //BT_LARGE_FLOAT; +static float suspensionStiffness = 20.f; +static float suspensionDamping = 2.3f; +static float suspensionCompression = 4.4f; +static float rollInfluence = 0.1f; //1.0f; -btScalar suspensionRestLength(0.6); +static btScalar suspensionRestLength = btScalar(0.6); #define CUBE_HALF_EXTENTS 1 @@ -342,7 +342,7 @@ void ForkLiftDemo::initPhysics() { m_dynamicsWorld->getSolverInfo().m_minimumSolverBatchSize = 128; //for direct solver, it is better to solve multiple objects together, small batches have high overhead } - m_dynamicsWorld->getSolverInfo().m_globalCfm = 0.00001; + m_dynamicsWorld->getSolverInfo().m_globalCfm = btScalar(0.00001); m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld); @@ -409,10 +409,10 @@ void ForkLiftDemo::initPhysics() btTransform localA, localB; localA.setIdentity(); localB.setIdentity(); - localA.getBasis().setEulerZYX(0, M_PI_2, 0); - localA.setOrigin(btVector3(0.0, 1.0, 3.05)); - localB.getBasis().setEulerZYX(0, M_PI_2, 0); - localB.setOrigin(btVector3(0.0, -1.5, -0.05)); + localA.getBasis().setEulerZYX(0, btScalar(M_PI_2), 0); + localA.setOrigin(btVector3(0.0, 1.0, btScalar(3.05))); + localB.getBasis().setEulerZYX(0, btScalar(M_PI_2), 0); + localB.setOrigin(btVector3(0.0, -1.5, btScalar(-0.05))); m_liftHinge = new btHingeConstraint(*m_carChassis, *m_liftBody, localA, localB); // m_liftHinge->setLimit(-LIFT_EPS, LIFT_EPS); m_liftHinge->setLimit(0.0f, 0.0f); @@ -446,10 +446,10 @@ void ForkLiftDemo::initPhysics() localA.setIdentity(); localB.setIdentity(); - localA.getBasis().setEulerZYX(0, 0, M_PI_2); + localA.getBasis().setEulerZYX(0, 0, btScalar(M_PI_2)); localA.setOrigin(btVector3(0.0f, -1.9f, 0.05f)); - localB.getBasis().setEulerZYX(0, 0, M_PI_2); - localB.setOrigin(btVector3(0.0, 0.0, -0.1)); + localB.getBasis().setEulerZYX(0, 0, btScalar(M_PI_2)); + localB.setOrigin(btVector3(0.0, 0.0, -0.1f)); m_forkSlider = new btSliderConstraint(*m_liftBody, *m_forkBody, localA, localB, true); m_forkSlider->setLowerLinLimit(0.1f); m_forkSlider->setUpperLinLimit(0.1f); @@ -499,26 +499,26 @@ void ForkLiftDemo::initPhysics() //choose coordinate system m_vehicle->setCoordinateSystem(rightIndex, upIndex, forwardIndex); - btVector3 connectionPointCS0(CUBE_HALF_EXTENTS - (0.3 * wheelWidth), connectionHeight, 2 * CUBE_HALF_EXTENTS - wheelRadius); + btVector3 connectionPointCS0(btScalar(CUBE_HALF_EXTENTS - (0.3 * wheelWidth)), btScalar(connectionHeight), btScalar(2 * CUBE_HALF_EXTENTS - wheelRadius)); - m_vehicle->addWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, m_tuning, isFrontWheel); - connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS + (0.3 * wheelWidth), connectionHeight, 2 * CUBE_HALF_EXTENTS - wheelRadius); + m_vehicle->addWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, btScalar(wheelRadius), m_tuning, isFrontWheel); + connectionPointCS0 = btVector3(btScalar(-CUBE_HALF_EXTENTS + (0.3 * wheelWidth)), btScalar(connectionHeight), btScalar(2 * CUBE_HALF_EXTENTS - wheelRadius)); - m_vehicle->addWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, m_tuning, isFrontWheel); - connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS + (0.3 * wheelWidth), connectionHeight, -2 * CUBE_HALF_EXTENTS + wheelRadius); + m_vehicle->addWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, btScalar(wheelRadius), m_tuning, isFrontWheel); + connectionPointCS0 = btVector3(btScalar(-CUBE_HALF_EXTENTS + (0.3 * wheelWidth)), btScalar(connectionHeight), btScalar(-2 * CUBE_HALF_EXTENTS + wheelRadius)); isFrontWheel = false; - m_vehicle->addWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, m_tuning, isFrontWheel); - connectionPointCS0 = btVector3(CUBE_HALF_EXTENTS - (0.3 * wheelWidth), connectionHeight, -2 * CUBE_HALF_EXTENTS + wheelRadius); - m_vehicle->addWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, m_tuning, isFrontWheel); + m_vehicle->addWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, btScalar(wheelRadius), m_tuning, isFrontWheel); + connectionPointCS0 = btVector3(btScalar(CUBE_HALF_EXTENTS - (0.3 * wheelWidth)), btScalar(connectionHeight), btScalar(-2 * CUBE_HALF_EXTENTS + wheelRadius)); + m_vehicle->addWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, btScalar(wheelRadius), m_tuning, isFrontWheel); for (int i = 0; i < m_vehicle->getNumWheels(); i++) { btWheelInfo& wheel = m_vehicle->getWheelInfo(i); - wheel.m_suspensionStiffness = suspensionStiffness; - wheel.m_wheelsDampingRelaxation = suspensionDamping; - wheel.m_wheelsDampingCompression = suspensionCompression; - wheel.m_frictionSlip = wheelFriction; - wheel.m_rollInfluence = rollInfluence; + wheel.m_suspensionStiffness = (btScalar)suspensionStiffness; + wheel.m_wheelsDampingRelaxation = (btScalar)suspensionDamping; + wheel.m_wheelsDampingCompression = (btScalar)suspensionCompression; + wheel.m_frictionSlip = (btScalar)wheelFriction; + wheel.m_rollInfluence = (btScalar)rollInfluence; } } @@ -665,6 +665,7 @@ void ForkLiftDemo::stepSimulation(float deltaTime) int numSimSteps; numSimSteps = m_dynamicsWorld->stepSimulation(dt, maxSimSubSteps); + (void)numSimSteps; if (m_dynamicsWorld->getConstraintSolver()->getSolverType() == BT_MLCP_SOLVER) { @@ -784,15 +785,15 @@ bool ForkLiftDemo::keyboardCallback(int key, int state) { case B3G_LEFT_ARROW: { - m_liftHinge->setLimit(-M_PI / 16.0f, M_PI / 8.0f); - m_liftHinge->enableAngularMotor(true, -0.1, maxMotorImpulse); + m_liftHinge->setLimit(btScalar(-M_PI / 16.0f), btScalar(M_PI / 8.0f)); + m_liftHinge->enableAngularMotor(true, -0.1f, maxMotorImpulse); handled = true; break; } case B3G_RIGHT_ARROW: { - m_liftHinge->setLimit(-M_PI / 16.0f, M_PI / 8.0f); - m_liftHinge->enableAngularMotor(true, 0.1, maxMotorImpulse); + m_liftHinge->setLimit(btScalar(-M_PI / 16.0f), btScalar(M_PI / 8.0f)); + m_liftHinge->enableAngularMotor(true, 0.1f, maxMotorImpulse); handled = true; break; } @@ -816,6 +817,8 @@ bool ForkLiftDemo::keyboardCallback(int key, int state) handled = true; break; } + default: + break; } } else @@ -860,7 +863,7 @@ bool ForkLiftDemo::keyboardCallback(int key, int state) handled = true; btDiscreteDynamicsWorld* world = (btDiscreteDynamicsWorld*)m_dynamicsWorld; world->setLatencyMotionStateInterpolation(!world->getLatencyMotionStateInterpolation()); - printf("world latencyMotionStateInterpolation = %d\n", world->getLatencyMotionStateInterpolation()); + printf("world latencyMotionStateInterpolation = %u\n", world->getLatencyMotionStateInterpolation()); break; } case B3G_F6: @@ -868,7 +871,7 @@ bool ForkLiftDemo::keyboardCallback(int key, int state) handled = true; //switch solver (needs demo restart) useMCLPSolver = !useMCLPSolver; - printf("switching to useMLCPSolver = %d\n", useMCLPSolver); + printf("switching to useMLCPSolver = %u\n", useMCLPSolver); delete m_constraintSolver; if (useMCLPSolver) @@ -934,14 +937,14 @@ bool ForkLiftDemo::keyboardCallback(int key, int state) return handled; } -void ForkLiftDemo::specialKeyboardUp(int key, int x, int y) +void ForkLiftDemo::specialKeyboardUp(int /*key*/, int /*x*/, int /*y*/) { #if 0 #endif } -void ForkLiftDemo::specialKeyboard(int key, int x, int y) +void ForkLiftDemo::specialKeyboard(int /*key*/, int /*x*/, int /*y*/) { #if 0 if (key==GLUT_KEY_END) @@ -1129,7 +1132,7 @@ btRigidBody* ForkLiftDemo::localCreateRigidBody(btScalar mass, const btTransform bool isDynamic = (mass != 0.f); btVector3 localInertia(0, 0, 0); - if (isDynamic) + if (isDynamic && shape) shape->calculateLocalInertia(mass, localInertia); //using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects diff --git a/examples/FractureDemo/FractureDemo.cpp b/examples/FractureDemo/FractureDemo.cpp index 24062e56bf..beb92a8b85 100644 --- a/examples/FractureDemo/FractureDemo.cpp +++ b/examples/FractureDemo/FractureDemo.cpp @@ -33,7 +33,7 @@ subject to the following restrictions: #include //printf debugging -int sFrameNumber = 0; +static int sFrameNumber = 0; #include "btFractureBody.h" #include "btFractureDynamicsWorld.h" @@ -83,7 +83,7 @@ class FractureDemo : public CommonRigidBodyBase float dist = 41; float pitch = -35; float yaw = 52; - float targetPos[3] = {0, 0.46, 0}; + float targetPos[3] = {0, 0.46f, 0}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } }; @@ -96,7 +96,7 @@ void FractureDemo::initPhysics() m_collisionConfiguration = new btDefaultCollisionConfiguration(); //m_collisionConfiguration->setConvexConvexMultipointIterations(); - ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) + ///use the default collision dispatcher. For parallel processing you can use a different dispatcher (see Extras/BulletMultiThreaded) m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); @@ -137,7 +137,7 @@ void FractureDemo::initPhysics() { //create a few dynamic rigidbodies - // Re-using the same collision is better for memory usage and performance + // Reusing the same collision is better for memory usage and performance btCollisionShape* colShape = new btBoxShape(btVector3(SCALING * 1, SCALING * 1, SCALING * 1)); //btCollisionShape* colShape = new btCapsuleShape(SCALING*0.4,SCALING*1); @@ -164,7 +164,7 @@ void FractureDemo::initPhysics() btTransform trans; trans.setIdentity(); - btVector3 pos(i * 2 * CUBE_HALF_EXTENTS, 20, 0); + btVector3 pos((float)i * 2 * CUBE_HALF_EXTENTS, 20, 0); trans.setOrigin(pos); //using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects @@ -177,7 +177,7 @@ void FractureDemo::initPhysics() } } - fractureWorld->stepSimulation(1. / 60., 0); + fractureWorld->stepSimulation(btScalar(1. / 60.), 0); fractureWorld->glueCallback(); m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld); diff --git a/examples/FractureDemo/btFractureBody.cpp b/examples/FractureDemo/btFractureBody.cpp index 351a9bc511..6f5ec4e1c3 100644 --- a/examples/FractureDemo/btFractureBody.cpp +++ b/examples/FractureDemo/btFractureBody.cpp @@ -20,10 +20,10 @@ void btFractureBody::recomputeConnectivity(btCollisionWorld* world) { bool m_connected; btScalar m_margin; - MyContactResultCallback() : m_connected(false), m_margin(0.05) + MyContactResultCallback() : m_connected(false), m_margin(btScalar(0.05)) { } - virtual btScalar addSingleResult(btManifoldPoint& cp, const btCollisionObjectWrapper* colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper* colObj1Wrap, int partId1, int index1) + virtual btScalar addSingleResult(btManifoldPoint& cp, const btCollisionObjectWrapper* /*colObj0Wrap*/, int /*partId0*/, int /*index0*/, const btCollisionObjectWrapper* /*colObj1Wrap*/, int /*partId1*/, int /*index1*/) { if (cp.getDistance() <= m_margin) m_connected = true; @@ -59,11 +59,11 @@ btCompoundShape* btFractureBody::shiftTransformDistributeMass(btCompoundShape* b { btVector3 principalInertia; - btScalar* masses = new btScalar[boxCompound->getNumChildShapes()]; + btScalar* masses = new btScalar[(size_t)boxCompound->getNumChildShapes()]; for (int j = 0; j < boxCompound->getNumChildShapes(); j++) { //evenly distribute mass - masses[j] = mass / boxCompound->getNumChildShapes(); + masses[j] = mass / (btScalar)boxCompound->getNumChildShapes(); } return shiftTransform(boxCompound, masses, shift, principalInertia); diff --git a/examples/FractureDemo/btFractureDynamicsWorld.cpp b/examples/FractureDemo/btFractureDynamicsWorld.cpp index 91cecb5d05..5aa367409b 100644 --- a/examples/FractureDemo/btFractureDynamicsWorld.cpp +++ b/examples/FractureDemo/btFractureDynamicsWorld.cpp @@ -46,6 +46,7 @@ void btFractureDynamicsWorld::glueCallback() unionFind.reset(index); int numElem = unionFind.getNumElements(); + (void)numElem; for (int i = 0; i < numManifolds; i++) { @@ -123,7 +124,7 @@ void btFractureDynamicsWorld::glueCallback() fractureObjectIndex = i; } btRigidBody* otherObject = btRigidBody::upcast(colObj0); - if (!otherObject || !otherObject->getInvMass()) + if (!otherObject || otherObject->getInvMass() == btScalar(0)) continue; numObjects++; } @@ -182,7 +183,7 @@ void btFractureDynamicsWorld::glueCallback() btRigidBody* otherObject = btRigidBody::upcast(otherCollider); //don't glue/merge with static objects right now, otherwise everything gets stuck to the ground ///todo: expose this as a callback - if (!otherObject || !otherObject->getInvMass()) + if (!otherObject || otherObject->getInvMass() == btScalar(0)) continue; oldImpulses.push_back(otherObject->getLinearVelocity() * (1.f / otherObject->getInvMass())); @@ -247,7 +248,7 @@ void btFractureDynamicsWorld::glueCallback() removedObjects.pop_back(); btRigidBody* otherObject = btRigidBody::upcast(otherCollider); - if (!otherObject || !otherObject->getInvMass()) + if (!otherObject || otherObject->getInvMass() == btScalar(0)) continue; removeRigidBody(otherObject); } @@ -266,7 +267,7 @@ void btFractureDynamicsWorld::solveConstraints(btContactSolverInfo& solverInfo) // save all velocities and if one or more objects fracture: // 1) revert all velocties // 2) apply impulses for the fracture bodies at the contact locations - // 3)and run the constaint solver again + // 3)and run the constraint solver again btDiscreteDynamicsWorld::solveConstraints(solverInfo); @@ -356,6 +357,7 @@ void btFractureDynamicsWorld::breakDisconnectedParts(btFractureBody* fracObj) unionFind.reset(index); int numElem = unionFind.getNumElements(); + (void)numElem; for (i = 0; i < fracObj->m_connections.size(); i++) { btConnection& connection = fracObj->m_connections[i]; @@ -387,6 +389,7 @@ void btFractureDynamicsWorld::breakDisconnectedParts(btFractureBody* fracObj) btAlignedObjectArray removedObjects; int numIslands = 0; + (void)numIslands; for (startIslandIndex = 0; startIslandIndex < numElem; startIslandIndex = endIslandIndex) { @@ -405,10 +408,10 @@ void btFractureDynamicsWorld::breakDisconnectedParts(btFractureBody* fracObj) int idx; for (idx = startIslandIndex; idx < endIslandIndex; idx++) { - int i = unionFind.getElement(idx).m_sz; + int ii = unionFind.getElement(idx).m_sz; // btCollisionShape* shape = compound->getChildShape(i); - newCompound->addChildShape(compound->getChildTransform(i), compound->getChildShape(i)); - masses.push_back(fracObj->m_masses[i]); + newCompound->addChildShape(compound->getChildTransform(ii), compound->getChildShape(ii)); + masses.push_back(fracObj->m_masses[ii]); numShapes++; } if (numShapes) @@ -456,7 +459,7 @@ void btFractureDynamicsWorld::fractureCallback() static float maxImpact = 0; if (totalImpact > maxImpact) - maxImpact = totalImpact; + maxImpact = (float)totalImpact; //some threshold otherwise resting contact would break objects after a while if (totalImpact < 40.f) @@ -480,7 +483,7 @@ void btFractureDynamicsWorld::fractureCallback() int f0 = m_fractureBodies.findLinearSearch((btFractureBody*)manifold->getBody0()); int f1 = m_fractureBodies.findLinearSearch((btFractureBody*)manifold->getBody1()); - if (f0 == f1 == m_fractureBodies.size()) + if ((f0 == f1) && (f1 == m_fractureBodies.size())) continue; if (f0 < m_fractureBodies.size()) diff --git a/examples/FractureDemo/btFractureDynamicsWorld.h b/examples/FractureDemo/btFractureDynamicsWorld.h index 857f8ca04d..db246e10fa 100644 --- a/examples/FractureDemo/btFractureDynamicsWorld.h +++ b/examples/FractureDemo/btFractureDynamicsWorld.h @@ -9,7 +9,7 @@ class btCompoundShape; class btTransform; ///The btFractureDynamicsWorld class enabled basic glue and fracture of objects. -///If/once this implementation is stablized/tested we might merge it into btDiscreteDynamicsWorld and remove the class. +///If/once this implementation is stabilized/tested we might merge it into btDiscreteDynamicsWorld and remove the class. class btFractureDynamicsWorld : public btDiscreteDynamicsWorld { btAlignedObjectArray m_fractureBodies; diff --git a/examples/GyroscopicDemo/GyroscopicSetup.cpp b/examples/GyroscopicDemo/GyroscopicSetup.cpp index 1324fb74ff..d43ac19e13 100644 --- a/examples/GyroscopicDemo/GyroscopicSetup.cpp +++ b/examples/GyroscopicDemo/GyroscopicSetup.cpp @@ -18,7 +18,7 @@ struct GyroscopicSetup : public CommonRigidBodyBase float dist = 20; float pitch = -16; float yaw = 180; - float targetPos[3] = {-2.4, 0.4, -0.24}; + float targetPos[3] = {-2.4f, 0.4f, -0.24f}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } }; @@ -56,15 +56,15 @@ void GyroscopicSetup::initPhysics() for (int i = 0; i < 4; i++) { - btCylinderShapeZ* pin = new btCylinderShapeZ(btVector3(0.1, 0.1, 0.2)); - btBoxShape* box = new btBoxShape(btVector3(1, 0.1, 0.1)); - box->setMargin(0.01); - pin->setMargin(0.01); + btCylinderShapeZ* pin = new btCylinderShapeZ(btVector3(btScalar(0.1), btScalar(0.1), btScalar(0.2))); + btBoxShape* box = new btBoxShape(btVector3(1, btScalar(0.1), btScalar(0.1))); + box->setMargin(btScalar(0.01)); + pin->setMargin(btScalar(0.01)); btCompoundShape* compound = new btCompoundShape(); compound->addChildShape(btTransform::getIdentity(), pin); - btTransform offsetBox(btMatrix3x3::getIdentity(), btVector3(0, 0, 0.2)); + btTransform offsetBox(btMatrix3x3::getIdentity(), btVector3(0, 0, btScalar(0.2))); compound->addChildShape(offsetBox, box); - btScalar masses[2] = {0.3, 0.1}; + btScalar masses[2] = {btScalar(0.3), btScalar(0.1)}; btVector3 localInertia; btTransform principal; compound->calculatePrincipalAxisTransform(masses, principal, localInertia); @@ -74,7 +74,7 @@ void GyroscopicSetup::initPhysics() tr.setIdentity(); tr.setOrigin(positions[i]); body->setCenterOfMassTransform(tr); - body->setAngularVelocity(btVector3(0, 0.1, 10)); //51)); + body->setAngularVelocity(btVector3(0, btScalar(0.1), 10)); //51)); //body->setLinearVelocity(btVector3(3, 0, 0)); body->setFriction(btSqrt(1)); m_dynamicsWorld->addRigidBody(body); @@ -111,7 +111,7 @@ void GyroscopicSetup::physicsDebugDraw(int debugFlags) btTransform tr = body->getWorldTransform(); btVector3 pos = tr.getOrigin() + btVector3(0, 0, 2); btScalar size = 1; - m_guiHelper->drawText3D(gyroNames[i], pos.x(), pos.y(), pos.z(), size); + m_guiHelper->drawText3D(gyroNames[i], (float)pos.x(), (float)pos.y(), (float)pos.z(), (float)size); } } } diff --git a/examples/Heightfield/HeightfieldExample.cpp b/examples/Heightfield/HeightfieldExample.cpp index d9b99fd9d2..3b6b9011af 100644 --- a/examples/Heightfield/HeightfieldExample.cpp +++ b/examples/Heightfield/HeightfieldExample.cpp @@ -27,25 +27,25 @@ subject to the following restrictions: #include "stb_image/stb_image.h" // constants ------------------------------------------------------------------- -static const btScalar s_gravity = 9.8; // 9.8 m/s^2 +static const btScalar s_gravity = btScalar(9.8); // 9.8 m/s^2 static int s_gridSize = 16 + 1; // must be (2^N) + 1 -static btScalar s_gridSpacing = 0.5; -static btScalar s_gridHeightScale = 0.02; +static btScalar s_gridSpacing = btScalar(0.5); +static btScalar s_gridHeightScale = btScalar(0.02); // the singularity at the center of the radial model means we need a lot of // finely-spaced time steps to get the physics right. // These numbers are probably too aggressive for a real game! // delta phase: radians per second -static const btScalar s_deltaPhase = 0.25 * 2.0 * SIMD_PI; +static const btScalar s_deltaPhase = btScalar(0.25 * 2.0 * SIMD_PI); // what type of terrain is generated? enum eTerrainModel { eRadial = 0, // deterministic eFractal = 1, // random - eCSVFile = 2,//csv file used in DeepLoco for example - eImageFile = 3,//terrain from png/jpg files, asset from https://www.beamng.com/threads/tutorial-adding-heightmap-roads-using-blender.16356/ + eCSVFile = 2, //csv file used in DeepLoco for example + eImageFile = 3 //terrain from png/jpg files, asset from https://www.beamng.com/threads/tutorial-adding-heightmap-roads-using-blender.16356/ }; @@ -255,43 +255,44 @@ setRadial btAssert(bytesPerElement > 0); // min/max - btScalar period = 0.5 / s_gridSpacing; + btScalar period = btScalar(0.5) / s_gridSpacing; btScalar floor = 0.0; - btScalar min_r = 3.0 * btSqrt(s_gridSpacing); - btScalar magnitude = 5.0 * btSqrt(s_gridSpacing); + btScalar min_r = btScalar(3.0) * btSqrt(s_gridSpacing); + btScalar magnitude = btScalar(5.0) * btSqrt(s_gridSpacing); // pick a base_phase such that phase = 0 results in max height // (this way, if you create a heightfield with phase = 0, // you can rely on the min/max heights that result) - btScalar base_phase = (0.5 * SIMD_PI) - (period * min_r); + btScalar base_phase = (btScalar(0.5) * SIMD_PI) - (period * min_r); phase += base_phase; // center of grid - btScalar cx = 0.5 * s_gridSize * s_gridSpacing; + btScalar cx = btScalar(0.5) * (btScalar)s_gridSize * s_gridSpacing; btScalar cy = cx; // assume square grid byte_t * p = grid; for (int i = 0; i < s_gridSize; ++i) { - float x = i * s_gridSpacing; + float x = float((btScalar)i * s_gridSpacing); for (int j = 0; j < s_gridSize; ++j) { - float y = j * s_gridSpacing; + float y = float((btScalar)j * s_gridSpacing); - float dx = x - cx; - float dy = y - cy; + float dx = x - (float)cx; + float dy = y - (float)cy; - float r = sqrt((dx * dx) + (dy * dy)); + float r = (float)sqrt((dx * dx) + (dy * dy)); - float z = period; + float z = (float)period; + (void)z; if (r < min_r) { - r = min_r; + r = (float)min_r; } - z = (1.0 / r) * sin(period * r + phase); + z = (1.0f / r) * (float)sin(period * r + phase); if (z > period) { - z = period; + z = (float)period; } else if (z < -period) { - z = -period; + z = (float)-period; } - z = floor + magnitude * z; + z = (float)floor + (float)magnitude * z; convertFromFloat(p, z, type); p += bytesPerElement; @@ -307,7 +308,7 @@ randomHeight int step ) { - return (0.33 * s_gridSpacing * s_gridSize * step * (rand() - (0.5 * RAND_MAX))) / (1.0 * RAND_MAX * s_gridSize); + return float((0.33 * s_gridSpacing * s_gridSize * step * (rand() - (0.5 * RAND_MAX))) / (1.0 * RAND_MAX * s_gridSize)); } @@ -347,7 +348,7 @@ updateHeight ) { btScalar old_val = convertToFloat(p, type); - if (!old_val) { + if (old_val == btScalar(0)) { convertFromFloat(p, new_val, type); } } @@ -391,19 +392,19 @@ setFractal btScalar c11 = convertToFloat(grid + (step * s_gridSize + step) * bytesPerElement, type); // set top middle - updateHeight(grid + newStep * bytesPerElement, 0.5 * (c00 + c01) + randomHeight(step), type); + updateHeight(grid + newStep * bytesPerElement, btScalar(0.5) * (c00 + c01) + (btScalar)randomHeight(step), type); // set left middle - updateHeight(grid + (newStep * s_gridSize) * bytesPerElement, 0.5 * (c00 + c10) + randomHeight(step), type); + updateHeight(grid + (newStep * s_gridSize) * bytesPerElement, btScalar(0.5) * (c00 + c10) + (btScalar)randomHeight(step), type); // set right middle - updateHeight(grid + (newStep * s_gridSize + step) * bytesPerElement, 0.5 * (c01 + c11) + randomHeight(step), type); + updateHeight(grid + (newStep * s_gridSize + step) * bytesPerElement, btScalar(0.5) * (c01 + c11) + (btScalar)randomHeight(step), type); // set bottom middle - updateHeight(grid + (step * s_gridSize + newStep) * bytesPerElement, 0.5 * (c10 + c11) + randomHeight(step), type); + updateHeight(grid + (step * s_gridSize + newStep) * bytesPerElement, btScalar(0.5) * (c10 + c11) + (btScalar)randomHeight(step), type); // set middle - updateHeight(grid + (newStep * s_gridSize + newStep) * bytesPerElement, 0.25 * (c00 + c01 + c10 + c11) + randomHeight(step), type); + updateHeight(grid + (newStep * s_gridSize + newStep) * bytesPerElement, btScalar(0.25) * (c00 + c01 + c10 + c11) + (btScalar)randomHeight(step), type); // std::cerr << "Computing grid with step = " << step << ": after\n"; // dumpGrid(grid, bytesPerElement, type, step + 1); @@ -439,6 +440,7 @@ getRawHeightfieldData b3BulletDefaultFileIO fileIO; char relativeFileName[1024]; int found = fileIO.findFile("heightmaps/wm_height_out.png", relativeFileName, 1024); + (void)found; b3AlignedObjectArray buffer; @@ -469,8 +471,8 @@ getRawHeightfieldData { printf("width=%d, height=%d at %d channels\n", width,height, n); s_gridSize = width; - s_gridSpacing = 0.2; - s_gridHeightScale = 0.2; + s_gridSpacing = btScalar(0.2); + s_gridHeightScale = btScalar(0.2); fileIO.fileClose(fileId); long nElements = ((long)s_gridSize) * s_gridSize; // std::cerr << " nElements = " << nElements << "\n"; @@ -481,7 +483,7 @@ getRawHeightfieldData long nBytes = nElements * bytesPerElement; // std::cerr << " nBytes = " << nBytes << "\n"; - byte_t * raw = new byte_t[nBytes]; + byte_t * raw = new byte_t[(size_t)nBytes]; btAssert(raw && "out of memory"); byte_t * p = raw; @@ -491,10 +493,10 @@ getRawHeightfieldData for (int i = 0; i < width; ++i) { - float x = i * s_gridSpacing; - float y = j * s_gridSpacing; + // float x = i * s_gridSpacing; + // float y = j * s_gridSpacing; float heightScaling = (14. / 256.); - float z = double(image[(width - 1 - i) * 3 + width*j * 3]) * heightScaling; + float z = float(image[(width - 1 - i) * 3 + width*j * 3]) * heightScaling; convertFromFloat(p, z, type); // update min/max if (!i && !j) { @@ -539,16 +541,16 @@ getRawHeightfieldData btAlignedObjectArray allValues; if (slot>=0) { - char* lineChar; - while (lineChar = fileIO.readLine(slot, lineBuffer, MYLINELENGTH)) + char* lineChar = fileIO.readLine(slot, lineBuffer, MYLINELENGTH); + while (lineChar) { rows=0; char** values = urdfStrSplit(lineChar, ","); if (values) { int index = 0; - char* value; - while (value = values[index++]) + char* value = values[index++]; + while (value) { std::string strval(value); double v; @@ -559,16 +561,17 @@ getRawHeightfieldData allValues.push_back(v); rows++; } + value = values[index++]; } } cols++; - + lineChar = fileIO.readLine(slot, lineBuffer, MYLINELENGTH); } printf("done, rows=%d, cols=%d\n", rows, cols); int width = rows-1; s_gridSize = rows; - s_gridSpacing = 0.2; - s_gridHeightScale = 0.2; + s_gridSpacing = btScalar(0.2); + s_gridHeightScale = btScalar(0.2); fileIO.fileClose(slot); long nElements = ((long)s_gridSize) * s_gridSize; // std::cerr << " nElements = " << nElements << "\n"; @@ -579,17 +582,17 @@ getRawHeightfieldData long nBytes = nElements * bytesPerElement; // std::cerr << " nBytes = " << nBytes << "\n"; - byte_t * raw = new byte_t[nBytes]; + byte_t * raw = new byte_t[(size_t)nBytes]; btAssert(raw && "out of memory"); byte_t * p = raw; for (int i = 0; i < width; ++i) { - float x = i * s_gridSpacing; + // float x = i * s_gridSpacing; for (int j = 0; j < width; ++j) { - float y = j * s_gridSpacing; - float z = allValues[i+width*j]; + // float y = j * s_gridSpacing; + float z = (float)allValues[i+width*j]; convertFromFloat(p, z, type); // update min/max if (!i && !j) { @@ -617,12 +620,12 @@ getRawHeightfieldData { s_gridSize = 16 + 1; // must be (2^N) + 1 s_gridSpacing = 0.5; - s_gridHeightScale = 0.02; + s_gridHeightScale = btScalar(0.02); } else { s_gridSize = 256 + 1; // must be (2^N) + 1 s_gridSpacing = 0.5; - s_gridHeightScale = 0.02; + s_gridHeightScale = btScalar(0.02); } // std::cerr << "\nRegenerating terrain\n"; // std::cerr << " model = " << model << "\n"; @@ -637,7 +640,7 @@ getRawHeightfieldData long nBytes = nElements * bytesPerElement; // std::cerr << " nBytes = " << nBytes << "\n"; - byte_t * raw = new byte_t[nBytes]; + byte_t * raw = new byte_t[(size_t)nBytes]; btAssert(raw && "out of memory"); // reseed randomization every 30 seconds @@ -752,9 +755,9 @@ class HeightfieldExample : public CommonRigidBodyMTBase//CommonRigidBodyBase #define HEIGHTFIELD_TYPE_COUNT 4 -eTerrainModel gHeightfieldType = eRadial; +static eTerrainModel gHeightfieldType = eRadial; -void setHeightfieldTypeComboBoxCallback(int combobox, const char* item, void* userPointer) +static void setHeightfieldTypeComboBoxCallback(int /*combobox*/, const char* item, void* userPointer) { const char** items = static_cast(userPointer); for (int i = 0; i < HEIGHTFIELD_TYPE_COUNT; ++i) @@ -819,7 +822,7 @@ class MyTriangleCollector3 : public btTriangleCallback m_pIndicesOut = 0; } - virtual void processTriangle(btVector3* tris, int partId, int triangleIndex) + virtual void processTriangle(btVector3* tris, int /*partId*/, int /*triangleIndex*/) { for (int k = 0; k < 3; k++) { @@ -830,8 +833,8 @@ class MyTriangleCollector3 : public btTriangleCallback normal.safeNormalize(); for (int l = 0; l < 3; l++) { - v.xyzw[l] = tris[k][l]; - v.normal[l] = normal[l]; + v.xyzw[l] = (float)tris[k][l]; + v.normal[l] = (float)normal[l]; } m_pIndicesOut->push_back(m_pVerticesOut->size()); m_pVerticesOut->push_back(v); @@ -880,7 +883,7 @@ class btRaycastBar3 sum_ms = 0; } - btRaycastBar3(btScalar ray_length, btScalar z, btScalar max_y, struct GUIHelperInterface* guiHelper, int upAxisIndex) + btRaycastBar3(btScalar ray_length, btScalar z, btScalar max_y_, struct GUIHelperInterface* guiHelper, int upAxisIndex) { m_guiHelper = guiHelper; @@ -893,12 +896,12 @@ class btRaycastBar3 dx = 10.0; min_x = 0; max_x = 0; - this->max_y = max_y; + this->max_y = max_y_; sign = 1.0; btScalar dalpha = 2 * SIMD_2_PI / NUMRAYS2; for (int i = 0; i < NUMRAYS2; i++) { - btScalar alpha = dalpha * i; + btScalar alpha = dalpha * (btScalar)i; // rotate around by alpha degrees y btVector3 upAxis(0, 0, 0); upAxis[upAxisIndex] = 1; @@ -910,11 +913,11 @@ class btRaycastBar3 if (upAxisIndex == 1) { - source[i] = btVector3(min_x, max_y, z); + source[i] = btVector3(min_x, max_y_, z); } else { - source[i] = btVector3(min_x, z, max_y); + source[i] = btVector3(min_x, z, max_y_); } dest[i] = source[i] + direction[i]; dest[i][upAxisIndex] = -1000; @@ -1019,7 +1022,7 @@ class btRaycastBar3 castRays(cw, 0, NUMRAYS2); } #ifdef USE_BT_CLOCK - ms += frame_timer.getTimeMilliseconds(); + ms += (int)frame_timer.getTimeMilliseconds(); #endif //USE_BT_CLOCK frame_counter++; if (frame_counter > 50) @@ -1043,21 +1046,21 @@ class btRaycastBar3 btAlignedObjectArray indices; btAlignedObjectArray points; - float lineColor[4] = { 1, 0.4, .4, 1 }; + float lineColor[4] = { 1, 0.4f, 0.4f, 1 }; for (int i = 0; i < NUMRAYS2; i++) { btVector3FloatData s, h; for (int w = 0; w < 4; w++) { - s.m_floats[w] = source[i][w]; - h.m_floats[w] = hit[i][w]; + s.m_floats[w] = (float)source[i][w]; + h.m_floats[w] = (float)hit[i][w]; } points.push_back(s); points.push_back(h); - indices.push_back(indices.size()); - indices.push_back(indices.size()); + indices.push_back((unsigned int)indices.size()); + indices.push_back((unsigned int)indices.size()); } m_guiHelper->getRenderInterface()->drawLines(&points[0].m_floats[0], lineColor, points.size(), sizeof(btVector3FloatData), &indices[0], indices.size(), 1); @@ -1088,11 +1091,11 @@ void HeightfieldExample::stepSimulation(float deltaTime) { btAlignedObjectArray gfxVertices; btAlignedObjectArray indices; - int strideInBytes = 9 * sizeof(float); + // int strideInBytes = 9 * sizeof(float); - m_phase += s_deltaPhase * deltaTime; - if (m_phase > 2.0 * SIMD_PI) { - m_phase -= 2.0 * SIMD_PI; + m_phase += (float)s_deltaPhase * deltaTime; + if (m_phase > (btScalar)2.0 * SIMD_PI) { + m_phase -= (float)((btScalar)2.0 * SIMD_PI); } int bpe = getByteSize(m_type); btAssert(bpe > 0 && "Bad bytes per element"); @@ -1197,6 +1200,7 @@ void HeightfieldExample::resetPhysics(void) b3BulletDefaultFileIO fileIO; char relativeFileName[1024]; int found = fileIO.findFile("heightmaps/gimp_overlay_out.png", relativeFileName, 1024); + (void)found; b3AlignedObjectArray buffer; buffer.reserve(1024); diff --git a/examples/Heightfield/HeightfieldExample.h b/examples/Heightfield/HeightfieldExample.h index 258e7f7017..461f2503a9 100644 --- a/examples/Heightfield/HeightfieldExample.h +++ b/examples/Heightfield/HeightfieldExample.h @@ -18,4 +18,4 @@ subject to the following restrictions: class CommonExampleInterface* HeightfieldExampleCreateFunc(struct CommonExampleOptions& options); -#endif //HEIGHTFIELD_EXAMPLE_H \ No newline at end of file +#endif //HEIGHTFIELD_EXAMPLE_H diff --git a/examples/HelloWorld/HelloWorld.cpp b/examples/HelloWorld/HelloWorld.cpp index 8b5fcee4c4..f7bc8c2971 100644 --- a/examples/HelloWorld/HelloWorld.cpp +++ b/examples/HelloWorld/HelloWorld.cpp @@ -19,7 +19,7 @@ subject to the following restrictions: /// This is a Hello World program for running a basic Bullet physics simulation -int main(int argc, char** argv) +int main(int /*argc*/, char** /*argv*/) { ///-----includes_end----- @@ -29,7 +29,7 @@ int main(int argc, char** argv) ///collision configuration contains default setup for memory, collision setup. Advanced users can create their own configuration. btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration(); - ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) + ///use the default collision dispatcher. For parallel processing you can use a different dispatcher (see Extras/BulletMultiThreaded) btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration); ///btDbvtBroadphase is a good general purpose broadphase. You can also try out btAxis3Sweep. @@ -45,7 +45,7 @@ int main(int argc, char** argv) ///-----initialization_end----- //keep track of the shapes, we release memory at exit. - //make sure to re-use collision shapes among rigid bodies whenever possible! + //make sure to reuse collision shapes among rigid bodies whenever possible! btAlignedObjectArray collisionShapes; ///create a few basic rigid bodies @@ -64,7 +64,7 @@ int main(int argc, char** argv) btScalar mass(0.); //rigidbody is dynamic if and only if mass is non zero, otherwise static - bool isDynamic = (mass != 0.f); + bool isDynamic = (mass != btScalar(0.f)); btVector3 localInertia(0, 0, 0); if (isDynamic) @@ -90,10 +90,10 @@ int main(int argc, char** argv) btTransform startTransform; startTransform.setIdentity(); - btScalar mass(1.f); + btScalar mass(btScalar(1.f)); //rigidbody is dynamic if and only if mass is non zero, otherwise static - bool isDynamic = (mass != 0.f); + bool isDynamic = (mass != btScalar(0.f)); btVector3 localInertia(0, 0, 0); if (isDynamic) @@ -114,7 +114,7 @@ int main(int argc, char** argv) ///-----stepsimulation_start----- for (i = 0; i < 150; i++) { - dynamicsWorld->stepSimulation(1.f / 60.f, 10); + dynamicsWorld->stepSimulation(btScalar(1.f) / btScalar(60.f), 10); //print positions of all objects for (int j = dynamicsWorld->getNumCollisionObjects() - 1; j >= 0; j--) @@ -130,7 +130,7 @@ int main(int argc, char** argv) { trans = obj->getWorldTransform(); } - printf("world pos object %d = %f,%f,%f\n", j, float(trans.getOrigin().getX()), float(trans.getOrigin().getY()), float(trans.getOrigin().getZ())); + printf("world pos object %d = %f,%f,%f\n", j, double(trans.getOrigin().getX()), double(trans.getOrigin().getY()), double(trans.getOrigin().getZ())); } } diff --git a/examples/Importers/ImportBsp/BspConverter.h b/examples/Importers/ImportBsp/BspConverter.h index 110790bcc2..247dd957bb 100644 --- a/examples/Importers/ImportBsp/BspConverter.h +++ b/examples/Importers/ImportBsp/BspConverter.h @@ -29,7 +29,7 @@ class BspConverter { } - ///this callback is called for each brush that succesfully converted into vertices + ///this callback is called for each brush that successfully converted into vertices virtual void addConvexVerticesCollider(btAlignedObjectArray& vertices, bool isEntity, const btVector3& entityTargetLocation) = 0; }; diff --git a/examples/Importers/ImportBsp/BspLoader.cpp b/examples/Importers/ImportBsp/BspLoader.cpp index 140294e1a2..909c23dcbb 100644 --- a/examples/Importers/ImportBsp/BspLoader.cpp +++ b/examples/Importers/ImportBsp/BspLoader.cpp @@ -32,19 +32,19 @@ typedef struct } BSPScript; #define MAX_INCLUDES 8 -BSPScript scriptstack[MAX_INCLUDES]; -BSPScript *script; -int scriptline; +static BSPScript scriptstack[MAX_INCLUDES]; +static BSPScript *script; +static int scriptline; -char token[BSPMAXTOKEN]; -bool endofscript; -bool tokenready; // only true if UnGetToken was just called +static char token[BSPMAXTOKEN]; +static bool endofscript; +static bool tokenready; // only true if UnGetToken was just called // //loadBSPFile // -int extrasize = 100; +static int extrasize = 100; BspLoader::BspLoader() : m_num_entities(0) @@ -70,47 +70,47 @@ bool BspLoader::loadBSPFile(void *memoryBuffer) // swap the header swapBlock((int *)header, sizeof(*header)); - int length = (header->lumps[BSPLUMP_SHADERS].filelen) / sizeof(BSPShader); + int length = (int)((header->lumps[BSPLUMP_SHADERS].filelen) / sizeof(BSPShader)); m_dshaders.resize(length + extrasize); m_numShaders = copyLump(header, BSPLUMP_SHADERS, &m_dshaders[0], sizeof(BSPShader)); - length = (header->lumps[LUMP_MODELS].filelen) / sizeof(BSPModel); + length = (int)((header->lumps[LUMP_MODELS].filelen) / sizeof(BSPModel)); m_dmodels.resize(length + extrasize); m_nummodels = copyLump(header, LUMP_MODELS, &m_dmodels[0], sizeof(BSPModel)); - length = (header->lumps[BSPLUMP_PLANES].filelen) / sizeof(BSPPlane); + length = (int)((header->lumps[BSPLUMP_PLANES].filelen) / sizeof(BSPPlane)); m_dplanes.resize(length + extrasize); m_numplanes = copyLump(header, BSPLUMP_PLANES, &m_dplanes[0], sizeof(BSPPlane)); - length = (header->lumps[BSPLUMP_LEAFS].filelen) / sizeof(BSPLeaf); + length = (int)((header->lumps[BSPLUMP_LEAFS].filelen) / sizeof(BSPLeaf)); m_dleafs.resize(length + extrasize); m_numleafs = copyLump(header, BSPLUMP_LEAFS, &m_dleafs[0], sizeof(BSPLeaf)); - length = (header->lumps[BSPLUMP_NODES].filelen) / sizeof(BSPNode); + length = (int)((header->lumps[BSPLUMP_NODES].filelen) / sizeof(BSPNode)); m_dnodes.resize(length + extrasize); m_numnodes = copyLump(header, BSPLUMP_NODES, &m_dnodes[0], sizeof(BSPNode)); - length = (header->lumps[BSPLUMP_LEAFSURFACES].filelen) / sizeof(m_dleafsurfaces[0]); + length = (int)((header->lumps[BSPLUMP_LEAFSURFACES].filelen) / sizeof(m_dleafsurfaces[0])); m_dleafsurfaces.resize(length + extrasize); m_numleafsurfaces = copyLump(header, BSPLUMP_LEAFSURFACES, &m_dleafsurfaces[0], sizeof(m_dleafsurfaces[0])); - length = (header->lumps[BSPLUMP_LEAFBRUSHES].filelen) / sizeof(m_dleafbrushes[0]); + length = (int)((header->lumps[BSPLUMP_LEAFBRUSHES].filelen) / sizeof(m_dleafbrushes[0])); m_dleafbrushes.resize(length + extrasize); m_numleafbrushes = copyLump(header, BSPLUMP_LEAFBRUSHES, &m_dleafbrushes[0], sizeof(m_dleafbrushes[0])); - length = (header->lumps[LUMP_BRUSHES].filelen) / sizeof(BSPBrush); + length = (int)((header->lumps[LUMP_BRUSHES].filelen) / sizeof(BSPBrush)); m_dbrushes.resize(length + extrasize); m_numbrushes = copyLump(header, LUMP_BRUSHES, &m_dbrushes[0], sizeof(BSPBrush)); - length = (header->lumps[LUMP_BRUSHSIDES].filelen) / sizeof(BSPBrushSide); + length = (int)((header->lumps[LUMP_BRUSHSIDES].filelen) / sizeof(BSPBrushSide)); m_dbrushsides.resize(length + extrasize); m_numbrushsides = copyLump(header, LUMP_BRUSHSIDES, &m_dbrushsides[0], sizeof(BSPBrushSide)); - length = (header->lumps[LUMP_SURFACES].filelen) / sizeof(BSPSurface); + length = (int)((header->lumps[LUMP_SURFACES].filelen) / sizeof(BSPSurface)); m_drawSurfaces.resize(length + extrasize); m_numDrawSurfaces = copyLump(header, LUMP_SURFACES, &m_drawSurfaces[0], sizeof(BSPSurface)); - length = (header->lumps[LUMP_DRAWINDEXES].filelen) / sizeof(m_drawIndexes[0]); + length = (int)((header->lumps[LUMP_DRAWINDEXES].filelen) / sizeof(m_drawIndexes[0])); m_drawIndexes.resize(length + extrasize); m_numDrawIndexes = copyLump(header, LUMP_DRAWINDEXES, &m_drawIndexes[0], sizeof(m_drawIndexes[0])); @@ -166,8 +166,8 @@ bool BspLoader::getVectorForKey(const BSPEntity *ent, const char *key, BSPVector k = getValueForKey(ent, key); if (strcmp(k, "")) { - sscanf(k, "%f %f %f", &vec[0], &vec[1], &vec[2]); - return true; + int len = sscanf(k, "%f %f %f", &vec[0], &vec[1], &vec[2]); + return len == 3; } return false; } @@ -229,7 +229,7 @@ bool BspLoader::getToken(bool crossline) { char *token_p; - if (tokenready) // is a token allready waiting? + if (tokenready) // is a token already waiting? { tokenready = false; return true; @@ -344,7 +344,7 @@ char *BspLoader::copystring(const char *s) { char *b; b = (char *)malloc(strlen(s) + 1); - strcpy(b, s); + if(b) strcpy(b, s); return b; } @@ -369,24 +369,27 @@ BSPKeyValuePair *BspLoader::parseEpair(void) BSPKeyValuePair *e; e = (struct BSPPair *)malloc(sizeof(BSPKeyValuePair)); - memset(e, 0, sizeof(BSPKeyValuePair)); + if(e) memset(e, 0, sizeof(BSPKeyValuePair)); if (strlen(token) >= BSPMAX_KEY - 1) { //printf ("ParseEpar: token too long"); } - e->key = copystring(token); + if(e) e->key = copystring(token); getToken(false); if (strlen(token) >= BSPMAX_VALUE - 1) { //printf ("ParseEpar: token too long"); } - e->value = copystring(token); + if(e) e->value = copystring(token); // strip trailing spaces that sometimes get accidentally // added in the editor - stripTrailing(e->key); - stripTrailing(e->value); + if(e) + { + stripTrailing(e->key); + stripTrailing(e->value); + } return e; } @@ -477,10 +480,10 @@ short BspLoader::isLittleShort(short l) { unsigned char b1, b2; - b1 = l & 255; - b2 = (l >> 8) & 255; + b1 = (unsigned char)(l & 255); + b2 = (unsigned char)((l >> 8) & 255); - return (b1 << 8) + b2; + return short((b1 << 8) + b2); } //little endian return l; @@ -495,10 +498,10 @@ short BspLoader::isBigShort(short l) unsigned char b1, b2; - b1 = l & 255; - b2 = (l >> 8) & 255; + b1 = (unsigned char)(l & 255); + b2 = (unsigned char)((l >> 8) & 255); - return (b1 << 8) + b2; + return short((b1 << 8) + b2); } int BspLoader::isLittleLong(int l) @@ -507,10 +510,10 @@ int BspLoader::isLittleLong(int l) { unsigned char b1, b2, b3, b4; - b1 = l & 255; - b2 = (l >> 8) & 255; - b3 = (l >> 16) & 255; - b4 = (l >> 24) & 255; + b1 = (unsigned char)(l & 255); + b2 = (unsigned char)((l >> 8) & 255); + b3 = (unsigned char)((l >> 16) & 255); + b4 = (unsigned char)((l >> 24) & 255); return ((int)b1 << 24) + ((int)b2 << 16) + ((int)b3 << 8) + b4; } @@ -528,10 +531,10 @@ int BspLoader::isBigLong(int l) unsigned char b1, b2, b3, b4; - b1 = l & 255; - b2 = (l >> 8) & 255; - b3 = (l >> 16) & 255; - b4 = (l >> 24) & 255; + b1 = (unsigned char)(l & 255); + b2 = (unsigned char)((l >> 8) & 255); + b3 = (unsigned char)((l >> 16) & 255); + b4 = (unsigned char)((l >> 24) & 255); return ((int)b1 << 24) + ((int)b2 << 16) + ((int)b3 << 8) + b4; } @@ -610,7 +613,7 @@ int BspLoader::copyLump(BSPHeader *header, int lump, void *dest, int size) // printf ("loadBSPFile: odd lump size"); //} - memcpy(dest, (unsigned char *)header + ofs, length); + memcpy(dest, (unsigned char *)header + ofs, (size_t)length); return length / size; } @@ -624,7 +627,7 @@ void BspLoader::swapBSPFile(void) int i; // models - swapBlock((int *)&m_dmodels[0], m_nummodels * sizeof(m_dmodels[0])); + swapBlock((int *)&m_dmodels[0], (int)(m_nummodels * sizeof(m_dmodels[0]))); // shaders (don't swap the name) for (i = 0; i < m_numShaders; i++) @@ -634,38 +637,38 @@ void BspLoader::swapBSPFile(void) } // planes - swapBlock((int *)&m_dplanes[0], m_numplanes * sizeof(m_dplanes[0])); + swapBlock((int *)&m_dplanes[0], (int)(m_numplanes * sizeof(m_dplanes[0]))); // nodes - swapBlock((int *)&m_dnodes[0], m_numnodes * sizeof(m_dnodes[0])); + swapBlock((int *)&m_dnodes[0], (int)(m_numnodes * sizeof(m_dnodes[0]))); // leafs - swapBlock((int *)&m_dleafs[0], m_numleafs * sizeof(m_dleafs[0])); + swapBlock((int *)&m_dleafs[0], (int)(m_numleafs * sizeof(m_dleafs[0]))); // leaffaces - swapBlock((int *)&m_dleafsurfaces[0], m_numleafsurfaces * sizeof(m_dleafsurfaces[0])); + swapBlock((int *)&m_dleafsurfaces[0], (int)(m_numleafsurfaces * sizeof(m_dleafsurfaces[0]))); // leafbrushes - swapBlock((int *)&m_dleafbrushes[0], m_numleafbrushes * sizeof(m_dleafbrushes[0])); + swapBlock((int *)&m_dleafbrushes[0], (int)(m_numleafbrushes * sizeof(m_dleafbrushes[0]))); // brushes - swapBlock((int *)&m_dbrushes[0], m_numbrushes * sizeof(m_dbrushes[0])); + swapBlock((int *)&m_dbrushes[0], (int)(m_numbrushes * sizeof(m_dbrushes[0]))); // brushsides - swapBlock((int *)&m_dbrushsides[0], m_numbrushsides * sizeof(m_dbrushsides[0])); + swapBlock((int *)&m_dbrushsides[0], (int)(m_numbrushsides * sizeof(m_dbrushsides[0]))); // vis ((int *)&m_visBytes)[0] = isLittleLong(((int *)&m_visBytes)[0]); ((int *)&m_visBytes)[1] = isLittleLong(((int *)&m_visBytes)[1]); // drawindexes - swapBlock((int *)&m_drawIndexes[0], m_numDrawIndexes * sizeof(m_drawIndexes[0])); + swapBlock((int *)&m_drawIndexes[0], (int)(m_numDrawIndexes * sizeof(m_drawIndexes[0]))); // drawsurfs - swapBlock((int *)&m_drawSurfaces[0], m_numDrawSurfaces * sizeof(m_drawSurfaces[0])); + swapBlock((int *)&m_drawSurfaces[0], (int)(m_numDrawSurfaces * sizeof(m_drawSurfaces[0]))); } -bool BspLoader::findVectorByName(float *outvec, const char *name) +bool BspLoader::findVectorByName(float *outvec, const char * /*name*/) { const char *cl; BSPVector3 origin; diff --git a/examples/Importers/ImportBsp/ImportBspExample.cpp b/examples/Importers/ImportBsp/ImportBspExample.cpp index 851e518564..69840cfb52 100644 --- a/examples/Importers/ImportBsp/ImportBspExample.cpp +++ b/examples/Importers/ImportBsp/ImportBspExample.cpp @@ -73,7 +73,7 @@ class BspToBulletConverter : public BspConverter { } - virtual void addConvexVerticesCollider(btAlignedObjectArray& vertices, bool isEntity, const btVector3& entityTargetLocation) + virtual void addConvexVerticesCollider(btAlignedObjectArray& vertices, bool /*isEntity*/, const btVector3& /*entityTargetLocation*/) { ///perhaps we can do something special with entities (isEntity) ///like adding a collision Triggering (as example) @@ -162,15 +162,16 @@ void BspDemo::initPhysics(const char* bspfilename) { BspLoader bspLoader; int size = 0; - if (fseek(file, 0, SEEK_END) || (size = ftell(file)) == EOF || fseek(file, 0, SEEK_SET)) + if (fseek(file, 0, SEEK_END) || (size = (int)ftell(file)) == EOF || fseek(file, 0, SEEK_SET)) { /* File operations denied? ok, just close and return failure */ printf("Error: cannot get filesize from %s\n", bspfilename); } else { //how to detect file size? - memoryBuffer = malloc(size + 1); - fread(memoryBuffer, 1, size, file); + memoryBuffer = malloc((size_t)size + 1); + int len = memoryBuffer ? (int)fread(memoryBuffer, 1, (size_t)size, file) : 0; + (void)len; bspLoader.loadBSPFile(memoryBuffer); BspToBulletConverter bsp2bullet(this); @@ -186,12 +187,12 @@ void BspDemo::initPhysics(const char* bspfilename) } //some code that de-mangles the windows filename passed in as argument -char cleaned_filename[512]; -char* getLastFileName() +static char cleaned_filename[512]; +static char* getLastFileName() { return cleaned_filename; } -char* makeExeToBspFilename(const char* lpCmdLine) +static char* makeExeToBspFilename(const char* lpCmdLine) { // We might get a windows-style path on the command line, this can mess up the DOM which expects // all paths to be URI's. This block of code does some conversion to try and make the input diff --git a/examples/Importers/ImportBullet/SerializeSetup.cpp b/examples/Importers/ImportBullet/SerializeSetup.cpp index f0caed3b1d..aff8628d13 100644 --- a/examples/Importers/ImportBullet/SerializeSetup.cpp +++ b/examples/Importers/ImportBullet/SerializeSetup.cpp @@ -19,10 +19,10 @@ class SerializeSetup : public CommonRigidBodyBase } virtual void resetCamera() { - float dist = 9.5; + float dist = 9.5f; float pitch = -20; - float yaw = -2.8; - float targetPos[3] = {-0.2, -1.4, 3.5}; + float yaw = -2.8f; + float targetPos[3] = {-0.2f, -1.4f, 3.5f}; m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } }; @@ -87,7 +87,7 @@ void SerializeSetup::initPhysics() m_dynamicsWorld->serialize(serializer); FILE* file = fopen("SerializeSetupTestFile.bullet", "wb"); - fwrite(serializer->getBufferPointer(), serializer->getCurrentBufferSize(), 1, file); + fwrite(serializer->getBufferPointer(), (size_t)serializer->getCurrentBufferSize(), 1, file); fclose(file); m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld); diff --git a/examples/Importers/ImportColladaDemo/ImportColladaSetup.cpp b/examples/Importers/ImportColladaDemo/ImportColladaSetup.cpp index eaada4268b..ae19782624 100644 --- a/examples/Importers/ImportColladaDemo/ImportColladaSetup.cpp +++ b/examples/Importers/ImportColladaDemo/ImportColladaSetup.cpp @@ -148,17 +148,17 @@ void ImportColladaSetup::initPhysics() b3AlignedObjectArray verts; verts.resize(gfxShape->m_vertices->size()); - for (int i = 0; i < gfxShape->m_vertices->size(); i++) + for (int j = 0; j < gfxShape->m_vertices->size(); j++) { - verts[i].normal[0] = gfxShape->m_vertices->at(i).normal[0]; - verts[i].normal[1] = gfxShape->m_vertices->at(i).normal[1]; - verts[i].normal[2] = gfxShape->m_vertices->at(i).normal[2]; - verts[i].uv[0] = gfxShape->m_vertices->at(i).uv[0]; - verts[i].uv[1] = gfxShape->m_vertices->at(i).uv[1]; - verts[i].xyzw[0] = gfxShape->m_vertices->at(i).xyzw[0]; - verts[i].xyzw[1] = gfxShape->m_vertices->at(i).xyzw[1]; - verts[i].xyzw[2] = gfxShape->m_vertices->at(i).xyzw[2]; - verts[i].xyzw[3] = gfxShape->m_vertices->at(i).xyzw[3]; + verts[j].normal[0] = gfxShape->m_vertices->at(j).normal[0]; + verts[j].normal[1] = gfxShape->m_vertices->at(j).normal[1]; + verts[j].normal[2] = gfxShape->m_vertices->at(j).normal[2]; + verts[j].uv[0] = gfxShape->m_vertices->at(j).uv[0]; + verts[j].uv[1] = gfxShape->m_vertices->at(j).uv[1]; + verts[j].xyzw[0] = gfxShape->m_vertices->at(j).xyzw[0]; + verts[j].xyzw[1] = gfxShape->m_vertices->at(j).xyzw[1]; + verts[j].xyzw[2] = gfxShape->m_vertices->at(j).xyzw[2]; + verts[j].xyzw[3] = gfxShape->m_vertices->at(j).xyzw[3]; } //compensate upAxisTrans and unitMeterScaling here diff --git a/examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp b/examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp index eed72ca140..8e6afeb5de 100644 --- a/examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp +++ b/examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp @@ -19,7 +19,14 @@ subject to the following restrictions: #include //fopen #include "Bullet3Common/b3AlignedObjectArray.h" #include +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wextra-semi-stmt" +#endif #include "../../ThirdPartyLibs/tinyxml2/tinyxml2.h" +#if defined(__clang__) +#pragma clang diagnostic pop +#endif using namespace tinyxml2; @@ -45,7 +52,7 @@ struct TokenFloatArray } inline void add(const char* token) { - float v = atof(token); + float v = (float)atof(token); m_values.push_back(v); } }; @@ -58,7 +65,7 @@ struct TokenIntArray } inline void add(const char* token) { - float v = atoi(token); + int v = atoi(token); m_values.push_back(v); } }; @@ -90,9 +97,9 @@ void tokenize(const std::string& str, AddToken& tokenAdder, const std::string& d } } -void readFloatArray(XMLElement* source, btAlignedObjectArray& floatArray, int& componentStride) +static void readFloatArray(XMLElement* source, btAlignedObjectArray& floatArray, int& componentStride) { - int numVals, stride; + int numVals = 0, stride; XMLElement* array = source->FirstChildElement("float_array"); if (array) { @@ -110,7 +117,7 @@ void readFloatArray(XMLElement* source, btAlignedObjectArray& floatArray, } } -btVector3 getVector3FromXmlText(const char* text) +static btVector3 getVector3FromXmlText(const char* text) { btVector3 vec(0, 0, 0); btAlignedObjectArray floatArray; @@ -125,7 +132,7 @@ btVector3 getVector3FromXmlText(const char* text) return vec; } -btVector4 getVector4FromXmlText(const char* text) +static btVector4 getVector4FromXmlText(const char* text) { btVector4 vec(0, 0, 0, 0); btAlignedObjectArray floatArray; @@ -140,7 +147,7 @@ btVector4 getVector4FromXmlText(const char* text) return vec; } -void readLibraryGeometries(XMLDocument& doc, btAlignedObjectArray& visualShapes, btHashMap& name2Shape, float extraScaling) +static void readLibraryGeometries(XMLDocument& doc, btAlignedObjectArray& visualShapes, btHashMap& name2Shape, float extraScaling) { btHashMap allSources; btHashMap vertexSources; @@ -229,15 +236,15 @@ void readLibraryGeometries(XMLDocument& doc, btAlignedObjectArray) - VertexSource* vs = vertexSources[source_name.c_str()]; - if (vs->m_positionArrayId.length()) + VertexSource* vertSrc = vertexSources[source_name.c_str()]; + if (vertSrc->m_positionArrayId.length()) { - positionSourceName = vs->m_positionArrayId; + positionSourceName = vertSrc->m_positionArrayId; posOffset = offset; } - if (vs->m_normalArrayId.length()) + if (vertSrc->m_normalArrayId.length()) { - normalSourceName = vs->m_normalArrayId; + normalSourceName = vertSrc->m_normalArrayId; normalOffset = offset; } } @@ -314,13 +321,13 @@ void readLibraryGeometries(XMLDocument& doc, btAlignedObjectArraypush_back(vtx); @@ -335,6 +342,7 @@ void readLibraryGeometries(XMLDocument& doc, btAlignedObjectArraysize(); visualShape.m_numIndices = visualShape.m_indices->size(); visualShape.m_numvertices = visualShape.m_vertices->size(); + (void)indexBase; } //b3Printf("geometry name=%s\n",geometryName); name2Shape.insert(geometryName, shapeIndex); @@ -347,7 +355,7 @@ void readLibraryGeometries(XMLDocument& doc, btAlignedObjectArray& name2Shape, btAlignedObjectArray& visualShapeInstances, const btMatrix4x4& parentTransMat) +static void readNodeHierarchy(XMLElement* node, btHashMap& name2Shape, btAlignedObjectArray& visualShapeInstances, const btMatrix4x4& parentTransMat) { btMatrix4x4 nodeTrans; nodeTrans.setIdentity(); @@ -450,7 +458,7 @@ void readNodeHierarchy(XMLElement* node, btHashMap& name2Shap readNodeHierarchy(childNode, name2Shape, visualShapeInstances, nodeTrans); } } -void readVisualSceneInstanceGeometries(XMLDocument& doc, btHashMap& name2Shape, btAlignedObjectArray& visualShapeInstances) +static void readVisualSceneInstanceGeometries(XMLDocument& doc, btHashMap& name2Shape, btAlignedObjectArray& visualShapeInstances) { btHashMap allVisualScenes; @@ -498,7 +506,7 @@ void readVisualSceneInstanceGeometries(XMLDocument& doc, btHashMapAttribute("meter"); //printf("meterText=%s\n", meterText); - unitMeterScaling = atof(meterText); + unitMeterScaling = (float)atof(meterText); } XMLElement* upAxisElem = doc.RootElement()->FirstChildElement("asset")->FirstChildElement("up_axis"); @@ -560,7 +568,7 @@ void getUnitMeterScalingAndUpAxisTransform(XMLDocument& doc, btTransform& tr, fl //we don't support X or other up axis btAssert(0); } - }; + } } } @@ -598,7 +606,7 @@ void LoadMeshFromCollada(const char* relativeFileName, btAlignedObjectArray(pieces[i].c_str())); + rgba.push_back((float)urdfLexicalCast(pieces[i].c_str())); } } if (rgba.size() != 4) @@ -94,7 +101,7 @@ static bool parseVector3(btVector3& vec3, const std::string& vector_str, MJCFErr { if (!pieces[i].empty()) { - rgba.push_back(urdfLexicalCast(pieces[i].c_str())); + rgba.push_back((float)urdfLexicalCast(pieces[i].c_str())); } } if (rgba.size() < 3) @@ -127,7 +134,7 @@ static bool parseVector6(btVector3& v0, btVector3& v1, const std::string& vector { if (!pieces[i].empty()) { - values.push_back(urdfLexicalCast(pieces[i].c_str())); + values.push_back((float)urdfLexicalCast(pieces[i].c_str())); } } if (values.size() < 6) @@ -166,7 +173,7 @@ struct MyMJCFDefaults MyMJCFDefaults() : m_defaultCollisionGroup(1), m_defaultCollisionMask(1), - m_defaultCollisionMargin(0.001), //assume unit meters, margin is 1mm + m_defaultCollisionMargin(btScalar(0.001)), //assume unit meters, margin is 1mm m_defaultConDim(3), m_defaultLateralFriction(0.5), m_defaultSpinningFriction(0), @@ -187,7 +194,7 @@ struct BulletMJCFImporterInternalData btAlignedObjectArray m_models; - // + // std::string m_meshDir; std::string m_textureDir; std::string m_angleUnits; @@ -261,7 +268,7 @@ struct BulletMJCFImporterInternalData return 0; } - void parseCompiler(XMLElement* root_xml, MJCFErrorLogger* logger) + void parseCompiler(XMLElement* root_xml, MJCFErrorLogger* /*logger*/) { const char* meshDirStr = root_xml->Attribute("meshdir"); if (meshDirStr) @@ -282,7 +289,7 @@ struct BulletMJCFImporterInternalData } } - void parseAssets(XMLElement* root_xml, MJCFErrorLogger* logger) + void parseAssets(XMLElement* root_xml, MJCFErrorLogger* /*logger*/) { // for (XMLElement* child_xml = root_xml->FirstChildElement(); child_xml; child_xml = child_xml->NextSiblingElement()) @@ -345,7 +352,7 @@ struct BulletMJCFImporterInternalData // armature="1" // damping="1" // limited="true" - if (const char* conTypeStr = child_xml->Attribute("limited")) + if (/*const char* conTypeStr =*/ child_xml->Attribute("limited")) { defaults.m_defaultJointLimited = child_xml->Attribute("limited"); } @@ -374,7 +381,7 @@ struct BulletMJCFImporterInternalData { defaults.m_defaultConDim = urdfLexicalCast(conDimS); } - int conDim = defaults.m_defaultConDim; + // int conDim = defaults.m_defaultConDim; const char* frictionS = child_xml->Attribute("friction"); if (frictionS) @@ -388,7 +395,7 @@ struct BulletMJCFImporterInternalData { if (!pieces[i].empty()) { - frictions.push_back(urdfLexicalCast(pieces[i].c_str())); + frictions.push_back((float)urdfLexicalCast(pieces[i].c_str())); } } if (frictions.size() > 0) @@ -467,7 +474,7 @@ struct BulletMJCFImporterInternalData return true; } - bool parseJoint(MyMJCFDefaults& defaults, XMLElement* link_xml, int modelIndex, int parentLinkIndex, int linkIndex, MJCFErrorLogger* logger, const btTransform& parentToLinkTrans, btTransform& jointTransOut) + bool parseJoint(MyMJCFDefaults& /*defaults*/, XMLElement* link_xml, int modelIndex, int parentLinkIndex, int linkIndex, MJCFErrorLogger* logger, const btTransform& parentToLinkTrans, btTransform& jointTransOut) { bool jointHandled = false; const char* jType = link_xml->Attribute("type"); @@ -519,7 +526,7 @@ struct BulletMJCFImporterInternalData } bool isLimited = lim == "true"; - UrdfJointTypes ejtype; + UrdfJointTypes ejtype = (UrdfJointTypes)0; if (jType) { std::string jointType = jType; @@ -563,7 +570,7 @@ struct BulletMJCFImporterInternalData { if (!pieces[i].empty()) { - limits.push_back(urdfLexicalCast(pieces[i].c_str())); + limits.push_back((float)urdfLexicalCast(pieces[i].c_str())); } } if (limits.size() == 2) @@ -653,7 +660,7 @@ struct BulletMJCFImporterInternalData if (linkPtrPtr == 0) { // XXX: should it be assert? - logger->reportWarning("Invalide linkindex"); + logger->reportWarning("Invalid linkindex"); return false; } UrdfLink* linkPtr = *linkPtrPtr; @@ -691,7 +698,7 @@ struct BulletMJCFImporterInternalData { if (!pieces[i].empty()) { - frictions.push_back(urdfLexicalCast(pieces[i].c_str())); + frictions.push_back((float)urdfLexicalCast(pieces[i].c_str())); } } if (frictions.size() > 0) @@ -708,18 +715,18 @@ struct BulletMJCFImporterInternalData } } - linkPtr->m_contactInfo.m_lateralFriction = lateralFriction; - linkPtr->m_contactInfo.m_spinningFriction = spinningFriction; - linkPtr->m_contactInfo.m_rollingFriction = rollingFriction; + linkPtr->m_contactInfo.m_lateralFriction = (btScalar)lateralFriction; + linkPtr->m_contactInfo.m_spinningFriction = (btScalar)spinningFriction; + linkPtr->m_contactInfo.m_rollingFriction = (btScalar)rollingFriction; if (conDim > 3) { - linkPtr->m_contactInfo.m_spinningFriction = defaults.m_defaultSpinningFriction; + linkPtr->m_contactInfo.m_spinningFriction = (btScalar)defaults.m_defaultSpinningFriction; linkPtr->m_contactInfo.m_flags |= URDF_CONTACT_HAS_SPINNING_FRICTION; } if (conDim > 4) { - linkPtr->m_contactInfo.m_rollingFriction = defaults.m_defaultRollingFriction; + linkPtr->m_contactInfo.m_rollingFriction = (btScalar)defaults.m_defaultRollingFriction; linkPtr->m_contactInfo.m_flags |= URDF_CONTACT_HAS_ROLLING_FRICTION; } @@ -848,7 +855,7 @@ struct BulletMJCFImporterInternalData { if (!pieces[i].empty()) { - sizes.push_back(urdfLexicalCast(pieces[i].c_str())); + sizes.push_back((float)urdfLexicalCast(pieces[i].c_str())); } } @@ -1002,7 +1009,7 @@ struct BulletMJCFImporterInternalData return tr; } - double computeVolume(const UrdfLink* linkPtr, MJCFErrorLogger* logger) const + double computeVolume(const UrdfLink* linkPtr, MJCFErrorLogger* /*logger*/) const { double totalVolume = 0; @@ -1056,7 +1063,7 @@ struct BulletMJCFImporterInternalData } else { - h = col->m_geometry.m_capsuleHeight; + h = (btScalar)col->m_geometry.m_capsuleHeight; } totalVolume += SIMD_PI * r * r * h; break; @@ -1180,7 +1187,7 @@ struct BulletMJCFImporterInternalData const char* m = xml->Attribute("mass"); if (m) { - mass = urdfLexicalCast(m); + mass = (btScalar)urdfLexicalCast(m); } const char* i = xml->Attribute("diaginertia"); if (i) @@ -1301,7 +1308,7 @@ struct BulletMJCFImporterInternalData { double density = 1000; double volume = computeVolume(linkPtr, logger); - mass = density * volume; + mass = btScalar(density * volume); } linkPtr->m_inertia.m_linkLocalFrame = localInertialFrame; // = jointTrans.inverse(); linkPtr->m_inertia.m_mass = mass; @@ -1436,7 +1443,7 @@ BulletMJCFImporter::~BulletMJCFImporter() delete m_data; } -bool BulletMJCFImporter::loadMJCF(const char* fileName, MJCFErrorLogger* logger, bool forceFixedBase) +bool BulletMJCFImporter::loadMJCF(const char* fileName, MJCFErrorLogger* logger, bool /*forceFixedBase*/) { if (strlen(fileName) == 0) return false; @@ -1447,7 +1454,7 @@ bool BulletMJCFImporter::loadMJCF(const char* fileName, MJCFErrorLogger* logger, b3FileUtils fu; //bool fileFound = fu.findFile(fileName, relativeFileName, 1024); - bool fileFound = (m_data->m_fileIO->findResourcePath(fileName, relativeFileName, 1024) > 0); + bool fileFound = m_data->m_fileIO->findResourcePath(fileName, relativeFileName, 1024); m_data->m_sourceFileName = relativeFileName; std::string xml_string; @@ -1507,8 +1514,8 @@ bool BulletMJCFImporter::parseMJCFString(const char* xmlText, MJCFErrorLogger* l m_data->m_fileModelName = modelName; } - //,