diff --git a/hecl/blender/BlenderConnection.hpp b/hecl/blender/BlenderConnection.hpp index ad854b714..bcf427d36 100644 --- a/hecl/blender/BlenderConnection.hpp +++ b/hecl/blender/BlenderConnection.hpp @@ -609,13 +609,35 @@ public: Bone(BlenderConnection& conn); }; std::vector bones; - Bone* lookupBone(const char* name) + const Bone* lookupBone(const char* name) const { - for (Bone& b : bones) + for (const Bone& b : bones) if (!b.name.compare(name)) return &b; return nullptr; } + const Bone* getParent(const Bone* bone) const + { + if (bone->parent < 0) + return nullptr; + return &bones[bone->parent]; + } + const Bone* getChild(const Bone* bone, size_t child) const + { + if (child >= bone->children.size()) + return nullptr; + int32_t cIdx = bone->children[child]; + if (cIdx < 0) + return nullptr; + return &bones[cIdx]; + } + const Bone* getRoot() const + { + for (const Bone& b : bones) + if (b.parent < 0) + return &b; + return nullptr; + } Armature(BlenderConnection& conn); }; std::vector armatures; @@ -674,6 +696,68 @@ public: return Actor(*m_parent); } + + std::vector getArmatureNames() + { + if (m_parent->m_loadedType != BlendType::Actor) + BlenderLog.report(logvisor::Fatal, _S("%s is not an ACTOR blend"), + m_parent->m_loadedBlend.getAbsolutePath().c_str()); + + m_parent->_writeLine("GETARMATURENAMES"); + + char readBuf[256]; + m_parent->_readLine(readBuf, 256); + if (strcmp(readBuf, "OK")) + BlenderLog.report(logvisor::Fatal, "unable to get armatures of actor: %s", readBuf); + + std::vector ret; + + uint32_t armCount; + m_parent->_readBuf(&armCount, 4); + ret.reserve(armCount); + for (uint32_t i=0 ; i_readBuf(&bufSz, 4); + name.assign(bufSz, ' '); + m_parent->_readBuf(&name[0], bufSz); + } + + return ret; + } + + std::vector getActionNames() + { + if (m_parent->m_loadedType != BlendType::Actor) + BlenderLog.report(logvisor::Fatal, _S("%s is not an ACTOR blend"), + m_parent->m_loadedBlend.getAbsolutePath().c_str()); + + m_parent->_writeLine("GETACTIONNAMES"); + + char readBuf[256]; + m_parent->_readLine(readBuf, 256); + if (strcmp(readBuf, "OK")) + BlenderLog.report(logvisor::Fatal, "unable to get actions of actor: %s", readBuf); + + std::vector ret; + + uint32_t actCount; + m_parent->_readBuf(&actCount, 4); + ret.reserve(actCount); + for (uint32_t i=0 ; i_readBuf(&bufSz, 4); + name.assign(bufSz, ' '); + m_parent->_readBuf(&name[0], bufSz); + } + + return ret; + } }; DataStream beginData() { diff --git a/hecl/blender/hecl/sact/__init__.py b/hecl/blender/hecl/sact/__init__.py index 6a682c9d2..d4f0ab1bd 100644 --- a/hecl/blender/hecl/sact/__init__.py +++ b/hecl/blender/hecl/sact/__init__.py @@ -303,6 +303,20 @@ def cook(writebuf): mesh = bpy.data.objects[subtype.linked_mesh] write_action_aabb(writebuf, arm, mesh) +# Access actor's contained armature names +def get_armature_names(writebuf): + writebuf(struct.pack('I', len(bpy.data.armatures))) + for arm in bpy.data.armatures: + writebuf(struct.pack('I', len(arm.name))) + writebuf(arm.name.encode()) + +# Access actor's contained action names +def get_action_names(writebuf): + writebuf(struct.pack('I', len(sact_data.actions))) + for action_idx in range(len(sact_data.actions)): + action = sact_data.actions[action_idx] + writebuf(struct.pack('I', len(action.name))) + writebuf(action.name.encode()) # Panel draw diff --git a/hecl/blender/hecl_blendershell.py b/hecl/blender/hecl_blendershell.py index 81f9c5e0f..58175d5fe 100644 --- a/hecl/blender/hecl_blendershell.py +++ b/hecl/blender/hecl_blendershell.py @@ -114,7 +114,8 @@ def animin_loop(globals): crv.keyframe_points.add(count=key_info[1]) if crv_type[0] == 1: - trans_head = globals['bone_trans_head'][key_info[0]] + #trans_head = globals['bone_trans_head'][key_info[0]] + trans_head = 0 for k in range(key_info[1]): key_data = struct.unpack('if', os.read(readfd, 8)) pt = crv.keyframe_points[k] @@ -188,6 +189,14 @@ def dataout_loop(): writepipeline(b'OK') hecl.sact.cook(writepipebuf) + elif cmdargs[0] == 'GETARMATURENAMES': + writepipeline(b'OK') + hecl.sact.get_armature_names(writepipebuf) + + elif cmdargs[0] == 'GETACTIONNAMES': + writepipeline(b'OK') + hecl.sact.get_action_names(writepipebuf) + # Command loop while True: diff --git a/hecl/driver/CMakeLists.txt b/hecl/driver/CMakeLists.txt index 5785b9b89..b0b8ad4cb 100644 --- a/hecl/driver/CMakeLists.txt +++ b/hecl/driver/CMakeLists.txt @@ -25,4 +25,5 @@ endif() target_link_libraries(hecl ${DATA_SPEC_LIBS} hecl-database hecl-backend hecl-frontend hecl-blender hecl-common athena-core nod - logvisor athena-libyaml ${PNG_LIB} squish xxhash boo ${ZLIB_LIBRARIES} ${LZO_LIB} ${PLAT_LIBS} ${BOO_SYS_LIBS}) + logvisor athena-libyaml ${PNG_LIB} squish xxhash zeus boo + ${ZLIB_LIBRARIES} ${LZO_LIB} ${PLAT_LIBS} ${BOO_SYS_LIBS}) diff --git a/hecl/driver/ToolBase.hpp b/hecl/driver/ToolBase.hpp index a80d4555e..dd12e1d1f 100644 --- a/hecl/driver/ToolBase.hpp +++ b/hecl/driver/ToolBase.hpp @@ -245,7 +245,7 @@ void ToolPrintProgress(const hecl::SystemChar* message, const hecl::SystemChar* else hecl::Printf(_S(" ")); - int width = hecl::ConsoleWidth(); + int width = std::max(80, hecl::ConsoleWidth()); int half; if (blocks) half = width / 2 - 2; diff --git a/hecl/extern/athena b/hecl/extern/athena index 8b2f1a859..d2fb800b9 160000 --- a/hecl/extern/athena +++ b/hecl/extern/athena @@ -1 +1 @@ -Subproject commit 8b2f1a8591982e57a036ec00ab0fbda3f9d65e40 +Subproject commit d2fb800b926c9d4ef76e54242c54f3fe369f7c3d diff --git a/hecl/lib/ClientProcess.cpp b/hecl/lib/ClientProcess.cpp index a91b5d352..a157b8170 100644 --- a/hecl/lib/ClientProcess.cpp +++ b/hecl/lib/ClientProcess.cpp @@ -82,7 +82,11 @@ void ClientProcess::Worker::proc() ClientProcess::ClientProcess(int verbosityLevel) : m_verbosity(verbosityLevel) { +#ifdef NDEBUG int cpuCount = GetCPUCount(); +#else + constexpr int cpuCount = 1; +#endif m_workers.reserve(cpuCount); for (int i=0 ; i