Getting Garbage Object.

Started by
2 comments, last by PhilCK 9 years, 10 months ago

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
}
Advertisement


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.

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

Yeah that was the issue so simple :/ Thanks.

This topic is closed to new replies.

Advertisement