[jak 2] Export the collision mesh (#2977)

![image](https://github.com/open-goal/jak-project/assets/48171810/266d014b-f6c5-440f-9c3e-ab7c5eafe771)
This commit is contained in:
water111
2023-09-10 17:32:18 -04:00
committed by GitHub
parent 1bd30bce84
commit 9b9fe7a7af
7 changed files with 590 additions and 3 deletions
+27 -2
View File
@@ -971,6 +971,19 @@ void PrototypeBucketTie::read_from_file(TypedRef ref,
collide_frag.read_from_file(typed_ref_from_basic(p, dts), dts, stats, version);
}
}
} else {
if (get_word_kind_for_field(ref, "collide-hash-fragment-array", dts) ==
decompiler::LinkedWord::PTR) {
auto fr = deref_label(get_field_ref(ref, "collide-hash-fragment-array", dts));
fr.byte_offset -= 4;
auto collide_array = typed_ref_from_basic(fr, dts);
int length = read_plain_data_field<int32_t>(collide_array, "length", dts);
auto r = get_field_ref(collide_array, "fragments", dts);
for (int i = 0; i < length; i++) {
collide_hash_frags.push_back(deref_label(r));
r.byte_offset += 4;
}
}
}
auto next_slot = get_field_ref(ref, "next", dts);
@@ -1995,8 +2008,6 @@ void DrawableInlineArrayActor::read_from_file(TypedRef ref,
DrawStats* stats,
GameVersion version) {
int num_actors = read_plain_data_field<int16_t>(ref, "length", dts);
fmt::print("total of {} actors\n", num_actors);
auto data_ref = get_field_ref(ref, "data", dts);
for (int i = 0; i < num_actors; i++) {
Ref obj_ref = data_ref;
@@ -2010,6 +2021,14 @@ void DrawableInlineArrayActor::read_from_file(TypedRef ref,
}
}
void CollideHash::read_from_file(TypedRef ref,
const decompiler::DecompilerTypeSystem& dts,
level_tools::DrawStats* stats,
GameVersion version) {
num_items = read_plain_data_field<uint32_t>(ref, "num-items", dts);
item_array = deref_label(get_field_ref(ref, "item-array", dts));
}
void BspHeader::read_from_file(const decompiler::LinkedObjectFile& file,
const decompiler::DecompilerTypeSystem& dts,
DrawStats* stats,
@@ -2067,6 +2086,12 @@ void BspHeader::read_from_file(const decompiler::LinkedObjectFile& file,
get_and_check_ref_to_basic(ref, "actors", "drawable-inline-array-actor", dts), dts, stats,
version);
}
if (version > GameVersion::Jak1 &&
get_word_kind_for_field(ref, "collide-hash", dts) == decompiler::LinkedWord::PTR) {
collide_hash.read_from_file(
get_and_check_ref_to_basic(ref, "collide-hash", "collide-hash", dts), dts, stats, version);
}
}
std::string BspHeader::print(const PrintSettings& settings) const {