[Bf-committers] custom face data progress

Brecht Van Lommel brechtvanlommel at pandora.be
Sat Jul 1 23:21:10 CEST 2006


Hey all,

I've made a patch of the current state of the custom vertex/edge/face data code
I'm working on. It's not ready for inclusion, but making a patch at least forced
me to fix the most important things, and get something workable.

Currently there's only support for face layers, like uvs and vertex colors.
Vertex, edge, and groups support will be added later. The patch is already
growing much too large with changes all over the code (+6006 -6283 lines of
code).

There will also be quite some collision with the modifier and sculpt SoC projects,
so maybe merging should be pushed back to not put Nicholas and Ben in CVS
merge hell :).

So, here's the current status.

Elem Data API:
- In BKE_elemdata.h, elemdata.c and DNA_elemdata_types.h.
- Docs will follow.

Interface:
- Can set the active uv and color layers in the editing buttons, mesh panel.
- Made the a1 in uiDefBut MENU be an option for sorting the menu items, to avoid
   code duplication.

Multiple uv and color layers:
- MCol is now always stored separately, never in TFace.
- TFace has been split into UFace, containing uvs and uv selection flags, and
   GFace, containing game engine flags and the texture image. This was done
   to potentially allow for different images with the same uvs, and for custom
   materials with pluggable game engines.
- This means that TFace shouldn't be used anywhere in the code.
- Forward compatibility was broken for uvs and vertex colors. This seemed the
   best solution due to some DNA issues with restoring the colors from TFace.

EditMesh:
- Almost all tools have been modified for custom face data support, still todo:
- new uv merge code
- select face group based on image
- edge_rotate had quite some code changes.

Modifier Stack:
- All face data preserved, except for modifiers that didn't support this before.

Booleans:
- Made some deep changes to the way face data is preserved here.
- Removed some files from old bsp module. Didn't want to update unused boolean
   code that gives inferior results anyway. Also cleaned up booleanops.c some.
- Side note: the boolean code seems quite slow on larger meshes, _before_ it
   does the actual intersection. This may be due to the .push_back calls on
   stl::vector, which I guess comes down to alloc and copy of the whole array
   for each vert/edge/face added, so bad O(n^2) behaviour. Better to use .reserve.

Game engine:
- Mostly changes done to replace TFace with UFace and GFace.
- Needs game engine coder to review.
- Doesn't take advantage of multiple uv sets yet, but it's already possible
   through python in the game engine, so shouldn't be too hard.

Python:
- Only tried to add backwards compatibility now, in Mesh and NMesh. Code is
   untested still.
- Needs API to deal with multiple uvs and vertex colors.
- I removed the "smart compaction" in delete_faces, Mesh.c. It's complicated
   code to add custom face data to, and I doubt if it makes any difference Also
   the duplicated eeek_fix I removed. If there's a good reason I can add these
   back.
- I've made NMESH_HASFACEUV check for both UFace and GFace. That
   makes the name inaccurate, but gives backwards compat.

Radiosity:
- All face data preserved.
- Radiosity colors are now saved in a vertex color layer named "radio".
- rad_addmesh was changed quite a bit, also dropping ancient 32000 vertex
   limit.

Renderer:
- Has support for multiple uv and color layers.
- Code changes here were not very nice, will rewrite this part of the patch.
   Mostly a good system for detecting which uv and color layers are used, and a
   way to look them quickly up is needed. Now e.g. uses strcmp's to find the uv
   and color layers for each pixel.
- Similar to vertnodes, vlaknodes was added to support adding custom data to
   faces.
- Specifying a uv or color layer in a material or nodes is done by typing the
   name in a text field. Need to think about the best way to do this, because a
   simple menu dropdown won't work.
- TexFace, VCol Paint/Light and tangent vectors for materials use the active
   uvs and vertex colors now. Maybe it should be possible to choose the layer
   for this too?
- Yafray uses the active uv and color layers, code here is untested even.
- Bug: preview and fastshade aren't always loading uv and color layers
   correctly.
- Added a vertex color node for materials, should allow for some nice
   possibilities.

Patch here:
http://users.pandora.be/blendix/customfacedata_patch.zip

Brecht.



More information about the Bf-committers mailing list