Skip to content

Commit ee7f74b

Browse files
committed
to prev.
1 parent beb7250 commit ee7f74b

File tree

6 files changed

+38
-16
lines changed

6 files changed

+38
-16
lines changed

src/main/java/com/ss/editor/control/painting/terrain/ChangeHeightTerrainToolControl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ protected void commitChanges() {
195195
});
196196

197197
originalHeight.forEach((terrain, floats) -> {
198-
final ObjectDictionary<Vector2f, Float> values = oldValues.get(terrain, () -> createValuesDictionary(floats));
198+
final ObjectDictionary<Vector2f, Float> values = newValues.get(terrain, () -> createValuesDictionary(floats));
199199
floats.forEach((heightPoint, height) -> {
200200
final Vector2f point = new Vector2f(heightPoint.x, heightPoint.y);
201201
values.put(point, terrain.getHeightmapHeight(point));

src/main/java/com/ss/editor/control/painting/terrain/LevelTerrainToolControl.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ public void finishPainting(@NotNull final Vector3f contactPoint) {
157157
@JmeThread
158158
private void modifyHeight(@NotNull final Vector3f contactPoint) {
159159

160-
161160
final LocalObjects local = getLocalObjects();
162161
final Spatial paintedModel = notNull(getPaintedModel());
163162
final Geometry brush = getBrush();
@@ -166,6 +165,9 @@ private void modifyHeight(@NotNull final Vector3f contactPoint) {
166165
final float brushSize = getBrushSize();
167166
final float brushPower = getBrushPower();
168167

168+
final List<Vector2f> locs = new ArrayList<>();
169+
final List<Float> heights = new ArrayList<>();
170+
169171
for (final Terrain terrain : getTerrains()) {
170172

171173
final Node terrainNode = (Node) terrain;
@@ -186,8 +188,8 @@ private void modifyHeight(@NotNull final Vector3f contactPoint) {
186188
final float xStepAmount = localScale.getX();
187189
final float zStepAmount = localScale.getZ();
188190

189-
final List<Vector2f> locs = new ArrayList<>();
190-
final List<Float> heights = new ArrayList<>();
191+
locs.clear();
192+
heights.clear();
191193

192194
for (int z = -radiusStepsZ; z < radiusStepsZ; z++) {
193195
for (int x = -radiusStepsX; x < radiusStepsX; x++) {

src/main/java/com/ss/editor/control/painting/terrain/RaiseLowerTerrainToolControl.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,16 @@ private void modifyHeight(@NotNull final PaintingInput input, @NotNull final Vec
9797
final float brushSize = getBrushSize();
9898
final float brushPower = input == PaintingInput.MOUSE_PRIMARY ? getBrushPower() : getBrushPower() * -1F;
9999

100+
final List<Vector2f> locs = new ArrayList<>();
101+
final List<Float> heights = new ArrayList<>();
102+
100103
for (final Terrain terrain : getTerrains()) {
101104

102105
final Node terrainNode = (Node) terrain;
103106

107+
locs.clear();
108+
heights.clear();
109+
104110
final Vector3f worldTranslation = terrainNode.getWorldTranslation();
105111
final Vector3f localScale = terrainNode.getLocalScale();
106112
final Vector3f localPoint = contactPoint.subtract(worldTranslation, local.nextVector());
@@ -113,9 +119,6 @@ private void modifyHeight(@NotNull final PaintingInput input, @NotNull final Vec
113119
final float xStepAmount = localScale.getX();
114120
final float zStepAmount = localScale.getZ();
115121

116-
final List<Vector2f> locs = new ArrayList<>();
117-
final List<Float> heights = new ArrayList<>();
118-
119122
for (int z = -radiusStepsZ; z < radiusStepsZ; z++) {
120123
for (int x = -radiusStepsX; x < radiusStepsX; x++) {
121124

src/main/java/com/ss/editor/control/painting/terrain/RoughTerrainToolControl.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,16 @@ private void modifyHeight(@NotNull final Vector3f contactPoint) {
111111
final int twoBrushSize = (int) (brushSize * 2);
112112

113113
final Basis fractalFilter = createFractalGenerator();
114+
final List<Vector2f> locs = new ArrayList<>();
115+
final List<Float> heights = new ArrayList<>();
114116

115117
for (final Terrain terrain : getTerrains()) {
116118

117119
final Node terrainNode = (Node) terrain;
118120

121+
locs.clear();
122+
heights.clear();
123+
119124
final Vector3f worldTranslation = terrainNode.getWorldTranslation();
120125
final Vector3f localScale = terrainNode.getLocalScale();
121126
final Vector3f localPoint = contactPoint.subtract(worldTranslation, local.nextVector());
@@ -130,9 +135,6 @@ private void modifyHeight(@NotNull final Vector3f contactPoint) {
130135
final float xStepAmount = localScale.getX();
131136
final float zStepAmount = localScale.getZ();
132137

133-
final List<Vector2f> locs = new ArrayList<>();
134-
final List<Float> heights = new ArrayList<>();
135-
136138
for (int z = -radiusStepsZ, yfb = 0; z < radiusStepsZ; z++, yfb++) {
137139
for (int x = -radiusStepsX, xfb = 0; x < radiusStepsX; x++, xfb++) {
138140

@@ -149,7 +151,12 @@ private void modifyHeight(@NotNull final Vector3f contactPoint) {
149151

150152
terrainLoc.set(locX, locZ);
151153

152-
final float currentHeight = terrain.getHeightmapHeight(terrainLoc) * localScale.getY();
154+
final float heightmapHeight = terrain.getHeightmapHeight(terrainLoc);
155+
if (Float.isNaN(heightmapHeight)) {
156+
continue;
157+
}
158+
159+
final float currentHeight = heightmapHeight * localScale.getY();
153160
// see if it is in the radius of the tool
154161
final float newHeight = calculateHeight(brushSize, height, effectPoint);
155162

src/main/java/com/ss/editor/control/painting/terrain/SlopeTerrainToolControl.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,16 @@ private void modifyHeight(@NotNull final Vector3f contactPoint) {
211211
final float brushSize = getBrushSize();
212212
final float brushPower = getBrushPower();
213213

214+
final List<Vector2f> locs = new ArrayList<>();
215+
final List<Float> heights = new ArrayList<>();
216+
214217
for (final Terrain terrain : getTerrains()) {
215218

216219
final Node terrainNode = (Node) terrain;
217220

221+
locs.clear();
222+
heights.clear();
223+
218224
final Vector3f worldTranslation = terrainNode.getWorldTranslation();
219225
final Vector3f localScale = terrainNode.getLocalScale();
220226
final Vector3f firstPoint = baseMarker.getLocalTranslation();
@@ -252,9 +258,6 @@ private void modifyHeight(@NotNull final Vector3f contactPoint) {
252258
final Plane secondPlane = local.nextPlane();
253259
secondPlane.setOriginNormal(higher, normal);
254260

255-
final List<Vector2f> locs = new ArrayList<>();
256-
final List<Float> heights = new ArrayList<>();
257-
258261
for (int z = -radiusStepsZ; z < radiusStepsZ; z++) {
259262
for (int x = -radiusStepsX; x < radiusStepsX; x++) {
260263

@@ -270,7 +273,12 @@ private void modifyHeight(@NotNull final Vector3f contactPoint) {
270273
terrainLoc.set(locX, locZ);
271274

272275
// adjust height based on radius of the tool
273-
float currentHeight = terrain.getHeightmapHeight(terrainLoc) * localScale.getY();
276+
final float heightmapHeight = terrain.getHeightmapHeight(terrainLoc);
277+
if (Float.isNaN(heightmapHeight)) {
278+
continue;
279+
}
280+
281+
float currentHeight = heightmapHeight * localScale.getY();
274282

275283
targetPoint.set(locX, currentHeight, locZ)
276284
.subtractLocal(lower)

src/main/java/com/ss/editor/control/painting/terrain/SmoothTerrainToolControl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ private void modifyHeight(@NotNull final Vector3f contactPoint) {
9494
final float brushSize = getBrushSize();
9595
final float brushPower = getBrushPower();
9696

97+
final List<Vector2f> locs = new ArrayList<>();
98+
9799
for (final Terrain terrain : getTerrains()) {
98100

99101
final Node terrainNode = (Node) terrain;
@@ -114,7 +116,7 @@ private void modifyHeight(@NotNull final Vector3f contactPoint) {
114116
final float xStepAmount = localScale.getX();
115117
final float zStepAmount = localScale.getZ();
116118

117-
final List<Vector2f> locs = new ArrayList<>();
119+
locs.clear();
118120

119121
for (int z = -radiusStepsZ; z < radiusStepsZ; z++) {
120122
for (int x = -radiusStepsX; x < radiusStepsX; x++) {

0 commit comments

Comments
 (0)