Jump to content
  • Advertisement
Sign in to follow this  
Rakkar2

Can't do a valid cast

This topic is 4188 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!