[ODE] ODE .NET

Manox manoxik at seznam.cz
Fri Jun 8 05:22:49 MST 2007


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 :-(


More information about the ODE mailing list