gwaldron / osgearth

3D Maps for OpenSceneGraph / C++14
https://www.pelicanmapping.com/home-1/opensource
Other
1.48k stars 774 forks source link

Simple pointer error #629

Closed DaxDeveloper closed 9 years ago

DaxDeveloper commented 9 years ago

Hi, I have a problem with osg earth version 2.6 VS2013. I have built it with successfull and on my project I have included this header:

#include <osgEarth/Map>
#include <osgEarth/MapNode>
#include <osgEarthDrivers/tms/TMSOptions>
#include <osgEarthDrivers/gdal/GDALOptions>

As result I have this compiler error:

Error   1   error C2664: 'bool osgEarth::Profile::isHorizEquivalentTo(const osgEarth::Profile *) const' : cannot convert argument 1 from 'const osg::ref_ptr<const osgEarth::Profile>' to 'const osgEarth::Profile *'   C:\lib\OSGEarth\include\osgEarth\TileKey

Can anyone explane my how I can solve this problem??

thanks in advance!!

gwaldron commented 9 years ago

This occurs when OSG is built with the CMAKE flag "OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION" set to false. You can either set it to true (which is the default) and rebuild OSG, or you can patch TileKey like so:

_profile->isHorizEquivalentTo(rhs._profile.get());

It's the missing ".get()" causing the trouble. This will be fixed in 2.7...

DaxDeveloper commented 9 years ago

OK thanks for quickly reply.

I prefer don't fix TileKey header because I think that I have the same problem in other find, I need I better solution.

I think that I can check if the flag is setted bat I think so because is default value of cmake.

I'll do the test that you have suggested and I'll let you known.

gwaldron commented 9 years ago

Thanks.

DaxDeveloper commented 9 years ago

"OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION" is set to true in OSG.

So this is not a valid solution for my problem.

At the moment I can try to continue using patch that you have suggested, I hope that will not necessary apply this path at more file.

Do you have other Idea?

gwaldron commented 9 years ago

You should write a simple test to make sure the implicit conversion is really enabled. I suspect it's not.

DaxDeveloper commented 9 years ago

I have checked the implicit conversion and is set correctly.

I have builded the latest version of code directly from branch master and seems that I have solve my problem (TileKey header already have get() for raw pointer access).

So at the moment I think that you can close this issue. Thanks a lot!