[Verse-dev] deleting a vertex

eskil at obsession.se eskil at obsession.se
Wed May 2 01:51:59 CEST 2007


Hi

> Do I ever need to delete a vertex? Surely I only need to buffer a face out of
> the draw list until that slot is used again in a subsequent set_vertex call
> with that id?

not 100% sure what you mean... But:

It would be easy to thing that it is unnecessary to delete a vertex  
when verse tells you to do so. You may think whats the problem if i  
store a vertex that inst used? The problem is that it may be used.

If you have polygon that used vertex 1, 2, and 3, and then someone  
deletes vertex 3 the polygon will be invalid, until some one  
re-creates vertex 3 or changes the polygons reference to reference a  
vertex that do exist. So you need to some how store the fact that  
there is no vertex #3, either by storing the vertex with some sort of  
flag or by not storing it at all.

Verse is optimizes so that you should be able to store you vertices in  
arrays, so since you can delete vertices you may get holes in those  
arrays. in order make sure you don't need to store an extra array of  
Boolean jut to know if the verices are there or not we have reserved  
the max value as invalid, so you can use that as deleted. you can find  
them in verse.h as V_REAL64_MAX or V_REAL32_MAX (depending on if you  
subscribe to vertices as floats or doubles)

in my code i usually store av vertices in one long array, and then all  
reference data in an array where each group of four integer values is  
one polygon. So the correct way of figuring out if polygons are valid  
would look like this:

for(i = 0; i < poly_count * 4; i += 4)
{
     if(ref[i] < vertex_count &&
         ref[i + 1] < vertex_count &&
         ref[i + 2] < vertex_count &&
         vertex[ref[i] * 3] != V_REAL32_MAX &&
         vertex[ref[i + 1] * 3] != V_REAL32_MAX &&
          vertex[ref[i + 2] * 3] != V_REAL32_MAX)
     {
         if(ref[i + 3] < vertex_count &&
             vertex[ref[i + 3] * 3] != V_REAL32_MAX)
             printf("quad %u %u %u\n",
             ref[i], ref[i + 1], ref[i + 2], ref[i + 3]);
         else
             printf("tri %u %u %u\n",
                 ref[i], ref[i + 1], ref[i + 2]);
     }
}

It is a common misstake to think that references (of any kind) in  
verse is garanteed to point at something that exists/isnt out of  
bounds/is of the right type. You need to check the data yourself. I  
hope it helped.

Cheers

E






More information about the Verse-dev mailing list