private void moveObstacleFace(int x, int y, boolean releasing) {
		if (obstacleIndexAndFace == null || obstacleIndexAndFace[0] < 0 || obstacleIndexAndFace[1] < 0)
			return;
		Obstacle o = model.getObstacle(obstacleIndexAndFace[0]);
		if (o instanceof CuboidObstacle) {
			CuboidObstacle obs = (CuboidObstacle) o;
			byte face = (byte) obstacleIndexAndFace[1];
			switch (face) {
			case 0x00: // front
			case 0x01: // rear
				Point3f p = viewer.findPointOnPlane('x', x, y, 0);
				checkObstacleBounds(face % 2 == 0, p.z - clickPoint3D.z, 0.5f * model.getHeight());
				if (releasing) {
					if (model.atomsOverlapCuboid(obs.getCenter().x, obs.getCenter().y, positionCenter,
							obs.getCorner().x, obs.getCorner().y, positionCorner)) {
						errorReminder.show(ErrorReminder.OBJECT_OVERLAP);
						viewer.updateCuboidObstacleFace('z', obs.getCenter().z, obs.getCorner().z);
						return;
					}
					obs.getCenter().z = positionCenter;
					obs.getCorner().z = positionCorner;
				}
				viewer.updateCuboidObstacleFace('z', positionCenter, positionCorner);
				break;
			case 0x02: // top
			case 0x03: // bottom
				p = viewer.findPointOnPlane('z', x, y, 0);
				checkObstacleBounds(face % 2 == 0, p.y - clickPoint3D.y, 0.5f * model.getWidth());
				if (releasing) {
					if (model.atomsOverlapCuboid(obs.getCenter().x, positionCenter, obs.getCenter().z,
							obs.getCorner().x, positionCorner, obs.getCorner().z)) {
						errorReminder.show(ErrorReminder.OBJECT_OVERLAP);
						viewer.updateCuboidObstacleFace('y', obs.getCenter().y, obs.getCorner().y);
						return;
					}
					obs.getCenter().y = positionCenter;
					obs.getCorner().y = positionCorner;
				}
				viewer.updateCuboidObstacleFace('y', positionCenter, positionCorner);
				break;
			case 0x04: // right
			case 0x05: // left
				p = viewer.findPointOnPlane('y', x, y, 0);
				checkObstacleBounds(face % 2 == 0, p.x - clickPoint3D.x, 0.5f * model.getLength());
				if (releasing) {
					if (model.atomsOverlapCuboid(positionCenter, obs.getCenter().y, obs.getCenter().z, positionCorner,
							obs.getCorner().y, obs.getCorner().z)) {
						errorReminder.show(ErrorReminder.OBJECT_OVERLAP);
						viewer.updateCuboidObstacleFace('x', obs.getCenter().x, obs.getCorner().x);
						return;
					}
					obs.getCenter().x = positionCenter;
					obs.getCorner().x = positionCorner;
				}
				viewer.updateCuboidObstacleFace('x', positionCenter, positionCorner);
				break;
			}
		}
		else if (o instanceof CylinderObstacle) {
			CylinderObstacle obs = (CylinderObstacle) o;
			float a = obs.getRadius() * COS45;
			byte face = (byte) obstacleIndexAndFace[1];
			switch (obs.getAxis()) {
			case 'x':
				Point3f p = viewer.findPointOnPlane('y', x, y, 0);
				if (face != 2) {// top and bottom
					checkObstacleBounds(face % 2 == 0, p.x - clickPoint3D.x, 0.5f * model.getLength());
					if (releasing) {
						if (model.atomsOverlapCylinder(positionCenter, obs.getCenter().y, obs.getCenter().z, obs
								.getAxis(), 2 * positionCorner, obs.getRadius())) {
							errorReminder.show(ErrorReminder.OBJECT_OVERLAP);
							viewer.updateCylinderObstacleFace('x', obs.getCenter().x, a, a, obs.getHeight());
							return;
						}
						obs.getCenter().x = positionCenter;
						obs.setHeight(2 * positionCorner);
					}
					viewer.updateCylinderObstacleFace('x', positionCenter, a, a, 2 * positionCorner);
				}
				else { // lateral
					checkCylindericObstacleBounds('x', p.z - clickPoint3D.z, obs.getCenter());
					if (releasing) {
						if (model.atomsOverlapCylinder(obs.getCenter().x, obs.getCenter().y, obs.getCenter().z, obs
								.getAxis(), obs.getHeight(), positionCorner)) {
							errorReminder.show(ErrorReminder.OBJECT_OVERLAP);
							viewer.updateCylinderObstacleFace('x', obs.getCenter().x, a, a, obs.getHeight());
							return;
						}
						obs.setRadius(positionCorner);
					}
					a = positionCorner * COS45;
					viewer.updateCylinderObstacleFace('x', obs.getCenter().x, a, a, obs.getHeight());
				}
				break;
			case 'y':
				p = viewer.findPointOnPlane('z', x, y, 0);
				if (face != 2) {// top and bottom
					checkObstacleBounds(face % 2 == 0, p.y - clickPoint3D.y, 0.5f * model.getWidth());
					if (releasing) {
						if (model.atomsOverlapCylinder(obs.getCenter().x, positionCenter, obs.getCenter().z, obs
								.getAxis(), 2 * positionCorner, obs.getRadius())) {
							errorReminder.show(ErrorReminder.OBJECT_OVERLAP);
							viewer.updateCylinderObstacleFace('y', obs.getCenter().y, a, a, obs.getHeight());
							return;
						}
						obs.getCenter().y = positionCenter;
						obs.setHeight(2 * positionCorner);
					}
					viewer.updateCylinderObstacleFace('y', positionCenter, a, a, 2 * positionCorner);
				}
				else { // lateral
					checkCylindericObstacleBounds('y', p.x - clickPoint3D.x, obs.getCenter());
					if (releasing) {
						if (model.atomsOverlapCylinder(obs.getCenter().x, obs.getCenter().y, obs.getCenter().z, obs
								.getAxis(), obs.getHeight(), positionCorner)) {
							errorReminder.show(ErrorReminder.OBJECT_OVERLAP);
							viewer.updateCylinderObstacleFace('y', obs.getCenter().y, a, a, obs.getHeight());
							return;
						}
						obs.setRadius(positionCorner);
					}
					a = positionCorner * COS45;
					viewer.updateCylinderObstacleFace('y', obs.getCenter().y, a, a, obs.getHeight());
				}
				break;
			case 'z':
				p = viewer.findPointOnPlane('x', x, y, 0);
				if (face != 2) {// top and bottom
					checkObstacleBounds(face % 2 == 0, p.z - clickPoint3D.z, 0.5f * model.getHeight());
					if (releasing) {
						if (model.atomsOverlapCylinder(obs.getCenter().x, obs.getCenter().y, positionCenter, obs
								.getAxis(), 2 * positionCorner, obs.getRadius())) {
							errorReminder.show(ErrorReminder.OBJECT_OVERLAP);
							viewer.updateCylinderObstacleFace('z', obs.getCenter().z, a, a, obs.getHeight());
							return;
						}
						obs.getCenter().z = positionCenter;
						obs.setHeight(2 * positionCorner);
					}
					viewer.updateCylinderObstacleFace('z', positionCenter, a, a, 2 * positionCorner);
				}
				else {
					checkCylindericObstacleBounds('z', p.y - clickPoint3D.y, obs.getCenter());
					if (releasing) {
						if (model.atomsOverlapCylinder(obs.getCenter().x, obs.getCenter().y, obs.getCenter().z, obs
								.getAxis(), obs.getHeight(), positionCorner)) {
							errorReminder.show(ErrorReminder.OBJECT_OVERLAP);
							viewer.updateCylinderObstacleFace('z', obs.getCenter().z, a, a, obs.getHeight());
							return;
						}
						obs.setRadius(positionCorner);
					}
					a = positionCorner * COS45;
					viewer.updateCylinderObstacleFace('z', obs.getCenter().z, a, a, obs.getHeight());
				}
				break;
			}
		}
	}