Game Development Community

Removing hidden verts?

by Lee Latham · in Artist Corner · 10/20/2008 (12:13 am) · 8 replies

Do hidden verts/faces matter when exporting to DTS?

Reason being is I'm making some high-ish poly objects for my game in Blender, and in the course of construction many, many verts are being hidden in places where it would be highly problematic to manually go in and remove them. It would be nice to get rid of them automatically, since I presume they would be taking up memory and cpu from the game for no purpose whatever.

Am I wrong? And is there an easy way to do it?

#1
10/20/2008 (7:17 am)
...
#2
10/20/2008 (7:57 am)
Yes vertexes will add to the model complexity if they are attached to an edge. If they are just free floating vertexes you can easily remove them by the "remove unused vertex" function

And removal of surplus vertexes that are connected to edges (and the removal of edges and polygons) is part of the final optimization of any good modeling artist.
#3
10/20/2008 (10:49 pm)
Thanks y'all. And thanks as usual for going to so much trouble to explain, JG. It seems obvious now, so it must be brilliant. ;-)

Too bad about no automatic tool, though. Some of my models have gotten pretty complex. For example, I have a pile of spheres that was created by dropping them from the sky in soft body mode. So now I've got a very interesting, comlex, 3d place for my players to run around in.

Polysoup collision!

I just had to shout that, sorry.

Anyway, as you can imagine a lot of them are kinda glommed together, hiding verts. And frankly I'm testing the upper limits of what the engine can handle on the target platform in this level...pushing 60k faces, and I think that's gonna have to do it.

It's times like this that I wish I could "run around" in the model in Blender, to get a lot of those external verts selected in the interior of the pile of spheres.
#4
10/20/2008 (11:03 pm)
Just for grins, here's a couple screenies to illustrate the point (still in a rough state--work in progress):

www.singularityfps.com/images/tree10.jpg
www.singularityfps.com/images/tree11.jpg
#5
10/21/2008 (7:48 am)
...
#6
10/21/2008 (2:57 pm)
Lol...for the first time Blender has failed me as a miracle worker. I can't believe that careful, tedious work has any role in game creation LOLZ :-)
#7
11/02/2008 (1:22 am)
You could try the "rem Doubl" in edit mode after selecting the whole model...that will remove any verts that are duplicated.

As for the "occlude background geom" that Joseph posted, this should work if you have 1 mesh, but if you have 2 or more meshes that intersect each other it wont, unless you perform it on each mesh individually.
I actually posted this method as a bug report in the blender bug tracker, but apparently the way that blender draws it's geometry doesn't allow this.

Quote from Ton (Head Dev. and founder of the Blender Foundation)

"it's the fact that for editmode selection we draw the active object totally separated in a selection buffer, so you can always select things. It's a convention that doesn't always work as expected, but it does make drawing selection buffers fast and predictable"

You can read the bug report Here

hope that helps :)
#8
11/02/2008 (8:40 am)
I know nothing about blender,
but one could imagine a script to automate this.

// pseudo-code to simplify a model by removing unseen vertices and polygons
   // by raycasting from the vertices to a given set of eye points.
   // note that even if a vertex is unseen, it's only safe to remove it
   // if all the vertices in all polygons containing it are also unseen.


   eyePoints = a user-selected list of points in space
               which define everywhere the model might be viewed from.
   verts     = the list of model vertices
   polygons  = the list of model polygons, specified as indices into verts.
   
   // step 1: mark each vertex as visible or not
   for (n = 0; n < verts.length; n++)
   {
      vert         = verts[n];
      vert.visible = false;
      vert.remove  = true;      // we'll come back to this in step 3.
      
      // raycast from this vertex to all eyePoints.
      // if the raycast is unobstructed for any of them, the vertex is visible.
      for (m = 0; m < eyePoints.length && !vert.visible; m++)
      {
         eyePoint = eyePoints[m];
         if (raycast(vert, eyePoint) is unobstructed)
            vert.visible = true;
      }
   }
   
   // step 2: mark each polygon as visible or not
   for (n = 0; n < polygons.length; n++)
   {
      polygon         = polygons[n];
      polygon.visible = false;
      for (m = 0; m < polygon.vertices.length && !polygon.visible; m++)
      {
         if (polygon.vertices[m].visible)
            polygon.visible = true;
      }
   }
   
   // step 3: remove polygons and mark which vertices not to remove
   for (n = polygons.length - 1; n >= 0; n--)
   {
      polygon = polygons[n];
      if (polygon.visible)
      {
         for (m = 0; m < polygon.vertices.length; m--)
         {
            vertices[m].remove = false;
         }
      }
      else
      {
         polygons.removeEntry(n);      // actually remove the polygon
      }
   }

   // step 4: remove vertices
   for (n = vertices.length - 1; n >= 0; n--)
   {
      vert = vertices[n];
      if (vert.remove)
      {
         vertices.remove(n);      // actually remove the vertex
      }
   }