mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-11 09:50:34 +00:00
3D geometries should now render without OpenGL
This commit is contained in:
parent
43fd94bed6
commit
c1ed54763b
@ -585,6 +585,7 @@ void geometry_information::make_revolution_cut(hpcshape &sh, int each, ld push,
|
||||
shDogStripes = shDogTorso;
|
||||
add_texture(shDogStripes);
|
||||
auto& utt = models_texture;
|
||||
if(utt.tvertices.empty()) return;
|
||||
int a = (6 * 360 / step);
|
||||
for(int i=0; i<shDogStripes.e - shDogStripes.s; i++)
|
||||
if(i % (2 * a) < a)
|
||||
@ -770,7 +771,8 @@ void geometry_information::adjust_eye(hpcshape& eye, hpcshape head, ld shift_eye
|
||||
for(int i=eye.s; i<s; i++) {
|
||||
hpcpush(MirrorY * hpc[i]);
|
||||
auto& utt = models_texture;
|
||||
utt.tvertices.push_back(utt.tvertices[i - eye.s + eye.texture_offset]);
|
||||
if(!utt.tvertices.empty())
|
||||
utt.tvertices.push_back(utt.tvertices[i - eye.s + eye.texture_offset]);
|
||||
}
|
||||
|
||||
finishshape();
|
||||
|
@ -1618,7 +1618,7 @@ void celldrawer::draw_features_and_walls_3d() {
|
||||
poly.tinf = &texture::config.tinf3;
|
||||
poly.offset_texture = 0;
|
||||
}
|
||||
else
|
||||
else if(!floor_texture_vertices.empty())
|
||||
#endif
|
||||
{
|
||||
poly.tinf = &floor_texture_vertices[qfi.fshape->id];
|
||||
|
37
drawing.cpp
37
drawing.cpp
@ -407,6 +407,12 @@ void coords_to_poly() {
|
||||
}
|
||||
}
|
||||
|
||||
bool behind3(hyperpoint h) {
|
||||
if(pmodel == mdGeodesic)
|
||||
h = lp_apply(inverse_exp(h, iTable));
|
||||
return h[2] < 0;
|
||||
}
|
||||
|
||||
void addpoly(const transmatrix& V, const vector<glvertex> &tab, int ofs, int cnt) {
|
||||
if(pmodel == mdPixel) {
|
||||
for(int i=ofs; i<ofs+cnt; i++) {
|
||||
@ -418,6 +424,24 @@ void addpoly(const transmatrix& V, const vector<glvertex> &tab, int ofs, int cnt
|
||||
return;
|
||||
}
|
||||
tofix.clear(); knowgood = false;
|
||||
if(among(pmodel, mdPerspective, mdGeodesic)) {
|
||||
if(poly_flags & POLY_TRIANGLES) {
|
||||
for(int i=ofs; i<ofs+cnt; i+=3) {
|
||||
hyperpoint h0 = V * glhr::gltopoint(tab[i]);
|
||||
hyperpoint h1 = V * glhr::gltopoint(tab[i+1]);
|
||||
hyperpoint h2 = V * glhr::gltopoint(tab[i+2]);
|
||||
if(!behind3(h0) && !behind3(h1) && !behind3(h2))
|
||||
addpoint(h0), addpoint(h1), addpoint(h2);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(int i=ofs; i<ofs+cnt; i++) {
|
||||
hyperpoint h = V * glhr::gltopoint(tab[i]);
|
||||
if(!behind3(h)) addpoint(h);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
hyperpoint last = V * glhr::gltopoint(tab[ofs]);
|
||||
bool last_behind = is_behind(last);
|
||||
if(!last_behind) addpoint(last);
|
||||
@ -1614,7 +1638,12 @@ void dqi_poly::draw() {
|
||||
coords_to_poly();
|
||||
color_t col = color;
|
||||
if(poly_flags & POLY_INVERSE) col = 0;
|
||||
svg::polygon(polyx, polyy, polyi, col, outline, get_width(this));
|
||||
if(poly_flags & POLY_TRIANGLES) {
|
||||
for(int i=0; i<polyi; i+=3)
|
||||
svg::polygon(polyx+i, polyy+i, 3, col, outline, get_width(this));
|
||||
}
|
||||
else
|
||||
svg::polygon(polyx, polyy, polyi, col, outline, get_width(this));
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
@ -1644,7 +1673,11 @@ void dqi_poly::draw() {
|
||||
}
|
||||
filledPolygonColorI(s, polyx, polyy, polyi+5, color);
|
||||
}
|
||||
else
|
||||
else if(poly_flags & POLY_TRIANGLES) {
|
||||
for(int i=0; i<polyi; i+=3)
|
||||
filledPolygonColorI(s, polyx+i, polyy+i, 3, color);
|
||||
}
|
||||
else
|
||||
filledPolygonColorI(s, polyx, polyy, polyi, color);
|
||||
|
||||
if(current_display->stereo_active()) filledPolygonColorI(aux, polyxr, polyy, polyi, color);
|
||||
|
@ -1086,6 +1086,7 @@ void draw_shape_for_texture(floorshape* sh) {
|
||||
/** copy the texture vertices so that there are at least qty of them */
|
||||
EX void ensure_vertex_number(basic_textureinfo& bti, int qty) {
|
||||
int s = isize(bti.tvertices);
|
||||
if(!s) return;
|
||||
while(isize(bti.tvertices) <= qty) {
|
||||
for(int i=0; i<s; i++) bti.tvertices.push_back(bti.tvertices[i]);
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ ld find_zlev(hyperpoint& H) {
|
||||
}
|
||||
|
||||
ld get_tz(hyperpoint H) {
|
||||
ld tz = euclid ? (1+vid.alpha) : vid.alpha+H[LDIM];
|
||||
ld tz = vid.alpha+H[LDIM];
|
||||
if(tz < BEHIND_LIMIT && tz > -BEHIND_LIMIT) tz = BEHIND_LIMIT;
|
||||
return tz;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user