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
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.renderer.queue.RenderQueue.ShadowMode;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.debug.WireFrustum;
import com.jme3.texture.FrameBuffer;
Expand Down Expand Up @@ -427,6 +428,10 @@ protected void doDisplayFrustumDebug(int shadowMapIndex) {
// Default implementation does nothing.
}

protected Node getSceneForDebug() {
return (Node) viewPort.getScenes().get(0);
}

@Override
public void postQueue(RenderQueue rq) {
lightReceivers.clear();
Expand All @@ -449,7 +454,10 @@ public void postQueue(RenderQueue rq) {
renderShadowMap(shadowMapIndex);
}

debugfrustums = false;
if (debugfrustums) {
debugfrustums = false;
getSceneForDebug().updateGeometricState();
}

//restore setting for future rendering
r.setFrameBuffer(viewPort.getOutputFrameBuffer());
Expand Down Expand Up @@ -956,3 +964,5 @@ public void write(JmeExporter ex) throws IOException {
oc.write(edgesThickness, "edgesThickness", 1.0f);
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import com.jme3.renderer.Camera;
import com.jme3.renderer.queue.GeometryList;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.util.clone.Cloner;

Expand Down Expand Up @@ -212,9 +211,9 @@ protected Camera getShadowCam(int shadowMapIndex) {

@Override
protected void doDisplayFrustumDebug(int shadowMapIndex) {
((Node) viewPort.getScenes().get(0)).attachChild(createFrustum(points, shadowMapIndex));
getSceneForDebug().attachChild(createFrustum(points, shadowMapIndex));
ShadowUtil.updateFrustumPoints2(shadowCam, points);
((Node) viewPort.getScenes().get(0)).attachChild(createFrustum(points, shadowMapIndex));
getSceneForDebug().attachChild(createFrustum(points, shadowMapIndex));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import com.jme3.renderer.queue.GeometryList;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.util.TempVars;
import com.jme3.util.clone.Cloner;
Expand Down Expand Up @@ -166,7 +165,7 @@ protected void doDisplayFrustumDebug(int shadowMapIndex) {
}
Geometry geo = frustums[shadowMapIndex];
if (geo.getParent() == null) {
((Node) viewPort.getScenes().get(0)).attachChild(geo);
getSceneForDebug().attachChild(geo);
}
}

Expand Down
21 changes: 13 additions & 8 deletions jme3-core/src/main/java/com/jme3/shadow/PssmShadowRenderer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2021 jMonkeyEngine
* Copyright (c) 2009-2025 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -438,13 +438,9 @@ public void postQueue(RenderQueue rq) {
renderManager.setCamera(shadowCam, false);

if (debugfrustums) {
// frustumFromBound(b.casterBB,ColorRGBA.Blue );
// frustumFromBound(b.receiverBB,ColorRGBA.Green );
// frustumFromBound(b.splitBB,ColorRGBA.Yellow );
((Node) viewPort.getScenes().get(0)).attachChild(createFrustum(points, i));
getSceneForDebug().attachChild(createFrustum(points, i));
ShadowUtil.updateFrustumPoints2(shadowCam, points);
((Node) viewPort.getScenes().get(0)).attachChild(createFrustum(points, i));

getSceneForDebug().attachChild(createFrustum(points, i));
}

r.setFrameBuffer(shadowFB[i]);
Expand All @@ -456,7 +452,11 @@ public void postQueue(RenderQueue rq) {
viewPort.getQueue().renderShadowQueue(splitOccluders, renderManager, shadowCam, true);
renderManager.setLightFilter(tmpLightFilter);
}
debugfrustums = false;

if (debugfrustums) {
debugfrustums = false;
getSceneForDebug().updateGeometricState();
}

//restore setting for future rendering
r.setFrameBuffer(viewPort.getOutputFrameBuffer());
Expand All @@ -465,6 +465,11 @@ public void postQueue(RenderQueue rq) {
renderManager.setCamera(viewCam, false);

}

protected Node getSceneForDebug() {
return (Node) viewPort.getScenes().get(0);
}

boolean debugfrustums = false;

public void displayFrustum() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import com.jme3.renderer.Camera;
import com.jme3.renderer.queue.GeometryList;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.util.TempVars;
import com.jme3.util.clone.Cloner;
Expand Down Expand Up @@ -89,7 +88,7 @@ public SpotLightShadowRenderer(AssetManager assetManager, int shadowMapSize) {
init(shadowMapSize);
}


private void init(int shadowMapSize) {
shadowCam = new Camera(shadowMapSize, shadowMapSize);
for (int i = 0; i < points.length; i++) {
Expand Down Expand Up @@ -175,9 +174,9 @@ protected Camera getShadowCam(int shadowMapIndex) {
protected void doDisplayFrustumDebug(int shadowMapIndex) {
Vector3f[] points2 = points.clone();

((Node) viewPort.getScenes().get(0)).attachChild(createFrustum(points, shadowMapIndex));
getSceneForDebug().attachChild(createFrustum(points, shadowMapIndex));
ShadowUtil.updateFrustumPoints2(shadowCam, points2);
((Node) viewPort.getScenes().get(0)).attachChild(createFrustum(points2, shadowMapIndex));
getSceneForDebug().attachChild(createFrustum(points2, shadowMapIndex));
}

@Override
Expand Down