C++/BMX question
BlitzMax Forums/BlitzMax Programming/C++/BMX question
| ||
This is my C++ function. I call this from BlitzMax and my C++ library fills in the pick values, if something is picked:int EntityRaycast(Leadwerks3D::Entity* entity, float x0, float y0, float z0, float x1, float y1, float z1, float* pick, float radius, int closest, int recursive) { Leadwerks3D::Pick p; bool result; result = entity->Raycast(Leadwerks3D::Vec3(x0,y0,z0),Leadwerks3D::Vec3(x1,y1,z1),p,radius,closest,recursive); if (result) { pick[0] = p.position.x; pick[1] = p.position.y; pick[2] = p.position.z; pick[3] = p.normal.x; pick[4] = p.normal.y; pick[5] = p.normal.z; memcpy(&pick[6],&p.entity,4); memcpy(&pick[7],&p.surface,4); memcpy(&pick[8],&p.face,4); memcpy(&pick[9],&p.triangle,4); } return result; } This is the raycast/pick structure in C++: class Pick { public: Vec3 position; Vec3 normal; Entity* entity; Surface* surface; Face* face; int triangle; }; This is the structure in BlitzMax: Type TRaycast Field x:Float,y:Float,z:Float Field nx:Float,ny:Float,nz:Float Field entity:LEEntity Field surface:LESurface Field face:LEFace Field triangle:Int EndType Am I doing this right? I suspect I am causing memory overwrite errors. Last edited 2012 |
| ||
Bah, I was passing a NULL BMX object to the function. X\ It works fine now. |