🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Can't register class with overloaded functions

Started by
1 comment, last by Rakkar2 17 years, 3 months ago
Not sure what I'm doing wrong here: My registration:

ScriptManager::engine->RegisterObjectMethod("Sphere", "bool intersects( const Sphere &in) const", asMETHODPR(Ogre::Sphere, intersects, (const Ogre::Sphere&), bool),asCALL_THISCALL);
ScriptManager::engine->RegisterObjectMethod("Sphere", "bool intersects( const Plane& in ) const", asMETHODPR(Ogre::Sphere, intersects, (const Ogre::Plane&), bool),asCALL_THISCALL);
ScriptManager::engine->RegisterObjectMethod("Sphere", "bool intersects( const Vector3& in ) const", asMETHODPR(Ogre::Sphere, intersects, (const Ogre::Vector3&), bool),asCALL_THISCALL);
ScriptManager::engine->RegisterObjectMethod("Sphere", "bool intersects( const AxisAlignedBox& in ) const", asMETHODPR(Ogre::Sphere, intersects, (const Ogre::AxisAlignedBox&), bool),asCALL_THISCALL);


Ogre source (inlined in header):

/** Returns whether or not this sphere interects a box. */
bool intersects(const AxisAlignedBox& box) const
{
	return Math::intersects(*this, box);
}
/** Returns whether or not this sphere interects a plane. */
bool intersects(const Plane& plane) const
{
	return Math::intersects(*this, plane);
}
/** Returns whether or not this sphere interects a point. */
bool intersects(const Vector3& v) const
{
         return ((v - mCenter).squaredLength() <= Math::Sqr(mRadius));
}


Result when I try to compile:

Error	1	error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'bool (__thiscall Ogre::Sphere::* )(const Ogre::Sphere&)'	c:\rakengine\source\engine\script\scriptsphere.cpp	26
Error	2	error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'bool (__thiscall Ogre::Sphere::* )(const Ogre::Plane &)'	c:\rakengine\source\engine\script\scriptsphere.cpp	27
Error	3	error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'bool (__thiscall Ogre::Sphere::* )(const Ogre::Vector3 &)'	c:\rakengine\source\engine\script\scriptsphere.cpp	28
Error	4	error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'bool (__thiscall Ogre::Sphere::* )(const Ogre::AxisAlignedBox &)'	c:\rakengine\source\engine\script\scriptsphere.cpp	29


Advertisement
You're not giving the complete function signature to asMETHODPR, so the compiler is not able to resolve the address. Try this adding const after the parameter list:

asMETHODPR(Ogre::Sphere, intersects, (const Ogre::Sphere&) const, bool)


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Thanks. I thought it was that but I didn't know where to put the const.

This topic is closed to new replies.

Advertisement