[ODE] New release?

Lode Vanacken lode.vanacken at uhasselt.be
Wed Dec 27 06:57:11 MST 2006


Lode Vanacken wrote:

>I think that GIMPACT believes that the stride is always 3. I discovered 
>this when stepping
>through the creation code, but did not have the time to look at the 
>difference with Opcode.
>I will try to take a deeper look tomorrow after X-mas.
>
>  
>

The problem resides in the fact that gimpact does indeed presume a 
stride of 3.

When the data gets linked to a trimesh in dxTriMesh constructor the 
following function is called:

gim_trimesh_create_from_data(&m_collision_trimesh,( vec3f 
*)(&Data->m_Vertices[0]), Data->m_VertexCount ,0, ( GUINT 
*)(&Data->m_Indices[0]), Data->m_TriangleCount*3,0,1);

There is no easy solution at hand here. I tried the following changes:

- float * cast, vertexstride as parameter:

gim_trimesh_create_from_data(&m_collision_trimesh,( float 
*)(&Data->m_Vertices[0]), Data->m_VertexCount , Data->m_VertexStride, 0, 
( GUINT *)(&Data->m_Indices[0]), Data->m_TriangleCount*3,0,1);

But then we get into trouble inside the function:

//Create vertices
    if(copy_vertices == 1)
    {
        gim_create_common_buffer_from_data(vertex_array, 
vertex_count*sizeof(vec3f), &buffer_vertex_array.m_buffer_id);
    }
    else//Create a shared buffer
    {
        gim_create_shared_buffer_from_data(vertex_array, 
vertex_count*sizeof(vec3f), &buffer_vertex_array.m_buffer_id);
    }
    
GIM_BUFFER_ARRAY_INIT_TYPE(vec3f,buffer_vertex_array,buffer_vertex_array.m_buffer_id,vertex_count);

The first part can easily be changed:

 if(copy_vertices == 1)
    {
        gim_create_common_buffer_from_data(vertex_array, 
vertex_count*vertexStride, &buffer_vertex_array.m_buffer_id);
    }
    else//Create a shared buffer
    {
        gim_create_shared_buffer_from_data(vertex_array, 
vertex_count*vertexStride, &buffer_vertex_array.m_buffer_id);
    }

But the last line, the first parameter decides the stride. The problem 
is here that it is not possible to define the stride when having
the amount of bytes, it seems that you need to have a structure on which 
a sizeof is performed, there is no other way around this.
So I decided to just copy the macro into the function:

(buffer_vertex_array).m_buffer_id.m_buffer_id = 
(buffer_vertex_array.m_buffer_id).m_buffer_id;
    (buffer_vertex_array).m_buffer_id.m_buffer_manager_id = 
(buffer_vertex_array.m_buffer_id).m_buffer_manager_id;
    (buffer_vertex_array).m_buffer_data = 0;
    (buffer_vertex_array).m_element_count = vertex_count;
    (buffer_vertex_array).m_byte_stride = vertexStride;
    GIM_BUFFER_ARRAY_SET_OFFSET(buffer_vertex_array,0);
    gim_buffer_add_ref(&(buffer_vertex_array.m_buffer_id));

When running this code it does not work, although it does seem to create 
everything correctly. I can't seem to find what goes wrong.
Maybe the above can help someone else in finding what is still wrong or 
a more clever solution to the stride problem.

Lode


More information about the ODE mailing list