From d3f5b69137ad82984af58d5aedbc1ab99bf29088 Mon Sep 17 00:00:00 2001 From: korenkonder Date: Thu, 15 Jun 2023 02:44:30 +0300 Subject: [PATCH] Motion Test (WiP) --- src/CRE/Glitter/glitter.hpp | 2 +- src/CRE/Glitter/render_scene.cpp | 8 +- src/CRE/auth_3d.cpp | 2 +- src/CRE/auth_3d.hpp | 2 +- src/CRE/customize_item_table.cpp | 2 +- src/CRE/item_table.cpp | 13 +- src/CRE/item_table.hpp | 7 +- src/CRE/light_param/wind.cpp | 9 + src/CRE/light_param/wind.hpp | 6 +- src/CRE/module_table.cpp | 24 +- src/CRE/module_table.hpp | 5 +- src/CRE/object.cpp | 8 +- src/CRE/pv_db.cpp | 2 +- src/CRE/pv_expression.cpp | 14 +- src/CRE/pv_expression.hpp | 4 +- src/CRE/rob/ex_block.cpp | 24 +- src/CRE/rob/rob.cpp | 2270 +++++++++---------- src/CRE/rob/rob.hpp | 116 +- src/CRE/rob/skin_param.cpp | 6 +- src/CRE/rob/skin_param.hpp | 2 +- src/CRE/task_effect.cpp | 14 +- src/DivaGL/bone_data.hpp | 18 +- src/KKdLib/database/aet.cpp | 24 +- src/KKdLib/database/object.cpp | 14 +- src/KKdLib/database/sprite.cpp | 24 +- src/KKdLib/io/json.cpp | 18 +- src/KKdLib/io/msgpack.cpp | 2 +- src/KKdLib/key_val.cpp | 129 +- src/KKdLib/key_val.hpp | 25 +- src/KKdLib/msgpack.cpp | 10 +- src/KKdLib/msgpack.hpp | 4 +- src/KKdLib/prj/vector_pair.hpp | 26 + src/KKdLib/prj/vector_pair_combine.hpp | 16 + src/ReDIVA/classes/data_view/draw_task.cpp | 10 +- src/ReDIVA/data_edit.cpp | 2 +- src/ReDIVA/data_test/auth_2d_test.cpp | 50 +- src/ReDIVA/data_test/auth_3d_test.cpp | 39 +- src/ReDIVA/data_test/auth_3d_test.hpp | 27 +- src/ReDIVA/data_test/equip_test.cpp | 192 ++ src/ReDIVA/data_test/equip_test.hpp | 196 ++ src/ReDIVA/data_test/motion_test.cpp | 2298 +++++++++++++++++--- src/ReDIVA/data_test/motion_test.hpp | 454 +++- src/ReDIVA/data_test/stage_test.cpp | 17 +- src/ReDIVA/dw.cpp | 242 ++- src/ReDIVA/dw.hpp | 159 +- src/ReDIVA/game_state.cpp | 2 +- src/ReDIVA/pv_game/pv_game.cpp | 6 +- src/ReDIVA/pv_game/pv_game.hpp | 2 +- src/ReDIVA/pv_game/pv_game_pv_data.cpp | 14 +- src/ReDIVA/pv_game/pv_game_pv_data.hpp | 2 +- src/ReDIVA/render.cpp | 3 + src/ReDIVA/x_pv_game.cpp | 52 +- src/ReDIVA/x_pv_game.hpp | 6 +- 53 files changed, 4764 insertions(+), 1859 deletions(-) create mode 100644 src/ReDIVA/data_test/equip_test.cpp create mode 100644 src/ReDIVA/data_test/equip_test.hpp diff --git a/src/CRE/Glitter/glitter.hpp b/src/CRE/Glitter/glitter.hpp index bfb0cccb..6cca70bd 100644 --- a/src/CRE/Glitter/glitter.hpp +++ b/src/CRE/Glitter/glitter.hpp @@ -761,7 +761,7 @@ namespace Glitter { GLuint vbo; GLuint ebo; float_t emission; - std::vector> draw_list; + prj::vector_pair draw_list; RenderGroup(); virtual ~RenderGroup(); diff --git a/src/CRE/Glitter/render_scene.cpp b/src/CRE/Glitter/render_scene.cpp index bda39636..08384d17 100644 --- a/src/CRE/Glitter/render_scene.cpp +++ b/src/CRE/Glitter/render_scene.cpp @@ -236,7 +236,7 @@ namespace Glitter { if (j > 0) { disp += j; - rend_group->draw_list.push_back({ (GLint)index, (GLsizei)j }); + rend_group->draw_list.push_back((GLint)index, (GLsizei)j); index += j; } } @@ -395,7 +395,7 @@ namespace Glitter { if (j > 0) { disp += j; - rend_group->draw_list.push_back({ (GLint)index, (GLsizei)(j * 2) }); + rend_group->draw_list.push_back((GLint)index, (GLsizei)(j * 2)); index += j * 2; } } @@ -1247,7 +1247,7 @@ namespace Glitter { if (j > 0) { disp += j; - rend_group->draw_list.push_back({ (GLint)index, (GLsizei)j }); + rend_group->draw_list.push_back((GLint)index, (GLsizei)j); index += j; } } @@ -1404,7 +1404,7 @@ namespace Glitter { if (j > 0) { disp += j; - rend_group->draw_list.push_back({ (GLint)index, (GLsizei)(j * 2) }); + rend_group->draw_list.push_back((GLint)index, (GLsizei)(j * 2)); index += j * 2; } } diff --git a/src/CRE/auth_3d.cpp b/src/CRE/auth_3d.cpp index 257e4efe..2c7932a2 100644 --- a/src/CRE/auth_3d.cpp +++ b/src/CRE/auth_3d.cpp @@ -2535,7 +2535,7 @@ void auth_3d_id::set_visibility(bool value) { } } -void auth_3d_id::unload_id(render_context* rctx) { +void auth_3d_id::unload(render_context* rctx) { if (id < 0 || (id & 0x7FFF) >= AUTH_3D_DATA_COUNT) return; diff --git a/src/CRE/auth_3d.hpp b/src/CRE/auth_3d.hpp index 0fabfe74..ea9d4b4f 100644 --- a/src/CRE/auth_3d.hpp +++ b/src/CRE/auth_3d.hpp @@ -846,7 +846,7 @@ struct auth_3d_id { void set_shadow(bool value); void set_src_dst_chara(int32_t src_chara, int32_t dst_chara); void set_visibility(bool value); - void unload_id(render_context* rctx); + void unload(render_context* rctx); }; inline bool operator >(const auth_3d_id& left, const auth_3d_id& right) { diff --git a/src/CRE/customize_item_table.cpp b/src/CRE/customize_item_table.cpp index 54dd72eb..4620a18f 100644 --- a/src/CRE/customize_item_table.cpp +++ b/src/CRE/customize_item_table.cpp @@ -207,7 +207,7 @@ void customize_item_table_handler::parse(p_file_handler* pfhndl) { customize_item.parts = parts; } - customize_items.push_back({ customize_item.id, customize_item }); + customize_items.push_back(customize_item.id, customize_item); kv.close_scope(); } diff --git a/src/CRE/item_table.cpp b/src/CRE/item_table.cpp index 86d9660b..8cfbba2b 100644 --- a/src/CRE/item_table.cpp +++ b/src/CRE/item_table.cpp @@ -318,7 +318,7 @@ static void item_table_load(data_struct* data, item_table& itm_tbl, itm_table& i itm.org_itm = i.org_itm; itm.npr_flag = i.npr_flag; itm.face_depth = i.face_depth; - itm_tbl.item.insert_or_assign(i.no, itm); + itm_tbl.item.push_back(i.no, itm); } for (itm_table_dbgset& i : itm_tbl_file.dbgset) { @@ -328,7 +328,7 @@ static void item_table_load(data_struct* data, item_table& itm_tbl, itm_table& i item_table_dbgset dbg; dbg.item = i.item; - itm_tbl.dbgset.insert_or_assign(set_id, dbg); + itm_tbl.dbgset.push_back(set_id, dbg); } for (itm_table_cos& i : itm_tbl_file.cos) { @@ -341,9 +341,12 @@ static void item_table_load(data_struct* data, item_table& itm_tbl, itm_table& i if (item) cos.arr[item->sub_id] = j; } - itm_tbl.cos.insert_or_assign(i.id, cos); + itm_tbl.cos.push_back(i.id, cos); } - item_cos_data cos = {}; - itm_tbl.cos.insert_or_assign(499, cos); + itm_tbl.cos.push_back(499, {}); + + itm_tbl.item.combine(); + itm_tbl.dbgset.combine(); + itm_tbl.cos.combine(); } diff --git a/src/CRE/item_table.hpp b/src/CRE/item_table.hpp index 6b0e7c21..787674bb 100644 --- a/src/CRE/item_table.hpp +++ b/src/CRE/item_table.hpp @@ -7,6 +7,7 @@ #include "../KKdLib/default.hpp" #include "../KKdLib/database/item_table.hpp" +#include "../KKdLib/prj/vector_pair_combine.hpp" #include "file_handler.hpp" #include "object.hpp" #include "texture.hpp" @@ -111,9 +112,9 @@ struct item_table_dbgset { }; struct item_table { - std::map item; - std::map cos; - std::map dbgset; + prj::vector_pair_combine item; + prj::vector_pair_combine cos; + prj::vector_pair_combine dbgset; item_table(); ~item_table(); diff --git a/src/CRE/light_param/wind.cpp b/src/CRE/light_param/wind.cpp index d58fa3fa..6eaddf46 100644 --- a/src/CRE/light_param/wind.cpp +++ b/src/CRE/light_param/wind.cpp @@ -137,6 +137,15 @@ void task_wind_init() { task_wind = new TaskWind; } +bool task_wind_hide_task() { + task_wind->ptr->reset(); + return task_wind->HideTask(); +} + +bool task_wind_run_task() { + return task_wind->RunTask(); +} + void task_wind_free() { if (task_wind) { delete task_wind; diff --git a/src/CRE/light_param/wind.hpp b/src/CRE/light_param/wind.hpp index e7eb3b29..a897fa99 100644 --- a/src/CRE/light_param/wind.hpp +++ b/src/CRE/light_param/wind.hpp @@ -61,5 +61,7 @@ public: extern TaskWind* task_wind; -void task_wind_init(); -void task_wind_free(); +extern void task_wind_init(); +extern bool task_wind_hide_task(); +extern bool task_wind_run_task(); +extern void task_wind_free(); diff --git a/src/CRE/module_table.cpp b/src/CRE/module_table.cpp index 07facb66..c12dbfdb 100644 --- a/src/CRE/module_table.cpp +++ b/src/CRE/module_table.cpp @@ -81,15 +81,27 @@ module::~module() { } -module_data::module_data() : sort_index(), chara_index(), cos(), -sleeve_l(), sleeve_r(), field_78(), field_79(), field_A0() { +module_data::module_data() : id(), sort_index(), chara_index(), cos(), sleeve_l(), sleeve_r(), +spr_sel_md_id_spr_set_id(), spr_sel_md_id_cmn_spr_set_id(), spr_sel_md_id_cmn_md_img_id_spr_id(), +spr_sel_md_id_cmn_md_img_spr_id(), field_78(), field_79(), field_A0() { + reset(); +} + +void module_data::reset() { id = -1; + sort_index = 0; + chara_index = CHARA_MIKU; + cos = 0; + sleeve_l = {}; + sleeve_r = {}; spr_sel_md_id_spr_set_id = -1; spr_sel_md_id_cmn_spr_set_id = -1; spr_sel_md_id_cmn_md_img_id_spr_id = -1; spr_sel_md_id_cmn_md_img_spr_id = -1; + field_78 = false; + field_79 = false; name.assign(""); - + field_A0 = 0; field_A8 = prj::time::get_default(); field_B0 = prj::time::get_default(); } @@ -139,6 +151,10 @@ bool module_data_handler_data_get_module(int32_t id, module_data& data) { return module_data_handler_data->get_module(id, data); } +const std::vector& module_data_handler_data_get_modules() { + return module_data_handler_data->modules; +} + void module_data_handler_data_free() { if (module_data_handler_data) { delete module_data_handler_data; @@ -276,7 +292,7 @@ void module_table_handler::parse(p_file_handler* pfhndl) { } } - modules.push_back({ module.id, module }); + modules.push_back(module.id, module); kv.close_scope(); } diff --git a/src/CRE/module_table.hpp b/src/CRE/module_table.hpp index 593a978e..59a6ec7b 100644 --- a/src/CRE/module_table.hpp +++ b/src/CRE/module_table.hpp @@ -38,9 +38,11 @@ struct module_data { std::string name; int32_t field_A0; prj::time field_A8; - prj::time field_B0; + prj::time field_B0; module_data(); + + void reset(); }; extern void module_table_handler_data_init(); @@ -54,4 +56,5 @@ extern void module_data_handler_data_init(); extern void module_data_handler_data_add_all_modules(); extern bool module_data_handler_data_get_module(chara_index chara_index, int32_t cos, module_data& data); extern bool module_data_handler_data_get_module(int32_t id, module_data& data); +extern const std::vector& module_data_handler_data_get_modules(); extern void module_data_handler_data_free(); diff --git a/src/CRE/object.cpp b/src/CRE/object.cpp index 054eec90..7d4fce27 100644 --- a/src/CRE/object.cpp +++ b/src/CRE/object.cpp @@ -1971,7 +1971,7 @@ bool object_storage_load_obj_set_check_not_read(uint32_t set_id, handler->obj_file_handler.reset(); handler->obj_id_data.reserve(set->obj_num); for (uint32_t i = 0; i < set->obj_num; i++) - handler->obj_id_data.push_back({ set->obj_data[i].id, i }); + handler->obj_id_data.push_back(set->obj_data[i].id, i); handler->obj_id_data.sort(); if (!obj_set_handler_vertex_buffer_load(handler) @@ -2088,7 +2088,7 @@ bool object_storage_load_obj_set_check_not_read(uint32_t set_id, handler->obj_file_handler.reset(); handler->obj_id_data.reserve(set->obj_num); for (uint32_t i = 0; i < set->obj_num; i++) - handler->obj_id_data.push_back({ set->obj_data[i].id, i }); + handler->obj_id_data.push_back(set->obj_data[i].id, i); if (!obj_set_handler_vertex_buffer_load(handler) || !obj_set_handler_index_buffer_load(handler)) @@ -2301,7 +2301,7 @@ static bool obj_set_handler_load_textures(obj_set_handler* handler, const void* uint32_t tex_num = handler->tex_num; texture** tex_data = handler->tex_data; for (uint32_t i = 0; i < tex_num; i++) { - handler->tex_id_data.push_back({ tex_id_data[i], i }); + handler->tex_id_data.push_back(tex_id_data[i], i); handler->gentex.push_back(tex_data[i]); } handler->tex_id_data.sort(); @@ -2330,7 +2330,7 @@ static bool obj_set_handler_load_textures_modern(obj_set_handler* handler, uint32_t tex_num = handler->tex_num; texture** tex_data = handler->tex_data; for (uint32_t i = 0; i < tex_num; i++) { - handler->tex_id_data.push_back({ tex_id_data[i], i }); + handler->tex_id_data.push_back(tex_id_data[i], i); handler->gentex.push_back(tex_data[i]); } handler->tex_id_data.sort(); diff --git a/src/CRE/pv_db.cpp b/src/CRE/pv_db.cpp index f7ed5395..0fe5b652 100644 --- a/src/CRE/pv_db.cpp +++ b/src/CRE/pv_db.cpp @@ -492,7 +492,7 @@ int32_t pv_db_pv::get_chrmot_motion_id(int32_t chara_id, for (const pv_db_pv_chrmot& i : chrmot) if (i.id == chara_id && chara_index_get_from_chara_name(i.chara.c_str()) == chara_index && !i.org_name.compare(motion.name)) { - int32_t motion_id = aft_mot_db->get_motion_id(i.name.c_str()); + uint32_t motion_id = aft_mot_db->get_motion_id(i.name.c_str()); if (motion_id != -1) return motion_id; break; diff --git a/src/CRE/pv_expression.cpp b/src/CRE/pv_expression.cpp index 81115fe1..a493d229 100644 --- a/src/CRE/pv_expression.cpp +++ b/src/CRE/pv_expression.cpp @@ -26,7 +26,7 @@ struct pv_expression_file { struct pv_expression { rob_chara* rob_chr; - int32_t motion_id; + uint32_t motion_id; pv_exp_data* face_data; pv_exp_data* face_data_curr; pv_exp_data* face_data_prev; @@ -47,8 +47,8 @@ struct pv_expression { void face_set_frame(float_t frame); void reset(); void reset_data(); - bool set_motion(const char* path, int32_t motion_id); - bool set_motion(uint32_t hash, int32_t motion_id); + bool set_motion(const char* path, uint32_t motion_id); + bool set_motion(uint32_t hash, uint32_t motion_id); }; pv_expression pv_expression_array[ROB_CHARA_COUNT]; @@ -111,13 +111,13 @@ bool pv_expression_array_set(size_t chara_id, void* rob_chr, float_t frame_speed return true; } -bool pv_expression_array_set_motion(const char* path, size_t chara_id, int32_t motion_id) { +bool pv_expression_array_set_motion(const char* path, size_t chara_id, uint32_t motion_id) { if (chara_id >= 0 && chara_id < ROB_CHARA_COUNT) return pv_expression_array[chara_id].set_motion(path, motion_id); return false; } -bool pv_expression_array_set_motion(uint32_t hash, size_t chara_id, int32_t motion_id) { +bool pv_expression_array_set_motion(uint32_t hash, size_t chara_id, uint32_t motion_id) { if (chara_id >= 0 && chara_id < ROB_CHARA_COUNT) return pv_expression_array[chara_id].set_motion(hash, motion_id); return false; @@ -493,14 +493,14 @@ void pv_expression::reset_data() { face_cl_data_update = false; } -bool pv_expression::set_motion(const char* path, int32_t motion_id) { +bool pv_expression::set_motion(const char* path, uint32_t motion_id) { const char* file = strrchr(path, '/'); if (!file) file = strrchr(path, '\\'); return set_motion(hash_utf8_murmurhash(file ? file + 1 : path), motion_id); } -bool pv_expression::set_motion(uint32_t hash, int32_t motion_id) { +bool pv_expression::set_motion(uint32_t hash, uint32_t motion_id) { pv_expression_file* pv_exp_file = 0; for (pv_expression_file*& i : pv_expression_file_storage) if (i && i->hash == hash) { diff --git a/src/CRE/pv_expression.hpp b/src/CRE/pv_expression.hpp index 99c43581..51eebce3 100644 --- a/src/CRE/pv_expression.hpp +++ b/src/CRE/pv_expression.hpp @@ -14,8 +14,8 @@ extern void pv_expression_array_reset(); extern void pv_expression_array_reset_data(); extern void pv_expression_array_reset_motion(size_t chara_id); extern bool pv_expression_array_set(size_t chara_id, void* rob_chr, float_t frame_speed); -extern bool pv_expression_array_set_motion(const char* path, size_t chara_id, int32_t motion_id); -extern bool pv_expression_array_set_motion(uint32_t hash, size_t chara_id, int32_t motion_id); +extern bool pv_expression_array_set_motion(const char* path, size_t chara_id, uint32_t motion_id); +extern bool pv_expression_array_set_motion(uint32_t hash, size_t chara_id, uint32_t motion_id); extern bool pv_expression_file_check_not_ready(const char* path); extern bool pv_expression_file_check_not_ready(uint32_t hash); diff --git a/src/CRE/rob/ex_block.cpp b/src/CRE/rob/ex_block.cpp index b3731b9a..146e2d50 100644 --- a/src/CRE/rob/ex_block.cpp +++ b/src/CRE/rob/ex_block.cpp @@ -900,7 +900,7 @@ void RobCloth::ResetData() { reset_data_list = 0; } -void RobCloth::AddMotionResetData(int32_t motion_id, float_t frame) { +void RobCloth::AddMotionResetData(uint32_t motion_id, float_t frame) { int32_t frame_int = (int32_t)roundf(frame * 1000.0f); auto elem = motion_reset_data.find({ motion_id, frame_int }); @@ -1153,7 +1153,7 @@ void RobCloth::SetForceAirRes(float_t force, float_t force_gain, float_t air_res skin_param_ptr->air_res = air_res; } -void RobCloth::SetMotionResetData(int32_t motion_id, float_t frame) { +void RobCloth::SetMotionResetData(uint32_t motion_id, float_t frame) { osage_reset = true; auto elem = motion_reset_data.find({ motion_id, (int32_t)roundf(frame * 1000.0f) }); if (elem != motion_reset_data.end() && elem->second.size() + root_count == nodes.size()) { @@ -1521,7 +1521,7 @@ void ExClothBlock::Field_50() { sub_14021D840(&rob); } -void ExClothBlock::AddMotionResetData(int32_t motion_id, float_t frame) { +void ExClothBlock::AddMotionResetData(uint32_t motion_id, float_t frame) { rob.AddMotionResetData(motion_id, frame); } @@ -1548,7 +1548,7 @@ float_t* ExClothBlock::LoadOpdData(size_t node_index, float_t* opd_data, size_t return rob.LoadOpdData(node_index, opd_data, opd_count); } -void ExClothBlock::SetMotionResetData(int32_t motion_id, float_t frame) { +void ExClothBlock::SetMotionResetData(uint32_t motion_id, float_t frame) { rob.SetMotionResetData(motion_id, frame); } @@ -1585,7 +1585,7 @@ RobOsage::~RobOsage() { } -void RobOsage::AddMotionResetData(int32_t motion_id, float_t frame) { +void RobOsage::AddMotionResetData(uint32_t motion_id, float_t frame) { int32_t frame_int = (int32_t)roundf(frame * 1000.0f); auto elem = motion_reset_data.find({ motion_id, frame_int }); @@ -1830,7 +1830,7 @@ void RobOsage::SetInitRot(float_t init_rot_y, float_t init_rot_z) { skin_param_ptr->init_rot.z = init_rot_z * DEG_TO_RAD_FLOAT; } -void RobOsage::SetMotionResetData(int32_t motion_id, float_t frame) { +void RobOsage::SetMotionResetData(uint32_t motion_id, float_t frame) { osage_reset = true; auto v6 = motion_reset_data.find({ motion_id, (int32_t)roundf(frame * 1000.0f) }); if (v6 != motion_reset_data.end() && v6->second.size() + 1 == nodes.size()) @@ -2172,7 +2172,7 @@ void ExOsageBlock::Field_58() { field_59 = false; } -void ExOsageBlock::AddMotionResetData(int32_t motion_id, float_t frame) { +void ExOsageBlock::AddMotionResetData(uint32_t motion_id, float_t frame) { rob.AddMotionResetData(motion_id, frame); } @@ -2190,7 +2190,7 @@ float_t* ExOsageBlock::LoadOpdData(size_t node_index, float_t* opd_data, size_t return rob.LoadOpdData(node_index, opd_data, opd_count); } -void ExOsageBlock::SetMotionResetData(int32_t motion_id, float_t frame) { +void ExOsageBlock::SetMotionResetData(uint32_t motion_id, float_t frame) { rob.SetMotionResetData(motion_id, frame); } @@ -2223,21 +2223,21 @@ void ExOsageBlock::SetWindDirection() { } void ExOsageBlock::sub_1405F3E10(obj_skin_block_osage* osg_data, - obj_skin_osage_node* osg_nodes, std::vector>* a4, + obj_skin_osage_node* osg_nodes, prj::vector_pair* a4, std::map* a5) { RobOsageNode* node = rob.GetNode(0); - a4->push_back({ osg_data->external_name_index, node }); + a4->push_back(osg_data->external_name_index, node); for (uint32_t i = 0; i < osg_data->count; i++) { node = rob.GetNode(i + 1ULL); - a4->push_back({ osg_nodes[i].name_index, node }); + a4->push_back(osg_nodes[i].name_index, node); if (node->bone_node_ptr && node->bone_node_ptr->name) a5->insert({ node->bone_node_ptr->name, this }); } node = rob.GetNode(osg_data->count + 1ULL); - a4->push_back({ osg_data->name_index, node }); + a4->push_back(osg_data->name_index, node); if (node->bone_node_ptr && node->bone_node_ptr->name) a5->insert({ node->bone_node_ptr->name, this }); diff --git a/src/CRE/rob/rob.cpp b/src/CRE/rob/rob.cpp index 7b023e4d..fadd67c6 100644 --- a/src/CRE/rob/rob.cpp +++ b/src/CRE/rob/rob.cpp @@ -59,8 +59,8 @@ struct OpdMaker { ~Data(); bool CheckOpdiFilesNotReady(); - const void* GetOpdiFileData(object_info obj_info, int32_t motion_id); - bool IsValidOpdiFile(rob_chara* rob_chr, int32_t motion_id); + const void* GetOpdiFileData(object_info obj_info, uint32_t motion_id); + bool IsValidOpdiFile(rob_chara* rob_chr, uint32_t motion_id); void Reset(); }; @@ -82,7 +82,7 @@ struct OpdMaker { bool InitThread(rob_chara* rob_chr, std::vector* motion_ids, OpdMaker::Data* data); bool IsWaiting(); void Reset(); - bool SetOsagePlayInitData(int32_t motion_id); + bool SetOsagePlayInitData(uint32_t motion_id); void SetWaiting(bool value); void sub_140475AE0(); @@ -179,7 +179,7 @@ struct struc_528 { struct struc_527 { rob_chara* rob_chr; - int32_t motion_id; + uint32_t motion_id; float_t frame; float_t last_frame; struc_528* type_62; @@ -467,13 +467,13 @@ struct rob_sleeve_handler { }; struct osage_set_motion { - int32_t motion_id; - std::vector> frames; + uint32_t motion_id; + prj::vector_pair frames; osage_set_motion(); ~osage_set_motion(); - void init_frame(int32_t motion_id, float_t frame, int32_t stage_index); + void init_frame(uint32_t motion_id, float_t frame, int32_t stage_index); }; struct skeleton_rotation_offset { @@ -516,8 +516,8 @@ public: virtual bool Dest() override; virtual void Disp() override; - void AddMotionFrameResetData(int32_t stage_index, int32_t motion_id, float_t frame, int32_t iterations); - bool CheckResetFrameNotFound(int32_t motion_id, float_t frame); + void AddMotionFrameResetData(int32_t stage_index, uint32_t motion_id, float_t frame, int32_t iterations); + bool CheckResetFrameNotFound(uint32_t motion_id, float_t frame); bool GetDisp(); bool GetNotReset(); void Reset(); @@ -531,7 +531,7 @@ public: void sub_1404F7BD0(bool not_reset); void sub_1404F82F0(); void sub_1404F83A0(::osage_set_motion* a2); - void sub_1404F88A0(uint32_t stage_index, int32_t motion_id, float_t frame); + void sub_1404F88A0(uint32_t stage_index, uint32_t motion_id, float_t frame); void sub_1404F8AA0(); static void ThreadMain(PvOsageManager* pv_osg_mgr); @@ -777,6 +777,7 @@ public: bool CheckHasRobCharaLoad(rob_chara* rob_chr); void CheckTypeAppendInitCharaLists(std::list* rob_chr_list); void FreeLoadedCharaList(int8_t* chara_id); + bool GetWait(rob_chara* rob_chr); }; struct rob_manager_rob_impl { @@ -802,7 +803,7 @@ static void bone_data_parent_load_rob_chara(bone_data_parent* bone); static void mot_blend_interpolate(mot_blend* a1, std::vector* bones, std::vector* bone_indices, bone_database_skeleton_type skeleton_type); -static void mot_blend_load_motion(mot_blend* a1, int32_t motion_id, const motion_database* mot_db); +static void mot_blend_load_motion(mot_blend* a1, uint32_t motion_id, const motion_database* mot_db); static void mot_blend_set_blend_duration(mot_blend* a1, float_t duration, float_t step, float_t offset); static void mot_blend_set_frame(mot_blend* a1, float_t frame); @@ -818,7 +819,7 @@ static void mot_key_data_init_key_sets(mot_key_data* a1, bone_database_skeleton_ size_t motion_bone_count, size_t ik_bone_count); static void mot_key_data_interpolate(mot_key_data* a1, float_t frame, uint32_t key_set_offset, uint32_t key_set_count); -static const mot_data* mot_key_data_load_file(mot_key_data* a1, int32_t motion_id, const motion_database* mot_db); +static const mot_data* mot_key_data_load_file(mot_key_data* a1, uint32_t motion_id, const motion_database* mot_db); static void mot_key_data_reserve_key_sets(mot_key_data* a1); static void mothead_func_0(mothead_func_data* func_data, @@ -990,7 +991,7 @@ static void motion_blend_mot_interpolate(motion_blend_mot* a1); static void motion_blend_mot_load_bone_data(motion_blend_mot* a1, rob_chara_bone_data* a2, PFNMOTIONBONECHECKFUNC bone_check_func, const bone_database* bone_data); static bool motion_blend_mot_interpolate_get_reverse(int32_t* a1); -static void motion_blend_mot_load_file(motion_blend_mot* a1, int32_t motion_id, +static void motion_blend_mot_load_file(motion_blend_mot* a1, uint32_t motion_id, MotionBlendType blend_type, float_t blend, const bone_database* bone_data, const motion_database* mot_db); static void motion_blend_mot_mult_mat(motion_blend_mot* a1, mat4* mat); static void motion_blend_mot_set_blend(motion_blend_mot* a1, @@ -1015,8 +1016,6 @@ static void rob_disp_rob_chara_ctrl_thread_main(rob_chara* rob_chr); static void rob_disp_rob_chara_disp(rob_chara* rob_chr); static void rob_disp_rob_chara_free(rob_chara* rob_chr); -static void rob_motion_modifier_rob_chara_ctrl(rob_chara* rob_chr); - static void rob_chara_age_age_ctrl(rob_chara_age_age* arr, int32_t chara_id, int32_t part_id, mat4& mat); static void rob_chara_age_age_disp(rob_chara_age_age* arr, @@ -1059,26 +1058,13 @@ static void rob_chara_bone_data_init_data(rob_chara_bone_data* rob_bone_data, static void rob_chara_bone_data_init_skeleton(rob_chara_bone_data* rob_bone_data, bone_database_skeleton_type base_skeleton_type, bone_database_skeleton_type skeleton_type, const bone_database* bone_data); -static void rob_chara_bone_data_interpolate(rob_chara_bone_data* rob_bone_data); -static void rob_chara_bone_data_load_eyelid_motion(rob_chara_bone_data* rob_bone_data, - int32_t motion_id, const motion_database* mot_db); -static void rob_chara_bone_data_load_eyes_motion(rob_chara_bone_data* rob_bone_data, - int32_t motion_id, const motion_database* mot_db); -static void rob_chara_bone_data_load_face_motion(rob_chara_bone_data* rob_bone_data, - int32_t motion_id, const motion_database* mot_db); -static void rob_chara_bone_data_load_hand_l_motion(rob_chara_bone_data* rob_bone_data, - int32_t motion_id, const motion_database* mot_db); -static void rob_chara_bone_data_load_hand_r_motion(rob_chara_bone_data* rob_bone_data, - int32_t motion_id, const motion_database* mot_db); -static void rob_chara_bone_data_load_mouth_motion(rob_chara_bone_data* rob_bone_data, - int32_t motion_id, const motion_database* mot_db); static void rob_chara_bone_data_motion_blend_mot_free(rob_chara_bone_data* rob_bone_data); static void rob_chara_bone_data_motion_blend_mot_init(rob_chara_bone_data* rob_bone_data); static void rob_chara_bone_data_motion_blend_mot_list_free(rob_chara_bone_data* rob_bone_data, size_t last_index); static void rob_chara_bone_data_motion_blend_mot_list_init(rob_chara_bone_data* rob_bone_data); static void rob_chara_bone_data_motion_load(rob_chara_bone_data* rob_bone_data, - int32_t motion_id, MotionBlendType blend_type, const bone_database* bone_data, const motion_database* mot_db); + uint32_t motion_id, MotionBlendType blend_type, const bone_database* bone_data, const motion_database* mot_db); static void rob_chara_bone_data_reserve(rob_chara_bone_data* rob_bone_data); static void rob_chara_bone_data_set_eyelid_anim_blend_duration(rob_chara_bone_data* rob_bone_data, float_t duration, float_t step, float_t offset); @@ -1112,7 +1098,6 @@ static void rob_chara_bone_data_set_parent_mats(rob_chara_bone_data* rob_bone_da const uint16_t* parent_indices); static void rob_chara_bone_data_set_rot_y(rob_chara_bone_data* rob_bone_data, float_t rot_y); static void rob_chara_bone_data_set_step(rob_chara_bone_data* rob_bone_data, float_t step); -static void rob_chara_bone_data_update(rob_chara_bone_data* rob_bone_data, mat4* mat); static void rob_chara_age_age_ctrl(rob_chara* rob_chr, int32_t part_id, const char* name); static object_info rob_chara_get_head_object(rob_chara* rob_chr, int32_t head_object_id); @@ -1120,7 +1105,7 @@ static object_info rob_chara_get_object_info(rob_chara* rob_chr, item_id id); static void rob_chara_load_default_motion(rob_chara* rob_chr, const bone_database* bone_data, const motion_database* mot_db); static void rob_chara_load_default_motion_sub(rob_chara* rob_chr, int32_t skeleton_select, - int32_t motion_id, const bone_database* bone_data, const motion_database* mot_db); + uint32_t motion_id, const bone_database* bone_data, const motion_database* mot_db); static void rob_chara_set_adjust(rob_chara* rob_chr, rob_chara_data_adjust* adjust_new, rob_chara_data_adjust* adjust, rob_chara_data_adjust* adjust_prev); @@ -2330,7 +2315,7 @@ bool osage_play_data_manager_check_task_ready() { } void osage_play_data_manager_get_opd_file_data(object_info obj_info, - int32_t motion_id, float_t*& data, uint32_t& count) { + uint32_t motion_id, float_t*& data, uint32_t& count) { osage_play_data_manager->GetOpdFileData(obj_info, motion_id, data, count); } @@ -2531,59 +2516,231 @@ mat4* rob_chara_bone_data_get_mats_mat(rob_chara_bone_data* rob_bone_data, size_ return 0; } -static void sub_140509D30(rob_chara* rob_chr) { - struc_195* v39 = rob_chr->data.field_1E68.field_DF8; - struc_195* v40 = rob_chr->data.field_1E68.field_1230; - struc_195* v41 = rob_chr->data.field_1E68.field_1668; - mat4* v42 = rob_chr->data.field_1E68.field_78; - mat4* v43 = rob_chr->data.field_1E68.field_738; +static void rob_chara_data_adjust_ctrl(rob_chara* rob_chr, + rob_chara_data_adjust* adjust, rob_chara_data_adjust* adjust_prev) { + float_t cycle = adjust->cycle; + float_t v7 = 0.0f; + adjust->frame += rob_chr->data.motion.step_data.frame; + if (rob_chr->data.field_1588.field_0.field_58 == 1) + cycle *= (60.0f / rob_chr->data.field_1588.field_0.frame); + cycle *= adjust->frame * 2.0f * (float_t)M_PI * (float_t)(1.0 / 60.0f); - const struc_218* v3 = rob_chr->chara_init_data->field_828; - const struc_218* v6 = rob_chr->chara_init_data->field_830; - mat4* m; - mat4 mat; - for (int32_t i = 0; i < 27; i++) { - m = rob_chara_bone_data_get_mats_mat(rob_chr->bone_data, v3->bone_index); - mat4_translate_mult(m, &v3->bone_offset, &mat); - *v42 = mat; - - m = rob_chara_bone_data_get_mats_mat(rob_chr->bone_data, v6->bone_index); - mat4_translate_mult(m, &v3->bone_offset, &mat); - *v43 = mat; - - float_t chara_scale = rob_chr->data.adjust_data.scale; - - vec3 v23 = *(vec3*)&v42->row3 * chara_scale + rob_chr->data.adjust_data.trans; - *(vec3*)&v42->row3 = v23; - - vec3 v29 = *(vec3*)&v43->row3 * chara_scale + rob_chr->data.adjust_data.trans; - *(vec3*)&v43->row3 = v29; - - float_t v20 = v3->scale * chara_scale; - v39->scale = v20; - v39->field_24 = v20; - v39->prev_trans = v39->trans; - v39->trans = v23; - - float_t v19 = v6->scale * chara_scale; - v40->scale = v19; - v40->field_24 = v19; - v40->prev_trans = v40->trans; - v40->trans = v29; - - v41->scale = v19; - v41->field_24 = v19; - v41->prev_trans = v41->trans; - v41->trans = v29; - - v39++; - v40++; - v41++; - v42++; - v43++; - v3++; - v6++; + switch (adjust->cycle_type) { + case 1: + v7 = cosf(adjust->phase * (float_t)M_PI + cycle); + break; + case 2: + v7 = sinf(adjust->phase * (float_t)M_PI + cycle); + break; } + + adjust->curr_external_force = (adjust->external_force_cycle + v7) + * (adjust->external_force * adjust->external_force_cycle_strength) + adjust->external_force; + + if (adjust->type == 1) { + mat4 mat = mat4_identity; + mat4_rotate_y_mult(&mat, (float_t)((double_t)rob_chr->data.miku_rot.rot_y_int16 + * M_PI * (1.0 / 32768.0)), &mat); + mat4_mult_vec3(&mat, &adjust->curr_external_force, &adjust->curr_external_force); + } + else if (adjust->type == 2) { + mat4* mat = rob_chara_bone_data_get_node(rob_chr->bone_data, 9)->ex_data_mat; + if (mat) + mat4_mult_vec3(mat, &adjust->curr_external_force, &adjust->curr_external_force); + } + else if (adjust->type == 3) { + mat4* mat = rob_chara_bone_data_get_node(rob_chr->bone_data, 10)->ex_data_mat; + if (mat) + mat4_mult_vec3(mat, &adjust->curr_external_force, &adjust->curr_external_force); + } + else if (adjust->type == 4) { + mat4* mat = rob_chara_bone_data_get_node(rob_chr->bone_data, 15)->ex_data_mat; + if (mat) + mat4_mult_vec3(mat, &adjust->curr_external_force, &adjust->curr_external_force); + } + else if (adjust->type == 5) { + mat4* mat = rob_chara_bone_data_get_node(rob_chr->bone_data, 177)->ex_data_mat; + if (mat) { + adjust->curr_external_force.z = -adjust->curr_external_force.z; + mat4_mult_vec3(mat, &adjust->curr_external_force, &adjust->curr_external_force); + } + } + + if (adjust->ignore_gravity) + adjust->curr_external_force.y = get_osage_gravity_const() + adjust->curr_external_force.y; + + adjust->curr_force = adjust->force; + adjust->curr_strength = adjust->strength; + + bool transition_frame_step = false; + if (adjust->transition_duration > adjust->transition_frame + && fabsf(adjust->transition_duration - adjust->transition_frame) > 0.000001f) { + transition_frame_step = true; + float_t blend = (adjust->transition_frame + 1.0f) / (adjust->transition_duration + 1.0f); + adjust->curr_external_force = vec3::lerp(adjust_prev->curr_external_force, + adjust->curr_external_force, blend); + adjust->curr_force = lerp_def(adjust_prev->curr_force, adjust->curr_force, blend); + } + + if (adjust->strength_transition > adjust->transition_frame + && fabsf(adjust->strength_transition - adjust->transition_frame) > 0.000001f) { + float_t blend = (adjust->transition_frame + 1.0f) / (adjust->strength_transition + 1.0f); + adjust->curr_strength = lerp_def(adjust_prev->curr_strength, adjust->curr_strength, blend); + } + else if (!transition_frame_step) + return; + + adjust->transition_frame += rob_chr->data.motion.step_data.frame; +} + +static void rob_chara_item_equip_object_set_parts_external_force( + rob_chara_item_equip_object* itm_eq_obj, rob_osage_parts_bit parts_bits, + vec3* weight, float_t force, float_t strength) { + for (ExOsageBlock*& i : itm_eq_obj->osage_blocks) { + RobOsage* rob_osg = &i->rob; + if (rob_osg->CheckPartsBits(parts_bits)) { + rob_osg->SetNodesExternalForce(weight, strength); + rob_osg->SetNodesForce(force); + } + } +} + +static void rob_chara_item_equip_set_parts_external_force(rob_chara_item_equip* rob_itm_eq, + int32_t parts, vec3* external_force, float_t force, float_t strength) { + item_id id = (item_id)(parts == ROB_OSAGE_PARTS_MUFFLER ? ITEM_OUTER : ITEM_KAMI); + if (!osage_setting_data_obj_has_key(rob_itm_eq->item_equip_object[id].obj_info)) + return; + + switch (parts) { + case ROB_OSAGE_PARTS_SHORT_L: + case ROB_OSAGE_PARTS_SHORT_R: + rob_itm_eq->parts_short = true; + break; + case ROB_OSAGE_PARTS_APPEND_L: + case ROB_OSAGE_PARTS_APPEND_R: + rob_itm_eq->parts_append = true; + break; + case ROB_OSAGE_PARTS_WHITE_ONE_L: + rob_itm_eq->parts_white_one_l = true; + break; + } + + rob_osage_parts_bit parts_bits = (rob_osage_parts_bit)(1 << parts); + if (!rob_itm_eq->parts_short) { + if (parts == ROB_OSAGE_PARTS_LEFT) + enum_or(parts_bits, ROB_OSAGE_PARTS_SHORT_L_BIT); + else if (parts == ROB_OSAGE_PARTS_RIGHT) + enum_or(parts_bits, ROB_OSAGE_PARTS_SHORT_R_BIT); + } + + if (!rob_itm_eq->parts_append) { + if (parts == ROB_OSAGE_PARTS_LEFT) + enum_or(parts_bits, ROB_OSAGE_PARTS_APPEND_L_BIT); + else if (parts == ROB_OSAGE_PARTS_RIGHT) + enum_or(parts_bits, ROB_OSAGE_PARTS_APPEND_R_BIT); + } + + if (!rob_itm_eq->parts_white_one_l && parts == ROB_OSAGE_PARTS_LONG_C) + enum_or(parts_bits, ROB_OSAGE_PARTS_WHITE_ONE_L_BIT); + + rob_chara_item_equip_object_set_parts_external_force( + &rob_itm_eq->item_equip_object[id], parts_bits, external_force, force, strength); +} + +static void rob_chara_item_equip_object_set_external_force( + rob_chara_item_equip_object* itm_eq_obj, vec3* external_force) { + for (ExOsageBlock*& i : itm_eq_obj->osage_blocks) { + i->rob.set_external_force = true; + i->rob.external_force = *external_force; + } + + for (ExClothBlock*& i : itm_eq_obj->cloth_blocks) { + i->rob.set_external_force = true; + i->rob.external_force = *external_force; + } +} + +static void rob_chara_item_equip_set_external_force( + rob_chara_item_equip* rob_itm_eq, vec3* external_force) { + for (int32_t i = rob_itm_eq->first_item_equip_object; i < rob_itm_eq->max_item_equip_object; i++) + rob_chara_item_equip_object_set_external_force(&rob_itm_eq->item_equip_object[i], external_force); +} + +void rob_chara::adjust_ctrl() { + rob_chara_item_equip* rob_itm_equip = item_equip; + + for (int32_t i = 0; i < ROB_OSAGE_PARTS_MAX; i++) { + rob_chara_data_adjust* parts_adjust = &data.motion.parts_adjust[i]; + if (parts_adjust->enable) { + rob_chara_data_adjust_ctrl(this, parts_adjust, &data.motion.parts_adjust_prev[i]); + rob_chara_item_equip_set_parts_external_force(rob_itm_equip, i, + &parts_adjust->curr_external_force, parts_adjust->curr_force, parts_adjust->curr_strength); + } + } + + rob_chara_data_adjust* adjust_global = &data.motion.adjust_global; + if (adjust_global->enable) { + rob_chara_data_adjust_ctrl(this, adjust_global, &data.motion.adjust_global_prev); + rob_chara_item_equip_set_external_force(rob_itm_equip, &adjust_global->curr_external_force); + } + + rob_itm_equip->parts_short = false; + rob_itm_equip->parts_append = false; + rob_itm_equip->parts_white_one_l = false; +} + +static motion_bone_index rob_motion_c_kata_bone_get(int32_t index) { + if (index == 0) + return MOTION_BONE_C_KATA_L; + else if (index == 1) + return MOTION_BONE_C_KATA_R; + else + return MOTION_BONE_NONE; +} + +static void rob_chara_bone_data_set_motion_arm_length(rob_chara_bone_data* rob_bone_data, + motion_bone_index motion_bone_index, float_t value) { + motion_blend_mot* v3 = rob_bone_data->motion_loaded.front(); + v3->bone_data.bones.data()[motion_bone_index].arm_length = value; +} + +static void rob_chara_data_arm_adjust_ctrl(rob_chara* rob_chr, int32_t index, rob_chara_data_arm_adjust* arm_adjust) { + if (!arm_adjust->enable) + return; + + float_t prev_value = arm_adjust->prev_value; + float_t next_value = arm_adjust->next_value; + float_t duration = arm_adjust->duration; + float_t frame = arm_adjust->frame; + if (duration <= frame || fabsf(duration - frame) <= 0.000001f) { + arm_adjust->enable = false; + arm_adjust->value = next_value; + return; + } + + float_t blend = (frame + 1.0f) / (duration + 1.0f); + float_t inv_blend = 1.0f - blend; + if (prev_value <= 0.0001f || prev_value >= 1.0f) { + if (next_value != 0.0f) + arm_adjust->value = next_value * blend + inv_blend; + else + arm_adjust->value = 0.0f; + } + else { + if (next_value != 0.0f) + arm_adjust->value = next_value * blend + prev_value * inv_blend; + else + arm_adjust->value = blend + prev_value * inv_blend; + } + arm_adjust->frame += rob_chr->data.motion.step_data.frame; + + rob_chara_bone_data_set_motion_arm_length(rob_chr->bone_data, + rob_motion_c_kata_bone_get(index), arm_adjust->value); +} + +void rob_chara::arm_adjust_ctrl() { + for (int32_t i = 0; i < 2; i++) + rob_chara_data_arm_adjust_ctrl(this, i, &data.motion.arm_adjust[i]); } void rob_chara::autoblink_disable() { @@ -2616,7 +2773,7 @@ float_t rob_chara::get_max_face_depth() { return item_cos_data.get_max_face_depth(); } -int32_t rob_chara::get_rob_cmn_mottbl_motion_id(int32_t id) { +uint32_t rob_chara::get_rob_cmn_mottbl_motion_id(int32_t id) { if (id >= 0xD6 && id <= 0xDF) return pv_data.motion_face_ids[id - 0xD6]; else if (id == 0xE0) @@ -2632,9 +2789,9 @@ int32_t rob_chara::get_rob_cmn_mottbl_motion_id(int32_t id) { rob_cmn_mottbl_sub_header* v4 = (rob_cmn_mottbl_sub_header*)((uint8_t*)rob_cmn_mottbl_data + rob_cmn_mottbl_data->subheaders_offset); if (v2 >= 0 && v2 < v4[chara_index].field_4) - return ((int32_t*)((uint8_t*)rob_cmn_mottbl_data - + *(int32_t*)((uint8_t*)rob_cmn_mottbl_data - + v2 * sizeof(int32_t) + v4[chara_index].data_offset)))[id]; + return ((uint32_t*)((uint8_t*)rob_cmn_mottbl_data + + *(uint32_t*)((uint8_t*)rob_cmn_mottbl_data + + v2 * sizeof(uint32_t) + v4[chara_index].data_offset)))[id]; } return -1; } @@ -2663,21 +2820,6 @@ static int16_t sub_14054FE90(rob_chara* rob_chr, bool a3) { return v3; } -static motion_bone_index rob_motion_c_kata_bone_get(int32_t index) { - if (index == 0) - return MOTION_BONE_C_KATA_L; - else if (index == 1) - return MOTION_BONE_C_KATA_R; - else - return MOTION_BONE_NONE; -} - -static void rob_chara_bone_data_set_motion_arm_length(rob_chara_bone_data* rob_bone_data, - motion_bone_index motion_bone_index, float_t value) { - motion_blend_mot* v3 = rob_bone_data->motion_loaded.front(); - v3->bone_data.bones.data()[motion_bone_index].arm_length = value; -} - static void sub_1405F9520(rob_chara_item_equip_object* itm_eq_obj, rob_osage_parts_bit a2, bool a3) { for (ExOsageBlock*& i : itm_eq_obj->osage_blocks) if (i->rob.CheckPartsBits(a2)) @@ -3080,7 +3222,7 @@ static void sub_14053A9C0(struc_223* a1, rob_chara* rob_chr, if (a1->field_0.field_20.field_0 & 0x200000) a1->field_0.field_20.field_0 |= 0x100; - if (a1->field_0.field_20.field_C & 0x20000 && !(rob_chr->data.field_3D9D & 0x04)) + if (a1->field_0.field_20.field_C & 0x20000 && !(rob_chr->data.field_3D9C & 0x400)) a1->field_0.field_20.field_C |= 0x400; a1->field_0.field_C = 0; @@ -3119,7 +3261,7 @@ void rob_chara::load_body_parts_object_info(item_id item_id, object_info obj_inf item_equip->load_body_parts_object_info(item_id, obj_info, bone_data, data, obj_db); } -void rob_chara::load_motion(int32_t motion_id, bool a3, float_t frame, +void rob_chara::load_motion(uint32_t motion_id, bool a3, float_t frame, MotionBlendType blend_type, const bone_database* bone_data, const motion_database* mot_db) { data.miku_rot.rot_y_int16 = sub_14054FE90(this, false); if (!(data.field_1588.field_0.field_20.field_0 & 0x10)) { @@ -3233,6 +3375,99 @@ void rob_chara::load_outfit_object_info(item_id id, object_info obj_info, item_equip->load_outfit_object_info(id, obj_info, osage_reset, bone_data, data, obj_db); } +static void sub_14053BEE0(rob_chara* rob_chr); +static bool rob_chara_hands_adjust(rob_chara* rob_chr); +static bool sub_14053B580(rob_chara* rob_chr, int32_t a2); +static void sub_14053B260(rob_chara* rob_chr); + +static bool sub_14053B530(rob_chara* rob_chr) { + return sub_14053B580(rob_chr, 2) | sub_14053B580(rob_chr, 3); +} + +static void rob_chara_bone_data_set_left_hand_scale(rob_chara_bone_data* rob_bone_data, float_t scale) { + mat4* kl_te_wj_mat = rob_chara_bone_data_get_mats_mat(rob_bone_data, ROB_BONE_KL_TE_L_WJ); + if (!kl_te_wj_mat) + return; + + vec3 trans; + mat4_get_translation(kl_te_wj_mat, &trans); + trans -= trans * scale; + + mat4 mat; + mat4_scale(scale, scale, scale, &mat); + mat4_set_translation(&mat, &trans); + + for (int32_t i = ROB_BONE_KL_TE_L_WJ; i <= ROB_BONE_NL_OYA_C_L_WJ; i++) { + mat4* m = rob_chara_bone_data_get_mats_mat(rob_bone_data, i); + if (m) + mat4_mult(m, &mat, m); + } + + for (int32_t i = MOT_BONE_KL_TE_L_WJ; i <= MOT_BONE_NL_OYA_C_L_WJ; i++) { + bone_node* node = rob_chara_bone_data_get_node(rob_bone_data, i); + if (node) + node->exp_data.scale = { scale, scale, scale }; + } +} + +static void rob_chara_bone_data_set_right_hand_scale(rob_chara_bone_data* rob_bone_data, float_t scale) { + mat4* kl_te_wj_mat = rob_chara_bone_data_get_mats_mat(rob_bone_data, ROB_BONE_KL_TE_R_WJ); + if (!kl_te_wj_mat) + return; + + vec3 trans; + mat4_get_translation(kl_te_wj_mat, &trans); + trans -= trans * scale; + + mat4 mat; + mat4_scale(scale, scale, scale, &mat); + mat4_set_translation(&mat, &trans); + + for (int32_t i = ROB_BONE_KL_TE_R_WJ; i <= ROB_BONE_NL_OYA_C_R_WJ; i++) { + mat4* m = rob_chara_bone_data_get_mats_mat(rob_bone_data, i); + if (m) + mat4_mult(m, &mat, m); + } + + for (int32_t i = MOT_BONE_KL_TE_R_WJ; i <= MOT_BONE_NL_OYA_C_R_WJ; i++) { + bone_node* node = rob_chara_bone_data_get_node(rob_bone_data, i); + if (node) + node->exp_data.scale = { scale, scale, scale }; + } +} + +void rob_chara::rob_motion_modifier_ctrl() { + sub_14053BEE0(this); + rob_chara_hands_adjust(this); + if (!sub_14053B530(this)) + sub_14053B260(this); + + float_t left_hand_scale_default = data.adjust_data.left_hand_scale_default; + float_t right_hand_scale_default = data.adjust_data.right_hand_scale_default; + float_t left_hand_scale = data.adjust_data.left_hand_scale; + float_t right_hand_scale = data.adjust_data.right_hand_scale; + + if (left_hand_scale_default > 0.0f) { + if (left_hand_scale <= 0.0f) + left_hand_scale = data.adjust_data.left_hand_scale_default; + else + left_hand_scale *= left_hand_scale_default; + } + + if (right_hand_scale_default > 0.0f) { + if (right_hand_scale <= 0.0f) + right_hand_scale = data.adjust_data.right_hand_scale_default; + else + right_hand_scale *= right_hand_scale_default; + } + + if (left_hand_scale > 0.0f) + rob_chara_bone_data_set_left_hand_scale(this->bone_data, left_hand_scale); + + if (right_hand_scale > 0.0f) + rob_chara_bone_data_set_right_hand_scale(this->bone_data, right_hand_scale); +} + static void sub_140514130(rob_chara_item_equip* rob_itm_equip, item_id id, bool a3) { if (a3) rob_itm_equip->field_18[id] &= ~0x01; @@ -3318,8 +3553,8 @@ void rob_chara::reset_osage() { void rob_chara::set_bone_data_frame(float_t frame) { bone_data->set_frame(frame); - rob_chara_bone_data_interpolate(bone_data); - rob_chara_bone_data_update(bone_data, 0); + bone_data->interpolate(); + bone_data->update(0); } void rob_chara::set_chara_color(bool value) { @@ -3362,7 +3597,7 @@ static void rob_chara_set_eyelid_motion(rob_chara* rob_chr, return; } - rob_chara_bone_data_load_eyelid_motion(rob_chr->bone_data, motion->data.motion_id, mot_db); + rob_chr->bone_data->load_eyelid_motion(motion->data.motion_id, mot_db); rob_chara_bone_data_set_eyelid_frame(rob_chr->bone_data, motion->data.frame); rob_chara_bone_data_set_eyelid_play_frame_step(rob_chr->bone_data, motion->data.play_frame_step); rob_chara_bone_data_set_eyelid_anim_blend_duration(rob_chr->bone_data, @@ -3382,7 +3617,7 @@ static void rob_chara_set_eyes_motion(rob_chara* rob_chr, return; } - rob_chara_bone_data_load_eyes_motion(rob_chr->bone_data, motion->data.motion_id, mot_db); + rob_chr->bone_data->load_eyes_motion(motion->data.motion_id, mot_db); rob_chara_bone_data_set_eyes_frame(rob_chr->bone_data, motion->data.frame); rob_chara_bone_data_set_eyes_play_frame_step(rob_chr->bone_data, motion->data.play_frame_step); rob_chara_bone_data_set_eyes_anim_blend_duration(rob_chr->bone_data, @@ -3402,7 +3637,7 @@ static void rob_chara_set_face_motion(rob_chara* rob_chr, return; } - rob_chara_bone_data_load_face_motion(rob_chr->bone_data, motion->data.motion_id, mot_db); + rob_chr->bone_data->load_face_motion(motion->data.motion_id, mot_db); rob_chara_bone_data_set_face_frame(rob_chr->bone_data, motion->data.frame); rob_chara_bone_data_set_face_play_frame_step(rob_chr->bone_data, motion->data.play_frame_step); rob_chara_bone_data_set_face_anim_blend_duration(rob_chr->bone_data, @@ -3427,7 +3662,7 @@ static void rob_chara_set_hand_l_motion(rob_chara* rob_chr, return; } - rob_chara_bone_data_load_hand_l_motion(rob_chr->bone_data, motion->data.motion_id, mot_db); + rob_chr->bone_data->load_hand_l_motion(motion->data.motion_id, mot_db); rob_chara_bone_data_set_hand_l_frame(rob_chr->bone_data, motion->data.frame); rob_chara_bone_data_set_hand_l_play_frame_step(rob_chr->bone_data, motion->data.play_frame_step); rob_chara_bone_data_set_hand_l_anim_blend_duration(rob_chr->bone_data, @@ -3452,7 +3687,7 @@ static void rob_chara_set_hand_r_motion(rob_chara* rob_chr, return; } - rob_chara_bone_data_load_hand_r_motion(rob_chr->bone_data, motion->data.motion_id, mot_db); + rob_chr->bone_data->load_hand_r_motion(motion->data.motion_id, mot_db); rob_chara_bone_data_set_hand_r_frame(rob_chr->bone_data, motion->data.frame); rob_chara_bone_data_set_hand_r_play_frame_step(rob_chr->bone_data, motion->data.play_frame_step); rob_chara_bone_data_set_hand_r_anim_blend_duration(rob_chr->bone_data, @@ -3472,7 +3707,7 @@ static void rob_chara_set_mouth_motion(rob_chara* rob_chr, return; } - rob_chara_bone_data_load_mouth_motion(rob_chr->bone_data, motion->data.motion_id, mot_db); + rob_chr->bone_data->load_mouth_motion(motion->data.motion_id, mot_db); rob_chara_bone_data_set_mouth_frame(rob_chr->bone_data, motion->data.frame); rob_chara_bone_data_set_mouth_play_frame_step(rob_chr->bone_data, motion->data.play_frame_step); rob_chara_bone_data_set_mouth_anim_blend_duration(rob_chr->bone_data, @@ -3535,6 +3770,73 @@ static void sub_1405500F0(rob_chara* rob_chr) { } } +static vec3* rob_chara_bone_data_get_global_trans(rob_chara_bone_data* rob_bone_data) { + return &rob_bone_data->motion_loaded.front()->bone_data.global_trans; +} + +static void rob_chara_data_adjuct_set_trans(rob_chara_adjust_data* rob_chr_adj, + vec3& trans, bool pos_adjust, vec3* global_trans) { + float_t scale = rob_chr_adj->scale; + float_t item_scale = rob_chr_adj->item_scale; // X + vec3 _offset = rob_chr_adj->offset; + if (global_trans) + _offset.y += global_trans->y; + + vec3 _trans = trans; + vec3 _item_trans = trans; + if (rob_chr_adj->height_adjust) { + _trans.y += rob_chr_adj->pos_adjust_y; + _item_trans.y += rob_chr_adj->pos_adjust_y; // X + } + else { + vec3 temp = (_trans - _offset) * scale + _offset; + vec3 arm_temp = (_item_trans - _offset) * item_scale + _offset; + + if (!rob_chr_adj->offset_x) { + _trans.x = temp.x; + _item_trans.x = arm_temp.x; // X + } + + if (!rob_chr_adj->offset_y) { + _trans.y = temp.y; + _item_trans.y = arm_temp.y; // X + } + + if (!rob_chr_adj->offset_z) { + _trans.z = temp.z; + _item_trans.z = arm_temp.z; // X + } + } + + if (pos_adjust) { + _trans = rob_chr_adj->pos_adjust + _trans; + _item_trans = rob_chr_adj->pos_adjust + _item_trans; //X + } + + rob_chr_adj->trans = _trans - trans * scale; + rob_chr_adj->item_trans = _item_trans - trans * item_scale; // X +} + +void rob_chara::set_data_adjust_mat(rob_chara_adjust_data* rob_chr_adj, bool pos_adjust) { + mat4* mat = rob_chara_bone_data_get_mats_mat(bone_data, ROB_BONE_N_HARA_CP); + + vec3 trans; + mat4_get_translation(mat, &trans); + + vec3* global_trans = 0; + if (rob_chr_adj->get_global_trans) + global_trans = rob_chara_bone_data_get_global_trans(bone_data); + rob_chara_data_adjuct_set_trans(rob_chr_adj, trans, pos_adjust, global_trans); + + float_t scale = rob_chr_adj->scale; + mat4_scale(scale, scale, scale, &rob_chr_adj->mat); + mat4_set_translation(&rob_chr_adj->mat, &rob_chr_adj->trans); + + float_t item_scale = rob_chr_adj->item_scale; // X + mat4_scale(item_scale, item_scale, item_scale, &rob_chr_adj->item_mat); + mat4_set_translation(&rob_chr_adj->item_mat, &rob_chr_adj->item_trans); +} + void rob_chara::set_data_miku_rot_position(vec3& value) { data.miku_rot.position = value; } @@ -3543,6 +3845,34 @@ void rob_chara::set_data_miku_rot_rot_y_int16(int16_t value) { data.miku_rot.rot_y_int16 = value; } +void rob_chara::set_eyelid_mottbl_motion(int32_t type, + int32_t mottbl_index, float_t value, int32_t state, float_t blend_duration, + float_t a7, float_t step, int32_t a9, float_t blend_offset, const motion_database* mot_db) { + RobEyelidMotion motion; + motion.data.motion_id = get_rob_cmn_mottbl_motion_id(mottbl_index); + motion.data.mottbl_index = mottbl_index; + motion.data.state = state; + motion.data.play_frame_step = step; + motion.data.blend_duration = blend_duration; + motion.data.blend_offset = blend_offset; + motion.data.field_24 = a7; + if (sub_14053F290(&motion)) { + motion.data.frame_data = &data.motion.frame_data; + motion.data.step_data = &data.motion.step_data; + } + motion.data.field_38 = a9; + if (motion.data.motion_id != -1) { + motion.data.frame_count = motion_storage_get_mot_data_frame_count(motion.data.motion_id, mot_db); + motion.data.frame = (motion.data.frame_count - 1.0f) * value; + } + + if (!type) { + data.motion.field_29 &= ~2; + data.motion.field_150.time = 0.0f; + } + rob_chara_set_eyelid_motion(this, &motion, type, mot_db); +} + void rob_chara::set_eyelid_mottbl_motion_from_face(int32_t a2, float_t blend_duration, float_t value, float_t blend_offset, const motion_database* mot_db) { if (!a2) @@ -3622,7 +3952,7 @@ void rob_chara::set_eyelid_mottbl_motion_from_face(int32_t a2, break; } - int32_t motion_id = get_rob_cmn_mottbl_motion_id(mottbl_index); + uint32_t motion_id = get_rob_cmn_mottbl_motion_id(mottbl_index); motion.data.motion_id = motion_id; if (motion_id == -1) { blend_duration = 0.0f; @@ -3650,34 +3980,6 @@ void rob_chara::set_eyelid_mottbl_motion_from_face(int32_t a2, rob_chara_set_eyelid_motion(this, &motion, 0, mot_db); } -void rob_chara::set_eyelid_mottbl_motion(int32_t type, - int32_t mottbl_index, float_t value, int32_t state, float_t blend_duration, - float_t a7, float_t step, int32_t a9, float_t blend_offset, const motion_database* mot_db) { - RobEyelidMotion motion; - motion.data.motion_id = get_rob_cmn_mottbl_motion_id(mottbl_index); - motion.data.mottbl_index = mottbl_index; - motion.data.state = state; - motion.data.play_frame_step = step; - motion.data.blend_duration = blend_duration; - motion.data.blend_offset = blend_offset; - motion.data.field_24 = a7; - if (sub_14053F290(&motion)) { - motion.data.frame_data = &data.motion.frame_data; - motion.data.step_data = &data.motion.step_data; - } - motion.data.field_38 = a9; - if (motion.data.motion_id != -1) { - motion.data.frame_count = motion_storage_get_mot_data_frame_count(motion.data.motion_id, mot_db); - motion.data.frame = (motion.data.frame_count - 1.0f) * value; - } - - if (!type) { - data.motion.field_29 &= ~2; - data.motion.field_150.time = 0.0f; - } - rob_chara_set_eyelid_motion(this, &motion, type, mot_db); -} - void rob_chara::set_eyes_mottbl_motion(int32_t type, int32_t mottbl_index, float_t value, int32_t state, float_t blend_duration, float_t a7, float_t step, int32_t a9, float_t blend_offset, const motion_database* mot_db) { @@ -3822,9 +4124,9 @@ void rob_chara::set_face_object_index(int32_t index) { void rob_chara::set_frame(float_t frame) { bone_data->set_frame(frame); data.motion.frame_data.frame = frame; - //rob_chara_bone_data_interpolate(bone_data); - //rob_chara_bone_data_update(bone_data, 0); - //sub_140509D30(this); + //bone_data->interpolate(); + //bone_data->update(0); + //sub_140509D30(); } void rob_chara::set_hand_l_mottbl_motion(int32_t type, @@ -3877,7 +4179,7 @@ void rob_chara::set_left_hand_scale(float_t value) { data.adjust_data.left_hand_scale = value; } -bool rob_chara::set_motion_id(int32_t motion_id, +bool rob_chara::set_motion_id(uint32_t motion_id, float_t frame, float_t blend_duration, bool blend, bool set_motion_reset_data, MotionBlendType blend_type, const bone_database* bone_data, const motion_database* mot_db) { if (!blend && data.motion.motion_id == motion_id) @@ -3914,11 +4216,11 @@ void rob_chara::set_motion_loop(float_t loop_begin, float_t loop_end, int32_t lo } } -void rob_chara::set_motion_reset_data(int32_t motion_id, float_t frame) { +void rob_chara::set_motion_reset_data(uint32_t motion_id, float_t frame) { item_equip->set_motion_reset_data(motion_id, frame); } -void rob_chara::set_motion_skin_param(int32_t motion_id, float_t frame) { +void rob_chara::set_motion_skin_param(uint32_t motion_id, float_t frame) { item_equip->set_motion_skin_param(chara_id, motion_id, (int32_t)roundf(frame)); } @@ -4038,6 +4340,359 @@ void rob_chara::set_wind_strength(float_t value) { static void sub_140554830(rob_chara* rob_chr, uint8_t a2, uint8_t a3, float_t a4, float_t a5, float_t a6, float_t a7, float_t a8, bool a9); +static bool sub_140413710(mot_play_data* a1) { + if (a1->loop_frames_enabled) + return a1->loop_frames <= 0.0f; + else if (a1->frame_data.loop_state >= MOT_PLAY_FRAME_DATA_LOOP_ONCE + && a1->frame_data.loop_state <= MOT_PLAY_FRAME_DATA_LOOP_REVERSE) + return false; + else if (a1->frame_data.playback_state == MOT_PLAY_FRAME_DATA_PLAYBACK_FORWARD) + return a1->frame_data.last_frame < a1->frame_data.frame; + else if (a1->frame_data.playback_state == MOT_PLAY_FRAME_DATA_PLAYBACK_BACKWARD) + return a1->frame_data.frame < 0.0f; + else + return false; +} + +static bool sub_140419E90(rob_chara_bone_data* rob_bone_data) { + return sub_140413710(&rob_bone_data->motion_loaded.front()->mot_play_data); +} + +static void sub_140505310(rob_chara* rob_chr, const bone_database* bone_data, const motion_database* mot_db) { + switch (rob_chr->data.field_1588.field_0.field_58) { + case -1: { + rob_chr->data.field_1588.field_0.field_20.field_0 &= ~0x81; + rob_chr->data.motion.frame_data.frame = rob_chr->data.field_1588.field_0.frame; + } break; + case 0: { + uint32_t motion_id = rob_chr->data.field_1588.field_0.field_5C; + if (motion_id == -1) + rob_chr->data.field_1588.field_0.field_20.field_0 &= ~0x81; + else + rob_chr->load_motion(motion_id, !!(rob_chr->data.field_1588.field_0.field_60 & 0x01), + 0.0f, MOTION_BLEND, bone_data, mot_db); + } break; + case 1: { + struc_223* v1 = &rob_chr->data.field_1588; + int32_t loop_count = rob_chr->data.field_1588.field_0.loop_count; + if (loop_count > 0) { + uint32_t motion_id = rob_chr->data.field_1588.field_0.field_64; + if (motion_id != -1) { + if (rob_chr->data.motion.loop_index >= loop_count) { + int32_t v6 = mothead_storage_get_mot_by_motion_id(motion_id, mot_db)->field_0.field_0; + if (!(v6 & 0x80000) && !(v6 & 0x100000)) + rob_chr->load_motion(motion_id, !!(rob_chr->data.field_1588.field_0.field_68 & 0x01), + 0.0f, MOTION_BLEND, bone_data, mot_db); + } + else if (v1->field_0.field_20.field_0 & 0x80000) { + int16_t* v8 = (int16_t*)rob_chr->data.field_8.field_148; + rob_chr->data.field_8.field_146 = v1->field_0.field_220; + if (v8) + v8[711] = v1->field_0.field_220; + } + else if (rob_chr->data.field_1588.field_0.field_20.field_0 & 0x100000) + rob_chr->data.field_8.field_0 = 1; + } + } + + rob_chr->data.motion.frame_data.frame = rob_chr->bone_data->get_frame(); + v1->field_330.field_0.current = v1->field_330.field_0.data; + rob_chr->data.motion.loop_index++; + return; + } break; + case 2: + case 3: + case 5: { + rob_chr->load_motion(rob_chr->get_rob_cmn_mottbl_motion_id(0), + false, 0.0f, MOTION_BLEND, bone_data, mot_db); + } break; + } +} + +static void sub_140505980(rob_chara* rob_chr) { + int32_t v3; + int32_t v4; + if (rob_chr->data.motion.field_24) { + if (rob_chr->data.motion.field_24 != 1) { + if (rob_chr->data.motion.field_24 != 2) + return; + goto LABEL_23; + } + } + else { + if (rob_chr->data.field_1588.field_0.field_78 > rob_chr->data.motion.frame_data.frame) + return; + + if (rob_chr->data.field_1588.field_0.field_10.field_0 & 0x4000) { + rob_chr->data.field_1588.field_0.field_20.field_0 |= 0x4000; + if ((rob_chr->data.field_1588.field_0.field_10.field_0 & 0x20000) != 0) + rob_chr->data.field_1588.field_0.field_20.field_0 &= ~0x20000; + } + rob_chr->data.field_1588.field_0.field_20.field_0 &= ~0x02; + rob_chr->data.motion.field_24 = 1; + } + + if (rob_chr->data.field_1588.field_0.field_7C > rob_chr->data.motion.frame_data.frame) + return; + + rob_chr->data.field_1588.field_0.field_20.field_0 |= 4; + rob_chr->data.field_1588.field_0.field_20.field_8 &= ~0x400000; + v3 = rob_chr->data.field_1588.field_0.field_20.field_0; + if (v3 & 0x4000) { + rob_chr->data.field_1588.field_0.field_20.field_0 = v3 & ~0x4000; + rob_chr->data.field_1588.field_0.field_88 &= ~0x02; + if (rob_chr->data.field_1588.field_0.field_88 & 0x04) + rob_chr->data.field_1588.field_0.field_20.field_0 &= ~0x8000; + } + else if (v3 & 0x2000000 + && (v3 & 0x01) != 0 + && !(rob_chr->data.field_1588.field_0.field_20.field_4 & 0x10000000) + && !(rob_chr->data.field_1588.field_0.field_20.field_4 & 0x20000000)) + rob_chr->data.field_1588.field_0.field_20.field_0 = v3 & ~0x01; + + v4 = rob_chr->data.field_1588.field_0.field_10.field_0; + if (v4 & 0x10000 && v4 & 0x20000) + rob_chr->data.field_1588.field_0.field_20.field_0 &= ~0x20000; + rob_chr->data.motion.field_24 = 2; + +LABEL_23: + float_t v5 = rob_chr->data.field_1588.field_0.field_80; + if (v5 >= 0.0f && v5 <= rob_chr->data.motion.frame_data.frame) { + if (v5 < (rob_chr->data.field_1588.field_0.frame - 1.0f) + || rob_chr->data.field_1588.field_0.field_58 == -1 + || rob_chr->data.field_1588.field_0.field_58 == 2) { + rob_chr->data.field_1588.field_0.field_20.field_0 &= ~0x2020081; + rob_chr->data.field_2 |= 0x20; + } + rob_chr->data.motion.field_24 = 3; + } +} + +static void mothead_apply(struc_223* a1, rob_chara* rob_chr, float_t frame, const motion_database* mot_db) { + a1->field_330.field_338 = 0; + + struc_377& v4 = a1->field_330.field_0; + if (!v4.current) + return; + + mothead_func_data v7; + v7.rob_chr = rob_chr; + v7.rob_chr_data = &rob_chr->data; + if (rob_chr->field_20) + v7.field_10 = (rob_chara_data*)((size_t)rob_chr->field_20 + 0x440); + else + v7.field_10 = 0; + v7.field_18 = rob_chr; + v7.field_28 = &rob_chr->data.field_1588; + v7.field_20 = &rob_chr->data; + v7.is_x = v4.is_x; // X + + int32_t frame_int = (int32_t)frame; + while (v4.current->frame <= frame_int && v4.current->type >= MOTHEAD_DATA_TYPE_0) { + if (v4.current->type >= MOTHEAD_DATA_MAX) { + v4.current++; + continue; + } + + mothead_data_type type = v4.current->type; + mothead_func func = mothead_func_array[type].func; + if (func) { + if (!(mothead_func_array[type].flags & 0x01) || frame_int <= 0) + func(&v7, v4.current->data, v4.current, frame_int, mot_db); + else { + frame_int -= v4.current->frame; + if (frame_int <= 1) + func(&v7, v4.current->data, v4.current, frame_int, mot_db); + } + } + v4.current++; + } +} + +static void sub_1405044B0(rob_chara* rob_chr) { + if (rob_chr->data.field_1588.field_330.arm_adjust_duration > 0) { // X + float_t blend = 1.0f; + if (fabsf(rob_chr->data.field_1588.field_330.arm_adjust_duration) > 0.000001f) + blend = (rob_chr->data.motion.frame_data.frame + - (float_t)rob_chr->data.field_1588.field_330.arm_adjust_start_frame) + / rob_chr->data.field_1588.field_330.arm_adjust_duration; + + blend = blend > 0.0f ? min_def(blend, 1.0f) : 0.0f; + if (fabsf(blend - 1.0f) <= 0.000001f) + rob_chr->data.field_1588.field_330.arm_adjust_duration = -1.0f; + rob_chr->data.arm_adjust_scale = lerp_def(rob_chr->data.field_1588.field_330.arm_adjust_prev_value, + rob_chr->data.field_1588.field_330.arm_adjust_next_value, blend); + + float_t default_scale = chara_size_table_get_value(1); + rob_chr->data.adjust_data.item_scale = default_scale + + (rob_chr->data.adjust_data.scale - default_scale) * rob_chr->data.arm_adjust_scale; + } + + float_t v2 = rob_chr->bone_data->ik_scale.ratio0; + float_t v4 = v2; + if (!rob_chr->data.field_1588.field_330.field_31C) { + rob_chr->data.motion.field_138 = v2; + rob_chr->data.motion.field_13C = v2; + rob_chr->data.motion.field_140 = 0.0f; + return; + } + + float_t v5 = rob_chr->data.field_1588.field_330.field_324; + float_t v6 = v2; + float_t v7 = rob_chr->data.field_1588.field_330.field_32C; + float_t v8 = 0.0f; + if (rob_chr->data.field_1588.field_330.field_318 == 1) { + switch (rob_chr->data.field_1588.field_330.field_31C) { + case 1: + v6 = 1.0f; + break; + case 2: + v6 = rob_chr->bone_data->ik_scale.ratio0; + case 3: + v6 = rob_chr->bone_data->ik_scale.ratio1; + case 4: + v6 = rob_chr->bone_data->ik_scale.ratio2; + case 5: + v6 = rob_chr->bone_data->ik_scale.ratio3; + case 6: + if (!rob_chr->field_20) + break; + v6 = ((rob_chara_bone_data*)((size_t)rob_chr->field_20 + 0x28))->ik_scale.ratio0; + if (rob_chr->bone_data->motion_loaded.front()->mot_key_data.skeleton_select == 1) + v6 *= v4; + case 7: + if (!rob_chr->field_20) + break; + v6 = ((rob_chara_bone_data*)((size_t)rob_chr->field_20 + 0x28))->ik_scale.ratio1; + if (rob_chr->bone_data->motion_loaded.front()->mot_key_data.skeleton_select == 1) + v6 *= v4; + case 8: + if (!rob_chr->field_20) + break; + v6 = ((rob_chara_bone_data*)((size_t)rob_chr->field_20 + 0x28))->ik_scale.ratio2; + if (rob_chr->bone_data->motion_loaded.front()->mot_key_data.skeleton_select == 1) + v6 *= v4; + case 9: + if (!rob_chr->field_20) + break; + v6 = ((rob_chara_bone_data*)((size_t)rob_chr->field_20 + 0x28))->ik_scale.ratio3; + if (rob_chr->bone_data->motion_loaded.front()->mot_key_data.skeleton_select == 1) + v6 *= v4; + break; + case 10: + if (rob_chr->data.field_1588.field_330.field_320 > 0.0f) + v6 = rob_chr->data.field_1588.field_330.field_320; + break; + default: + break; + } + v8 = rob_chr->data.field_1588.field_330.field_328; + } + + float_t v15 = rob_chr->data.motion.frame_data.frame; + float_t v16 = rob_chr->data.field_1588.field_330.field_314; + if (v15 < v16) { + float_t v17 = rob_chr->data.field_1588.field_330.field_310; + if (v15 < v17) { + v6 = v5; + v8 = v7; + } + else if (fabsf(v16 - v17) > 0.000001f && v16 - v17 > 0.0f) { + float_t v19 = (v16 - v15) / (v16 - v17); + v6 = v6 + (v5 - v6) * v19; + v8 = v8 + (v7 - v8) * v19; + } + } + + rob_chr->data.motion.field_138 = v6; + rob_chr->data.motion.field_13C = v4; + rob_chr->data.motion.field_140.x = 0.0f; + rob_chr->data.motion.field_140.y = v8; + rob_chr->data.motion.field_140.z = 0.0f; +} + +void rob_chara::sub_1405070E0(const bone_database* bone_data, const motion_database* mot_db) { + if (sub_140419E90(this->bone_data) || this->bone_data->get_motion_has_looped()) + sub_140505310(this, bone_data, mot_db); + sub_140505980(this); + mothead_apply(&data.field_1588, this, data.motion.frame_data.frame, mot_db); + sub_1405044B0(this); +} + +void rob_chara::sub_140509D30() { + struc_195* v39 = data.field_1E68.field_DF8; + struc_195* v40 = data.field_1E68.field_1230; + struc_195* v41 = data.field_1E68.field_1668; + mat4* v42 = data.field_1E68.field_78; + mat4* v43 = data.field_1E68.field_738; + + const struc_218* v3 = chara_init_data->field_828; + const struc_218* v6 = chara_init_data->field_830; + mat4* m; + mat4 mat; + for (int32_t i = 0; i < 27; i++) { + m = rob_chara_bone_data_get_mats_mat(bone_data, v3->bone_index); + mat4_translate_mult(m, &v3->bone_offset, &mat); + *v42 = mat; + + m = rob_chara_bone_data_get_mats_mat(bone_data, v6->bone_index); + mat4_translate_mult(m, &v3->bone_offset, &mat); + *v43 = mat; + + float_t chara_scale = data.adjust_data.scale; + + vec3 v23 = *(vec3*)&v42->row3 * chara_scale + data.adjust_data.trans; + *(vec3*)&v42->row3 = v23; + + vec3 v29 = *(vec3*)&v43->row3 * chara_scale + data.adjust_data.trans; + *(vec3*)&v43->row3 = v29; + + float_t v20 = v3->scale * chara_scale; + v39->scale = v20; + v39->field_24 = v20; + v39->prev_trans = v39->trans; + v39->trans = v23; + + float_t v19 = v6->scale * chara_scale; + v40->scale = v19; + v40->field_24 = v19; + v40->prev_trans = v40->trans; + v40->trans = v29; + + v41->scale = v19; + v41->field_24 = v19; + v41->prev_trans = v41->trans; + v41->trans = v29; + + v39++; + v40++; + v41++; + v42++; + v43++; + v3++; + v6++; + } +} + +void rob_chara::rob_info_ctrl() { + data.field_3DA0 = data.field_3D9C; + if (data.field_1E68.field_64 > 0.01f) + data.field_2 |= 0x40; + + //sub_140517CC0(this); + //sub_140517B80(this); + //sub_140517F20(this); + + /*int32_t v4 = sub_14013C8C0()->sub_1400E7910(); + if (v4 >= 4 && v4 != 8) + sub_14054FF20(this);*/ +} + +void rob_chara::sub_140551000() { + struc_223* v1 = &data.field_1588; + v1->field_330.field_0.current = v1->field_330.field_0.data; +} + void rob_chara::sub_140554790(bool a2, float_t a3, float_t a5, float_t a6, float_t a7, float_t a8) { sub_140554830(this, true, a2, a3, a5, a6, a7, a8, false); } @@ -4046,6 +4701,19 @@ void rob_chara::sub_1405547E0(bool a2, float_t a3, float_t a5, float_t a6, float sub_140554830(this, true, a2, a3, a5, a6, a7, a8, false); } +pv_data_set_motion::pv_data_set_motion() : frame_stage_index() { + motion_id = -1; +} + +pv_data_set_motion::pv_data_set_motion(uint32_t motion_id) : frame_stage_index() { + this->motion_id = motion_id; +} + +pv_data_set_motion::pv_data_set_motion(uint32_t motion_id, std::pair frame_stage_index) { + this->motion_id = motion_id; + this->frame_stage_index = frame_stage_index; +} + osage_init_data::osage_init_data() : rob_chr() { pv_id = -1; motion_id = -1; @@ -4059,6 +4727,15 @@ osage_init_data::osage_init_data(rob_chara* rob_chr, uint32_t motion_id) { frame = -1; } +osage_init_data::osage_init_data(rob_chara* rob_chr, int32_t pv_id, + uint32_t motion_id, std::string&& path, int32_t frame) { + this->rob_chr = rob_chr; + this->pv_id = pv_id; + this->motion_id = motion_id; + this->path.assign(path); + this->frame = frame; +} + osage_init_data::~osage_init_data() { } @@ -4770,7 +5447,7 @@ static void mot_blend_interpolate(mot_blend* a1, std::vector* bones, } } -static void mot_blend_load_motion(mot_blend* a1, int32_t motion_id, const motion_database* mot_db) { +static void mot_blend_load_motion(mot_blend* a1, uint32_t motion_id, const motion_database* mot_db) { mot_key_data_load_file(&a1->mot_key_data, motion_id, mot_db); a1->blend.Reset(); } @@ -5070,7 +5747,7 @@ static void mot_key_data_interpolate(mot_key_data* a1, float_t frame, &a1->key_set.data()[key_set_offset], key_set_count, &a1->field_68); } -static const mot_data* mot_key_data_load_file(mot_key_data* a1, int32_t motion_id, const motion_database* mot_db) { +static const mot_data* mot_key_data_load_file(mot_key_data* a1, uint32_t motion_id, const motion_database* mot_db) { if (a1->motion_id != motion_id) { const mot_data* mot_data = motion_storage_get_mot_data(motion_id, mot_db); a1->mot_data = mot_data; @@ -5732,7 +6409,7 @@ static void mothead_func_49(mothead_func_data* func_data, } -static void rob_chara_set_face_motion_id(rob_chara* rob_chr, int32_t motion_id, +static void rob_chara_set_face_motion_id(rob_chara* rob_chr, uint32_t motion_id, float_t frame, int32_t state, float_t blend_duration, float_t a6, float_t step, int32_t a8, float_t blend_offset, const motion_database* mot_db); @@ -5788,10 +6465,10 @@ static void mothead_func_58_set_eyelid_mottbl_motion(mothead_func_data* func_dat ((float_t*)data)[2] * 6.0f, ((float_t*)data)[4], 1.0f, -1, 0.0f, mot_db); } -static void rob_chara_set_eyelid_motion_id(rob_chara* rob_chr, int32_t motion_id, +static void rob_chara_set_eyelid_motion_id(rob_chara* rob_chr, uint32_t motion_id, float_t frame, int32_t state, float_t blend_duration, float_t a6, float_t step, int32_t a8, float_t blend_offset, const motion_database* mot_db); -static void rob_chara_set_eyes_motion_id(rob_chara* rob_chr, int32_t motion_id, +static void rob_chara_set_eyes_motion_id(rob_chara* rob_chr, uint32_t motion_id, float_t frame, int32_t state, float_t blend_duration, float_t a6, float_t step, int32_t a8, float_t blend_offset, const motion_database* mot_db); @@ -5908,7 +6585,7 @@ static void mothead_func_64_osage_reset(mothead_func_data* func_data, static void mothead_func_65_motion_skin_param(mothead_func_data* func_data, void* data, const mothead_data* mhd_data, int32_t frame, const motion_database* mot_db) { rob_chara* rob_chr = func_data->rob_chr; - int32_t motion_id = rob_chr->data.motion.motion_id; + uint32_t motion_id = rob_chr->data.motion.motion_id; float_t _frame = (float_t)mhd_data->frame; rob_chr->set_motion_skin_param(motion_id, _frame); rob_chr->set_motion_reset_data(motion_id, _frame); @@ -6198,7 +6875,7 @@ static void mothead_mot_msgpack_read(const char* path, const char* set_name, mot if (!mot_id || !arr) continue; - int32_t motion_id = mot_id->read_int32_t(); + uint32_t motion_id = mot_id->read_int32_t(); if (motion_id < mhd->first_mot_id || motion_id > mhd->last_mot_id) continue; @@ -6611,7 +7288,7 @@ static void sub_140412F20(mot_blend* a1, std::vector* a2) { sub_1401EB1D0(&i, 0); } -static void motion_blend_mot_load_file(motion_blend_mot* a1, int32_t motion_id, +static void motion_blend_mot_load_file(motion_blend_mot* a1, uint32_t motion_id, MotionBlendType blend_type, float_t blend, const bone_database* bone_data, const motion_database* mot_db) { motion_blend_mot_set_blend(a1, blend_type, blend); const mot_data* v6 = mot_key_data_load_file(&a1->mot_key_data, motion_id, mot_db); @@ -6812,179 +7489,6 @@ static void sub_140507F60(rob_chara* rob_chr) { rob_chr->data.miku_rot.field_6 = (int32_t)((float_t)(atan2f(v10.x, v10.z) * 32768.0f) * (1.0 / M_PI)); } -void rob_chara_data_adjust_ctrl(rob_chara* rob_chr, rob_chara_data_adjust* adjust, - rob_chara_data_adjust* adjust_prev) { - float_t cycle = adjust->cycle; - float_t v7 = 0.0f; - adjust->frame += rob_chr->data.motion.step_data.frame; - if (rob_chr->data.field_1588.field_0.field_58 == 1) - cycle *= (60.0f / rob_chr->data.field_1588.field_0.frame); - cycle *= adjust->frame * 2.0f * (float_t)M_PI * (float_t)(1.0 / 60.0f); - - switch (adjust->cycle_type) { - case 1: - v7 = cosf(adjust->phase * (float_t)M_PI + cycle); - break; - case 2: - v7 = sinf(adjust->phase * (float_t)M_PI + cycle); - break; - } - - adjust->curr_external_force = (adjust->external_force_cycle + v7) - * (adjust->external_force * adjust->external_force_cycle_strength) + adjust->external_force; - - if (adjust->type == 1) { - mat4 mat = mat4_identity; - mat4_rotate_y_mult(&mat, (float_t)((double_t)rob_chr->data.miku_rot.rot_y_int16 - * M_PI * (1.0 / 32768.0)), &mat); - mat4_mult_vec3(&mat, &adjust->curr_external_force, &adjust->curr_external_force); - } - else if (adjust->type == 2) { - mat4* mat = rob_chara_bone_data_get_node(rob_chr->bone_data, 9)->ex_data_mat; - if (mat) - mat4_mult_vec3(mat, &adjust->curr_external_force, &adjust->curr_external_force); - } - else if (adjust->type == 3) { - mat4* mat = rob_chara_bone_data_get_node(rob_chr->bone_data, 10)->ex_data_mat; - if (mat) - mat4_mult_vec3(mat, &adjust->curr_external_force, &adjust->curr_external_force); - } - else if (adjust->type == 4) { - mat4* mat = rob_chara_bone_data_get_node(rob_chr->bone_data, 15)->ex_data_mat; - if (mat) - mat4_mult_vec3(mat, &adjust->curr_external_force, &adjust->curr_external_force); - } - else if (adjust->type == 5) { - mat4* mat = rob_chara_bone_data_get_node(rob_chr->bone_data, 177)->ex_data_mat; - if (mat) { - adjust->curr_external_force.z = -adjust->curr_external_force.z; - mat4_mult_vec3(mat, &adjust->curr_external_force, &adjust->curr_external_force); - } - } - - if (adjust->ignore_gravity) - adjust->curr_external_force.y = get_osage_gravity_const() + adjust->curr_external_force.y; - - adjust->curr_force = adjust->force; - adjust->curr_strength = adjust->strength; - - bool transition_frame_step = false; - if (adjust->transition_duration > adjust->transition_frame - && fabsf(adjust->transition_duration - adjust->transition_frame) > 0.000001f) { - transition_frame_step = true; - float_t blend = (adjust->transition_frame + 1.0f) / (adjust->transition_duration + 1.0f); - adjust->curr_external_force = vec3::lerp(adjust_prev->curr_external_force, - adjust->curr_external_force, blend); - adjust->curr_force = lerp_def(adjust_prev->curr_force, adjust->curr_force, blend); - } - - if (adjust->strength_transition > adjust->transition_frame - && fabsf(adjust->strength_transition - adjust->transition_frame) > 0.000001f) { - float_t blend = (adjust->transition_frame + 1.0f) / (adjust->strength_transition + 1.0f); - adjust->curr_strength = lerp_def(adjust_prev->curr_strength, adjust->curr_strength, blend); - } - else if (!transition_frame_step) - return; - - adjust->transition_frame += rob_chr->data.motion.step_data.frame; -} - -static void rob_chara_item_equip_object_set_parts_external_force( - rob_chara_item_equip_object* itm_eq_obj, rob_osage_parts_bit parts_bits, - vec3* weight, float_t force, float_t strength) { - for (ExOsageBlock*& i : itm_eq_obj->osage_blocks) { - RobOsage* rob_osg = &i->rob; - if (rob_osg->CheckPartsBits(parts_bits)) { - rob_osg->SetNodesExternalForce(weight, strength); - rob_osg->SetNodesForce(force); - } - } -} - -static void rob_chara_item_equip_set_parts_external_force(rob_chara_item_equip* rob_itm_eq, - int32_t parts, vec3* external_force, float_t force, float_t strength) { - item_id id = (item_id)(parts == ROB_OSAGE_PARTS_MUFFLER ? ITEM_OUTER : ITEM_KAMI); - if (!osage_setting_data_obj_has_key(rob_itm_eq->item_equip_object[id].obj_info)) - return; - - switch (parts) { - case ROB_OSAGE_PARTS_SHORT_L: - case ROB_OSAGE_PARTS_SHORT_R: - rob_itm_eq->parts_short = true; - break; - case ROB_OSAGE_PARTS_APPEND_L: - case ROB_OSAGE_PARTS_APPEND_R: - rob_itm_eq->parts_append = true; - break; - case ROB_OSAGE_PARTS_WHITE_ONE_L: - rob_itm_eq->parts_white_one_l = true; - break; - } - - rob_osage_parts_bit parts_bits = (rob_osage_parts_bit)(1 << parts); - if (!rob_itm_eq->parts_short) { - if (parts == ROB_OSAGE_PARTS_LEFT) - enum_or(parts_bits, ROB_OSAGE_PARTS_SHORT_L_BIT); - else if (parts == ROB_OSAGE_PARTS_RIGHT) - enum_or(parts_bits, ROB_OSAGE_PARTS_SHORT_R_BIT); - } - - if (!rob_itm_eq->parts_append) { - if (parts == ROB_OSAGE_PARTS_LEFT) - enum_or(parts_bits, ROB_OSAGE_PARTS_APPEND_L_BIT); - else if (parts == ROB_OSAGE_PARTS_RIGHT) - enum_or(parts_bits, ROB_OSAGE_PARTS_APPEND_R_BIT); - } - - if (!rob_itm_eq->parts_white_one_l && parts == ROB_OSAGE_PARTS_LONG_C) - enum_or(parts_bits, ROB_OSAGE_PARTS_WHITE_ONE_L_BIT); - - rob_chara_item_equip_object_set_parts_external_force( - &rob_itm_eq->item_equip_object[id], parts_bits, external_force, force, strength); -} - -static void rob_chara_item_equip_object_set_external_force( - rob_chara_item_equip_object* itm_eq_obj, vec3* external_force) { - for (ExOsageBlock*& i : itm_eq_obj->osage_blocks) { - i->rob.set_external_force = true; - i->rob.external_force = *external_force; - } - - for (ExClothBlock*& i : itm_eq_obj->cloth_blocks) { - i->rob.set_external_force = true; - i->rob.external_force = *external_force; - } -} - -static void rob_chara_item_equip_set_external_force( - rob_chara_item_equip* rob_itm_eq, vec3* external_force) { - for (int32_t i = rob_itm_eq->first_item_equip_object; i < rob_itm_eq->max_item_equip_object; i++) - rob_chara_item_equip_object_set_external_force(&rob_itm_eq->item_equip_object[i], external_force); -} - -static void rob_chara_adjust_ctrl(rob_chara* rob_chr) { - rob_chara_item_equip* rob_itm_equip = rob_chr->item_equip; - - for (int32_t i = 0; i < ROB_OSAGE_PARTS_MAX; i++) { - rob_chara_data_adjust* parts_adjust = &rob_chr->data.motion.parts_adjust[i]; - if (parts_adjust->enable) { - rob_chara_data_adjust_ctrl(rob_chr, parts_adjust, &rob_chr->data.motion.parts_adjust_prev[i]); - rob_chara_item_equip_set_parts_external_force(rob_itm_equip, i, - &parts_adjust->curr_external_force, parts_adjust->curr_force, parts_adjust->curr_strength); - } - } - - rob_chara_data_adjust* adjust_global = &rob_chr->data.motion.adjust_global; - if (adjust_global->enable) { - rob_chara_data_adjust_ctrl(rob_chr, adjust_global, &rob_chr->data.motion.adjust_global_prev); - rob_chara_item_equip_set_external_force(rob_itm_equip, &adjust_global->curr_external_force); - } - - rob_itm_equip->parts_short = false; - rob_itm_equip->parts_append = false; - rob_itm_equip->parts_white_one_l = false; -} - static void sub_140505B20(rob_chara* rob_chr) { if (rob_chr->data.field_1588.field_0.field_20.field_0 & 0x100) rob_chr->data.miku_rot.field_2 = rob_chr->data.miku_rot.rot_y_int16 @@ -6998,80 +7502,12 @@ static void sub_140505B20(rob_chara* rob_chr) { rob_chr->data.field_1 &= ~0x80; } -static vec3* rob_chara_bone_data_get_global_trans(rob_chara_bone_data* rob_bone_data) { - return &rob_bone_data->motion_loaded.front()->bone_data.global_trans; -} - -static void rob_chara_data_adjuct_set_trans(rob_chara_adjust_data* rob_chr_adj, - vec3& trans, bool pos_adjust, vec3* global_trans) { - float_t scale = rob_chr_adj->scale; - float_t item_scale = rob_chr_adj->item_scale; // X - vec3 _offset = rob_chr_adj->offset; - if (global_trans) - _offset.y += global_trans->y; - - vec3 _trans = trans; - vec3 _item_trans = trans; - if (rob_chr_adj->height_adjust) { - _trans.y += rob_chr_adj->pos_adjust_y; - _item_trans.y += rob_chr_adj->pos_adjust_y; // X - } - else { - vec3 temp = (_trans - _offset) * scale + _offset; - vec3 arm_temp = (_item_trans - _offset) * item_scale + _offset; - - if (!rob_chr_adj->offset_x) { - _trans.x = temp.x; - _item_trans.x = arm_temp.x; // X - } - - if (!rob_chr_adj->offset_y) { - _trans.y = temp.y; - _item_trans.y = arm_temp.y; // X - } - - if (!rob_chr_adj->offset_z) { - _trans.z = temp.z; - _item_trans.z = arm_temp.z; // X - } - } - - if (pos_adjust) { - _trans = rob_chr_adj->pos_adjust + _trans; - _item_trans = rob_chr_adj->pos_adjust + _item_trans; //X - } - - rob_chr_adj->trans = _trans - trans * scale; - rob_chr_adj->item_trans = _item_trans - trans * item_scale; // X -} - -static void rob_chara_set_data_adjust_mat(rob_chara* rob_chr, - rob_chara_adjust_data* rob_chr_adj, bool pos_adjust = true) { - mat4* mat = rob_chara_bone_data_get_mats_mat(rob_chr->bone_data, ROB_BONE_N_HARA_CP); - - vec3 trans; - mat4_get_translation(mat, &trans); - - vec3* global_trans = 0; - if (rob_chr_adj->get_global_trans) - global_trans = rob_chara_bone_data_get_global_trans(rob_chr->bone_data); - rob_chara_data_adjuct_set_trans(rob_chr_adj, trans, pos_adjust, global_trans); - - float_t scale = rob_chr_adj->scale; - mat4_scale(scale, scale, scale, &rob_chr_adj->mat); - mat4_set_translation(&rob_chr_adj->mat, &rob_chr_adj->trans); - - float_t item_scale = rob_chr_adj->item_scale; // X - mat4_scale(item_scale, item_scale, item_scale, &rob_chr_adj->item_mat); - mat4_set_translation(&rob_chr_adj->item_mat, &rob_chr_adj->item_trans); -} - static void rob_base_rob_chara_ctrl(rob_chara* rob_chr) { sub_140507F60(rob_chr); - rob_chara_adjust_ctrl(rob_chr); + rob_chr->adjust_ctrl(); sub_140505B20(rob_chr); //sub_14036D130(7, &rob_chr); - rob_chara_set_data_adjust_mat(rob_chr, &rob_chr->data.adjust_data); + rob_chr->set_data_adjust_mat(&rob_chr->data.adjust_data); } static void sub_140514680(rob_chara* rob_chr) { @@ -7230,324 +7666,6 @@ static void sub_1405077D0(rob_chara* rob_chr, const bone_database* bone_data, co } } -static bool sub_140413710(mot_play_data* a1) { - if (a1->loop_frames_enabled) - return a1->loop_frames <= 0.0f; - else if (a1->frame_data.loop_state >= MOT_PLAY_FRAME_DATA_LOOP_ONCE - && a1->frame_data.loop_state <= MOT_PLAY_FRAME_DATA_LOOP_REVERSE) - return false; - else if (a1->frame_data.playback_state == MOT_PLAY_FRAME_DATA_PLAYBACK_FORWARD) - return a1->frame_data.last_frame < a1->frame_data.frame; - else if (a1->frame_data.playback_state == MOT_PLAY_FRAME_DATA_PLAYBACK_BACKWARD) - return a1->frame_data.frame < 0.0f; - else - return false; -} - -static bool sub_140419E90(rob_chara_bone_data* rob_bone_data) { - return sub_140413710(&rob_bone_data->motion_loaded.front()->mot_play_data); -} - -static void sub_140505310(rob_chara* rob_chr, const bone_database* bone_data, const motion_database* mot_db) { - switch (rob_chr->data.field_1588.field_0.field_58) { - case -1: { - rob_chr->data.field_1588.field_0.field_20.field_0 &= ~0x81; - rob_chr->data.motion.frame_data.frame = rob_chr->data.field_1588.field_0.frame; - } break; - case 0: { - int32_t motion_id = rob_chr->data.field_1588.field_0.field_5C; - if (motion_id == -1) - rob_chr->data.field_1588.field_0.field_20.field_0 &= ~0x81; - else - rob_chr->load_motion(motion_id, !!(rob_chr->data.field_1588.field_0.field_60 & 0x01), - 0.0f, MOTION_BLEND, bone_data, mot_db); - } break; - case 1: { - struc_223* v1 = &rob_chr->data.field_1588; - int32_t loop_count = rob_chr->data.field_1588.field_0.loop_count; - if (loop_count > 0) { - int32_t motion_id = rob_chr->data.field_1588.field_0.field_64; - if (motion_id != -1) { - if (rob_chr->data.motion.loop_index >= loop_count) { - int32_t v6 = mothead_storage_get_mot_by_motion_id(motion_id, mot_db)->field_0.field_0; - if (!(v6 & 0x80000) && !(v6 & 0x100000)) - rob_chr->load_motion(motion_id, !!(rob_chr->data.field_1588.field_0.field_68 & 0x01), - 0.0f, MOTION_BLEND, bone_data, mot_db); - } - else if (v1->field_0.field_20.field_0 & 0x80000) { - int16_t* v8 = (int16_t*)rob_chr->data.field_8.field_148; - rob_chr->data.field_8.field_146 = v1->field_0.field_220; - if (v8) - v8[711] = v1->field_0.field_220; - } - else if (rob_chr->data.field_1588.field_0.field_20.field_0 & 0x100000) - rob_chr->data.field_8.field_0 = 1; - } - } - - rob_chr->data.motion.frame_data.frame = rob_chr->bone_data->get_frame(); - v1->field_330.field_0.current = v1->field_330.field_0.data; - rob_chr->data.motion.loop_index++; - return; - } break; - case 2: - case 3: - case 5: { - rob_chr->load_motion(rob_chr->get_rob_cmn_mottbl_motion_id(0), - false, 0.0f, MOTION_BLEND, bone_data, mot_db); - } break; - } -} - -static void sub_140505980(rob_chara* rob_chr) { - int32_t v3; - int32_t v4; - if (rob_chr->data.motion.field_24) { - if (rob_chr->data.motion.field_24 != 1) { - if (rob_chr->data.motion.field_24 != 2) - return; - goto LABEL_23; - } - } - else { - if (rob_chr->data.field_1588.field_0.field_78 > rob_chr->data.motion.frame_data.frame) - return; - - if (rob_chr->data.field_1588.field_0.field_10.field_0 & 0x4000) { - rob_chr->data.field_1588.field_0.field_20.field_0 |= 0x4000; - if ((rob_chr->data.field_1588.field_0.field_10.field_0 & 0x20000) != 0) - rob_chr->data.field_1588.field_0.field_20.field_0 &= ~0x20000; - } - rob_chr->data.field_1588.field_0.field_20.field_0 &= ~0x02; - rob_chr->data.motion.field_24 = 1; - } - - if (rob_chr->data.field_1588.field_0.field_7C > rob_chr->data.motion.frame_data.frame) - return; - - rob_chr->data.field_1588.field_0.field_20.field_0 |= 4; - rob_chr->data.field_1588.field_0.field_20.field_8 &= ~0x400000; - v3 = rob_chr->data.field_1588.field_0.field_20.field_0; - if (v3 & 0x4000) { - rob_chr->data.field_1588.field_0.field_20.field_0 = v3 & ~0x4000; - rob_chr->data.field_1588.field_0.field_88 &= ~0x02; - if (rob_chr->data.field_1588.field_0.field_88 & 0x04) - rob_chr->data.field_1588.field_0.field_20.field_0 &= ~0x8000; - } - else if (v3 & 0x2000000 - && (v3 & 0x01) != 0 - && !(rob_chr->data.field_1588.field_0.field_20.field_4 & 0x10000000) - && !(rob_chr->data.field_1588.field_0.field_20.field_4 & 0x20000000)) - rob_chr->data.field_1588.field_0.field_20.field_0 = v3 & ~0x01; - - v4 = rob_chr->data.field_1588.field_0.field_10.field_0; - if (v4 & 0x10000 && v4 & 0x20000) - rob_chr->data.field_1588.field_0.field_20.field_0 &= ~0x20000; - rob_chr->data.motion.field_24 = 2; - -LABEL_23: - float_t v5 = rob_chr->data.field_1588.field_0.field_80; - if (v5 >= 0.0f && v5 <= rob_chr->data.motion.frame_data.frame) { - if (v5 < (rob_chr->data.field_1588.field_0.frame - 1.0f) - || rob_chr->data.field_1588.field_0.field_58 == -1 - || rob_chr->data.field_1588.field_0.field_58 == 2) { - rob_chr->data.field_1588.field_0.field_20.field_0 &= ~0x2020081; - rob_chr->data.field_2 |= 0x20; - } - rob_chr->data.motion.field_24 = 3; - } -} - -static void mothead_apply(struc_223* a1, rob_chara* rob_chr, float_t frame, const motion_database* mot_db) { - a1->field_330.field_338 = 0; - - struc_377& v4 = a1->field_330.field_0; - if (!v4.current) - return; - - mothead_func_data v7; - v7.rob_chr = rob_chr; - v7.rob_chr_data = &rob_chr->data; - if (rob_chr->field_20) - v7.field_10 = (rob_chara_data*)((size_t)rob_chr->field_20 + 0x440); - else - v7.field_10 = 0; - v7.field_18 = rob_chr; - v7.field_28 = &rob_chr->data.field_1588; - v7.field_20 = &rob_chr->data; - v7.is_x = v4.is_x; // X - - int32_t frame_int = (int32_t)frame; - while (v4.current->frame <= frame_int && v4.current->type >= MOTHEAD_DATA_TYPE_0) { - if (v4.current->type >= MOTHEAD_DATA_MAX) { - v4.current++; - continue; - } - - mothead_data_type type = v4.current->type; - mothead_func func = mothead_func_array[type].func; - if (func) { - if (!(mothead_func_array[type].flags & 0x01) || frame_int <= 0) - func(&v7, v4.current->data, v4.current, frame_int, mot_db); - else { - frame_int -= v4.current->frame; - if (frame_int <= 1) - func(&v7, v4.current->data, v4.current, frame_int, mot_db); - } - } - v4.current++; - } -} - -static void sub_1405044B0(rob_chara* rob_chr) { - if (rob_chr->data.field_1588.field_330.arm_adjust_duration > 0) { // X - float_t blend = 1.0f; - if (fabsf(rob_chr->data.field_1588.field_330.arm_adjust_duration) > 0.000001f) - blend = (rob_chr->data.motion.frame_data.frame - - (float_t)rob_chr->data.field_1588.field_330.arm_adjust_start_frame) - / rob_chr->data.field_1588.field_330.arm_adjust_duration; - - blend = blend > 0.0f ? min_def(blend, 1.0f) : 0.0f; - if (fabsf(blend - 1.0f) <= 0.000001f ) - rob_chr->data.field_1588.field_330.arm_adjust_duration = -1.0f; - rob_chr->data.arm_adjust_scale = lerp_def(rob_chr->data.field_1588.field_330.arm_adjust_prev_value, - rob_chr->data.field_1588.field_330.arm_adjust_next_value, blend); - - float_t default_scale = chara_size_table_get_value(1); - rob_chr->data.adjust_data.item_scale = default_scale - + (rob_chr->data.adjust_data.scale - default_scale) * rob_chr->data.arm_adjust_scale; - } - - float_t v2 = rob_chr->bone_data->ik_scale.ratio0; - float_t v4 = v2; - if (!rob_chr->data.field_1588.field_330.field_31C) { - rob_chr->data.motion.field_138 = v2; - rob_chr->data.motion.field_13C = v2; - rob_chr->data.motion.field_140 = 0.0f; - return; - } - - float_t v5 = rob_chr->data.field_1588.field_330.field_324; - float_t v6 = v2; - float_t v7 = rob_chr->data.field_1588.field_330.field_32C; - float_t v8 = 0.0f; - if (rob_chr->data.field_1588.field_330.field_318 == 1) { - switch (rob_chr->data.field_1588.field_330.field_31C) { - case 1: - v6 = 1.0f; - break; - case 2: - v6 = rob_chr->bone_data->ik_scale.ratio0; - case 3: - v6 = rob_chr->bone_data->ik_scale.ratio1; - case 4: - v6 = rob_chr->bone_data->ik_scale.ratio2; - case 5: - v6 = rob_chr->bone_data->ik_scale.ratio3; - case 6: - if (!rob_chr->field_20) - break; - v6 = ((rob_chara_bone_data*)((size_t)rob_chr->field_20 + 0x28))->ik_scale.ratio0; - if (rob_chr->bone_data->motion_loaded.front()->mot_key_data.skeleton_select == 1) - v6 *= v4; - case 7: - if (!rob_chr->field_20) - break; - v6 = ((rob_chara_bone_data*)((size_t)rob_chr->field_20 + 0x28))->ik_scale.ratio1; - if (rob_chr->bone_data->motion_loaded.front()->mot_key_data.skeleton_select == 1) - v6 *= v4; - case 8: - if (!rob_chr->field_20) - break; - v6 = ((rob_chara_bone_data*)((size_t)rob_chr->field_20 + 0x28))->ik_scale.ratio2; - if (rob_chr->bone_data->motion_loaded.front()->mot_key_data.skeleton_select == 1) - v6 *= v4; - case 9: - if (!rob_chr->field_20) - break; - v6 = ((rob_chara_bone_data*)((size_t)rob_chr->field_20 + 0x28))->ik_scale.ratio3; - if (rob_chr->bone_data->motion_loaded.front()->mot_key_data.skeleton_select == 1) - v6 *= v4; - break; - case 10: - if (rob_chr->data.field_1588.field_330.field_320 > 0.0f) - v6 = rob_chr->data.field_1588.field_330.field_320; - break; - default: - break; - } - v8 = rob_chr->data.field_1588.field_330.field_328; - } - - float_t v15 = rob_chr->data.motion.frame_data.frame; - float_t v16 = rob_chr->data.field_1588.field_330.field_314; - if (v15 < v16) { - float_t v17 = rob_chr->data.field_1588.field_330.field_310; - if (v15 < v17) { - v6 = v5; - v8 = v7; - } - else if (fabsf(v16 - v17) > 0.000001f && v16 - v17 > 0.0f) { - float_t v19 = (v16 - v15) / (v16 - v17); - v6 = v6 + (v5 - v6) * v19; - v8 = v8 + (v7 - v8) * v19; - } - } - - rob_chr->data.motion.field_138 = v6; - rob_chr->data.motion.field_13C = v4; - rob_chr->data.motion.field_140.x = 0.0f; - rob_chr->data.motion.field_140.y = v8; - rob_chr->data.motion.field_140.z = 0.0f; -} - -static void sub_1405070E0(rob_chara* rob_chr, const bone_database* bone_data, const motion_database* mot_db) { - if (sub_140419E90(rob_chr->bone_data) || rob_chr->bone_data->get_motion_has_looped()) - sub_140505310(rob_chr, bone_data, mot_db); - sub_140505980(rob_chr); - mothead_apply(&rob_chr->data.field_1588, rob_chr, rob_chr->data.motion.frame_data.frame, mot_db); - sub_1405044B0(rob_chr); -} - -static void rob_chara_data_arm_adjust_ctrl(rob_chara* rob_chr, int32_t index, rob_chara_data_arm_adjust* arm_adjust) { - if (!arm_adjust->enable) - return; - - float_t prev_value = arm_adjust->prev_value; - float_t next_value = arm_adjust->next_value; - float_t duration = arm_adjust->duration; - float_t frame = arm_adjust->frame; - if (duration <= frame || fabsf(duration - frame) <= 0.000001f) { - arm_adjust->enable = false; - arm_adjust->value = next_value; - return; - } - - float_t blend = (frame + 1.0f) / (duration + 1.0f); - float_t inv_blend = 1.0f - blend; - if (prev_value <= 0.0001f || prev_value >= 1.0f) { - if (next_value != 0.0f) - arm_adjust->value = next_value * blend + inv_blend; - else - arm_adjust->value = 0.0f; - } - else { - if (next_value != 0.0f) - arm_adjust->value = next_value * blend + prev_value * inv_blend; - else - arm_adjust->value = blend + prev_value * inv_blend; - } - arm_adjust->frame += rob_chr->data.motion.step_data.frame; - - rob_chara_bone_data_set_motion_arm_length(rob_chr->bone_data, - rob_motion_c_kata_bone_get(index), arm_adjust->value); -} - -static void rob_chara_arm_adjust_ctrl(rob_chara* rob_chr) { - for (int32_t i = 0; i < 2; i++) - rob_chara_data_arm_adjust_ctrl(rob_chr, i, &rob_chr->data.motion.arm_adjust[i]); -} - static void rob_chara_set_face_motion(rob_chara* rob_chr, RobFaceMotion* motion, int32_t type, const motion_database* mot_db); @@ -7589,7 +7707,7 @@ static bool sub_14053F1B0(RobPartialMotion* a1) { return false; } -static void rob_chara_set_face_motion_id(rob_chara* rob_chr, int32_t motion_id, +static void rob_chara_set_face_motion_id(rob_chara* rob_chr, uint32_t motion_id, float_t frame, int32_t state, float_t blend_duration, float_t a6, float_t step, int32_t a8, float_t blend_offset, const motion_database* mot_db) { RobFaceMotion motion; @@ -7619,7 +7737,7 @@ static void sub_1405509D0(rob_chara* rob_chr, const motion_database* mot_db) { static void rob_chara_set_hand_l_motion(rob_chara* rob_chr, RobHandMotion* motion, int32_t type, const motion_database* mot_db); -static void sub_140553E30(rob_chara* rob_chr, int32_t motion_id, +static void sub_140553E30(rob_chara* rob_chr, uint32_t motion_id, float_t frame, int32_t state, float_t blend_duration, float_t a6, float_t step, int32_t a8, float_t blend_offset, const motion_database* mot_db) { RobHandMotion motion; @@ -7649,7 +7767,7 @@ static void sub_140550A40(rob_chara* rob_chr, const motion_database* mot_db) { static void rob_chara_set_hand_r_motion(rob_chara* rob_chr, RobHandMotion* motion, int32_t type, const motion_database* mot_db); -static void sub_140554370(rob_chara* rob_chr, int32_t motion_id, +static void sub_140554370(rob_chara* rob_chr, uint32_t motion_id, float_t frame, int32_t state, float_t blend_duration, float_t a6, float_t step, int32_t a8, float_t blend_offset, const motion_database* mot_db) { RobHandMotion motion; @@ -7679,7 +7797,7 @@ static void sub_140550AB0(rob_chara* rob_chr, const motion_database* mot_db) { static void rob_chara_set_mouth_motion(rob_chara* rob_chr, RobMouthMotion* motion, int32_t type, const motion_database* mot_db); -static void sub_140554C40(rob_chara* rob_chr, int32_t motion_id, +static void sub_140554C40(rob_chara* rob_chr, uint32_t motion_id, float_t frame, int32_t state, float_t blend_duration, float_t a6, float_t step, int32_t a8, float_t blend_offset, const motion_database* mot_db) { RobMouthMotion motion; @@ -7709,7 +7827,7 @@ static void sub_140550B20(rob_chara* rob_chr, const motion_database* mot_db) { static void rob_chara_set_eyes_motion(rob_chara* rob_chr, RobEyesMotion* motion, int32_t type, const motion_database* mot_db); -static void rob_chara_set_eyes_motion_id(rob_chara* rob_chr, int32_t motion_id, +static void rob_chara_set_eyes_motion_id(rob_chara* rob_chr, uint32_t motion_id, float_t frame, int32_t state, float_t blend_duration, float_t a6, float_t step, int32_t a8, float_t blend_offset, const motion_database* mot_db) { RobEyesMotion motion; @@ -7739,7 +7857,7 @@ static void sub_140550960(rob_chara* rob_chr, const motion_database* mot_db) { static void rob_chara_set_eyelid_motion(rob_chara* rob_chr, RobEyelidMotion* motion, int32_t type, const motion_database* mot_db); -static void rob_chara_set_eyelid_motion_id(rob_chara* rob_chr, int32_t motion_id, +static void rob_chara_set_eyelid_motion_id(rob_chara* rob_chr, uint32_t motion_id, float_t frame, int32_t state, float_t blend_duration, float_t a6, float_t step, int32_t a8, float_t blend_offset, const motion_database* mot_db) { RobEyelidMotion motion; @@ -8012,8 +8130,8 @@ static void sub_140504710(rob_chara* rob_chr, const motion_database* mot_db, rob_chr->load_outfit_object_info(ITEM_HARA, v14, false, bone_data, data, obj_db); - rob_chara_bone_data_interpolate(rob_chr->bone_data); - rob_chara_bone_data_update(rob_chr->bone_data, 0); + rob_chr->bone_data->interpolate(); + rob_chr->bone_data->update(0); sub_140504F00(rob_chr); rob_chr->data.motion.field_28 &= ~0x80; @@ -8102,8 +8220,8 @@ static void rob_base_rob_chara_ctrl_thread_main(rob_chara* rob_chr) { sub_140514520(rob_chr, aft_bone_data, aft_mot_db); sub_14054CC80(rob_chr); sub_1405077D0(rob_chr, aft_bone_data, aft_mot_db); - sub_1405070E0(rob_chr, aft_bone_data, aft_mot_db); - rob_chara_arm_adjust_ctrl(rob_chr); + rob_chr->sub_1405070E0(aft_bone_data, aft_mot_db); + rob_chr->arm_adjust_ctrl(); sub_140504710(rob_chr, aft_mot_db, aft_bone_data, aft_data, aft_obj_db); sub_140504AC0(rob_chr); } @@ -8969,7 +9087,7 @@ static bool sub_14053ACA0(rob_chara* rob_chr, int32_t hand) { float_t scale = adjust_scale / chara_scale; adjust_data.scale = scale; adjust_data.item_scale = scale; // X - rob_chara_set_data_adjust_mat(rob_chr, &adjust_data, false); + rob_chr->set_data_adjust_mat(&adjust_data, false); int32_t v15 = 0; bool solve_ik = true; @@ -9543,10 +9661,6 @@ static bool rob_chara_hands_adjust(rob_chara* rob_chr) { return v2; } -static bool sub_14053B530(rob_chara* rob_chr) { - return sub_14053B580(rob_chr, 2) | sub_14053B580(rob_chr, 3); -} - static float_t sub_140406E90(bone_data* a1, bone_data* a2, float_t a3, vec3* a4) { vec3 v18 = 0.0f; mat4_mult_vec3_trans(a1->node[3].mat, &v18, &v18); @@ -9659,90 +9773,6 @@ static void sub_14053B260(rob_chara* rob_chr) { sub_140418810(rob_chr->bone_data, dword_140A2DDB0, dword_140A2DD90); } -static void rob_chara_bone_data_set_left_hand_scale(rob_chara_bone_data* rob_bone_data, float_t scale) { - mat4* kl_te_wj_mat = rob_chara_bone_data_get_mats_mat(rob_bone_data, ROB_BONE_KL_TE_L_WJ); - if (!kl_te_wj_mat) - return; - - vec3 trans; - mat4_get_translation(kl_te_wj_mat, &trans); - trans -= trans * scale; - - mat4 mat; - mat4_scale(scale, scale, scale, &mat); - mat4_set_translation(&mat, &trans); - - for (int32_t i = ROB_BONE_KL_TE_L_WJ; i <= ROB_BONE_NL_OYA_C_L_WJ; i++) { - mat4* m = rob_chara_bone_data_get_mats_mat(rob_bone_data, i); - if (m) - mat4_mult(m, &mat, m); - } - - for (int32_t i = MOT_BONE_KL_TE_L_WJ; i <= MOT_BONE_NL_OYA_C_L_WJ; i++) { - bone_node* node = rob_chara_bone_data_get_node(rob_bone_data, i); - if (node) - node->exp_data.scale = { scale, scale, scale }; - } -} - -static void rob_chara_bone_data_set_right_hand_scale(rob_chara_bone_data* rob_bone_data, float_t scale) { - mat4* kl_te_wj_mat = rob_chara_bone_data_get_mats_mat(rob_bone_data, ROB_BONE_KL_TE_R_WJ); - if (!kl_te_wj_mat) - return; - - vec3 trans; - mat4_get_translation(kl_te_wj_mat, &trans); - trans -= trans * scale; - - mat4 mat; - mat4_scale(scale, scale, scale, &mat); - mat4_set_translation(&mat, &trans); - - for (int32_t i = ROB_BONE_KL_TE_R_WJ; i <= ROB_BONE_NL_OYA_C_R_WJ; i++) { - mat4* m = rob_chara_bone_data_get_mats_mat(rob_bone_data, i); - if (m) - mat4_mult(m, &mat, m); - } - - for (int32_t i = MOT_BONE_KL_TE_R_WJ; i <= MOT_BONE_NL_OYA_C_R_WJ; i++) { - bone_node* node = rob_chara_bone_data_get_node(rob_bone_data, i); - if (node) - node->exp_data.scale = { scale, scale, scale }; - } -} - -static void rob_motion_modifier_rob_chara_ctrl(rob_chara* rob_chr) { - sub_14053BEE0(rob_chr); - rob_chara_hands_adjust(rob_chr); - if (!sub_14053B530(rob_chr)) - sub_14053B260(rob_chr); - - float_t left_hand_scale_default = rob_chr->data.adjust_data.left_hand_scale_default; - float_t right_hand_scale_default = rob_chr->data.adjust_data.right_hand_scale_default; - float_t left_hand_scale = rob_chr->data.adjust_data.left_hand_scale; - float_t right_hand_scale = rob_chr->data.adjust_data.right_hand_scale; - - if (left_hand_scale_default > 0.0f) { - if (left_hand_scale <= 0.0f) - left_hand_scale = rob_chr->data.adjust_data.left_hand_scale_default; - else - left_hand_scale *= left_hand_scale_default; - } - - if (right_hand_scale_default > 0.0f) { - if (right_hand_scale <= 0.0f) - right_hand_scale = rob_chr->data.adjust_data.right_hand_scale_default; - else - right_hand_scale *= right_hand_scale_default; - } - - if (left_hand_scale > 0.0f) - rob_chara_bone_data_set_left_hand_scale(rob_chr->bone_data, left_hand_scale); - - if (right_hand_scale > 0.0f) - rob_chara_bone_data_set_right_hand_scale(rob_chr->bone_data, right_hand_scale); -} - static void rob_chara_age_age_ctrl(rob_chara_age_age* arr, int32_t chara_id, int32_t part_id, mat4& mat) { arr[chara_id * 3 + part_id].ctrl(mat); @@ -10226,27 +10256,6 @@ static void sub_14041DAC0(rob_chara_bone_data* a1) { sub_140415B30(&a1->eyelid); } -static void rob_chara_bone_data_interpolate(rob_chara_bone_data* rob_bone_data) { - if (rob_bone_data->motion_loaded.size() < 0) - return; - - sub_14041ABA0(rob_bone_data); - sub_14041DAC0(rob_bone_data); - - for (motion_blend_mot*& i : rob_bone_data->motion_loaded) - motion_blend_mot_interpolate(i); - - bone_database_skeleton_type skeleton_type = rob_bone_data->base_skeleton_type; - motion_blend_mot* v5 = rob_bone_data->motion_loaded.front(); - std::vector* bones = &v5->bone_data.bones; - std::vector* bone_indices = &v5->bone_data.bone_indices; - mot_blend_interpolate(&rob_bone_data->face, bones, bone_indices, skeleton_type); - mot_blend_interpolate(&rob_bone_data->hand_l, bones, bone_indices, skeleton_type); - mot_blend_interpolate(&rob_bone_data->hand_r, bones, bone_indices, skeleton_type); - mot_blend_interpolate(&rob_bone_data->mouth, bones, bone_indices, skeleton_type); - mot_blend_interpolate(&rob_bone_data->eyes, bones, bone_indices, skeleton_type); - mot_blend_interpolate(&rob_bone_data->eyelid, bones, bone_indices, skeleton_type); -} static void rob_chara_bone_data_motion_blend_mot_free(rob_chara_bone_data* rob_bone_data) { rob_chara_bone_data_motion_blend_mot_list_free(rob_bone_data, 0); @@ -10399,7 +10408,7 @@ static void sub_14041BA60(rob_chara_bone_data* rob_bone_data) { sub_1404146F0(&rob_bone_data->motion_loaded.front()->field_0); } -static void rob_chara_bone_data_motion_load(rob_chara_bone_data* rob_bone_data, int32_t motion_id, +static void rob_chara_bone_data_motion_load(rob_chara_bone_data* rob_bone_data, uint32_t motion_id, MotionBlendType blend_type, const bone_database* bone_data, const motion_database* mot_db) { if (!rob_bone_data->motion_loaded.size()) return; @@ -10879,20 +10888,6 @@ void sub_14041B9F0(rob_chara_bone_data* rob_bone_data) { sub_1404146F0(&rob_bone_data->eyelid.field_0); } -static void rob_chara_bone_data_update(rob_chara_bone_data* rob_bone_data, mat4* mat) { - if (!rob_bone_data->motion_loaded.size()) - return; - - for (motion_blend_mot*& i : rob_bone_data->motion_loaded) { - sub_1404117F0(i); - sub_14040FBF0(i, rob_bone_data->ik_scale.ratio0); - } - - sub_1404182B0(rob_bone_data); - sub_14041B9F0(rob_bone_data); - motion_blend_mot_mult_mat(rob_bone_data->motion_loaded.front(), mat); -} - void sub_140506C20(struc_523* a1) { a1->field_0 = 0; a1->field_1 = 0; @@ -10924,11 +10919,11 @@ void sub_140506C20(struc_523* a1) { static void sub_140505C90(struc_264* a1) { a1->field_0 = 0; - a1->field_4 = { 0, {}, -1, 0 }; - a1->field_18 = { 0, {}, -1, 0 }; - a1->field_2C = { 0, {}, -1, 0 }; - a1->field_40 = { 0, {}, -1, 0 }; - a1->field_54 = { 0, {}, -1, 0 }; + a1->field_4 = { 0, {}, (uint32_t)-1, 0 }; + a1->field_18 = { 0, {}, (uint32_t)-1, 0 }; + a1->field_2C = { 0, {}, (uint32_t)-1, 0 }; + a1->field_40 = { 0, {}, (uint32_t)-1, 0 }; + a1->field_54 = { 0, {}, (uint32_t)-1, 0 }; a1->field_68 = 0; a1->field_6C = 0; a1->field_70 = 0; @@ -11208,7 +11203,7 @@ static float_t sub_140512F60(rob_chara_item_equip* rob_itm_equip) { } static void rob_chara_add_motion_reset_data(rob_chara* rob_chr, - int32_t motion_id, float_t frame, int32_t iterations) { + uint32_t motion_id, float_t frame, int32_t iterations) { if (motion_id != -1) rob_chr->item_equip->add_motion_reset_data(motion_id, frame, iterations); } @@ -11235,64 +11230,25 @@ static object_info rob_chara_get_head_object(rob_chara* rob_chr, int32_t head_ob static object_info rob_chara_get_object_info(rob_chara* rob_chr, item_id id) { return rob_chr->item_equip->get_object_info(id); } + static void rob_chara_load_default_motion(rob_chara* rob_chr, const bone_database* bone_data, const motion_database* mot_db) { - int32_t motion_id = rob_chr->get_rob_cmn_mottbl_motion_id(0); + uint32_t motion_id = rob_chr->get_rob_cmn_mottbl_motion_id(0); rob_chara_load_default_motion_sub(rob_chr, 1, motion_id, bone_data, mot_db); } -static void rob_chara_bone_data_load_face_motion(rob_chara_bone_data* rob_bone_data, - int32_t motion_id, const motion_database* mot_db) { - sub_14041AD90(rob_bone_data); - sub_140412F20(&rob_bone_data->face, &rob_bone_data->motion_loaded.front()->bone_data.bones); - sub_1404146F0(&rob_bone_data->face.field_0); - mot_blend_load_motion(&rob_bone_data->face, motion_id, mot_db); -} - -static void rob_chara_bone_data_load_hand_l_motion(rob_chara_bone_data* rob_bone_data, - int32_t motion_id, const motion_database* mot_db) { - sub_140412F20(&rob_bone_data->hand_l, &rob_bone_data->motion_loaded.front()->bone_data.bones); - mot_blend_load_motion(&rob_bone_data->hand_l, motion_id, mot_db); -} - -static void rob_chara_bone_data_load_hand_r_motion(rob_chara_bone_data* rob_bone_data, - int32_t motion_id, const motion_database* mot_db) { - sub_140412F20(&rob_bone_data->hand_r, &rob_bone_data->motion_loaded.front()->bone_data.bones); - mot_blend_load_motion(&rob_bone_data->hand_r, motion_id, mot_db); -} - -static void rob_chara_bone_data_load_mouth_motion(rob_chara_bone_data* rob_bone_data, - int32_t motion_id, const motion_database* mot_db) { - sub_140412F20(&rob_bone_data->mouth, &rob_bone_data->motion_loaded.front()->bone_data.bones); - mot_blend_load_motion(&rob_bone_data->mouth, motion_id, mot_db); -} - -static void rob_chara_bone_data_load_eyes_motion(rob_chara_bone_data* rob_bone_data, - int32_t motion_id, const motion_database* mot_db) { - sub_140412F20(&rob_bone_data->eyes, &rob_bone_data->motion_loaded.front()->bone_data.bones); - mot_blend_load_motion(&rob_bone_data->eyes, motion_id, mot_db); -} - -static void rob_chara_bone_data_load_eyelid_motion(rob_chara_bone_data* rob_bone_data, - int32_t motion_id, const motion_database* mot_db) { - sub_14041AD50(rob_bone_data); - sub_140412F20(&rob_bone_data->eyelid, &rob_bone_data->motion_loaded.front()->bone_data.bones); - sub_1404146F0(&rob_bone_data->eyelid.field_0); - mot_blend_load_motion(&rob_bone_data->eyelid, motion_id, mot_db); -} - static void sub_140419820(rob_chara_bone_data* rob_bone_data, int32_t skeleton_select) { sub_140412E10(rob_bone_data->motion_loaded.front(), skeleton_select); } static void rob_chara_load_default_motion_sub(rob_chara* rob_chr, int32_t skeleton_select, - int32_t motion_id, const bone_database* bone_data, const motion_database* mot_db) { - rob_chara_bone_data_load_face_motion(rob_chr->bone_data, -1, mot_db); - rob_chara_bone_data_load_hand_l_motion(rob_chr->bone_data, -1, mot_db); - rob_chara_bone_data_load_hand_r_motion(rob_chr->bone_data, -1, mot_db); - rob_chara_bone_data_load_mouth_motion(rob_chr->bone_data, -1, mot_db); - rob_chara_bone_data_load_eyes_motion(rob_chr->bone_data, -1, mot_db); - rob_chara_bone_data_load_eyelid_motion(rob_chr->bone_data, -1, mot_db); + uint32_t motion_id, const bone_database* bone_data, const motion_database* mot_db) { + rob_chr->bone_data->load_face_motion(-1, mot_db); + rob_chr->bone_data->load_hand_l_motion(-1, mot_db); + rob_chr->bone_data->load_hand_r_motion(-1, mot_db); + rob_chr->bone_data->load_mouth_motion(-1, mot_db); + rob_chr->bone_data->load_eyes_motion(-1, mot_db); + rob_chr->bone_data->load_eyelid_motion(-1, mot_db); rob_chara_bone_data_motion_load(rob_chr->bone_data, motion_id, MOTION_BLEND_FREEZE, bone_data, mot_db); rob_chr->bone_data->set_frame(0.0f); sub_14041C680(rob_chr->bone_data, false); @@ -11304,9 +11260,9 @@ static void rob_chara_load_default_motion_sub(rob_chara* rob_chr, int32_t skelet rob_chara_bone_data_set_rot_y(rob_chr->bone_data, 0.0f); rob_chara_bone_data_set_motion_duration(rob_chr->bone_data, 0.0f, 1.0f, 1.0f); sub_14041D310(rob_chr->bone_data, 0.0f, 0.0f, 2); - rob_chara_bone_data_interpolate(rob_chr->bone_data); - rob_chara_bone_data_update(rob_chr->bone_data, 0); - sub_140509D30(rob_chr); + rob_chr->bone_data->interpolate(); + rob_chr->bone_data->update(0); + rob_chr->sub_140509D30(); sub_140419820(rob_chr->bone_data, skeleton_select); } @@ -11557,6 +11513,18 @@ bool pv_osage_manager_array_get_disp() { return disp; } +bool pv_osage_manager_array_get_disp(int32_t chara_id) { + return pv_osage_manager_array_get(chara_id)->GetDisp(); +} + +void pv_osage_manager_array_set_motion_ids( + int32_t chara_id, const std::vector& motion_ids) { + std::vector set_motion; + for (const uint32_t& i : motion_ids) + set_motion.push_back({ i }); + pv_osage_manager_array_get(chara_id)->SetPvSetMotion(set_motion); +} + void pv_osage_manager_array_set_not_reset_true() { for (int32_t i = 0; i < ROB_CHARA_COUNT; i++) pv_osage_manager_array_get(i)->SetNotReset(true); @@ -11646,6 +11614,13 @@ bool task_rob_manager_hide_task() { return task_rob_manager->HideTask(); } +bool task_rob_manager_get_wait(int32_t chara_id) { + if (chara_id < 0 || chara_id >= ROB_CHARA_COUNT) + return false; + + return task_rob_manager->GetWait(&rob_chara_array[chara_id]); +} + bool task_rob_manager_run_task() { return task_rob_manager->RunTask(); } @@ -12402,6 +12377,62 @@ void rob_chara_bone_data::reset() { sleeve_adjust.reset(); } +void rob_chara_bone_data::interpolate() { + if (motion_loaded.size() < 0) + return; + + sub_14041ABA0(this); + sub_14041DAC0(this); + + for (motion_blend_mot*& i : motion_loaded) + motion_blend_mot_interpolate(i); + + bone_database_skeleton_type skeleton_type = base_skeleton_type; + motion_blend_mot* v5 = motion_loaded.front(); + std::vector* bones = &v5->bone_data.bones; + std::vector* bone_indices = &v5->bone_data.bone_indices; + mot_blend_interpolate(&face, bones, bone_indices, skeleton_type); + mot_blend_interpolate(&hand_l, bones, bone_indices, skeleton_type); + mot_blend_interpolate(&hand_r, bones, bone_indices, skeleton_type); + mot_blend_interpolate(&mouth, bones, bone_indices, skeleton_type); + mot_blend_interpolate(&eyes, bones, bone_indices, skeleton_type); + mot_blend_interpolate(&eyelid, bones, bone_indices, skeleton_type); +} + +void rob_chara_bone_data::load_eyelid_motion(uint32_t motion_id, const motion_database* mot_db) { + sub_14041AD50(this); + sub_140412F20(&eyelid, &motion_loaded.front()->bone_data.bones); + sub_1404146F0(&eyelid.field_0); + mot_blend_load_motion(&eyelid, motion_id, mot_db); +} + +void rob_chara_bone_data::load_eyes_motion(uint32_t motion_id, const motion_database* mot_db) { + sub_140412F20(&eyes, &motion_loaded.front()->bone_data.bones); + mot_blend_load_motion(&eyes, motion_id, mot_db); +} + +void rob_chara_bone_data::load_face_motion(uint32_t motion_id, const motion_database* mot_db) { + sub_14041AD90(this); + sub_140412F20(&face, &motion_loaded.front()->bone_data.bones); + sub_1404146F0(&face.field_0); + mot_blend_load_motion(&face, motion_id, mot_db); +} + +void rob_chara_bone_data::load_hand_l_motion(uint32_t motion_id, const motion_database* mot_db) { + sub_140412F20(&hand_l, &motion_loaded.front()->bone_data.bones); + mot_blend_load_motion(&hand_l, motion_id, mot_db); +} + +void rob_chara_bone_data::load_hand_r_motion(uint32_t motion_id, const motion_database* mot_db) { + sub_140412F20(&hand_r, &motion_loaded.front()->bone_data.bones); + mot_blend_load_motion(&hand_r, motion_id, mot_db); +} + +void rob_chara_bone_data::load_mouth_motion(uint32_t motion_id, const motion_database* mot_db) { + sub_140412F20(&mouth, &motion_loaded.front()->bone_data.bones); + mot_blend_load_motion(&mouth, motion_id, mot_db); +} + void rob_chara_bone_data::set_disable_eye_motion(bool value) { disable_eye_motion = value; } @@ -12450,6 +12481,177 @@ void rob_chara_bone_data::set_motion_playback_state(mot_play_frame_data_playback motion_loaded.front()->mot_play_data.frame_data.playback_state = value; } +void rob_chara_bone_data::update(mat4* mat) { + if (!motion_loaded.size()) + return; + + for (motion_blend_mot*& i : motion_loaded) { + sub_1404117F0(i); + sub_14040FBF0(i, ik_scale.ratio0); + } + + sub_1404182B0(this); + sub_14041B9F0(this); + motion_blend_mot_mult_mat(motion_loaded.front(), mat); +} + +static void sub_1404156B0(mot_play_data* a1) { + mot_play_frame_data* frame_data = &a1->frame_data; + frame_data->looped = false; + if (a1->loop_frames_enabled && a1->loop_frames >= 0.0f) + a1->loop_frames -= frame_data->step; + + switch (frame_data->playback_state) { + case MOT_PLAY_FRAME_DATA_PLAYBACK_FORWARD: { + frame_data->frame += frame_data->step; + if (frame_data->max_frame >= 0.0f && frame_data->frame > frame_data->max_frame) + frame_data->frame = frame_data->max_frame; + + float_t last_frame = frame_data->last_frame; + switch (frame_data->loop_state) { + case MOT_PLAY_FRAME_DATA_LOOP_ONCE: + default: + frame_data->frame = min_def(frame_data->frame, frame_data->frame_count); + break; + case MOT_PLAY_FRAME_DATA_LOOP_CONTINUOUS: { + if (frame_data->loop_end >= 0.0f && frame_data->loop_end <= last_frame) + last_frame = frame_data->loop_end; + + if (frame_data->frame < last_frame) + break; + + if (frame_data->loop_count > 0 && a1->loop_index >= frame_data->loop_count) { + frame_data->loop_state = MOT_PLAY_FRAME_DATA_LOOP_NONE; + return; + } + + float_t frame = frame_data->frame - last_frame; + float_t loop_range = last_frame - frame_data->loop_begin; + if (frame >= loop_range && loop_range > 0.0f) + frame = fmodf(frame, loop_range); + frame_data->frame = frame + frame_data->loop_begin; + frame_data->looped = true; + a1->loop_index++; + } break; + case MOT_PLAY_FRAME_DATA_LOOP_RESET: { + if (frame_data->loop_end >= 0.0f && frame_data->loop_end <= last_frame) + last_frame = frame_data->loop_end; + + if (last_frame >= frame_data->frame) + break; + + if (frame_data->loop_count > 0 && a1->loop_index >= frame_data->loop_count) { + frame_data->loop_state = MOT_PLAY_FRAME_DATA_LOOP_NONE; + return; + } + + frame_data->frame = frame_data->loop_begin; + frame_data->looped = true; + a1->loop_index++; + } break; + case MOT_PLAY_FRAME_DATA_LOOP_REVERSE: { + if (frame_data->frame <= last_frame) + return; + + if (frame_data->loop_count > 0 && a1->loop_index <= frame_data->loop_count) { + frame_data->loop_state = MOT_PLAY_FRAME_DATA_LOOP_NONE; + return; + } + + float_t frame = frame_data->frame - last_frame; + if (frame >= last_frame && last_frame > 0.0f) + frame = fmodf(frame, last_frame); + frame_data->frame = last_frame - frame; + frame_data->playback_state = MOT_PLAY_FRAME_DATA_PLAYBACK_BACKWARD; + frame_data->looped = true; + a1->loop_index++; + } break; + } + } break; + case MOT_PLAY_FRAME_DATA_PLAYBACK_BACKWARD: { + float_t last_frame = frame_data->last_frame; + frame_data->frame -= frame_data->step; + switch (frame_data->loop_state) { + case MOT_PLAY_FRAME_DATA_LOOP_ONCE: + default: + frame_data->frame = max_def(frame_data->frame, 0.0f); + break; + case MOT_PLAY_FRAME_DATA_LOOP_CONTINUOUS: { + float_t loop_begin = 0.0f; + if (frame_data->loop_begin >= 0.0f) + loop_begin = frame_data->loop_begin; + + if (frame_data->frame > loop_begin) + break; + + if (frame_data->loop_count > 0 && a1->loop_index >= frame_data->loop_count) { + frame_data->loop_state = MOT_PLAY_FRAME_DATA_LOOP_NONE; + return; + } + + if (frame_data->loop_end >= 0.0f && frame_data->loop_end <= last_frame) + last_frame = frame_data->loop_end; + + float_t loop_range = last_frame - loop_begin; + float_t frame = loop_begin - frame_data->frame; + if (frame >= loop_range && loop_range > 0.0f) + frame = fmodf(frame, loop_range); + frame_data->frame = last_frame - frame; + frame_data->looped = true; + a1->loop_index++; + } break; + case MOT_PLAY_FRAME_DATA_LOOP_RESET: { + float_t loop_begin = 0.0f; + if (frame_data->loop_begin >= 0.0f) + loop_begin = frame_data->loop_begin; + + if (frame_data->frame >= loop_begin) + break; + + if (frame_data->loop_count > 0 && a1->loop_index >= frame_data->loop_count) { + frame_data->loop_state = MOT_PLAY_FRAME_DATA_LOOP_NONE; + return; + } + + if (frame_data->loop_end >= 0.0f && frame_data->loop_end <= last_frame) + last_frame = frame_data->loop_end; + frame_data->frame = last_frame; + frame_data->looped = true; + a1->loop_index++; + } break; + case MOT_PLAY_FRAME_DATA_LOOP_REVERSE: { + if (frame_data->frame >= 0.0f) + return; + + if (frame_data->loop_count > 0 && a1->loop_index >= frame_data->loop_count) { + frame_data->loop_state = MOT_PLAY_FRAME_DATA_LOOP_NONE; + return; + } + + float_t frame = -frame_data->frame; + if (last_frame > 0.0f && frame >= last_frame) + frame = fmodf(frame, last_frame); + frame_data->frame = frame; + frame_data->playback_state = MOT_PLAY_FRAME_DATA_PLAYBACK_FORWARD; + frame_data->looped = true; + a1->loop_index++; + } break; + } + } break; + case MOT_PLAY_FRAME_DATA_PLAYBACK_EXTERNAL: { + if (a1->ext_frame) + frame_data->frame = *a1->ext_frame; + if (a1->ext_step) + frame_data->step = *a1->ext_step; + } break; + } +} + +void rob_chara_bone_data::sub_14041DBA0() { + for (motion_blend_mot*& i : motion_loaded) + sub_1404156B0(&i->mot_play_data); +} + rob_chara_pv_data::rob_chara_pv_data() { type = ROB_CHARA_TYPE_2; field_4 = true; @@ -12521,7 +12723,7 @@ rob_chara_item_equip_object::~rob_chara_item_equip_object() { } void rob_chara_item_equip_object::add_motion_reset_data( - int32_t motion_id, float_t frame, int32_t osage_iterations) { + uint32_t motion_id, float_t frame, int32_t osage_iterations) { if (osage_iterations > 0) rob_chara_item_equip_object_ctrl_iterate_nodes(this, osage_iterations); @@ -12607,9 +12809,9 @@ int32_t rob_chara_item_equip_object::get_bone_index(const char* name, const bone int32_t bone_index = bone_data->get_skeleton_motion_bone_index( bone_database_skeleton_type_to_string(BONE_DATABASE_SKELETON_COMMON), name); if (bone_index == -1) - for (ex_data_name_bone_index& i : ex_bones) - if (!str_utils_compare(name, i.name)) - return 0x8000 | i.bone_index; + for (auto& i : ex_bones) + if (!str_utils_compare(name, i.first)) + return 0x8000 | i.second; return bone_index; } @@ -12689,7 +12891,7 @@ void rob_chara_item_equip_object::init_ex_data_bone_nodes(obj_skin_ex_data* ex_d const char** bone_name_array = ex_data->bone_name_array; for (uint32_t i = 0; i < num_bone_name; i++) { bone_nodes[i].set_name_mat_ex_data_mat(bone_name_array[i], &bone_mats[i], &mats[i]); - ex_bones.push_back({ bone_name_array[i], i }); + ex_bones.push_back(bone_name_array[i], i); } } } @@ -12727,7 +12929,7 @@ void rob_chara_item_equip_object::load_ex_data(obj_skin_ex_data* ex_data, if (!ex_data->block_array) return; - std::vector> v129; + prj::vector_pair v129; std::map v138; clear_ex_data(); @@ -12990,7 +13192,7 @@ void rob_chara_item_equip_object::set_collision_target_osage( } } -void rob_chara_item_equip_object::set_motion_reset_data(int32_t motion_id, float_t frame) { +void rob_chara_item_equip_object::set_motion_reset_data(uint32_t motion_id, float_t frame) { for (ExOsageBlock*& i : osage_blocks) i->SetMotionResetData(motion_id, frame); @@ -12998,7 +13200,7 @@ void rob_chara_item_equip_object::set_motion_reset_data(int32_t motion_id, float i->SetMotionResetData(motion_id, frame); } -void rob_chara_item_equip_object::set_motion_skin_param(int8_t chara_id, int32_t motion_id, int32_t frame) { +void rob_chara_item_equip_object::set_motion_skin_param(int8_t chara_id, uint32_t motion_id, int32_t frame) { if (obj_info.is_null()) return; @@ -13195,7 +13397,7 @@ rob_chara_item_equip::~rob_chara_item_equip() { } } -void rob_chara_item_equip::add_motion_reset_data(int32_t motion_id, float_t frame, int32_t iterations) { +void rob_chara_item_equip::add_motion_reset_data(uint32_t motion_id, float_t frame, int32_t iterations) { for (int32_t i = first_item_equip_object; i < max_item_equip_object; i++) item_equip_object[i].add_motion_reset_data(motion_id, frame, iterations); } @@ -13423,14 +13625,14 @@ void rob_chara_item_equip::set_item_equip_range(bool value) { } } -void rob_chara_item_equip::set_motion_reset_data(int32_t motion_id, float_t frame) { +void rob_chara_item_equip::set_motion_reset_data(uint32_t motion_id, float_t frame) { for (int32_t i = first_item_equip_object; i < max_item_equip_object; i++) item_equip_object[i].set_motion_reset_data(motion_id, frame); task_wind->ptr->reset(); } -void rob_chara_item_equip::set_motion_skin_param(int8_t chara_id, int32_t motion_id, int32_t frame) { +void rob_chara_item_equip::set_motion_skin_param(int8_t chara_id, uint32_t motion_id, int32_t frame) { for (int32_t i = ITEM_KAMI; i < ITEM_ITEM16; i++) item_equip_object[i].set_motion_skin_param(chara_id, motion_id, frame); } @@ -15038,7 +15240,7 @@ struc_209::~struc_209() { } rob_chara_data::rob_chara_data() : field_0(), field_1(), field_2(), field_3(), field_4(), miku_rot(), -adjust_data(), field_3D90(), field_3D94(), field_3D98(), field_3D9A(), field_3D9C(), field_3D9D(), field_3DA0(), +adjust_data(), field_3D90(), field_3D94(), field_3D98(), field_3D9A(), field_3D9C(), field_3DA0(), field_3DA4(), field_3DA8(), field_3DB0(), field_3DB8(), field_3DBC(), field_3DC0(), field_3DC4(), field_3DC8(), field_3DCC(), field_3DD0(), field_3DD4(), field_3DD8(), field_3DDC(), field_3DE0(), arm_adjust_scale() { @@ -15384,14 +15586,14 @@ bool OpdMaker::Data::CheckOpdiFilesNotReady() { return false; } -const void* OpdMaker::Data::GetOpdiFileData(object_info obj_info, int32_t motion_id) { +const void* OpdMaker::Data::GetOpdiFileData(object_info obj_info, uint32_t motion_id) { auto elem = opdi_files.find({ obj_info, motion_id }); if (elem != opdi_files.end()) return elem->second->get_data(); return 0; } -bool OpdMaker::Data::IsValidOpdiFile(rob_chara* rob_chr, int32_t motion_id) { +bool OpdMaker::Data::IsValidOpdiFile(rob_chara* rob_chr, uint32_t motion_id) { if (!rob_chr) return false; @@ -15957,8 +16159,8 @@ static void sub_14053D360(struc_527* a1) { rob_chr->set_bone_data_frame(a1->frame); sub_14053E170(a1); - rob_chara_adjust_ctrl(a1->rob_chr); - rob_motion_modifier_rob_chara_ctrl(a1->rob_chr); + a1->rob_chr->adjust_ctrl(); + a1->rob_chr->rob_motion_modifier_ctrl(); rob_disp_rob_chara_ctrl(a1->rob_chr); } @@ -16033,7 +16235,7 @@ void OpdMaker::Ctrl() { return; } - int32_t motion_id = (*motion_ids)[index]; + uint32_t motion_id = (*motion_ids)[index]; if (motion_id == -1) break; @@ -16282,7 +16484,7 @@ void OpdMaker::Reset() { thread = 0; } -bool OpdMaker::SetOsagePlayInitData(int32_t motion_id) { +bool OpdMaker::SetOsagePlayInitData(uint32_t motion_id) { rob_chara_item_equip* rob_itm_equip = rob_chr->item_equip; for (int32_t i = ITEM_KAMI; i < ITEM_MAX; i++) { rob_chara_item_equip_object* itm_eq_obj = rob_itm_equip->get_item_equip_object((item_id)i); @@ -16630,7 +16832,7 @@ void OsagePlayDataManager::AppendCharaMotionId(rob_chara* rob_chr, const std::ve continue; for (uint32_t j : motion_ids) - opd_req_data.push_back({ itm_eq_obj->obj_info, j }); + opd_req_data.push_back(itm_eq_obj->obj_info, j); } } @@ -17772,10 +17974,10 @@ osage_set_motion::~osage_set_motion() { } -void osage_set_motion::init_frame(int32_t motion_id, float_t frame, int32_t stage_index) { +void osage_set_motion::init_frame(uint32_t motion_id, float_t frame, int32_t stage_index) { frames.clear(); this->motion_id = motion_id; - frames.push_back({ frame, stage_index }); + frames.push_back(frame, stage_index); } skeleton_rotation_offset::skeleton_rotation_offset() : x(), y(), z() { @@ -17852,7 +18054,7 @@ void PvOsageManager::Disp() { } -void PvOsageManager::AddMotionFrameResetData(int32_t stage_index, int32_t motion_id, float_t frame, int32_t iterations) { +void PvOsageManager::AddMotionFrameResetData(int32_t stage_index, uint32_t motion_id, float_t frame, int32_t iterations) { if (!CheckResetFrameNotFound(motion_id, frame)) return; @@ -17863,8 +18065,8 @@ void PvOsageManager::AddMotionFrameResetData(int32_t stage_index, int32_t motion rob_chara* rob_chr = rob_chara_array_get(chara_id); struc_527 v17(rob_chr, stage_index, motion_id, frame, aft_bone_data, aft_mot_db); - rob_chara_adjust_ctrl(rob_chr); - rob_motion_modifier_rob_chara_ctrl(rob_chr); + rob_chr->adjust_ctrl(); + rob_chr->rob_motion_modifier_ctrl(); if (iterations < 0) { iterations = 60; @@ -17881,7 +18083,7 @@ void PvOsageManager::AddMotionFrameResetData(int32_t stage_index, int32_t motion sub_140555120(rob_chr, (rob_osage_parts)i, false); } -bool PvOsageManager::CheckResetFrameNotFound(int32_t motion_id, float_t frame) { +bool PvOsageManager::CheckResetFrameNotFound(uint32_t motion_id, float_t frame) { return reset_frames_list.find(frame) == reset_frames_list.end(); } @@ -17953,7 +18155,7 @@ void PvOsageManager::sub_1404F77E0() { osage_set_motion.clear(); - int32_t motion_id = -1; + uint32_t motion_id = -1; ::osage_set_motion* set_motion = 0; for (pv_data_set_motion& i : pv_set_motion) { if (motion_id != i.motion_id) { @@ -18035,7 +18237,7 @@ void PvOsageManager::sub_1404F83A0(::osage_set_motion* a2) { if (!a2->frames.size()) return; - int32_t motion_id = a2->motion_id; + uint32_t motion_id = a2->motion_id; bool v32 = false; std::vector v34; @@ -18108,7 +18310,7 @@ void PvOsageManager::sub_1404F83A0(::osage_set_motion* a2) { sub_140555120(rob_chr, (rob_osage_parts)i, false); } -void PvOsageManager::sub_1404F88A0(uint32_t stage_index, int32_t motion_id, float_t frame) { +void PvOsageManager::sub_1404F88A0(uint32_t stage_index, uint32_t motion_id, float_t frame) { if (!CheckResetFrameNotFound(motion_id, frame)) return; @@ -18122,7 +18324,7 @@ void PvOsageManager::sub_1404F8AA0() { return; ::osage_set_motion& v4 = osage_set_motion.back(); - int32_t motion_id = v4.motion_id; + uint32_t motion_id = v4.motion_id; if (motion_id == -1) return; @@ -18513,7 +18715,7 @@ bool TaskRobCollision::Ctrl() { /*if (sub_140227DD0())*/ { for (rob_chara*& i : ctrl_chara) { - sub_140509D30(i); + i->sub_140509D30(); //sub_14050F4D0(i); //sub_14050E930(i); } @@ -18645,9 +18847,9 @@ bool TaskRobInfo::Ctrl() { AppendCtrlCharaList(i); init_chara.clear(); - /*for (rob_chara*& i : ctrl_chara) + for (rob_chara*& i : ctrl_chara) if (i && i->data.field_3 >= 0) - rob_chara_ctrl_rob_info(i);*/ + i->rob_info_ctrl(); free_chara.clear(); return false; @@ -19331,6 +19533,33 @@ void TaskRobManager::FreeLoadedCharaList(int8_t* chara_id) { i++; } +bool TaskRobManager::GetWait(rob_chara* rob_chr) { + if (!app::TaskWork::CheckTaskReady(this)) + return false; + + int32_t chara_id = rob_chr->chara_id; + if (chara_id < 0 || chara_id >= ROB_CHARA_COUNT) + return false; + + for (auto& i : init_chara) + if (i->chara_id == chara_id) + return true; + + for (auto& i : load_chara) + if (i->chara_id == chara_id) + return true; + + for (auto& i : loaded_chara) + if (i->chara_id == chara_id) + return true; + + for (auto& i : free_chara) + if (i->chara_id == chara_id) + return true; + + return true; +} + TaskRobMotionModifier::TaskRobMotionModifier() { } @@ -19358,7 +19587,7 @@ bool TaskRobMotionModifier::Ctrl() { for (rob_chara*& i : ctrl_chara) if (i) - rob_motion_modifier_rob_chara_ctrl(i); + i->rob_motion_modifier_ctrl(); free_chara.clear(); return false; @@ -19418,163 +19647,6 @@ bool TaskRobPrepareControl::Init() { return true; } -static void sub_1404156B0(mot_play_data* a1) { - mot_play_frame_data* frame_data = &a1->frame_data; - frame_data->looped = false; - if (a1->loop_frames_enabled && a1->loop_frames >= 0.0f) - a1->loop_frames -= frame_data->step; - - switch (frame_data->playback_state) { - case MOT_PLAY_FRAME_DATA_PLAYBACK_FORWARD: { - frame_data->frame += frame_data->step; - if (frame_data->max_frame >= 0.0f && frame_data->frame > frame_data->max_frame) - frame_data->frame = frame_data->max_frame; - - float_t last_frame = frame_data->last_frame; - switch (frame_data->loop_state) { - case MOT_PLAY_FRAME_DATA_LOOP_ONCE: - default: - frame_data->frame = min_def(frame_data->frame, frame_data->frame_count); - break; - case MOT_PLAY_FRAME_DATA_LOOP_CONTINUOUS: { - if (frame_data->loop_end >= 0.0f && frame_data->loop_end <= last_frame) - last_frame = frame_data->loop_end; - - if (frame_data->frame < last_frame) - break; - - if (frame_data->loop_count > 0 && a1->loop_index >= frame_data->loop_count) { - frame_data->loop_state = MOT_PLAY_FRAME_DATA_LOOP_NONE; - return; - } - - float_t frame = frame_data->frame - last_frame; - float_t loop_range = last_frame - frame_data->loop_begin; - if (frame >= loop_range && loop_range > 0.0f) - frame = fmodf(frame, loop_range); - frame_data->frame = frame + frame_data->loop_begin; - frame_data->looped = true; - a1->loop_index++; - } break; - case MOT_PLAY_FRAME_DATA_LOOP_RESET: { - if (frame_data->loop_end >= 0.0f && frame_data->loop_end <= last_frame) - last_frame = frame_data->loop_end; - - if (last_frame >= frame_data->frame) - break; - - if (frame_data->loop_count > 0 && a1->loop_index >= frame_data->loop_count) { - frame_data->loop_state = MOT_PLAY_FRAME_DATA_LOOP_NONE; - return; - } - - frame_data->frame = frame_data->loop_begin; - frame_data->looped = true; - a1->loop_index++; - } break; - case MOT_PLAY_FRAME_DATA_LOOP_REVERSE: { - if (frame_data->frame <= last_frame) - return; - - if (frame_data->loop_count > 0 && a1->loop_index <= frame_data->loop_count) { - frame_data->loop_state = MOT_PLAY_FRAME_DATA_LOOP_NONE; - return; - } - - float_t frame = frame_data->frame - last_frame; - if (frame >= last_frame && last_frame > 0.0f) - frame = fmodf(frame, last_frame); - frame_data->frame = last_frame - frame; - frame_data->playback_state = MOT_PLAY_FRAME_DATA_PLAYBACK_BACKWARD; - frame_data->looped = true; - a1->loop_index++; - } break; - } - } break; - case MOT_PLAY_FRAME_DATA_PLAYBACK_BACKWARD: { - float_t last_frame = frame_data->last_frame; - frame_data->frame -= frame_data->step; - switch (frame_data->loop_state) { - case MOT_PLAY_FRAME_DATA_LOOP_ONCE: - default: - frame_data->frame = max_def(frame_data->frame, 0.0f); - break; - case MOT_PLAY_FRAME_DATA_LOOP_CONTINUOUS: { - float_t loop_begin = 0.0f; - if (frame_data->loop_begin >= 0.0f) - loop_begin = frame_data->loop_begin; - - if (frame_data->frame > loop_begin) - break; - - if (frame_data->loop_count > 0 && a1->loop_index >= frame_data->loop_count) { - frame_data->loop_state = MOT_PLAY_FRAME_DATA_LOOP_NONE; - return; - } - - if (frame_data->loop_end >= 0.0f && frame_data->loop_end <= last_frame) - last_frame = frame_data->loop_end; - - float_t loop_range = last_frame - loop_begin; - float_t frame = loop_begin - frame_data->frame; - if (frame >= loop_range && loop_range > 0.0f) - frame = fmodf(frame, loop_range); - frame_data->frame = last_frame - frame; - frame_data->looped = true; - a1->loop_index++; - } break; - case MOT_PLAY_FRAME_DATA_LOOP_RESET: { - float_t loop_begin = 0.0f; - if (frame_data->loop_begin >= 0.0f) - loop_begin = frame_data->loop_begin; - - if (frame_data->frame >= loop_begin) - break; - - if (frame_data->loop_count > 0 && a1->loop_index >= frame_data->loop_count) { - frame_data->loop_state = MOT_PLAY_FRAME_DATA_LOOP_NONE; - return; - } - - if (frame_data->loop_end >= 0.0f && frame_data->loop_end <= last_frame) - last_frame = frame_data->loop_end; - frame_data->frame = last_frame; - frame_data->looped = true; - a1->loop_index++; - } break; - case MOT_PLAY_FRAME_DATA_LOOP_REVERSE: { - if (frame_data->frame >= 0.0f) - return; - - if (frame_data->loop_count > 0 && a1->loop_index >= frame_data->loop_count) { - frame_data->loop_state = MOT_PLAY_FRAME_DATA_LOOP_NONE; - return; - } - - float_t frame = -frame_data->frame; - if (last_frame > 0.0f && frame >= last_frame) - frame = fmodf(frame, last_frame); - frame_data->frame = frame; - frame_data->playback_state = MOT_PLAY_FRAME_DATA_PLAYBACK_FORWARD; - frame_data->looped = true; - a1->loop_index++; - } break; - } - } break; - case MOT_PLAY_FRAME_DATA_PLAYBACK_EXTERNAL: { - if (a1->ext_frame) - frame_data->frame = *a1->ext_frame; - if (a1->ext_step) - frame_data->step = *a1->ext_step; - } break; - } -} - -static void sub_14041DBA0(rob_chara_bone_data* rob_bone_data) { - for (motion_blend_mot*& i : rob_bone_data->motion_loaded) - sub_1404156B0(&i->mot_play_data); -} - static void sub_14053F300(RobPartialMotion* a1) { if (!sub_14053F2B0(a1)) return; @@ -19643,7 +19715,7 @@ static void sub_14053F300(RobPartialMotion* a1) { static void sub_140548660(rob_chara* rob_chr) { rob_chr->data.motion.frame_data.prev_frame = rob_chr->data.motion.frame_data.frame; - sub_14041DBA0(rob_chr->bone_data); + rob_chr->bone_data->sub_14041DBA0(); if (rob_chr->data.motion.field_28 < 0) rob_chr->bone_data->set_frame(rob_chr->data.motion.frame_data.last_set_frame); rob_chr->data.motion.frame_data.frame = rob_chr->bone_data->get_frame(); diff --git a/src/CRE/rob/rob.hpp b/src/CRE/rob/rob.hpp index 7933b8dc..1475b85e 100644 --- a/src/CRE/rob/rob.hpp +++ b/src/CRE/rob/rob.hpp @@ -913,7 +913,7 @@ struct mot_key_data { const mot_data* mot_data; bone_database_skeleton_type skeleton_type; int32_t skeleton_select; - int32_t motion_id; + uint32_t motion_id; float_t frame; struc_369 field_68; @@ -1330,6 +1330,13 @@ struct rob_chara_bone_data { float_t get_frame(); float_t get_frame_count(); bool get_motion_has_looped(); + void interpolate(); + void load_eyes_motion(uint32_t motion_id, const motion_database* mot_db); + void load_face_motion(uint32_t motion_id, const motion_database* mot_db); + void load_eyelid_motion(uint32_t motion_id, const motion_database* mot_db); + void load_hand_l_motion(uint32_t motion_id, const motion_database* mot_db); + void load_hand_r_motion(uint32_t motion_id, const motion_database* mot_db); + void load_mouth_motion(uint32_t motion_id, const motion_database* mot_db); void reset(); void set_disable_eye_motion(bool value); void set_frame(float_t frame); @@ -1338,7 +1345,9 @@ struct rob_chara_bone_data { void set_motion_loop_state(mot_play_frame_data_loop_state value); void set_motion_max_frame(float_t value); void set_motion_playback_state(mot_play_frame_data_playback_state value); + void update(mat4* mat); + void sub_14041DBA0(); }; union rob_chara_pv_data_item { @@ -1362,7 +1371,7 @@ struct rob_chara_pv_data { rob_sleeve_data sleeve_l; rob_sleeve_data sleeve_r; int32_t field_70; - int32_t motion_face_ids[10]; + uint32_t motion_face_ids[10]; int32_t chara_size_index; bool height_adjust; rob_chara_pv_data_item item; @@ -1816,7 +1825,7 @@ struct RobClothSubMeshArray { }; struct opd_blend_data { - int32_t motion_id; + uint32_t motion_id; float_t frame; float_t frame_count; bool field_C; @@ -1843,7 +1852,7 @@ struct RobCloth : public CLOTH { virtual void ResetData() override; - void AddMotionResetData(int32_t motion_id, float_t frame); + void AddMotionResetData(uint32_t motion_id, float_t frame); void ApplyResetData(); void ColiSet(mat4* mats); void Disp(const mat4* mat, render_context* rctx); @@ -1856,7 +1865,7 @@ struct RobCloth : public CLOTH { void LoadSkinParam(void* kv, const char* name, const bone_database* bone_data); void ResetExtrenalForce(); void SetForceAirRes(float_t force, float_t force_gain, float_t air_res); - void SetMotionResetData(int32_t motion_id, float_t frame); + void SetMotionResetData(uint32_t motion_id, float_t frame); void SetOsagePlayData(std::vector& opd_blend_data); float_t* SetOsagePlayDataInit(float_t* opdi_data); void SetSkinParamOsageRoot(const skin_param_osage_root& skp_root); @@ -1888,12 +1897,12 @@ public: virtual void Field_48() override; virtual void Field_50() override; - void AddMotionResetData(int32_t motion_id, float_t frame); + void AddMotionResetData(uint32_t motion_id, float_t frame); void ColiSet(); void InitData(rob_chara_item_equip_object* itm_eq_obj, obj_skin_block_cloth* cls_data, skin_param_osage_root* skp_root, const bone_database* bone_data); float_t* LoadOpdData(size_t node_index, float_t* opd_data, size_t opd_count); - void SetMotionResetData(int32_t motion_id, float_t frame); + void SetMotionResetData(uint32_t motion_id, float_t frame); float_t* SetOsagePlayDataInit(float_t* opdi_data); void SetOsageReset(); void SetSkinParam(skin_param_file_data* skp); @@ -1948,7 +1957,7 @@ struct RobOsage { RobOsage(); ~RobOsage(); - void AddMotionResetData(int32_t motion_id, float_t frame); + void AddMotionResetData(uint32_t motion_id, float_t frame); void ApplyResetData(mat4* mat); bool CheckPartsBits(rob_osage_parts_bit parts_bits); void ColiSet(mat4* mats); @@ -1965,7 +1974,7 @@ struct RobOsage { void SetForce(float_t force, float_t force_gain); void SetHinge(float_t hinge_y, float_t hinge_z); void SetInitRot(float_t init_rot_y, float_t init_rot_z); - void SetMotionResetData(int32_t motion_id, float_t frame); + void SetMotionResetData(uint32_t motion_id, float_t frame); void SetNodesExternalForce(vec3* external_force, float_t strength); void SetNodesForce(float_t force); void SetOsagePlayData(mat4* parent_mat, @@ -2000,18 +2009,18 @@ public: virtual void Field_50() override; virtual void Field_58() override; - void AddMotionResetData(int32_t motion_id, float_t frame); + void AddMotionResetData(uint32_t motion_id, float_t frame); void InitData(rob_chara_item_equip_object* itm_eq_obj, obj_skin_block_osage* osg_data, const char* osg_data_name, obj_skin_osage_node* osg_nodes, bone_node* bone_nodes, bone_node* ex_data_bone_nodes, obj_skin* skin); float_t* LoadOpdData(size_t node_index, float_t* opd_data, size_t opd_count); - void SetMotionResetData(int32_t motion_id, float_t frame); + void SetMotionResetData(uint32_t motion_id, float_t frame); float_t* SetOsagePlayDataInit(float_t* opdi_data); void SetOsageReset(); void SetSkinParam(skin_param_file_data* skp); void SetWindDirection(); void sub_1405F3E10(obj_skin_block_osage* osg_data, obj_skin_osage_node* osg_nodes, - std::vector>* a4, + prj::vector_pair* a4, std::map* a5); }; @@ -2120,11 +2129,6 @@ public: const char* exp_data_name, object_info a4, size_t index, const bone_database* bone_data); }; -struct ex_data_name_bone_index { - const char* name; - uint32_t bone_index; -}; - struct rob_chara_item_equip; struct rob_chara_item_equip_object { @@ -2147,7 +2151,7 @@ struct rob_chara_item_equip_object { std::vector ex_data_bone_nodes; std::vector ex_data_bone_mats; std::vector ex_data_mats; - std::vector ex_bones; + prj::vector_pair ex_bones; int64_t field_138; std::vector null_blocks; std::vector osage_blocks; @@ -2164,7 +2168,7 @@ struct rob_chara_item_equip_object { rob_chara_item_equip_object(); ~rob_chara_item_equip_object(); - void add_motion_reset_data(int32_t motion_id, float_t frame, int32_t osage_iterations); + void add_motion_reset_data(uint32_t motion_id, float_t frame, int32_t osage_iterations); void check_no_opd(std::vector& opd_blend_data); void clear_ex_data(); void disp(const mat4* mat, render_context* rctx); @@ -2185,8 +2189,8 @@ struct rob_chara_item_equip_object { void set_alpha_obj_flags(float_t alpha, int32_t flags); bool set_boc(const skin_param_osage_root& skp_root, ExOsageBlock* osg); void set_collision_target_osage(const skin_param_osage_root& skp_root, skin_param* skp); - void set_motion_reset_data(int32_t motion_id, float_t frame); - void set_motion_skin_param(int8_t chara_id, int32_t motion_id, int32_t frame); + void set_motion_reset_data(uint32_t motion_id, float_t frame); + void set_motion_skin_param(int8_t chara_id, uint32_t motion_id, int32_t frame); void set_null_blocks_expression_data(const vec3& position, const vec3& rotation, const vec3& scale); void set_osage_play_data_init(float_t* opdi_data); void set_osage_reset(); @@ -2258,7 +2262,7 @@ struct rob_chara_item_equip { rob_chara_item_equip(); ~rob_chara_item_equip(); - void add_motion_reset_data(int32_t motion_id, float_t frame, int32_t iterations); + void add_motion_reset_data(uint32_t motion_id, float_t frame, int32_t iterations); void disp(int32_t chara_id, render_context* rctx); rob_chara_item_equip_object* get_item_equip_object(item_id id); object_info get_object_info(item_id id); @@ -2277,8 +2281,8 @@ struct rob_chara_item_equip { void set_alpha_obj_flags(float_t alpha, mdl::ObjFlags flags); void set_disp(item_id id, bool value); void set_item_equip_range(bool value); - void set_motion_reset_data(int32_t motion_id, float_t frame); - void set_motion_skin_param(int8_t chara_id, int32_t motion_id, int32_t frame); + void set_motion_reset_data(uint32_t motion_id, float_t frame); + void set_motion_skin_param(int8_t chara_id, uint32_t motion_id, int32_t frame); void set_null_blocks_expression_data(item_id id, const vec3& position, const vec3& rotation, const vec3& scale); void set_object_texture_pattern(item_id id, texture_pattern_struct* tex_pat, size_t count); @@ -2346,7 +2350,7 @@ struct struc_525 { struct struc_524 { int32_t field_0; struc_525 field_4; - int32_t motion_id; + uint32_t motion_id; int8_t field_10; }; @@ -2638,7 +2642,7 @@ struct struc_406 { class RobPartialMotion { public: struct Data { - int32_t motion_id; + uint32_t motion_id; int32_t mottbl_index; int32_t state; float_t frame; @@ -2771,7 +2775,7 @@ struct rob_chara_data_adjust { vec3 curr_external_force; float_t curr_force; float_t curr_strength; - int32_t motion_id; + uint32_t motion_id; float_t set_frame; float_t transition_duration; int32_t type; @@ -2827,8 +2831,8 @@ struct rob_chara_data_arm_adjust { }; struct rob_chara_motion { - int32_t motion_id; - int32_t prev_motion_id; + uint32_t motion_id; + uint32_t prev_motion_id; struc_389 frame_data; struc_406 step_data; float_t step; @@ -2905,9 +2909,9 @@ struct mothead_mot { }; struct mothead { - int32_t mot_set_id; - int32_t first_mot_id; - int32_t last_mot_id; + uint32_t mot_set_id; + uint32_t first_mot_id; + uint32_t last_mot_id; std::vector mots; void* data_x; @@ -2916,9 +2920,9 @@ struct mothead { }; struct mothead_file { - int32_t mot_set_id; - int32_t first_mot_id; - int32_t last_mot_id; + uint32_t mot_set_id; + uint32_t first_mot_id; + uint32_t last_mot_id; uint32_t mot_offsets_offset; }; @@ -3251,7 +3255,7 @@ struct struc_209 { struc_195 field_1668[27]; pos_scale field_1AA0[27]; float_t field_1BE4[27]; - std::vector> field_1C50; + prj::vector_pair field_1C50; int64_t field_1C68; int64_t field_1C70; int64_t field_1C78; @@ -3355,8 +3359,7 @@ struct rob_chara_data { int32_t field_3D94; int16_t field_3D98; int16_t field_3D9A; - uint8_t field_3D9C; - uint8_t field_3D9D; + int32_t field_3D9C; int32_t field_3DA0; uint8_t field_3DA4; int64_t field_3DA8; @@ -3413,6 +3416,8 @@ struct rob_chara { rob_chara(); ~rob_chara(); + void adjust_ctrl(); + void arm_adjust_ctrl(); void autoblink_disable(); void autoblink_enable(); bool check_for_ageageagain_module(); @@ -3421,15 +3426,17 @@ struct rob_chara { float_t get_frame(); float_t get_frame_count(); float_t get_max_face_depth(); - int32_t get_rob_cmn_mottbl_motion_id(int32_t id); + uint32_t get_rob_cmn_mottbl_motion_id(int32_t id); float_t get_trans_scale(int32_t bone, vec3& trans); bool is_visible(); void load_body_parts_object_info(item_id item_id, object_info obj_info, const bone_database* bone_data, void* data, const object_database* obj_db); - void load_motion(int32_t motion_id, bool a3, float_t frame, + void load_motion(uint32_t motion_id, bool a3, float_t frame, MotionBlendType blend_type, const bone_database* bone_data, const motion_database* mot_db); void load_outfit_object_info(item_id id, object_info obj_info, bool osage_reset, const bone_database* bone_data, void* data, const object_database* obj_db); + void rob_info_ctrl(); + void rob_motion_modifier_ctrl(); void reset_data(rob_chara_pv_data* pv_data, const bone_database* bone_data, const motion_database* mot_db); void reset_osage(); @@ -3439,13 +3446,14 @@ struct rob_chara { void set_chara_pos_adjust(vec3& value); void set_chara_pos_adjust_y(float_t value); void set_chara_size(float_t value); + void set_data_adjust_mat(rob_chara_adjust_data* rob_chr_adj, bool pos_adjust = true); void set_data_miku_rot_position(vec3& value); void set_data_miku_rot_rot_y_int16(int16_t value); - void set_eyelid_mottbl_motion_from_face(int32_t a2, - float_t blend_duration, float_t value, float_t blend_offset, const motion_database* mot_db); void set_eyelid_mottbl_motion(int32_t type, int32_t mottbl_index, float_t value, int32_t state, float_t blend_duration, float_t a7, float_t step, int32_t a9, float_t blend_offset, const motion_database* mot_db); + void set_eyelid_mottbl_motion_from_face(int32_t a2, + float_t blend_duration, float_t value, float_t blend_offset, const motion_database* mot_db); void set_eyes_mottbl_motion(int32_t type, int32_t mottbl_index, float_t value, int32_t state, float_t blend_duration, float_t a7, float_t step, int32_t a9, float_t blend_offset, const motion_database* mot_db); @@ -3462,12 +3470,12 @@ struct rob_chara { float_t value, int32_t state, float_t blend_duration, float_t a7, float_t step, int32_t a9, float_t blend_offset, const motion_database* mot_db); void set_left_hand_scale(float_t value); - bool set_motion_id(int32_t motion_id, float_t frame, + bool set_motion_id(uint32_t motion_id, float_t frame, float_t blend_duration, bool blend, bool set_motion_reset_data, MotionBlendType blend_type, const bone_database* bone_data, const motion_database* mot_db); void set_motion_loop(float_t loop_begin, float_t loop_end, int32_t loop_count); - void set_motion_reset_data(int32_t motion_id, float_t frame); - void set_motion_skin_param(int32_t motion_id, float_t frame); + void set_motion_reset_data(uint32_t motion_id, float_t frame); + void set_motion_skin_param(uint32_t motion_id, float_t frame); void set_motion_step(float_t value); void set_mouth_mottbl_motion(int32_t type, int32_t mottbl_index, float_t value, int32_t state, float_t blend_duration, float_t a7, @@ -3483,13 +3491,21 @@ struct rob_chara { void set_visibility(bool value); void set_wind_strength(float_t value); + void sub_1405070E0(const bone_database* bone_data, const motion_database* mot_db); + void sub_140509D30(); + void sub_140518190(); + void sub_140551000(); void sub_140554790(bool a2, float_t a3, float_t a5, float_t a6, float_t a7, float_t a8); void sub_1405547E0(bool a2, float_t a3, float_t a5, float_t a6, float_t a7, float_t a8); }; struct pv_data_set_motion { - int32_t motion_id; + uint32_t motion_id; std::pair frame_stage_index; + + pv_data_set_motion(); + pv_data_set_motion(uint32_t motion_id); + pv_data_set_motion(uint32_t motion_id, std::pair frame_stage_index); }; struct osage_init_data { @@ -3501,6 +3517,8 @@ struct osage_init_data { osage_init_data(); osage_init_data(rob_chara* rob_chr, uint32_t motion_id = -1); + osage_init_data(rob_chara* rob_chr, int32_t pv_id, + uint32_t motion_id, std::string&& path = "", int32_t frame = -1); ~osage_init_data(); }; @@ -3534,7 +3552,7 @@ extern void osage_play_data_manager_append_chara_motion_ids( rob_chara* rob_chr, const std::vector& motion_ids); extern bool osage_play_data_manager_check_task_ready(); extern void osage_play_data_manager_get_opd_file_data(object_info obj_info, - int32_t motion_id, float_t*& data, uint32_t& count); + uint32_t motion_id, float_t*& data, uint32_t& count); extern void osage_play_data_manager_reset(); extern void pv_osage_manager_array_reset(int32_t chara_id); @@ -3583,6 +3601,9 @@ extern bool rob_sleeve_handler_data_load(); extern void rob_sleeve_handler_data_read(); extern bool pv_osage_manager_array_get_disp(); +extern bool pv_osage_manager_array_get_disp(int32_t chara_id); +extern void pv_osage_manager_array_set_motion_ids( + int32_t chara_id, const std::vector& motion_ids); extern void pv_osage_manager_array_set_not_reset_true(); extern void pv_osage_manager_array_set_pv_id(int32_t chara_id, int32_t pv_id, bool reset); extern void pv_osage_manager_array_set_pv_set_motion( @@ -3600,6 +3621,7 @@ extern bool task_rob_manager_add_task(); extern bool task_rob_manager_check_chara_loaded(int32_t chara_id); extern bool task_rob_manager_check_task_ready(); extern bool task_rob_manager_hide_task(); +extern bool task_rob_manager_get_wait(int32_t chara_id); extern bool task_rob_manager_run_task(); extern bool task_rob_manager_del_task(); diff --git a/src/CRE/rob/skin_param.cpp b/src/CRE/rob/skin_param.cpp index 8834fc31..426e699b 100644 --- a/src/CRE/rob/skin_param.cpp +++ b/src/CRE/rob/skin_param.cpp @@ -61,7 +61,7 @@ struct SkinParamManager : public app::Task { int32_t GetExtSkpFile(const osage_init_data& osage_init, const std::string& path, std::string& file, void* data, motion_database* mot_db, object_database* obj_db); std::vector* GetSkinParamFileData( - object_info obj_info, int32_t motion_id, int32_t frame); + object_info obj_info, uint32_t motion_id, int32_t frame); void Reset(); }; @@ -238,7 +238,7 @@ bool skin_param_manager_check_task_ready(int32_t chara_id) { } std::vector* skin_param_manager_get_skin_param_file_data( - int32_t chara_id, object_info obj_info, int32_t motion_id, int32_t frame) { + int32_t chara_id, object_info obj_info, uint32_t motion_id, int32_t frame) { return skin_param_manager_get(chara_id)->GetSkinParamFileData(obj_info, motion_id, frame); } @@ -972,7 +972,7 @@ int32_t SkinParamManager::GetExtSkpFile(const osage_init_data& osage_init, const } std::vector* SkinParamManager::GetSkinParamFileData( - object_info obj_info, int32_t motion_id, int32_t frame) { + object_info obj_info, uint32_t motion_id, int32_t frame) { if (object_motion_frame.size()) { auto elem = object_motion_frame.find({ obj_info, { motion_id, frame } }); if (elem != object_motion_frame.end()) diff --git a/src/CRE/rob/skin_param.hpp b/src/CRE/rob/skin_param.hpp index 4e74f318..290e8009 100644 --- a/src/CRE/rob/skin_param.hpp +++ b/src/CRE/rob/skin_param.hpp @@ -21,7 +21,7 @@ extern bool skin_param_manager_array_check_task_ready(); extern bool skin_param_manager_add_task(int32_t chara_id, std::vector& vec); extern bool skin_param_manager_check_task_ready(int32_t chara_id); extern std::vector* skin_param_manager_get_skin_param_file_data( - int32_t chara_id, object_info obj_info, int32_t motion_id, int32_t frame); + int32_t chara_id, object_info obj_info, uint32_t motion_id, int32_t frame); extern void skin_param_manager_reset(int32_t chara_id); extern void skin_param_osage_node_parse(void* kv, const char* name, diff --git a/src/CRE/task_effect.cpp b/src/CRE/task_effect.cpp index 5cf05b4f..bb5ae4bd 100644 --- a/src/CRE/task_effect.cpp +++ b/src/CRE/task_effect.cpp @@ -116,7 +116,7 @@ struct ripple_emit_scene_shader_data { struct struc_608 { const stage_effects* stage_effects; const stage_effects_modern* stage_effects_modern; - std::vector> field_10; + prj::vector_pair field_10; struc_608(); struc_608(const ::stage_effects* stage_effects); @@ -130,9 +130,9 @@ struct TaskEffectParent { std::vector stage_hashes; // Added std::vector stage_indices; std::vector obj_set_ids; - std::vector> effects; - std::vector> field_50; - std::vector> field_68; + prj::vector_pair effects; + prj::vector_pair field_50; + prj::vector_pair field_68; int32_t state; bool enable; bool modern; // Added @@ -622,7 +622,7 @@ void TaskEffectAuth3D::Reset() { void TaskEffectAuth3D::ResetData() { for (int32_t i = 0; i < stage.count; i++) { auth_3d_id& id = stage.auth_3d_ids_ptr[i]; - id.unload_id(rctx_ptr); + id.unload(rctx_ptr); } stage.count = 0; enable = false; @@ -2969,7 +2969,7 @@ void TaskEffectParent::SetStageHashes(std::vector& stage_hashes) { const stage_effects_modern* effects = stage_data->effects_init ? &stage_data->effects : &stage_effects_modern_default; - field_68.push_back({ i, struc_608(effects) }); + field_68.push_back(i, struc_608(effects)); for (uint32_t j : effects->field_0) if (j == hash_murmurhash_empty || j == hash_murmurhash_null || j == -1) @@ -3005,7 +3005,7 @@ void TaskEffectParent::SetStageIndices(std::vector& stage_indices) { const stage_effects* effects = stage_data->effects_init ? &stage_data->effects : &stage_effects_default; - field_68.push_back({ i, struc_608(effects) }); + field_68.push_back(i, struc_608(effects)); for (int32_t j : effects->field_0) if (j == -1) diff --git a/src/DivaGL/bone_data.hpp b/src/DivaGL/bone_data.hpp index 2c4f7fd0..868be499 100644 --- a/src/DivaGL/bone_data.hpp +++ b/src/DivaGL/bone_data.hpp @@ -1161,7 +1161,7 @@ struct struc_525 { struct struc_524 { int32_t field_0; struc_525 field_4; - int32_t motion_id; + uint32_t motion_id; uint8_t field_10; }; @@ -1376,7 +1376,7 @@ struct RobPartialMotion { RobPartialMotion_vtbl* __vftable; struct Data { - int32_t motion_id; + uint32_t motion_id; int32_t mottbl_index; int32_t state; float_t frame; @@ -1419,7 +1419,7 @@ struct rob_chara_data_adjust { vec3 curr_external_force; float_t curr_force; float_t curr_strength; - int32_t motion_id; + uint32_t motion_id; float_t set_frame; float_t force_duration; int32_t type; @@ -1469,7 +1469,7 @@ struct struc_405 { RobHandMotion hand_l; RobHandMotion hand_r; RobMouthMotion mouth; - RobEyesMotion eye; + RobEyesMotion eyes; RobEyelidMotion eyelid; object_info head_object; object_info hand_l_object; @@ -1480,7 +1480,7 @@ struct struc_405 { }; struct rob_chara_motion { - int32_t motion_id; + uint32_t motion_id; int32_t prev_motion_id; struc_389 frame_data; struc_406 step_data; @@ -1540,7 +1540,7 @@ struct mothead_data2 { }; struct struc_652 { - int32_t motion_id; + uint32_t motion_id; float_t frame_count; float_t field_8; int16_t field_C; @@ -1705,7 +1705,7 @@ struct struc_223 { struc_652 field_0; struc_651 field_330; int64_t *field_7A0; - int32_t motion_set_id; + uint32_t motion_set_id; }; struct rob_chara_data_miku_rot { @@ -2661,7 +2661,7 @@ struct mot_key_data { mot_data* mot_data; bone_database_skeleton_type skeleton_type; int32_t skeleton_select; - int32_t motion_id; + uint32_t motion_id; float_t frame; struc_369 field_68; }; @@ -2991,7 +2991,7 @@ struct rob_chara_bone_data { }; struct opd_blend_data { - int32_t motion_id; + uint32_t motion_id; float_t frame; float_t frame_count; bool field_C; diff --git a/src/KKdLib/database/aet.cpp b/src/KKdLib/database/aet.cpp index fab74342..44cdc04e 100644 --- a/src/KKdLib/database/aet.cpp +++ b/src/KKdLib/database/aet.cpp @@ -268,9 +268,9 @@ void aet_database::add(aet_database_file* aet_db_file) { aet_set.index = (uint32_t)(aet_sets_count + i.index); aet_set.sprite_set_id = i.sprite_set_id; - aet_set_ids.push_back({ aet_set.id, &aet_set }); - aet_set_indices.push_back({ aet_set.index, &aet_set }); - aet_set_names.push_back({ aet_set.name, &aet_set }); + aet_set_ids.push_back(aet_set.id, &aet_set); + aet_set_indices.push_back(aet_set.index, &aet_set); + aet_set_names.push_back(aet_set.name, &aet_set); aet_ids.reserve(i.aet.size()); aet_names.reserve(i.aet.size()); @@ -285,9 +285,9 @@ void aet_database::add(aet_database_file* aet_db_file) { aet.info = { j.index, (uint16_t)aet_set.index }; aet.load_count = 1; - aet_ids.push_back({ aet.id, &aet }); - aet_names.push_back({ aet.name, &aet }); - aet_indices.push_back({ aet.info, &aet }); + aet_ids.push_back(aet.id, &aet); + aet_names.push_back(aet.name, &aet); + aet_indices.push_back(aet.info, &aet); } } @@ -319,8 +319,8 @@ void aet_database::add_aet_set(uint32_t set_id, uint32_t index) { set.id = set_id; set.index = index; - aet_set_indices.push_back({ set.index, &set }); - aet_set_ids.push_back({ set.id, &set }); + aet_set_indices.push_back(set.index, &set); + aet_set_ids.push_back(set.id, &set); aet_set_indices.combine(); aet_set_ids.combine(); @@ -337,7 +337,7 @@ void aet_database::parse(const aet_db_aet_set_file* set_file, uint16_t set_index = (uint16_t)elem->second->index; - aet_set_names.push_back({ set_file->name, elem->second }); + aet_set_names.push_back(set_file->name, elem->second); aet_ids.reserve(set_file->aet.size()); for (const aet_db_aet_file& i : set_file->aet) { @@ -365,9 +365,9 @@ void aet_database::parse(const aet_db_aet_set_file* set_file, aet->info = { i.index, set_index }; aet->load_count++; - this->aet_ids.push_back({ aet->id, aet }); - aet_names.push_back({ aet->name, aet }); - aet_indices.push_back({ aet->info, aet }); + this->aet_ids.push_back(aet->id, aet); + aet_names.push_back(aet->name, aet); + aet_indices.push_back(aet->info, aet); } aet_set_names.combine(); diff --git a/src/KKdLib/database/object.cpp b/src/KKdLib/database/object.cpp index 16f97b2c..a599bfbd 100644 --- a/src/KKdLib/database/object.cpp +++ b/src/KKdLib/database/object.cpp @@ -314,8 +314,8 @@ void object_database::update() { obj_set_murmurhashes.reserve(object_set.size()); for (object_set_info& i : object_set) { - obj_set_ids.push_back({ i.id, &i }); - obj_set_murmurhashes.push_back({ i.name_hash, &i }); + obj_set_ids.push_back(i.id, &i); + obj_set_murmurhashes.push_back(i.name_hash, &i); obj_infos.reserve(i.object.size()); obj_fnv1a64m_hashes.reserve(i.object.size()); @@ -324,11 +324,11 @@ void object_database::update() { obj_info_murmurhashes.reserve(i.object.size()); for (object_info_data& j : i.object) { - obj_infos.push_back({ { j.id, i.id }, &j }); - obj_fnv1a64m_hashes.push_back({ j.name_hash_fnv1a64m, &j }); - obj_fnv1a64m_hashes_upper.push_back({ j.name_hash_fnv1a64m_upper, &j }); - obj_murmurhashes.push_back({ j.name_hash_murmurhash, &j }); - obj_info_murmurhashes.push_back({ j.name_hash_murmurhash, { j.id, i.id } }); + obj_infos.push_back({ j.id, i.id }, &j); + obj_fnv1a64m_hashes.push_back(j.name_hash_fnv1a64m, &j); + obj_fnv1a64m_hashes_upper.push_back(j.name_hash_fnv1a64m_upper, &j); + obj_murmurhashes.push_back(j.name_hash_murmurhash, &j); + obj_info_murmurhashes.push_back(j.name_hash_murmurhash, { j.id, i.id }); } } diff --git a/src/KKdLib/database/sprite.cpp b/src/KKdLib/database/sprite.cpp index de899ca3..611a5279 100644 --- a/src/KKdLib/database/sprite.cpp +++ b/src/KKdLib/database/sprite.cpp @@ -264,9 +264,9 @@ void sprite_database::add(sprite_database_file* spr_db_file) { spr_set.file_name_hash = hash_string_murmurhash(spr_set.file_name); spr_set.index = (uint32_t)(sprite_sets_count + i.index); - spr_set_ids.push_back({ spr_set.id, &spr_set }); - spr_set_indices.push_back({ spr_set.index, &spr_set }); - spr_set_names.push_back({ spr_set.name, &spr_set }); + spr_set_ids.push_back(spr_set.id, &spr_set); + spr_set_indices.push_back(spr_set.index, &spr_set); + spr_set_names.push_back(spr_set.name, &spr_set); spr_ids.reserve(i.sprite.size()); spr_names.reserve(i.sprite.size()); @@ -282,9 +282,9 @@ void sprite_database::add(sprite_database_file* spr_db_file) { spr.info = { j.index, (uint16_t)((j.texture ? 0x4000 : 0x0000) | spr_set.index) }; spr.load_count = 1; - spr_ids.push_back({ spr.id, &spr }); - spr_names.push_back({ spr.name, &spr }); - spr_indices.push_back({ spr.info, &spr }); + spr_ids.push_back(spr.id, &spr); + spr_names.push_back(spr.name, &spr); + spr_indices.push_back(spr.info, &spr); } } @@ -316,8 +316,8 @@ void sprite_database::add_spr_set(uint32_t set_id, uint32_t index) { set.id = set_id; set.index = index; - spr_set_indices.push_back({ set.index, &set }); - spr_set_ids.push_back({ set.id, &set }); + spr_set_indices.push_back(set.index, &set); + spr_set_ids.push_back(set.id, &set); spr_set_indices.combine(); spr_set_ids.combine(); @@ -334,7 +334,7 @@ void sprite_database::parse(const spr_db_spr_set_file* set_file, uint16_t set_index = (uint16_t)elem->second->index; - spr_set_names.push_back({ set_file->name, elem->second }); + spr_set_names.push_back(set_file->name, elem->second); sprite_ids.reserve(set_file->sprite.size()); for (const spr_db_spr_file& i : set_file->sprite) { @@ -365,9 +365,9 @@ void sprite_database::parse(const spr_db_spr_set_file* set_file, spr->info = { i.index, (uint16_t)((i.texture ? 0x4000 : 0x0000) | set_index) }; spr->load_count++; - spr_ids.push_back({ spr->id, spr }); - spr_names.push_back({ spr->name, spr }); - spr_indices.push_back({ spr->info, spr }); + spr_ids.push_back(spr->id, spr); + spr_names.push_back(spr->name, spr); + spr_indices.push_back(spr->info, spr); } spr_set_names.combine(); diff --git a/src/KKdLib/io/json.cpp b/src/KKdLib/io/json.cpp index a5ebd6b3..e96f0fdf 100644 --- a/src/KKdLib/io/json.cpp +++ b/src/KKdLib/io/json.cpp @@ -422,7 +422,7 @@ static void io_json_read_map(stream& s, io_json_read_buffer* buf, msgpack* msg, } io_json_read_skip_whitespace(s, buf, c); - map.push_back({ key, {} }); + map.push_back(key, {}); io_json_read_inner(s, buf, &map.back().second, c); free_def(key); @@ -548,9 +548,12 @@ inline static void io_json_write_inner(stream& s, msgpack* msg, size_t tabs) { s.write("[\n", 2); + std::string tabs_str; + for (size_t i = 0; i <= tabs; i++) + tabs_str.append(" "); + for (msgpack& i : *ptr) { - for (size_t i = 0; i <= tabs; i++) - s.write(" ", 2); + s.write(tabs_str.c_str(), tabs_str.size()); io_json_write_inner(s, &i, tabs + 1); if (&i + 1 != ptr->data() + ptr->size()) s.write_char(','); @@ -570,9 +573,12 @@ inline static void io_json_write_inner(stream& s, msgpack* msg, size_t tabs) { s.write("{\n", 2); - for (msgpack_key_value& i : *ptr) { - for (size_t i = 0; i <= tabs; i++) - s.write(" ", 2); + std::string tabs_str; + for (size_t i = 0; i <= tabs; i++) + tabs_str.append(" "); + + for (auto& i : *ptr) { + s.write(tabs_str.c_str(), tabs_str.size()); io_json_write_string(s, i.first); s.write(": ", 2); io_json_write_inner(s, &i.second, tabs + 1); diff --git a/src/KKdLib/io/msgpack.cpp b/src/KKdLib/io/msgpack.cpp index 0a104d99..2f64e7c3 100644 --- a/src/KKdLib/io/msgpack.cpp +++ b/src/KKdLib/io/msgpack.cpp @@ -244,7 +244,7 @@ inline static void io_msgpack_write_inner(stream& s, msgpack* msg) { case MSGPACK_MAP: { msgpack_map* ptr = msg->data.map; io_msgpack_write_map(s, ptr->size()); - for (msgpack_key_value& i : *ptr) { + for (auto& i : *ptr) { io_msgpack_write_string(s, i.first); io_msgpack_write_inner(s, &i.second); } diff --git a/src/KKdLib/key_val.cpp b/src/KKdLib/key_val.cpp index 406f4e2e..111b0ddd 100644 --- a/src/KKdLib/key_val.cpp +++ b/src/KKdLib/key_val.cpp @@ -18,15 +18,6 @@ static int64_t key_val_get_key_index(key_val* kv, std::string& key); static int64_t key_val_get_key_index(key_val* kv, const char* str, size_t size); static void key_val_sort(key_val* kv); -key_val_hash_index_pair::key_val_hash_index_pair() { - hash = hash_fnv1a64m_empty; - index = 0; -} - -key_val_hash_index_pair::key_val_hash_index_pair(uint64_t hash, size_t index) : hash(hash), index(index) { - -} - key_val_scope::key_val_scope() : index(), count() { } @@ -35,14 +26,6 @@ key_val_scope::~key_val_scope() { } -key_val_pair::key_val_pair() : str(), length() { - -} - -key_val_pair::key_val_pair(const char* str, size_t length) : str(str), length(length) { - -} - key_val::key_val() : curr_scope(), buf(), scope_size() { } @@ -131,7 +114,7 @@ bool key_val::open_scope(const char* str) { curr_scope->count = prev_scope->count; curr_scope->key_hash_index.resize(prev_scope->key_hash_index.size()); memmove(curr_scope->key_hash_index.data(), prev_scope->key_hash_index.data(), - sizeof(key_val_hash_index_pair) * prev_scope->key_hash_index.size()); + sizeof(std::pair) * prev_scope->key_hash_index.size()); return true; } @@ -188,7 +171,7 @@ bool key_val::open_scope(std::string& str) { curr_scope->count = prev_scope->count; curr_scope->key_hash_index.resize(prev_scope->key_hash_index.size()); memmove(curr_scope->key_hash_index.data(), prev_scope->key_hash_index.data(), - sizeof(key_val_hash_index_pair) * prev_scope->key_hash_index.size()); + sizeof(std::pair) * prev_scope->key_hash_index.size()); return true; } @@ -309,7 +292,7 @@ bool key_val::read(bool& value) { value = false; return false; } - value = atoi(val[index].str) ? true : false; + value = atoi(val[index].first) ? true : false; return true; } @@ -319,7 +302,7 @@ bool key_val::read(float_t& value) { value = 0.0f; return false; } - value = (float_t)atof(val[index].str); + value = (float_t)atof(val[index].first); return true; } @@ -329,7 +312,7 @@ bool key_val::read(int32_t& value) { value = 0; return false; } - value = atoi(val[index].str); + value = atoi(val[index].first); return true; } @@ -339,7 +322,7 @@ bool key_val::read(uint32_t& value) { value = 0; return false; } - value = (uint32_t)atoll(val[index].str); + value = (uint32_t)atoll(val[index].first); return true; } @@ -349,7 +332,7 @@ bool key_val::read(const char*& value) { value = 0; return false; } - value = val[index].str; + value = val[index].first; return true; } @@ -359,7 +342,7 @@ bool key_val::read(std::string& value) { value.clear(); return false; } - value.assign(val[index].str, val[index].length); + value.assign(val[index].first, val[index].second); return true; } @@ -376,7 +359,7 @@ bool key_val::read(const char* key, bool& value) { value = false; return false; } - value = atoi(val[index].str) ? true : false; + value = atoi(val[index].first) ? true : false; return true; } @@ -386,7 +369,7 @@ bool key_val::read(std::string& key, bool& value) { value = false; return false; } - value = atoi(val[index].str) ? true : false; + value = atoi(val[index].first) ? true : false; return true; } @@ -396,7 +379,7 @@ bool key_val::read(const char* key, float_t& value) { value = 0.0f; return false; } - value = (float_t)atof(val[index].str); + value = (float_t)atof(val[index].first); return true; } @@ -406,7 +389,7 @@ bool key_val::read(std::string& key, float_t& value) { value = 0.0f; return false; } - value = (float_t)atof(val[index].str); + value = (float_t)atof(val[index].first); return true; } @@ -416,7 +399,7 @@ bool key_val::read(const char* key, int32_t& value) { value = 0; return false; } - value = atoi(val[index].str); + value = atoi(val[index].first); return true; } @@ -426,7 +409,7 @@ bool key_val::read(std::string& key, int32_t& value) { value = 0; return false; } - value = atoi(val[index].str); + value = atoi(val[index].first); return true; } @@ -436,7 +419,7 @@ bool key_val::read(const char* key, uint32_t& value) { value = 0; return false; } - value = (uint32_t)atoll(val[index].str); + value = (uint32_t)atoll(val[index].first); return true; } @@ -446,7 +429,7 @@ bool key_val::read(std::string& key, uint32_t& value) { value = 0; return false; } - value = (uint32_t)atoll(val[index].str); + value = (uint32_t)atoll(val[index].first); return true; } @@ -456,7 +439,7 @@ bool key_val::read(const char* key, const char*& value) { value = 0; return false; } - value = val[index].str; + value = val[index].first; return true; } @@ -466,7 +449,7 @@ bool key_val::read(std::string& key, const char*& value) { value = 0; return false; } - value = val[index].str; + value = val[index].first; return true; } @@ -476,7 +459,7 @@ bool key_val::read(const char* key, std::string& value) { value.clear(); return false; } - value.assign(val[index].str, val[index].length); + value.assign(val[index].first, val[index].second); return true; } @@ -486,7 +469,7 @@ bool key_val::read(std::string& key, std::string& value) { value.clear(); return false; } - value.assign(val[index].str, val[index].length); + value.assign(val[index].first, val[index].second); return true; } @@ -1073,24 +1056,24 @@ void key_val_out::get_lexicographic_order(std::vector& vec, int32_t len static int64_t key_val_find_first_key(key_val* kv, int64_t low, int64_t high, const char* s, size_t s_len, size_t offset) { - key_val_pair* k = kv->key.data(); + auto* k = kv->key.data(); int64_t first_idx = -1; int64_t mid; int32_t res; bool full; while (low <= high) { - key_val_pair* l = &k[mid = (low + high) / 2]; - if (l->length > offset && s_len <= l->length - offset) { - res = memcmp(s, l->str + offset, s_len); - if (!res && l->str[offset + s_len] && l->str[offset + s_len] != '.') + auto* l = &k[mid = (low + high) / 2]; + if (l->second > offset && s_len <= l->second - offset) { + res = memcmp(s, l->first + offset, s_len); + if (!res && l->first[offset + s_len] && l->first[offset + s_len] != '.') res = -1; full = true; } else { - if (l->length >= offset) { - res = str_utils_compare_length(s, s_len, l->str + offset, l->length - offset); - if (!res && s[l->length - offset]) + if (l->second >= offset) { + res = str_utils_compare_length(s, s_len, l->first + offset, l->second - offset); + if (!res && s[l->second - offset]) res = 1; } else @@ -1113,24 +1096,24 @@ static int64_t key_val_find_first_key(key_val* kv, int64_t low, int64_t high, static int64_t key_val_find_last_key(key_val* kv, int64_t low, int64_t high, const char* s, size_t s_len, size_t offset) { - key_val_pair* k = kv->key.data(); + auto* k = kv->key.data(); int64_t last_idx = -1; int64_t mid; int32_t res; bool full; while (low <= high) { - key_val_pair* l = &k[mid = (low + high) / 2]; - if (l->length > offset && s_len <= l->length - offset) { - res = memcmp(s, l->str + offset, s_len); - if (!res && l->str[offset + s_len] && l->str[offset + s_len] != '.') + auto* l = &k[mid = (low + high) / 2]; + if (l->second > offset && s_len <= l->second - offset) { + res = memcmp(s, l->first + offset, s_len); + if (!res && l->first[offset + s_len] && l->first[offset + s_len] != '.') res = -1; full = true; } else { - if (l->length >= offset) { - res = str_utils_compare_length(s, s_len, l->str + offset, l->length - offset); - if (!res && s[l->length - offset]) + if (l->second >= offset) { + res = str_utils_compare_length(s, s_len, l->first + offset, l->second - offset); + if (!res && s[l->second - offset]) res = 1; } else @@ -1186,11 +1169,11 @@ static int64_t key_val_get_key_index(key_val* kv, const char* str, size_t size) uint64_t hash = hash_fnv1a64m(str, size); - key_val_hash_index_pair* key = curr_scope->key_hash_index.data(); + auto* key = curr_scope->key_hash_index.data(); size_t len = curr_scope->count; size_t temp; while (len > 0) { - if (hash < key[temp = len / 2].hash) + if (hash < key[temp = len / 2].first) len = temp; else { key += temp + 1; @@ -1199,16 +1182,16 @@ static int64_t key_val_get_key_index(key_val* kv, const char* str, size_t size) } if (key == curr_scope->key_hash_index.data()) - if (key[0].hash == hash) - return key[0].index; + if (key[0].first == hash) + return key[0].second; else return -1; - else if (key[-1].hash == hash) - return key[-1].index; + else if (key[-1].first == hash) + return key[-1].second; else if (key == curr_scope->key_hash_index.data() + curr_scope->key_hash_index.size()) return -1; - else if (key[0].hash == hash) - return key[0].index; + else if (key[0].first == hash) + return key[0].second; return -1; } @@ -1227,11 +1210,11 @@ static void key_val_sort(key_val* kv) { curr_scope->key_hash_index.clear(); curr_scope->key_hash_index.resize(count); - key_val_pair* key = kv->key.data() + index; - key_val_hash_index_pair* key_hash_index = curr_scope->key_hash_index.data(); + auto* key = kv->key.data() + index; + auto* key_hash_index = curr_scope->key_hash_index.data(); for (size_t i = 0; i < count; i++) { - key_hash_index->index = index + i; - key_hash_index->hash = hash_fnv1a64m(key->str, key->length); + key_hash_index->second = index + i; + key_hash_index->first = hash_fnv1a64m(key->first, key->second); key++; key_hash_index++; } @@ -1242,34 +1225,34 @@ static void key_val_sort(key_val* kv) { size_t c[RADIX]; kv->temp_key_hash_index.clear(); kv->temp_key_hash_index.reserve(count); - key_val_hash_index_pair* o_key_hash_index = kv->temp_key_hash_index.data(); - key_val_hash_index_pair* arr_key_hash_index = curr_scope->key_hash_index.data(); - key_val_hash_index_pair* org_arr = arr_key_hash_index; + auto* o_key_hash_index = kv->temp_key_hash_index.data(); + auto* arr_key_hash_index = curr_scope->key_hash_index.data(); + auto* org_arr = arr_key_hash_index; for (size_t shift = 0, s = 0; shift < sizeof(uint64_t) * 8 / RADIX_BASE; shift++, s += RADIX_BASE) { memset(c, 0, sizeof(size_t) * RADIX); for (size_t i = 0; i < count; i++) - c[(arr_key_hash_index[i].hash >> s) & (RADIX - 1)]++; + c[(arr_key_hash_index[i].first >> s) & (RADIX - 1)]++; for (size_t i = 1; i < RADIX; i++) c[i] += c[i - 1]; for (int64_t i = count - 1; i >= 0; i--) { - size_t index = --c[(arr_key_hash_index[i].hash >> s) & (RADIX - 1)]; + size_t index = --c[(arr_key_hash_index[i].first >> s) & (RADIX - 1)]; o_key_hash_index[index] = arr_key_hash_index[i]; } - key_val_hash_index_pair* t_key_hash = arr_key_hash_index; + auto* t_key_hash = arr_key_hash_index; arr_key_hash_index = o_key_hash_index; o_key_hash_index = t_key_hash; } if (org_arr == o_key_hash_index) { - key_val_hash_index_pair* t_key_hash_index = arr_key_hash_index; + auto* t_key_hash_index = arr_key_hash_index; arr_key_hash_index = o_key_hash_index; o_key_hash_index = t_key_hash_index; - memmove(arr_key_hash_index, o_key_hash_index, sizeof(key_val_hash_index_pair) * count); + memmove(arr_key_hash_index, o_key_hash_index, sizeof(*o_key_hash_index) * count); } } diff --git a/src/KKdLib/key_val.hpp b/src/KKdLib/key_val.hpp index 8ec0141d..4d40e634 100644 --- a/src/KKdLib/key_val.hpp +++ b/src/KKdLib/key_val.hpp @@ -9,44 +9,29 @@ #include #include "default.hpp" #include "io/stream.hpp" +#include "prj/vector_pair.hpp" #include "vec.hpp" -struct key_val_hash_index_pair { - uint64_t hash; - size_t index; - - key_val_hash_index_pair(); - key_val_hash_index_pair(uint64_t hash, size_t index); -}; - struct key_val_scope { std::string key; size_t index; size_t count; - std::vector key_hash_index; + prj::vector_pair key_hash_index; key_val_scope(); ~key_val_scope(); }; -struct key_val_pair { - const char* str; - size_t length; - - key_val_pair(); - key_val_pair(const char* str, size_t length); -}; - struct key_val { key_val_scope* curr_scope; std::vector scope; ssize_t scope_size; std::string temp_key; - std::vector temp_key_hash_index; + prj::vector_pair temp_key_hash_index; - std::vector key; - std::vector val; + prj::vector_pair key; + prj::vector_pair val; char* buf; key_val(); diff --git a/src/KKdLib/msgpack.cpp b/src/KKdLib/msgpack.cpp index c11db0a7..dfafcf1a 100644 --- a/src/KKdLib/msgpack.cpp +++ b/src/KKdLib/msgpack.cpp @@ -31,7 +31,7 @@ msgpack* msgpack::get_by_name(const char* name) { return 0; msgpack_map* ptr = data.map; - for (msgpack_key_value& i : *ptr) + for (auto& i : *ptr) if (!i.first.compare(name)) return &i.second; @@ -43,7 +43,7 @@ void msgpack::set_by_name(const char* name, msgpack* m) { return; msgpack_map* ptr = data.map; - for (msgpack_key_value& i : *ptr) + for (auto& i : *ptr) if (!i.first.compare(name)) { i.second = *m; return; @@ -63,7 +63,7 @@ msgpack* msgpack::append(const char* name, msgpack* m) { return tm; } else { - data.map->push_back({ name, *m }); + data.map->push_back(name, *m); m->clear(); return &data.map->back().second; } @@ -80,7 +80,7 @@ msgpack* msgpack::append(const char* name, msgpack& m) { return tm; } else { - data.map->push_back({ name, m }); + data.map->push_back(name, m); m.clear(); return &data.map->back().second; } @@ -97,7 +97,7 @@ msgpack* msgpack::append(const char* name, msgpack&& m) { return tm; } else { - data.map->push_back({ name, m }); + data.map->push_back(name, m); m.clear(); return &data.map->back().second; } diff --git a/src/KKdLib/msgpack.hpp b/src/KKdLib/msgpack.hpp index dce960d2..e696c1d9 100644 --- a/src/KKdLib/msgpack.hpp +++ b/src/KKdLib/msgpack.hpp @@ -8,6 +8,7 @@ #include #include #include "default.hpp" +#include "prj/vector_pair.hpp" enum msgpack_type : uint32_t { MSGPACK_NONE = 0, @@ -31,8 +32,7 @@ enum msgpack_type : uint32_t { struct msgpack; typedef std::vector msgpack_array; -typedef std::pair msgpack_key_value; -typedef std::vector msgpack_map; +typedef prj::vector_pair msgpack_map; union msgpack_data { bool b; diff --git a/src/KKdLib/prj/vector_pair.hpp b/src/KKdLib/prj/vector_pair.hpp index 885f49a2..8aebc473 100644 --- a/src/KKdLib/prj/vector_pair.hpp +++ b/src/KKdLib/prj/vector_pair.hpp @@ -15,6 +15,32 @@ namespace prj { template class vector_pair : public std::vector> { public: + using value_pair = std::pair; + + inline void push_back(const T& first, const U& second) { + push_back({ first, second }); + } + + inline void push_back(const T& first, U&& second) { + push_back({ first, second }); + } + + inline void push_back(T&& first, const U& second) { + push_back({ first, second }); + } + + inline void push_back(T&& first, U&& second) { + push_back({ first, second }); + } + + inline void push_back(const value_pair& value) { + std::vector>::push_back(value); + } + + inline void push_back(value_pair&& value) { + std::vector>::push_back(value); + } + inline void sort() { std::sort(this->begin(), this->end(), [](const std::pair& a, const std::pair& b) { diff --git a/src/KKdLib/prj/vector_pair_combine.hpp b/src/KKdLib/prj/vector_pair_combine.hpp index 9f3220b5..7919c4b9 100644 --- a/src/KKdLib/prj/vector_pair_combine.hpp +++ b/src/KKdLib/prj/vector_pair_combine.hpp @@ -177,6 +177,22 @@ namespace prj { return data.crend(); } + inline void push_back(const T& first, const U& second) { + new_data.push_back({ first, second }); + } + + inline void push_back(const T& first, U&& second) { + new_data.push_back({ first, second }); + } + + inline void push_back(T&& first, const U& second) { + new_data.push_back({ first, second }); + } + + inline void push_back(T&& first, U&& second) { + new_data.push_back({ first, second }); + } + inline void push_back(const value_pair& value) { new_data.push_back(value); } diff --git a/src/ReDIVA/classes/data_view/draw_task.cpp b/src/ReDIVA/classes/data_view/draw_task.cpp index 4824968e..858bf48d 100644 --- a/src/ReDIVA/classes/data_view/draw_task.cpp +++ b/src/ReDIVA/classes/data_view/draw_task.cpp @@ -55,11 +55,9 @@ static const char* mdl_obj_kind_name[] = { "User", }; -typedef std::pair mdl_obj_data_sort; - struct data_view_draw_task { render_context* rctx; - std::vector obj_data; + prj::vector_pair obj_data; data_view_draw_task(); ~data_view_draw_task(); @@ -112,7 +110,7 @@ void data_view_draw_task_imgui(class_data* data) { render_context* rctx = data_view->rctx; std::vector* obj = rctx->disp_manager.obj; - std::vector& obj_data = data_view->obj_data; + auto& obj_data = data_view->obj_data; ImGuiTreeNodeFlags tree_node_base_flags = 0; tree_node_base_flags |= ImGuiTreeNodeFlags_OpenOnDoubleClick; @@ -138,11 +136,11 @@ void data_view_draw_task_imgui(class_data* data) { obj_data.reserve(count); for (mdl::ObjData*& j : draw_tasks) - obj_data.push_back({ j, hash_murmurhash(&j, 8, 0, true) }); + obj_data.push_back(j, hash_murmurhash(&j, 8, 0, true)); ImGui::Text(" Hash; Type"); - for (mdl_obj_data_sort& j : obj_data) { + for (auto& j : obj_data) { mdl::ObjData* data = j.first; if (data->kind < mdl::OBJ_KIND_NORMAL || data->kind > mdl::OBJ_KIND_TRANSLUCENT) continue; diff --git a/src/ReDIVA/data_edit.cpp b/src/ReDIVA/data_edit.cpp index e3201a6c..ca8cec8d 100644 --- a/src/ReDIVA/data_edit.cpp +++ b/src/ReDIVA/data_edit.cpp @@ -340,7 +340,7 @@ void DataEdit::Auth3D::Patch() { void DataEdit::Auth3D::Reset() { auth_3d_data_unload_category(category.hash_murmurhash); - id.unload_id(rctx_ptr); + id.unload(rctx_ptr); object_storage_unload_set(object_set.hash_murmurhash); category.clear(); diff --git a/src/ReDIVA/data_test/auth_2d_test.cpp b/src/ReDIVA/data_test/auth_2d_test.cpp index 33a336e6..4c47d80c 100644 --- a/src/ReDIVA/data_test/auth_2d_test.cpp +++ b/src/ReDIVA/data_test/auth_2d_test.cpp @@ -84,16 +84,15 @@ bool DtmAet::Ctrl() { || aet_manager_load_file(set_id, aft_aet_db)) break; - dw::List* id_list = dtw_aet->id->list; - id_list->ClearItems(); + dw::ListBox* id = dtw_aet->id; + id->ClearItems(); uint32_t scenes_count = aet_manager_get_scenes_count(set_id, aft_aet_db); for (uint32_t i = scenes_count, j = 0; i; i--, j++) - id_list->AddItem(aet_manager_get_scene_name( + id->AddItem(aet_manager_get_scene_name( aft_aet_db->get_aet_by_set_id_index(set_id, j)->id, aft_aet_db)); - id_list->hovered_item = id_index; - id_list->ResetSetSelectedItem(id_index); + id->SetItemIndex(id_index); state = 4; } break; case 4: { @@ -112,14 +111,15 @@ bool DtmAet::Ctrl() { else i++; - dw::List* layer_list = dtw_aet->layer->list; - layer_list->ClearItems(); - layer_list->AddItem("ROOT"); - for (std::string& i : comp_layers) - layer_list->AddItem(i); + dw::ListBox* layer = dtw_aet->layer; + layer->ClearItems(); - layer_list->hovered_item = layer_index; - layer_list->ResetSetSelectedItem(layer_index); + layer->AddItem("ROOT"); + + for (std::string& i : comp_layers) + layer->AddItem(i); + + layer->SetItemIndex(layer_index); state = 5; } break; case 5: { @@ -145,18 +145,14 @@ bool DtmAet::Ctrl() { end_time = aet_manager_get_scene_end_time(aet_id, aft_aet_db); dw::ListBox* marker = dtw_aet->marker; - if (marker->list) - marker->ClearItems(); + marker->ClearItems(); marker->AddItem("NOMARKER"); for (std::string& i : markers) marker->AddItem(i); - if (marker->list) { - marker->list->hovered_item = marker_index; - marker->list->ResetSetSelectedItem(marker_index); - } + marker->SetItemIndex(marker_index); state = 6; } break; case 6: { @@ -344,12 +340,11 @@ DtwAet::DtwAet() : Shell(0) { for (size_t i = aft_aet_db->aet_set_names.size(), j = 0; i; i--, j++) { uint32_t set_id = aft_aet_db->get_aet_set_id_by_name_index((uint32_t)j); const aet_db_aet_set* set = aft_aet_db->get_aet_set_by_id(set_id); - this->set->list->AddItem(set->name); + this->set->AddItem(set->name); } //set->list->sub_1402F9930(20); - set->list->hovered_item = dtm_aet->curr_set_index; - set->list->ResetSetSelectedItem(dtm_aet->curr_set_index); + set->SetItemIndex(dtm_aet->curr_set_index); set->list->AddSelectionListener(new dw::SelectionListenerOnHook(DtwAet::SetCallback)); @@ -385,8 +380,7 @@ DtwAet::DtwAet() : Shell(0) { type->AddItem("DRAW"); type->AddItem("LAYOUT"); - type->list->hovered_item = dtm_aet->type; - type->list->ResetSetSelectedItem(dtm_aet->type); + type->list->SetItemIndex(dtm_aet->type); type->list->AddSelectionListener(new dw::SelectionListenerOnHook(DtwAet::TypeCallback)); @@ -397,7 +391,7 @@ DtwAet::DtwAet() : Shell(0) { frame->SetName("FRAME"); frame->format = "%4.0f"; - frame->scroll_bar->SetParams(0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 10.0f); + frame->SetParams(0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 10.0f); frame->AddSelectionListener(new dw::SelectionListenerOnHook(DtwAet::FrameCallback)); @@ -489,9 +483,13 @@ void dtm_aet_load() { return; app::TaskWork::AddTask(dtm_aet, "DATA_TEST_AET_MANAGER"); - if (!dtw_aet) + + if (!dtw_aet) { dtw_aet = new DtwAet(); - dtw_aet->Disp(); + dtw_aet->sub_1402F38B0(); + } + else + dtw_aet->Disp(); } void dtm_aet_unload() { diff --git a/src/ReDIVA/data_test/auth_3d_test.cpp b/src/ReDIVA/data_test/auth_3d_test.cpp index 93e5b2c3..c3b9b546 100644 --- a/src/ReDIVA/data_test/auth_3d_test.cpp +++ b/src/ReDIVA/data_test/auth_3d_test.cpp @@ -140,7 +140,7 @@ bool Auth3dTestTask::Ctrl() { } bool Auth3dTestTask::Dest() { - auth_3d_id.unload_id(rctx_ptr); + auth_3d_id.unload(rctx_ptr); object_storage_unload_set(effcmn_obj_set); task_stage_unload_task(); clear_color = color_black; @@ -219,7 +219,7 @@ void Auth3dTestTask::SetAuth3dId() { data_struct* aft_data = &data_list[DATA_AFT]; auth_3d_database* aft_auth_3d_db = &aft_data->data_ft.auth_3d_db; - auth_3d_id.unload_id(rctx_ptr); + auth_3d_id.unload(rctx_ptr); auth_3d_id = auth_3d_data_load_uid(auth_3d_uid, aft_auth_3d_db); if (auth_3d_id.check_not_empty()) { auth_3d_id.set_enable(false); @@ -290,11 +290,11 @@ void Auth3dTestTask::SetStage() { } } -auth_3d_test_window_category::auth_3d_test_window_category() : name(), index() { +Auth3dTestWindow::Category::Category() : name(), index() { } -auth_3d_test_window_category::~auth_3d_test_window_category() { +Auth3dTestWindow::Category::~Category() { } @@ -309,17 +309,18 @@ Auth3dTestWindow::Auth3dTestWindow() { category.resize(auth_3d_db_cat.size()); for (auth_3d_database_category& i : auth_3d_db_cat) { - auth_3d_test_window_category* cat = &category[&i - auth_3d_db_cat.data()]; + Auth3dTestWindow::Category* cat = &category[&i - auth_3d_db_cat.data()]; cat->name = &i.name; cat->index = -1; cat->uid.reserve(i.uid.size()); for (int32_t& j : i.uid) if (uids[j].enabled) - cat->uid.push_back({ &uids[j].name, uids[j].org_uid }); + cat->uid.push_back(&uids[j].name, uids[j].org_uid); if (cat->uid.size()) { - quicksort_custom(cat->uid.data(), cat->uid.size(), sizeof(auth_3d_test_window_uid), + quicksort_custom(cat->uid.data(), cat->uid.size(), + sizeof(std::pair), auth_3d_test_window_uid_quicksort_compare_func); cat->index = 0; } @@ -334,12 +335,12 @@ Auth3dTestWindow::Auth3dTestWindow() { auth_3d_uid_load = false; if (category.size() > 0) { - auth_3d_test_window_category* cat = &category.front(); + Auth3dTestWindow::Category* cat = &category.front(); if (cat->uid.size()) { auth_3d_load = true; auth_3d_uid_load = true; - auth_3d_uid = cat->uid.front().uid; + auth_3d_uid = cat->uid.front().second; } auth_3d_category_index = 0; @@ -444,7 +445,7 @@ void Auth3dTestWindow::Window() { ImGui::GetContentRegionAvailSetNextItemWidth(); if (ImGui::BeginCombo("##Auth 3D Category Index", _auth_3d_category_index > -1 ? category[_auth_3d_category_index].name->c_str() : "", 0)) { - for (auth_3d_test_window_category& i : category) { + for (Auth3dTestWindow::Category& i : category) { int32_t auth_3d_category_idx = (int32_t)(&i - category.data()); ImGui::PushID(&i); @@ -465,12 +466,12 @@ void Auth3dTestWindow::Window() { } if (_auth_3d_category_index != auth_3d_category_index) { - auth_3d_test_window_category* cat = &category[_auth_3d_category_index]; + Auth3dTestWindow::Category* cat = &category[_auth_3d_category_index]; if (cat->uid.size() > 0) { auth_3d_load = true; auth_3d_uid_load = true; - auth_3d_uid = cat->uid[cat->index].uid; + auth_3d_uid = cat->uid[cat->index].second; } else { auth_3d_load = false; @@ -491,17 +492,17 @@ void Auth3dTestWindow::Window() { ImGui::GetContentRegionAvailSetNextItemWidth(); bool auth_3d_category_found = false; - for (auth_3d_test_window_category& i : category) { + for (Auth3dTestWindow::Category& i : category) { if (auth_3d_category_index != &i - category.data()) continue; if (ImGui::BeginCombo("##Auth 3D Index", _auth_3d_index > -1 - ? i.uid[_auth_3d_index].name->c_str() : "", 0)) { - for (auth_3d_test_window_uid& j : i.uid) { + ? i.uid[_auth_3d_index].first->c_str() : "", 0)) { + for (auto& j : i.uid) { int32_t auth_3d_idx = (int32_t)(&j - i.uid.data()); ImGui::PushID(&j); - if (ImGui::Selectable(j.name->c_str(), _auth_3d_index == auth_3d_idx) + if (ImGui::Selectable(j.first->c_str(), _auth_3d_index == auth_3d_idx) || ImGui::ItemKeyPressed(ImGuiKey_Enter) || (ImGui::IsItemFocused() && _auth_3d_index != auth_3d_idx)) { auth_3d_index = -1; @@ -520,7 +521,7 @@ void Auth3dTestWindow::Window() { if (_auth_3d_index != auth_3d_index) { i.index = _auth_3d_index; auth_3d_uid_load = true; - auth_3d_uid = i.uid[_auth_3d_index].uid; + auth_3d_uid = i.uid[_auth_3d_index].second; auth_3d_index = _auth_3d_index; } auth_3d_category_found = true; @@ -673,7 +674,7 @@ void auth_3d_test_window_free() { } static int auth_3d_test_window_uid_quicksort_compare_func(void const* src1, void const* src2) { - std::string* str1 = ((auth_3d_test_window_uid*)src1)->name; - std::string* str2 = ((auth_3d_test_window_uid*)src2)->name; + std::string* str1 = ((std::pair*)src1)->first; + std::string* str2 = ((std::pair*)src2)->first; return str_utils_compare_length(str1->c_str(), str1->size(), str2->c_str(), str2->size()); } diff --git a/src/ReDIVA/data_test/auth_3d_test.hpp b/src/ReDIVA/data_test/auth_3d_test.hpp index 9a436e3c..eddeaaa1 100644 --- a/src/ReDIVA/data_test/auth_3d_test.hpp +++ b/src/ReDIVA/data_test/auth_3d_test.hpp @@ -39,7 +39,7 @@ public: int32_t load_stage_index; vec3 trans_value; float_t rot_y_value; - std::vector> field_348; + prj::vector_pair field_348; bool field_388; int32_t field_38C; bool field_390; @@ -68,22 +68,17 @@ public: void SetStage(); }; -struct auth_3d_test_window_uid { - std::string* name; - int32_t uid; -}; - -struct auth_3d_test_window_category { - std::string* name; - int32_t index; - std::vector uid; - - auth_3d_test_window_category(); - ~auth_3d_test_window_category(); -}; - class Auth3dTestWindow : public app::TaskWindow { public: + struct Category { + std::string* name; + int32_t index; + prj::vector_pair uid; + + Category(); + ~Category(); + }; + int32_t auth_3d_category_index; int32_t auth_3d_category_index_prev; int32_t auth_3d_index; @@ -101,7 +96,7 @@ public: bool stg_display; std::vector stage; - std::vector category; + std::vector category; Auth3dTestWindow(); virtual ~Auth3dTestWindow() override; diff --git a/src/ReDIVA/data_test/equip_test.cpp b/src/ReDIVA/data_test/equip_test.cpp new file mode 100644 index 00000000..d0632b3f --- /dev/null +++ b/src/ReDIVA/data_test/equip_test.cpp @@ -0,0 +1,192 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#include "equip_test.hpp" +#include "../../CRE/rob/rob.hpp" +#include "auth_3d_test.hpp" +#include "motion_test.hpp" + +extern render_context* rctx_ptr; + +DtmEqVs* dtm_eq_vs_array; + +DtmEqVs::DtmEqVs() : chara_id(), chara_index(), curr_chara_index(), +module_index(), curr_module_index(), field_80() { + state = -1; +} + +DtmEqVs::~DtmEqVs() { + +} + +bool DtmEqVs::Init() { + state = 0; + return true; +} + +bool DtmEqVs::Ctrl() { + rob_chara_item_cos_data* item_cos_data = rob_chara_array_get_item_cos_data(chara_id); + rob_chara* rob_chr = rob_chara_array_get(chara_id); + switch (state) { + case 0: + //data_test_equip_dw_sub_14025FCC0(chara_id); + //data_test_equip_dw_sub_14025FA80(chara_id, item_cos_data->get_cos()); + state = 3; + case 3: + if (false /*dtm_mot_array_sub_140287740()*/) { + sub_140262050(); + sub_140261FF0(); + + int32_t item_no = ITEM_NONE;//data_test_equip_dw_sub_14025FB20(chara_id); + ::item_cos_data temp_cos; + if (rob_chr) + temp_cos = *rob_chr->item_cos_data.get_cos(); + + bool v2 = false; + /*if (data_test_equip_dw_sub_14025FAF0(chara_id)) { + item_cos_data->set_chara_index_item(chara_index, item_no); + v2 = true; + }*/ + + /*if (data_test_equip_dw_sub_14025FB80(chara_id)) { + item_cos_data->set_chara_index_item_zero(chara_index, item_no); + v2 = true; + }*/ + + const ::item_cos_data* cos = 0;//data_test_equip_dw_get_cos(chara_id); + if (cos) { + item_cos_data->set_chara_index_item_nos(chara_index, cos->arr); + v2 = true; + } + + /*if (sub_1402CEEC0(chara_id)) { + v2 = true; + sub_1402CF8F0(); + }*/ + + //data_test_equip_dw_sub_14025FBE0(chara_id); + + if (v2) { + if (rob_chr) + task_rob_load_append_free_req_data_obj(rob_chr->chara_index, &temp_cos); + rob_chara_array_reset_bone_data_item_equip(chara_id); + task_rob_manager_hide_task(); + state = 1; + } + } + break; + case 1: + if (rob_chr->chara_index) { + task_rob_load_append_load_req_data_obj(rob_chr->chara_index, rob_chr->item_cos_data.get_cos()); + state = 2; + } + break; + case 2: + if (!task_rob_load_check_load_req_data()) { + task_rob_manager_run_task(); + if (rob_chara_array_get(chara_id)) { + data_struct* aft_data = &data_list[DATA_AFT]; + bone_database* aft_bone_data = &aft_data->data_ft.bone_data; + object_database* aft_obj_db = &aft_data->data_ft.obj_db; + item_cos_data->reload_items(chara_id, aft_bone_data, aft_data, aft_obj_db); + } + auth_3d_test_task_disp_chara(); + dtm_mot_array_set_reset_mot(); + this->state = 3; + } + break; + } + return false; +} + +bool DtmEqVs::Dest() { + return true; +} + +bool DtmEqVs::AddTask(int32_t chara_id, ::chara_index chara_index) { + chara_id = chara_id; + this->chara_index = chara_index; + this->curr_chara_index = chara_index; + module_index = 0; + curr_module_index = 0; + this->field_80 = 0; + //data_test_equip_dw_set_chara_index(chara_id, chara_index); + //data_test_equip_dw_set_module_index(chara_id, module_index); + return app::TaskWork::AddTask(this, "DATA TEST EQUIP MANAGER FOR VS"); + return true; +} + +bool DtmEqVs::DelTask() { + return app::Task::DelTask(); +} + +void DtmEqVs::SetCharaIndexModuleIndex(::chara_index chara_index, int32_t module_index) { + this->chara_index = chara_index; + this->module_index = module_index; + //data_test_equip_dw_set_chara_index(chara_id, chara_index); + //data_test_equip_dw_set_module_index(chara_id, module_index); +} + +void DtmEqVs::sub_140261FF0() { + if (chara_index == curr_chara_index && module_index == curr_module_index) + return; + + curr_chara_index = chara_index; + curr_module_index = module_index; + const item_cos_data* cos = item_table_handler_array_get_item_cos_data_by_module_index(chara_index, module_index); + if (!check_module_index_is_501(curr_module_index) || !cos) { + //data_test_equip_dw_sub_14025FCC0(chara_id); + //data_test_equip_dw_sub_14025FA80(chara_id, cos); + } +} + +void DtmEqVs::sub_140262050() { + return; + + int32_t v2 = 0;//data_test_equip_dw_sub_14025FAC0(chara_id); + /*if (v2 == field_80) + return;*/ + + rob_chara_item_equip* rob_itm_equip = rob_chara_array_get_item_equip(chara_id); + bool disp = false; + item_id id; + switch (v2) { + default: + id = ITEM_NONE; + disp = true; + break; + case 1: + id = ITEM_NONE; + break; + case 2: + id = ITEM_OUTER; + break; + case 3: + id = ITEM_PANTS; + break; + } + + for (int32_t i = ITEM_ATAMA; i < ITEM_MAX; i++) + if (rob_itm_equip->get_object_info((item_id)i).not_null()) + rob_itm_equip->set_disp((item_id)i, true); + + for (int32_t i = ITEM_ATAMA; i < ITEM_MAX; i++) + if (i != id && (!disp || i != rob_itm_equip->field_D4)) + rob_itm_equip->set_disp((item_id)i, disp); + + field_80 = v2; +} + +void equip_test_init() { + if (!dtm_eq_vs_array) + dtm_eq_vs_array = new DtmEqVs[2]; +} + +void equip_test_free() { + if (dtm_eq_vs_array) { + delete[] dtm_eq_vs_array; + dtm_eq_vs_array = 0; + } +} diff --git a/src/ReDIVA/data_test/equip_test.hpp b/src/ReDIVA/data_test/equip_test.hpp new file mode 100644 index 00000000..8a944fd3 --- /dev/null +++ b/src/ReDIVA/data_test/equip_test.hpp @@ -0,0 +1,196 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#pragma once + +#include "../../KKdLib/default.hpp" +#include "../../CRE/rob/rob.hpp" +#include "../dw.hpp" +#include "../task_window.hpp" + +class DtmEqVs : public app::Task { +public: + int32_t state; + int32_t chara_id; + ::chara_index chara_index; + ::chara_index curr_chara_index; + int32_t module_index; + int32_t curr_module_index; + int32_t field_80; + + DtmEqVs(); + virtual ~DtmEqVs() override; + + virtual bool Init() override; + virtual bool Ctrl() override; + virtual bool Dest() override; + + virtual bool AddTask(int32_t chara_id, ::chara_index chara_index); + virtual bool DelTask(); + + void SetCharaIndexModuleIndex(::chara_index chara_index, int32_t module_index); + + void sub_140261FF0(); + void sub_140262050(); +}; + +class DataTestEquipDw : public dw::Shell { +public: + struct Data { + bool field_0; + bool field_1; + bool field_2; + bool field_3; + uint32_t field_4; + item_cos_data* cos; + chara_index chara_index; + int32_t module_index; + bool field_18; + int field_1C; + std::vector field_20[25]; + std::map field_278[25]; + uint32_t field_408[25]; + + Data(); + ~Data(); + }; + + int32_t chara_id; + DataTestEquipDw::Data data[6]; + dw::Composite* field_1C28[25]; + dw::Label* field_1CF0[25]; + dw::ListBox* field_1DB8[25]; + dw::ListBox* field_1E80; + __int64 field_1E88; + __int64 field_1E90; + __int64 field_1E98; + __int64 field_1EA0; + __int64 field_1EA8; + __int64 field_1EB0; + __int64 field_1EB8; + __int64 field_1EC0; + __int64 field_1EC8; + __int64 field_1ED0; + __int64 field_1ED8; + __int64 field_1EE0; + __int64 field_1EE8; + __int64 field_1EF0; + __int64 field_1EF8; + __int64 field_1F00; + __int64 field_1F08; + __int64 field_1F10; + __int64 field_1F18; + __int64 field_1F20; + __int64 field_1F28; + __int64 field_1F30; + __int64 field_1F38; + __int64 field_1F40; + __int64 field_1F48; + __int64 field_1F50; + __int64 field_1F58; + __int64 field_1F60; + __int64 field_1F68; + __int64 field_1F70; + __int64 field_1F78; + __int64 field_1F80; + __int64 field_1F88; + __int64 field_1F90; + __int64 field_1F98; + __int64 field_1FA0; + __int64 field_1FA8; + __int64 field_1FB0; + __int64 field_1FB8; + __int64 field_1FC0; + __int64 field_1FC8; + __int64 field_1FD0; + __int64 field_1FD8; + __int64 field_1FE0; + __int64 field_1FE8; + __int64 field_1FF0; + __int64 field_1FF8; + __int64 field_2000; + __int64 field_2008; + __int64 field_2010; + __int64 field_2018; + __int64 field_2020; + __int64 field_2028; + __int64 field_2030; + __int64 field_2038; + __int64 field_2040; + __int64 field_2048; + __int64 field_2050; + __int64 field_2058; + __int64 field_2060; + __int64 field_2068; + __int64 field_2070; + __int64 field_2078; + __int64 field_2080; + __int64 field_2088; + __int64 field_2090; + __int64 field_2098; + __int64 field_20A0; + __int64 field_20A8; + __int64 field_20B0; + __int64 field_20B8; + __int64 field_20C0; + __int64 field_20C8; + __int64 field_20D0; + __int64 field_20D8; + __int64 field_20E0; + __int64 field_20E8; + __int64 field_20F0; + __int64 field_20F8; + __int64 field_2100; + __int64 field_2108; + __int64 field_2110; + __int64 field_2118; + __int64 field_2120; + __int64 field_2128; + __int64 field_2130; + __int64 field_2138; + __int64 field_2140; + __int64 field_2148; + __int64 field_2150; + __int64 field_2158; + __int64 field_2160; + __int64 field_2168; + __int64 field_2170; + __int64 field_2178; + __int64 field_2180; + __int64 field_2188; + __int64 field_2190; + __int64 field_2198; + __int64 field_21A0; + __int64 field_21A8; + __int64 field_21B0; + __int64 field_21B8; + __int64 field_21C0; + __int64 field_21C8; + __int64 field_21D0; + __int64 field_21D8; + __int64 field_21E0; + __int64 field_21E8; + __int64 field_21F0; + __int64 field_21F8; + __int64 field_2200; + __int64 field_2208; + __int64 field_2210; + __int64 field_2218; + __int64 field_2220; + __int64 field_2228; + __int64 field_2230; + __int64 field_2238; + __int64 field_2240; + __int64 field_2248; + __int64 field_2250; + __int64 field_2258; + __int64 field_2260; + __int64 field_2268; +}; + +extern DtmEqVs* dtm_eq_vs_array; + +extern void equip_test_init(); +extern void equip_test_free(); diff --git a/src/ReDIVA/data_test/motion_test.cpp b/src/ReDIVA/data_test/motion_test.cpp index 9c5dc79d..c636e455 100644 --- a/src/ReDIVA/data_test/motion_test.cpp +++ b/src/ReDIVA/data_test/motion_test.cpp @@ -4,36 +4,65 @@ */ #include "motion_test.hpp" -#include "../../KKdLib/io/path.hpp" #include "../../KKdLib/prj/algorithm.hpp" -#include "../../KKdLib/sort.hpp" -#include "../../KKdLib/str_utils.hpp" +#include "../../CRE/rob/motion.hpp" +#include "../../CRE/rob/skin_param.hpp" #include "../../CRE/clear_color.hpp" -#include "../../CRE/data.hpp" #include "../../CRE/hand_item.hpp" -#include "../../CRE/render_context.hpp" +#include "../../CRE/module_table.hpp" +#include "../../CRE/pv_db.hpp" +#include "../../CRE/resolution_mode.hpp" #include "../../CRE/stage.hpp" -#include "../imgui_helper.hpp" -#include "../input.hpp" -#include "../task_window.hpp" #include "auth_3d_test.hpp" +#include "equip_test.hpp" +#include "stage_test.hpp" extern int32_t width; extern int32_t height; extern render_context* rctx_ptr; DataTestMot* data_test_mot; +DataTestMotA3d* data_test_mot_a3d; + DtmMot* dtm_mot_array; -DtmEqVs* dtm_eq_vs_array; + +DataTestMotDw* data_test_mot_dw_array[ROB_CHARA_COUNT]; +DataTestMotA3dDw* data_test_mot_a3d_dw; +DataTestMotCtrlDw* data_test_mot_ctrl_dw; +DataTestFaceMotDw* data_test_face_mot_dw_array[ROB_CHARA_COUNT]; std::vector motion_test_objset; -static void dtm_mot_array_set_reset_mot(); +static DataTestMot::Data* data_test_mot_data_get(); + +static bool data_test_mot_a3d_add_task(); +static bool data_test_mot_a3d_del_task(); +static const char* data_test_mot_a3d_get_state_text(); +static DataTestMotA3d* data_test_mot_a3d_get(); +static void data_test_mot_a3d_set_auth_3d(std::string& value); + +static void data_test_mot_dw_array_init(int32_t chara_id, DtmMot* dtm_mot); +static DataTestMotDw* data_test_mot_dw_array_get(int32_t chara_id); + +static void data_test_mot_a3d_dw_init(); +static DataTestMotA3dDw* data_test_mot_a3d_dw_get(); + +static void data_test_mot_ctrl_dw_init(); +static DataTestMotCtrlDw* data_test_mot_ctrl_dw_get(); + +static void data_test_face_mot_dw_array_init(int32_t chara_id); +static DataTestFaceMotDw* data_test_face_mot_dw_array_get(int32_t chara_id); +static void data_test_face_mot_dw_array_unload(); static bool motion_test_objset_check_not_read(); static void motion_test_objset_load(); static void motion_test_objset_unload(); +DataTestMot::Data::Offset::Offset() { + pre = 0.0f; + post = 0.0f; +} + DataTestMot::Data::Divide::Divide() { array[0] = 0.0f; array[1] = 0.0f; @@ -47,13 +76,9 @@ DataTestMot::Data::Step::Step() { array[3] = 1.0f; } -DataTestMot::Data::Data() : chara_index_p1(), chara_index_p2(), curr_chara_index_p1(), -curr_chara_index_p2(), module_index_p1(), module_index_p2(), curr_module_index_p1(), -curr_module_index_p2(), motion_set_index_p1(), motion_set_index_p2(), -curr_motion_set_index_p1(), curr_motion_set_index_p2(), motion_index_p1(), -motion_index_p2(), curr_motion_index_p1(), curr_motion_index_p2(), rot_y_p1(), rot_y_p2(), -trans_x_p1(), trans_x_p2(), pre_offset_p1(), post_offset_p1(), pre_offset_p2(), post_offset_p2(), -start_frame_p1(), start_frame_p2(), type(), reset_mot(), reset_cam(), reload_data(), +DataTestMot::Data::Data() : chara_index(), curr_chara_index(), module_index(), curr_module_index(), +motion_set_index(), curr_motion_set_index(), motion_index(), curr_motion_index(), rot_y(), +trans_x(), offset(), start_frame(), type(), reset_mot(), reset_cam(), reload_data(), sync_frame(), field_A8(), field_A9(), running(), field_AC(), field_B0(), sync_1p_frame() { field_AA = true; } @@ -75,14 +100,14 @@ bool DataTestMot::Init() { cam->set_view_point({ 0.0f, 1.0f, 3.45f }); cam->set_interest({ 0.0f, 1.0f, 0.0f }); - //DataTestMotDw::InitByCharaID(0, &dtm_mot_array[-]); - //DataTestMotDw::InitByCharaID(1, &dtm_mot_array[1]); - //data_test_mot_ctrl_dw_init(); - //data_test_mot_a3d_dw_init(); + data_test_mot_dw_array_init(0, &dtm_mot_array[0]); + data_test_mot_dw_array_init(1, &dtm_mot_array[1]); + data_test_mot_ctrl_dw_init(); + data_test_mot_a3d_dw_init(); data.reset_cam = true; data.field_A8 = true; - dtm_eq_vs_array[0].AddTask(0, data.chara_index_p1); - dtm_eq_vs_array[1].AddTask(1, data.chara_index_p1); + //dtm_eq_vs_array[0].AddTask(0, data.chara_index[0]); + //dtm_eq_vs_array[1].AddTask(1, data.chara_index[1]); motion_test_objset_load(); return true; } @@ -91,7 +116,7 @@ bool DataTestMot::Ctrl() { data_struct* aft_data = &data_list[DATA_AFT]; motion_database* aft_mot_db = &aft_data->data_ft.mot_db; - //data_mot_test_dw_array_get(0)->sub_14028D8B0(); + //data_test_mot_dw_array_get(0)->sub_14028D8B0(); bool v3 = false; bool v2 = false; @@ -102,112 +127,104 @@ bool DataTestMot::Ctrl() { v2 = true; } - if (data.chara_index_p1 != data.curr_chara_index_p1) { - data.curr_chara_index_p1 = data.chara_index_p1; - dtm_eq_vs_array[0].SetCharaIndexModuleIndex(data.chara_index_p1, data.module_index_p1); + if (data.chara_index[0] != data.curr_chara_index[0]) { + data.curr_chara_index[0] = data.chara_index[0]; + //dtm_eq_vs_array[0].SetCharaIndexModuleIndex(data.chara_index[0], data.module_index[0]); v3 = true; v2 = true; } - if (data.chara_index_p2 != data.curr_chara_index_p2) { - data.curr_chara_index_p2 = data.chara_index_p2; - dtm_eq_vs_array[1].SetCharaIndexModuleIndex(data.chara_index_p2, data.module_index_p2); + if (data.chara_index[1] != data.curr_chara_index[1]) { + data.curr_chara_index[1] = data.chara_index[1]; + //dtm_eq_vs_array[1].SetCharaIndexModuleIndex(data.chara_index[1], data.module_index[1]); v3 = true; v2 = true; } - if (data.module_index_p1 != data.curr_module_index_p1) { - data.curr_module_index_p1 = data.module_index_p1; - dtm_eq_vs_array[0].SetCharaIndexModuleIndex(data.chara_index_p1, data.module_index_p1); + if (data.module_index[0] != data.curr_module_index[0]) { + data.curr_module_index[0] = data.module_index[0]; + //dtm_eq_vs_array[0].SetCharaIndexModuleIndex(data.chara_index[0], data.module_index[0]); v3 = true; v2 = true; } - if (data.module_index_p2 != data.curr_module_index_p2) { - data.curr_module_index_p2 = data.module_index_p2; - dtm_eq_vs_array[1].SetCharaIndexModuleIndex(data.chara_index_p2, data.module_index_p2); + if (data.module_index[1] != data.curr_module_index[1]) { + data.curr_module_index[1] = data.module_index[1]; + //dtm_eq_vs_array[1].SetCharaIndexModuleIndex(data.chara_index[1], data.module_index[1]); v3 = true; v2 = true; } - if (data.motion_set_index_p1 != data.curr_motion_set_index_p1) { - data.curr_motion_set_index_p1 = data.motion_set_index_p1; + if (data.motion_set_index[0] != data.curr_motion_set_index[0]) { + data.curr_motion_set_index[0] = data.motion_set_index[0]; - /*data_mot_test_dw_array_get(0)->field_D8(); + data_test_mot_dw_array_get(0)->ClearIDs(); - uint32_t v16 = motion_database_set_indices_get_id(data.motion_set_index_p1); - uint32_t v18 = motion_database_get_set_motion_count(v16); - for (uint32_t i = 0; i < v18; i++) { - uint32_t v20 = motion_database_get_motion_id(v16, i); - const char* v21 = motion_database_get_motion_name_by_motion_index(v20); - data_mot_test_dw_array_get(0)->field_E0(v21); - } + const motion_set_info& set_info = aft_mot_db->motion_set[data.motion_set_index[0]]; + for (const motion_info& i : set_info.motion) + data_test_mot_dw_array_get(0)->AddID(i.name.c_str()); - data_mot_test_dw_array_get(0)->sub_14028EB80();*/ + data_test_mot_dw_array_get(0)->ResetIDListBoxIndex(); - data.curr_motion_index_p1 = 0; - data.motion_index_p1 = 0; + data.curr_motion_index[0] = 0; + data.motion_index[0] = 0; v3 = true; v2 = true; } - if (data.motion_set_index_p2 != data.curr_motion_set_index_p2) { - data.curr_motion_set_index_p2 = data.motion_set_index_p2; + if (data.motion_set_index[1] != data.curr_motion_set_index[1]) { + data.curr_motion_set_index[1] = data.motion_set_index[1]; - /*data_mot_test_dw_array_get(1)->field_D8(); + data_test_mot_dw_array_get(1)->ClearIDs(); - uint32_t v24 = motion_database_set_indices_get_id(data.motion_set_index_p2); - uint32_t v18 = motion_database_get_set_motion_count(v24); - for (uint32_t i = 0; i < v18; i++) { - uint32_t v28 = motion_database_get_motion_id(v24, i); - const char* v29 = motion_database_get_motion_name_by_motion_index(v28); - data_mot_test_dw_array_get(0)->field_E0(v29); - } + const motion_set_info& set_info = aft_mot_db->motion_set[data.motion_set_index[0]]; + for (const motion_info& i : set_info.motion) + data_test_mot_dw_array_get(1)->AddID(i.name.c_str()); - data_mot_test_dw_array_get(1)->sub_14028EB80();*/ + data_test_mot_dw_array_get(1)->ResetIDListBoxIndex(); - data.curr_motion_index_p2 = 0; - data.motion_index_p2 = 0; + data.curr_motion_index[1] = 0; + data.motion_index[1] = 0; v3 = true; v2 = true; } - bool v59 = false; - if (data.motion_index_p1 != data.curr_motion_index_p1) { - data.curr_motion_index_p1 = data.motion_index_p1; - dtm_mot_array[0].SetMotion(data.motion_set_index_p1, data.motion_index_p1); - dtm_mot_array[1].SetMotion(data.motion_set_index_p2, data.motion_index_p2); + bool frame_comp = false; + if (data.motion_index[0] != data.curr_motion_index[0]) { + data.curr_motion_index[0] = data.motion_index[0]; + dtm_mot_array[0].SetMotion(data.motion_set_index[0], data.motion_index[0]); + dtm_mot_array[1].SetMotion(data.motion_set_index[1], data.motion_index[1]); dtm_mot_array[0].SetChangeMotion(); dtm_mot_array[1].SetChangeMotion(); - v59 = true; + frame_comp = true; } - if (data.motion_index_p2 != data.curr_motion_index_p2) { - data.curr_motion_index_p2 = data.motion_index_p2; - dtm_mot_array[0].SetMotion(data.motion_set_index_p1, data.motion_index_p1); - dtm_mot_array[1].SetMotion(data.motion_set_index_p2, data.motion_index_p2); + if (data.motion_index[1] != data.curr_motion_index[1]) { + data.curr_motion_index[1] = data.motion_index[1]; + dtm_mot_array[0].SetMotion(data.motion_set_index[0], data.motion_index[0]); + dtm_mot_array[1].SetMotion(data.motion_set_index[1], data.motion_index[1]); dtm_mot_array[0].SetChangeMotion(); dtm_mot_array[1].SetChangeMotion(); } - dtm_mot_array[0].SetRotationY(data.rot_y_p1); - dtm_mot_array[1].SetRotationY(data.rot_y_p2); - dtm_mot_array[0].SetTrans({ data.trans_x_p1, 0.0f, 0.0f }); - dtm_mot_array[1].SetTrans({ data.trans_x_p2, 0.0f, 0.0f }); - dtm_mot_array[0].SetOffset(data.pre_offset_p1, data.post_offset_p1); - dtm_mot_array[1].SetOffset(data.pre_offset_p2, data.post_offset_p2); - dtm_mot_array[0].SetStartFrame(data.start_frame_p1); - dtm_mot_array[1].SetStartFrame(data.start_frame_p2); + dtm_mot_array[0].SetRotationY(data.rot_y[0]); + dtm_mot_array[1].SetRotationY(data.rot_y[1]); + dtm_mot_array[0].SetTrans({ data.trans_x[0], 0.0f, 0.0f }); + dtm_mot_array[1].SetTrans({ data.trans_x[1], 0.0f, 0.0f }); + dtm_mot_array[0].SetOffset(data.offset[0].pre, data.offset[0].post); + dtm_mot_array[1].SetOffset(data.offset[1].pre, data.offset[1].post); + dtm_mot_array[0].SetStartFrame(data.start_frame[0]); + dtm_mot_array[1].SetStartFrame(data.start_frame[1]); for (int32_t i = 0; i < 3; i++) { - dtm_mot_array[0].SetDivide(i, data.divide_p1.array[i]); - dtm_mot_array[1].SetDivide(i, data.divide_p2.array[i]); + dtm_mot_array[0].SetDivide(i, data.divide[0].array[i]); + dtm_mot_array[1].SetDivide(i, data.divide[1].array[i]); } for (int32_t i = 0; i < 4; i++) { - dtm_mot_array[0].SetStep(i, data.step_p1.array[i]); - dtm_mot_array[1].SetStep(i, data.step_p2.array[i]); + dtm_mot_array[0].SetStep(i, data.step[0].array[i]); + dtm_mot_array[1].SetStep(i, data.step[1].array[i]); } switch (data.type) { @@ -252,14 +269,14 @@ bool DataTestMot::Ctrl() { if (v3) dtm_mot_array[0].DelTask(); else - dtm_mot_array[0].AddTask(data.chara_index_p1, - data.module_index_p1, data.motion_set_index_p1, data.motion_index_p1); + dtm_mot_array[0].AddTask(data.chara_index[0], + data.module_index[0], data.motion_set_index[0], data.motion_index[0]); if (v2) dtm_mot_array[1].DelTask(); else - dtm_mot_array[1].AddTask(data.chara_index_p2, - data.module_index_p2, data.motion_set_index_p2, data.motion_index_p2); + dtm_mot_array[1].AddTask(data.chara_index[1], + data.module_index[1], data.motion_set_index[1], data.motion_index[1]); if (data.reset_cam) { data.reset_cam = false; @@ -283,20 +300,20 @@ bool DataTestMot::Ctrl() { if (data.field_A8) { data.field_A8 = false; - //sub_1401F9510(data.field_A9 ? 32.2673416137695 : 32.8125); + //rctx_ptr->camera->set_fov(data.field_A9 ? 32.2673416137695 : 32.8125); } - /*if (data.running && dtm_mot_array[0].sub_140291B70() && !v59 - && data.motion_index_p1 < aft_mot_db->motion_set[data.motion_set_index_p1].motion.size()) { - data.curr_motion_index_p1 = data.motion_index_p1; - data.motion_index_p1 = data.motion_index_p1 + 1; - dtm_mot_array[0].SetMotion(data.motion_set_index_p1, data.motion_index_p1); - dtm_mot_array[1].SetMotion(data.motion_set_index_p2, data.motion_index_p2); - dtm_mot_array[0].sub_140291F20(); - dtm_mot_array[1].sub_140291F20(); + if (data.running && dtm_mot_array[0].CheckFirstFrame() && !frame_comp + && data.motion_index[0] < aft_mot_db->motion_set[data.motion_set_index[0]].motion.size()) { + data.curr_motion_index[0] = data.motion_index[0]; + data.motion_index[0] = data.motion_index[0] + 1; + dtm_mot_array[0].SetMotion(data.motion_set_index[0], data.motion_index[0]); + dtm_mot_array[1].SetMotion(data.motion_set_index[1], data.motion_index[1]); + dtm_mot_array[0].SetChangeMotion(); + dtm_mot_array[1].SetChangeMotion(); - //data_mot_test_dw_array_get(0)->sub_14028EF90(data.motion_index_p1); - }*/ + data_test_mot_dw_array_get(0)->SetIDListBoxIndex(data.motion_index[0]); + } motion_test_objset_check_not_read(); sub_140286280(); @@ -309,15 +326,15 @@ bool DataTestMot::Dest() { dtm_mot_array[0].DelTask(); dtm_mot_array[1].DelTask(); - //data_mot_test_dw_array_get(0)->field_D0(); - //data_mot_test_dw_array_get(1)->field_D0(); - //data_test_mot_ctrl_dw_get()->field_D0(); - //data_test_mot_a3d_dw()->field_D0(); - //sub_140263340(); - dtm_eq_vs_array[0].DelTask(); - dtm_eq_vs_array[1].DelTask(); + data_test_mot_dw_array_get(0)->Hide(); + data_test_mot_dw_array_get(1)->Hide(); + data_test_mot_ctrl_dw_get()->Hide(); + data_test_mot_a3d_dw_get()->Hide(); + data_test_face_mot_dw_array_unload(); + //dtm_eq_vs_array[0].DelTask(); + //dtm_eq_vs_array[1].DelTask(); motion_test_objset_unload(); - //data_mot_test_a3d_get()->DelTask(); + data_test_mot_a3d_get()->DelTask(); return true; } @@ -326,17 +343,207 @@ void DataTestMot::Disp() { } void DataTestMot::sub_140286280() { - /*dtm_mot_array[0].sub_1402922C0(true); dtm_mot_array[0].sub_1402922C0(true); - if (this->data.sync_frame && (!dtm_mot_array[0].sub_140291C10() || !dtm_mot_array[1].sub_140291C10())) { + dtm_mot_array[0].sub_1402922C0(true); + if (data.sync_frame && (!dtm_mot_array[0].sub_140291C10() || !dtm_mot_array[1].sub_140291C10())) { dtm_mot_array[0].sub_1402922C0(false); dtm_mot_array[0].sub_1402922C0(false); - }*/ + } } -DtmMot::DtmMot() : rob_bone_data(), field_7C(), field_A8(), pre_offset(), post_offset(), divide(), +DataTestMotA3d::DataTestMotA3d() : state(), camera() { + +} + +DataTestMotA3d::~DataTestMotA3d() { + +} + +bool DataTestMotA3d::Init() { + Reset(); + auth_3d.clear(); + state = 0; + return true; +} + +bool DataTestMotA3d::Ctrl() { + switch (state) { + case 0: + state = 1; + break; + case 1: + Sync1pFrame(); + break; + case 2: { + Reset(); + + LoadAuth3d(std::string(auth_3d)); + + data_struct* aft_data = &data_list[DATA_AFT]; + object_database* aft_obj_db = &aft_data->data_ft.obj_db; + + for (uint32_t& i : obj_sets) + object_storage_load_set(aft_data, aft_obj_db, i); + + state = 3; + } break; + case 3: { + bool wait_load = false; + + for (uint32_t& i : obj_sets) + if (object_storage_load_obj_set_check_not_read(i)) + return false; + + if (wait_load) + break; + + for (std::string& i : categories) + auth_3d_data_load_category(i.c_str()); + + state = 4; + } break; + case 4: { + bool wait_load = false; + + for (std::string& i : categories) + if (!auth_3d_data_check_category_loaded(i.c_str())) + wait_load |= true; + + if (wait_load) + break; + + data_struct* aft_data = &data_list[DATA_AFT]; + auth_3d_database* aft_auth_3d_db = &aft_data->data_ft.auth_3d_db; + + for (auth_3d_id& i : auth_3d_ids) + i.read_file(aft_auth_3d_db); + + state = 5; + } break; + case 5: { + bool wait_load = false; + + for (auth_3d_id& i : auth_3d_ids) + if (!i.check_loaded()) + wait_load |= true; + + if (wait_load) + break; + + for (auth_3d_id& i : auth_3d_ids) + i.set_enable(true); + + state = 1; + } break; + case 6: + return true; + } + return false; +} + +bool DataTestMotA3d::Dest() { + Reset(); + camera = false; + return true; +} + +void DataTestMotA3d::Disp() { + +} + +void DataTestMotA3d::Basic() { + +} + +const char* DataTestMotA3d::GetStateText() { + switch (state) { + case 0: + return "A3D: 初期化中..."; + case 1: + return "A3D: 命令待機中..."; + case 2: + return "A3D: データリクエスト中..."; + case 3: + return "A3D: PVステージ読込中..."; + case 4: + return "A3D: A3Dカテゴリ読込中..."; + case 5: + return "A3D: A3Dハンドル読込中..."; + default: + return "A3D: 未知のモード"; + } +} + +void DataTestMotA3d::LoadAuth3d(std::string&& name) { + data_struct* aft_data = &data_list[DATA_AFT]; + auth_3d_database* aft_auth_3d_db = &aft_data->data_ft.auth_3d_db; + object_database* aft_obj_db = &aft_data->data_ft.obj_db; + + int32_t uid = aft_auth_3d_db->get_uid(name.c_str()); + if (uid == -1) + return; + + auth_3d_id id = auth_3d_data_load_uid(uid, aft_auth_3d_db); + if (!id.check_not_empty()) + return; + + id.set_enable(false); + id.set_repeat(true); + + auth_3d_ids.push_back(id); + + if (!name.find("CAM")) { + if (!camera) + camera = true; + } + else { + if (camera) + camera = false; + } + + std::string category(aft_auth_3d_db->uid[uid].category.c_str()); + categories.push_back(category); + auth_3d_data_get_obj_sets_from_category(category, obj_sets, aft_auth_3d_db, aft_obj_db); +} + +void DataTestMotA3d::Reset() { + for (std::string& i : categories) + auth_3d_data_unload_category(i.c_str()); + + categories.clear(); + + for (auth_3d_id& i : auth_3d_ids) + i.unload(rctx_ptr); + + auth_3d_ids.clear(); + + for (uint32_t& i : obj_sets) + object_storage_unload_set(i); + + obj_sets.clear(); +} + +void DataTestMotA3d::SetAuth3d(std::string& value) { + if (state != 1) + return; + + auth_3d.assign(value); + state = 2; +} + +void DataTestMotA3d::Sync1pFrame() { + if (!data_test_mot_data_get()->sync_1p_frame) + return; + + float_t frame = dtm_mot_array->GetFrame(); + + for (auth_3d_id& i : auth_3d_ids) + i.set_req_frame(frame); +} + +DtmMot::DtmMot() : rob_bone_data(), field_7C(), rot_y(), pre_offset(), post_offset(), divide(), loop(), change_motion(), use_opd(), field_D6(), reset_mot(), save_only_start_frame(), state(), -frame(), field_E4(), field_E8(), start_frame(), a_frame(), b_frame(), ab_loop(), field_2C960() { +frame(), delta_frame(), looped(), start_frame(), ab_frame(), ab_loop(), set_motion_index() { chara_id = -1; chara_index = CHARA_MAX; module_index = 502; @@ -360,12 +567,12 @@ DtmMot::~DtmMot() { bool DtmMot::Init() { frame = 0.0f; - field_E4 = 1.0f; + delta_frame = 1.0f; state = 1; - field_E8 = 0; + looped = 0; if (chara_index < CHARA_MIKU || chara_index >= CHARA_MAX || module_index >= 502) { - this->state = 0; + state = 0; return true; } @@ -393,25 +600,408 @@ bool DtmMot::Init() { return true; } +bool DtmMot::sub_140291C10() { + if (state) + return field_D6; + return true; +} + +void DtmMot::sub_1402922C0(bool value) { + this->field_100 = value; +} + bool DtmMot::Ctrl() { + data_struct* aft_data = &data_list[DATA_AFT]; + bone_database* aft_bone_data = &aft_data->data_ft.bone_data; + motion_database* aft_mot_db = &aft_data->data_ft.mot_db; + + switch (state) { + case 1: { + if (pv_id >= 0) { + const pv_db_pv_difficulty* diff = task_pv_db_get_pv_difficulty(pv_id, PV_DIFFICULTY_HARD, 0); + if (diff) { + dsc_file_handler.reset(); + dsc_file_handler.read_file(aft_data, diff->script_file_name.c_str()); + } + } + + motion_set_load_motion(motion_set_id, "", aft_mot_db); + motion_set_load_mothead(motion_set_id, "", aft_mot_db); + state = 2; + } break; + case 2: { + if (motion_storage_check_mot_file_not_ready(motion_set_id) + || mothead_storage_check_mhd_file_not_ready(motion_set_id) + || dsc_file_handler.check_not_ready()) + break; + + state = 3; + } break; + case 3: { + if (chara_id >= 0 && chara_id < ROB_CHARA_COUNT && task_rob_manager_get_wait(chara_id)) + break; + + rob_chara_pv_data pv_data; + pv_data.type = ROB_CHARA_TYPE_3; + + module_data data; + if (module_data_handler_data_get_module(chara_index, module_index, data)) { + pv_data.sleeve_l = data.sleeve_l; + pv_data.sleeve_r = data.sleeve_r; + } + + chara_id = rob_chara_array_init_chara_index(chara_index, pv_data, module_index, true); + state = 4; + } break; + case 4: { + if (!task_rob_manager_check_chara_loaded(chara_id)) + break; + + rob_bone_data = rob_chara_array_get_bone_data(chara_id); + state = 7; + } break; + case 5: { + if (osage_play_data_manager_check_task_ready()) + break; + + osage_play_data_manager_append_chara_motion_id(rob_chara_array_get(chara_id), motion_id); + osage_play_data_manager_add_task(); + state = 6; + } break; + case 6: { + if (osage_play_data_manager_check_task_ready() || skin_param_manager_check_task_ready(chara_id)) + break; + + rob_chara* rob_chr = rob_chara_array_get(chara_id); + rob_chr->set_motion_id(motion_id, frame, 0.0f, true, false, MOTION_BLEND_CROSS, aft_bone_data, aft_mot_db); + rob_chr->set_use_opd(true); + state = 11; + } break; + case 7: { + field_D6 = false; + if (skin_param_manager_check_task_ready(chara_id) + || pv_osage_manager_array_get_disp(chara_id) + || osage_play_data_manager_check_task_ready()) + break; + + const pv_db_pv_difficulty* diff = task_pv_db_get_pv_difficulty(pv_id, PV_DIFFICULTY_HARD, 0); + if (pv_id > 0 && diff && dsc_file_handler.get_data()) { + if (diff) { + pv_data.reset(); + pv_data.dsc.parse(dsc_file_handler.get_data(), dsc_file_handler.get_size(), DSC_FT); + + dsc_file_handler.reset(); + + int32_t chara_id = 0; + for (auto& i : diff->motion) + for (const pv_db_pv_motion& j : i) + if (j.id == motion_id) { + chara_id = (int32_t)(&i - diff->motion); + break; + } + + pv_data.find_playdata_set_motion(chara_id); + pv_data.find_set_motion(diff); + const std::vector* set_motion = pv_data.get_set_motion(chara_id); + if (set_motion) { + this->set_motion.assign(set_motion->begin(), set_motion->end()); + const mothead_mot* mhdm = mothead_storage_get_mot_by_motion_id(motion_id, aft_mot_db); + if (mhdm) + for (const mothead_data& i : mhdm->data) { + if (i.type != MOTHEAD_DATA_WIND_RESET) + continue; + + auto j_begin = this->set_motion.begin(); + auto j_end = this->set_motion.end(); + for (auto j = j_begin; j != j_end; ) + if ((float_t)i.frame == j->frame_stage_index.first) { + std::move(j + 1, j_end, j); + this->set_motion.pop_back(); + j_end = this->set_motion.end(); + } + else + j++; + } + } + } + } + + task_rob_manager_hide_task(); + task_wind_hide_task(); + reset_mot = false; + state = 8; + } break; + case 8: { + rob_chara* rob_chr = rob_chara_array_get(chara_id); + rob_chr->set_use_opd(false); + + skin_param_manager_reset(chara_id); + + std::vector vec; + vec.push_back({ rob_chr }); + vec.push_back({ rob_chr, pv_id, motion_id }); + + const pv_db_pv* pv = task_pv_db_get_pv(pv_id); + if (pv) { + for (const pv_db_pv_osage_init& i : pv->osage_init) { + uint32_t mot_id = aft_mot_db->get_motion_id(i.motion.c_str()); + if (mot_id != -1 && mot_id == motion_id) + vec.push_back({ rob_chr, pv_id, mot_id, "", i.frame }); + } + + for (pv_data_set_motion& i : set_motion) + vec.push_back({ rob_chr, pv->id, i.motion_id, "", (int32_t)roundf(i.frame_stage_index.first) }); + + } + skin_param_manager_add_task(chara_id, vec); + + state = 9; + + bool has_opd = false; + const uint32_t* opd_motion_set_ids = get_opd_motion_set_ids(); + while (*opd_motion_set_ids != -1) { + if (*opd_motion_set_ids != motion_set_id) { + opd_motion_set_ids++; + continue; + } + + if (use_opd) + state = 5; + break; + } + + } break; + case 9: { + if (skin_param_manager_check_task_ready(chara_id)) + break; + + pv_osage_manager_array_reset(chara_id); + if (save_only_start_frame) { + pv_data_set_motion motion; + motion.motion_id = motion_id; + motion.frame_stage_index.first = start_frame; + motion.frame_stage_index.second = task_stage_get_current_stage_index(); + + std::vector set_motion; + set_motion.push_back(motion); + pv_osage_manager_array_set_pv_set_motion(chara_id, set_motion); + } + else { + std::vector motion_ids; + motion_ids.push_back(motion_id); + pv_osage_manager_array_set_motion_ids(chara_id, motion_ids); + + if (pv_id >= 0) + pv_osage_manager_array_set_pv_set_motion(chara_id, set_motion); + } + + /*if (pv_id >= 0) { + stage_param_data_coli_data_clear(); + stage_param_data_coli_data_load(pv_id); + }*/ + + pv_osage_manager_array_set_pv_id(chara_id, pv_id, 0); + state = 10; + } break; + case 10: { + if (pv_osage_manager_array_get_disp()) + break; + + /*int32_t stage_index = task_stage_get_current_stage_index(); + if (stage_index != -1) + rob_chara_array_get(chara_id)->set_stage_data_ring(stage_index);*/ + state = 11; + } break; + case 11: { + field_D6 = true; + if (!field_100) + break; + + task_rob_manager_run_task(); + task_wind_run_task(); + state = 12; + } break; + case 12: { + frame = start_frame; + + rob_chara* rob_chr = rob_chara_array_get(chara_id); + rob_chr->set_step_motion_step(1.0f); + rob_chr->set_motion_id(motion_id, frame, 0.0f, true, true, MOTION_BLEND_CROSS, aft_bone_data, aft_mot_db); + + set_motion_index = 0; + + if (data_test_face_mot_dw_array_get(chara_id)) + data_test_face_mot_dw_array_get(chara_id)->Reset(); + state = 13; + } + case 13: { + if (reset_mot) { + state = 7; + break; + } + + rob_chara* rob_chr = rob_chara_array_get(chara_id); + + float_t frame = 0.0f; + if (frame >= pre_offset) + frame = min_def(rob_chr->data.field_1588.field_0.frame, frame - pre_offset); + + rob_bone_data->sub_14041DBA0(); + + rob_chr->set_frame(frame); + rob_chr->set_step_motion_step(delta_frame); + + if (looped) { + rob_chr->sub_140551000(); + set_motion_index = 0; + } + + rob_chr->sub_1405070E0(aft_bone_data, aft_mot_db); + rob_chr->arm_adjust_ctrl(); + + if (!partial_mot) { + rob_bone_data->load_face_motion(-1, aft_mot_db); + rob_bone_data->load_hand_l_motion(-1, aft_mot_db); + rob_bone_data->load_hand_r_motion(-1, aft_mot_db); + rob_bone_data->load_mouth_motion(-1, aft_mot_db); + rob_bone_data->load_eyes_motion(-1, aft_mot_db); + rob_bone_data->load_eyelid_motion(-1, aft_mot_db); + } + + CtrlFaceMot(); + + rob_bone_data->interpolate(); + + mat4 mat; + mat4_rotate_zyx(&rotation, &mat); + mat4_rotate_y_mult(&mat, rot_y, &mat); + mat4_set_translation(&mat, &trans); + rob_bone_data->update(&mat); + + rob_chr->adjust_ctrl(); + rob_chr->set_data_adjust_mat(&rob_chr->data.adjust_data); + rob_chr->rob_motion_modifier_ctrl(); + rob_chr->sub_140509D30(); + + if (data_test_mot_dw_array_get(chara_id)) { + data_test_mot_dw_array_get(chara_id)->SetFrameSlider(GetFrame(), GetFrameCount() + pre_offset + post_offset); + data_test_mot_dw_array_get(chara_id)->SetFrameLabel(GetFrame(), GetFrameCount()); + } + + if (change_motion) + change_motion = false; + + if (rob_chara_array_check_visibility(chara_id) != disp) + rob_chara_array_set_visibility(chara_id, disp); + + rob_chr->rob_info_ctrl(); + + while (set_motion_index < set_motion.size()) { + if (set_motion.data()[set_motion_index].motion_id != motion_id) { + set_motion_index++; + continue; + } + + float_t frame = (float_t)(int32_t)roundf(set_motion.data()[set_motion_index].frame_stage_index.first); + if (frame > this->frame) + break; + + rob_chr->set_motion_reset_data(motion_id, frame); + rob_chr->set_motion_skin_param(motion_id, frame); + set_motion_index++; + } + } break; + } return false; } bool DtmMot::Dest() { + if (!state) + return true; + + pv_osage_manager_array_set_not_reset_true(); + if (skin_param_manager_check_task_ready(chara_id) + || pv_osage_manager_array_get_disp() + || osage_play_data_manager_check_task_ready()) + return false; + + task_rob_manager_run_task(); + task_wind_run_task(); + if (rob_chara_array_get(chara_id)) + rob_chara_array_free_chara_id(chara_id); + motion_set_unload_motion(motion_set_id); + motion_set_unload_mothead(motion_set_id); + skin_param_manager_reset(chara_id); + //stage_param_data_coli_data_clear(); + osage_play_data_manager_reset(); + set_motion.clear(); + set_motion_index = 0; + dsc_file_handler.reset(); + pv_data.reset(); + rob_bone_data = 0; + state = 1; return true; } void DtmMot::Basic() { + if (state != 13) + return; + int32_t step_index = 3; + for (int32_t i = 0; i < 4; i++) + if (frame >= divide[i]) { + step_index = i; + break; + } + + float_t frame = this->frame; + + delta_frame = get_delta_frame() * step[step_index]; + looped = false; + + if (play) + frame += delta_frame; + + rob_chara* rob_chr = rob_chara_array_get(chara_id); + + float_t begin = 0.0f; + float_t end = rob_chr->data.field_1588.field_0.frame; + if (ab_loop) { + begin = ab_frame[0]; + end = ab_frame[1]; + } + + end += pre_offset + post_offset; + if (frame < begin) + if (loop || ab_loop) + frame += end; + else + frame = begin; + + if (frame >= end) { + if (ab_loop) { + looped = true; + frame = begin; + } + else if (loop) { + looped = true; + frame -= end; + frame += rob_chr->data.field_1588.field_0.loop_begin; + } + else + frame = end; + } + + this->frame = frame; } bool DtmMot::AddTask(::chara_index chara_index, - int32_t module_index, int32_t motion_set_id, int32_t motion_id) { + int32_t module_index, uint32_t motion_set_id, uint32_t motion_id) { return true; } bool DtmMot::AddTask(::chara_index chara_index, - int32_t module_index, int32_t motion_id) { + int32_t module_index, uint32_t motion_id) { return true; } @@ -421,6 +1011,49 @@ bool DtmMot::DelTask() { return false; } +bool DtmMot::CheckFirstFrame() { + if (rob_bone_data) + return false; + + rob_chara* rob_chr = rob_chara_array_get(chara_id); + if (!rob_chr) + return false; + + float_t frame_count = rob_chr->data.field_1588.field_0.frame + pre_offset + post_offset; + if (frame_count > 0.0f) + return fabsf(frame_count - frame) <= 0.000001f; + return false; +} + +void DtmMot::CtrlFaceMot() { + DataTestFaceMotDw* face_mot_dw = data_test_face_mot_dw_array_get(chara_id); + if (!face_mot_dw) + return; + + if (!face_mot_dw->GetEnable()) + return; + + data_struct* aft_data = &data_list[DATA_AFT]; + motion_database* aft_mot_db = &aft_data->data_ft.mot_db; + + DataTestFaceMotDw::Data data = face_mot_dw->GetData(); + rob_chara* rob_chr = rob_chara_array_get(chara_id); + rob_chr->set_face_mottbl_motion(0, data.face.mottbl_index, data.face.frame * 0.01f, + 0, 0.0f, 0.0f, 1.0f, -1, 0.0f, false, aft_mot_db); + rob_chr->set_eyelid_mottbl_motion(0, data.eyelid.mottbl_index, data.eyelid.frame * 0.01f, + 0, 0.0f, 0.0f, 1.0f, -1, 0.0f, aft_mot_db); + rob_chr->set_eyes_mottbl_motion(0, data.eyes.mottbl_index, data.eyes.frame * 0.01f, + 0, 0.0f, 0.0f, 1.0f, -1, 0.0f, aft_mot_db); + rob_chr->set_mouth_mottbl_motion(0, data.mouth.mottbl_index, data.mouth.frame * 0.01f, + 0, 0.0f, 0.0f, 1.0f, -1, 0.0f, aft_mot_db); +} + +void DtmMot::GetABLoop(bool& ab_loop, float_t& a_frame, float_t& b_frame) { + ab_loop = this->ab_loop; + a_frame = ab_frame[0]; + b_frame = ab_frame[1]; +} + float_t DtmMot::GetFrame() { if (state == 13) return frame; @@ -437,6 +1070,21 @@ float_t DtmMot::GetStep() { return step[3]; } +void DtmMot::ResetABLoop() { + ab_loop = false; + ab_frame[0] = 0.0f; + ab_frame[1] = 0.0f; +} + +void DtmMot::SetABFrame(bool a) { + if (a) + ab_frame[0] = frame; + else + ab_frame[1] = frame; + + UpdateABFrame(); +} + void DtmMot::SetChangeMotion() { change_motion = true; } @@ -496,7 +1144,7 @@ void DtmMot::SetResetMot() { } void DtmMot::SetRotationY(float_t value) { - rotatation.y = value; + rotation.y = value; } void DtmMot::SetSaveOnlyStartFrame(bool value) { @@ -520,6 +1168,44 @@ void DtmMot::SetUseOpd(bool value) { use_opd = value; } +void DtmMot::ToggleABLoop() { + if (!ab_loop) + UpdateABFrame(); + + ab_loop = !ab_loop; +} + +void DtmMot::UpdateABFrame() { + rob_chara* rob_chr = rob_chara_array_get(chara_id); + if (!rob_chr) + return; + + float_t v3 = rob_chr->data.field_1588.field_0.frame; + for (float_t& i : ab_frame) + i = clamp_def(i, 0.0f, v3); + + if (ab_frame[0] < ab_frame[1]) + return; + + bool found = false; + float_t a_frame = ab_frame[0]; + int32_t b_frame = (int32_t)v3; + + for (pv_data_set_motion& i : set_motion) + if (i.motion_id == motion_id && i.frame_stage_index.first > a_frame) { + if ((int32_t)i.frame_stage_index.first) { + b_frame = (int32_t)i.frame_stage_index.first; + found = true; + } + break; + } + + if (!found) + b_frame = (int32_t)v3; + + ab_frame[1] = (float_t)b_frame; +} + int32_t DtmMot::ConvertMotionSetNameToPVID(const char* set_name) { if (!set_name) return -1; @@ -542,211 +1228,1275 @@ int32_t DtmMot::ConvertMotionSetNameToPVID(const char* set_name) { return pv_id; } -DtmEqVs::DtmEqVs() : chara_id(), chara_index(), curr_chara_index(), -module_index(), curr_module_index(), field_80() { - state = -1; -} - -DtmEqVs::~DtmEqVs() { - -} - -bool DtmEqVs::Init() { - state = 0; - return true; -} - -bool DtmEqVs::Ctrl() { - rob_chara_item_cos_data* item_cos_data = rob_chara_array_get_item_cos_data(chara_id); - rob_chara* rob_chr = rob_chara_array_get(chara_id); - switch (state) { - case 0: - //data_test_equip_dw_sub_14025FCC0(this->chara_id); - //data_test_equip_dw_sub_14025FA80(this->chara_id, item_cos_data->get_cos()); - state = 3; - case 3: - if (false /*dtm_mot_array_sub_140287740()*/) { - sub_140262050(); - sub_140261FF0(); - - int32_t item_no = ITEM_NONE;//data_test_equip_dw_sub_14025FB20(this->chara_id); - ::item_cos_data temp_cos; - if (rob_chr) - temp_cos = *rob_chr->item_cos_data.get_cos(); - - bool v2 = false; - /*if (data_test_equip_dw_sub_14025FAF0(chara_id)) { - item_cos_data->set_chara_index_item(chara_index, item_no); - v2 = true; - }*/ - - /*if (data_test_equip_dw_sub_14025FB80(chara_id)) { - item_cos_data->set_chara_index_item_zero(chara_index, item_no); - v2 = true; - }*/ - - const ::item_cos_data* cos = 0;//data_test_equip_dw_get_cos(chara_id); - if (cos) { - item_cos_data->set_chara_index_item_nos(chara_index, cos->arr); - v2 = true; - } - - /*if (sub_1402CEEC0(chara_id)) { - v2 = true; - sub_1402CF8F0(); - }*/ - - //data_test_equip_dw_sub_14025FBE0(chara_id); - - if (v2) { - if (rob_chr) - task_rob_load_append_free_req_data_obj(rob_chr->chara_index, &temp_cos); - rob_chara_array_reset_bone_data_item_equip(chara_id); - task_rob_manager_hide_task(); - state = 1; - } - } - break; - case 1: - if (rob_chr->chara_index) { - task_rob_load_append_load_req_data_obj(rob_chr->chara_index, rob_chr->item_cos_data.get_cos()); - state = 2; - } - break; - case 2: - if (!task_rob_load_check_load_req_data()) { - task_rob_manager_run_task(); - if (rob_chara_array_get(chara_id)) { - data_struct* aft_data = &data_list[DATA_AFT]; - bone_database* aft_bone_data = &aft_data->data_ft.bone_data; - object_database* aft_obj_db = &aft_data->data_ft.obj_db; - item_cos_data->reload_items(chara_id, aft_bone_data, aft_data, aft_obj_db); - } - auth_3d_test_task_disp_chara(); - dtm_mot_array_set_reset_mot(); - this->state = 3; - } - break; - } - return false; -} - -bool DtmEqVs::Dest() { - return true; -} - -bool DtmEqVs::AddTask(int32_t chara_id, ::chara_index chara_index) { +DataTestFaceMotDw::DataTestFaceMotDw(int32_t chara_id) { this->chara_id = chara_id; - this->chara_index = chara_index; - this->curr_chara_index = chara_index; - module_index = 0; - curr_module_index = 0; - this->field_80 = 0; - //data_test_equip_dw_set_chara_index(chara_id, chara_index); - //data_test_equip_dw_set_module_index(chara_id, module_index); - return app::TaskWork::AddTask(this, "DATA TEST EQUIP MANAGER FOR VS"); - return true; + + SetName("Face motion"); + + enable = new dw::Button(this, dw::CHECKBOX); + enable->SetName("Enable"); + enable->SetValue(false); + + dw::Group* motion_group = new dw::Group(this); + motion_group->SetLayout(new dw::GridLayout(3)); + motion_group->SetName("Motion"); + + (new dw::Label(motion_group))->SetName("FACE "); + + face = InitAddMottblMapMotions(motion_group, 0); + + face_frame = dw::Slider::make(motion_group); + face_frame->SetName("Frame "); + face_frame->format = "%4.0f"; + face_frame->SetParams(0.0f, 0.0f, 100.0f, 10.0f, 1.0f, 10.0f); + + (new dw::Label(motion_group))->SetName("FACE_CL "); + + face_cl = new dw::Label(motion_group); + face_cl->SetName(""); + + face_cl_frame = dw::Slider::make(motion_group); + face_cl_frame->SetName("Frame"); + face_cl_frame->format = "%4.0f"; + face_cl_frame->SetParams(0.0f, 0.0f, 100.0f, 10.0f, 1.0f, 10.0f); + + (new dw::Label(motion_group))->SetName("EYES "); + + eyes = InitAddMottblMapMotions(motion_group, 1); + + eyes_frame = dw::Slider::make(motion_group); + eyes_frame->SetName("Frame"); + eyes_frame->format = "%4.0f"; + eyes_frame->SetParams(0.0f, 0.0f, 100.0f, 10.0f, 1.0f, 10.0f); + + (new dw::Label(motion_group))->SetName("MOUTH "); + + mouth = InitAddMottblMapMotions(motion_group, 2); + + mouth_frame = dw::Slider::make(motion_group); + mouth_frame->SetName("Frame"); + mouth_frame->format = "%4.0f"; + mouth_frame->SetParams(0.0f, 0.0f, 100.0f, 10.0f, 1.0f, 10.0f); + + //GetSetSize(); } -bool DtmEqVs::DelTask() { - return app::Task::DelTask(); +DataTestFaceMotDw::~DataTestFaceMotDw() { + } -void DtmEqVs::SetCharaIndexModuleIndex(::chara_index chara_index, int32_t module_index) { - this->chara_index = chara_index; - this->module_index = module_index; - //data_test_equip_dw_set_chara_index(chara_id, chara_index); - //data_test_equip_dw_set_module_index(chara_id, module_index); +void DataTestFaceMotDw::Hide() { + data_test_face_mot_dw_array[chara_id] = 0; + dw::Shell::Hide(); } -void DtmEqVs::sub_140261FF0() { - if (chara_index == curr_chara_index && module_index == curr_module_index) +void DataTestFaceMotDw::AddMottblMapMotions(dw::ListBox* list_box, int32_t type) { + data_struct* aft_data = &data_list[DATA_AFT]; + motion_database* aft_mot_db = &aft_data->data_ft.mot_db; + + size_t selected_item = list_box->list->selected_item; + if (selected_item >= list_box->list->items.size()) + selected_item = 0; + + list_box->ClearItems(); + + rob_chara* rob_chr = rob_chara_array_get(chara_id); + if (!rob_chr) return; - curr_chara_index = chara_index; - curr_module_index = module_index; - const item_cos_data* cos = item_table_handler_array_get_item_cos_data_by_module_index(chara_index, module_index); - if (!check_module_index_is_501(curr_module_index) || !cos) { - //data_test_equip_dw_sub_14025FCC0(chara_id); - //data_test_equip_dw_sub_14025FA80(chara_id, cos); + switch (type) { + case 0: + for (int32_t i = 6; i <= 130; i++) { + uint32_t motion_id = rob_chr->get_rob_cmn_mottbl_motion_id(i); + if (motion_id != -1) { + if (motion_id_mottbl_map.insert({ motion_id, i }).second) { + std::string motion_name(aft_mot_db->get_motion_name(motion_id)); + if (motion_name.find("_CL") != motion_name.size() - 3) + list_box->AddItem(motion_name); + } + } + } + break; + case 1: + for (int32_t i = 165; i <= 191; i++) { + uint32_t motion_id = rob_chr->get_rob_cmn_mottbl_motion_id(i); + if (motion_id != -1) { + motion_id_mottbl_map.insert({ motion_id, i }); + list_box->AddItem(aft_mot_db->get_motion_name(motion_id)); + } + } + break; + case 2: + for (int32_t i = 131; i <= 164; ++i) { + uint32_t motion_id = rob_chr->get_rob_cmn_mottbl_motion_id(i); + if (motion_id != -1) { + motion_id_mottbl_map.insert({ motion_id, i }); + list_box->AddItem(aft_mot_db->get_motion_name(motion_id)); + } + } + break; + } + + if (selected_item >= list_box->list->items.size()) + selected_item = 0; + + list_box->list->SetItemIndex(selected_item); +} + +DataTestFaceMotDw::Data DataTestFaceMotDw::GetData() { + data_struct* aft_data = &data_list[DATA_AFT]; + motion_database* aft_mot_db = &aft_data->data_ft.mot_db; + + DataTestFaceMotDw::Data data = { + { 6, 0.0f }, + { 6, 0.0f }, + { 165, 0.0f }, + { 131, 0.0f }, + }; + + std::string face_mot = face->GetSelectedItem(); + auto elem_face = motion_id_mottbl_map.find(aft_mot_db->get_motion_id(face_mot.c_str())); + if (elem_face != motion_id_mottbl_map.end()) + data.face.mottbl_index = elem_face->second; + data.face.frame = face_frame->scroll_bar->value; + + std::string face_cl_mot; + if (face_mot.find("FACE_WINK_OLD") != -1) + face_cl_mot.assign("FACE_WINK_FT_OLD_CL"); + else { + face_cl_mot.assign(face_mot); + face_cl_mot.append("_CL"); + } + + uint32_t face_cl_mot_id = aft_mot_db->get_motion_id(face_cl_mot.c_str()); + if (face_cl_mot_id != -1) + face_cl->SetName(face_cl_mot); + else + face_cl->SetName("CLモーションなし"); + + auto elem_eyelid = motion_id_mottbl_map.find(face_cl_mot_id); + if (elem_eyelid != motion_id_mottbl_map.end()) + data.eyelid.mottbl_index = elem_eyelid->second; + data.eyelid.frame = face_cl_frame->scroll_bar->value; + + auto elem_eyes = motion_id_mottbl_map.find(aft_mot_db->get_motion_id(eyes->GetSelectedItem().c_str())); + if (elem_eyes != motion_id_mottbl_map.end()) + data.eyes.mottbl_index = elem_eyes->second; + data.eyes.frame = eyes_frame->scroll_bar->value; + + auto elem_mouth = motion_id_mottbl_map.find(aft_mot_db->get_motion_id(mouth->GetSelectedItem().c_str())); + if (elem_mouth != motion_id_mottbl_map.end()) + data.mouth.mottbl_index = elem_mouth->second; + data.mouth.frame = mouth_frame->scroll_bar->value; + + return data; +} + +bool DataTestFaceMotDw::GetEnable() { + return enable->value; +} + +dw::ListBox* DataTestFaceMotDw::InitAddMottblMapMotions(dw::Composite* parent, int32_t type) { + dw::ListBox* list_box = new dw::ListBox(parent); + //list_box->list->sub_1402F9930(20); + AddMottblMapMotions(list_box, type); + return list_box; +} + +void DataTestFaceMotDw::Reset() { + motion_id_mottbl_map.clear(); + AddMottblMapMotions(face, 0); + AddMottblMapMotions(eyes, 1); + AddMottblMapMotions(mouth, 2); +} + +DataTestMotDw::StepSliderProc::StepSliderProc() : index() { + +} + +DataTestMotDw::StepSliderProc::~StepSliderProc() { + +} + +void DataTestMotDw::StepSliderProc::Callback(dw::Widget* data) { + DataTestMot::Data* test_mot_data = data_test_mot_data_get(); + dw::Slider* slider = dynamic_cast(data); + if (slider) + test_mot_data->step[slider->callback_data.i32].array[index] = slider->scroll_bar->value; +} + +DataTestMotDw::CharaListBoxProc::CharaListBoxProc() : list_box() { + +} + +DataTestMotDw::CharaListBoxProc::~CharaListBoxProc() { + +} + +void DataTestMotDw::CharaListBoxProc::Callback(dw::Widget* data) { + DataTestMot::Data* test_mot_data = data_test_mot_data_get(); + dw::ListBox* list_box = dynamic_cast(data); + if (list_box) { + int32_t chara_id = list_box->callback_data.i32; + ::chara_index chara_index = (::chara_index)list_box->list->selected_item; + test_mot_data->chara_index[chara_id] = chara_index; + + DataTestMotDw* test_mot_dw = data_test_mot_dw_array_get(chara_id); + if (test_mot_dw->disp_button_proc.button->value) { + data_struct* aft_data = &data_list[DATA_AFT]; + motion_database* aft_mot_db = &aft_data->data_ft.mot_db; + + uint32_t set_id = chara_init_data_get(chara_index)->motion_set; + uint32_t set_index = -1; + for (const motion_set_info& i : aft_mot_db->motion_set) + if (i.id == set_id) { + set_index = (uint32_t)(&i - aft_mot_db->motion_set.data()); + break; + } + + test_mot_dw->c_type_list_box_proc.list_box->SetItemIndex(set_index); + test_mot_data->motion_set_index[chara_id] = set_index; + } + + test_mot_dw->AddModules(chara_id, test_mot_dw->chara_list_box_proc.list_box); } } -void DtmEqVs::sub_140262050() { - return; +DataTestMotDw::CTypeListBoxProc::CTypeListBoxProc() : list_box() { - int32_t v2 = 0;//data_test_equip_dw_sub_14025FAC0(chara_id); - /*if (v2 == field_80) - return;*/ +} - rob_chara_item_equip* rob_itm_equip = rob_chara_array_get_item_equip(chara_id); - bool disp = false; - item_id id; - switch (v2) { - default: - id = ITEM_NONE; - disp = true; - break; - case 1: - id = ITEM_NONE; - break; - case 2: - id = ITEM_OUTER; - break; - case 3: - id = ITEM_PANTS; - break; +DataTestMotDw::CTypeListBoxProc::~CTypeListBoxProc() { + +} + +void DataTestMotDw::CTypeListBoxProc::Callback(dw::Widget* data) { + DataTestMot::Data* test_mot_data = data_test_mot_data_get(); + dw::ListBox* list_box = dynamic_cast(data); + if (list_box) { + std::string str = list_box->GetSelectedItem(); + size_t start = str.find('('); + if (start != -1) { + start += 4; + + size_t end = str.find(')'); + if (end != -1) + test_mot_data->module_index[list_box->callback_data.i32] = + atoi(str.substr(start, end - start).c_str()) - 1; + } + } +} + +DataTestMotDw::SetListBoxProc::SetListBoxProc() : list_box() { + +} + +DataTestMotDw::SetListBoxProc::~SetListBoxProc() { + +} + +void DataTestMotDw::SetListBoxProc::Callback(dw::Widget* data) { + DataTestMot::Data* test_mot_data = data_test_mot_data_get(); + dw::ListBox* list_box = dynamic_cast(data); + if (list_box) { + int32_t chara_id = list_box->callback_data.i32; + test_mot_data->motion_set_index[chara_id] = (int32_t)list_box->list->selected_item; + data_test_mot_dw_array_get(chara_id)->ResetFrame(); + } +} + +DataTestMotDw::IdListBoxProc::IdListBoxProc() : slider() { + +} + +DataTestMotDw::IdListBoxProc::~IdListBoxProc() { + +} + +void DataTestMotDw::IdListBoxProc::Callback(dw::Widget* data) { + +} + +DataTestMotDw::RotateSliderProc::RotateSliderProc() : slider() { + +} + +DataTestMotDw::RotateSliderProc::~RotateSliderProc() { + +} + +void DataTestMotDw::RotateSliderProc::Callback(dw::Widget* data) { + +} + +DataTestMotDw::PositionSliderProc::PositionSliderProc() { + +} + +DataTestMotDw::PositionSliderProc::~PositionSliderProc() { + +} + +void DataTestMotDw::PositionSliderProc::Callback(dw::Widget* data) { + +} + +DataTestMotDw::FrameSliderProc::FrameSliderProc() : slider() { + +} + +DataTestMotDw::FrameSliderProc::~FrameSliderProc() { + +} + +void DataTestMotDw::FrameSliderProc::Callback(dw::Widget* data) { + +} + +DataTestMotDw::StartFrameSliderProc::StartFrameSliderProc() : button() { + +} + +DataTestMotDw::StartFrameSliderProc::~StartFrameSliderProc() { + +} + +void DataTestMotDw::StartFrameSliderProc::Callback(dw::Widget* data) { + +} + +DataTestMotDw::DispButtonProc::DispButtonProc() : button() { + +} + +DataTestMotDw::DispButtonProc::~DispButtonProc() { + +} + +void DataTestMotDw::DispButtonProc::Callback(dw::Widget* data) { + +} + +DataTestMotDw::UseOpdButtonProc::UseOpdButtonProc() { + +} + +DataTestMotDw::UseOpdButtonProc::~UseOpdButtonProc() { + +} + +void DataTestMotDw::UseOpdButtonProc::Callback(dw::Widget* data) { + +} + +DataTestMotDw::PartialMotButtonProc::PartialMotButtonProc() { + +} + +DataTestMotDw::PartialMotButtonProc::~PartialMotButtonProc() { + +} + +void DataTestMotDw::PartialMotButtonProc::Callback(dw::Widget* data) { + +} + +DataTestMotDw::SaveOnlyStartFrameButtonProc::SaveOnlyStartFrameButtonProc() { + +} + +DataTestMotDw::SaveOnlyStartFrameButtonProc::~SaveOnlyStartFrameButtonProc() { + +} + +void DataTestMotDw::SaveOnlyStartFrameButtonProc::Callback(dw::Widget* data) { + +} + +DataTestMotDw::CreateFaceMotDwProc::CreateFaceMotDwProc() { + +} + +DataTestMotDw::CreateFaceMotDwProc::~CreateFaceMotDwProc() { + +} + +void DataTestMotDw::CreateFaceMotDwProc::Callback(dw::Widget* data) { + +} + +DataTestMotDw::CreateEqDwProc::CreateEqDwProc() { + +} + +DataTestMotDw::CreateEqDwProc::~CreateEqDwProc() { + +} + +void DataTestMotDw::CreateEqDwProc::Callback(dw::Widget* data) { + +} + +DataTestMotDw::CreateDebugCamProc::CreateDebugCamProc() { + +} + +DataTestMotDw::CreateDebugCamProc::~CreateDebugCamProc() { + +} + +void DataTestMotDw::CreateDebugCamProc::Callback(dw::Widget* data) { + +} + +DataTestMotDw::DataTestMotDw(int32_t chara_id, DtmMot* dtm_mot) { + this->dtm_mot = dtm_mot; + + DataTestMot::Data* test_mot_data = data_test_mot_data_get(); + + char buf[0x20]; + sprintf_s(buf, sizeof(buf), "MOTION TEST %dP", chara_id + 1); + SetName(buf); + + dw::Composite* chara_comp = new dw::Composite(this); + chara_comp->SetLayout(new dw::RowLayout(dw::HORIZONTAL)); + + dw::Label* chara_label = new dw::Label(chara_comp); + chara_label->SetName("CHARA "); + //chara_label->SetFont(&p_dw__font_type_6x12); + + dw::ListBox* chara = new dw::ListBox(chara_comp); + //chara->list->sub_1402F9930(20); + for (int32_t i = CHARA_MIKU; i < CHARA_MAX; i++) + chara->AddItem(chara_index_get_name((chara_index)i)); + chara->callback_data.i32 = chara_id; + chara->SetItemIndex(test_mot_data->chara_index[chara_id]); + chara->AddSelectionListener(&chara_list_box_proc); + //chara->SetFont(&p_dw__font_type_6x12); + + dw::Composite* chara_list_box_comp = new dw::Composite(this); + chara_list_box_comp->SetLayout(new dw::RowLayout(dw::HORIZONTAL)); + + chara_list_box_proc.list_box = new dw::ListBox(chara_list_box_comp); + //chara_list_box_proc.list_box->list->sub_1402F9930(40); + //chara_list_box_proc.list_box->SetFont(&p_dw__font_type_6x12); + AddModules(chara_id, chara_list_box_proc.list_box); + chara_list_box_proc.list_box->callback_data.i32 = chara_id; + + chara_list_box_proc.list_box->SetItemIndex(test_mot_data->module_index[chara_id]); + chara_list_box_proc.list_box->AddSelectionListener(&c_type_list_box_proc); + //chara_list_box_proc.list_box->SetFont(&p_dw__font_type_6x12); + + dw::Composite* set_comp = new dw::Composite(this); + set_comp->SetLayout( new dw::RowLayout(dw::HORIZONTAL)); + + dw::Label* set_label = new dw::Label(set_comp); + set_label->SetName("SET "); + //set_label->SetFont(&p_dw__font_type_6x12); + + data_struct* aft_data = &data_list[DATA_AFT]; + motion_database* aft_mot_db = &aft_data->data_ft.mot_db; + + c_type_list_box_proc.list_box = new dw::ListBox(set_comp); + for (motion_set_info& i : aft_mot_db->motion_set) + c_type_list_box_proc.list_box->AddItem(i.name); + //c_type_list_box_proc.list_box->list->sub_1402F9930(40); + c_type_list_box_proc.list_box->callback_data.i32 = chara_id; + + c_type_list_box_proc.list_box->SetItemIndex(test_mot_data->motion_set_index[chara_id]); + c_type_list_box_proc.list_box->AddSelectionListener(&set_list_box_proc); + //c_type_list_box_proc.list_box->SetFont(&p_dw__font_type_6x12); + + dw::Composite* id_comp = new dw::Composite(this); + id_comp->SetLayout(new dw::RowLayout(dw::HORIZONTAL)); + + dw::Label* id_label = new dw::Label(id_comp); + id_label->SetName("ID "); + //id_label->SetFont(&p_dw__font_type_6x12); + + set_list_box_proc.list_box = new dw::ListBox(id_comp); + //set_list_box_proc.list_box->list->sub_1402F9930(40); + set_list_box_proc.list_box->callback_data.i32 = chara_id; + set_list_box_proc.list_box->AddSelectionListener(&id_list_box_proc); + //set_list_box_proc.list_box->SetFont(&p_dw__font_type_6x12); + + id_list_box_proc.slider = dw::Slider::make(this); + id_list_box_proc.slider->SetName("Y ROT"); + id_list_box_proc.slider->format = "%3.0f"; + id_list_box_proc.slider->SetParams(test_mot_data->rot_y[chara_id], -180.0f, 180.0f, 36.0f, 1.0f, 10.0f); + id_list_box_proc.slider->callback_data.i32 = chara_id; + id_list_box_proc.slider->AddSelectionListener(&rotate_slider_proc); + + rotate_slider_proc.slider = dw::Slider::make(this); + rotate_slider_proc.slider->dw::Widget::SetName("X POS"); + rotate_slider_proc.slider->format = "%3.2f"; + rotate_slider_proc.slider->SetParams(test_mot_data->trans_x[chara_id], -2.0f, 2.0f, 0.4f, 0.01f, 0.1f); + rotate_slider_proc.slider->callback_data.i32 = chara_id; + rotate_slider_proc.slider->AddSelectionListener(&position_slider_proc); + + dw::Group* frame_group = new dw::Group(this); + frame_group->SetName("FRAME"); + //frame_group->SetFont(&p_dw__font_type_6x12); + + for (int32_t i = 3; i < 4; i++) { + step_slider = dw::Slider::make(frame_group); + char buf[0x10]; + sprintf_s(buf, sizeof(buf), "STEP %02d", i); + step_slider->SetName(buf); + step_slider->format = "%4.4f"; + step_slider->SetParams(test_mot_data->step[chara_id].array[i], -3.0f, 3.0f, 0.4f, 0.01f, 0.1f); + step_slider->callback_data.i32 = chara_id; + step_slider_proc[i].index = i; + step_slider->AddSelectionListener(&step_slider_proc[i]); } - for (int32_t i = ITEM_ATAMA; i < ITEM_MAX; i++) - if (rob_itm_equip->get_object_info((item_id)i).not_null()) - rob_itm_equip->set_disp((item_id)i, true); + dw::Composite* frame_comp = new dw::Composite(frame_group); + frame_comp->SetLayout(new dw::RowLayout(dw::HORIZONTAL)); - for (int32_t i = ITEM_ATAMA; i < ITEM_MAX; i++) - if (i != id && (!disp || i != rob_itm_equip->field_D4)) - rob_itm_equip->set_disp((item_id)i, disp); + (new dw::Label(frame_comp))->SetName("FRAME "); - field_80 = v2; + frame = new dw::Label(frame_comp, dw::FLAG_4000); + frame->SetName("00000.0000"); + + dw::Label* frame_separator = new dw::Label(frame_comp); + frame_separator->SetName(" / "); + + frame_count = new dw::Label(frame_comp, dw::FLAG_4000); + frame_count->SetName("00000.0000"); + + current = dw::Slider::make(frame_group); + current->SetName("Current"); + current->format = "%4.0f"; + current->SetParams(0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); + current->callback_data.i32 = chara_id; + current->AddSelectionListener(&frame_slider_proc); + + frame_slider_proc.slider = dw::Slider::make(frame_group); + frame_slider_proc.slider->SetName("Start "); + frame_slider_proc.slider->format = "%4.0f"; + frame_slider_proc.slider->SetParams(0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); + frame_slider_proc.slider->callback_data.i32 = chara_id; + frame_slider_proc.slider->AddSelectionListener(&start_frame_slider_proc); + + dw::Composite* start_ctrl_comp = new dw::Composite(frame_group); + start_ctrl_comp->SetLayout(new dw::RowLayout(dw::HORIZONTAL)); + + (new dw::Label(start_ctrl_comp))->SetName("Start Ctrl : "); + + dw::Button* start_ctrl_left = new dw::Button(start_ctrl_comp, dw::FLAG_8); + start_ctrl_left->SetName(" < "); + start_ctrl_left->callback_data.v64 = this; + start_ctrl_left->callback = DataTestMotDw::StartCtrlLeftRightCallback; + + dw::Button* start_ctrl_reset = new dw::Button(start_ctrl_comp, dw::FLAG_8); + start_ctrl_reset->SetName(" RESET "); + start_ctrl_reset->callback = DataTestMotDw::StartCtrlResetCallback; + + dw::Button* start_ctrl_right = new dw::Button(start_ctrl_comp, dw::FLAG_8); + start_ctrl_right->SetName(" > "); + start_ctrl_right->callback_data.v64 = this; + start_ctrl_right->callback = DataTestMotDw::StartCtrlLeftRightCallback; + + dw::Group* ab_loop_group = new dw::Group(this); + ab_loop_group->SetLayout(new dw::RowLayout(dw::HORIZONTAL)); + ab_loop_group->SetName("AB LOOP"); + //ab_loop_group->SetFont(&p_dw__font_type_6x12); + + dw::Button* a_label = new dw::Button(ab_loop_group, dw::FLAG_8); + a_label->SetName(" A "); + a_label->callback_data.i64 = (int64_t)this; + a_label->callback = DataTestMotDw::ACallback; + //a_label->SetFont(&p_dw__font_type_6x12); + + dw::Button* b_label = new dw::Button(ab_loop_group, dw::FLAG_8); + b_label->SetName(" B "); + b_label->callback_data.i64 = (int64_t)this; + b_label->callback = DataTestMotDw::BCallback; + //b_label->SetFont(&p_dw__font_type_6x12); + + dw::Button* ab_toggle_button = new dw::Button(ab_loop_group, dw::CHECKBOX); + ab_toggle_button->SetName(""); + ab_toggle_button->callback_data.v64 = this; + ab_toggle_button->callback = DataTestMotDw::ABToggleCallback; + //ab_toggle->SetFont(&p_dw__font_type_6x12); + start_frame_slider_proc.button = ab_toggle_button; + + ab_loop = new dw::Label(ab_loop_group, dw::FLAG_8); + //ab_loop->SetFont(&p_dw__font_type_6x12); + ab_loop->SetName(" 00000:00000"); + + dw::Composite* rob_comp = new dw::Composite(this); + rob_comp->SetLayout(new dw::RowLayout(dw::HORIZONTAL)); + + dw::Button* disp_button = new dw::Button(rob_comp, dw::CHECKBOX); + disp_button->SetName("DISP "); + disp_button->SetValue(true); + disp_button->AddSelectionListener(&disp_button_proc); + disp_button->callback_data.i32 = chara_id; + //disp_button->SetFont(&p_dw__font_type_6x12); + + disp_button_proc.button = new dw::Button(rob_comp, dw::CHECKBOX); + disp_button_proc.button->SetName("SET CHANGE "); + disp_button_proc.button->SetValue(false); + //disp_button_proc.button->SetFont(&p_dw__font_type_6x12); + + dw::Composite* var_comp = new dw::Composite(this); + var_comp->Composite::SetLayout(new dw::RowLayout(dw::HORIZONTAL)); + + dw::Button* reate_face_mot_dw = new dw::Button(var_comp, dw::FLAG_8); + reate_face_mot_dw->SetName(" FACE MOT "); + reate_face_mot_dw->AddSelectionListener(&create_face_mot_dw_proc); + reate_face_mot_dw->callback_data.i32 = chara_id; + //reate_face_mot_dw->SetFont(&p_dw__font_type_6x12); + + dw::Button* create_eq_dw = new dw::Button(var_comp, dw::FLAG_8); + create_eq_dw->SetName(" EQUIP "); + create_eq_dw->AddSelectionListener(&create_eq_dw_proc); + //create_eq_dw->SetFont(&p_dw__font_type_6x12); + + dw::Button* create_debug_cam = new dw::Button(var_comp, dw::FLAG_8); + create_debug_cam->SetName(" LOCK CAM "); + create_debug_cam->AddSelectionListener(&create_debug_cam_proc); + //create_debug_cam->SetFont(&p_dw__font_type_6x12); + + dw::Button* use_opd_button = new dw::Button(this, dw::CHECKBOX); + use_opd_button->SetName("USE OSAGE PLAY DATA"); + use_opd_button->SetValue(false); + use_opd_button->AddSelectionListener(&use_opd_button_proc); + use_opd_button->callback_data.i32 = chara_id; + //use_opd_button->SetFont(&p_dw__font_type_6x12); + + dtm_mot->SetPartialMot(false); + + dw::Button* save_only_start_frame_button = new dw::Button(this, dw::CHECKBOX); + save_only_start_frame_button->SetName("Initialize only Start Frame Osage"); + save_only_start_frame_button->SetValue(false); + save_only_start_frame_button->AddSelectionListener(&save_only_start_frame_button_proc); + save_only_start_frame_button->callback_data.i32 = chara_id; + //save_only_start_frame_button->SetFont(&p_dw__font_type_6x12); + + //GetSetSize(); +} + +DataTestMotDw::~DataTestMotDw() { + +} + +void DataTestMotDw::Draw() { + bool ab_loop; + float_t a_frame; + float_t b_frame; + dtm_mot->GetABLoop(ab_loop, a_frame, b_frame); + start_frame_slider_proc.button->SetValue(ab_loop); + + char buf[0x20]; + sprintf_s(buf, sizeof(buf), " %5d:%5d", (int32_t)roundf(a_frame), (int32_t)roundf(b_frame)); + this->ab_loop->SetName(buf); + + dw::Shell::Draw(); +} + +void DataTestMotDw::Hide() { + SetDisp(false); +} + +void DataTestMotDw::ClearIDs() { + set_list_box_proc.list_box->ClearItems(); +} + +void DataTestMotDw::AddID(const char* str) { + set_list_box_proc.list_box->AddItem(str); +} + +void DataTestMotDw::SetFrameSlider(float_t frame, float_t frame_count) { + float_t last_frame = frame_count - 1.0f; + current->SetParams(min_def(frame, last_frame), 0.0f, last_frame, last_frame * 0.1f, 1.0f, 10.0f); + + float_t _frame = frame_slider_proc.slider->scroll_bar->value; + if (_frame >= 0.0) + _frame = 0.0; + else if (_frame > last_frame) + _frame = last_frame; + frame_slider_proc.slider->SetParams(_frame, 0.0f, last_frame, last_frame * 0.1f, 1.0f, 10.0f); + + data_test_mot_data_get()->start_frame[frame_slider_proc.slider->callback_data.i32] = _frame; +} + +void DataTestMotDw::SetFrameLabel(float_t frame, float_t frame_count) { + char buf[0x40]; + sprintf_s(buf, sizeof(buf), "%10.4f", frame); + this->frame->SetName(buf); + + sprintf_s(buf, sizeof(buf), "%7.1f", frame_count); + this->frame_count->SetName(buf); +} + +void DataTestMotDw::AddModules(int32_t chara_id, dw::ListBox* list_box) { + if (!list_box) + return; + + DataTestMot::Data* test_mot_data = data_test_mot_data_get(); + + list_box->ClearItems(); + + chara_index chara_index = test_mot_data->chara_index[chara_id]; + const char* chara_name = chara_index_get_chara_name(chara_index); + + const std::vector& modules = module_data_handler_data_get_modules(); + for (auto& i : item_table_handler_array_get_table(chara_index)->cos) { + bool found = false; + for (const module_data& j : modules) + if (chara_index == j.chara_index && i.first == j.cos) { + char buf[0x200]; + sprintf_s(buf, sizeof(buf), "%03d:(%s%03d)%s", j.id, chara_name, i.first + 1, j.name.c_str()); + list_box->AddItem(buf); + + found = true; + break; + } + + if (!found && i.second.data.outer) { + const item_table_item* item = item_table_handler_array_get_item(chara_index, i.second.data.outer); + if (item) { + char buf[0x200]; + sprintf_s(buf, sizeof(buf), "---:(%s%03d)%s", chara_name, i.first + 1, item->name.c_str()); + list_box->AddItem(buf); + } + } + } + + int32_t module_index = test_mot_data->module_index[chara_id]; + list_box->SetItemIndex(module_index < list_box->GetItemCount() ? module_index : 0); +} + +void DataTestMotDw::ResetFrame() { + frame_slider_proc.slider->SetValue(0.0f); + dtm_mot->ResetABLoop(); +} + +void DataTestMotDw::ResetIDListBoxIndex() { + //GetSetSize(); + + set_list_box_proc.list_box->SetItemIndex(0); +} + +void DataTestMotDw::SetIDListBoxIndex(uint32_t index) { + set_list_box_proc.list_box->SetItemIndex(index); +} + +void DataTestMotDw::ABToggleCallback(dw::Widget* data) { + DataTestMotDw* test_mot_dw = (DataTestMotDw*)data->callback_data.v64; + if (test_mot_dw) + test_mot_dw->dtm_mot->ToggleABLoop(); +} + +void DataTestMotDw::ACallback(dw::Widget* data) { + DataTestMotDw* test_mot_dw = (DataTestMotDw*)data->callback_data.v64; + if (test_mot_dw) + test_mot_dw->dtm_mot->SetABFrame(true); +} + +void DataTestMotDw::BCallback(dw::Widget* data) { + DataTestMotDw* test_mot_dw = (DataTestMotDw*)data->callback_data.v64; + if (test_mot_dw) + test_mot_dw->dtm_mot->SetABFrame(false); +} + +void DataTestMotDw::StartCtrlLeftRightCallback(dw::Widget* data) { + dw::Button* button = dynamic_cast(data); + if (!button) + return; + + DataTestMotDw* test_mot_dw = (DataTestMotDw*)button->callback_data.v64; + if (!test_mot_dw) + return; + + float_t frame = test_mot_dw->frame_slider_proc.slider->scroll_bar->value; + + std::vector set_motion(test_mot_dw->dtm_mot->set_motion); + + auto i_begin = set_motion.begin(); + auto i_end = set_motion.end(); + for (auto i = i_begin; i != i_end; ) + if (i->motion_id != test_mot_dw->dtm_mot->motion_id) { + for (auto j = i, k = i - 1; k != i_end; j++, k++) + *j = *k; + + set_motion.pop_back(); + i_end = set_motion.end(); + } + else + i++; + + if (!set_motion.size()) + return; + + float_t last = 0.0f; + float_t first = -1.0f; + for (pv_data_set_motion& i : set_motion) { + if (i.motion_id == test_mot_dw->dtm_mot->motion_id) + if (&i != set_motion.data()) + last = i.frame_stage_index.first; + if (frame < i.frame_stage_index.first) { + first = i.frame_stage_index.first; + break; + } + } + + if (frame > set_motion.back().frame_stage_index.first) + last = set_motion.back().frame_stage_index.first; + + if (button->GetName().compare(" < ")) + test_mot_dw->frame_slider_proc.slider->SetValue(last); + else if (first > 0.0f) + test_mot_dw->frame_slider_proc.slider->SetValue(first); +} + +void DataTestMotDw::StartCtrlResetCallback(dw::Widget* data) { + data_test_mot_data_get()->reset_mot = true; +} + +DataTestMotA3dDw::PvListBoxProc::PvListBoxProc() { + +} + +DataTestMotA3dDw::PvListBoxProc::~PvListBoxProc() { + +} + +void DataTestMotA3dDw::PvListBoxProc::Callback(dw::Widget* data) { + dw::ListBox* list_box = dynamic_cast(data); + if (list_box) + data_test_mot_a3d_dw->SetPvId(atoi(list_box->GetSelectedItem().c_str())); + + //data_test_mot_a3d_dw->GetSetSize(); +} + +DataTestMotA3dDw::A3dListBoxProc::A3dListBoxProc() { + +} + +DataTestMotA3dDw::A3dListBoxProc::~A3dListBoxProc() { + +} + +void DataTestMotA3dDw::A3dListBoxProc::Callback(dw::Widget* data) { + +} + +DataTestMotCtrlDw::TypeListBoxProc::TypeListBoxProc() { + +} + +DataTestMotCtrlDw::TypeListBoxProc::~TypeListBoxProc() { + +} + +void DataTestMotCtrlDw::TypeListBoxProc::Callback(dw::Widget* data) { + DataTestMot::Data* test_mot_data = data_test_mot_data_get(); + dw::ListBox* list_box = dynamic_cast(data); + if (list_box) + test_mot_data->type = (int32_t)list_box->list->selected_item; +} + +DataTestMotCtrlDw::SyncFrameButtonProc::SyncFrameButtonProc() { + +} + +DataTestMotCtrlDw::SyncFrameButtonProc::~SyncFrameButtonProc() { + +} + +void DataTestMotCtrlDw::SyncFrameButtonProc::Callback(dw::Widget* data) { + DataTestMot::Data* test_mot_data = data_test_mot_data_get(); + dw::Button* button = dynamic_cast(data); + if (button) + test_mot_data->sync_frame = button->value; +} + +DataTestMotCtrlDw::GameCameraButtonProc::GameCameraButtonProc() { + +} + +DataTestMotCtrlDw::GameCameraButtonProc::~GameCameraButtonProc() { + +} + +void DataTestMotCtrlDw::GameCameraButtonProc::Callback(dw::Widget* data) { + DataTestMot::Data* test_mot_data = data_test_mot_data_get(); + dw::Button* button = dynamic_cast(data); + if (button) { + test_mot_data->field_A8 = true; + test_mot_data->field_A9 = button->value; + } +} + +DataTestMotA3dDw::DataTestMotA3dDw() { + SetName("MOTION TEST"); + + dw::Composite* pv_comp = new dw::Composite(this); + pv_comp->SetLayout(new dw::RowLayout(dw::HORIZONTAL)); + + dw::Label* pv_label = new dw::Label(pv_comp); + pv_label->SetName("PV"); + //pv_label->SetFont(&p_dw__font_type_6x12); + + pv = new dw::ListBox(pv_comp); + //pv->list->sub_1402F9930(20); + //pv->SetFont(&p_dw__font_type_6x12); + + for (int32_t i = 0; i < 1000; i++) { + if (!task_pv_db_get_pv(i)) + continue; + + char buf[0x10]; + sprintf_s(buf, sizeof(buf), "%03d", i); + pv->AddItem(buf); + } + + pv->AddSelectionListener(&pv_list_box_proc); + + dw::Composite* a3d_comp = new dw::Composite(this); + a3d_comp->SetLayout(new dw::RowLayout(dw::HORIZONTAL)); + + dw::Label* a3d_label = new dw::Label(a3d_comp); + a3d_label->SetName("A3d"); + //a3d_label->SetFont(&p_dw__font_type_6x12); + + a3d = new dw::ListBox(a3d_comp); + //a3d->list->sub_1402F9930(20); + a3d->AddItem("PVを選択して下さい"); + + a3d->Reset(); + a3d->AddSelectionListener(&a3d_list_box_proc); + //a3d->SetFont(&p_dw__font_type_6x12); + + dw::Composite* button_comp = new dw::Composite(this); + button_comp->SetLayout(new dw::RowLayout(dw::HORIZONTAL)); + + play_a3d = new dw::Button(button_comp, dw::FLAG_8); + play_a3d->SetName(" PLAY A3D "); + + play_a3d->callback_data.v64 = this; + play_a3d->callback = DataTestMotA3dDw::PlayA3dCallback; + //play_a3d->SetFont(&p_dw__font_type_6x12); + + sync_1p_frame = new dw::Button(button_comp, dw::CHECKBOX); + sync_1p_frame->SetName("SYNC 1P FRAME"); + sync_1p_frame->callback_data.v64 = this; + sync_1p_frame->callback = DataTestMotA3dDw::Sync1pFrameCallback; + //sync_1p_frame->SetFont(&p_dw__font_type_6x12); + + /*GetSetSize(); + + position.x = (float_t)res_window_get()->width * 0.3f - size.x * 0.3f; + + SetSize(size);*/ +} + +DataTestMotA3dDw::~DataTestMotA3dDw() { + +} + +void DataTestMotA3dDw::Draw() { + SetName(data_test_mot_a3d_get_state_text()); +} + +void DataTestMotA3dDw::Hide() { + SetDisp(false); + data_test_mot_a3d_del_task(); +} + +void DataTestMotA3dDw::SetPvId(int32_t pv_id) { + a3d->ClearItems(); + + char buf[0x20]; + sprintf_s(buf, sizeof(buf), "PV%03d", pv_id); + + data_struct* aft_data = &data_list[DATA_AFT]; + auth_3d_database* aft_auth_3d_db = &aft_data->data_ft.auth_3d_db; + + for (const auth_3d_database_category& i : aft_auth_3d_db->category) { + if (i.name.find(buf) == -1 || !i.uid.size()) + continue; + + std::vector auth_3d_names; + auth_3d_names.reserve(i.uid.size()); + + for (const int32_t& j : i.uid) + auth_3d_names.push_back(aft_auth_3d_db->uid[j].name); + + prj::sort(auth_3d_names); + + for (const std::string& i : auth_3d_names) + a3d->AddItem(i); + } + + if (!a3d->GetItemCount()) + a3d->AddItem("No 3D Auth"); + + a3d->SetItemIndex(0); +} + +void DataTestMotA3dDw::PlayA3dCallback(dw::Widget* data) { + std::string auth_3d = data_test_mot_a3d_dw_get()->a3d->GetSelectedItem(); + data_test_mot_a3d_set_auth_3d(auth_3d); +} + +void DataTestMotA3dDw::Sync1pFrameCallback(dw::Widget* data) { + DataTestMot::Data* test_mot_data = data_test_mot_data_get(); + dw::Button* button = dynamic_cast(data); + if (button) + test_mot_data->sync_1p_frame = button->value; +} + +DataTestMotCtrlDw::DataTestMotCtrlDw() { + DataTestMot::Data* test_mot_data = data_test_mot_data_get(); + + SetName("MOTION TEST"); + + type_list = new dw::ListBox(this); + type_list->AddItem("ONCE"); + type_list->AddItem("LOOP"); + type_list->AddItem("STEP"); + type_list->SetItemIndex(test_mot_data->type); + type_list->AddSelectionListener(&type_list_box_proc); + + reset_mot = new dw::Button(this, dw::FLAG_8); + reset_mot->SetName("RESET MOT"); + reset_mot->callback_data.v64 = this; + reset_mot->callback = DataTestMotCtrlDw::ResetMotCallback; + + reset_cam = new dw::Button(this, dw::FLAG_8); + reset_cam->SetName("RESET CAM"); + reset_cam->callback_data.v64 = this; + reset_cam->callback = DataTestMotCtrlDw::ResetCamCallback; + + reload_data = new dw::Button(this, dw::FLAG_8); + reload_data->SetName("RELOAD DATA"); + reload_data->callback_data.v64 = this; + reload_data->callback = DataTestMotCtrlDw::ReloadDataCallback; + + dw::Button* sync_frame_button = new dw::Button(this, dw::CHECKBOX); + sync_frame_button->SetName("SYNC FRAME"); + sync_frame_button->AddSelectionListener(&sync_frame_button_proc); + //sync_frame_button->SetFont(&p_dw__font_type_6x12); + + running = new dw::Button(this, dw::CHECKBOX); + running->SetName("RUNNING"); + running->SetValue(false); + running->callback = DataTestMotCtrlDw::RunningCallback; + //running->SetFont(&p_dw__font_type_6x12); + + stage = new dw::Button(this, dw::FLAG_8); + stage->SetName("STAGE"); + stage->callback = DataTestMotCtrlDw::StageCallback; + + /*GetSetSize(); + + position.x = (float_t)res_window_get()->width - size.x; + + SetSize(size);*/ +} + +DataTestMotCtrlDw::~DataTestMotCtrlDw() { + +} + +void DataTestMotCtrlDw::Draw() { + +} + +void DataTestMotCtrlDw::Hide() { + +} + +void DataTestMotCtrlDw::ReloadDataCallback(dw::Widget* data) { + data_test_mot_data_get()->reload_data = true; +} + +void DataTestMotCtrlDw::ResetCamCallback(dw::Widget* data) { + data_test_mot_data_get()->reset_cam = true; +} + +void DataTestMotCtrlDw::ResetMotCallback(dw::Widget* data) { + data_test_mot_data_get()->reset_mot = true; +} + +void DataTestMotCtrlDw::RunningCallback(dw::Widget* data) { + DataTestMot::Data* test_mot_data = data_test_mot_data_get(); + dw::Button* button = dynamic_cast(data); + if (button) + test_mot_data->running = button->value; +} + +void DataTestMotCtrlDw::StageCallback(dw::Widget* data) { + dtw_stg_load(false); } void motion_test_init() { if (!data_test_mot) data_test_mot = new DataTestMot; + if (!data_test_mot_a3d) + data_test_mot_a3d = new DataTestMotA3d; + if (!dtm_mot_array) dtm_mot_array = new DtmMot[2]; - if (!dtm_eq_vs_array) - dtm_eq_vs_array = new DtmEqVs[2]; - motion_test_objset = {}; } void motion_test_free() { + for (DataTestFaceMotDw*& i : data_test_face_mot_dw_array) + if (i) { + delete i; + i = 0; + } + + if (data_test_mot_ctrl_dw) { + delete data_test_mot_ctrl_dw; + data_test_mot_ctrl_dw = 0; + } + + if (data_test_mot_a3d_dw) { + delete data_test_mot_a3d_dw; + data_test_mot_a3d_dw = 0; + } + + for (DataTestMotDw*& i : data_test_mot_dw_array) + if (i) { + delete i; + i = 0; + } + motion_test_objset.clear(); motion_test_objset.shrink_to_fit(); - if (dtm_eq_vs_array) { - delete[] dtm_eq_vs_array; - dtm_eq_vs_array = 0; - } - if (dtm_mot_array) { delete[] dtm_mot_array; dtm_mot_array = 0; } + if (data_test_mot_a3d) { + delete data_test_mot_a3d; + data_test_mot_a3d = 0; + } + if (data_test_mot) { delete data_test_mot; data_test_mot = 0; } } -static void dtm_mot_array_set_reset_mot() { +void dtm_mot_array_set_reset_mot() { dtm_mot_array[0].SetResetMot(); dtm_mot_array[1].SetResetMot(); } +static DataTestMot::Data* data_test_mot_data_get() { + return &data_test_mot->data; +} + +static bool data_test_mot_a3d_add_task() { + return app::TaskWork::AddTask(data_test_mot_a3d_get(), "DATA_TEST_MOT_A3D", 0); +} + +static bool data_test_mot_a3d_del_task() { + return data_test_mot_a3d_get()->DelTask(); +} + +static const char* data_test_mot_a3d_get_state_text() { + return data_test_mot_a3d_get()->GetStateText(); +} + +static DataTestMotA3d* data_test_mot_a3d_get() { + return data_test_mot_a3d; +} + +static void data_test_mot_a3d_set_auth_3d(std::string& value) { + data_test_mot_a3d_get()->SetAuth3d(value); +} + +static void data_test_mot_dw_array_init(int32_t chara_id, DtmMot* dtm_mot) { + if (data_test_mot_dw_array[chara_id]) { + data_test_mot_dw_array[chara_id]->Disp(); + return; + } + + DataTestMotDw* test_mot_dw = new DataTestMotDw(chara_id, dtm_mot); + data_test_mot_dw_array[chara_id] = test_mot_dw; + + test_mot_dw->sub_1402F38B0(); + + switch (chara_id) { + case 0: { + test_mot_dw->position.y += 14.0f; + } break; + case 1: { + resolution_struct* res_wind = res_window_get(); + test_mot_dw->position.x = (float_t)res_wind->width - test_mot_dw->size.x; + test_mot_dw->position.y = (float_t)res_wind->height - 24.0f; + } break; + } +} + +static DataTestMotDw* data_test_mot_dw_array_get(int32_t chara_id) { + return data_test_mot_dw_array[chara_id]; +} + +static void data_test_mot_a3d_dw_init() { + if (!data_test_mot_a3d_dw) { + data_test_mot_a3d_dw = new DataTestMotA3dDw; + data_test_mot_a3d_dw->sub_1402F38B0(); + } + else + data_test_mot_a3d_dw->Disp(); +} + +static DataTestMotA3dDw* data_test_mot_a3d_dw_get() { + return data_test_mot_a3d_dw; +} + +static void data_test_mot_ctrl_dw_init() { + if (!data_test_mot_ctrl_dw) { + data_test_mot_ctrl_dw = new DataTestMotCtrlDw; + data_test_mot_ctrl_dw->sub_1402F38B0(); + } + else + data_test_mot_ctrl_dw->Disp(); +} + +static DataTestMotCtrlDw* data_test_mot_ctrl_dw_get() { + return data_test_mot_ctrl_dw; +} + +static void data_test_face_mot_dw_array_init(int32_t chara_id) { + if (chara_id < 0 || chara_id >= ROB_CHARA_COUNT || !rob_chara_array_get(chara_id)) + return; + + if (!data_test_face_mot_dw_array[chara_id]) { + data_test_face_mot_dw_array[chara_id] = new DataTestFaceMotDw(chara_id); + data_test_face_mot_dw_array[chara_id]->sub_1402F38B0(); + } + else + data_test_face_mot_dw_array[chara_id]->Disp(); +} + +static DataTestFaceMotDw* data_test_face_mot_dw_array_get(int32_t chara_id) { + if (chara_id >= 0 && chara_id < ROB_CHARA_COUNT) + return data_test_face_mot_dw_array[chara_id]; + return 0; +} + +static void data_test_face_mot_dw_array_unload() { + for (DataTestFaceMotDw*& i : data_test_face_mot_dw_array) + if (i) { + i->Hide(); + i = 0; + } +} + static bool motion_test_objset_check_not_read() { for (uint32_t i : motion_test_objset) if (object_storage_load_obj_set_check_not_read(i)) diff --git a/src/ReDIVA/data_test/motion_test.hpp b/src/ReDIVA/data_test/motion_test.hpp index bf3c0667..be841810 100644 --- a/src/ReDIVA/data_test/motion_test.hpp +++ b/src/ReDIVA/data_test/motion_test.hpp @@ -5,13 +5,23 @@ #pragma once -#include "../../CRE/rob/rob.hpp" #include "../../KKdLib/default.hpp" +#include "../../CRE/rob/rob.hpp" +#include "../../CRE/auth_3d.hpp" +#include "../pv_game/pv_game_pv_data.hpp" +#include "../dw.hpp" #include "../task_window.hpp" class DataTestMot : public app::Task { public: struct Data { + struct Offset { + float_t pre; + float_t post; + + Offset(); + }; + struct Divide { float_t array[3]; @@ -24,36 +34,20 @@ public: Step(); }; - ::chara_index chara_index_p1; - ::chara_index chara_index_p2; - ::chara_index curr_chara_index_p1; - ::chara_index curr_chara_index_p2; - uint32_t module_index_p1; - uint32_t module_index_p2; - uint32_t curr_module_index_p1; - uint32_t curr_module_index_p2; - uint32_t motion_set_index_p1; - uint32_t motion_set_index_p2; - uint32_t curr_motion_set_index_p1; - uint32_t curr_motion_set_index_p2; - uint32_t motion_index_p1; - uint32_t motion_index_p2; - uint32_t curr_motion_index_p1; - uint32_t curr_motion_index_p2; - float_t rot_y_p1; - float_t rot_y_p2; - float_t trans_x_p1; - float_t trans_x_p2; - float_t pre_offset_p1; - float_t post_offset_p1; - float_t pre_offset_p2; - float_t post_offset_p2; - Divide divide_p1; - Divide divide_p2; - Step step_p1; - Step step_p2; - float_t start_frame_p1; - float_t start_frame_p2; + ::chara_index chara_index[2]; + ::chara_index curr_chara_index[2]; + uint32_t module_index[2]; + uint32_t curr_module_index[2]; + uint32_t motion_set_index[2]; + uint32_t curr_motion_set_index[2]; + uint32_t motion_index[2]; + uint32_t curr_motion_index[2]; + float_t rot_y[2]; + float_t trans_x[2]; + Offset offset[2]; + Divide divide[2]; + Step step[2]; + float_t start_frame[2]; int32_t type; bool reset_mot; bool reset_cam; @@ -83,6 +77,31 @@ public: void sub_140286280(); }; +class DataTestMotA3d : public app::Task { +public: + int32_t state; + std::string auth_3d; + std::vector categories; + std::vector auth_3d_ids; + std::vector obj_sets; + bool camera; + + DataTestMotA3d(); + virtual ~DataTestMotA3d() override; + + virtual bool Init() override; + virtual bool Ctrl() override; + virtual bool Dest() override; + virtual void Disp() override; + virtual void Basic() override; + + const char* GetStateText(); + void LoadAuth3d(std::string&& name); + void Reset(); + void SetAuth3d(std::string& value); + void Sync1pFrame(); +}; + class DtmMot : public app::Task { public: rob_chara_bone_data* rob_bone_data; @@ -91,16 +110,16 @@ public: ::chara_index chara_index; int32_t module_index; union { - int32_t motion_set_id; + uint32_t motion_set_id; int32_t motion_set_index; }; union { - int32_t motion_id; + uint32_t motion_id; int32_t motion_index; }; vec3 trans; - vec3 rotatation; - float_t field_A8; + vec3 rotation; + float_t rot_y; float_t pre_offset; float_t post_offset; float_t step[4]; @@ -117,18 +136,17 @@ public: bool save_only_start_frame; int32_t state; float_t frame; - float_t field_E4; - bool field_E8; + float_t delta_frame; + bool looped; float_t start_frame; - float_t a_frame; - float_t b_frame; + float_t ab_frame[2]; bool ab_loop; int32_t pv_id; bool field_100; - p_file_handler field_108; - //pv_game_dsc_data field_110; + p_file_handler dsc_file_handler; + pv_game_pv_data pv_data; std::vector set_motion; - int32_t field_2C960; + int32_t set_motion_index; DtmMot(); virtual ~DtmMot() override; @@ -139,14 +157,19 @@ public: virtual void Basic() override; virtual bool AddTask(::chara_index chara_index, - int32_t module_index, int32_t motion_set_id, int32_t motion_id); + int32_t module_index, uint32_t motion_set_id, uint32_t motion_id); virtual bool AddTask(::chara_index chara_index, - int32_t module_index, int32_t motion_id); + int32_t module_index, uint32_t motion_id); virtual bool DelTask(); + bool CheckFirstFrame(); + void CtrlFaceMot(); + void GetABLoop(bool& ab_loop, float_t& a_frame, float_t& b_frame); float_t GetFrame(); float_t GetFrameCount(); float_t GetStep(); + void ResetABLoop(); + void SetABFrame(bool a); void SetChangeMotion(); void SetDisp(bool value); void SetDivide(int32_t index, float_t value); @@ -163,36 +186,343 @@ public: void SetStep(int32_t index, float_t value); void SetTrans(const vec3& value); void SetUseOpd(bool value); + void ToggleABLoop(); + void UpdateABFrame(); static int32_t ConvertMotionSetNameToPVID(const char* set_name); + + bool sub_140291C10(); + void sub_1402922C0(bool value); }; -class DtmEqVs : public app::Task { +class DataTestFaceMotDw : public dw::Shell { public: - int32_t state; + struct MotionData + { + int32_t mottbl_index; + float_t frame; + }; + + struct Data { + MotionData face; + MotionData eyelid; + MotionData eyes; + MotionData mouth; + }; + int32_t chara_id; - ::chara_index chara_index; - ::chara_index curr_chara_index; - int32_t module_index; - int32_t curr_module_index; - int32_t field_80; + std::map motion_id_mottbl_map; + dw::Button* enable; + dw::ListBox* face; + dw::Slider* face_frame; + dw::Label* face_cl; + dw::Slider* face_cl_frame; + dw::ListBox* eyes; + dw::Slider* eyes_frame; + dw::ListBox* mouth; + dw::Slider* mouth_frame; - DtmEqVs(); - virtual ~DtmEqVs() override; + DataTestFaceMotDw(int32_t chara_id); + virtual ~DataTestFaceMotDw() override; - virtual bool Init() override; - virtual bool Ctrl() override; - virtual bool Dest() override; + virtual void Hide() override; - virtual bool AddTask(int32_t chara_id, ::chara_index chara_index); - virtual bool DelTask(); + void AddMottblMapMotions(dw::ListBox* list_box, int32_t type); + Data GetData(); + bool GetEnable(); + dw::ListBox* InitAddMottblMapMotions(dw::Composite* parent, int32_t type); + void Reset(); +}; - void SetCharaIndexModuleIndex(::chara_index chara_index, int32_t module_index); +class DataTestMotDw : public dw::Shell { +public: + class StepSliderProc : public dw::SelectionAdapter { + public: + int32_t index; - void sub_140261FF0(); - void sub_140262050(); + StepSliderProc(); + virtual ~StepSliderProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + class CharaListBoxProc : public dw::SelectionAdapter { + public: + dw::ListBox* list_box; + + CharaListBoxProc(); + virtual ~CharaListBoxProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + class CTypeListBoxProc : public dw::SelectionAdapter { + public: + dw::ListBox* list_box; + + CTypeListBoxProc(); + virtual ~CTypeListBoxProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + class SetListBoxProc : public dw::SelectionAdapter { + public: + dw::ListBox* list_box; + + SetListBoxProc(); + virtual ~SetListBoxProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + class IdListBoxProc : public dw::SelectionAdapter { + public: + dw::Slider* slider; + + IdListBoxProc(); + virtual ~IdListBoxProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + class RotateSliderProc : public dw::SelectionAdapter { + public: + dw::Slider* slider; + + RotateSliderProc(); + virtual ~RotateSliderProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + class PositionSliderProc : public dw::SelectionAdapter { + public: + PositionSliderProc(); + virtual ~PositionSliderProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + class FrameSliderProc : public dw::SelectionAdapter { + public: + dw::Slider* slider; + + FrameSliderProc(); + virtual ~FrameSliderProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + class StartFrameSliderProc : public dw::SelectionAdapter { + public: + dw::Button* button; + + StartFrameSliderProc(); + virtual ~StartFrameSliderProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + class DispButtonProc : public dw::SelectionAdapter { + public: + dw::Button* button; + + DispButtonProc(); + virtual ~DispButtonProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + class UseOpdButtonProc : public dw::SelectionAdapter { + public: + UseOpdButtonProc(); + virtual ~UseOpdButtonProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + class PartialMotButtonProc : public dw::SelectionAdapter { + public: + PartialMotButtonProc(); + virtual ~PartialMotButtonProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + class SaveOnlyStartFrameButtonProc : public dw::SelectionAdapter { + public: + SaveOnlyStartFrameButtonProc(); + virtual ~SaveOnlyStartFrameButtonProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + class CreateFaceMotDwProc : public dw::SelectionAdapter { + public: + CreateFaceMotDwProc(); + virtual ~CreateFaceMotDwProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + class CreateEqDwProc : public dw::SelectionAdapter { + public: + CreateEqDwProc(); + virtual ~CreateEqDwProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + struct CreateDebugCamProc : public dw::SelectionAdapter { + public: + CreateDebugCamProc(); + virtual ~CreateDebugCamProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + DtmMot* dtm_mot; + dw::ListBox* chara; + CharaListBoxProc chara_list_box_proc; + CTypeListBoxProc c_type_list_box_proc; + SetListBoxProc set_list_box_proc; + IdListBoxProc id_list_box_proc; + RotateSliderProc rotate_slider_proc; + PositionSliderProc position_slider_proc; + //__int64 field_1E8; + //__int64 field_1F0; + //__int64 field_1F8; + dw::Slider* step_slider; + StepSliderProc step_slider_proc[4]; + dw::Slider* current; + FrameSliderProc frame_slider_proc; + StartFrameSliderProc start_frame_slider_proc; + dw::Label* ab_loop; + dw::Label* frame; + dw::Label* frame_count; + DispButtonProc disp_button_proc; + UseOpdButtonProc use_opd_button_proc; + PartialMotButtonProc partial_mot_button_proc; + SaveOnlyStartFrameButtonProc save_only_start_frame_button_proc; + CreateFaceMotDwProc create_face_mot_dw_proc; + CreateEqDwProc create_eq_dw_proc; + CreateDebugCamProc create_debug_cam_proc; + + DataTestMotDw(int32_t chara_id, DtmMot* dtm_mot); + virtual ~DataTestMotDw() override; + + virtual void Draw() override; + virtual void Hide() override; + + virtual void ClearIDs(); + virtual void AddID(const char* str); + virtual void SetFrameSlider(float_t frame, float_t frame_count); + virtual void SetFrameLabel(float_t frame, float_t frame_count); + + void AddModules(int32_t chara_id, dw::ListBox* list_box); + void ResetFrame(); + void ResetIDListBoxIndex(); + void SetIDListBoxIndex(uint32_t index); + + static void ABToggleCallback(dw::Widget* data); + static void ACallback(dw::Widget* data); + static void BCallback(dw::Widget* data); + static void StartCtrlLeftRightCallback(dw::Widget* data); + static void StartCtrlResetCallback(dw::Widget* data); +}; + +class DataTestMotA3dDw : public dw::Shell { +public: + class PvListBoxProc : public dw::SelectionAdapter { + public: + PvListBoxProc(); + virtual ~PvListBoxProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + class A3dListBoxProc : public dw::SelectionAdapter { + public: + A3dListBoxProc(); + virtual ~A3dListBoxProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + dw::ListBox* pv; + DataTestMotA3dDw::PvListBoxProc pv_list_box_proc; + dw::ListBox* a3d; + DataTestMotA3dDw::A3dListBoxProc a3d_list_box_proc; + dw::Button* play_a3d; + dw::Button* sync_1p_frame; + + DataTestMotA3dDw(); + virtual ~DataTestMotA3dDw(); + + virtual void Draw() override; + virtual void Hide() override; + + void SetPvId(int32_t pv_id); + + static void PlayA3dCallback(dw::Widget* data); + static void Sync1pFrameCallback(dw::Widget* data); +}; + +class DataTestMotCtrlDw : public dw::Shell { +public: + class TypeListBoxProc : public dw::SelectionAdapter { + public: + TypeListBoxProc(); + virtual ~TypeListBoxProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + class SyncFrameButtonProc : public dw::SelectionAdapter { + public: + SyncFrameButtonProc(); + virtual ~SyncFrameButtonProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + + class GameCameraButtonProc : public dw::SelectionAdapter { + public: + GameCameraButtonProc(); + virtual ~GameCameraButtonProc() override; + + virtual void Callback(dw::Widget* data) override; + }; + + dw::ListBox* type_list; + TypeListBoxProc type_list_box_proc; + dw::Button* reset_mot; + dw::Button* reset_cam; + dw::Button* reload_data; + dw::Button* stage; + dw::Button* running; + DataTestMotCtrlDw::SyncFrameButtonProc sync_frame_button_proc; + DataTestMotCtrlDw::GameCameraButtonProc game_camera_button_proc; + + DataTestMotCtrlDw(); + virtual ~DataTestMotCtrlDw(); + + virtual void Draw() override; + virtual void Hide() override; + + static void ReloadDataCallback(dw::Widget* data); + static void ResetCamCallback(dw::Widget* data); + static void ResetMotCallback(dw::Widget* data); + static void RunningCallback(dw::Widget* data); + static void StageCallback(dw::Widget* data); }; extern DataTestMot* data_test_mot; extern DtmMot* dtm_mot_array; -extern DtmEqVs* dtm_eq_vs_array; + +extern void motion_test_init(); +extern void motion_test_free(); + +extern void dtm_mot_array_set_reset_mot(); diff --git a/src/ReDIVA/data_test/stage_test.cpp b/src/ReDIVA/data_test/stage_test.cpp index f2ab22f5..d2e71164 100644 --- a/src/ReDIVA/data_test/stage_test.cpp +++ b/src/ReDIVA/data_test/stage_test.cpp @@ -140,13 +140,11 @@ DtwStg::DtwStg() : Shell(0) { pv->AddSelectionListener(new dw::SelectionListenerOnHook(DtwStg::StageCallback)); //dw::List::sub_1402F9930(this->ns->list, 30); - ns->list->hovered_item = 0; - ns->list->ResetSetSelectedItem(0); + ns->list->SetItemIndex(0); ns->AddSelectionListener(new dw::SelectionListenerOnHook(DtwStg::StageCallback)); //dw::List::sub_1402F9930(this->stage->list, 30); - stage->list->hovered_item = 0; - stage->list->ResetSetSelectedItem(0); + stage->list->SetItemIndex(0); stage->AddSelectionListener(new dw::SelectionListenerOnHook(DtwStg::StageCallback)); stage_display = new dw::Button(this, dw::CHECKBOX); @@ -186,7 +184,7 @@ void DtwStg::PvIdCallback(dw::Widget* data) { data_struct* aft_data = &data_list[DATA_AFT]; stage_database* aft_stage_data = &aft_data->data_ft.stage_data; - std::string name = list_box->GetItem(list_box->list->selected_item); + std::string name = list_box->GetSelectedItem(); dw::ListBox* pv_list_box = dtw_stg->pv; pv_list_box->ClearItems(); @@ -203,7 +201,7 @@ void DtwStg::StageCallback(dw::Widget* data) { data_struct* aft_data = &data_list[DATA_AFT]; stage_database* aft_stage_data = &aft_data->data_ft.stage_data; - std::string name = list_box->GetItem(list_box->list->selected_item); + std::string name = list_box->GetSelectedItem(); dtm_stg->load_stage_index = aft_stage_data->get_stage_index(name.c_str()); } } @@ -240,9 +238,12 @@ void dtm_stg_free() { } void dtw_stg_init() { - if (!dtw_stg) + if (!dtw_stg) { dtw_stg = new DtwStg; - dtw_stg->Disp(); + dtw_stg->sub_1402F38B0(); + } + else + dtw_stg->Disp(); } void dtw_stg_load(bool hide) { diff --git a/src/ReDIVA/dw.cpp b/src/ReDIVA/dw.cpp index 373ab7f5..ce8ccc2c 100644 --- a/src/ReDIVA/dw.cpp +++ b/src/ReDIVA/dw.cpp @@ -24,10 +24,7 @@ namespace dw_gui_detail { std::vector free_widgets; /*struc_751 field_C0; int field_F4; - int field_F8; - int field_FC; - int field_100; - int field_104; + rectangle field_F8; int field_108; int field_10C; int field_110; @@ -125,6 +122,11 @@ static bool dw_gui_get_ctrl(); static bool dw_gui_get_disp(); namespace dw { + static RowLayout* row_layout_vertical = new RowLayout(VERTICAL); + + static DropDownListScrollBarSelectionListener drop_down_list_scroll_bar_selection_listener; + static ScrollBarTestSelectionListener scroll_bar_test_Selection_listener; + SelectionListener::SelectionListener() { } @@ -141,7 +143,7 @@ namespace dw { } - void SelectionAdapter::Field_8(Widget* data) { + void SelectionAdapter::Callback(Widget* data) { } @@ -161,10 +163,34 @@ namespace dw { } - void SelectionListenerOnHook::Field_8(Widget* data) { + void SelectionListenerOnHook::Callback(Widget* data) { callback(data); } + DropDownListScrollBarSelectionListener::DropDownListScrollBarSelectionListener() { + + } + + DropDownListScrollBarSelectionListener::~DropDownListScrollBarSelectionListener() { + + } + + void DropDownListScrollBarSelectionListener::Callback(Widget* data) { + + } + + ScrollBarTestSelectionListener::ScrollBarTestSelectionListener() { + + } + + ScrollBarTestSelectionListener::~ScrollBarTestSelectionListener() { + + } + + void ScrollBarTestSelectionListener::Callback(Widget* data) { + + } + Widget::Widget(Widget* parent, Flags flags) : free(), callback_data(), free_callback(), parent() { this->flags = flags; @@ -246,6 +272,26 @@ namespace dw { Widget::Reset(); } + vec2 dw::Control::GetPos() { + vec2 pos = position; + if (parent_comp) { + rectangle parent_rect = parent_comp->GetBoundingBox(); + vec2 parent_pos = parent_comp->GetPos(); + pos += parent_pos + parent_rect.pos; + if (parent_comp->v_bar) + pos.y -= parent_comp->v_bar->value; + } + return pos; + } + + void Control::GetSetSize() { + SetSize(GetSize()); + } + + vec2 Control::GetSize() { + return size; + } + Label::Label(Composite* parent, Flags flags) : Control(parent, flags) { } @@ -296,6 +342,30 @@ namespace dw { this->step = step; } + void ScrollBar::SetValue(float_t value) { + value = clamp_def(value, min, max); + if (round) + this->value = roundf(value / step) * step; + else + this->value = value; + } + + void ScrollBar::SetWidth(float_t value) { + vec2 glyph_size = value;//font->GetFontGlyphSize(); + if (flags & HORIZONTAL) { + size.x = value; + size.y = glyph_size.y; + } + else { + size.x = glyph_size.x; + size.y = value; + } + } + + void ScrollBar::AddSelectionListener(SelectionListener* value) { + selection_listeners.push_back(value); + } + Scrollable::Scrollable(Composite* parent, Flags flags) : Control(parent, flags), h_bar(), v_bar() { if (flags & HORIZONTAL) { h_bar = new ScrollBar(parent, HORIZONTAL); @@ -321,6 +391,38 @@ namespace dw { Control::Reset(); } + void Scrollable::SetSize(vec2 value) { + Widget::SetSize(value); + + if (flags & FLAG_800) { + value.x -= 2.0f * 2.0f; + value.y -= 2.0f * 2.0f; + } + + if (v_bar) { + v_bar->position.x = value.x - v_bar->size.x; + v_bar->position.y = 0.0f; + v_bar->SetWidth(value.y); + } + } + + rectangle Scrollable::GetBoundingBox() { + rectangle rect; + rect.size.x = size.x; + rect.size.y = size.y; + + if (flags & FLAG_800) { + rect.pos.x = 2.0f; + rect.pos.y = 2.0f; + rect.size.x = size.x - 2.0f * 2.0f; + rect.size.y = size.y - 2.0f * 2.0f; + } + + if (v_bar) + rect.size.x -= v_bar->size.x; + return rect; + } + Layout::Layout() { } @@ -487,8 +589,8 @@ namespace dw { } } - Composite::Composite(Composite* parent, Flags flags) : Scrollable(parent, flags), layout() { - + Composite::Composite(Composite* parent, Flags flags) : Scrollable(parent, flags) { + layout = row_layout_vertical; } Composite::~Composite() { @@ -521,10 +623,35 @@ namespace dw { Scrollable::Reset(); } + void Composite::SetSize(vec2 size) { + Scrollable::SetSize(size); + layout->SetSize(this); + } + + void Composite::GetSetSize() { + SetSize(GetSize()); + } + + vec2 Composite::GetSize() { + return layout->GetSize(this); + } + void Composite::SetLayout(Layout* value) { layout = value; } + Group::Group(Composite* parent, Flags flag) : Composite(parent, (Flags)(flags & ~(VERTICAL | HORIZONTAL))) { + + } + + Group::~Group() { + + } + + void Group::Draw() { + Composite::Draw(); + } + Button::Button(Composite* parent, Flags flags) : Control(parent, flags), value(), callback() { } @@ -552,6 +679,10 @@ namespace dw { ImGui::PopID(); } + void Button::AddSelectionListener(SelectionListener* value) { + selection_listeners.push_back(value); + } + void Button::SetValue(bool value) { this->value = value; if (!(flags & RADIOBUTTON)) @@ -664,7 +795,57 @@ namespace dw { } void Shell::Hide() { + destroy = true; + } + void dw::Shell::SetSize(vec2 size) { + dw::Widget::SetSize(size); + if (flags & CHECKBOX) { + if (close_button) { + vec2 size = close_button->GetSize(); + close_button->position.x = this->size.x - size.x + 2.0f; + close_button->position.y = 2.0f; + } + } + + rectangle bounding_box = GetBoundingBox(); + if (v_bar) { + v_bar->position.x = bounding_box.pos.x + bounding_box.size.x - v_bar->size.x; + v_bar->position.y = bounding_box.pos.y; + v_bar->SetWidth(bounding_box.size.y); + } + + layout->SetSize(this); + } + + vec2 Shell::GetPos() { + return position; + } + + vec2 Shell::GetSize() { + vec2 size = dw::Composite::GetSize(); + size.x += 2.0f * 2.0f; + size.y += 2.0f * 2.0f; + /*if (flags & CHECKBOX) + size.y += p_dw__font_type_8x16_0_get_font_glyph_height() + 2.0f;*/ + return size; + } + + rectangle dw::Shell::GetBoundingBox() { + rectangle rect; + rect.pos.x = 2.0; + rect.pos.y = 2.0; + rect.size.x = size.x - 2.0f * 2.0f; + rect.size.y = size.y - 2.0f * 2.0f; + + /*if (flags & CHECKBOX) { + rect.size.y -= p_dw__font_type_8x16_0_get_font_glyph_height() + 2.0f; + rect.pos.y += p_dw__font_type_8x16_0_get_font_glyph_height() + 2.0f; + }*/ + + if (v_bar) + rect.size.x -= v_bar->size.x; + return rect; } void Shell::Disp() { @@ -697,6 +878,11 @@ namespace dw { } } + void Shell::sub_1402F38B0() { + //sub_1402F3770(); + Disp(); + } + List::List(Composite* parent, Flags flags) : Scrollable(parent, flags) { hovered_item = -1; selected_item = -1; @@ -735,6 +921,10 @@ namespace dw { return items[index]; } + size_t List::GetItemCount() { + return items.size(); + } + void List::ResetSelectedItem() { if (flags & MULTISELECT) selected_item = -1; @@ -748,6 +938,11 @@ namespace dw { SetSelectedItem(index); } + void List::SetItemIndex(size_t index) { + hovered_item = index; + ResetSetSelectedItem(index); + } + void List::SetSelectedItem(size_t index) { if (index < items.size()) if (flags & MULTISELECT) @@ -758,6 +953,13 @@ namespace dw { ListBox::ListBox(Composite* parent, Flags flags) : Composite(parent, flags), list() { list = new List(parent, flags); + list->SetName("ddl"); + list->parent = this; + + if (list->v_bar) { + list->v_bar->parent = this; + list->v_bar->AddSelectionListener(&drop_down_list_scroll_bar_selection_listener); + } } ListBox::~ListBox() { @@ -803,7 +1005,7 @@ namespace dw { if (list->selected_item != selected_item) { list->selected_item = selected_item; for (SelectionListener*& i : list->selection_listeners) - i->Field_8(this); + i->Callback(this); } ImGui::PopID(); @@ -814,26 +1016,6 @@ namespace dw { Composite::Reset(); } - void ListBox::AddItem(const std::string& str) { - list->AddItem(str); - } - - void ListBox::AddItem(const std::string&& str) { - list->AddItem(str); - } - - void ListBox::AddSelectionListener(SelectionListener* value) { - list->AddSelectionListener(value); - } - - void ListBox::ClearItems() { - list->ClearItems(); - } - - std::string ListBox::GetItem(size_t index) const { - return list->GetItem(index); - } - Slider::Slider(Composite* parent, Flags flags) : Control(parent, flags) { format = "%f"; scroll_bar = new ScrollBar(this, (Flags)(flags & (HORIZONTAL | VERTICAL))); @@ -852,7 +1034,7 @@ namespace dw { ImGui::PopID(); if (ret) for (SelectionListener*& i : selection_listeners) - i->Field_8(this); + i->Callback(this); } void Slider::Reset() { diff --git a/src/ReDIVA/dw.hpp b/src/ReDIVA/dw.hpp index 9dd3e027..c9f39904 100644 --- a/src/ReDIVA/dw.hpp +++ b/src/ReDIVA/dw.hpp @@ -7,22 +7,26 @@ #include "../KKdLib/default.hpp" #include "../KKdLib/vec.hpp" +#include "../CRE/sprite.hpp" #include namespace dw { enum Flags { - FLAG_1 = 0x001, - FLAG_2 = 0x002, - MULTISELECT = 0x004, - FLAG_8 = 0x008, - RADIOBUTTON = 0x010, - CHECKBOX = 0x020, - CLOSE_BUTTON = 0x040, - FLAG_80 = 0x080, - HORIZONTAL = 0x100, - VERTICAL = 0x200, - FLAG_400 = 0x400, - FLAG_800 = 0x800, + FLAG_1 = 0x0001, + FLAG_2 = 0x0002, + MULTISELECT = 0x0004, + FLAG_8 = 0x0008, + RADIOBUTTON = 0x0010, + CHECKBOX = 0x0020, + CLOSE_BUTTON = 0x0040, + FLAG_80 = 0x0080, + HORIZONTAL = 0x0100, + VERTICAL = 0x0200, + FLAG_400 = 0x0400, + FLAG_800 = 0x0800, + FLAG_1000 = 0x1000, + FLAG_2000 = 0x2000, + FLAG_4000 = 0x4000, // Added LABEL_SIZE = 0x8000, @@ -73,7 +77,7 @@ namespace dw { SelectionListener(); virtual ~SelectionListener(); - virtual void Field_8(Widget* data) = 0; + virtual void Callback(Widget* data) = 0; virtual void Field_10(Widget* data) = 0; }; @@ -82,7 +86,7 @@ namespace dw { SelectionAdapter(); virtual ~SelectionAdapter() override; - virtual void Field_8(Widget* data) override; + virtual void Callback(Widget* data) override; virtual void Field_10(Widget* data) override; }; @@ -94,7 +98,23 @@ namespace dw { SelectionListenerOnHook(Widget::Callback callback); virtual ~SelectionListenerOnHook() override; - virtual void Field_8(Widget* data) override; + virtual void Callback(Widget* data) override; + }; + + class DropDownListScrollBarSelectionListener : public SelectionAdapter { + public: + DropDownListScrollBarSelectionListener(); + virtual ~DropDownListScrollBarSelectionListener() override; + + virtual void Callback(Widget* data) override; + }; + + class ScrollBarTestSelectionListener : public SelectionAdapter { + public: + ScrollBarTestSelectionListener(); + virtual ~ScrollBarTestSelectionListener() override; + + virtual void Callback(Widget* data) override; }; class Composite; @@ -111,6 +131,10 @@ namespace dw { virtual void Draw() override; virtual void Reset() override; + virtual vec2 GetPos() override; + + virtual void GetSetSize(); + virtual vec2 GetSize(); }; class Label : public Control { @@ -168,6 +192,10 @@ namespace dw { void SetParams(float_t value, float_t min, float_t max, float_t a5, float_t step, float_t step_fast); + void SetValue(float_t value); + void SetWidth(float_t value); + + void AddSelectionListener(SelectionListener* value); }; class Scrollable : public Control { @@ -180,6 +208,9 @@ namespace dw { virtual void Draw() override; virtual void Reset() override; + virtual void SetSize(vec2 value) override; + + virtual rectangle GetBoundingBox(); }; class Layout { @@ -285,10 +316,22 @@ namespace dw { virtual void Draw() override; virtual void Reset() override; + virtual void SetSize(vec2 size) override; + + virtual void GetSetSize() override; + virtual vec2 GetSize() override; void SetLayout(Layout* value); }; + class Group : public Composite { + public: + Group(Composite* parent = 0, Flags flags = (Flags)0); + virtual ~Group() override; + + virtual void Draw() override; + }; + class Button : public Control { public: bool value; @@ -300,6 +343,7 @@ namespace dw { virtual void Draw() override; + void AddSelectionListener(SelectionListener* value); void SetValue(bool value); }; @@ -331,12 +375,20 @@ namespace dw { virtual void Draw() override; virtual void Reset() override; + virtual void SetSize(vec2 size) override; + virtual vec2 GetPos() override; + + virtual vec2 GetSize() override; + + virtual rectangle GetBoundingBox() override; virtual void Hide(); void Disp(); bool GetDisp(); void SetDisp(bool value); + + void sub_1402F38B0(); }; class List : public Scrollable { @@ -358,9 +410,19 @@ namespace dw { void AddSelectionListener(SelectionListener* value); void ClearItems(); std::string GetItem(size_t index) const; + size_t GetItemCount(); void ResetSelectedItem(); void ResetSetSelectedItem(size_t index); + void SetItemIndex(size_t index); void SetSelectedItem(size_t index); + + inline std::string GetHoveredItem() { + return GetItem(hovered_item); + } + + inline std::string GetSelectedItem() { + return GetItem(selected_item); + } }; class ListBox : public Composite { @@ -373,11 +435,54 @@ namespace dw { virtual void Draw() override; virtual void Reset() override; - void AddItem(const std::string& str); - void AddItem(const std::string&& str); - void AddSelectionListener(SelectionListener* value); - void ClearItems(); - std::string GetItem(size_t index) const; + inline void AddItem(const std::string& str) { + if (list) + list->AddItem(str); + } + + inline void AddItem(const std::string&& str) { + if (list) + list->AddItem(str); + } + + inline void AddSelectionListener(SelectionListener* value) { + if (list) + list->AddSelectionListener(value); + } + + inline void ClearItems() { + if (list) + list->ClearItems(); + } + + inline std::string GetItem(size_t index) { + if (list) + return list->GetItem(index); + return {}; + } + + inline size_t GetItemCount() { + if (list) + return list->GetItemCount(); + return 0; + } + + inline std::string GetHoveredItem() { + if (list) + return list->GetHoveredItem(); + return {}; + } + + inline std::string GetSelectedItem() { + if (list) + return list->GetHoveredItem(); + return {}; + } + + inline void SetItemIndex(size_t index) { + if (list) + list->SetItemIndex(index); + } }; class Slider : public Control { @@ -395,8 +500,18 @@ namespace dw { void AddSelectionListener(SelectionListener* value); - static Slider* make(Composite* parent, Flags flags, - float_t x, float_t y, float_t width, float_t height, const char* name); + static Slider* make(Composite* parent = 0, + Flags flags = (dw::Flags)(dw::FLAG_800 | dw::HORIZONTAL), float_t x = 0.0f, float_t y = 0.0f, + float_t width = 128.0f, float_t height = 20.0f, const char* name = "slider"); + + inline void SetParams(float_t value, float_t min, float_t max, + float_t a5, float_t step, float_t step_fast) { + scroll_bar->SetParams(value, min, max, a5, step, step_fast); + } + + inline void SetValue(float_t value) { + scroll_bar->SetValue(value); + } }; } diff --git a/src/ReDIVA/game_state.cpp b/src/ReDIVA/game_state.cpp index 2099dffd..1ffaadf1 100644 --- a/src/ReDIVA/game_state.cpp +++ b/src/ReDIVA/game_state.cpp @@ -1397,7 +1397,7 @@ bool SubGameState::DataTestMot::Init() { } bool SubGameState::DataTestMot::Ctrl() { - return task_data_init_check_state(); + return false; } bool SubGameState::DataTestMot::Dest() { diff --git a/src/ReDIVA/pv_game/pv_game.cpp b/src/ReDIVA/pv_game/pv_game.cpp index 9b517aad..c8fbb2aa 100644 --- a/src/ReDIVA/pv_game/pv_game.cpp +++ b/src/ReDIVA/pv_game/pv_game.cpp @@ -4287,7 +4287,7 @@ void pv_game::set_osage_init(const pv_game_chara& chr) { } for (const pv_db_pv_osage_init& i : pv->osage_init) { - int32_t motion_id = aft_mot_db->get_motion_id(i.motion.c_str()); + uint32_t motion_id = aft_mot_db->get_motion_id(i.motion.c_str()); if (motion_id == -1) continue; @@ -4497,11 +4497,11 @@ bool pv_game::unload() { data.field_2D8A0 = true; for (auto& i : data.auth_3d) - i.second.unload_id(rctx_ptr); + i.second.unload(rctx_ptr); for (auto& i : data.field_2DA08) for (auto& j : i.auth_3d_ids) - j.unload_id(rctx_ptr); + j.unload(rctx_ptr); if (data.field_2DAC8) for (std::string& i : data.auth_3d_categories) diff --git a/src/ReDIVA/pv_game/pv_game.hpp b/src/ReDIVA/pv_game/pv_game.hpp index 015f21e2..a80851c1 100644 --- a/src/ReDIVA/pv_game/pv_game.hpp +++ b/src/ReDIVA/pv_game/pv_game.hpp @@ -478,7 +478,7 @@ struct struc_14 { int32_t type; pv_difficulty difficulty; int32_t edition; - uint32_t pv; + int32_t pv; int8_t field_10; int8_t field_11; int8_t field_12; diff --git a/src/ReDIVA/pv_game/pv_game_pv_data.cpp b/src/ReDIVA/pv_game/pv_game_pv_data.cpp index 893d07f5..7562076a 100644 --- a/src/ReDIVA/pv_game/pv_game_pv_data.cpp +++ b/src/ReDIVA/pv_game/pv_game_pv_data.cpp @@ -576,7 +576,7 @@ bool pv_game_pv_data::dsc_ctrl(float_t delta_time, int64_t curr_time, if (!diff) break; - int32_t motion_id = diff->get_motion_or_default(chara_id, motion_index).id; + uint32_t motion_id = diff->get_motion_or_default(chara_id, motion_index).id; if (pv_game_get()->data.pv) motion_id = pv_game_get()->data.pv->get_chrmot_motion_id(rob_chr->chara_id, rob_chr->chara_index, diff->get_motion_or_default(chara_id, motion_index)); @@ -1018,7 +1018,7 @@ bool pv_game_pv_data::dsc_ctrl(float_t delta_time, int64_t curr_time, frame_speed = 1.0f; value = clamp_def(value, 0.0f, 1.0f); - int32_t motion_id; + uint32_t motion_id; const pv_db_pv_difficulty* diff = pv_game->data.pv->get_difficulty( sub_14013C8C0()->difficulty, sub_14013C8C0()->edition); if (diff) { @@ -2065,17 +2065,17 @@ void pv_game_pv_data::find_change_fields() { switch (pv_branch_mode) { case 0: - change_field_branch_fail.push_back({ time, data[0] }); - change_field_branch_success.push_back({ time, data[0] }); + change_field_branch_fail.push_back(time, data[0]); + change_field_branch_success.push_back(time, data[0]); if (!branch) change_field_branch_time = 10000LL * time; break; case 1: - change_field_branch_fail.push_back({ time, data[0] }); + change_field_branch_fail.push_back(time, data[0]); branch = true; break; case 2: - change_field_branch_success.push_back({ time, data[0] }); + change_field_branch_success.push_back(time, data[0]); branch = true; break; } @@ -2317,7 +2317,7 @@ void pv_game_pv_data::find_set_motion(const pv_db_pv_difficulty* diff) { if (frame != -0.0f && (float_t)frame_int != frame) frame = (float_t)(frame < 0.0f ? frame_int - 1 : frame_int); - int32_t motion_id = diff->get_motion_or_default(i, j.index).id; + uint32_t motion_id = diff->get_motion_or_default(i, j.index).id; if (pv_game_get()->data.pv) { rob_chara* rob_chr = playdata.rob_chr; if (rob_chr) diff --git a/src/ReDIVA/pv_game/pv_game_pv_data.hpp b/src/ReDIVA/pv_game/pv_game_pv_data.hpp index 4bb54c6f..1bc1122f 100644 --- a/src/ReDIVA/pv_game/pv_game_pv_data.hpp +++ b/src/ReDIVA/pv_game/pv_game_pv_data.hpp @@ -120,7 +120,7 @@ enum dsc_ft_func { struct pv_play_data_set_motion { float_t frame_speed; - int32_t motion_id; + uint32_t motion_id; float_t frame; float_t blend_duration; bool blend; diff --git a/src/ReDIVA/render.cpp b/src/ReDIVA/render.cpp index d7d18ae3..fde30d31 100644 --- a/src/ReDIVA/render.cpp +++ b/src/ReDIVA/render.cpp @@ -49,6 +49,7 @@ #include "data_test/auth_2d_test.hpp" #include "data_test/auth_3d_test.hpp" #include "data_test/glitter_test.hpp" +#include "data_test/motion_test.hpp" #include "data_test/stage_test.hpp" #include "pv_game/pv_game.hpp" #include "game_state.hpp" @@ -579,6 +580,7 @@ static render_context* render_context_load() { auth_3d_test_window_init(); dtm_aet_init(); dtm_stg_init(); + motion_test_init(); task_data_test_glitter_particle_init(); Glitter::glt_particle_manager->bone_data = aft_bone_data; @@ -1208,6 +1210,7 @@ static void render_context_dispose(render_context* rctx) { light_param_data_storage::unload(); task_data_test_glitter_particle_free(); + motion_test_free(); dtm_stg_free(); dtm_aet_free(); auth_3d_test_window_free(); diff --git a/src/ReDIVA/x_pv_game.cpp b/src/ReDIVA/x_pv_game.cpp index 3ee64b53..5599014f 100644 --- a/src/ReDIVA/x_pv_game.cpp +++ b/src/ReDIVA/x_pv_game.cpp @@ -212,7 +212,7 @@ struct dof_cam { std::vector focus_range; std::vector fuzzing_range; std::vector ratio; - std::vector> enable_frame; + prj::vector_pair enable_frame; int32_t frame; bool enable; @@ -858,7 +858,7 @@ void x_pv_game_camera::unload() { if (state != 20) return; - id.unload_id(rctx_ptr); + id.unload(rctx_ptr); auth_3d_data_unload_category(category.hash_murmurhash); state = 0; } @@ -1224,7 +1224,7 @@ void x_pv_game_effect::unload() { for (x_pv_game_song_effect& i : song_effect) for (x_pv_game_song_effect_auth_3d& j : i.auth_3d) { - j.id.unload_id(rctx_ptr); + j.id.unload(rctx_ptr); j.id = {}; } @@ -1583,7 +1583,7 @@ void x_pv_game_chara_effect::unload() { if (!j.category.str.size()) continue; - j.id.unload_id(rctx_ptr); + j.id.unload(rctx_ptr); auth_3d_data_unload_category(j.category.hash_murmurhash); object_storage_unload_set(j.object_set.hash_murmurhash); } @@ -2146,7 +2146,7 @@ int64_t x_pv_game_dsc_data::find_pv_end() { return max_def(pv_end_time, end_time); } -void x_pv_game_dsc_data::find_stage_effects(std::vector>& stage_effects) { +void x_pv_game_dsc_data::find_stage_effects(prj::vector_pair& stage_effects) { int32_t pv_branch_mode = 0; int32_t time = -1; int32_t prev_time = -1; @@ -2164,7 +2164,7 @@ void x_pv_game_dsc_data::find_stage_effects(std::vector 9) - stage_effects.push_back({ (int64_t)time * 10000, stage_effect }); + stage_effects.push_back((int64_t)time * 10000, stage_effect); prev_time = time; i++; } @@ -3875,7 +3875,7 @@ void x_pv_game_stage::unload() { return; for (std::pair i : auth_3d_ids) - i.second.unload_id(rctx_ptr); + i.second.unload(rctx_ptr); auth_3d_ids.clear(); @@ -4405,9 +4405,9 @@ bool x_pv_game::Ctrl() { x_pv_bar_beat_data* bar_beat_data = 0; int32_t beat_counter = 0; - std::vector> miku_disp; - std::vector> set_motion; - std::vector> set_playdata; + prj::vector_pair miku_disp; + prj::vector_pair set_motion; + prj::vector_pair set_playdata; int32_t time = -1; int32_t frame = -1; @@ -4429,16 +4429,16 @@ bool x_pv_game::Ctrl() { state[chara_id].disp = (int32_t)data[1] == 1; if (state[chara_id].disp) state[chara_id].disp_time = time; - miku_disp.push_back({ time, i.data_offset }); + miku_disp.push_back(time, i.data_offset); } break; case DSC_X_SET_MOTION: { int32_t chara_id = (int32_t)data[0]; state[chara_id].set_motion_time = time; state[chara_id].set_motion_data_offset = i.data_offset; - set_motion.push_back({ time, i.data_offset }); + set_motion.push_back(time, i.data_offset); } break; case DSC_X_SET_PLAYDATA: { - set_playdata.push_back({ time, i.data_offset }); + set_playdata.push_back(time, i.data_offset); } break; } } @@ -4730,7 +4730,7 @@ bool x_pv_game::Ctrl() { for (int32_t& i : effchrpv_rob_mot_ids) { char buf[0x100]; sprintf_s(buf, sizeof(buf), "PV826_OST_P%d_00", i + 1); - int32_t motion_id = aft_mot_db->get_motion_id(buf); + uint32_t motion_id = aft_mot_db->get_motion_id(buf); rob_chara* rob_chr = rob_chara_array_get(rob_chara_ids[i]); rob_chr->set_motion_id(motion_id, 0.0f, 0.0f, false, false, MOTION_BLEND_CROSS, aft_bone_data, aft_mot_db); @@ -4966,7 +4966,7 @@ void x_pv_game::Basic() { dof_cam_data.fuzzing_range.push_back(pv.f2.fuzzing_range); dof_cam_data.ratio.push_back(pv.f2.ratio); if (dof_cam_data.enable != enable) { - dof_cam_data.enable_frame.push_back({ frame, enable }); + dof_cam_data.enable_frame.push_back(frame, enable); dof_cam_data.enable = enable; } dof_cam_data.frame = frame; @@ -5271,7 +5271,7 @@ static void mot_write_motion(mot_data_bake* bake) { char buf[0x200]; sprintf_s(buf, sizeof(buf), "PV826_OST_P%d_00", bake->performer); - int32_t motion_id = aft_mot_db->get_motion_id(buf); + uint32_t motion_id = aft_mot_db->get_motion_id(buf); size_t motion_index = -1; const motion_set_info* set_info = bake_pv826_set_info; @@ -5643,7 +5643,7 @@ bool x_pv_game::Unload() { i = -1; } - light_auth_3d_id.unload_id(rctx_ptr); + light_auth_3d_id.unload(rctx_ptr); light_auth_3d_id = {}; @@ -6339,7 +6339,7 @@ static bool x_pv_game_dsc_process(x_pv_game* a1, int64_t curr_time) { frame = 0.0f; } - int32_t motion_id = -1; + uint32_t motion_id = -1; int32_t chara_id = 0; for (pvpp_chara& i : pv_data.play_param->chara) { if (chara_id++ != a1->chara_id) @@ -8091,7 +8091,7 @@ static void x_pv_game_split_auth_3d_hrc_material_list(x_pv_game* xpvgm, handler->obj_id_data.reserve(set->obj_num); for (uint32_t j = 0; j < obj_num_new; j++) - handler->obj_id_data.push_back({ obj_data_new[j].id, obj_num + j }); + handler->obj_id_data.push_back(obj_data_new[j].id, obj_num + j); uint32_t _obj_num = obj_num + obj_num_new; handler->vertex_buffer_num = _obj_num; @@ -8153,7 +8153,7 @@ static void x_pv_game_split_auth_3d_hrc_material_list(x_pv_game* xpvgm, x_pv_game_split_auth_3d_hrc_obj_bone& bone_vertices = bones_vertices[l]; const char* bone_name = bone_array[bone_vertices.index].name; - hrc_bones.push_back({ bone_name, &bone_array[bone_vertices.index] }); + hrc_bones.push_back(bone_name, &bone_array[bone_vertices.index]); int32_t node_index = obj_hrc->get_node_index(bone_name); while (node_index >= 0) { @@ -9231,7 +9231,7 @@ static void x_pv_game_split_auth_3d_material_list(x_pv_game* xpvgm, auto elem = object_material_list.find(i); if (elem == object_material_list.end()) { - object_material_list.push_back({ i, {} }); + object_material_list.push_back(i, {}); elem = object_material_list.end() - 1; } elem->second.push_back(k); @@ -9251,7 +9251,7 @@ static void x_pv_game_split_auth_3d_material_list(x_pv_game* xpvgm, if (j.id.check_not_empty() && j.id.check_loaded()) { auth_3d* auth = j.id.get_auth_3d(); if (auth && auth->material_list.size() && auth->object.size()) - stage_data_effect_auth_3ds.push_back({ j.id, {} }); + stage_data_effect_auth_3ds.push_back(j.id, {}); } } @@ -9262,7 +9262,7 @@ static void x_pv_game_split_auth_3d_material_list(x_pv_game* xpvgm, if (k.id.check_not_empty() && k.id.check_loaded()) { auth_3d* auth = k.id.get_auth_3d(); if (auth && auth->material_list.size() && auth->object.size()) - stage_data_change_effect_auth_3ds.push_back({ k.id, {} }); + stage_data_change_effect_auth_3ds.push_back(k.id, {}); } } @@ -9287,7 +9287,7 @@ static void x_pv_game_split_auth_3d_material_list(x_pv_game* xpvgm, if (!(j.flags & (AUTH_3D_MATERIAL_LIST_BLEND_COLOR | AUTH_3D_MATERIAL_LIST_EMISSION))) continue; - i.second.push_back({ j.hash, {} }); + i.second.push_back(j.hash, {}); material_list_data& data = i.second.back().second; x_pv_game_split_auth_3d_material_list(j, auth->play_control.size, data); @@ -9308,7 +9308,7 @@ static void x_pv_game_split_auth_3d_material_list(x_pv_game* xpvgm, if (!(j.flags & (AUTH_3D_MATERIAL_LIST_BLEND_COLOR | AUTH_3D_MATERIAL_LIST_EMISSION))) continue; - i.second.push_back({ j.hash, {} }); + i.second.push_back(j.hash, {}); material_list_data& data = i.second.back().second; x_pv_game_split_auth_3d_material_list(j, auth->play_control.size, data); @@ -9485,7 +9485,7 @@ static void pv_game_dsc_data_find_set_motion(x_pv_game* xpvgm) { if (v61 != -0.0f && (float_t)frame_int != v61) v61 = (float_t)(v61 < 0.0f ? frame_int - 1 : frame_int); - int32_t motion_id = -1; + uint32_t motion_id = -1; if (i >= 0 && i < play_param->chara.size()) { pvpp_chara& chara = play_param->chara[i]; if (j.motion_index > 0 && j.motion_index <= chara.motion.size()) { diff --git a/src/ReDIVA/x_pv_game.hpp b/src/ReDIVA/x_pv_game.hpp index 26274a52..de56b9e6 100644 --- a/src/ReDIVA/x_pv_game.hpp +++ b/src/ReDIVA/x_pv_game.hpp @@ -109,7 +109,7 @@ public: struct x_pv_play_data_set_motion { float_t frame_speed; - int32_t motion_id; + uint32_t motion_id; float_t frame; float_t blend_duration; bool blend; @@ -471,7 +471,7 @@ struct x_pv_game_dsc_data { void find_bar_beat(x_pv_bar_beat& bar_beat); void find_change_fields(std::vector& change_fields); int64_t find_pv_end(); - void find_stage_effects(std::vector>& stage_effects); + void find_stage_effects(prj::vector_pair& stage_effects); void reset(); void unload(); }; @@ -493,7 +493,7 @@ struct x_pv_game_data { x_pv_bar_beat bar_beat; int32_t stage_effect_index; int32_t next_stage_effect_bar; - std::vector> stage_effects; + prj::vector_pair stage_effects; x_pv_game_camera camera; x_pv_game_effect effect; x_pv_game_chara_effect chara_effect;