Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualhupsilardee

Posted 06 May 2013 - 12:41 PM

Hi all, I've been using Angelscript in my project with great success so far, except this one weird bug.

 

I have bound my MeshSceneNode class to the scripting engine for scripting. It can only be created/destroyed by using the Scene interface (which appears as a singleton to the script)

// C++
assert(0 <= engine->RegisterObjectType("MeshSceneNode", sizeof(MeshSceneNode), asOBJ_REF | asOBJ_NOCOUNT));
assert(0 <= engine->RegisterObjectMethod("CScene", "MeshSceneNode@ CreateMesh(const string &in)", asMETHOD(Scene, AddMesh), asCALL_THISCALL));
assert(0 <= engine->RegisterObjectMethod("CScene", "void DestroyMesh(MeshSceneNode@)", asMETHOD(Scene, DestroyMesh), asCALL_THISCALL));

I made a Character class in script, and made an Avatar subclass to handle graphical representation of it (thus fulfilling ORP), like so

// Angelscript
class Avatar
{
    Character@ Char;
    MeshSceneNode@ armour;
    MeshSceneNode@ helmet;
 
 
    Avatar(Character@ char)
    {
        @Char = char;
        helmet = Scene.CreateMesh("helmet_steel.obj");
        armour = Scene.CreateMesh("armour_steel.obj");
    }
    ~Avatar()
    {
        Scene.DestroyMesh(helmet);
        Scene.DestroyMesh(armour);
    }
}
class Character
{
    Avatar@ avatar;
    
}

 

Now the problem is, when the game shuts down the player is obviously destroyed, but when Scene::DestroyMesh is called, it complains that the meshes passed in are null pointers. Why?


#3hupsilardee

Posted 06 May 2013 - 12:40 PM

Hi all, I've been using Angelscript in my project with great success so far, except this one weird bug.

 

I have bound my MeshSceneNode class to the scripting engine for scripting. It can only be created/destroyed by using the Scene interface (which appears as a singleton to the script)

// C++
assert(0 <= engine->RegisterObjectType("MeshSceneNode", sizeof(MeshSceneNode), asOBJ_REF | asOBJ_NOCOUNT));
assert(0 <= engine->RegisterObjectMethod("CScene", "MeshSceneNode@ CreateMesh(const string &in)", asMETHOD(Scene, AddMesh), asCALL_THISCALL));

    assert(0 <= engine->RegisterObjectMethod("CScene", "void DestroyMesh(MeshSceneNode@)", asMETHOD(Scene, DestroyMesh), asCALL_THISCALL));

I made a Character class in script, and made an Avatar subclass to handle graphical representation of it (thus fulfilling ORP), like so

// Angelscript
class Avatar
{
    Character@ Char;
    MeshSceneNode@ armour;
    MeshSceneNode@ helmet;
 
 
    Avatar(Character@ char)
    {
        @Char = char;
        helmet = Scene.CreateMesh("helmet_steel.obj");
        armour = Scene.CreateMesh("armour_steel.obj");
    }
    ~Avatar()
    {
        Scene.DestroyMesh(helmet);
        Scene.DestroyMesh(armour);
    }
}
class Character
{
    Avatar@ avatar;
    
}

 

Now the problem is, when the game shuts down the player is obviously destroyed, but when Scene::DestroyMesh is called, it complains that the meshes passed in are null pointers. Why?


#2hupsilardee

Posted 06 May 2013 - 12:37 PM

Hi all, I've been using Angelscript in my project with great success so far, except this one weird bug.

 

I have bound my MeshSceneNode class to the scripting engine for scripting. It can only be created/destroyed by using the Scene interface (which appears as a singleton to the script)

 

 

// C++
assert(0 <= engine->RegisterObjectType("MeshSceneNode", sizeof(MeshSceneNode), asOBJ_REF | asOBJ_NOCOUNT));
assert(0 <= engine->RegisterObjectMethod("CScene", "MeshSceneNode@ CreateMesh(const string &in)", asMETHOD(Scene, AddMesh), asCALL_THISCALL));

    assert(0 <= engine->RegisterObjectMethod("CScene", "void DestroyMesh(MeshSceneNode@)", asMETHOD(Scene, DestroyMesh), asCALL_THISCALL));

 

I made a Character class in script, and made an Avatar subclass to handle graphical representation of it (thus fulfilling ORP), like so

 

 

// Angelscript
class Avatar

{
    Character@ Char;
    MeshSceneNode@ armour;
    MeshSceneNode@ helmet;
 
 
Scene.CreateMesh("helmet_steel.obj");

}
class Character

{
    Avatar@ avatar;

}

 

Now the problem is, when the game shuts down,

 

EDIT: sorry, incomplete post. Currently editing...


#1hupsilardee

Posted 06 May 2013 - 12:37 PM

Hi all, I've been using Angelscript in my project with great success so far, except this one weird bug.

 

I have bound my MeshSceneNode class to the scripting engine for scripting. It can only be created/destroyed by using the Scene interface (which appears as a singleton to the script)

 

// C++
assert(0 <= engine->RegisterObjectType("MeshSceneNode", sizeof(MeshSceneNode), asOBJ_REF | asOBJ_NOCOUNT));
assert(0 <= engine->RegisterObjectMethod("CScene", "MeshSceneNode@ CreateMesh(const string &in)", asMETHOD(Scene, AddMesh), asCALL_THISCALL));

    assert(0 <= engine->RegisterObjectMethod("CScene", "void DestroyMesh(MeshSceneNode@)", asMETHOD(Scene, DestroyMesh), asCALL_THISCALL));

 

I made a Character class in script, and made an Avatar subclass to handle graphical representation of it (thus fulfilling ORP), like so

 

// Angelscript
class Avatar

{
    Character@ Char;
    MeshSceneNode@ armour;
    MeshSceneNode@ helmet;
 
 
Scene.CreateMesh("helmet_steel.obj");

}
class Character

{
    Avatar@ avatar;

}

 

Now the problem is, when the game shuts down,


PARTNERS