aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/share
diff options
context:
space:
mode:
authorKevin Rushforth <[email protected]>2004-08-12 16:55:17 +0000
committerKevin Rushforth <[email protected]>2004-08-12 16:55:17 +0000
commit3f3187ab805a0173fb5a3e1e7466688d52314c64 (patch)
tree8633ad5817611cce35cef3c7625cd5969e49e590 /src/classes/share
parentc2600a074a9d3ebf863bf74301c4fb3bd351daca (diff)
Fixed Issue 12: Frame counter isn't always incremented correctly
Fixed Issue 21: Exception in WakeupOnElapsedFrames behavior stops renderer... git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@32 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src/classes/share')
-rw-r--r--src/classes/share/javax/media/j3d/BehaviorScheduler.java6
-rw-r--r--src/classes/share/javax/media/j3d/MasterControl.java41
2 files changed, 38 insertions, 9 deletions
diff --git a/src/classes/share/javax/media/j3d/BehaviorScheduler.java b/src/classes/share/javax/media/j3d/BehaviorScheduler.java
index a152408..6a59952 100644
--- a/src/classes/share/javax/media/j3d/BehaviorScheduler.java
+++ b/src/classes/share/javax/media/j3d/BehaviorScheduler.java
@@ -172,9 +172,9 @@ class BehaviorScheduler extends J3dThread {
behav.processStimulus(wakeupCond.trigEnum);
}
catch (RuntimeException e) {
- if (wakeupCond != null) {
- wakeupCond.cleanTree(behaviorStructure);
- }
+ // Force behavior condition to be unset
+ // Issue 21: don't call cleanTree here
+ behavret.conditionSet = false;
System.err.println("Exception occurred during Behavior execution:");
e.printStackTrace();
}
diff --git a/src/classes/share/javax/media/j3d/MasterControl.java b/src/classes/share/javax/media/j3d/MasterControl.java
index a14014b..71122df 100644
--- a/src/classes/share/javax/media/j3d/MasterControl.java
+++ b/src/classes/share/javax/media/j3d/MasterControl.java
@@ -1537,7 +1537,7 @@ class MasterControl {
threads = (J3dThreadData []) renderWorkThreads.toArray(false);
size = renderWorkThreads.arraySize();
- View v = null;
+ View v;
J3dThreadData lastRunThread = null;
waitTimestamp++;
sleepTime = Long.MAX_VALUE;
@@ -1545,17 +1545,28 @@ class MasterControl {
boolean threadToRun = false;
boolean needToSetWork = false;
+ // Fix for Issue 12: loop through the list of threads, calling
+ // computeCycleTime() exactly once per view. This ensures that
+ // all threads for a given view see consistent values for
+ // isMinCycleTimeAchieve and sleepTime.
+ v = null;
for (i=0; i<size; i++) {
thread = threads[i];
- if (thread.canvas == null) { // Only for swap thread
- ((Object []) thread.threadArgs)[3] = null;
- }
if (thread.view != v) {
thread.view.computeCycleTime();
if (thread.view.sleepTime < sleepTime) {
sleepTime = thread.view.sleepTime;
}
}
+ v = thread.view;
+ }
+
+ v = null;
+ for (i=0; i<size; i++) {
+ thread = threads[i];
+ if (thread.canvas == null) { // Only for swap thread
+ ((Object []) thread.threadArgs)[3] = null;
+ }
if ((thread.lastUpdateTime > thread.lastRunTime) &&
!thread.thread.userStop) {
@@ -1639,9 +1650,27 @@ class MasterControl {
if (needToSetWork && !threadToRun) {
- sleepTime -= (currentTime - lastTime);
+ // Modified the following in the course of fixing Issue 12:
+ //
+ // 1. don't modify sleepTime by subtracting a value that
+ // doesn't even represent time!
+ //
+ // 2. use sleep(sleepTime) rather than wait(sleepTime)
+ //
+ // Note that this will need to be redone anyway for Issue 11
+
+ // BUG: sleepTime -= (currentTime - lastTime);
+
if (sleepTime > 0) {
- runMonitor(SLEEP, null, null, null, null);
+ // OLD: runMonitor(SLEEP, null, null, null, null);
+
+ // System.err.println("MasterControl: sleep(" + sleepTime + ")");
+ try {
+ Thread.sleep(sleepTime);
+ } catch (InterruptedException e) {
+ System.err.println(e);
+ }
+ // System.err.println("MasterControl: done sleeping");
}
// Need to invoke MC to do work
// next time after sleep