Yesterday I started experimenting to see if we can get rid of the Marshal stuff, and I beleive is possible, check this out
- Code: Select all
m_body.AddForce(new dVector(1.0f, 2.0f, 3.0f));
m_body.AddForce(m_forceAcc.x, m_forceAcc.y, m_forceAcc.z);
before we had a marshall command that copy the data to a local memory buffer, that that very ugly and now that we start adding more objects, the constructors star to get more complicatted because the lack of strong types.
so I thougth that the reason we can not pass a reference is because the object live on c# memory manager and we have to make a copy. the Mashall command make a memory buffer some where and copy that data, but in addition of the being ugly it can't be efficient either because it will trash memory in the long run.
The solution is to pass object by value, basically make a copy of the objet on eh stack and pass the entire object. C# we you make a local
my firs try I make the sing function that passed the atomic member of the vector, the first function I m passing the complete vector and it seems to work.
I will try wit the matrices and of it work we can remove the marshall for many place and use constructors that take data with actual type rather than void pointers of float pointers.