@@ -173,4 +173,53 @@ public Quad[] getQuads() {
173173 public Texture [] getTextures () {
174174 return textures ;
175175 }
176+
177+ /**
178+ * Intersects this glass pane model with the given ray.
179+ * <p>
180+ * Unlike {@link QuadModel#intersect(Ray, Scene)}, this method also registers
181+ * hits in the transparent regions of the quads. In addition, biome tinting is
182+ * disabled as a minor optimization, since it does not affect glass panes.
183+ *
184+ * @param ray the ray to test for intersection
185+ * @param scene the scene providing context for the intersection
186+ * @return true if the glass pane was hit, false otherwise
187+ */
188+ @ Override
189+ public boolean intersect (Ray ray , Scene scene ) {
190+ boolean hit = false ;
191+ ray .t = Double .POSITIVE_INFINITY ;
192+
193+ Quad [] quads = getQuads ();
194+ Texture [] textures = getTextures ();
195+
196+ float [] color = null ;
197+ for (int i = 0 ; i < quads .length ; ++i ) {
198+ Quad quad = quads [i ];
199+ if (quad .intersect (ray )) {
200+ color = textures [i ].getColor (ray .u , ray .v );
201+ ray .t = ray .tNext ;
202+ if (quad .doubleSided )
203+ ray .orientNormal (quad .n );
204+ else
205+ ray .setNormal (quad .n );
206+ hit = true ;
207+ }
208+ }
209+
210+ if (hit ) {
211+ double px = ray .o .x - Math .floor (ray .o .x + ray .d .x * Ray .OFFSET ) + ray .d .x * ray .tNext ;
212+ double py = ray .o .y - Math .floor (ray .o .y + ray .d .y * Ray .OFFSET ) + ray .d .y * ray .tNext ;
213+ double pz = ray .o .z - Math .floor (ray .o .z + ray .d .z * Ray .OFFSET ) + ray .d .z * ray .tNext ;
214+ if (px < E0 || px > E1 || py < E0 || py > E1 || pz < E0 || pz > E1 ) {
215+ // TODO this check is only really needed for wall torches
216+ return false ;
217+ }
218+
219+ ray .color .set (color );
220+ ray .distance += ray .t ;
221+ ray .o .scaleAdd (ray .t , ray .d );
222+ }
223+ return hit ;
224+ }
176225}
0 commit comments