11package com .ss .editor .ui .component .editing .terrain .control ;
22
3- import static java . util .Objects . requireNonNull ;
3+ import static com . ss . rlib . util .ObjectUtils . notNull ;
44import com .jme3 .math .Vector2f ;
55import com .jme3 .math .Vector3f ;
66import com .jme3 .scene .Node ;
99import com .ss .editor .model .undo .editor .ModelChangeConsumer ;
1010import com .ss .editor .ui .component .editing .terrain .TerrainEditingComponent ;
1111import com .ss .editor .ui .control .model .property .operation .ModelPropertyOperation ;
12- import org .jetbrains .annotations .NotNull ;
13- import org .jetbrains .annotations .Nullable ;
1412import com .ss .rlib .util .dictionary .DictionaryFactory ;
1513import com .ss .rlib .util .dictionary .ObjectDictionary ;
14+ import org .jetbrains .annotations .NotNull ;
15+ import org .jetbrains .annotations .Nullable ;
1616
1717import java .util .ArrayList ;
1818import java .util .List ;
@@ -32,6 +32,8 @@ private static class HeightPoint {
3232 private final int xIndex ;
3333 private final int yIndex ;
3434
35+ private final int hash ;
36+
3537 /**
3638 * Instantiates a new Height point.
3739 *
@@ -45,6 +47,7 @@ public HeightPoint(final float x, final float y, final int xIndex, final int yIn
4547 this .y = y ;
4648 this .xIndex = xIndex ;
4749 this .yIndex = yIndex ;
50+ this .hash = xIndex | (yIndex << 15 );
4851 }
4952
5053 @ Override
@@ -58,9 +61,7 @@ public boolean equals(final Object o) {
5861
5962 @ Override
6063 public int hashCode () {
61- int result = xIndex ;
62- result = 31 * result + yIndex ;
63- return result ;
64+ return hash ;
6465 }
6566 }
6667
@@ -83,7 +84,7 @@ public int hashCode() {
8384 */
8485 public ChangeHeightTerrainToolControl (@ NotNull final TerrainEditingComponent component ) {
8586 super (component );
86- this .originalHeight = DictionaryFactory .newObjectDictionary ();
87+ this .originalHeight = DictionaryFactory .newObjectDictionary (0.2F , 1000 );
8788 }
8889
8990 /**
@@ -102,7 +103,7 @@ protected void startChange() {
102103 final ObjectDictionary <HeightPoint , Float > originalHeight = getOriginalHeight ();
103104 originalHeight .clear ();
104105
105- copiedTerrain = requireNonNull (getEditedModel ()).clone ();
106+ copiedTerrain = notNull (getEditedModel ()).clone ();
106107 }
107108
108109 /**
@@ -112,8 +113,8 @@ protected void startChange() {
112113 */
113114 protected void change (@ NotNull final Vector2f point ) {
114115
115- final Terrain terrain = (Terrain ) requireNonNull (copiedTerrain );
116- final Node terrainNode = (Node ) requireNonNull (getEditedModel ());
116+ final Terrain terrain = (Terrain ) notNull (copiedTerrain );
117+ final Node terrainNode = (Node ) notNull (getEditedModel ());
117118 final Vector3f scale = terrainNode .getWorldScale ();
118119
119120 final int halfSize = terrain .getTerrainSize () / 2 ;
@@ -135,7 +136,7 @@ protected void change(@NotNull final Vector2f point) {
135136 */
136137 protected void commitChanges () {
137138
138- final Terrain terrain = (Terrain ) requireNonNull (getEditedModel ());
139+ final Terrain terrain = (Terrain ) notNull (getEditedModel ());
139140 final ObjectDictionary <Vector2f , Float > oldValues = DictionaryFactory .newObjectDictionary ();
140141 final ObjectDictionary <Vector2f , Float > newValues = DictionaryFactory .newObjectDictionary ();
141142
0 commit comments