@@ -999,9 +999,26 @@ protected void doDrawOrderedRenderable(DrawContext dc, PickSupport pickCandidate
999999 (byte ) color .getAlpha ());
10001000 }
10011001
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+
10021019 // The image is drawn using a parallel projection.
10031020 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 );
10051022
10061023 // Apply the depth buffer but don't change it (for screen-space shapes).
10071024 if ((!dc .isDeepPickingEnabled ()))
@@ -1014,52 +1031,34 @@ protected void doDrawOrderedRenderable(DrawContext dc, PickSupport pickCandidate
10141031
10151032 // Adjust depth of image to bring it slightly forward
10161033 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 );
10181035 gl .glDepthFunc (GL .GL_LESS );
10191036 gl .glDepthRange (depth , depth );
10201037
10211038 // The image is drawn using a translated and scaled unit quad.
1022- // Translate to screen point and adjust to align hot spot.
10231039 osh .pushModelviewIdentity (gl );
1024- gl .glTranslated (opm .screenPoint .x + this .dx , opm .screenPoint .y + this .dy , 0 );
10251040
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 );
10391043
1040- Double heading = getActiveAttributes (). getHeading ();
1044+ // Apply the pitch if specified.
10411045 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 );
10501048 }
10511049
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 );
10611057 }
10621058
1059+ // Adjust to align hot spot.
1060+ gl .glTranslated (this .dx , this .dy , 0 );
1061+
10631062 // Scale the unit quad
10641063 gl .glScaled (xscale , yscale , 1 );
10651064
0 commit comments