9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-26 10:39:07 +00:00

Implement rotation, remove precise rotation.

This commit is contained in:
Sjoerd van de Goor
2023-02-15 14:05:34 +01:00
parent e5a7b5d0c6
commit e94406fb45
2 changed files with 8 additions and 19 deletions

View File

@@ -30,10 +30,7 @@ import com.volmit.iris.util.data.B;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.interpolation.IrisInterpolation;
import com.volmit.iris.util.json.JSONObject;
import com.volmit.iris.util.math.AxisAlignedBB;
import com.volmit.iris.util.math.BlockPosition;
import com.volmit.iris.util.math.Position2;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.math.*;
import com.volmit.iris.util.matter.MatterMarker;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.MultiBurst;
@@ -500,18 +497,11 @@ public class IrisObject extends IrisRegistrant {
// Rotation calculation
double slopeRotationY = 0;
ProceduralStream<Double> heightStream = rdata.getEngine().getComplex().getHeightStream();
if (config.isRotateTowardsSlopePrecise()) {
// I take three points which together make a plane that decently represents the slope beneath the object
double hNorth = heightStream.get(x, z + ((float)h) / 2);
double hEast = heightStream.get(x + ((float)w) / 2, z);
double hSouthWest = heightStream.get(x - ((float)w) / 2, z - ((float)h) / 2);
// TODO: Complex math
} else if (config.isRotateTowardsSlope()) {
// TODO: Make this respect object rotation. Currently takes the object without rotation to define the corner points.
if (config.isRotateTowardsSlope()) {
// Whichever side of the rectangle that bounds the object is lowest is the 'direction' of the slope (simply said).
double hNorth = heightStream.get(x, z + ((float)h) / 2);
double hNorth = heightStream.get(x, z + ((float)d) / 2);
double hEast = heightStream.get(x + ((float)w) / 2, z);
double hSouth = heightStream.get(x, z - ((float)h) / 2);
double hSouth = heightStream.get(x, z - ((float)d) / 2);
double hWest = heightStream.get(x - ((float)w) / 2, z);
double min = Math.min(Math.min(hNorth, hEast), Math.min(hSouth, hWest));
if (min == hNorth) {
@@ -524,6 +514,8 @@ public class IrisObject extends IrisRegistrant {
slopeRotationY = 270;
}
}
config.getRotation().setYAxis(new IrisAxisRotationClamp(true, false, slopeRotationY, slopeRotationY, 360));
config.getRotation().setEnabled(true);
if (config.isSmartBore()) {
ensureSmartBored(placer.isDebugSmartBore());

View File

@@ -62,12 +62,9 @@ public class IrisObjectPlacement {
private double snow = 0;
@Desc("Whether or not this object can be targeted by a dolphin.")
private boolean isDolphinTarget = false;
@Desc("Set to true to add the rotation of the direction of the slope of the terrain (wherever the slope is going down) to the y-axis rotation of the object. See also rotateTowardsSlopePrecise.")
@Desc("Set to true to add the rotation of the direction of the slope of the terrain (wherever the slope is going down) to the y-axis rotation of the object." +
"Overwrites the y-axis of the rotation settings if set to true, and force-enables it. This is rounded by 90 degrees as to not fuck up your objects.")
private boolean rotateTowardsSlope = false;
@Desc("By default the 'rotateTowardsSlope' function simply calculates which direction" +
" (North East South or West) is the lowest, resulting in a 0, 90, 180 or 270 degree rotations. " +
"Setting this to true does a precise calculation, which may give unwanted side-effects due to non-90 degree rotations.")
private boolean rotateTowardsSlopePrecise = false;
@MinNumber(0)
@MaxNumber(1)
@Desc("The chance for this to place in a chunk. If you need multiple per chunk, set this to 1 and use density.")