Sign in to follow this  
PhilCK

Getting Garbage Object.

Recommended Posts

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

Share this post


Link to post
Share on other sites


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.

Share this post


Link to post
Share on other sites

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).

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