Skip to content

Commit

Permalink
Merge pull request #131 from dallmeyer/vanilla-20250106
Browse files Browse the repository at this point in the history
Vanilla 20250106
  • Loading branch information
dallmeyer authored Jan 7, 2025
2 parents fd6f769 + 6749fbb commit b5c18f5
Show file tree
Hide file tree
Showing 61 changed files with 48,158 additions and 3,639 deletions.
6 changes: 6 additions & 0 deletions common/formatter/rules/rule_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ const std::unordered_map<std::string, FormFormattingConfig> opengoal_form_config
{"defun-debug", new_flow_rule(3)},
{"defbehavior", new_flow_rule(4)},
{"if", new_inlineable_flow_rule(2)},
{"aif", new_inlineable_flow_rule(2)},
{"#if", new_inlineable_flow_rule(2)},
{"define", new_permissive_flow_rule()},
{"def-mips2c", new_permissive_flow_rule()},
Expand All @@ -305,10 +306,14 @@ const std::unordered_map<std::string, FormFormattingConfig> opengoal_form_config
{"declare-type", new_permissive_flow_rule()},
{"defmacro", new_function_rule(3)},
{"desfun", new_function_rule(3)},
{"def-actor", new_flow_rule(2, true)},
{"defskelgroup", new_flow_rule(2, true)},
{"defpartgroup", new_flow_rule(2, true)},
{"defpart", new_flow_rule(2, true)},
{"defstate", new_defstate_rule(3, true)},
{"defevent", new_flow_rule(2)},
{"event", new_flow_rule(1)},
{"defpost", new_flow_rule(2)},
{"behavior", new_flow_rule(2)},
{"dotimes", new_flow_rule(2)},
{"dolist", new_flow_rule(2)},
Expand All @@ -319,6 +324,7 @@ const std::unordered_map<std::string, FormFormattingConfig> opengoal_form_config
{"rlet", new_binding_rule(5)},
{"mlet", new_binding_rule(5)},
{"when", new_flow_rule(2)},
{"awhen", new_flow_rule(2)},
{"unless", new_flow_rule(2)},
{"with-profiler", new_flow_rule(2)},
{"with-pc", new_flow_rule(0)},
Expand Down
2 changes: 2 additions & 0 deletions common/serialization/subtitles/subtitles_v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ const std::unordered_map<std::string, u16> jak3_speaker_name_to_enum_val = {
{"martinsen", 42},
{"phillips", 43},
{"yates", 44},
{"ottsel-voice-before-outro", 45},
{"ottsel-voice", 46},
};

