mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-10-03 04:18:09 +03:00
SealEngine: Implement ZWrite .opr attribute
This commit is contained in:
@@ -664,6 +664,7 @@ enum mesh_flags {
|
||||
MESH_NO_HEIGHT_DETECTION = 1 << 7,
|
||||
MESH_ALPHA = 1 << 8,
|
||||
MESH_HAS_LIGHT_UV = 1 << 9,
|
||||
MESH_NO_ZWRITE = 1 << 10,
|
||||
};
|
||||
|
||||
struct pol_mesh {
|
||||
|
||||
@@ -620,6 +620,15 @@ void opr_load(uint8_t *data, size_t size, struct pol *pol)
|
||||
} else {
|
||||
WARNING("invalid HeightDetection: %s", s);
|
||||
}
|
||||
} else if (sscanf(line, "ZWrite = %s", s) == 1) {
|
||||
if (!strcmp(s, "false")) {
|
||||
for (int i = 0; i < pol->nr_meshes; i++) {
|
||||
if (!selected[i]) continue;
|
||||
pol->meshes[i]->flags |= MESH_NO_ZWRITE;
|
||||
}
|
||||
} else if (strcmp(s, "true")) {
|
||||
WARNING("invalid ZWrite: %s", s);
|
||||
}
|
||||
} else if (sscanf(line, "UVScroll = ( %f , %f )", &f1, &f2) == 2) {
|
||||
for (int i = 0; i < pol->nr_meshes; i++) {
|
||||
if (!selected[i]) continue;
|
||||
|
||||
@@ -506,12 +506,16 @@ static void render_model(struct RE_instance *inst, struct RE_renderer *r, enum d
|
||||
|
||||
if (mesh->flags & MESH_BOTH)
|
||||
glDisable(GL_CULL_FACE);
|
||||
if (mesh->flags & MESH_NO_ZWRITE)
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
if (mesh->nr_indices)
|
||||
glDrawElements(GL_TRIANGLES, mesh->nr_indices, GL_UNSIGNED_SHORT, NULL);
|
||||
else
|
||||
glDrawArrays(GL_TRIANGLES, 0, mesh->nr_vertices);
|
||||
|
||||
if (mesh->flags & MESH_NO_ZWRITE)
|
||||
glDepthMask(GL_TRUE);
|
||||
if (mesh->flags & MESH_BOTH)
|
||||
glEnable(GL_CULL_FACE);
|
||||
glBindVertexArray(0);
|
||||
|
||||
Reference in New Issue
Block a user