Fixes for ANCS cooking

This commit is contained in:
Jack Andersen 2019-06-14 14:37:53 -10:00
parent 31caec79dd
commit 4fa1a2f3b7
4 changed files with 19 additions and 14 deletions

View File

@ -158,11 +158,12 @@ def write_action_channels(writebuf, action):
writebuf(struct.pack('fff', writevec[0], writevec[1], writevec[2])) 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 scene = bpy.context.scene
# Frame 1 # Mute root channels
scene.frame_set(1) for fcurve in action.fcurves:
fcurve.mute = fcurve.data_path == 'pose.bones["root"].location'
# Transform against root # Transform against root
root_bone = arm_obj.pose.bones['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) root_bone.rotation_quaternion = (1.0,0.0,0.0,0.0)
else: else:
root_bone.rotation_euler = (0.0,0.0,0.0) 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_min = Vector(mesh_obj.bound_box[0])
root_aabb_max = Vector(mesh_obj.bound_box[6]) 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): for frame_idx in range(2, scene.frame_end + 1):
scene.frame_set(frame_idx) 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_min = Vector(mesh_obj.bound_box[0])
test_aabb_max = Vector(mesh_obj.bound_box[6]) 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]: if test_aabb_max[comp] > root_aabb_max[comp]:
root_aabb_max[comp] = test_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', writebuf(struct.pack('ffffff',
root_aabb_min[0], root_aabb_min[1], root_aabb_min[2], root_aabb_min[0], root_aabb_min[1], root_aabb_min[2],
root_aabb_max[0], root_aabb_max[1], root_aabb_max[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: if subtype.linked_mesh not in bpy.data.objects:
raise RuntimeError('mesh %s not found' % subtype.linked_mesh) raise RuntimeError('mesh %s not found' % subtype.linked_mesh)
mesh = bpy.data.objects[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): def _out_action_no_subtypes(sact_data, writebuf, action_name):
for action_idx in range(len(sact_data.actions)): for action_idx in range(len(sact_data.actions)):

2
hecl/extern/athena vendored

@ -1 +1 @@
Subproject commit a9271862dcde58982affda98383e2367e5d205b8 Subproject commit 335ed6bb6f8ba51b8c74aadedb484e2688826a68

View File

@ -1454,10 +1454,12 @@ Action::Action(Connection& conn) {
conn._readBuf(&aabbCount, 4); conn._readBuf(&aabbCount, 4);
subtypeAABBs.reserve(aabbCount); subtypeAABBs.reserve(aabbCount);
for (uint32_t i = 0; i < aabbCount; ++i) { for (uint32_t i = 0; i < aabbCount; ++i) {
// printf("AABB %s %d\n", name.c_str(), i);
subtypeAABBs.emplace_back(); subtypeAABBs.emplace_back();
subtypeAABBs.back().first.read(conn); subtypeAABBs.back().first.read(conn);
subtypeAABBs.back().second.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]));
} }
} }

View File

@ -24,7 +24,7 @@ namespace hecl {
unsigned VerbosityLevel = 0; unsigned VerbosityLevel = 0;
bool GuiMode = false; bool GuiMode = false;
logvisor::Module LogModule("hecl"); logvisor::Module LogModule("hecl");
static const std::string Illegals{"<>?\"|"}; static const std::string Illegals{"<>?\""};
#if __GNUC__ #if __GNUC__
__attribute__((__format__(__printf__, 1, 2))) __attribute__((__format__(__printf__, 1, 2)))
@ -106,7 +106,7 @@ void SanitizePath(std::string& path) {
path.pop_back(); path.pop_back();
} }
static const std::wstring WIllegals{L"<>?\"|"}; static const std::wstring WIllegals{L"<>?\""};
void SanitizePath(std::wstring& path) { void SanitizePath(std::wstring& path) {
if (path.empty()) if (path.empty())