blender-cod icon indicating copy to clipboard operation
blender-cod copied to clipboard

calc_tessface was removed from Mesh API in Blender 2.80

Open BTOdell opened this issue 3 years ago • 4 comments

calc_tessface has been removed as of Blender 2.80

https://wiki.blender.org/wiki/Reference/Release_Notes/2.80/Python_API/Mesh_API

I'm not familiar at all yet with the Blender Python API so I'm still trying to figure out what this actually does and what the equivalent functions would be...

Python: Traceback (most recent call last):
  File "C:\Users\xxx\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\io_scene_cod\__init__.py", line 610, in execute
    result = export_xmodel.save(self, context,
  File "C:\Users\xxx\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\io_scene_cod\export_xmodel.py", line 382, in save
    result = save_model(self, context, filepath,
  File "C:\Users\xxx\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\io_scene_cod\export_xmodel.py", line 485, in save_model
    mesh_triangulate(mesh, use_vertex_cleanup)
  File "C:\Users\xxx\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\io_scene_cod\export_xmodel.py", line 49, in mesh_triangulate
    mesh.update(calc_tessface=True)
TypeError: Mesh.update(): was called with invalid keyword argument(s) (calc_tessface), expected (calc_edges, calc_edges_loose)

BTOdell avatar Jan 25 '22 07:01 BTOdell

If I remember correctly, then it computed triangles and quads from polygon meshes. Faces in Blender can have 3, 4, or more vertices but they need to be turned into triangles for Call of Duty. Tessfaces were an easy way to mostly get there. As they are either triangles or quads, the addon code takes care of turning the quads into triangles as well. So the end result is a triangulated mesh.There seems to be a drop-in replacement, loop_triangles:https://wiki.blender.org/wiki/Reference/Release_Notes/2.80/Python_API/Mesh_API

CoDEmanX avatar Jan 25 '22 09:01 CoDEmanX

Yes, I converted the code to use loop_triangles in my fork (see PR #32). Although, I am worried about the tessface_vertex_colors also being removed from the Mesh API. I changed it to just vertex_colors but I don't think that's an equivalent field. It may require additional transforms to get the vertex colors of the "loop triangles".

BTOdell avatar Jan 25 '22 10:01 BTOdell

If memory serves, CoD2 supported vertex colors on map geometry, but not the later titles (CoD4/5). Not sure if it did for models too. The vertex colors were otherwise only used for carrying information for vertex shader effects, such as the wave shader. The colors aren't really used as colors in that case. Rather as weights, to move heavier vertices less and lighter vertices more in the wind for a realistic flag animation. Although, I can't tell for sure how that shader uses the code values as I've never seen its source code.

CoDEmanX avatar Jan 25 '22 21:01 CoDEmanX

If memory serves, CoD2 supported vertex colors on map geometry, but not the later titles (CoD4/5). Not sure if it did for models too. The vertex colors were otherwise only used for carrying information for vertex shader effects, such as the wave shader. The colors aren't really used as colors in that case. Rather as weights, to move heavier vertices less and lighter vertices more in the wind for a realistic flag animation. Although, I can't tell for sure how that shader uses the code values as I've never seen its source code.

This is correct for CoD 5 at least. Trees, etc. used vertex colors as weights for the vertex shaders that were used to animate them if I remember correctly.

SE2Dev avatar Jan 26 '22 00:01 SE2Dev