Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,21 @@ add_compile_definitions(MOD_ID=\"${MOD_ID}\")
RECURSE_FILES(cpp_file_list ${SOURCE_DIR}/*.cpp)
RECURSE_FILES(c_file_list ${SOURCE_DIR}/*.c)

# beatsaber-hook v6 inline hook sources (provide A64HookFunction)
set(INLINE_HOOK_DIR ${EXTERN_DIR}/includes/beatsaber-hook/shared/inline-hook)
set(inline_hook_sources
${INLINE_HOOK_DIR}/And64InlineHook.cpp
${INLINE_HOOK_DIR}/inlineHook.c
${INLINE_HOOK_DIR}/relocate.c
)

# add all src files to compile
add_library(
${COMPILE_ID}
SHARED
${cpp_file_list}
${c_file_list}
${inline_hook_sources}
)

# Add any assets
Expand Down
5 changes: 5 additions & 0 deletions include/AssetLib/generators/avatarGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

#include "AssetLib/VRMConcepts.hpp"

// Include System/String.hpp first to break circular include: HumanBone_impl -> IEquatable_1_def -> typedefs.h -> String.hpp -> IEquatable_1 (not yet declared)
#include "System/String.hpp"
// Ensure HumanBone/SkeletonBone are fully defined before Avatar.hpp triggers HumanDescription_impl
#include "UnityEngine/zzzz__HumanBone_impl.hpp"
#include "UnityEngine/zzzz__SkeletonBone_impl.hpp"
#include "UnityEngine/Avatar.hpp"
#include "UnityEngine/GameObject.hpp"

Expand Down
4 changes: 2 additions & 2 deletions include/AssetLib/shaders/ShaderSO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "UnityEngine/Material.hpp"
#include "UnityEngine/GameObject.hpp"

DECLARE_CLASS_CODEGEN(VRMData, ShaderSO, UnityEngine::ScriptableObject,
DECLARE_CLASS_CODEGEN(VRMData, ShaderSO, UnityEngine::ScriptableObject) {
DECLARE_INSTANCE_FIELD(UnityEngine::Shader*, mToonShader);
DECLARE_INSTANCE_FIELD(UnityEngine::Shader*, mirrorShader);
DECLARE_INSTANCE_FIELD(UnityEngine::Material*, shadowMaterial);
)
};
3 changes: 3 additions & 0 deletions include/TPoseHelper.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#pragma once
#include <sombrero/shared/FastVector3.hpp>

// Ensure HumanBone/SkeletonBone are fully defined before Avatar.hpp triggers HumanDescription_impl
#include "UnityEngine/zzzz__HumanBone_impl.hpp"
#include "UnityEngine/zzzz__SkeletonBone_impl.hpp"
#include "UnityEngine/Avatar.hpp"

#include "UnityEngine/Transform.hpp"
Expand Down
4 changes: 2 additions & 2 deletions include/UI/AvatarsFlowCoordinator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

using namespace VRMQavatars::UI;

DECLARE_CLASS_CODEGEN(VRMQavatars::UI::FlowCoordinators, AvatarsFlowCoordinator, HMUI::FlowCoordinator,
DECLARE_CLASS_CODEGEN(VRMQavatars::UI::FlowCoordinators, AvatarsFlowCoordinator, HMUI::FlowCoordinator) {
DECLARE_INSTANCE_FIELD(ViewControllers::MirrorViewController*, MirrorViewController);
DECLARE_INSTANCE_FIELD(ViewControllers::AvatarSettingsViewController*, AvatarSettingsViewController);
DECLARE_INSTANCE_FIELD(ViewControllers::AvatarSelectionViewController*, AvatarSelectionViewController);
Expand All @@ -21,4 +21,4 @@ DECLARE_CLASS_CODEGEN(VRMQavatars::UI::FlowCoordinators, AvatarsFlowCoordinator,

DECLARE_OVERRIDE_METHOD(void, DidActivate, GET_FIND_METHOD(&HMUI::FlowCoordinator::DidActivate), bool firstActivation, bool addedToHeirarchy, bool screenSystemEnabling);
DECLARE_OVERRIDE_METHOD(void, BackButtonWasPressed, GET_FIND_METHOD(&HMUI::FlowCoordinator::BackButtonWasPressed), HMUI::ViewController* topViewController);
)
};
52 changes: 26 additions & 26 deletions include/config/config.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "mini-config-utils.hpp"
#include "utils/structs/OffsetPose.hpp"

DECLARE_JSON_CLASS(OffsetPoseConfig,
DECLARE_JSON_STRUCT(OffsetPoseConfig) {
VALUE(float, posX);
VALUE(float, posY);
VALUE(float, posZ);
Expand Down Expand Up @@ -33,9 +33,9 @@ DECLARE_JSON_CLASS(OffsetPoseConfig,
}
OffsetPoseConfig() = default;
OffsetPoseConfig(float posX, float posY, float posZ, float rotX, float rotY, float rotZ) : posX(posX), posY(posY), posZ(posZ), rotX(rotX), rotY(rotY), rotZ(rotZ) {}
)
};

DECLARE_JSON_CLASS(Color2,
DECLARE_JSON_STRUCT(Color2) {
VALUE_DEFAULT(float, r, {});
VALUE_DEFAULT(float, g, {});
VALUE_DEFAULT(float, b, {});
Expand All @@ -59,9 +59,9 @@ DECLARE_JSON_CLASS(Color2,
{
return UnityEngine::Color(r, g, b, a);
}
)
};

DECLARE_JSON_CLASS(VectorThree,
DECLARE_JSON_STRUCT(VectorThree) {
VALUE_DEFAULT(float, x, {});
VALUE_DEFAULT(float, y, {});
VALUE_DEFAULT(float, z, {});
Expand Down Expand Up @@ -92,9 +92,9 @@ DECLARE_JSON_CLASS(VectorThree,
{
return Sombrero::FastVector3(x, y, z);
}
)
};

DECLARE_JSON_CLASS(ControllerTriggerSettings,
DECLARE_JSON_STRUCT(ControllerTriggerSettings) {
VALUE_DEFAULT(std::string, A, "None");
VALUE_DEFAULT(std::string, B, "None");
VALUE_DEFAULT(std::string, X, "None");
Expand All @@ -104,48 +104,48 @@ DECLARE_JSON_CLASS(ControllerTriggerSettings,
VALUE_DEFAULT(std::string, RGrip, "None");
VALUE_DEFAULT(std::string, LTrigger, "None");
VALUE_DEFAULT(std::string, RTrigger, "None");
)
};

DECLARE_JSON_CLASS(BlendshapeSettings,
DECLARE_JSON_STRUCT(BlendshapeSettings) {
VALUE_DEFAULT(bool, autoBlink, true);
VALUE_DEFAULT(float, waitTime, 2.0f);
VALUE_DEFAULT(bool, mockEyeMovement, true);
VALUE_DEFAULT(std::string, neutralExpression, "Neutral");
)
};

DECLARE_JSON_CLASS(LightingSettings,
DECLARE_JSON_STRUCT(LightingSettings) {
VALUE_DEFAULT(Color2, globalColor, Color2(1.0f, 1.0f, 1.0f, 1.0f));
VALUE_DEFAULT(float, globalLightIntensity, 1.0f);
VALUE_DEFAULT(VectorThree, lightRotation, UnityEngine::Vector3(30.0f, 240.0f, 0.0f));
VALUE_DEFAULT(bool, beatmapLighting, true);
VALUE_DEFAULT(float, beatmapLightingColorIntensity, 0.25f);
VALUE_DEFAULT(float, beatmapLightingBrightness, 0.5f);
VALUE_DEFAULT(float, beatmapLightingMinimumBrightness, 0.75f);
)
};

DECLARE_JSON_CLASS(LocomotionSettings,
DECLARE_JSON_STRUCT(LocomotionSettings) {
VALUE_DEFAULT(float, footDistance, 0.1f);
VALUE_DEFAULT(float, stepThreshold, 0.1f);
VALUE_DEFAULT(VectorThree, stepOffset, UnityEngine::Vector3(0.0f, 0.0f, 0.0f));
)
};

DECLARE_JSON_CLASS(IKSettings,
DECLARE_JSON_STRUCT(IKSettings) {
VALUE_DEFAULT(float, legSwivel, 0.0f);
VALUE_DEFAULT(float, armSwivel, 0.0f);
VALUE_DEFAULT(float, bodyStiffness, 0.75f);
VALUE_DEFAULT(float, shoulderRotationWeight, 1.0f);
VALUE_DEFAULT(float, groundOffset, 0.0f);
)
};

DECLARE_JSON_CLASS(OffsetSettings,
DECLARE_JSON_STRUCT(OffsetSettings) {
VALUE_DEFAULT(OffsetPoseConfig, handOffset, OffsetPoseConfig(0.07f, 0.02f, -0.03f, -55.0f, 0.0f, 90.0f));
)
};

DECLARE_JSON_CLASS(FingerPoseSettings,
DECLARE_JSON_STRUCT(FingerPoseSettings) {
VALUE_DEFAULT(std::string, grabPose, "-36,-43,-74,0,-66,-66,-74,0,-56,-73,-70,0,-46,-90,-51,0,-77,-47,-20,19");
)
};

DECLARE_JSON_CLASS(VMCSettings,
DECLARE_JSON_STRUCT(VMCSettings) {
VALUE_DEFAULT(bool, enableSender, false);
VALUE_DEFAULT(std::string, destIP, "127.0.0.1");
VALUE_DEFAULT(std::string, destPort, "39540");
Expand All @@ -160,9 +160,9 @@ DECLARE_JSON_CLASS(VMCSettings,
VALUE_DEFAULT(std::string, rightFoot, "None");
VALUE_DEFAULT(std::string, leftKnee, "None");
VALUE_DEFAULT(std::string, rightKnee, "None");
)
};

DECLARE_JSON_CLASS(MirrorSettings,
DECLARE_JSON_STRUCT(MirrorSettings) {
VALUE_DEFAULT(bool, enabled, true);
VALUE_DEFAULT(VectorThree, position, VectorThree(0, 1.5f, 2));
VALUE_DEFAULT(VectorThree, rotation, VectorThree(15.0f, 180, 0));
Expand All @@ -177,13 +177,13 @@ DECLARE_JSON_CLASS(MirrorSettings,
VALUE_DEFAULT(float, nearClip, 1.0f);
VALUE_DEFAULT(Color2, borderColor, Color2(1.0f, 1.0f, 1.0f, 1.0f));
VALUE_DEFAULT(bool, showHandle, true);
)
};

DECLARE_JSON_CLASS(WindSettings,
DECLARE_JSON_STRUCT(WindSettings) {
VALUE_DEFAULT(bool, enabled, true);
VALUE_DEFAULT(float, windStrength, 1.0f);
VALUE_DEFAULT(float, timeFactor, 1.0f);
)
};

//Access Global through ConfigManager::GetGlobal
//Access Avatar through ConfigManager::GetAvatar
Expand Down
49 changes: 24 additions & 25 deletions include/config/mini-config-utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
#include "rapidjson-macros/shared/macros.hpp"

#define DECLARE_CONFIG(name, ...) \
DECLARE_JSON_CLASS(name##_t, \
DISCARD_EXTRA_FIELDS \
DECLARE_JSON_STRUCT(name##_t) { \
__VA_ARGS__ \
public: \
static inline std::string __config_path = ""; \
Expand Down Expand Up @@ -36,14 +35,14 @@ DECLARE_JSON_CLASS(name##_t, \
ConfigUtils::Logger.error("Error saving config: {} (to {})", err.what(), __config_path.c_str()); \
} \
} \
) \
}; \
inline name##_t& get##name() { \
return name##_t::GetInstance(); \
}

#define CONFIG_VALUE(name, type, jsonName, def, ...) \
private: \
NAMED_VALUE_DEFAULT(ConfigUtils::Specialization<type>::JSONType, __##name, def, jsonName) \
NAMED_VALUE_DEFAULT(ConfigUtils::Specialization<type>::JSONType, __##name, def, jsonName); \
public: \
ConfigUtils::ConfigValue<type> name = {&this->Save, &__##name, jsonName, def __VA_OPT__(,) __VA_ARGS__};

Expand Down Expand Up @@ -141,54 +140,54 @@ clazz(const UnityEngine::clazz& other) { construct; } \
clazz& operator=(const UnityEngine::clazz& other) { construct; return *this; } \
operator UnityEngine::clazz() const { return UnityEngine::clazz convert; }

DECLARE_JSON_CLASS(Vector2,
VALUE(float, x)
VALUE(float, y)
DECLARE_JSON_STRUCT(Vector2) {
VALUE(float, x);
VALUE(float, y);
CONVERSION(Vector2,
x = other.x; y = other.y;,
(x, y)
)
Vector2() = default;
Vector2(float x, float y) : x(x), y(y) {}
)
};

DECLARE_JSON_CLASS(Vector3,
VALUE(float, x)
VALUE(float, y)
VALUE(float, z)
DECLARE_JSON_STRUCT(Vector3) {
VALUE(float, x);
VALUE(float, y);
VALUE(float, z);
CONVERSION(Vector3,
x = other.x; y = other.y; z = other.z;,
(x, y, z)
)
Vector3() = default;
Vector3(float x, float y, float z) : x(x), y(y), z(z) {}
)
};

DECLARE_JSON_CLASS(Vector4,
VALUE(float, x)
VALUE(float, y)
VALUE(float, z)
VALUE(float, w)
DECLARE_JSON_STRUCT(Vector4) {
VALUE(float, x);
VALUE(float, y);
VALUE(float, z);
VALUE(float, w);
CONVERSION(Vector4,
x = other.x; y = other.y; z = other.z; w = other.w;,
(x, y, z, w)
)
Vector4() = default;
Vector4(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) {}
)
};

DECLARE_JSON_CLASS(Color,
VALUE(float, r)
VALUE(float, g)
VALUE(float, b)
VALUE(float, a)
DECLARE_JSON_STRUCT(Color) {
VALUE(float, r);
VALUE(float, g);
VALUE(float, b);
VALUE(float, a);
CONVERSION(Color,
r = other.r; g = other.g; b = other.b; a = other.a;,
(r, g, b, a)
)
Color() = default;
Color(float r, float g, float b, float a) : r(r), g(g), b(b), a(a) {}
)
};

#pragma endregion

Expand Down
4 changes: 2 additions & 2 deletions include/customTypes/Installers/MenuInstaller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "custom-types/shared/macros.hpp"
#include "lapiz/shared/macros.hpp"

DECLARE_CLASS_CODEGEN(VRMQavatars, MenuInstaller, ::Zenject::Installer,
DECLARE_CLASS_CODEGEN(VRMQavatars, MenuInstaller, ::Zenject::Installer) {
DECLARE_OVERRIDE_METHOD(void, InstallBindings, il2cpp_utils::il2cpp_type_check::MetadataGetter<&Zenject::Installer::InstallBindings>::methodInfo());
DECLARE_DEFAULT_CTOR();
)
};
4 changes: 2 additions & 2 deletions include/customTypes/VRMSpringBone.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "sombrero/shared/FastQuaternion.hpp"

DECLARE_CLASS_CODEGEN(VRMQavatars, VRMSpringBone, UnityEngine::MonoBehaviour,
DECLARE_CLASS_CODEGEN(VRMQavatars, VRMSpringBone, UnityEngine::MonoBehaviour) {
DECLARE_INSTANCE_METHOD(void, Awake);
DECLARE_INSTANCE_METHOD(ArrayW<UnityEngine::Transform*>, GetChildren, UnityEngine::Transform* parent);
DECLARE_INSTANCE_METHOD(void, FixedUpdate);
Expand All @@ -42,4 +42,4 @@ DECLARE_CLASS_CODEGEN(VRMQavatars, VRMSpringBone, UnityEngine::MonoBehaviour,
std::vector<VRMQavatars::VRMSpringBoneLogic*> verlet;
std::vector<VRMQavatars::VRMSpringBoneColliderGroup*> colliderGroups;
std::map<UnityEngine::Transform*, Sombrero::FastQuaternion> initialLocalRotationMap;
)
};
4 changes: 2 additions & 2 deletions include/customTypes/VRMSpringBoneColliderGroup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <map>

DECLARE_CLASS_CODEGEN(VRMQavatars, VRMSpringBoneColliderGroup, UnityEngine::MonoBehaviour,
DECLARE_CLASS_CODEGEN(VRMQavatars, VRMSpringBoneColliderGroup, UnityEngine::MonoBehaviour) {
public:
std::vector<SphereCollider> colliders;
)
};
2 changes: 1 addition & 1 deletion mod.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"author": "FutureMapper",
"version": "1.0.1",
"packageId": "com.beatgames.beatsaber",
"packageVersion": "1.28.0_4124311467",
"packageVersion": "1.40.8_7379",
"description": "A VRM based Custom Avatar mod for Beat Saber",
"dependencies": [],
"modFiles": [],
Expand Down
Loading