aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/share
diff options
context:
space:
mode:
authorChien Yang <[email protected]>2004-12-09 17:49:17 +0000
committerChien Yang <[email protected]>2004-12-09 17:49:17 +0000
commitb1d5cf7a169b2042dfc1d7bb64147b7f9cd77d0f (patch)
tree8fab57f3c2328f2b9caeff55dda02578366ef60f /src/classes/share
parent0ca87453d48a8593ab0598994a5ced64f76ee1e2 (diff)
1) Added a better fix to issue 15 and 88
2) Renamed VWORLD_SCALE_DIRTY to VIEW_MATRIX_DIRTY to reflect the real meaning of this dirty bit. 3) Added comments to a bug in LightBin.updateAttributes(). git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@87 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src/classes/share')
-rw-r--r--src/classes/share/javax/media/j3d/Canvas3D.java2
-rw-r--r--src/classes/share/javax/media/j3d/CanvasViewCache.java2
-rw-r--r--src/classes/share/javax/media/j3d/EnvironmentSet.java169
-rw-r--r--src/classes/share/javax/media/j3d/GraphicsContext3D.java9
-rw-r--r--src/classes/share/javax/media/j3d/LightBin.java9
-rw-r--r--src/classes/share/javax/media/j3d/Renderer.java7
6 files changed, 93 insertions, 105 deletions
diff --git a/src/classes/share/javax/media/j3d/Canvas3D.java b/src/classes/share/javax/media/j3d/Canvas3D.java
index 8a7dc82..0fabc33 100644
--- a/src/classes/share/javax/media/j3d/Canvas3D.java
+++ b/src/classes/share/javax/media/j3d/Canvas3D.java
@@ -299,7 +299,7 @@ public class Canvas3D extends Canvas {
static final int RENDERMOLECULE_DIRTY = 0x1000;
static final int FOG_DIRTY = 0x2000;
static final int MODELCLIP_DIRTY = 0x4000;
- static final int VWORLD_SCALE_DIRTY = 0x8000;
+ static final int VIEW_MATRIX_DIRTY = 0x8000;
// Use to notify D3D Canvas when window change
static final int RESIZE = 1;
diff --git a/src/classes/share/javax/media/j3d/CanvasViewCache.java b/src/classes/share/javax/media/j3d/CanvasViewCache.java
index 43469bc..6c269df 100644
--- a/src/classes/share/javax/media/j3d/CanvasViewCache.java
+++ b/src/classes/share/javax/media/j3d/CanvasViewCache.java
@@ -488,7 +488,7 @@ class CanvasViewCache extends Object {
if(cvc != null)
copyComputedCanvasViewCache(cvc, doInfinite);
- canvas.canvasDirty |= Canvas3D.VWORLD_SCALE_DIRTY;
+ canvas.canvasDirty |= Canvas3D.VIEW_MATRIX_DIRTY;
// reset screen view dirty mask if canvas is offScreen. Note:
// there is only one canvas per offscreen, so it is ok to
diff --git a/src/classes/share/javax/media/j3d/EnvironmentSet.java b/src/classes/share/javax/media/j3d/EnvironmentSet.java
index 309d909..2586522 100644
--- a/src/classes/share/javax/media/j3d/EnvironmentSet.java
+++ b/src/classes/share/javax/media/j3d/EnvironmentSet.java
@@ -434,125 +434,98 @@ class EnvironmentSet extends Object implements ObjectUpdate{
int i, numLights;
float red, green, blue;
double scale;
-
+ boolean updateSceneAmbient = false, updateLightEnables = false;
+ boolean updateModelClip = false, updateFog = false;
// within frame
if (cv.environmentSet != this ) {
if (cv.enableMask != enableMask) {
- cv.setLightEnables(cv.ctx, enableMask, renderBin.maxLights);
- cv.enableMask = enableMask;
+ updateLightEnables = true;
}
if (cv.sceneAmbient.x != sceneAmbient.x ||
cv.sceneAmbient.y != sceneAmbient.y ||
cv.sceneAmbient.z != sceneAmbient.z ) {
- cv.setSceneAmbient(cv.ctx,
- sceneAmbient.x, sceneAmbient.y, sceneAmbient.z);
-
- cv.sceneAmbient.x = sceneAmbient.x;
- cv.sceneAmbient.y = sceneAmbient.y;
- cv.sceneAmbient.z = sceneAmbient.z;
+ updateSceneAmbient = true;
}
-
if (cv.fog != fog) {
- if (fog != null) {
- scale = lightBin.geometryBackground == null?
- cv.canvasViewCache.getVworldToCoexistenceScale():
- cv.canvasViewCache.getInfVworldToCoexistenceScale();
- fog.update(cv.ctx, scale);
- } else {
- cv.disableFog(cv.ctx);
- }
- cv.fog = fog;
+ updateFog = true;
}
if (cv.modelClip != modelClip) {
- if (modelClip != null) {
- modelClip.update(cv, enableMCMask);
- } else {
- cv.disableModelClip(cv.ctx);
- }
- cv.modelClip = modelClip;
+ updateModelClip = true;
}
-
- cv.environmentSet = this;
- cv.canvasDirty &= ~(Canvas3D.LIGHTENABLES_DIRTY|
- Canvas3D.AMBIENTLIGHT_DIRTY |
- Canvas3D.FOG_DIRTY |
- Canvas3D.MODELCLIP_DIRTY);
-
}
- else {
- // across frames
- if ((cv.canvasDirty & (Canvas3D.LIGHTENABLES_DIRTY|
- Canvas3D.AMBIENTLIGHT_DIRTY|
- Canvas3D.FOG_DIRTY|
- Canvas3D.MODELCLIP_DIRTY)) != 0) {
- if ((cv.canvasDirty & Canvas3D.LIGHTENABLES_DIRTY) != 0) {
- cv.setLightEnables(cv.ctx, enableMask, renderBin.maxLights);
- cv.enableMask = enableMask;
- }
- if ((cv.canvasDirty & Canvas3D.AMBIENTLIGHT_DIRTY) != 0) {
- cv.setSceneAmbient(cv.ctx, sceneAmbient.x,
- sceneAmbient.y,
- sceneAmbient.z);
- cv.sceneAmbient.x = sceneAmbient.x;
- cv.sceneAmbient.y = sceneAmbient.y;
- cv.sceneAmbient.z = sceneAmbient.z;
- }
+ // Check for dirtybit.
+ if ((cv.canvasDirty & (Canvas3D.LIGHTENABLES_DIRTY|
+ Canvas3D.AMBIENTLIGHT_DIRTY|
+ Canvas3D.FOG_DIRTY|
+ Canvas3D.MODELCLIP_DIRTY|
+ Canvas3D.VIEW_MATRIX_DIRTY)) != 0) {
- if ((cv.canvasDirty & Canvas3D.FOG_DIRTY) != 0) {
- if (fog != null) {
- scale = lightBin.geometryBackground == null?
- cv.canvasViewCache.getVworldToCoexistenceScale():
- cv.canvasViewCache.getInfVworldToCoexistenceScale();
- fog.update(cv.ctx, scale);
- } else {
- cv.disableFog(cv.ctx);
- }
- cv.fog = fog;
- }
-
- if ((cv.canvasDirty & Canvas3D.MODELCLIP_DIRTY) != 0) {
- if (modelClip != null) {
- modelClip.update(cv, enableMCMask);
- } else {
- cv.disableModelClip(cv.ctx);
- }
- cv.modelClip = modelClip;
- }
-
- cv.canvasDirty &= ~(Canvas3D.LIGHTENABLES_DIRTY|
- Canvas3D.AMBIENTLIGHT_DIRTY |
- Canvas3D.FOG_DIRTY |
- Canvas3D.MODELCLIP_DIRTY);
+ if ((cv.canvasDirty & Canvas3D.LIGHTENABLES_DIRTY) != 0) {
+ updateLightEnables = true;
+ }
+
+ if ((cv.canvasDirty & Canvas3D.AMBIENTLIGHT_DIRTY) != 0) {
+ updateSceneAmbient = true;
+ }
+
+ if ((cv.canvasDirty & Canvas3D.FOG_DIRTY) != 0) {
+ updateFog = true;
+ }
+
+ if ((cv.canvasDirty & Canvas3D.MODELCLIP_DIRTY) != 0) {
+ updateModelClip = true;
}
- // Update modelClip and fog if view matrix changed.
- // Note : If using stereo, the vworldToEc matrix will be different
- // for each stereo pass, in this case, we will need to
- // update modelClip and fog.
-
- if (((cv.canvasDirty & Canvas3D.VWORLD_SCALE_DIRTY) != 0) ||
- cv.useStereo) {
- if (fog instanceof LinearFogRetained) {
- if (fog != null) {
- scale = lightBin.geometryBackground == null?
- cv.canvasViewCache.getVworldToCoexistenceScale():
- cv.canvasViewCache.getInfVworldToCoexistenceScale();
- fog.update(cv.ctx, scale);
- } else {
- cv.disableFog(cv.ctx);
- }
- cv.fog = fog;
- }
+ if ((cv.canvasDirty & Canvas3D.VIEW_MATRIX_DIRTY) != 0) {
+ updateFog = true;
+ updateModelClip = true;
+ }
+ }
- if (modelClip != null) {
- modelClip.update(cv, enableMCMask);
- cv.modelClip = modelClip;
- }
- }
+ // do states update here.
+ if (updateLightEnables) {
+ cv.setLightEnables(cv.ctx, enableMask, renderBin.maxLights);
+ cv.enableMask = enableMask;
+ }
+
+ if (updateSceneAmbient) {
+ cv.setSceneAmbient(cv.ctx, sceneAmbient.x,
+ sceneAmbient.y, sceneAmbient.z);
+ cv.sceneAmbient.set(sceneAmbient);
}
+
+ if (updateFog) {
+ if (fog != null) {
+ scale = lightBin.geometryBackground == null?
+ cv.canvasViewCache.getVworldToCoexistenceScale():
+ cv.canvasViewCache.getInfVworldToCoexistenceScale();
+ fog.update(cv.ctx, scale);
+ } else {
+ cv.disableFog(cv.ctx);
+ }
+ cv.fog = fog;
+ }
+
+ if (updateModelClip) {
+ if (modelClip != null) {
+ modelClip.update(cv, enableMCMask);
+ } else {
+ cv.disableModelClip(cv.ctx);
+ }
+ cv.modelClip = modelClip;
+ }
+
+ cv.canvasDirty &= ~(Canvas3D.LIGHTENABLES_DIRTY|
+ Canvas3D.AMBIENTLIGHT_DIRTY |
+ Canvas3D.FOG_DIRTY |
+ Canvas3D.MODELCLIP_DIRTY |
+ Canvas3D.VIEW_MATRIX_DIRTY);
+
+ cv.environmentSet = this;
+
}
}
diff --git a/src/classes/share/javax/media/j3d/GraphicsContext3D.java b/src/classes/share/javax/media/j3d/GraphicsContext3D.java
index 32754ed..3c22585 100644
--- a/src/classes/share/javax/media/j3d/GraphicsContext3D.java
+++ b/src/classes/share/javax/media/j3d/GraphicsContext3D.java
@@ -2424,10 +2424,9 @@ public class GraphicsContext3D extends Object {
canvas3d.enableMask = enableMask;
}
+ // Force LightBin.updateAttributes and EnvironmentSet.updateAttributes
+ // to use the within frame case.
canvas3d.lightBin = null;
-
-
- // Mark the envset as dirty for the canvas for scene graph rendering
canvas3d.environmentSet = null;
if (fog != null) {
@@ -2472,6 +2471,10 @@ public class GraphicsContext3D extends Object {
canvas3d.canvasDirty |= Canvas3D.MODELCLIP_DIRTY;
}
}
+
+ // Force EnvironmentSet.updateAttributes to use the within frame case.
+ canvas3d.environmentSet = null;
+
}
diff --git a/src/classes/share/javax/media/j3d/LightBin.java b/src/classes/share/javax/media/j3d/LightBin.java
index 28aeb08..b6dce07 100644
--- a/src/classes/share/javax/media/j3d/LightBin.java
+++ b/src/classes/share/javax/media/j3d/LightBin.java
@@ -369,6 +369,13 @@ class LightBin extends Object implements ObjectUpdate {
int frameCount = VirtualUniverse.mc.frameCount;
+ // TODO: When working on issue 15 and 88, we realise that the
+ // logic in this method flaw. As we are ready into 1.3.2beta1
+ // phase, and there isn't an existing issue related to the logic
+ // error in method, we decided not to fix it for now. This method
+ // should have the logic as in EnvironmentSet.updateAttributes();
+ // The fix to issue 15 and 88.
+
// within frames
if (cv.lightBin != this) {
@@ -424,7 +431,7 @@ class LightBin extends Object implements ObjectUpdate {
cv.canvasDirty &= ~Canvas3D.LIGHTBIN_DIRTY;
}
- else if ((pointLts.size() > 0) && ((cv.canvasDirty & Canvas3D.VWORLD_SCALE_DIRTY) != 0 )) {
+ else if ((pointLts.size() > 0) && ((cv.canvasDirty & Canvas3D.VIEW_MATRIX_DIRTY) != 0 )) {
if (geometryBackground == null) {
scale = cv.canvasViewCache.getVworldToCoexistenceScale();
cv.setModelViewMatrix(cv.ctx, cv.vpcToEc.mat,
diff --git a/src/classes/share/javax/media/j3d/Renderer.java b/src/classes/share/javax/media/j3d/Renderer.java
index f05ebb0..133fd77 100644
--- a/src/classes/share/javax/media/j3d/Renderer.java
+++ b/src/classes/share/javax/media/j3d/Renderer.java
@@ -289,7 +289,7 @@ class Renderer extends J3dThread {
Canvas3D.LIGHTENABLES_DIRTY |
Canvas3D.AMBIENTLIGHT_DIRTY |
Canvas3D.MODELCLIP_DIRTY |
- Canvas3D.VWORLD_SCALE_DIRTY |
+ Canvas3D.VIEW_MATRIX_DIRTY |
Canvas3D.FOG_DIRTY));
// Force reload of transform next frame
cv.modelMatrix = null;
@@ -1279,6 +1279,11 @@ class Renderer extends J3dThread {
}
}
+ // Force view matrix dirty for each eye.
+ if (useStereo) {
+ canvas.canvasDirty |= Canvas3D.VIEW_MATRIX_DIRTY;
+ }
+
// render opaque geometry
renderBin.renderOpaque(canvas);