1+ #include " utils/debug_draw.h"
12#include " cemu_hooks.h"
23#include " instance.h"
34#include " rendering/openxr.h"
@@ -193,28 +194,6 @@ void CemuHooks::hook_UpdateCameraForGameplay(PPCInterpreter_t* hCPU) {
193194 s_framesSinceLastCameraUpdate = 0 ;
194195}
195196
196- // turns out this only does the minimap ui, and not the stamina UI :/
197- // void CemuHooks::hook_UpdateUIPosition(PPCInterpreter_t* hCPU) {
198- // hCPU->instructionPointer = hCPU->sprNew.LR;
199- //
200- // EyeSide side = hCPU->gpr[10] == 0 ? EyeSide::LEFT : EyeSide::RIGHT;
201- // uint32_t currFrameCounter = hCPU->gpr[11];
202- // uint32_t doesUIManagerExist = hCPU->gpr[3] != 0;
203- // uint32_t uiManagerInstance = hCPU->gpr[12];
204- //
205- // if (!doesUIManagerExist) {
206- // return;
207- // }
208- //
209- // BEVec3 playerPosCopy = getMemory<BEVec3>(uiManagerInstance + offsetof(UIManager, innerArray.uiPos1));
210- // BEVec3 playerMtxPositionCopy = getMemory<BEVec3>(uiManagerInstance + offsetof(UIManager, innerArray.uiPos2));
211- //
212- // Log::print<INFO>("[{}] Updating UI position (frame = {}, playerPos = {}, playerMtxPos = {})", side, currFrameCounter, playerPosCopy, playerMtxPositionCopy);
213- //
214- // writeMemory(uiManagerInstance + offsetof(UIManager, innerArray.uiPos1), &playerPosCopy);
215- // writeMemory(uiManagerInstance + offsetof(UIManager, innerArray.uiPos2), &playerMtxPositionCopy);
216- // }
217-
218197void CemuHooks::hook_FixStaminaGaugeScreenPosition (PPCInterpreter_t* hCPU) {
219198 hCPU->instructionPointer = hCPU->sprNew .LR ;
220199
@@ -397,7 +376,7 @@ static glm::mat4 calculateProjectionMatrix(float nearZ, float farZ, const XrFovf
397376void CemuHooks::hook_GetRenderProjection (PPCInterpreter_t* hCPU) {
398377 hCPU->instructionPointer = hCPU->sprNew .LR ;
399378
400- if (CemuHooks:: UseBlackBarsDuringEvents ()) {
379+ if (UseBlackBarsDuringEvents ()) {
401380 return ;
402381 }
403382
@@ -1092,4 +1071,50 @@ void CemuHooks::hook_PlayerLadderFix(PPCInterpreter_t* hCPU) {
10921071 if (IsFirstPerson ()) {
10931072 s_isLadderClimbing = 2 ;
10941073 }
1095- }
1074+ }
1075+
1076+ void CemuHooks::hook_VisualizeRayCastHits (PPCInterpreter_t* hCPU) {
1077+ hCPU->instructionPointer = hCPU->sprNew .LR ;
1078+
1079+ if (VRManager::instance ().XR ->GetRenderer () == nullptr ) {
1080+ return ;
1081+ }
1082+
1083+ uint32_t rayCastResultPtr = hCPU->gpr [3 ];
1084+ glm::fvec3 raycastHitPos = getMemory<BEVec3>(hCPU->gpr [4 ]).getLE ();
1085+
1086+ ksys::phys::RayCast rayCast = {};
1087+ readMemory (rayCastResultPtr, &rayCast);
1088+
1089+ glm::fvec3 rayStart = rayCast.from .getLE ();
1090+ glm::fvec3 rayEnd = rayCast.to .getLE ();
1091+
1092+ rayStart.y += 0 .5f ;
1093+ rayEnd.y += 0 .5f ;
1094+ raycastHitPos.y += 0 .5f ;
1095+
1096+ DebugDraw::instance ().Line (rayStart, raycastHitPos, IM_COL32 (255 , 0 , 255 , 255 ));
1097+ DebugDraw::instance ().Line (raycastHitPos, rayEnd, IM_COL32 (128 , 0 , 128 , 128 ));
1098+ }
1099+
1100+ // turns out this only does the minimap ui, and not the stamina UI :/
1101+ // void CemuHooks::hook_UpdateUIPosition(PPCInterpreter_t* hCPU) {
1102+ // hCPU->instructionPointer = hCPU->sprNew.LR;
1103+ //
1104+ // EyeSide side = hCPU->gpr[10] == 0 ? EyeSide::LEFT : EyeSide::RIGHT;
1105+ // uint32_t currFrameCounter = hCPU->gpr[11];
1106+ // uint32_t doesUIManagerExist = hCPU->gpr[3] != 0;
1107+ // uint32_t uiManagerInstance = hCPU->gpr[12];
1108+ //
1109+ // if (!doesUIManagerExist) {
1110+ // return;
1111+ // }
1112+ //
1113+ // BEVec3 playerPosCopy = getMemory<BEVec3>(uiManagerInstance + offsetof(UIManager, innerArray.uiPos1));
1114+ // BEVec3 playerMtxPositionCopy = getMemory<BEVec3>(uiManagerInstance + offsetof(UIManager, innerArray.uiPos2));
1115+ //
1116+ // Log::print<INFO>("[{}] Updating UI position (frame = {}, playerPos = {}, playerMtxPos = {})", side, currFrameCounter, playerPosCopy, playerMtxPositionCopy);
1117+ //
1118+ // writeMemory(uiManagerInstance + offsetof(UIManager, innerArray.uiPos1), &playerPosCopy);
1119+ // writeMemory(uiManagerInstance + offsetof(UIManager, innerArray.uiPos2), &playerMtxPositionCopy);
1120+ // }
0 commit comments