@@ -197,7 +197,7 @@ private PaneBox createArrayBox(ModelObject modelObject, ModelClass modelClass, R
197197 else {
198198 newPosition = new Point3D (newPosition .getX () + (ARRAYBOX_LEVEL_DIFF * 2 ) + (modelObject .getWidth () / 2 ), modelObject .getY (), newPosition .getZ ());
199199 }
200- while (hasArrayBoxAtPos (newPosition )) {
200+ while (hasBoxApproxAtPos (newPosition )) {
201201 newPosition = new Point3D (newPosition .getX (), newPosition .getY () + ARRAYBOX_LEVEL_DIFF , newPosition .getZ ());
202202 }
203203 paneBox .setTranslateXYZ (newPosition );
@@ -234,24 +234,14 @@ private void createArrayBoxArrows(PaneBox arrayBox, Endpoint endpoint, ObjectGra
234234 }
235235 }
236236 }
237-
238- public boolean hasArrayBoxAtPos (Point3D coords ) {
239- for (PaneBox paneBox : this .boxes ) {
240- boolean approxEqualX = Math .floor (paneBox .getCenterPoint ().getX ()) == Math .floor (coords .getX ());
241- boolean approxEqualY = Math .floor (paneBox .getCenterPoint ().getY () + paneBox .getDepth () / 2 ) == Math .floor (coords .getY ());
242- boolean approxEqualZ = Math .floor (paneBox .getCenterPoint ().getZ ()) == Math .floor (coords .getZ ());
243- if (approxEqualX && approxEqualY && approxEqualZ ) {
244- return true ;
245- }
246- }
247- return false ;
248- }
249237
250- public boolean hasArrayBoxAtYZ (Point3D coords ) {
238+ public boolean hasBoxApproxAtPos (Point3D coords ) {
239+ double approxRange = 50 ;
251240 for (PaneBox paneBox : this .boxes ) {
252- boolean approxEqualY = Math .floor (paneBox .getCenterPoint ().getY () + paneBox .getDepth () / 2 ) == Math .floor (coords .getY ());
253- boolean approxEqualZ = Math .floor (paneBox .getCenterPoint ().getZ ()) == Math .floor (coords .getZ ());
254- if (approxEqualY && approxEqualZ ) {
241+ boolean approxEqualX = Math .abs (paneBox .getCenterPoint ().getX () - coords .getX ()) < approxRange ;
242+ boolean approxEqualY = Math .abs ((paneBox .getCenterPoint ().getY () + paneBox .getDepth () / 2 ) - coords .getY ()) < approxRange ;
243+ boolean approxEqualZ = Math .abs (paneBox .getCenterPoint ().getZ () - coords .getZ ()) < approxRange ;
244+ if (approxEqualX && approxEqualY && approxEqualZ ) {
255245 return true ;
256246 }
257247 }
0 commit comments