Skip to content

Commit

Permalink
Editor: Kage export: Fix triangle list construction for strips and bi…
Browse files Browse the repository at this point in the history
…llboards

+ Enable KG2 export in release mode
  • Loading branch information
pmttavara committed Feb 15, 2024
1 parent ab72312 commit 8645b14
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions ph2ed_proto/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3557,11 +3557,13 @@ DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,20 Size=1920,1007 Split=Y
}
#ifndef NDEBUG
{
// map_load(g, "map/ob01 (2).map");
map_load(g, "map/ob01 (2).map");
// cld_load(g, "../cld/cld/ob01.cld");
// map_load(g, "map/ap64.map");
// test_all_maps(g);
test_all_kg2s(g);
// test_all_kg2s(g);
bool kg2_export(char *filename);
bool success = kg2_export("kg2/ap01.kg2");
// sapp_request_quit();
}
#endif
Expand Down Expand Up @@ -4882,13 +4884,13 @@ bool kg2_export(char *filename) {
KG2_Export_Vertex v1 = vertices[vertices.count - 1];
KG2_Export_Vertex v2 = {posf.XYZ, normalf};
if (vertex_index & 1) {
vertices.push(v0);
vertices.push(v1);
vertices.push(v2);
} else {
vertices.push(v0);
vertices.push(v2);
} else {
vertices.push(vertices[vertices.count - 3]); // index - 2 in the stripped version, but we have added triangles since then!!
vertices.push(v1);
vertices.push(v2);
}

group->length += 3;
Expand Down Expand Up @@ -4935,9 +4937,12 @@ bool kg2_export(char *filename) {
HMM_Vec4 posf = {pos.x*1.f, pos.y*1.f, pos.z*1.f, pos.w*1.f};
posf = shadow_object_header.matrix * posf;

vertices.push({vertices[group->start_index].position, normalf});
vertices.push({vertices[vertices.count - 1].position, normalf});
vertices.push({posf.XYZ, normalf});
KG2_Export_Vertex v0 = vertices[group->start_index];
KG2_Export_Vertex v1 = vertices[vertices.count - 1];
KG2_Export_Vertex v2 = {posf.XYZ, normalf};
vertices.push({v0.position, normalf});
vertices.push({v1.position, normalf});
vertices.push({v2.position, normalf});
group->length += 3;
}
KG2_export_log(" }");
Expand Down Expand Up @@ -5447,7 +5452,9 @@ static void frame(void *userdata) {
free(obj_file_buf);
};

// static unsigned long long asdfasdf; if (!asdfasdf++) obj_file_buf = strdup("map/ap64.map.obj");
#ifndef NDEBUG
static bool asdfasdf; if (!asdfasdf++) obj_file_buf = strdup("kg2/ap01.kg2.obj");
#endif

char *dds_file_buf = nullptr;
defer {
Expand Down Expand Up @@ -5500,7 +5507,7 @@ static void frame(void *userdata) {
start_export_all_as_obj_popup = true;
}
ImGui::Separator();
#ifndef NDEBUG
#if 1 // ndef NDEBUG
if (ImGui::MenuItem("Convert KG2 to OBJ...")) {
char *kg2_file_buf = win_import_or_export_dialog(L"KG2 Shadow File (*.kg2)\0" "*.kg2\0"
"All Files (*.*)\0" "*.*\0",
Expand Down

0 comments on commit 8645b14

Please sign in to comment.