Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

Getting Garbage Object.

  • You cannot reply to this topic
3 replies to this topic

#1 PhilCK   Members   -  Reputation: 127

Like
0Likes
Like

Posted 21 June 2014 - 05:15 AM

Hello,

Firstly AS is very cool, I was surprised how easy it was to get going.

I've got an issue with a member function that I'm trying to export, Im running it through a free-function so I can convert the vec3 from the AS one to the C++ one. (This is unfortunately necessary as the engine hasn't been completely turned over to the newer one.

But the component object comes out as garbage, but all other methods are fine

 // These all work fine.
r = engine->RegisterObjectType("CameraComponent", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
r = engine->RegisterObjectBehaviour("Component", asBEHAVE_REF_CAST, "CameraComponent@ f()", asFUNCTION((ASHelper::refCast<CaffEnt::Component, CaffComp::CameraComponent>)), asCALL_CDECL_OBJLAST); assert(r >= 0);
r = engine->RegisterObjectMethod("CameraComponent", "void makeActiveCamera()", asMETHOD(CaffComp::CameraComponent, makeActiveCamera), asCALL_THISCALL); assert(r >= 0);
r = engine->RegisterObjectMethod("CameraComponent", "bool isActive() const", asMETHOD(CaffComp::CameraComponent, isActive), asCALL_THISCALL); assert(r >= 0);
r = engine->RegisterObjectMethod("CameraComponent", "void setFOV(const uint)", asMETHOD(CaffComp::CameraComponent, setFOV), asCALL_THISCALL); assert(r >= 0);

// This gives rubbish for the camera component.
r = engine->RegisterObjectMethod("CameraComponent", "void setLookAt(const Vec3 &in) const", asFUNCTION(CaffGlue::Comp::SetLookAt), asCALL_CDECL_OBJLAST); assert(r >= 0);
// Free func glue.
void SetLookAt(const CaffMath::Vector3 vec3, CaffComp::CameraComponent *camera)

What am I doing wrong?


The AS code as well
 

@camera = cast<CameraComponent@>(getOwner().getComponent("CameraComponent"));

if(camera !is null)
{
	camera.makeActiveCamera(); // works

	Vec3 lookat = {0.1f,0.1f,0.1f};
	camera.setLookAt(lookat); // does not
}

Edited by PhilCK, 21 June 2014 - 05:21 AM.


Sponsor:

#2 Juliean   GDNet+   -  Reputation: 2247

Like
0Likes
Like

Posted 21 June 2014 - 06:04 AM


void SetLookAt(const CaffMath::Vector3 vec3, CaffComp::CameraComponent *camera)

 

One thing I noticed is that your declaration says "const Vec3& in" while here it's pass by value instead of reference. This is certain to make problems unless its just a typo while copying the code over here, but not sure if it also relates to the actual problem of yours.



#3 Andreas Jonsson   Moderators   -  Reputation: 3241

Like
0Likes
Like

Posted 21 June 2014 - 07:26 AM

I'd say Juliean is right.

 

If fixing that doesn't help then I'll need to know a little more about how you've registered your CaffMath::Vector3 type, and what platform you're working on (as the ABI varies).


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

#4 PhilCK   Members   -  Reputation: 127

Like
0Likes
Like

Posted 21 June 2014 - 09:14 AM

Yeah that was the issue so simple :/ Thanks.







PARTNERS