From 4fa1a2f3b72899dbc6cc6b569d6e43bf0e2b146b Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Fri, 14 Jun 2019 14:37:53 -1000 Subject: [PATCH] Fixes for ANCS cooking --- hecl/blender/hecl/sact/__init__.py | 23 +++++++++++++---------- hecl/extern/athena | 2 +- hecl/lib/Blender/Connection.cpp | 4 +++- hecl/lib/hecl.cpp | 4 ++-- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/hecl/blender/hecl/sact/__init__.py b/hecl/blender/hecl/sact/__init__.py index 3ef5d74d9..d2ce45bc2 100644 --- a/hecl/blender/hecl/sact/__init__.py +++ b/hecl/blender/hecl/sact/__init__.py @@ -158,11 +158,12 @@ def write_action_channels(writebuf, action): writebuf(struct.pack('fff', writevec[0], writevec[1], writevec[2])) -def write_action_aabb(writebuf, arm_obj, mesh_obj): +def write_action_aabb(writebuf, arm_obj, mesh_obj, action): scene = bpy.context.scene - # Frame 1 - scene.frame_set(1) + # Mute root channels + for fcurve in action.fcurves: + fcurve.mute = fcurve.data_path == 'pose.bones["root"].location' # Transform against root root_bone = arm_obj.pose.bones['root'] @@ -171,6 +172,10 @@ def write_action_aabb(writebuf, arm_obj, mesh_obj): root_bone.rotation_quaternion = (1.0,0.0,0.0,0.0) else: root_bone.rotation_euler = (0.0,0.0,0.0) + + # Frame 1 + scene.frame_set(1) + root_aabb_min = Vector(mesh_obj.bound_box[0]) root_aabb_max = Vector(mesh_obj.bound_box[6]) @@ -178,12 +183,6 @@ def write_action_aabb(writebuf, arm_obj, mesh_obj): for frame_idx in range(2, scene.frame_end + 1): scene.frame_set(frame_idx) - root_bone.location = (0.0,0.0,0.0) - scene.update_tag() - if root_bone.rotation_mode == 'QUATERNION': - root_bone.rotation_quaternion = (1.0,0.0,0.0,0.0) - else: - root_bone.rotation_euler = (0.0,0.0,0.0) test_aabb_min = Vector(mesh_obj.bound_box[0]) test_aabb_max = Vector(mesh_obj.bound_box[6]) @@ -194,6 +193,10 @@ def write_action_aabb(writebuf, arm_obj, mesh_obj): if test_aabb_max[comp] > root_aabb_max[comp]: root_aabb_max[comp] = test_aabb_max[comp] + # Unmute root channels + for fcurve in action.fcurves: + fcurve.mute = False + writebuf(struct.pack('ffffff', root_aabb_min[0], root_aabb_min[1], root_aabb_min[2], root_aabb_max[0], root_aabb_max[1], root_aabb_max[2])) @@ -318,7 +321,7 @@ def _out_actions(sact_data, writebuf): if subtype.linked_mesh not in bpy.data.objects: raise RuntimeError('mesh %s not found' % subtype.linked_mesh) mesh = bpy.data.objects[subtype.linked_mesh] - write_action_aabb(writebuf, arm, mesh) + write_action_aabb(writebuf, arm, mesh, bact) def _out_action_no_subtypes(sact_data, writebuf, action_name): for action_idx in range(len(sact_data.actions)): diff --git a/hecl/extern/athena b/hecl/extern/athena index a9271862d..335ed6bb6 160000 --- a/hecl/extern/athena +++ b/hecl/extern/athena @@ -1 +1 @@ -Subproject commit a9271862dcde58982affda98383e2367e5d205b8 +Subproject commit 335ed6bb6f8ba51b8c74aadedb484e2688826a68 diff --git a/hecl/lib/Blender/Connection.cpp b/hecl/lib/Blender/Connection.cpp index 344e34d9e..d1532ac69 100644 --- a/hecl/lib/Blender/Connection.cpp +++ b/hecl/lib/Blender/Connection.cpp @@ -1454,10 +1454,12 @@ Action::Action(Connection& conn) { conn._readBuf(&aabbCount, 4); subtypeAABBs.reserve(aabbCount); for (uint32_t i = 0; i < aabbCount; ++i) { - // printf("AABB %s %d\n", name.c_str(), i); subtypeAABBs.emplace_back(); subtypeAABBs.back().first.read(conn); subtypeAABBs.back().second.read(conn); + //printf("AABB %s %d (%f %f %f) (%f %f %f)\n", name.c_str(), i, + // float(subtypeAABBs.back().first.val.simd[0]), float(subtypeAABBs.back().first.val.simd[1]), float(subtypeAABBs.back().first.val.simd[2]), + // float(subtypeAABBs.back().second.val.simd[0]), float(subtypeAABBs.back().second.val.simd[1]), float(subtypeAABBs.back().second.val.simd[2])); } } diff --git a/hecl/lib/hecl.cpp b/hecl/lib/hecl.cpp index 92554a821..d4cc0eb25 100644 --- a/hecl/lib/hecl.cpp +++ b/hecl/lib/hecl.cpp @@ -24,7 +24,7 @@ namespace hecl { unsigned VerbosityLevel = 0; bool GuiMode = false; logvisor::Module LogModule("hecl"); -static const std::string Illegals{"<>?\"|"}; +static const std::string Illegals{"<>?\""}; #if __GNUC__ __attribute__((__format__(__printf__, 1, 2))) @@ -106,7 +106,7 @@ void SanitizePath(std::string& path) { path.pop_back(); } -static const std::wstring WIllegals{L"<>?\"|"}; +static const std::wstring WIllegals{L"<>?\""}; void SanitizePath(std::wstring& path) { if (path.empty())