NVIDIAGameWorks / PhysX

NVIDIA PhysX SDK
Other
3.15k stars 795 forks source link

Compile error on GCC #283

Open alekseyt opened 4 years ago

alekseyt commented 4 years ago
[ 18%] Building CXX object sdk_source_bin/CMakeFiles/PhysXCommon.dir/home/alex/projects/PhysX/physx/source/geomutils/src/GuMTD.cpp.o
In file included from <skip>/PhysX/physx/source/geomutils/src/pcm/GuPCMContactGen.h:38,
                 from <skip>/PhysX/physx/source/geomutils/src/GuMTD.cpp:53:
<skip>/PhysX/physx/source/geomutils/src/gjk/GuGJKType.h: In member function ‘physx::shdfnd::aos::PsMatTransformV& physx::Gu::RelativeConvex<Convex>::getRelativeTransform()’:
<skip>/PhysX/physx/source/geomutils/src/gjk/GuGJKType.h:154:67: error: binding reference of type ‘physx::shdfnd::aos::PsMatTransformV&’ to ‘const physx::shdfnd::aos::PsMatTransformV’ discards qualifiers
  154 |   PX_FORCE_INLINE Ps::aos::PsMatTransformV& getRelativeTransform(){ return mAToB; }
      |                                                                   ^~~~~

This is too trivial for PR or signing CLA or whatever, it's just that const is missing.

Patch:

diff --git a/physx/source/geomutils/src/gjk/GuGJKType.h b/physx/source/geomutils/src/gjk/GuGJKType.h
index a0099e2f..b824ec7a 100644
--- a/physx/source/geomutils/src/gjk/GuGJKType.h
+++ b/physx/source/geomutils/src/gjk/GuGJKType.h
@@ -151,7 +151,7 @@ namespace Gu

                virtual Ps::aos::Vec3V getCenter() const { return mAToB.transform(getConvex<Convex>().getCenter()); }

-               PX_FORCE_INLINE Ps::aos::PsMatTransformV& getRelativeTransform(){ return mAToB; }
+               PX_FORCE_INLINE const Ps::aos::PsMatTransformV& getRelativeTransform(){ return mAToB; }

                //ML: we can't force inline function, otherwise win modern will throw compiler error
                PX_INLINE RelativeConvex<typename ConvexGeom<Convex>::Type > getGjkConvex() const
alekseyt commented 4 years ago

This is not a compile error, but another missing const is here:

diff --git a/physx/source/lowleveldynamics/include/DyFeatherstoneArticulationUtils.h b/physx/source/lowleveldynamics/include/DyFeatherstoneArticulationUtils.h
index a2be3b09..39e3afd4 100644
--- a/physx/source/lowleveldynamics/include/DyFeatherstoneArticulationUtils.h
+++ b/physx/source/lowleveldynamics/include/DyFeatherstoneArticulationUtils.h
@@ -212,7 +212,7 @@ namespace Dy
                        return Cm::UnAlignedSpatialVector(top1, bottom1);
                }

-               PX_CUDA_CALLABLE PX_FORCE_INLINE void operator =(SpatialTransform& other)
+               PX_CUDA_CALLABLE PX_FORCE_INLINE void operator =(const SpatialTransform& other)
                {
                        R = other.R;
                        q = other.q;

It probably would be beneficial to compile PhysX with GCC with -Wextra flag and look into printed warnings.