mirror of
https://github.com/open-goal/jak-project
synced 2026-05-23 15:02:01 -04:00
decompiler: defskelgroup macro detection for jak 3, fix art group dumping for jak 3 and some more decomp work (#3370)
- `transformq` - `wind-work` - `progress-static` - `merc-vu1` - `emerc-vu1` - `merc` - `emerc` - `cloth-h` - Most of `cloth`, not added to gsrc yet Art group dumps were incorrect for Jak 3 because the master art group fields were at different offsets.
This commit is contained in:
@@ -902,7 +902,8 @@ void get_joint_info(ObjectFileDB& db, ObjectFileData& obj, JointGeo jg) {
|
||||
}
|
||||
|
||||
void get_art_info(ObjectFileDB& db, ObjectFileData& obj) {
|
||||
if (obj.obj_version == 4 || (obj.obj_version == 5 && obj.linked_data.segments == 1)) {
|
||||
// jak 1/2
|
||||
if (obj.obj_version == 4) {
|
||||
const auto& words = obj.linked_data.words_by_seg.at(MAIN_SEGMENT);
|
||||
if (words.at(0).kind() == LinkedWord::Kind::TYPE_PTR &&
|
||||
words.at(0).symbol_name() == "art-group") {
|
||||
@@ -961,6 +962,68 @@ void get_art_info(ObjectFileDB& db, ObjectFileData& obj) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// jak 3
|
||||
if (obj.obj_version == 5 && obj.linked_data.segments == 1) {
|
||||
const auto& words = obj.linked_data.words_by_seg.at(MAIN_SEGMENT);
|
||||
if (words.at(0).kind() == LinkedWord::Kind::TYPE_PTR &&
|
||||
words.at(0).symbol_name() == "art-group") {
|
||||
auto obj_unique_name = obj.to_unique_name();
|
||||
|
||||
// lg::print("art-group {}:\n", obj.to_unique_name());
|
||||
auto name = obj.linked_data.get_goal_string_by_label(words.at(2).label_id());
|
||||
int length = words.at(3).data;
|
||||
// lg::print(" length: {}\n", length);
|
||||
for (int i = 0; i < length; ++i) {
|
||||
const auto& word = words.at(8 + i);
|
||||
if (word.kind() == LinkedWord::Kind::SYM_PTR && word.symbol_name() == "#f") {
|
||||
continue;
|
||||
}
|
||||
const auto& label = obj.linked_data.labels.at(word.label_id());
|
||||
auto elt_name =
|
||||
obj.linked_data.get_goal_string_by_label(words.at(label.offset / 4 + 1).label_id());
|
||||
auto unique_name = elt_name;
|
||||
|
||||
auto ag_name = obj_unique_name;
|
||||
int elt_index = i;
|
||||
std::string elt_type = words.at(label.offset / 4 - 1).symbol_name();
|
||||
auto& word_master_ag = words.at(label.offset / 4 + 4);
|
||||
auto& word_master_idx = words.at(label.offset / 4 + 5);
|
||||
if (word_master_ag.kind() == LinkedWord::Kind::PTR &&
|
||||
word_master_idx.kind() == LinkedWord::Kind::PLAIN_DATA) {
|
||||
ag_name = obj.linked_data.get_goal_string_by_label(word_master_ag.label_id()) + "-ag";
|
||||
if (elt_type != "art-cloth-geo") {
|
||||
elt_index = word_master_idx.data;
|
||||
}
|
||||
}
|
||||
|
||||
if (elt_type == "art-joint-geo") {
|
||||
// the skeleton!
|
||||
unique_name += "-jg";
|
||||
JointGeo jg;
|
||||
jg.offset = label.offset;
|
||||
jg.name = unique_name;
|
||||
jg.length = words.at(label.offset / 4 + 2).data;
|
||||
get_joint_info(db, obj, jg);
|
||||
} else if (elt_type == "merc-ctrl" || elt_type == "shadow-geo") {
|
||||
// (maybe mesh-geo as well but that doesnt exist)
|
||||
// the skin!
|
||||
unique_name += "-mg";
|
||||
} else if (elt_type == "art-joint-anim") {
|
||||
// the animations!
|
||||
unique_name += "-ja";
|
||||
} else if (elt_type == "art-cloth-geo") {
|
||||
// cloth geometry (jak 3)
|
||||
unique_name += "-cg";
|
||||
} else {
|
||||
// the something idk!
|
||||
throw std::runtime_error(
|
||||
fmt::format("unknown art elt type {} in {}", elt_type, obj.to_unique_name()));
|
||||
}
|
||||
// lg::print(" {}: {} ({}) -> {} @ {}\n", i, elt_name, elt_type, unique_name, elt_index);
|
||||
db.dts.add_art_group_elt(ag_name, unique_name, elt_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
Reference in New Issue
Block a user