Isometric seems to work!

This commit is contained in:
Bill Kendrick 2024-01-13 12:04:56 -08:00
parent f585c6e897
commit fff19763e2

View file

@ -1185,13 +1185,13 @@ void n_pt_persp_work(magic_api * api, int tool,
x2 = x1; x2 = x1;
y2 = y; y2 = y;
} else { } else {
/* vertical */ /* all tools include vertical */
valid_angles[0] = M_PI / 2; valid_angles[0] = -M_PI / 2;
if (tool == TOOL_ISO_DRAW) { if (tool == TOOL_ISO_DRAW) {
/* isometric diagonals */ /* isometric diagonals */
valid_angles[1] = (30.0 * M_PI / 180.0); valid_angles[1] = -(30.0 * M_PI / 180.0);
valid_angles[2] = (150.0 * M_PI / 180.0); valid_angles[2] = -(150.0 * M_PI / 180.0);
} else if (tool == TOOL_DIM_DRAW) { } else if (tool == TOOL_DIM_DRAW) {
/* dimetric diagonals */ /* dimetric diagonals */
valid_angles[1] = dim_ang; valid_angles[1] = dim_ang;
@ -1215,6 +1215,9 @@ void n_pt_persp_work(magic_api * api, int tool,
/* And the opposite directions */ /* And the opposite directions */
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
valid_angles[i + 3] = valid_angles[i] + M_PI; valid_angles[i + 3] = valid_angles[i] + M_PI;
if (valid_angles[i + 3] > M_PI * 2) {
valid_angles[i] -= (M_PI * 2);
}
} }
// FIXME needs more work // FIXME needs more work
@ -1241,13 +1244,14 @@ void n_pt_persp_work(magic_api * api, int tool,
ang = valid_angles[best_angle_idx]; ang = valid_angles[best_angle_idx];
printf("best ang = %.2f\n", ang * 180.0 / M_PI); printf("best ang = [%d] %.2f\n", best_angle_idx, ang * 180.0 / M_PI);
x1 = line_start_x; x1 = line_start_x;
y1 = line_start_y; y1 = line_start_y;
x2 = line_start_x + cos(ang) * 1000; x2 = line_start_x + cos(ang) * 1000;
y2 = line_start_y + sin(ang) * 1000; y2 = line_start_y + sin(ang) * 1000;
if (abs(x2 - x1) >= 2) {
slope = ((float) y2 - (float) y1) / ((float) x2 - (float) x1); slope = ((float) y2 - (float) y1) / ((float) x2 - (float) x1);
x2 = x; x2 = x;
y2 = line_start_y + (slope * (x - line_start_x)); y2 = line_start_y + (slope * (x - line_start_x));
@ -1260,6 +1264,10 @@ void n_pt_persp_work(magic_api * api, int tool,
x2 = ((y - line_start_y) / slope) + line_start_x; x2 = ((y - line_start_y) / slope) + line_start_x;
} }
} }
} else {
x2 = x1;
y2 = y;
}
} }
} }