Skip to content

Commit 440ca69

Browse files
Disabled culling. thx henwill and dark
1 parent 69a87f3 commit 440ca69

File tree

4 files changed

+63
-9
lines changed

4 files changed

+63
-9
lines changed

Android.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ LOCAL_SHARED_LIBRARIES += codegen_0_4_0
6464
LOCAL_SHARED_LIBRARIES += questui
6565
LOCAL_SHARED_LIBRARIES += custom-types
6666
LOCAL_LDLIBS += -llog
67-
LOCAL_CFLAGS += -I'extern/libil2cpp/il2cpp/libil2cpp' -DID='"Play3rdPer"' -DVERSION='"0.1.0"' -I'./shared' -I'./extern' -isystem'extern/codegen/include'
67+
LOCAL_CFLAGS += -I'extern/libil2cpp/il2cpp/libil2cpp' -DID='"Play3rdPer"' -DVERSION='"0.1.1"' -I'./shared' -I'./extern' -isystem'extern/codegen/include'
6868
LOCAL_CPPFLAGS += -std=c++2a
6969
LOCAL_C_INCLUDES += ./include ./src
7070
include $(BUILD_SHARED_LIBRARY)

buildBMBF.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ if (-not ($PSVersionTable.PSEdition -eq "Core")) {
88

99
& $buildScript NDK_PROJECT_PATH=$PSScriptRoot APP_BUILD_SCRIPT=$PSScriptRoot/Android.mk NDK_APPLICATION_MK=$PSScriptRoot/Application.mk
1010

11-
Compress-Archive -Path "./libs/arm64-v8a/libPlay3rdPer.so", "./bmbfmod.json" -DestinationPath "./Play3rdPer_v0.1.0.zip" -Update
11+
Compress-Archive -Path "./libs/arm64-v8a/libPlay3rdPer.so", "./bmbfmod.json" -DestinationPath "./Play3rdPer_v0.1.1.zip" -Update

src/Play3rdPerViewController.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ void SetActive(Play3rdPerViewController* self, bool newValue) {
3232
getConfig().config["Active"].SetBool(newValue);
3333
}
3434

35+
void SetFixed(Play3rdPerViewController* self, bool newValue) {
36+
getConfig().config["Fixed"].SetBool(newValue);
37+
}
38+
3539
void SetXFloat(Play3rdPerViewController* self, float newValue) {
3640
getConfig().config["XOffset"].SetFloat(newValue);
3741
}
@@ -58,11 +62,17 @@ void Play3rdPerViewController::DidActivate(bool firstActivation, bool addedToHie
5862
get_gameObject()->AddComponent<Touchable*>();
5963
GameObject* container = BeatSaberUI::CreateScrollableSettingsContainer(get_transform());
6064

61-
// Toggle
65+
// Active
6266
auto ActivePress = il2cpp_utils::MakeDelegate<UnityEngine::Events::UnityAction_1<bool>*>(
6367
classof(UnityEngine::Events::UnityAction_1<bool>*), this, SetActive);
6468
QuestUI::BeatSaberUI::CreateToggle(container->get_transform(), "Active", getConfig().config["Active"].GetBool(), ActivePress);
6569

70+
// Fixed
71+
auto FixedPress = il2cpp_utils::MakeDelegate<UnityEngine::Events::UnityAction_1<bool>*>(
72+
classof(UnityEngine::Events::UnityAction_1<bool>*), this, SetFixed);
73+
UnityEngine::UI::Toggle* FixedObject = QuestUI::BeatSaberUI::CreateToggle(container->get_transform(), "Fixed camera position", getConfig().config["Fixed"].GetBool(), FixedPress);
74+
QuestUI::BeatSaberUI::AddHoverHint(FixedObject->get_gameObject(), "Can make you dizzy and motion sick");
75+
6676
// X
6777
auto XChange = il2cpp_utils::MakeDelegate<UnityEngine::Events::UnityAction_1<float>*>(
6878
classof(UnityEngine::Events::UnityAction_1<float>*), this, SetXFloat);

src/main.cpp

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "UnityEngine/Resources.hpp"
2121
#include "UnityEngine/Camera.hpp"
2222
#include "UnityEngine/GameObject.hpp"
23+
#include "UnityEngine/Matrix4x4.hpp"
2324

2425
#include "Play3rdPerViewController.hpp"
2526

@@ -42,6 +43,28 @@ Logger& getLogger() {
4243
return *logger;
4344
}
4445

46+
UnityEngine::Matrix4x4 TranslateMatrix(UnityEngine::Vector3 vector)
47+
{
48+
UnityEngine::Matrix4x4 result;
49+
result.m00 = 1;
50+
result.m01 = 0;
51+
result.m02 = 0;
52+
result.m03 = vector.x;
53+
result.m10 = 0;
54+
result.m11 = 1;
55+
result.m12 = 0;
56+
result.m13 = vector.y;
57+
result.m20 = 0;
58+
result.m21 = 0;
59+
result.m22 = 1;
60+
result.m23 = vector.z;
61+
result.m30 = 0;
62+
result.m31 = 0;
63+
result.m32 = 0;
64+
result.m33 = 1;
65+
return result;
66+
}
67+
4568
MAKE_HOOK_OFFSETLESS(LightManager_OnWillRenderObject, void, LightManager* self, UnityEngine::Camera* camera) {
4669
// Do stuff when this function is called
4770
LightManager_OnWillRenderObject(self, camera);
@@ -51,13 +74,29 @@ MAKE_HOOK_OFFSETLESS(LightManager_OnWillRenderObject, void, LightManager* self,
5174
UnityEngine::Vector3 rot = c->get_transform()->get_eulerAngles();
5275
UnityEngine::Vector3 pos = c->get_transform()->get_position();
5376

54-
pos.x += getConfig().config["XOffset"].GetFloat();
55-
pos.y += getConfig().config["YOffset"].GetFloat();
56-
pos.z += getConfig().config["ZOffset"].GetFloat();
77+
typedef function_ptr_t<void, UnityEngine::Camera*, UnityEngine::Matrix4x4> type;
78+
auto method = *reinterpret_cast<type>(il2cpp_functions::resolve_icall("UnityEngine.Camera::set_cullingMatrix_Injected"));
79+
80+
method(c, UnityEngine::Matrix4x4::Ortho(-99999, 99999, -99999, 99999, 0.001f, 99999) * TranslateMatrix(UnityEngine::Vector3::get_forward() * -99999 / 2) * c->get_worldToCameraMatrix());
81+
82+
if(getConfig().config["Fixed"].GetBool()) {
83+
pos.x = getConfig().config["XOffset"].GetFloat();
84+
pos.y = getConfig().config["YOffset"].GetFloat();
85+
pos.z = getConfig().config["ZOffset"].GetFloat();
86+
87+
rot.x = getConfig().config["XRot"].GetFloat();
88+
rot.y = getConfig().config["YRot"].GetFloat();
89+
rot.z = getConfig().config["ZRot"].GetFloat();
90+
} else {
91+
pos.x += getConfig().config["XOffset"].GetFloat();
92+
pos.y += getConfig().config["YOffset"].GetFloat();
93+
pos.z += getConfig().config["ZOffset"].GetFloat();
5794

58-
rot.x += getConfig().config["XRot"].GetFloat();
59-
rot.y += getConfig().config["YRot"].GetFloat();
60-
rot.z += getConfig().config["ZRot"].GetFloat();
95+
rot.x += getConfig().config["XRot"].GetFloat();
96+
rot.y += getConfig().config["YRot"].GetFloat();
97+
rot.z += getConfig().config["ZRot"].GetFloat();
98+
}
99+
61100

62101

63102
c->get_transform()->set_position(pos);
@@ -81,6 +120,10 @@ void createDefaultConfig() {
81120
getConfig().config.AddMember("ZRot", rapidjson::Value().SetFloat(0), allocator);
82121
}
83122

123+
if(getConfig().config.HasMember("Active") && !(getConfig().config.HasMember("Fixed"))) {
124+
getConfig().config.AddMember("Fixed", rapidjson::Value().SetBool(false), allocator);
125+
}
126+
84127
if(getConfig().config.HasMember("Active")) {return;}
85128

86129
// Add all the default options
@@ -93,6 +136,7 @@ void createDefaultConfig() {
93136
// Add a member to the config, using the allocator
94137

95138
getConfig().config.AddMember("Active", rapidjson::Value().SetBool(true), allocator);
139+
getConfig().config.AddMember("Fixed", rapidjson::Value().SetBool(false), allocator);
96140
getConfig().config.AddMember("XOffset", rapidjson::Value().SetFloat(2.0), allocator);
97141
getConfig().config.AddMember("YOffset", rapidjson::Value().SetFloat(1.0), allocator);
98142
getConfig().config.AddMember("ZOffset", rapidjson::Value().SetFloat(-2.0), allocator);

0 commit comments

Comments
 (0)