ivansafrin/Polycode — Issue #50: LUA bindings break on addPhysicsChild() with an ENTITY_MESH
Author: mcclure
Created: 2011-11-24 20:01:03+00:00
State: open

Context: As described in issue #49, I had trouble creating a ScreenMesh. I tried to work around the problem with initializing ScreenMesh by creating (with a C++ polycode program) a mesh file for a totally empty mesh; then I tried loading that and operating on it. This part worked, but...

```screen = PhysicsScreen(10, 60)
screen:setGravity( Vector2( 0,0 ) )
polygon = Polygon()
for i=0,2 do
local theta = i/3 * 2 * math.pi
polygon:addVertex(math.sin(theta),math.cos(theta),0)
end
shape = ScreenMesh("blankmesh.dat")
shape:getMesh():addPolygon(polygon)
shape:setColor(0.0,0.0,0.0,1.0)
shape:setPosition(640/2, 400)
screen:addPhysicsChild(shape, ENTITY_MESH, false)```

So look, I load the blank mesh, then add (what I hope to be) one triangle to it.

When I run this I get:

````11/18/11 11:37:36 PM	[0x0-0x2b2cb2a].PolycodePlayer[26794]	Opened entrypoint file...Tried to make a mesh collision object from a non-mesh````

When I look in PolyPhysicsScreenEntity.cpp I find this outcome is possible only if dynamic_cast(entity) fails (where entity comes from the first argument to addPhysicsChild()). This looks like a LUA problem; I am passing in what should definitely be a ScreenMesh, but C++ is not recognizing it as such.

Ivan says "sounds like a pointer casting issue with the bindings".

Note, this was with a PolycodePlayer I built myself, as described in issue #48. I doubt this could be the problem though.