Skip to content

Commit

Permalink
add qol settings and update framework
Browse files Browse the repository at this point in the history
  • Loading branch information
PredatorCZ committed Jan 13, 2025
1 parent 6417917 commit 8f02903
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion 3rd_party/spike
Submodule spike updated 62 files
+6 −6 .github/workflows/cmake.yml
+12 −2 3rd_party/pugixml/CMakeLists.txt
+10 −2 CMakeLists.txt
+1 −1 LICENSE
+5 −5 README.md
+5 −0 bin/CMakeLists.txt
+5 −2 cmake/targetex.cmake
+3 −1 include/spike/app/batch.hpp
+2 −0 include/spike/app/cache.hpp
+3 −1 include/spike/app/context.hpp
+6 −0 include/spike/app/out_context.hpp
+52 −0 include/spike/app/texel.hpp
+214 −10 include/spike/app_context.hpp
+2 −1 include/spike/crypto/jenkinshash.hpp
+33 −30 include/spike/crypto/jenkinshash3.hpp
+27 −21 include/spike/format/WAVE.hpp
+65 −14 include/spike/gltf.hpp
+2 −0 include/spike/gltf/gltf.h
+76 −0 include/spike/gltf_attribute.hpp
+2 −2 include/spike/gpu/BlockDecoder.h
+3 −3 include/spike/gpu/BlockDecoder.inl
+19 −3 include/spike/io/directory_scanner.hpp
+4 −4 include/spike/io/fileinfo.hpp
+2 −0 include/spike/io/stat.hpp
+1 −0 include/spike/reflect/detail/reflector_type.hpp
+1 −0 include/spike/reflect/reflector.hpp
+1 −0 include/spike/reflect/reflector_io.hpp
+5 −1 include/spike/type/pointer.hpp
+14 −9 include/spike/type/vectors_simd.hpp
+2 −1 include/spike/uni/detail/format_full.hpp
+8 −5 include/spike/uni/detail/model.inl
+1 −0 include/spike/uni/model.hpp
+1 −0 src/CMakeLists.txt
+15 −6 src/app/CMakeLists.txt
+50 −49 src/app/batch.cpp
+808 −0 src/app/bc7decomp.c
+27 −0 src/app/bc7decomp.h
+154 −36 src/app/context.cpp
+59 −11 src/app/in_context.cpp
+42 −1 src/app/out_context.cpp
+757 −0 src/app/pvr_decompress.cpp
+28 −0 src/app/pvr_decompress.hpp
+650 −0 src/app/qoi.h
+2,279 −0 src/app/texel.cpp
+12 −0 src/cli/CMakeLists.txt
+32 −3 src/cli/console.cpp
+183 −28 src/cli/spike.cpp
+10 −2 src/detail/stat_win.inl
+6 −4 src/gltf/CMakeLists.txt
+0 −0 src/gltf/fx/.clang-format
+0 −0 src/gltf/fx/fx_gltf.cpp
+1,292 −681 src/gltf/gltf.cpp
+1 −1 src/matrix44.cpp
+1 −2 src/uni_format.cpp
+4 −1 test/CMakeLists.txt
+1 −1 test/matrix44.inl
+2 −0 test/spike/.gitignore
+17 −4 test/spike/CMakeLists.txt
+81 −0 test/spike/compiled_resources/CMakeLists.txt
+ test/spike/compiled_resources/resources.tar.zst
+6 −2 test/spike/test_cache.cpp
+269 −0 test/spike/test_texel.cpp
36 changes: 29 additions & 7 deletions toolset/gltf/hk_to_gltf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
You should have received a copy of the GNU General Public License
along with this program.If not, see <https://www.gnu.org/licenses/>.
*/
#define GLM_FORCE_QUAT_DATA_XYZW

#include "havok_api.hpp"
#include "hklib/hka_animation.hpp"
Expand Down Expand Up @@ -70,13 +71,15 @@ struct AnimationSettings {
uint8 sampleRate = 60;
BlendHintOverride blendOverride = BlendHintOverride::AUTO;
ScaleType scaleType = ScaleType::NONE;
bool unnamedAnimsAsFile = false;
void ReflectorTag();
};