GameSubtitlePackage read_json_files_v2(const GameSubtitleDefinitionFile& file_info) {
Expand Down
55 changes: 55 additions & 0 deletions common/util/FontUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ static std::vector<ReplaceInfo> s_replace_info_jak1 = {
{"U~Y~-13H~+2V,~Z", "Ų"},
{"U~Y~-18H~-10V-~Z", "Ū"},
{"I~Y~-8H~+1V,~Z", "Į"},
// czech specific
{"U~Y~-23H~-5Vº~Z", "Ů"},

// tildes
{"N~Y~-22H~-4V<TIL>~Z", "Ñ"},
Expand All @@ -575,6 +577,8 @@ static std::vector<ReplaceInfo> s_replace_info_jak1 = {
{"N~Y~-21H~-5V'~Z", "Ń"},
{"S~Y~-21H~-5V'~Z", "Ś"},
{"Z~Y~-21H~-5V'~Z", "Ź"},
// czech specific
{"Y~Y~-25H~-4V'~Z", "Ý"},

// double acute accents
{"O~Y~-28H~-4V'~-9H'~Z", "Ő"}, // custom
Expand Down Expand Up @@ -602,6 +606,22 @@ static std::vector<ReplaceInfo> s_replace_info_jak1 = {
{"O~Y~-22H~-3V¨~Z", "ö"}, // dumb
{"U~Y~-22H~-3V¨~Z", "Ü"},

// caron - Ǎ ǎ Ě ě Ǧ ǧ Ǐ ǐ Ǒ ǒ Ǔ ǔ Y̌ y̌
{"A~Y~-20H~-4Vˇ~Z", "Ǎ"},
{"E~Y~-20H~-5Vˇ~Z", "Ě"},
{"G~Y~-20H~-5Vˇ~Z", "Ǧ"},
{"I~Y~-19H~-5Vˇ~Z", "Ǐ"},
{"O~Y~-20H~-4Vˇ~Z", "Ǒ"},
{"U~Y~-24H~-3Vˇ~Z", "Ǔ"},
{"Y~Y~-24H~-3Vˇ~Z", ""},
// czech specific - Č Ň Ř Š Ž Ť
{"C~Y~-25H~-9Vˇ~Z", "Č"},
{"N~Y~-23H~-5Vˇ~Z", "Ň"},
{"R~Y~-24H~-5Vˇ~Z", "Ř"},
{"S~Y~-24H~-5Vˇ~Z", "Š"},
{"T~Y~-23H~-5Vˇ~Z", "Ť"},
{"Z~Y~-23H~-5Vˇ~Z", "Ž"},

// dakuten katakana
{"~Yウ~Z゛", ""},
{"~Yカ~Z゛", ""},
Expand Down Expand Up @@ -966,6 +986,10 @@ static std::vector<ReplaceInfo> s_replace_info_jak2 = {
{"u~Y~-18H~-15V-~Z", "ū"},
{"I~Y~-8H~+4V,~Z", "Į"},
{"i~Y~-8H~+4V,~Z", "į"},
// czech specific
{"U~Y~-24H~-7Vº~Z", "Ů"},
{"u~Y~-23H~-5Vº~Z", "ů"},
{"t~Y~-7H~-21V,~Z", "ť"},

// tildes
{"N~Y~-22H~-4V<TIL>~Z", "Ñ"},
Expand All @@ -987,6 +1011,9 @@ static std::vector<ReplaceInfo> s_replace_info_jak2 = {
{"u~Y~-24H~-3V'~Z", "ú"},
{"Z~Y~-24H~-3V'~Z", "Ź"},
{"z~Y~-24H~-3V'~Z", "ź"},
// czech specific
{"Y~Y~-26H~-5V'~Z", "Ý"},
{"~+7Vy~-7V~Y~-24H~-3V'~Z", "ý"},

// circumflex
{"A~Y~-20H~-4V^~Z", "Â"},
Expand Down Expand Up @@ -1023,6 +1050,34 @@ static std::vector<ReplaceInfo> s_replace_info_jak2 = {
{"U~Y~-25H~-8V¨~Z", "Ü"},
{"u~Y~-24H~-3V¨~Z", "ü"},

// caron - Ǎ ǎ Ě ě Ǧ ǧ Ǐ ǐ Ǒ ǒ Ǔ ǔ Y̌ y̌
{"A~Y~-25H~-9Vˇ~Z", "Ǎ"},
{"a~Y~-24H~-5Vˇ~Z", "ǎ"},
{"E~Y~-22H~-8Vˇ~Z", "Ě"},
{"e~Y~-25H~-4Vˇ~Z", "ě"},
{"G~Y~-24H~-8Vˇ~Z", "Ǧ"},
{"~+7Vg~-7V~Y~-25H~-4Vˇ~Z", "ǧ"},
{"I~Y~-19H~-8Vˇ~Z", "Ǐ"},
{"i~Y~-19H~-8Vˇ~Z", "ǐ"},
{"O~Y~-25H~-7Vˇ~Z", "Ǒ"},
{"o~Y~-25H~-4Vˇ~Z", "ǒ"},
{"U~Y~-25H~-6Vˇ~Z", "Ǔ"},
{"u~Y~-24H~-3Vˇ~Z", "ǔ"},
{"Y~Y~-25H~-5Vˇ~Z", ""},
{"~+7Vy~-7V~Y~-25H~-3Vˇ~Z", ""},
// czech specific - Č č Ň ň Ř ř Š š Ž ž Ť
{"C~Y~-25H~-9Vˇ~Z", "Č"},
{"c~Y~-24H~-5Vˇ~Z", "č"},
{"N~Y~-25H~-9Vˇ~Z", "Ň"},
{"n~Y~-24H~-5Vˇ~Z", "ň"},
{"R~Y~-25H~-9Vˇ~Z", "Ř"},
{"r~Y~-22H~-5Vˇ~Z", "ř"},
{"S~Y~-25H~-9Vˇ~Z", "Š"},
{"s~Y~-22H~-5Vˇ~Z", "š"},
{"T~Y~-24H~-7Vˇ~Z", "Ť"},
{"Z~Y~-25H~-9Vˇ~Z", "Ž"},
{"z~Y~-24H~-5Vˇ~Z", "ž"},

// dakuten katakana
{"~Yウ~Z゛", ""},
{"~Yカ~Z゛", ""},
Expand Down
85 changes: 85 additions & 0 deletions common/util/gltf_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,4 +756,89 @@ tfrag3::PackedTimeOfDay pack_time_of_day(const std::vector<math::Vector<u8, 4>>&
return colors;
}

void process_normal_merc_draw(const tinygltf::Model& model,
MercExtractData& out,
u32 tex_offset,
tfrag3::MercEffect& eff,
int mat_idx,
const tfrag3::MercDraw& d_) {
const auto& mat = model.materials[mat_idx];
eff.all_draws.push_back(d_);
auto& draw = eff.all_draws.back();
draw.mode = gltf_util::make_default_draw_mode();

if (mat_idx == -1) {
lg::warn("Draw had a material index of -1, using default texture.");
draw.tree_tex_id = 0;
return;
}
int tex_idx = mat.pbrMetallicRoughness.baseColorTexture.index;
if (tex_idx == -1) {
lg::warn("Material {} has no texture, using default texture.", mat.name);
draw.tree_tex_id = 0;
return;
}

const auto& tex = model.textures[tex_idx];
ASSERT(tex.sampler >= 0);
ASSERT(tex.source >= 0);
gltf_util::setup_draw_mode_from_sampler(model.samplers.at(tex.sampler), &draw.mode);
gltf_util::setup_alpha_from_material(mat, &draw.mode);

const auto& img = model.images[tex.source];
draw.tree_tex_id = tex_offset + texture_pool_add_texture(&out.tex_pool, img);
};

void process_envmap_merc_draw(const tinygltf::Model& model,
MercExtractData& out,
u32 tex_offset,
tfrag3::MercEffect& eff,
int mat_idx,
const tfrag3::MercDraw& d_) {
const auto& mat = model.materials[mat_idx];
eff.all_draws.push_back(d_);
auto& draw = eff.all_draws.back();
draw.mode = gltf_util::make_default_draw_mode();

if (mat_idx == -1) {
lg::warn("Envmap draw had a material index of -1, using default texture.");
draw.tree_tex_id = texture_pool_debug_checker(&out.tex_pool);
return;
}
int base_tex_idx = mat.pbrMetallicRoughness.baseColorTexture.index;
if (base_tex_idx == -1) {
lg::warn("Envmap material {} has no texture, using default texture.", mat.name);
draw.tree_tex_id = texture_pool_debug_checker(&out.tex_pool);
return;
}

const auto& base_tex = model.textures[base_tex_idx];
ASSERT(base_tex.sampler >= 0);
ASSERT(base_tex.source >= 0);
gltf_util::setup_draw_mode_from_sampler(model.samplers.at(base_tex.sampler), &draw.mode);
gltf_util::setup_alpha_from_material(mat, &draw.mode);
const auto& roughness_tex =
model.textures.at(mat.pbrMetallicRoughness.metallicRoughnessTexture.index);
ASSERT(roughness_tex.sampler >= 0);
ASSERT(roughness_tex.source >= 0);

draw.tree_tex_id =
tex_offset + gltf_util::texture_pool_add_envmap_control_texture(
&out.tex_pool, model, base_tex.source, roughness_tex.source,
!draw.mode.get_clamp_s_enable(), !draw.mode.get_clamp_t_enable());

// now, setup envmap draw:
auto envmap_settings = gltf_util::envmap_settings_from_gltf(mat);
const auto& envmap_tex = model.textures[envmap_settings.texture_idx];
ASSERT(envmap_tex.sampler >= 0);
ASSERT(envmap_tex.source >= 0);
auto env_mode = gltf_util::make_default_draw_mode();
gltf_util::setup_draw_mode_from_sampler(model.samplers.at(envmap_tex.sampler), &env_mode);
eff.envmap_texture = tex_offset + gltf_util::texture_pool_add_texture(
&out.tex_pool, model.images[envmap_tex.source]);
env_mode.set_alpha_blend(DrawMode::AlphaBlend::SRC_0_DST_DST);
env_mode.enable_ab();
eff.envmap_mode = env_mode;
};

} // namespace gltf_util
31 changes: 31 additions & 0 deletions common/util/gltf_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,35 @@ math::Matrix4f matrix_from_trs(const math::Vector3f& trans,

tfrag3::PackedTimeOfDay pack_time_of_day(const std::vector<math::Vector<u8, 4>>& color_palette);

struct MercExtractData {
TexturePool tex_pool;
std::vector<u32> new_indices;
std::vector<tfrag3::PreloadedVertex> new_vertices;
std::vector<math::Vector<u8, 4>> new_colors;
std::vector<math::Vector3f> normals;
std::vector<JointsAndWeights> joints_and_weights;
tfrag3::MercModel new_model;
};

// Data produced by loading a replacement model
struct MercSwapData {
std::vector<u32> new_indices;
std::vector<tfrag3::MercVertex> new_vertices;
std::vector<tfrag3::Texture> new_textures;
tfrag3::MercModel new_model;
};

void process_normal_merc_draw(const tinygltf::Model& model,
MercExtractData& out,
u32 tex_offset,
tfrag3::MercEffect& eff,
int mat_idx,
const tfrag3::MercDraw& d_);
void process_envmap_merc_draw(const tinygltf::Model& model,
MercExtractData& out,
u32 tex_offset,
tfrag3::MercEffect& eff,
int mat_idx,
const tfrag3::MercDraw& d_);

} // namespace gltf_util
4 changes: 4 additions & 0 deletions custom_assets/blender_plugins/opengoal.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ def draw_func_ob(self, context):
ob = context.object
layout.prop(ob, "set_invisible")
layout.prop(ob, "enable_custom_weights")
layout.prop(ob, "copy_eye_draws")
layout.prop(ob, "copy_mod_draws")
layout.prop(ob, "set_collision")
if (ob.set_collision):
layout.prop(ob, "ignore")
Expand Down Expand Up @@ -118,6 +120,8 @@ def register():
bpy.types.Object.set_invisible = bpy.props.BoolProperty(name="Invisible")
bpy.types.Object.set_collision = bpy.props.BoolProperty(name="Apply Collision Properties")
bpy.types.Object.enable_custom_weights = bpy.props.BoolProperty(name="Use Custom Bone Weights")
bpy.types.Object.copy_eye_draws = bpy.props.BoolProperty(name="Copy Eye Draws")
bpy.types.Object.copy_mod_draws = bpy.props.BoolProperty(name="Copy Mod Draws")
bpy.types.Object.ignore = bpy.props.BoolProperty(name="ignore")
bpy.types.Object.noedge = bpy.props.BoolProperty(name="No-Edge")
bpy.types.Object.noentity = bpy.props.BoolProperty(name="No-Entity")
Expand Down
3 changes: 0 additions & 3 deletions decompiler/IR2/FormExpressionAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2603,9 +2603,6 @@ void SetVarElement::push_to_stack(const Env& env, FormPool& pool, FormStack& sta
ASSERT(x->parent_form == m_src);
}

if (auto test0 = m_src->to_string(env) == "(* 0.00024414062 (-> arg0 y))") {
printf("");
}
if (m_src->is_single_element()) {
auto src_as_se = dynamic_cast<SimpleExpressionElement*>(m_src->back());
if (src_as_se) {
Expand Down
2 changes: 1 addition & 1 deletion decompiler/config/jak2/jak2_config.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"rip_collision": false,
// save game textures as .png files to decompiler_out/<game>/textures
"save_texture_pngs": false,

// whether or not to dump out streamed audio files to decompiler_out/<game>/audio
"rip_streamed_audio": false,

Expand Down
10 changes: 10 additions & 0 deletions decompiler/level_extractor/extract_level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ void extract_art_groups_from_level(const ObjectFileDB& db,
if (db.obj_files_by_dgo.count(dgo_name)) {
const auto& files = db.obj_files_by_dgo.at(dgo_name);
MercSwapInfo swapped_info;
// build list of models to replace
auto merc_replacements_path = file_util::get_jak_project_dir() / "custom_assets" /
game_version_names[db.version()] / "merc_replacements";
if (file_util::file_exists(merc_replacements_path.string())) {
auto custom_models =
file_util::find_files_in_dir(merc_replacements_path, std::regex(".*\\.glb"));
for (auto& mdl : custom_models) {
swapped_info.add_to_swap_list(mdl.stem().string());
}
}
for (const auto& file : files) {
if (file.name.length() > 3 && !file.name.compare(file.name.length() - 3, 3, "-ag")) {
const auto& ag_file = db.lookup_record(file);
Expand Down
7 changes: 7 additions & 0 deletions decompiler/level_extractor/extract_level.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ namespace decompiler {

// info about what models have been replaced/added per level
struct MercSwapInfo {
std::vector<std::string> swap_list;
std::map<std::string, std::vector<std::string>> per_level_merc_swaps;
std::map<std::string, std::vector<std::string>> per_level_custom_mdls;

bool should_swap(const std::string& model) {
return std::find(swap_list.begin(), swap_list.end(), model) != swap_list.end();
}

bool already_swapped(const std::string& model, const std::string& level) {
auto mdls_it = per_level_merc_swaps.find(level);
if (mdls_it != per_level_merc_swaps.end()) {
Expand All @@ -35,6 +40,8 @@ struct MercSwapInfo {
return false;
}

void add_to_swap_list(const std::string& model) { swap_list.push_back(model); }

void add_to_swapped_list(const std::string& model, const std::string& level) {
per_level_merc_swaps[level].push_back(model);
}
Expand Down
Loading

0 comments on commit b5c18f5

Please sign in to comment.