projects
/
mercenary-reloaded.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0697fa5
)
Fix scale of vertices for double resolution tags (e.g. faces)
author
Andreas Eversberg
<jolly@eversberg.eu>
Sun, 22 Apr 2018 09:48:17 +0000
(11:48 +0200)
committer
Andreas Eversberg
<jolly@eversberg.eu>
Fri, 27 Apr 2018 19:21:02 +0000
(21:21 +0200)
src/mercenary/render.c
patch
|
blob
|
history
diff --git
a/src/mercenary/render.c
b/src/mercenary/render.c
index
b4f53b9
..
7e1226d
100644
(file)
--- a/
src/mercenary/render.c
+++ b/
src/mercenary/render.c
@@
-420,7
+420,7
@@
static int32_t wrap_int28(int32_t value)
return value;
}
return value;
}
-static void store_coord(const char __attribute__((unused)) *what, uint32_t vertex, int32_t x, int32_t y, int32_t z)
+static void store_coord(const char __attribute__((unused)) *what, uint32_t vertex, int32_t x, int32_t y, int32_t z
, double scale
)
{
if ((vertex & 3)) {
print_info("Vertex %d is not a multiple of four!\n", vertex);
{
if ((vertex & 3)) {
print_info("Vertex %d is not a multiple of four!\n", vertex);
@@
-464,12
+464,9
@@
static void store_coord(const char __attribute__((unused)) *what, uint32_t verte
printf("storing %s coordinates: vertex=%d, x=%d, y=%d, z=%d\n", what, vertex, x, y, z);
#endif
/* use absolute position */
printf("storing %s coordinates: vertex=%d, x=%d, y=%d, z=%d\n", what, vertex, x, y, z);
#endif
/* use absolute position */
- x += motion_new.position_east;
- y += motion_new.position_height;
- z += motion_new.position_north;
- render_item->u.vertices.x[vertex] = x;
- render_item->u.vertices.y[vertex] = y;
- render_item->u.vertices.z[vertex] = z;
+ render_item->u.vertices.x[vertex] = (double)x * scale + motion_new.position_east;
+ render_item->u.vertices.y[vertex] = (double)y * scale + motion_new.position_height;
+ render_item->u.vertices.z[vertex] = (double)z * scale + motion_new.position_north;
}
static void store_planets_coord(const char __attribute__((unused)) *what, uint32_t vertex, int32_t x, int32_t y, int32_t z)
}
static void store_planets_coord(const char __attribute__((unused)) *what, uint32_t vertex, int32_t x, int32_t y, int32_t z)
@@
-620,7
+617,7
@@
static void coord_object(void)
y += (int32_t)REG_A[2];
z = (int16_t)REG_D[5];
z += (int32_t)REG_A[3];
y += (int32_t)REG_A[2];
z = (int16_t)REG_D[5];
z += (int32_t)REG_A[3];
- store_coord("object", REG_A[0], x, y, z);
+ store_coord("object", REG_A[0], x, y, z
, 1.0
);
}
/* polygon of object */
}
/* polygon of object */
@@
-689,7
+686,7
@@
static void coord_beacon(void)
x = (int32_t)(REG_D[3] << 4) / 16;
y = (int32_t)(REG_D[4] << 4) / 16;
z = (int32_t)(REG_D[5] << 4) / 16;
x = (int32_t)(REG_D[3] << 4) / 16;
y = (int32_t)(REG_D[4] << 4) / 16;
z = (int32_t)(REG_D[5] << 4) / 16;
- store_coord("beacon", 0, x, y, z);
+ store_coord("beacon", 0, x, y, z
, 1.0
);
}
/* point of beacon */
}
/* point of beacon */
@@
-717,7
+714,7
@@
static void coord_building_exterior(void)
x = (int32_t)REG_D[3];
y = (int32_t)REG_D[4];
z = (int32_t)REG_D[5];
x = (int32_t)REG_D[3];
y = (int32_t)REG_D[4];
z = (int32_t)REG_D[5];
- store_coord("building exterior", REG_A[0], x, y, z);
+ store_coord("building exterior", REG_A[0], x, y, z
, 1.0
);
}
/* polygon of building (exterior) */
}
/* polygon of building (exterior) */
@@
-904,7
+901,7
@@
static void coord_line_road(void)
x = REG_D[3];
y = -motion_new.position_height;
z = REG_D[5];
x = REG_D[3];
y = -motion_new.position_height;
z = REG_D[5];
- store_coord("road", REG_A[0], x, y, z);
+ store_coord("road", REG_A[0], x, y, z
, 1.0
);
}
/* line of road */
}
/* line of road */
@@
-940,7
+937,7
@@
static void coord_poly_road(void)
y = -motion_new.position_height;
z = m68k_read_memory_32(576 + REG_A[0]);
z -= REG_A[3];
y = -motion_new.position_height;
z = m68k_read_memory_32(576 + REG_A[0]);
z -= REG_A[3];
- store_coord("road/place", REG_A[0], x, y, z);
+ store_coord("road/place", REG_A[0], x, y, z
, 1.0
);
}
/* polygon of road */
}
/* polygon of road */
@@
-984,7
+981,7
@@
static void coord_tags(void)
y += (int32_t)REG_A[2];
z = (int16_t)REG_D[5];
z += (int32_t)REG_A[3];
y += (int32_t)REG_A[2];
z = (int16_t)REG_D[5];
z += (int32_t)REG_A[3];
- store_coord("tags", REG_A[0], x, y, z);
+ store_coord("tags", REG_A[0], x, y, z
, 1.0
);
}
/* coordinates ready for large tags */
}
/* coordinates ready for large tags */
@@
-998,7
+995,10
@@
static void coord_tags2(void)
y += 2 * (int32_t)REG_A[2];
z = (int16_t)REG_D[5];
z += 2 * (int32_t)REG_A[3];
y += 2 * (int32_t)REG_A[2];
z = (int16_t)REG_D[5];
z += 2 * (int32_t)REG_A[3];
- store_coord("large tags", REG_A[0], x, y, z);
+ /* note that large tags have double distance, so the resolution is vitrually doubled.
+ * since we use interpolation and VR, we need to scale the vertex back to normal distance.
+ */
+ store_coord("large tags", REG_A[0], x, y, z, 0.5);
}
/* line of tag */
}
/* line of tag */
@@
-1189,7
+1189,7
@@
static void coord_islands(void)
y = -motion_new.position_height;
z = ((int16_t)m68k_read_memory_16(REG_A[4]) * 65536);
z += (int32_t)REG_A[3];
y = -motion_new.position_height;
z = ((int16_t)m68k_read_memory_16(REG_A[4]) * 65536);
z += (int32_t)REG_A[3];
- store_coord("island", REG_A[0], x, y, z);
+ store_coord("island", REG_A[0], x, y, z
, 1.0
);
}
/* polygon of island */
}
/* polygon of island */