Added a newFrame() method to UniformBindingManager

to signal the beginning of a frame.  Currently this
just grabs the time and tpf values once so as to avoid
per-material Float allocation and time drift within a
frame.
RenderManager now calls this at the beginning of the
root-level render() method.
experimental
pspeed42 11 years ago
parent 852ae28605
commit c0465b73a8
  1. 1
      jme3-core/src/main/java/com/jme3/renderer/RenderManager.java
  2. 18
      jme3-core/src/main/java/com/jme3/shader/UniformBindingManager.java

@ -1035,6 +1035,7 @@ public class RenderManager {
}
this.shader = renderer.getCaps().contains(Caps.GLSL100);
uniformBindingManager.newFrame();
for (int i = 0; i < preViewPorts.size(); i++) {
ViewPort vp = preViewPorts.get(i);

@ -51,7 +51,8 @@ import java.util.List;
public class UniformBindingManager {
private Timer timer;
private float near, far;
private Float near, far;
private Float time, tpf;
private int viewX, viewY, viewWidth, viewHeight;
private Vector3f camUp = new Vector3f(),
camLeft = new Vector3f(),
@ -196,10 +197,10 @@ public class UniformBindingManager {
u.setValue(VarType.Vector3, camUp);
break;
case Time:
u.setValue(VarType.Float, timer.getTimeInSeconds());
u.setValue(VarType.Float, time);
break;
case Tpf:
u.setValue(VarType.Float, timer.getTimePerFrame());
u.setValue(VarType.Float, tpf);
break;
case FrameRate:
u.setValue(VarType.Float, timer.getFrameRate());
@ -251,4 +252,15 @@ public class UniformBindingManager {
this.viewWidth = viewWidth;
this.viewHeight = viewHeight;
}
/**
* Internal use only. Called by the RenderManager at the beginning of a
* new application frame.
*/
public void newFrame() {
// Avoid per-material Float allocations and lock in the
// time for this frame to avoid inter-frame drift.
time = timer.getTimeInSeconds();
tpf = timer.getTimePerFrame();
}
}

Loading…
Cancel
Save