|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2009-2020 jMonkeyEngine |
| 2 | + * Copyright (c) 2009-2023 jMonkeyEngine |
3 | 3 | * All rights reserved.
|
4 | 4 | *
|
5 | 5 | * Redistribution and use in source and binary forms, with or without
|
|
56 | 56 | import java.nio.FloatBuffer;
|
57 | 57 | import java.util.HashMap;
|
58 | 58 | import java.util.List;
|
| 59 | +import java.util.logging.Logger; |
| 60 | +import java.util.logging.Level; |
59 | 61 |
|
60 | 62 |
|
61 | 63 | /**
|
|
79 | 81 | * @author Brent Owens
|
80 | 82 | */
|
81 | 83 | public class TerrainPatch extends Geometry {
|
| 84 | + |
| 85 | + private static final Logger logger = Logger.getLogger(TerrainPatch.class.getName()); |
82 | 86 |
|
83 | 87 | protected LODGeomap geomap;
|
84 | 88 | protected int lod = 0; // this terrain patch's LOD
|
@@ -798,19 +802,22 @@ protected void setLodBottom(int lodBottom) {
|
798 | 802 |
|
799 | 803 | @Override
|
800 | 804 | public int collideWith(Collidable other, CollisionResults results) throws UnsupportedCollisionException {
|
801 |
| - if (refreshFlags != 0) |
802 |
| - throw new IllegalStateException("Scene graph must be updated" + |
803 |
| - " before checking collision"); |
804 |
| - |
805 |
| - if (other instanceof BoundingVolume) |
806 |
| - if (!getWorldBound().intersects((BoundingVolume)other)) |
| 805 | + if ((refreshFlags & (RF_BOUND | RF_TRANSFORM)) != 0) { |
| 806 | + logger.log(Level.WARNING, "Scene graph must be updated before checking collision"); |
| 807 | + return 0; |
| 808 | + } |
| 809 | + |
| 810 | + if (other instanceof BoundingVolume) { |
| 811 | + if (!getWorldBound().intersects((BoundingVolume)other)) { |
807 | 812 | return 0;
|
808 |
| - |
809 |
| - if(other instanceof Ray) |
| 813 | + } |
| 814 | + } |
| 815 | + |
| 816 | + if (other instanceof Ray) { |
810 | 817 | return collideWithRay((Ray)other, results);
|
811 |
| - else if (other instanceof BoundingVolume) |
| 818 | + } else if (other instanceof BoundingVolume) { |
812 | 819 | return collideWithBoundingVolume((BoundingVolume)other, results);
|
813 |
| - else { |
| 820 | + } else { |
814 | 821 | throw new UnsupportedCollisionException("TerrainPatch cannot collide with "+other.getClass().getName());
|
815 | 822 | }
|
816 | 823 | }
|
|
0 commit comments