Skip to content

Commit

Permalink
ISSUE-17: fix tangents having signed bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
Brachi committed Jun 4, 2017
1 parent ecf7dc2 commit 2b08d88
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
16 changes: 8 additions & 8 deletions albam/engines/mtframework/mod_156.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ class VertexFormat0(Structure):
('normal_y', c_ubyte),
('normal_z', c_ubyte),
('normal_w', c_ubyte),
('tangent_x', c_byte),
('tangent_y', c_byte),
('tangent_z', c_byte),
('tangent_w', c_byte),
('tangent_x', c_ubyte),
('tangent_y', c_ubyte),
('tangent_z', c_ubyte),
('tangent_w', c_ubyte),
('uv_x', c_ushort), # half float
('uv_y', c_ushort), # half float
('uv2_x', c_ushort), # half float
Expand All @@ -258,10 +258,10 @@ class VertexFormat(Structure):
('normal_y', c_ubyte),
('normal_z', c_ubyte),
('normal_w', c_ubyte),
('tangent_x', c_byte),
('tangent_y', c_byte),
('tangent_z', c_byte),
('tangent_w', c_byte),
('tangent_x', c_ubyte),
('tangent_y', c_ubyte),
('tangent_z', c_ubyte),
('tangent_w', c_ubyte),
('uv_x', c_ushort), # half float
('uv_y', c_ushort), # half float
('uv2_x', c_ushort), # half float
Expand Down
16 changes: 9 additions & 7 deletions tests/mtframework/test_mod156_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def test_meshes_array_immutable_fields(mod156_original, mod156_exported):

def test_mesh_vertices(request, mod156_mesh_original, mod156_mesh_exported):
FAILURE_RATIO = 0.15
TANGENT_LIMIT = 20

mod_original = mod156_mesh_original._parent_structure
mod_exported = mod156_mesh_exported._parent_structure
Expand Down Expand Up @@ -164,10 +165,10 @@ def test_mesh_vertices(request, mod156_mesh_original, mod156_mesh_exported):
check_normal(vertex_index, vertex_ori.normal_w, vertex_exp.normal_w, failed_norm_w_vertices)

try:
check_normal(vertex_index, vertex_ori.tangent_x, vertex_exp.tangent_x, failed_tang_x_vertices)
check_normal(vertex_index, vertex_ori.tangent_y, vertex_exp.tangent_y, failed_tang_y_vertices)
check_normal(vertex_index, vertex_ori.tangent_z, vertex_exp.tangent_z, failed_tang_z_vertices)
check_normal(vertex_index, vertex_ori.tangent_w, vertex_exp.tangent_w, failed_tang_w_vertices)
check_normal(vertex_index, vertex_ori.tangent_x, vertex_exp.tangent_x, failed_tang_x_vertices, TANGENT_LIMIT)
check_normal(vertex_index, vertex_ori.tangent_y, vertex_exp.tangent_y, failed_tang_y_vertices, TANGENT_LIMIT)
check_normal(vertex_index, vertex_ori.tangent_z, vertex_exp.tangent_z, failed_tang_z_vertices, TANGENT_LIMIT)
check_normal(vertex_index, vertex_ori.tangent_w, vertex_exp.tangent_w, failed_tang_w_vertices, TANGENT_LIMIT)
except AttributeError:
pass

Expand All @@ -180,9 +181,10 @@ def test_mesh_vertices(request, mod156_mesh_original, mod156_mesh_exported):
assert len(failed_norm_z_vertices) / len(mesh_original_vertices) < FAILURE_RATIO
# TODO: Improve and research tangets. For now there are many failures, but good enough in-game
"""
assert len(failed_tang_x_vertices) / len(mesh_original_vertices) < FAILURE_RATIO
assert len(failed_tang_y_vertices) / len(mesh_original_vertices) < FAILURE_RATIO
assert len(failed_tang_z_vertices) / len(mesh_original_vertices) < FAILURE_RATIO
FAILURE_RATIO_TANGENT = 0.30
assert len(failed_tang_x_vertices) / len(mesh_original_vertices) < FAILURE_RATIO_TANGENT
assert len(failed_tang_y_vertices) / len(mesh_original_vertices) < FAILURE_RATIO_TANGENT
assert len(failed_tang_z_vertices) / len(mesh_original_vertices) < FAILURE_RATIO_TANGENT
"""


Expand Down

0 comments on commit 2b08d88

Please sign in to comment.