Sign in to follow this  
Rakkar2

Can't do a valid cast

Recommended Posts

I'm trying to pass a pointer to a derived class to a function that takes a pointer to a base class. It doesn't work through script though. Error: No matching signatures to 'attachObject(BillboardSet@&) Script Code:
SceneNode parent = this.getSceneNode();
BillboardSet @billboardSet = createBillboardSet("Blah", 20);
billboardSet.setMaterialName("PhotonGunMaterial");
parent.attachObject(cast<MovableObject>(billboardSet));

C++ Script registration:
ScriptManager::engine->RegisterGlobalFunction("BillboardSet@ createBillboardSet(const string& in, int)", asFUNCTION(ScriptSceneManager::CreateBillboardSet), asCALL_CDECL); 

...

ScriptManager::engine->RegisterObjectMethod("SceneNode", "void attachObject(MovableObject@)",  asMETHOD(SceneNode, attachObject),asCALL_THISCALL);

Actual C++:
Ogre::BillboardSet* ScriptSceneManager::CreateBillboardSet(std::string &name)
{
return sm->createBillboardSet(name);
}

...

 class _OgreExport BillboardSet : public MovableObject, public Renderable
    {
    protected:



Share this post


Link to post
Share on other sites
I don't recall there being a way to tell Angelscript that a registered type derives from some other registered type. Unless there is, you'll have to register functions for each type.

Share this post


Link to post
Share on other sites
There needs to be a way to force the cast to take place no matter what.

This doesn't work either


ScriptManager::engine->RegisterObjectBehaviour("MovableObject", asBEHAVE_ASSIGNMENT, "MovableObject @&f(const BillboardSet @& in)", asFUNCTION((Wrap::AssignCast<MovableObject*&,MovableObject*,const BillboardSet*&>)), asCALL_CDECL_OBJLAST);



Just returns INVALID_DECLARATION

Share this post


Link to post
Share on other sites
Cast operations are at the very top of my to-do list. You will be able to register relationships between classes, so that AngelScript can automatically cast an object handle from one type to another.

Currently the easiest thing you can do is to register a function that does the conversion, i.e. takes a pointer of one type and returns the pointer as another type. Then you'll have to call this function to convert the handle.

Regards,
Andreas

Share this post


Link to post
Share on other sites
Well damn, I just came on here because I couldn't find any information about registering cast operations, and here it is. Nice to know you're planning on implementing it, though. I guess I'll just work around it for now.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this