@@ -999,9 +999,26 @@ protected void doDrawOrderedRenderable(DrawContext dc, PickSupport pickCandidate
999
999
(byte ) color .getAlpha ());
1000
1000
}
1001
1001
1002
+ // Compute the scale
1003
+ double xscale ;
1004
+ Double scale = this .getActiveAttributes ().getScale ();
1005
+ if (scale != null )
1006
+ xscale = scale * this .activeTexture .getWidth (dc );
1007
+ else
1008
+ xscale = this .activeTexture .getWidth (dc );
1009
+
1010
+ double yscale ;
1011
+ if (scale != null )
1012
+ yscale = scale * this .activeTexture .getHeight (dc );
1013
+ else
1014
+ yscale = this .activeTexture .getHeight (dc );
1015
+
1016
+ // Calculate maximum possible depth value in case of rectangle is tilted on 90 degree and rotated on 45
1017
+ double maxDepth = Math .max (xscale , yscale ) * 1.42 ;
1018
+
1002
1019
// The image is drawn using a parallel projection.
1003
1020
osh .pushProjectionIdentity (gl );
1004
- gl .glOrtho (0d , dc .getView ().getViewport ().width , 0d , dc .getView ().getViewport ().height , -1d , 1d );
1021
+ gl .glOrtho (0d , dc .getView ().getViewport ().width , 0d , dc .getView ().getViewport ().height , -maxDepth , maxDepth );
1005
1022
1006
1023
// Apply the depth buffer but don't change it (for screen-space shapes).
1007
1024
if ((!dc .isDeepPickingEnabled ()))
@@ -1014,52 +1031,34 @@ protected void doDrawOrderedRenderable(DrawContext dc, PickSupport pickCandidate
1014
1031
1015
1032
// Adjust depth of image to bring it slightly forward
1016
1033
double depth = opm .screenPoint .z - (8d * 0.00048875809d );
1017
- depth = depth < 0d ? 0d : (depth > 1d ? 1d : depth );
1034
+ depth = depth < 0d ? 0d : Math . min (depth , 1d );
1018
1035
gl .glDepthFunc (GL .GL_LESS );
1019
1036
gl .glDepthRange (depth , depth );
1020
1037
1021
1038
// The image is drawn using a translated and scaled unit quad.
1022
- // Translate to screen point and adjust to align hot spot.
1023
1039
osh .pushModelviewIdentity (gl );
1024
- gl .glTranslated (opm .screenPoint .x + this .dx , opm .screenPoint .y + this .dy , 0 );
1025
1040
1026
- // Compute the scale
1027
- double xscale ;
1028
- Double scale = this .getActiveAttributes ().getScale ();
1029
- if (scale != null )
1030
- xscale = scale * this .activeTexture .getWidth (dc );
1031
- else
1032
- xscale = this .activeTexture .getWidth (dc );
1033
-
1034
- double yscale ;
1035
- if (scale != null )
1036
- yscale = scale * this .activeTexture .getHeight (dc );
1037
- else
1038
- yscale = this .activeTexture .getHeight (dc );
1041
+ // Translate to screen point.
1042
+ gl .glTranslated (opm .screenPoint .x , opm .screenPoint .y , 0 );
1039
1043
1040
- Double heading = getActiveAttributes (). getHeading ();
1044
+ // Apply the pitch if specified.
1041
1045
Double pitch = getActiveAttributes ().getPitch ();
1042
-
1043
- // Adjust heading to be relative to globe or screen
1044
- if (heading != null )
1045
- {
1046
- if (AVKey .RELATIVE_TO_GLOBE .equals (this .getActiveAttributes ().getHeadingReference ()))
1047
- heading = dc .getView ().getHeading ().degrees - heading ;
1048
- else
1049
- heading = -heading ;
1046
+ if (pitch != null ) {
1047
+ gl .glRotated (pitch , 1 , 0 , 0 );
1050
1048
}
1051
1049
1052
- // Apply the heading and pitch if specified.
1053
- if (heading != null || pitch != null )
1054
- {
1055
- gl .glTranslated (xscale / 2 , yscale / 2 , 0 );
1056
- if (pitch != null )
1057
- gl .glRotated (pitch , 1 , 0 , 0 );
1058
- if (heading != null )
1059
- gl .glRotated (heading , 0 , 0 , 1 );
1060
- gl .glTranslated (-xscale / 2 , -yscale / 2 , 0 );
1050
+ // Apply the heading if specified.
1051
+ Double heading = getActiveAttributes ().getHeading ();
1052
+ if (heading != null ) {
1053
+ // Adjust heading to be relative to globe or screen
1054
+ heading = AVKey .RELATIVE_TO_GLOBE .equals (this .getActiveAttributes ().getHeadingReference ())
1055
+ ? dc .getView ().getHeading ().degrees - heading : -heading ;
1056
+ gl .glRotated (heading , 0 , 0 , 1 );
1061
1057
}
1062
1058
1059
+ // Adjust to align hot spot.
1060
+ gl .glTranslated (this .dx , this .dy , 0 );
1061
+
1063
1062
// Scale the unit quad
1064
1063
gl .glScaled (xscale , yscale , 1 );
1065
1064
0 commit comments