[ODE] ODE .NET

Manox manoxik at seznam.cz
Mon Jun 11 00:20:58 MST 2007


Jon Watte (ODE) napsal(a):
> Those are managed arrays. Managed arrays can move around in memory. 
> From what I understand, you need to pin those arrays for the duration 
> of the geom lifetime.
>
> Cheers,
>
>          / h+
>
>
> Manox wrote:
>> Jason Perkins napsal(a):
>>  
>>> On 6/8/07, Manox <manoxik at seznam.cz> wrote:
>>>    
>>>> When I use trimesh geom, it throws : AccesViolationException - 
>>>> Attempted
>>>> to read or write protected memory ....
>>>>       
>>> Be sure that you are keeping a reference to your mesh data in your
>>> .NET code, otherwise it will get garbage collected. Sounds to me like
>>> that is what is happening.
>>>
>>> HTH,
>>>
>>> Jason
>>>
>>>     
>> No, I have class
>>
>> public class PhysicsSolver : IDisposable
>>   {
>>    ..
>>     double[] vrcholy;
>>     int[] indices;
>>     IntPtr temp;
>> ...
>>
>> Function
>>
>> public unsafe uint AddStaticBody(float[] data)
>>     {
>>       int count = data.Length / 10;
>>
>>       vrcholy = new double[count * 9];
>>       indices = new int[count * 3];
>>
>>       for (int i = 0; i < count; i++)
>>       {
>>         vrcholy[9 * i] = data[10 * i + 1];
>>         vrcholy[9 * i + 1] = data[10 * i + 3];
>>         vrcholy[9 * i + 2] = data[10 * i + 2];
>>
>>         vrcholy[9 * i + 3] = data[10 * i + 4];
>>         vrcholy[9 * i + 4] = data[10 * i + 6];
>>         vrcholy[9 * i + 5] = data[10 * i + 5];
>>
>>         vrcholy[9 * i + 6] = data[10 * i + 7];
>>         vrcholy[9 * i + 7] = data[10 * i + 9];
>>         vrcholy[9 * i + 8] = data[10 * i + 8];
>>
>>         indices[3 * i] = (3 * i);
>>         indices[3 * i + 1] = (3 * i + 1);
>>         indices[3 * i + 2] = (3 * i + 2);
>>       }
>>
>>       tricall = new d.TriCallback(TriCallback);
>>       raycall = new d.TriRayCallback(TriRayCallback);
>>       arraycall = new d.TriArrayCallback(TriArrayCallback);
>>
>>       temp = d.GeomTriMeshDataCreate();
>>
>>       d.GeomTriMeshDataBuildDouble(temp, vrcholy, 24, vrcholy.Length 
>> / 3, indices, indices.Length, 12);
>>       d.GeomTriMeshDataPreprocess(temp);
>>
>>       geom = d.CreateTriMesh(this._space, temp, tricall, arraycall, 
>> raycall);
>>
>>       return AddStaticBody(geom);
>>     }
>>
>> and coliision function. I don't call any Dispose, and data are 
>> defined in class. I don't see any reason for garbage collector.
>>
>> The problem is in memory, but I don't know where :-(
>> _______________________________________________
>> ODE mailing list
>> ODE at ode.org
>> http://ode.org/mailman/listinfo/ode
>>
>>
>>   
>

Hi,

I changed it to :

fixed (double* vertexs = vrcholy)
      fixed (int* iindices = indices)
      {
        {
          for (int i = 0; i < count; i++)
          {
            vertexs[9 * i] = data[10 * i + 1];
            vertexs[9 * i + 1] = data[10 * i + 3];
            vertexs[9 * i + 2] = data[10 * i + 2];

            vertexs[9 * i + 3] = data[10 * i + 4];
            vertexs[9 * i + 4] = data[10 * i + 6];
            vertexs[9 * i + 5] = data[10 * i + 5];

            vertexs[9 * i + 6] = data[10 * i + 7];
            vertexs[9 * i + 7] = data[10 * i + 9];
            vertexs[9 * i + 8] = data[10 * i + 8];

            iindices[3 * i] = (3 * i);
            iindices[3 * i + 1] = (3 * i + 1);
            iindices[3 * i + 2] = (3 * i + 2);
          }

        ...

          Ivertexs = new IntPtr(vertexs);
          IIndices = new IntPtr(iindices);

          d.GeomTriMeshDataBuildDouble(temp, Ivertexs, 24, 
vrcholy.Length / 3, IIndices, indices.Length, 12);

and the error is the same :-(


I need only vehicle simulation, don't you know about some vehicle 
physics tutorial ? I found nothing :-(. I'm working on this over 2 
months, I tried different ODE wrappers and always I have same errors :-(.

I wanted make my own vehicle physics, but I can't find any tutorial. I 
have my own integrators, collision detection, but I have problem with 
suspensions and joints.

Marek


More information about the ODE mailing list