(PATCH) OctreeZone::getHeightAt()


21-01-2009 03:25:36


We had an issue using the OctreeZone::getHeightAt() function with MinGW. MinGW would issue a link error when we tried to use the function regardless of how we tried to access it. I found that by declaring the getHeightAt function as a 'virtual' function MinGW will link to it. I'm not sure I fully understand why MinGW refused to link without the 'virtual' declaration, and that bothers me. So if anyone knows why or can explain how to access the function without the virtual declaration I would appreciate the info. MSVC2005 and XCode is able to link either way. I have not tested with MSVC2008 but I would expect the results to be the same as 2005.

This is how we are currently using the function:

float height = dynamic_cast<Ogre::TerrainZone*>(mPCZone)->getHeightAt(x, z);

where; mPCZone is a pointer to the specific Ogre::PCZone.

Here is the patch (I'll also submit it officially):

Index: OgreTerrainZone.h
--- OgreTerrainZone.h (revision 8267)
+++ OgreTerrainZone.h (working copy)
@@ -100,7 +100,7 @@
const String& typeName = StringUtil::BLANK);

/** Returns the height at the given terrain coordinates. */
- float getHeightAt( float x, float y );
+ virtual float getHeightAt( float x, float y );

bool intersectSegment( const Vector3 & start, const Vector3 & end, Vector3 * result );
@@ -402,3 +402,4 @@



21-01-2009 03:33:45

I have the same problem with VC2005. The patch worked.




15-02-2009 20:05:31

This patch is in the SVN.