aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarvey Harrison <[email protected]>2012-11-18 16:37:48 -0800
committerHarvey Harrison <[email protected]>2012-11-18 16:37:48 -0800
commit3be80211208f09dafeba1f1b70e06d47ceb736c1 (patch)
tree5b30a345fcb143e7ba3531d110ba6e9696ccf0d6
parent9fcef4ebc1d2596384e580926993ef36ff509c9e (diff)
j3dcore: introduce a useAlpha helper to collapse some tricky logic
Signed-off-by: Harvey Harrison <[email protected]>
-rw-r--r--src/classes/share/javax/media/j3d/AppearanceRetained.java13
-rw-r--r--src/classes/share/javax/media/j3d/GraphicsContext3D.java11
-rw-r--r--src/classes/share/javax/media/j3d/RenderAtom.java6
-rw-r--r--src/classes/share/javax/media/j3d/RenderMolecule.java16
-rw-r--r--src/classes/share/javax/media/j3d/TransparencyAttributesRetained.java9
5 files changed, 17 insertions, 38 deletions
diff --git a/src/classes/share/javax/media/j3d/AppearanceRetained.java b/src/classes/share/javax/media/j3d/AppearanceRetained.java
index 14d5ea1..3edb659 100644
--- a/src/classes/share/javax/media/j3d/AppearanceRetained.java
+++ b/src/classes/share/javax/media/j3d/AppearanceRetained.java
@@ -1324,17 +1324,8 @@ class AppearanceRetained extends NodeComponentRetained {
}
boolean isOpaque(int geoType) {
- TransparencyAttributesRetained ta;
-
- ta = transparencyAttributes;
- if (ta != null &&
- ta.transparencyMode != TransparencyAttributes.NONE &&
- (VirtualUniverse.mc.isD3D() ||
- (!VirtualUniverse.mc.isD3D() &&
- (ta.transparencyMode !=
- TransparencyAttributes.SCREEN_DOOR)))) {
- return(false);
- }
+ if (TransparencyAttributesRetained.useAlpha(transparencyAttributes))
+ return false;
switch (geoType) {
case GeometryRetained.GEO_TYPE_POINT_SET:
diff --git a/src/classes/share/javax/media/j3d/GraphicsContext3D.java b/src/classes/share/javax/media/j3d/GraphicsContext3D.java
index d3dae8b..f37686d 100644
--- a/src/classes/share/javax/media/j3d/GraphicsContext3D.java
+++ b/src/classes/share/javax/media/j3d/GraphicsContext3D.java
@@ -2763,14 +2763,9 @@ public class GraphicsContext3D extends Object {
canvas3d.canvasDirty |= Canvas3D.TRANSPARENCYATTRS_DIRTY;
canvas3d.transparency = app.transparencyAttributes;
- useAlpha = useAlpha || ((app.transparencyAttributes.transparencyMode !=
- TransparencyAttributes.NONE)
- &&
- (VirtualUniverse.mc.isD3D()
- ||
- (!VirtualUniverse.mc.isD3D() &&
- (app.transparencyAttributes. transparencyMode !=
- TransparencyAttributes.SCREEN_DOOR))));
+ if (!useAlpha)
+ useAlpha = TransparencyAttributesRetained.useAlpha(app.transparencyAttributes);
+
} else {
canvas3d.resetTransparency(canvas3d.ctx, geometryType,
polygonMode, lineAA, pointAA);
diff --git a/src/classes/share/javax/media/j3d/RenderAtom.java b/src/classes/share/javax/media/j3d/RenderAtom.java
index 66e202b..9a75be0 100644
--- a/src/classes/share/javax/media/j3d/RenderAtom.java
+++ b/src/classes/share/javax/media/j3d/RenderAtom.java
@@ -232,11 +232,7 @@ class RenderAtom extends Object implements ObjectUpdate {
break;
}
- return ((ta == null) ||
- (ta.transparencyMode ==
- TransparencyAttributes.NONE) ||
- (ta.transparencyMode ==
- TransparencyAttributes.SCREEN_DOOR));
+ return !TransparencyAttributesRetained.useAlpha(ta);
}
boolean inRenderBin() {
diff --git a/src/classes/share/javax/media/j3d/RenderMolecule.java b/src/classes/share/javax/media/j3d/RenderMolecule.java
index 0b214d3..3e7cb64 100644
--- a/src/classes/share/javax/media/j3d/RenderMolecule.java
+++ b/src/classes/share/javax/media/j3d/RenderMolecule.java
@@ -1698,15 +1698,7 @@ class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponen
TextureUnitStateRetained[] texUnits) {
boolean alphaBlend, alphaTest, textureBlend = false;
- alphaBlend =
- definingTransparency != null &&
- definingTransparency.transparencyMode !=
- TransparencyAttributes.NONE &&
- (VirtualUniverse.mc.isD3D() ||
- !VirtualUniverse.mc.isD3D() &&
- definingTransparency.transparencyMode !=
- TransparencyAttributes.SCREEN_DOOR);
-
+ alphaBlend = TransparencyAttributesRetained.useAlpha(definingTransparency);
if (texUnits != null) {
for (int i = 0;
@@ -2420,11 +2412,7 @@ class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponen
return false;
}
}
- return ((definingTransparency == null) ||
- (definingTransparency.transparencyMode ==
- TransparencyAttributes.NONE) ||
- (definingTransparency.transparencyMode ==
- TransparencyAttributes.SCREEN_DOOR));
+ return !TransparencyAttributesRetained.useAlpha(definingTransparency);
}
diff --git a/src/classes/share/javax/media/j3d/TransparencyAttributesRetained.java b/src/classes/share/javax/media/j3d/TransparencyAttributesRetained.java
index a03667f..4b25e60 100644
--- a/src/classes/share/javax/media/j3d/TransparencyAttributesRetained.java
+++ b/src/classes/share/javax/media/j3d/TransparencyAttributesRetained.java
@@ -229,6 +229,15 @@ class TransparencyAttributesRetained extends NodeComponentRetained {
}
}
+static boolean useAlpha(TransparencyAttributesRetained ta) {
+ if (ta != null &&
+ ta.transparencyMode != TransparencyAttributes.NONE &&
+ ta.transparencyMode != TransparencyAttributes.SCREEN_DOOR) {
+ return true;
+ }
+ return false;
+}
+
void updateNative(Context ctx,
float alpha, int geometryType, int polygonMode,
boolean lineAA,