Skip to content

Commit

Permalink
Prevent locking camera from resetting render (#1658)
Browse files Browse the repository at this point in the history
* Prevent locking camera from resetting render

* Soft-refresh the scene when un/locking the camera and keep rendering after soft resets.

---------

Co-authored-by: Maik Marschner <[email protected]>
  • Loading branch information
Peregrine05 and leMaik authored Oct 29, 2023
1 parent 5c91b71 commit c91e3e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions chunky/src/java/se/llbit/chunky/renderer/scene/Camera.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.apache.commons.math3.util.FastMath;
import se.llbit.chunky.entity.Entity;
import se.llbit.chunky.renderer.ApertureShape;
import se.llbit.chunky.renderer.Refreshable;
import se.llbit.chunky.renderer.projection.ApertureProjector;
import se.llbit.chunky.renderer.projection.FisheyeProjector;
import se.llbit.chunky.renderer.projection.ForwardDisplacementProjector;
Expand Down Expand Up @@ -93,7 +92,7 @@ public static double clampedFovTan(double fov) {
*/
public static final double MAX_SUBJECT_DISTANCE = 1000;

private final Refreshable scene;
private final Scene scene;

private boolean lockCamera = false;

Expand Down Expand Up @@ -167,7 +166,7 @@ public static double clampedFovTan(double fov) {
/**
* @param scene The scene that will be refreshed after the camera view changes.
*/
public Camera(Refreshable scene) {
public Camera(Scene scene) {
this.scene = scene;
transform.setIdentity();
initProjector();
Expand Down Expand Up @@ -788,7 +787,7 @@ public ApertureShape getApertureShape() {

public void setCameraLocked(boolean value) {
lockCamera = value;
scene.refresh();
scene.softRefresh();
}

public boolean getCameraLocked() {
Expand Down
4 changes: 2 additions & 2 deletions chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java
Original file line number Diff line number Diff line change
Expand Up @@ -1572,7 +1572,7 @@ public synchronized void startHeadlessRender() {
* restarted
*/
public boolean shouldRefresh() {
return resetReason != ResetReason.NONE;
return resetReason.shouldRerender();
}

/**
Expand Down Expand Up @@ -3068,7 +3068,7 @@ private synchronized void refresh(ResetReason reason) {
if (mode == RenderMode.PAUSED) {
mode = RenderMode.RENDERING;
}
if (reason != ResetReason.NONE) {
if (reason.shouldRerender()) {
spp = 0;
renderTime = 0;
}
Expand Down

0 comments on commit c91e3e8

Please sign in to comment.