Jump to content

  • Log In with Google      Sign In   
  • Create Account

DavidColson

Member Since 18 Nov 2013
Offline Last Active Jul 31 2015 03:00 PM

Posts I've Made

In Topic: Returning an existing userdata in __index metamethod (Lua)

08 July 2015 - 03:47 PM

I can see the need to simplify and maybe change my approach to things. It's a little disappointing, but I may have gone into lua with the wrong mindset.


In Topic: Returning an existing userdata in __index metamethod (Lua)

08 July 2015 - 11:13 AM

It's hardly overengineering to want to be able to do this is it?

transform.position.x = 10

Is there really no way for the position getter to return a reference to the same data?


In Topic: Returning an existing userdata in __index metamethod (Lua)

08 July 2015 - 05:10 AM

I tried something like this:

static int TransformGet(lua_State* L)
{
	if (luaL_checkudata(L, 1, "Transform") == NULL)
	{
		luaL_typerror(L, 1, "Transform");
	}
	Transform* trans = (Transform*)lua_touserdata(L, 1);

	const char* key = luaL_checkstring(L, 2);

	if (strcmp(key, "Position") == 0)
	{
		lua_pushlightuserdata(L, (void*)&trans->Position);
		luaL_getmetatable(L, "Vector3");
		lua_setmetatable(L, -2);
	}
        
        return 1;
}

But sadly it did not work. I get this error from Lua:

LuaSource/main.lua:26: bad argument #1 to '__newindex' (Vector3 expected, got userdata)

In Topic: Edge artifact with basic diffuse shading

02 July 2015 - 04:27 PM

 

Looks like you have face-culling disabled and the depth-buffer precision isn't enough to avoid Z-fighting at the edges.

Create a 24-bit depth-buffer, or increase the distance to your near-plane in the projection matrix, like changing 0.01 to

 

Its implicit here, but you should enable face culling if you dont need it to be disabled, as well. At least this particular scene does not need it disabled, assuming the cube meshes are defined correctly (counterclockwise order defined triangle vertices)

 

 

Yea I had it on out of laziness. I've disabled it in the last screenshot I posted.


In Topic: Edge artifact with basic diffuse shading

02 July 2015 - 11:00 AM

Looks like you have face-culling disabled and the depth-buffer precision isn't enough to avoid Z-fighting at the edges.

Create a 24-bit depth-buffer, or increase the distance to your near-plane in the projection matrix, like changing 0.01 to 0.1 or even 1.

 

That did the trick! Thank you so much!

 

WUuaXhM.png


PARTNERS