Skip to content

Commit 22730ee

Browse files
committed
fix culling
enable render distance toggle
1 parent 8cb6513 commit 22730ee

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

PracticeModManager.cs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ class PracticeModManager : MonoBehaviour
2828
int storedMap;
2929
float storeTime;
3030
float teleportTime;
31-
31+
bool unlimitedRenderDistance;
3232

3333
void Awake()
3434
{
3535
PracticeModManager.Instance = this;
3636
noClip = false;
37+
unlimitedRenderDistance = false;
3738
noClipSpeed = 10.0f;
3839
defaultFarClipPlane = 999f;
3940

@@ -94,8 +95,6 @@ void Update()
9495

9596
if (noClip)
9697
{
97-
playerCamera.GetComponent<CameraSettingsLayer>().enabled = false;
98-
playerCamera.farClipPlane = 10000f;
9998
this.noClipSpeed += Input.mouseScrollDelta.y;
10099
this.noClipSpeed = Mathf.Max(0f, this.noClipSpeed);
101100
Vector3 directionVector = new Vector3(GameManager.GM.playerInput.GetAxisRaw("Move Horizontal"), 0f, GameManager.GM.playerInput.GetAxisRaw("Move Vertical"));
@@ -108,17 +107,30 @@ void Update()
108107
directionVector.y -= 1f;
109108
}
110109
playerMotor.transform.Translate(directionVector.normalized * Time.deltaTime * this.noClipSpeed);
110+
playerCamera.cullingMatrix = new Matrix4x4(Vector4.positiveInfinity, Vector4.positiveInfinity, Vector4.positiveInfinity, Vector4.positiveInfinity);
111111
}
112-
else
112+
113+
if(noClip || unlimitedRenderDistance)
113114
{
115+
playerCamera.cullingMatrix = new Matrix4x4(Vector4.positiveInfinity, Vector4.positiveInfinity, Vector4.positiveInfinity, Vector4.positiveInfinity);
114116
playerCamera.GetComponent<CameraSettingsLayer>().enabled = false;
117+
playerCamera.farClipPlane = 10000f;
118+
}
119+
else
120+
{
121+
122+
playerCamera.GetComponent<CameraSettingsLayer>().enabled = true;
123+
playerCamera.ResetCullingMatrix();
115124
}
116125

117126
if(playerText != null)
118127
{
119128
playerText.text = GetPlayerTextString();
120129
}
121130

131+
if (Input.GetKeyDown(KeyCode.F4) && !noClip)
132+
unlimitedRenderDistance = !unlimitedRenderDistance;
133+
122134
if (Input.GetKeyDown(KeyCode.F5))
123135
StorePosition();
124136

@@ -132,17 +144,6 @@ void Update()
132144
RestartMap();
133145
}
134146

135-
void LateUpdate()
136-
{
137-
if (noClip)
138-
{
139-
playerCamera.farClipPlane = 10000f;
140-
}
141-
else
142-
{
143-
playerCamera.farClipPlane = defaultFarClipPlane;
144-
}
145-
}
146147

147148
Text NewPlayerText()
148149
{
@@ -181,6 +182,9 @@ string GetPlayerTextString()
181182
if (noClip)
182183
dynamicInfo += "\nNoClip";
183184

185+
if (!noClip && unlimitedRenderDistance)
186+
dynamicInfo += "\nUnlimited Render Distance";
187+
184188
if (flashLight.activeSelf)
185189
dynamicInfo += "\nFlashlight";
186190

0 commit comments

Comments
 (0)