struct SkeletonSettings {
std::string path;
SkeletonGeneration generation;
bool visualize = true;
bool createRootNode = false;
std::string generateControlBones;
void ReflectorTag();
};
Expand Down Expand Up @@ -114,7 +117,7 @@ struct Havok2GLTF : ReflectorBase<Havok2GLTF> {
float sceneScale = 0.f;
es::Matrix44 corMat;
} settings;

// bpnrsuBCFGNRSUV
REFLECT(
CLASS(AnimationSettings),
MEMBERNAME(blendOverride, "blend-override", "b",
Expand All @@ -123,7 +126,10 @@ REFLECT(
ReflDesc{"Specify frames per second for GLTF."}),
MEMBERNAME(scaleType, "scale-type", "S",
ReflDesc{
"Select desired processing mode for node scale tracks."}), )
"Select desired processing mode for node scale tracks."}),
MEMBERNAME(unnamedAnimsAsFile, "filename-anims", "f",
ReflDesc{
"Use filename for unnamed animations instead of Motion[]"}), )

REFLECT(CLASS(SkeletonSettings),
MEMBERNAME(path, "skeleton-path", "s",
Expand All @@ -135,7 +141,10 @@ REFLECT(CLASS(SkeletonSettings),
"applied scale tracks."}),
MEMBER(visualize, "V",
ReflDesc{"Create visualization mesh for skeletons. (Enforces "
"armature object for Blender)"}), )
"armature object for Blender)"}),
MEMBERNAME(createRootNode, "create-root-node", "N",
ReflDesc{"Force create root node named after skeleton. "
"(Separates root motion)"}), )

REFLECT(CLASS(Scene), MEMBER(units, "u", ReflDesc{"Input scene units."}),
MEMBERNAME(customScale, "custom-scale", "C",
Expand Down Expand Up @@ -418,7 +427,7 @@ struct GLTFHK : GLTF {
controlBones = std::move(controlBonesFiltered);
}

if (rootIndices.size() > 1) {
if (rootIndices.size() > 1 || settings.skeleton.createRootNode) {
gltf::Node rootNode;
rootNode.name = skel.Name();

Expand Down Expand Up @@ -468,14 +477,24 @@ struct GLTFHK : GLTF {
}

size_t animIndex = 0;
std::string_view fileName;
bool singleAnim = false;

void ProcessAnimation(const hkaAnimation *anim,
const hkaAnimationBinding *binding) {
gltf::Animation glanim;
glanim.channels.reserve(anim->GetNumOfTransformTracks() * 3);
glanim.name = anim->Name();
if (glanim.name.empty()) {
glanim.name = "Motion[" + std::to_string(animIndex++) + "]";
if (settings.animation.unnamedAnimsAsFile) {
glanim.name = fileName;
} else {
glanim.name = "Motion";
}

if (!singleAnim) {
glanim.name.append("[" + std::to_string(animIndex++) + "]");
}
}
const size_t upperLimit =
gltfutils::FindTimeEndIndex(times, anim->Duration());
Expand Down Expand Up @@ -815,8 +834,8 @@ struct GLTFHK : GLTF {
v *= nodeVal;
}
} else if (componentIndex == uni::MotionTrack::Rotation) {
glm::quat nodeVal{node.rotation[3], node.rotation[0], node.rotation[1],
node.rotation[2]};
glm::quat nodeVal{node.rotation[0], node.rotation[1], node.rotation[2],
node.rotation[3]};

for (auto &v : r.values) {
glm::quat rVal = AsQuat(v);
Expand Down Expand Up @@ -962,6 +981,7 @@ void AppProcessFile(AppContext *ctx) {
}

GLTFHK main;
main.fileName = ctx->workingFile.GetFilename();

// Load skeletons
for (auto skel_ : skeletons) {
Expand All @@ -980,6 +1000,8 @@ void AppProcessFile(AppContext *ctx) {
return;
}

main.singleAnim = anims.size() == 1;

main.times = [&] {
float maxDuration = 0;

Expand Down

0 comments on commit 8f02903

Please sign in to comment.