WIP: Port BBL auto-orient

This commit is contained in:
YTKAB0BP
2025-02-26 18:45:17 +03:00
parent 1eb405b07f
commit ecc9fc6f48
9 changed files with 839 additions and 4 deletions
@@ -456,8 +456,7 @@ public class OrientationMenu extends ListBedMenu {
dz %= 360;
model.rotate(j, Math.toRadians(dx), Math.toRadians(dy), Math.toRadians(dz));
model.getBoundingBoxExact(j, bbMin, bbMax);
model.translate(j, 0, 0, -bbMin.z);
model.ensureOnBed(j);
fragment.getGlView().getRenderer().setSelectionRotation(0, 0, 0);
fragment.getGlView().getRenderer().invalidateGlModel(j);
@@ -421,8 +421,7 @@ public class GLRenderer implements GLSurfaceView.Renderer {
if (minPlane != -1) {
GLModel glModel = flattenPlanes.get(minPlane);
model.flattenRotate(selectedObject, glModel);
model.getBoundingBoxExact(j, bbMin, bbMax);
model.translate(j, 0, 0, -bbMin.z);
model.ensureOnBed(selectedObject);
invalidateGlModel(selectedObject);
for (int k = 0, l = flattenPlanes.size(); k < l; k++) {
@@ -86,6 +86,10 @@ public class Model {
resetBoundingBox();
}
public void ensureOnBed(int i) {
Native.model_ensure_on_bed(pointer, i);
}
public void scale(int i, double x, double y, double z) {
Native.model_scale(pointer, i, x, y, z);
}
@@ -66,6 +66,7 @@ class Native {
static native boolean model_is_left_handed(long ptr, int i);
static native void model_translate(long ptr, int i, double x, double y, double z);
static native void model_translate_global(long ptr, double x, double y, double z);
static native void model_ensure_on_bed(long ptr, int i);
static native void model_scale(long ptr, int i, double x, double y, double z);
static native void model_rotate(long ptr, int i, double x, double y, double z);
static native void model_flatten_rotate(long ptr, int i, long surfacePtr);