AcademySoftwareFoundation / openvdb

OpenVDB - Sparse volume data structure and tools
http://www.openvdb.org/
Apache License 2.0
2.69k stars 658 forks source link

[BUILD] MeshToVolume.h makes an error. (VDB 8.1) #1494

Closed mifth closed 1 year ago

mifth commented 2 years ago

Environment

Operating System: Windows 11 Version / Commit SHA: 8.1 CMake Version: Compiler: msvc 2022

Describe the problem

I tried to compile an UE5 plugin with included VDB. If I add this I'll get a compile error: #include <openvdb/tools/MeshToVolume.h>

Probably this is not a bug but could you please check my LOG out?

LOG: ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\MeshToVolume.h(1684): error C2062: type 'bool' unexpected ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\MeshToVolume.h(1684): note: see reference to class template instantiation 'openvdb::v8_1::tools::mesh_to_volume_internal::ValidateIntersectingVoxels::IsNegative' being compiled ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\MeshToVolume.h(1727): note: see reference to class template instantiation 'openvdb::v8_1::tools::mesh_to_volume_internal::ValidateIntersectingVoxels' being compiled ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\MeshToVolume.h(1684): error C2334: unexpected token(s) preceding '{'; skipping apparent function body ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\MeshToVolume.h(1684): error C2059: syntax error: '{' ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\MeshToVolume.h(1684): error C2334: unexpected token(s) preceding '{'; skipping apparent function body ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\MeshToVolume.h(1737): error C2062: type 'bool' unexpected ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\MeshToVolume.h(1737): note: see reference to class template instantiation 'openvdb::v8_1::tools::mesh_to_volume_internal::RemoveSelfIntersectingSurface::Comp' being compiled ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\MeshToVolume.h(1786): note: see reference to class template instantiation 'openvdb::v8_1::tools::mesh_to_volume_internal::RemoveSelfIntersectingSurface' being compiled ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\MeshToVolume.h(1737): error C2334: unexpected token(s) preceding '{'; skipping apparent function body ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\MeshToVolume.h(1737): error C2059: syntax error: '{' ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\MeshToVolume.h(1737): error C2334: unexpected token(s) preceding '{'; skipping apparent function body ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\Activate.h(65): error C2062: type 'bool' unexpected ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\Activate.h(106): note: see reference to class template instantiation 'openvdb::v8_1::tools::activate_internal::ActivateOp<TreeT,IgnoreTolerance>' being compiled ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\Activate.h(65): error C2334: unexpected token(s) preceding '{'; skipping apparent function body ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\Activate.h(65): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\Activate.h(65): error C2059: syntax error: '{' ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\Activate.h(65): error C2334: unexpected token(s) preceding '{'; skipping apparent function body ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\Activate.h(121): error C2062: type 'bool' unexpected ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\Activate.h(160): note: see reference to class template instantiation 'openvdb::v8_1::tools::activate_internal::DeactivateOp<TreeT,IgnoreTolerance>' being compiled ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\Activate.h(121): error C2334: unexpected token(s) preceding '{'; skipping apparent function body ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\Activate.h(121): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\Activate.h(121): error C2059: syntax error: '{' ubt> D:\Projects\TKG\Perforce\GasVegas_Pavel\Engine\Source\ThirdParty\OpenVDB\Deploy\openvdb-8.1.0\include\openvdb\tools\Activate.h(121): error C2334: unexpected token(s) preceding '{'; skipping apparent function body p4> p4.exe -p "ssl:10.51.2.17:1666" -u "pgeraskin" -c "GasVegas_Pavel" -s -zprog=UGS -zversion=1.0.0.0 -Q utf8 -ztag -x "C:\Users\mifth\AppData\Local\Temp\tmp5D03.tmp" opened

mifth commented 2 years ago

I would like to admit if I add other files I'll get no compile error. For example, this will compile fine:

#include <openvdb/openvdb.h>
#include <openvdb/tools/Interpolation.h> // for Spatial Query
#include <openvdb/tools/VolumeToMesh.h> // for VolumeToMesh
#include <openvdb/tools/Composite.h> // for CSG operations
Idclip commented 1 year ago

I've been unable to reproduce this. The main errors are:

openvdb\tools\MeshToVolume.h(1684): error C2062: type 'bool' unexpected
openvdb\tools\MeshToVolume.h(1737): error C2062: type 'bool' unexpected
openvdb\tools\Activate.h(65): error C2062: type 'bool' unexpected
openvdb\tools\Activate.h(121): error C2062: type 'bool' unexpected

All these cases implement a function check, e.g:

struct Comp { static bool check(const ValueType v) { return !(v > ValueType(0.75)); } };

inline bool check(const ValueT& value) const

I suspect something in UE is defining some check macro? Indeed, I just googled "UE5 check macro" and got the following:

https://docs.unrealengine.com/4.26/en-US/ProgrammingAndScripting/ProgrammingWithCPP/Assertions/

Perhaps try using #undef check before including the MeshToVolume header, include the header before any UE stuff or try and disable this behaviour in UE.